Ejemplo n.º 1
0
 function sendSavedReports(Am_Event $event)
 {
     class_exists('Am_Report', true);
     require_once 'Am/Report/Standard.php';
     foreach ($this->getDi()->adminTable->findBy() as $admin) {
         $frequency = $admin->getPref(Admin::PREF_REPORTS_SEND_FREQUENCY);
         if ($frequency == $event->getId()) {
             $content = '';
             foreach ($this->findByAdminId($admin->pk()) as $report) {
                 $r = Am_Report_Abstract::createById($report->report_id);
                 $r->applyConfigForm(new Am_Request(unserialize($report->request)));
                 $result = $r->getReport();
                 $output = new Am_Report_Text($result);
                 $content .= $report->title . "\n----------------------------\n";
                 $content .= $output->render() . "\n";
             }
             if ($content) {
                 $mail = $this->getDi()->mail;
                 $mail->addTo($admin->email);
                 $mail->setSubject($this->getDi()->config->get('site_title') . ': Reports');
                 $mail->setBodyText($content);
                 $mail->send();
             }
         }
     }
 }
 function indexAction()
 {
     $reports = Am_Report_Abstract::getAvailableReports();
     $defaults = @$this->getSession()->reportDefaults;
     if ($defaults) {
         foreach ($reports as $r) {
             $r->getForm()->setDataSources(array(new HTML_QuickForm2_DataSource_Array($defaults)));
         }
     }
     $this->view->assign('reports', $reports);
     $this->view->display('admin/report.phtml');
 }
Ejemplo n.º 3
0
 public function getReport(Am_Report_Result $result = null, Am_Report_Shift $shift = null)
 {
     $result = parent::getReport($result);
     $origStart = $this->start;
     $origStop = $this->stop;
     foreach ($this->shift as $id) {
         $shift = Am_Report_Shift::create($id, Am_Di::getInstance()->interval->getDuration($this->period));
         if (!in_array($this->period, $shift->getCompatiablePeriods())) {
             continue;
         }
         $diff = '-' . $shift->getDiff();
         $this->setInterval("{$origStart} {$diff}", "{$origStop} {$diff}");
         $result = parent::getReport($result, $shift);
     }
     return $result;
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     $this->title = ___("Affiliate Clicks");
     $this->description = ___("number of affiliate program clicks");
     parent::__construct();
 }
Ejemplo n.º 5
0
 public function exportAction()
 {
     $reportId = $this->getFiltered('report_id');
     $request = unserialize($this->getParam('request'));
     $r = Am_Report_Abstract::createById($reportId);
     $r->applyConfigForm(new Am_Request($request));
     $result = $r->getReport();
     $dat = date('YmdHis');
     $output = new Am_Report_Csv($result);
     $data = $output->render();
     $this->_helper->sendFile->sendData($data, 'text/csv', "amember_reports-{$reportId}-{$dat}.csv");
     throw new Am_Exception_Redirect();
 }
Ejemplo n.º 6
0
 public function _initConfigForm(Am_Form $form)
 {
     parent::_initConfigForm($form);
     $sel = $form->addAdvRadio('type')->setLabel(___('Group By'));
     $sel->loadOptions(array('country' => ___('Country'), 'state' => ___('State')));
     $sel->setValue('country');
 }
Ejemplo n.º 7
0
 public function renderWidgetReport(Am_View $view, $config = null, $invokeArgs = array())
 {
     require_once 'Am/Report.php';
     require_once 'Am/Report/Standard.php';
     $view->enableReports();
     /* @var $savedReport SavedReport */
     $savedReport = $invokeArgs['savedReport'];
     $request = new Am_Request(unserialize($savedReport->request));
     $r = Am_Report_Abstract::createById($savedReport->report_id);
     $r->applyConfigForm($request);
     $result = $r->getReport();
     $result->setTitle($savedReport->title);
     $type = is_null($config) ? 'graph-line' : $config['type'];
     switch ($type) {
         case 'graph-line':
             $output = new Am_Report_Graph_Line($result);
             $output->setSize('100%', 250);
             break;
         case 'graph-bar':
             $output = new Am_Report_Graph_Bar($result);
             $output->setSize('100%', 250);
             break;
         case 'table':
             $output = new Am_Report_Table($result);
             break;
         default:
             throw new Am_Exception_InputError(___('Unknown report display type [%s]', $type));
     }
     return sprintf('<h2>%s</h2><div class="admin-index-report-wrapper"><div class="admin-index-report report-%s">%s</div></div>', $savedReport->title, $savedReport->report_id, $output->render());
 }