From 448d9b9e909ed48c603ba7895719880c6b728c71 Mon Sep 17 00:00:00 2001 From: Robbt Date: Wed, 1 May 2019 20:45:09 -0400 Subject: [PATCH] modified listener stat more --- .../controllers/ListenerstatController.php | 34 ++++++++++---- .../airtime/listenerstat/showlistenerstat.js | 44 ++++++++++++++++--- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/airtime_mvc/application/controllers/ListenerstatController.php b/airtime_mvc/application/controllers/ListenerstatController.php index 5670c08bc..195f98996 100644 --- a/airtime_mvc/application/controllers/ListenerstatController.php +++ b/airtime_mvc/application/controllers/ListenerstatController.php @@ -26,7 +26,6 @@ class ListenerstatController extends Zend_Controller_Action $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->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']); list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request); @@ -62,32 +61,40 @@ class ListenerstatController extends Zend_Controller_Action $request = $this->getRequest(); $baseUrl = Application_Common_OsPath::getBaseDir(); Zend_Layout::getMvcInstance()->assign('parent_page', 'Analytics'); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/listenerstat/showlistenerstat.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $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/listenerstat/showlistenerstat.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/airtime/utilities/utilities.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-2.1.5/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headLink()->appendStylesheet($baseUrl.'js/datatables/plugin/TableTools-2.1.5/css/TableTools.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']); + $user = Application_Model_User::getCurrentUser(); if ($user->isUserType(array(UTYPE_SUPERADMIN, UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $this->view->showAllShows = true; } - $form = new Application_Form_ShowBuilder(); + $data = []; + $this->view->showData = $data; + + $form = new Application_Form_ShowListenerStat(); list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request); $userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone()); $startsDT->setTimezone($userTimezone); $endsDT->setTimezone($userTimezone); $form->populate(array( - 'sb_date_start' => $startsDT->format("Y-m-d"), - 'sb_time_start' => $startsDT->format("H:i"), - 'sb_date_end' => $endsDT->format("Y-m-d"), - 'sb_time_end' => $endsDT->format("H:i") + 'his_date_start' => $startsDT->format("Y-m-d"), + 'his_time_start' => $startsDT->format("H:i"), + 'his_date_end' => $endsDT->format("Y-m-d"), + 'his_time_end' => $endsDT->format("H:i") )); - $this->view->sb_form = $form; + $this->view->date_form = $form; } public function getDataAction(){ @@ -97,6 +104,7 @@ class ListenerstatController extends Zend_Controller_Action $endsDT->format(DEFAULT_TIMESTAMP_FORMAT)); $this->_helper->json->sendJson($data); } + public function getShowDataAction(){ list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest()); $show_id = $this->getRequest()->getParam("show_id", null); @@ -104,6 +112,14 @@ class ListenerstatController extends Zend_Controller_Action $endsDT->format(DEFAULT_TIMESTAMP_FORMAT),$show_id); $this->_helper->json->sendJson($data); } + public function getAllShowData(){ + list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest()); + $show_id = $this->getRequest()->getParam("show_id", null); + $data = Application_Model_ListenerStat::getAllShowDataPointsWithinRange($startsDT->format(DEFAULT_TIMESTAMP_FORMAT), + $endsDT->format(DEFAULT_TIMESTAMP_FORMAT),$show_id); + return $data; + } + public function getAllShowDataAction(){ list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest()); $show_id = $this->getRequest()->getParam("show_id", null); diff --git a/airtime_mvc/public/js/airtime/listenerstat/showlistenerstat.js b/airtime_mvc/public/js/airtime/listenerstat/showlistenerstat.js index ab440c16d..a35afb25e 100644 --- a/airtime_mvc/public/js/airtime/listenerstat/showlistenerstat.js +++ b/airtime_mvc/public/js/airtime/listenerstat/showlistenerstat.js @@ -1,22 +1,27 @@ $(document).ready(function() { showlistenerstat_content = $("#showlistenerstat_content") - dateStartId = "#sb_date_start", - timeStartId = "#sb_time_start", - dateEndId = "#sb_date_end", - timeEndId = "#sb_time_end", - show_id = "#sb_show_filter"; + dateStartId = "#his_date_start", + timeStartId = "#his_time_start", + dateEndId = "#his_date_end", + timeEndId = "#his_time_end", + show_id = "#his_show_filter"; console.log(show_id); // set width dynamically var width = $("#showlistenerstat_content").width(); width = width * .91; + addDatePicker(); + + showlistenerstat_content.find("#sb_submit").click(function(){ var show_id = $("#sb_show_filter").val(); console.log(show_id); var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); var start = oRange.start; var end = oRange.end; + getShowData(start, end, show_id); + }); }); @@ -27,6 +32,34 @@ function getShowData(startTimestamp, endTimestamp, show_id) { }); } +function addDatePicker() { + + oBaseDatePickerSettings = { + dateFormat: 'yy-mm-dd', + //i18n_months, i18n_days_short are in common.js + monthNames: i18n_months, + dayNamesMin: i18n_days_short, + onSelect: function(sDate, oDatePicker) { + $(this).datepicker( "setDate", sDate ); + } + }; + + oBaseTimePickerSettings = { + showPeriodLabels: false, + showCloseButton: true, + closeButtonText: $.i18n._("Done"), + showLeadingZero: false, + defaultTime: '0:00', + hourText: $.i18n._("Hour"), + minuteText: $.i18n._("Minute") + }; + + showlistenerstat_content.find(dateStartId).datepicker(oBaseDatePickerSettings); + showlistenerstat_content.find(timeStartId).timepicker(oBaseTimePickerSettings); + showlistenerstat_content.find(dateEndId).datepicker(oBaseDatePickerSettings); + showlistenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings); +} + function brokeDataTable() { var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); var start = oRange.start; @@ -74,4 +107,5 @@ function brokeDataTable() { }), "sDom": '<"H"lf<"dt-process-rel"r>><"#user_list_inner_wrapper"t><"F"ip>' }); + } \ No newline at end of file