2012-03-08 18:30:56 +01:00
|
|
|
<?php
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
class PlayouthistoryController extends Zend_Controller_Action
|
2012-03-08 18:30:56 +01:00
|
|
|
{
|
2012-07-16 03:17:13 +02:00
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
2012-07-11 00:53:06 +02:00
|
|
|
$ajaxContext
|
2012-07-16 03:17:13 +02:00
|
|
|
->addActionContext('playout-history-feed', 'json')
|
2013-07-09 00:00:02 +02:00
|
|
|
->addActionContext('edit-aggregate-item', 'json')
|
2012-07-16 03:17:13 +02:00
|
|
|
->initContext();
|
2012-10-19 17:09:34 +02:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
|
|
|
public function indexAction()
|
2012-07-11 00:53:06 +02:00
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-07-11 00:53:06 +02:00
|
|
|
$request = $this->getRequest();
|
2012-10-19 17:09:34 +02:00
|
|
|
|
|
|
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
2012-03-12 11:47:25 +01:00
|
|
|
|
|
|
|
//default time is the last 24 hours.
|
|
|
|
$now = time();
|
|
|
|
$from = $request->getParam("from", $now - (24*60*60));
|
|
|
|
$to = $request->getParam("to", $now);
|
|
|
|
|
|
|
|
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
|
|
|
|
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
|
|
|
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
|
|
|
|
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
|
|
|
|
|
|
|
$form = new Application_Form_DateRange();
|
|
|
|
$form->populate(array(
|
|
|
|
'his_date_start' => $start->format("Y-m-d"),
|
|
|
|
'his_time_start' => $start->format("H:i"),
|
|
|
|
'his_date_end' => $end->format("Y-m-d"),
|
|
|
|
'his_time_end' => $end->format("H:i")
|
|
|
|
));
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
$this->view->date_form = $form;
|
|
|
|
|
2013-01-14 22:00:38 +01:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
2012-07-16 03:17:13 +02:00
|
|
|
|
|
|
|
$offset = date("Z") * -1;
|
|
|
|
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
|
2013-01-14 22:00:38 +01:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
|
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'js/datatables/plugin/TableTools/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
|
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
|
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
|
2012-07-11 00:53:06 +02:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
|
|
|
public function playoutHistoryFeedAction()
|
2012-07-11 00:53:06 +02:00
|
|
|
{
|
2012-07-16 03:17:13 +02:00
|
|
|
$request = $this->getRequest();
|
2012-07-11 00:53:06 +02:00
|
|
|
$current_time = time();
|
2012-07-16 03:17:13 +02:00
|
|
|
|
|
|
|
$params = $request->getParams();
|
|
|
|
|
|
|
|
$starts_epoch = $request->getParam("start", $current_time - (60*60*24));
|
2012-07-11 00:53:06 +02:00
|
|
|
$ends_epoch = $request->getParam("end", $current_time);
|
2012-07-16 03:17:13 +02:00
|
|
|
|
|
|
|
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
|
|
|
|
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
|
|
|
|
2013-07-03 22:02:17 +02:00
|
|
|
$historyService = new Application_Service_HistoryService();
|
2013-07-09 00:00:02 +02:00
|
|
|
$r = $historyService->getAggregateView($startsDT, $endsDT, $params);
|
2013-07-03 22:00:48 +02:00
|
|
|
|
2012-07-11 00:53:06 +02:00
|
|
|
$this->view->sEcho = $r["sEcho"];
|
|
|
|
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
|
|
|
|
$this->view->iTotalRecords = $r["iTotalRecords"];
|
2012-07-16 03:17:13 +02:00
|
|
|
$this->view->history = $r["history"];
|
2012-07-11 00:53:06 +02:00
|
|
|
}
|
2013-07-09 00:00:02 +02:00
|
|
|
|
|
|
|
public function editAggregateItemAction()
|
|
|
|
{
|
|
|
|
$file_id = $this->_getParam('id');
|
|
|
|
|
|
|
|
$historyService = new Application_Service_HistoryService();
|
|
|
|
$form = $historyService->makeHistoryFileForm($file_id);
|
|
|
|
|
|
|
|
$this->view->form = $form;
|
|
|
|
$this->view->dialog = $this->view->render('form/edit-history-file.phtml');
|
|
|
|
|
|
|
|
unset($this->view->form);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function updateAggregateItemAction()
|
|
|
|
{
|
|
|
|
$file_id = $this->_getParam('id');
|
|
|
|
|
|
|
|
$historyService = new Application_Service_HistoryService();
|
|
|
|
$historyService->editPlayedFile($file_id);
|
|
|
|
}
|
2012-10-19 17:09:34 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
}
|