Exemplo n.º 1
0
 public function getGetData()
 {
     $start = Request::get('start', 'int', null, -30);
     $end = Request::get('end', 'int', null, 0);
     $message_id = Request::get('message_id', 'int');
     $tracker = new Tracker();
     $email_sent = $tracker->getHistory(Tracker::getTrackerId('Email Sent'), $start, $end, $message_id);
     $email_bounced = $tracker->getHistory(Tracker::getTrackerId('Email Bounced'), $start, $end, $message_id);
     $email_opened = $tracker->getHistory(Tracker::getTrackerId('Email Opened'), $start, $end, $message_id);
     $data = new ChartData(Time::today() + $start, Time::today() + $end);
     $data->addDataSet($email_sent, 'Sent');
     $data->addDataSet($email_bounced, 'Bounced');
     $data->addDataSet($email_opened, 'Opened');
     $data->setXLabels(array_map('jdtogregorian', range(Time::today() + $start, Time::today() + $end)));
     $data->output();
 }
Exemplo n.º 2
0
 public static function getHistoryAllSubIDs($tracker, $start = -30, $end = 0, $user_id = -1)
 {
     // Start the criteria with tracker id.
     if (is_array($tracker)) {
         $criteria = array('tracker_id' => array('IN', $tracker));
     } else {
         $criteria = array('tracker_id' => $tracker);
     }
     // Filter by date range.
     $start = Time::today() + $start;
     $end = Time::today() + $end;
     $criteria['date'] = array('BETWEEN', $start, $end);
     // Add the user ID if required.
     if ($user_id != -1) {
         $criteria['user_id'] = $user_id;
     }
     // Run the query.
     $results = Database::getInstance()->select('tracker_event', $criteria, array('y' => array('expression' => 'COUNT(*)'), 'x' => 'date', 'set' => 'sub_id'), 'GROUP BY date, sub_id');
     $data = new ChartData($start, $end);
     $data->createDataSets($results);
     return $data->getData();
 }