public function get_liveview($campaign) { date_default_timezone_set('Europe/London'); $time_limit = $this->param('showtime'); $stats = \Model_Dialler_Campaign_Call::find()->where('campaign', $campaign); if (!is_null($time_limit)) { $time_strings = array('10m' => '10 minutes ago', '30m' => '30 minutes ago', '1h' => '1 hour ago', '2h' => '2 hours ago', '6h' => '6 hours ago', '12h' => '12 hours ago', '1d' => '1 day ago', '1w' => '1 week ago'); $stats = $stats->where('date', '>=', date("Y-m-d H:i:s", strtotime($time_strings[$time_limit]))); } else { $stats = $stats->where('date', '>=', date("Y-m-d 08:50:00"))->where('date', '<=', date("Y-m-d 20:10:00")); } $stats = $stats->order_by('date', 'asc')->get(); $calls = array('label' => "Calls Made", 'data' => array()); $answers = array('label' => "Calls Answered", 'data' => array()); foreach ($stats as $stat) { $calls['data'][] = array((int) strtotime($stat->date) * 1000, (int) $stat->calls_made); $answers['data'][] = array((int) strtotime($stat->date) * 1000, (int) $stat->calls_answered); } $this->response(array('calls_made' => $calls, 'calls_answered' => $answers)); }
public function gipltd_log_minute_stats($campaign_id, $set_dialler = FALSE, $connection = null) { date_default_timezone_set('Europe/London'); $connection = is_null($connection) ? "gipltd" : $connection; $campaign_stats = \Goautodial\Model_Vicidial_Campaign_Stats_Gipltd::find(null, array(), $connection)->where('campaign_id', $campaign_id)->get_one(); $delete_early = \DB::query('DELETE FROM dialler_campaign_calls WHERE campaign="' . "GIPLTD_" . $campaign_id . '" DATE(date) < "' + date("Y-m-d H:i-s", strtotime("1 week ago")) + '";'); $add_current = \Model_Dialler_Campaign_Call::forge(array('campaign' => "GIPLTD_" . $campaign_id, 'calls_made' => (int) $campaign_stats->calls_onemin, 'calls_answered' => (int) $campaign_stats->answers_onemin, 'date' => date("Y-m-d H:i-s"))); $add_current->save(); }