Generating reports programatically

Discussion in 'Integration' started by richard_fullbrook984, Jun 17, 2016.

  1. ENTS

    ENTS aMember Pro Customer

    Joined:
    Aug 13, 2015
    Messages:
    10
    I'm looking to generate the New vs Existing report in the code and use it for some other processing. I can see that Am_Reports exists, but I'm not sure how to get the report I need.

    I'm looking to do something like this:
    PHP:
    $report = new Am_Report_NewVsExisting();
    $report->setInterval($start$stop);
    $report->setQuantity(new Am_Quantity_Day());
    $result $report->generate();
    Any help is appreciated.
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    How do you plan to use result of this report?
  3. ENTS

    ENTS aMember Pro Customer

    Joined:
    Aug 13, 2015
    Messages:
    10
    We have some reports that we want on the dashboard and some we want sent to our email every so often at different intervals. Right now aMember Pro only allows us to send all reports at the same time over email, so I was going to write a small plugin to support the per-report settings.
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Here is example of code to run report:
    PHP:
    class_exists('Am_Report'true);
    require_once 
    'Am/Report/Standard.php';

    $r Am_Report_Abstract::createById('newVsExisting');
    $r->applyConfigForm(new Am_Mvc_Request(array(
        
    'period' => Am_Interval::PERIOD_THIS_WEEK_FROM_SUN,
        
    'quant' => 'day')));
    $result $r->getReport();
    foreach (
    $r->getOutput($result) as $output) {
        echo 
    $output->render();
    }

Share This Page