got basic data tables working need to add show selection, redraw etc
This commit is contained in:
parent
448d9b9e90
commit
7c783536db
|
@ -60,17 +60,18 @@ class ListenerstatController extends Zend_Controller_Action
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||||
|
$headScript = $this->view->headScript();
|
||||||
|
AirtimeTableView::injectTableJavaScriptDependencies($headScript, $baseUrl, $CC_CONFIG['airtime_version']);
|
||||||
Zend_Layout::getMvcInstance()->assign('parent_page', 'Analytics');
|
Zend_Layout::getMvcInstance()->assign('parent_page', 'Analytics');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.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/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/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/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/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.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
|
||||||
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/dataTables.colReorder.min.css?'.$CC_CONFIG['airtime_version']);
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'js/datatables/plugin/TableTools-2.1.5/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
|
$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']);
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
|
||||||
|
|
||||||
|
@ -99,7 +100,6 @@ class ListenerstatController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function getDataAction(){
|
public function getDataAction(){
|
||||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest());
|
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest());
|
||||||
|
|
||||||
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format(DEFAULT_TIMESTAMP_FORMAT),
|
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format(DEFAULT_TIMESTAMP_FORMAT),
|
||||||
$endsDT->format(DEFAULT_TIMESTAMP_FORMAT));
|
$endsDT->format(DEFAULT_TIMESTAMP_FORMAT));
|
||||||
$this->_helper->json->sendJson($data);
|
$this->_helper->json->sendJson($data);
|
||||||
|
@ -114,9 +114,8 @@ class ListenerstatController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
public function getAllShowData(){
|
public function getAllShowData(){
|
||||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest());
|
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),
|
$data = Application_Model_ListenerStat::getAllShowDataPointsWithinRange($startsDT->format(DEFAULT_TIMESTAMP_FORMAT),
|
||||||
$endsDT->format(DEFAULT_TIMESTAMP_FORMAT),$show_id);
|
$endsDT->format(DEFAULT_TIMESTAMP_FORMAT));
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +123,7 @@ class ListenerstatController extends Zend_Controller_Action
|
||||||
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest());
|
list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest());
|
||||||
$show_id = $this->getRequest()->getParam("show_id", null);
|
$show_id = $this->getRequest()->getParam("show_id", null);
|
||||||
$data = Application_Model_ListenerStat::getAllShowDataPointsWithinRange($startsDT->format(DEFAULT_TIMESTAMP_FORMAT),
|
$data = Application_Model_ListenerStat::getAllShowDataPointsWithinRange($startsDT->format(DEFAULT_TIMESTAMP_FORMAT),
|
||||||
$endsDT->format(DEFAULT_TIMESTAMP_FORMAT),$show_id);
|
$endsDT->format(DEFAULT_TIMESTAMP_FORMAT));
|
||||||
$this->_helper->json->sendJson($data);
|
$this->_helper->json->sendJson($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Application_Form_ShowListenerStat extends Zend_Form_SubForm
|
||||||
|
{
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->setDecorators(array(
|
||||||
|
array('ViewScript', array('viewScript' => 'form/daterange.phtml'))
|
||||||
|
));
|
||||||
|
|
||||||
|
// Add start date element
|
||||||
|
$startDate = new Zend_Form_Element_Text('his_date_start');
|
||||||
|
$startDate->class = 'input_text';
|
||||||
|
$startDate->setRequired(true)
|
||||||
|
->setLabel(_('Date Start:'))
|
||||||
|
->setValue(date("Y-m-d"))
|
||||||
|
->setFilters(array('StringTrim'))
|
||||||
|
->setValidators(array(
|
||||||
|
'NotEmpty',
|
||||||
|
array('date', false, array('YYYY-MM-DD'))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$startDate->setAttrib('alt', 'date');
|
||||||
|
$this->addElement($startDate);
|
||||||
|
|
||||||
|
// Add start time element
|
||||||
|
$startTime = new Zend_Form_Element_Text('his_time_start');
|
||||||
|
$startTime->class = 'input_text';
|
||||||
|
$startTime->setRequired(true)
|
||||||
|
->setValue('00:00')
|
||||||
|
->setFilters(array('StringTrim'))
|
||||||
|
->setValidators(array(
|
||||||
|
'NotEmpty',
|
||||||
|
array('date', false, array('HH:mm')),
|
||||||
|
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$startTime->setAttrib('alt', 'time');
|
||||||
|
$this->addElement($startTime);
|
||||||
|
|
||||||
|
// Add end date element
|
||||||
|
$endDate = new Zend_Form_Element_Text('his_date_end');
|
||||||
|
$endDate->class = 'input_text';
|
||||||
|
$endDate->setRequired(true)
|
||||||
|
->setLabel(_('Date End:'))
|
||||||
|
->setValue(date("Y-m-d"))
|
||||||
|
->setFilters(array('StringTrim'))
|
||||||
|
->setValidators(array(
|
||||||
|
'NotEmpty',
|
||||||
|
array('date', false, array('YYYY-MM-DD'))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$endDate->setAttrib('alt', 'date');
|
||||||
|
$this->addElement($endDate);
|
||||||
|
|
||||||
|
// Add end time element
|
||||||
|
$endTime = new Zend_Form_Element_Text('his_time_end');
|
||||||
|
$endTime->class = 'input_text';
|
||||||
|
$endTime->setRequired(true)
|
||||||
|
->setValue('01:00')
|
||||||
|
->setFilters(array('StringTrim'))
|
||||||
|
->setValidators(array(
|
||||||
|
'NotEmpty',
|
||||||
|
array('date', false, array('HH:mm')),
|
||||||
|
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$endTime->setAttrib('alt', 'time');
|
||||||
|
$this->addElement($endTime);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<div id="showlistenerstat_content" class="alpha-block padded">
|
||||||
|
<H2><?php echo _("Listeners")?></H2>
|
||||||
|
<div id="date_form" style="float:left; margin:0px 0px">
|
||||||
|
<h3 style="padding-left: 0px">Date Range</h3>
|
||||||
|
<?php echo $this->date_form; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>
|
||||||
|
<table cellspacing="0" cellpadding="0" style="" id="show_stats_datatable" class="datatable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php echo _("Show Name") ?></th>
|
||||||
|
<th><?php echo _("Air Date") ?></th>
|
||||||
|
<th><?php echo _("Average Listeners")?></th>
|
||||||
|
<th><?php echo _("Maximum Number of Listeners")?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div style="clear: both;"></div>
|
||||||
|
</div>
|
|
@ -6,28 +6,23 @@ $(document).ready(function() {
|
||||||
timeEndId = "#his_time_end",
|
timeEndId = "#his_time_end",
|
||||||
show_id = "#his_show_filter";
|
show_id = "#his_show_filter";
|
||||||
|
|
||||||
console.log(show_id);
|
|
||||||
// set width dynamically
|
// set width dynamically
|
||||||
var width = $("#showlistenerstat_content").width();
|
var width = $("#showlistenerstat_content").width();
|
||||||
width = width * .91;
|
width = width * .91;
|
||||||
addDatePicker();
|
addDatePicker();
|
||||||
|
|
||||||
|
showlistenerstat_content.find("#his_submit").click(function(){
|
||||||
showlistenerstat_content.find("#sb_submit").click(function(){
|
// var show_id = $("#sb_show_filter").val();
|
||||||
var show_id = $("#sb_show_filter").val();
|
|
||||||
console.log(show_id);
|
|
||||||
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||||
var start = oRange.start;
|
var start = oRange.start;
|
||||||
var end = oRange.end;
|
var end = oRange.end;
|
||||||
|
brokeDataTable();
|
||||||
getShowData(start, end, show_id);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function getShowData(startTimestamp, endTimestamp, show_id) {
|
function getShowData(startTimestamp, endTimestamp, show_id) {
|
||||||
// get data
|
// get data
|
||||||
$.get(baseUrl+'Listenerstat/get-show-data', {start: startTimestamp, end: endTimestamp, show_id: show_id}, function(data) {
|
$.get(baseUrl+'Listenerstat/get-all-show-data', {start: startTimestamp, end: endTimestamp }, function(data) {
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -60,52 +55,50 @@ function addDatePicker() {
|
||||||
showlistenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
showlistenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStartEnd() {
|
||||||
|
|
||||||
|
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function showSummaryList(start, end) {
|
||||||
|
var url = baseUrl+"playouthistory/show-history-feed",
|
||||||
|
data = {
|
||||||
|
format: "json",
|
||||||
|
start: start,
|
||||||
|
end: end
|
||||||
|
};
|
||||||
|
|
||||||
|
$.post(url, data, function(json) {
|
||||||
|
drawShowList(json);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function brokeDataTable() {
|
function brokeDataTable() {
|
||||||
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||||
var start = oRange.start;
|
var start = oRange.start;
|
||||||
var end = oRange.end;
|
var end = oRange.end;
|
||||||
var show_id = $("#sb_show_filter").val();
|
var show_id = $("#sb_show_filter").val();
|
||||||
var dt = $('#show_stats_datatable');
|
var dt = $('#show_stats_datatable');
|
||||||
|
info = getStartEnd();
|
||||||
dt.dataTable({
|
dt.dataTable({
|
||||||
"bProcessing": true,
|
|
||||||
"bServerSide": true,
|
|
||||||
"sAjaxSource": baseUrl + "Listenerstat/get-show-data",
|
|
||||||
"fnServerParams": function (aoData) {
|
|
||||||
aoData.push({start: start, end: end, show_id: show_id});
|
|
||||||
},
|
|
||||||
"fnAddData": function (sSource, aoData, fnCallback) {
|
|
||||||
$.ajax({
|
|
||||||
"dataType": 'json',
|
|
||||||
"type": "POST",
|
|
||||||
"url": sSource,
|
|
||||||
"data": aoData,
|
|
||||||
"success": fnCallback
|
|
||||||
});
|
|
||||||
},
|
|
||||||
"aoColumns": [
|
"aoColumns": [
|
||||||
/* first name */ {"sName": "show", "mDataProp": "show"},
|
/* first name */ {"sName": "show", "mDataProp": "show"},
|
||||||
/* air date */ {"sName": "time", "mDataProp": "time"},
|
/* air date */ {"sName": "time", "mDataProp": "time"},
|
||||||
/* last name */ {"sName": "average_number_of_listeners", "mDataProp": "average_number_of_listeners"},
|
/* last name */ {"sName": "average_number_of_listeners", "mDataProp": "average_number_of_listeners"},
|
||||||
/* last name */ {"sName": "max_number_of_listeners", "mDataProp": "max_number_of_listeners"},
|
/* last name */ {"sName": "maximum_number_of_listeners", "mDataProp": "maximum_number_of_listeners"}],
|
||||||
/* del button */ {
|
"sAjaxSource": baseUrl+'Listenerstat/get-all-show-data',
|
||||||
"sName": "null as delete",
|
"sAjaxDataProp": "",
|
||||||
"bSearchable": false,
|
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
||||||
"bSortable": false,
|
aoData.push({"start": start, "end": end});
|
||||||
"mDataProp": "delete"
|
$.ajax( {
|
||||||
}
|
"dataType": 'json',
|
||||||
],
|
"type": "POST",
|
||||||
"bJQueryUI": true,
|
"url": sSource,
|
||||||
"bAutoWidth": false,
|
"data": {"start": start, "end": end},
|
||||||
"bLengthChange": false,
|
"success": fnCallback
|
||||||
"oLanguage": getDatatablesStrings({
|
} );
|
||||||
"sEmptyTable": $.i18n._("No Show Records Found"),
|
},
|
||||||
"sEmptyTable": $.i18n._("No show found"),
|
|
||||||
"sZeroRecords": $.i18n._("No show statistics found"),
|
|
||||||
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ users"),
|
|
||||||
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 users"),
|
|
||||||
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total users)"),
|
|
||||||
}),
|
|
||||||
"sDom": '<"H"lf<"dt-process-rel"r>><"#user_list_inner_wrapper"t><"F"ip>'
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue