diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index 5b6e4f7d9..37a81f5f6 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -254,8 +254,20 @@ class Application_Service_HistoryService $timezoneUTC = new DateTimeZone("UTC"); $timezoneLocal = new DateTimeZone($this->timezone); + $boolCast = array(); + foreach ($fields as $index=>$field) { + + if ($field["type"] == TEMPLATE_BOOLEAN) { + $boolCast[] = $field["name"]; + } + } + //need to display the results in the station's timezone. foreach ($rows as $index => &$result) { + + foreach ($boolCast as $name) { + $result[$name] = (bool) $result[$name]; + } $dateTime = new DateTime($result["starts"], $timezoneUTC); $dateTime->setTimezone($timezoneLocal); @@ -1019,7 +1031,8 @@ class Application_Service_HistoryService $columns[] = array( "sTitle"=> $label, "mDataProp"=> $key, - "sClass"=> "his_{$key}" + "sClass"=> "his_{$key}", + "sDataType"=> $field["type"] ); } diff --git a/airtime_mvc/public/js/airtime/playouthistory/historytable.js b/airtime_mvc/public/js/airtime/playouthistory/historytable.js index 5719d7d61..f4daa185b 100644 --- a/airtime_mvc/public/js/airtime/playouthistory/historytable.js +++ b/airtime_mvc/public/js/airtime/playouthistory/historytable.js @@ -96,6 +96,7 @@ var AIRTIME = (function(AIRTIME) { function aggregateHistoryTable() { var oTable, $historyTableDiv = $historyContentDiv.find("#history_table_aggregate"), + columns, fnRowCallback; fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { @@ -104,7 +105,7 @@ var AIRTIME = (function(AIRTIME) { nRow.setAttribute('url-edit', editUrl); }; - var columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns')); + columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns')); oTable = $historyTableDiv.dataTable( { @@ -133,18 +134,42 @@ var AIRTIME = (function(AIRTIME) { function itemHistoryTable() { var oTable, $historyTableDiv = $historyContentDiv.find("#history_table_list"), - fnRowCallback; + columns, + fnRowCallback, + booleans = {}, + i, c; - var columns = JSON.parse(localStorage.getItem('datatables-historyitem-aoColumns')); + columns = JSON.parse(localStorage.getItem('datatables-historyitem-aoColumns')); + + for (i in columns) { + + c = columns[i]; + if (c["sDataType"] === "boolean") { + booleans[c["mDataProp"]] = c["sTitle"]; + } + } fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { var editUrl = baseUrl+"playouthistory/edit-list-item/format/json/id/"+aData.history_id, - deleteUrl = baseUrl+"playouthistory/delete-list-item/format/json/id/"+aData.history_id; + deleteUrl = baseUrl+"playouthistory/delete-list-item/format/json/id/"+aData.history_id, + emptyCheckBox = String.fromCharCode(parseInt(2610, 16)), + checkedCheckBox = String.fromCharCode(parseInt(2612, 16)), + b, + text, + $nRow = $(nRow); nRow.setAttribute('url-edit', editUrl); nRow.setAttribute('url-delete', deleteUrl); + + for (b in booleans) { + + text = aData[b] ? checkedCheckBox : emptyCheckBox; + text = text + " " + booleans[b]; + + $nRow.find(".his_"+b).html(text); + } }; - + oTable = $historyTableDiv.dataTable( { "aoColumns": columns,