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;
 }
Exemple #2
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;
 }