Ejemplo n.º 1
0
 function getUsersReport()
 {
     $res = $this->getDi()->db->select("SELECT status as ARRAY_KEY, COUNT(*) as `count`\n            FROM ?_user\n            GROUP BY status");
     $total = array_sum($res);
     for ($i = 0; $i <= 2; $i++) {
         $res[$i]['count'] = (int) @$res[$i]['count'];
     }
     $active_paid = $this->getDi()->db->selectCell("\n            SELECT COUNT(DISTINCT user_id) AS active\n            FROM ?_invoice_payment");
     $active_free = $res[1]['count'] - $active_paid;
     $result = new Am_Report_Result();
     $result->setTitle("Users Breakdown");
     $result->addPoint(new Am_Report_Point(0, "Pending"))->addValue(0, (int) $res[0]['count']);
     $result->addPoint(new Am_Report_Point(1, "Active"))->addValue(0, (int) $active_paid);
     $result->addPoint(new Am_Report_Point(4, "Active(free)"))->addValue(0, (int) $active_free);
     $result->addPoint(new Am_Report_Point(2, "Expired"))->addValue(0, (int) $res[2]['count']);
     $result->addLine(new Am_Report_Line(0, "# of users"));
     $output = new Am_Report_Graph_Bar($result);
     $output->setSize(400, 250);
     return $output;
 }
Ejemplo n.º 2
0
 /** @return Am_Report_Result */
 public function getReport(Am_Report_Result $result = null, Am_Report_Shift $shift = null)
 {
     $needPropagation = true;
     if ($result === null) {
         $needPropagation = false;
         $result = new Am_Report_Result();
         $result->setTitle($this->getTitle());
     }
     $result->setQuantity($this->getQuantity());
     foreach ($this->getLines() as $line) {
         $result->addLine($line, $shift);
     }
     $this->runQuery();
     while ($r = $this->fetchNextRow()) {
         $k = $r[self::POINT_FLD];
         unset($r[self::POINT_FLD]);
         $result->addValues($k, $this->getQuantity()->getLabel($k), $r, $shift);
     }
     if ($needPropagation) {
         $lines = $result->getLines();
         foreach ($result->getPoints() as $point) {
             foreach ($lines as $line) {
                 if (is_null($point->getValue($line->getkey()))) {
                     $point->addValue($line->getkey(), '');
                 }
             }
         }
     }
     $result->sortPoints();
     return $result;
 }
Ejemplo n.º 3
0
 /** @return Am_Report_Result */
 public function getReport(Am_Report_Result $result = null)
 {
     if ($result === null) {
         $result = new Am_Report_Result();
         $result->setTitle($this->getTitle());
     }
     $result->setQuantity($this->getQuantity());
     foreach ($this->getLines() as $line) {
         $result->addLine($line);
     }
     $this->runQuery();
     while ($r = $this->fetchNextRow()) {
         $k = $r[self::POINT_FLD];
         unset($r[self::POINT_FLD]);
         $result->addValues($k, $this->getQuantity()->getLabel($k), $r);
     }
     return $result;
 }
Ejemplo n.º 4
0
 protected function getReportUsers()
 {
     require_once 'Am/Report.php';
     require_once 'Am/Report/Standard.php';
     $res = $this->getDi()->db->select("SELECT status as ARRAY_KEY, COUNT(*) as `count`\n            FROM ?_user\n            GROUP BY status");
     $total = array_sum($res);
     for ($i = 0; $i <= 2; $i++) {
         $res[$i]['count'] = (int) @$res[$i]['count'];
     }
     $active_paid = $this->getDi()->db->selectCell("\n            SELECT COUNT(DISTINCT p.user_id) AS active\n            FROM ?_invoice_payment p \n                INNER JOIN ?_user u USING (user_id)\n            WHERE u.status = 1\n        ");
     $active_free = $res[1]['count'] - $active_paid;
     $result = new Am_Report_Result();
     $result->setTitle(___('Users Breakdown'));
     $result->addPoint(new Am_Report_Point(0, ___('Pending')))->addValue(0, (int) $res[0]['count']);
     $result->addPoint(new Am_Report_Point(1, ___('Active')))->addValue(0, (int) $active_paid);
     $result->addPoint(new Am_Report_Point(4, ___('Active(free)')))->addValue(0, (int) $active_free);
     $result->addPoint(new Am_Report_Point(2, ___('Expired')))->addValue(0, (int) $res[2]['count']);
     $result->addLine(new Am_Report_Line(0, ___('# of users')));
     $output = new Am_Report_Graph_Bar($result);
     $output->setSize('100%', 250);
     return $output;
 }