diff --git a/airtime_mvc/application/configs/navigation.php b/airtime_mvc/application/configs/navigation.php index 851cae36b..0eec09124 100644 --- a/airtime_mvc/application/configs/navigation.php +++ b/airtime_mvc/application/configs/navigation.php @@ -29,6 +29,13 @@ $pages = array( 'action' => 'index', 'resource' => 'library' ), + array( + 'label' => 'Show Builder', + 'module' => 'default', + 'controller' => 'Showbuilder', + 'action' => 'index', + 'resource' => 'showbuilder' + ), array( 'label' => 'Calendar', 'module' => 'default', @@ -67,7 +74,7 @@ $pages = array( 'action' => 'stream-setting' ), array( - 'label' => + 'label' => Application_Model_Preference::GetPlanLevel() == 'disabled'?'Support Settings':'Station Information Settings', 'module' => 'default', 'controller' => 'Preference', diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 0d499c9d6..2e52ca019 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -232,8 +232,8 @@ class LibraryController extends Zend_Controller_Action public function contentsAction() { - $post = $this->getRequest()->getPost(); - $datatables = Application_Model_StoredFile::searchFilesForPlaylistBuilder($post); + $params = $this->getRequest()->getParams(); + $datatables = Application_Model_StoredFile::searchFilesForPlaylistBuilder($params); //format clip lengh to 1 decimal foreach($datatables["aaData"] as &$data){ diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 5da2c875f..89f36eeac 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -26,13 +26,8 @@ class ShowbuilderController extends Zend_Controller_Action $request = $this->getRequest(); $baseUrl = $request->getBaseUrl(); - $this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript'); - $this->view->headScript()->appendScript("var serverTimezoneOffset = ".date("Z")."; //in seconds"); - //$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript'); - //$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js','text/javascript'); - //$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js','text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedHeader.js','text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js','text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css'); @@ -64,12 +59,44 @@ class ShowbuilderController extends Zend_Controller_Action $request = $this->getRequest(); - $show_instance_id = $request->getParam("sid", 0); - $scheduled_item_id = $request->getParam("time", 0); - $scheduled_start = $request->getParam("start", 0); + $instance = $request->getParam("instance", null); + $id = $request->getParam("id", null); + $starts_epoch = $request->getParam("start", null); + $file_id = $request->getParam("file", null); - //snap to previous/next default. - $scheduled_type = $request->getParam("type", 0); + $startDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); + //invalid request + if (is_null($start)) { + return; + } + + //updating a scheduled item. + if (isset($id)) { + $schedItem = CcScheduleQuery::create()->findPK($id); + $duration = $schedItem->getDbEnds('U') - $schedItem->getDbStarts('U'); + + $endDT = DateTime::createFromFormat("U", $starts_epoch + $duration, new DateTimeZone("UTC")); + + $oldInstance = $schedItem->getDbInstanceId(); + + if ($instance === $oldInstance) { + CcScheduleQuery::create() + ->filterByDbInstanceId($oldInstance) + ->find(); + } + //file was dragged out of the show into another show or scheduled not within a show. + else { + } + + + } + else { + $schedItem = new CcSchedule(); + } + + $schedItem->setDbStarts($startDT); + $schedItem->setDbEnds($endDT); + $schedItem->save(); } } \ No newline at end of file diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php new file mode 100644 index 000000000..3a3391eb1 --- /dev/null +++ b/airtime_mvc/application/models/Scheduler.php @@ -0,0 +1,70 @@ +propSched = new CcSchedule(); + } + else { + $this->propSched = CcScheduleQuery::create()->findPK($id); + } + } + + /* + public function findScheduledItems($starts, $ends) { + + CcScheduleQuery::create() + ->filterByDbStarts(array('min' => $starts->format('Y-m-d H:i:s'), 'max' => $ends->format('Y-m-d H:i:s'))) + ->find(); + } + */ + + public function addScheduledItem($starts, $duration, $adjustSched = true) { + + } + + /* + * @param DateTime $starts + */ + public function updateScheduledItem($p_newStarts, $p_adjustSched = true) { + + $origStarts = $this->propSched->getDbStarts(null); + + $diff = $origStarts->diff($p_newStarts); + + //item is scheduled further in future + if ($diff->format("%R") === "+") { + + CcScheduleQuery::create() + ->filterByDbStarts($this->propSched->getDbStarts(), Criteria::GREATER_THAN) + ->filterByDbId($this->propSched->getDbId(), Criteria::NOT_EQUAL) + ->find(); + + } + //item has been scheduled earlier + else { + CcScheduleQuery::create() + ->filterByDbStarts($this->propSched->getDbStarts(), Criteria::GREATER_THAN) + ->filterByDbId($this->propSched->getDbId(), Criteria::NOT_EQUAL) + ->find(); + } + } + + public function removeScheduledItem($adjustSched = true) { + + if ($adjustSched === true) { + $duration = $this->propSched->getDbEnds('U') - $this->propSched->getDbStarts('U'); + + CcScheduleQuery::create() + ->filterByDbInstanceId() + ->filterByDbStarts() + ->find(); + } + + $this->propSched->delete(); + } +} \ No newline at end of file diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 507224548..8724b6e50 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -14,7 +14,9 @@ class Application_Model_ShowBuilder { "id" => "", "instance" => "", "starts" => "", + "startsUnix" => null, "ends" => "", + "endsUnix" => null, "runtime" => "", "title" => "", "creator" => "", @@ -73,7 +75,10 @@ class Application_Model_ShowBuilder { $row["header"] = true; $row["starts"] = $showStartDT->format("Y-m-d H:i"); + $row["startsUnix"] = $showStartDT->format("U"); $row["ends"] = $showEndDT->format("Y-m-d H:i"); + $row["endsUnix"] = $showEndDT->format("U"); + $row["duration"] = $showEndDT->format("U") - $showStartDT->format("U"); $row["title"] = $p_item["show_name"]; return $row; @@ -94,7 +99,10 @@ class Application_Model_ShowBuilder { $row["id"] = $p_item["sched_id"]; $row["instance"] = $p_item["si_id"]; $row["starts"] = $schedStartDT->format("H:i:s"); + $row["startsUnix"] = $schedStartDT->format("U"); $row["ends"] = $schedEndDT->format("H:i:s"); + $row["endsUnix"] = $schedEndDT->format("U"); + $row["duration"] = $schedEndDT->format("U") - $schedStartDT->format("U"); $row["runtime"] = $this->formatDuration($runtime); $row["title"] = $p_item["file_track_title"]; $row["creator"] = $p_item["file_artist_name"]; diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 3e42e4e41..1963738af 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -804,6 +804,8 @@ class Application_Model_StoredFile { $sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"]; } + Logging::log($sql); + $results = $CC_DBC->getAll($sql); if(!isset($totalDisplayRows)) { diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index fac705b37..b99dbc89a 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -273,7 +273,7 @@ function saveNumEntriesSetting() { * Use user preference for number of entries to show */ function getNumEntriesPreference(data) { - return parseInt(data.libraryInit.numEntries); + return parseInt(data.libraryInit.numEntries, 10); } function groupAdd() { @@ -457,11 +457,12 @@ function createDataTable(data) { dTable = $('#library_display').dataTable( { "bProcessing": true, "bServerSide": true, - "sAjaxSource": "/Library/contents/format/json", + "sAjaxSource": "/Library/contents", "fnServerData": function ( sSource, aoData, testCallback ) { + aoData.push( { name: "format", value: "json"} ); $.ajax( { "dataType": 'json', - "type": "POST", + "type": "GET", "url": sSource, "data": aoData, "success": testCallback @@ -490,7 +491,7 @@ function createDataTable(data) { "sSearch": "" }, "iDisplayLength": getNumEntriesPreference(data), - "bStateSave": true, + // R = ColReorder, C = ColVis, see datatables doc for others "sDom": 'Rlfr<"H"C<"library_toolbar">>t<"F"ip>', "oColVis": { @@ -499,10 +500,6 @@ function createDataTable(data) { "aiExclude": [0, 1, 2], "sSize": "css", "bShowAll": true - }, - "oColReorder": { - "aiOrder": [ 0, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], /* code this */ - "iFixedColumns": 3 } }); dTable.fnSetFilteringDelay(350); diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index 38600398a..c0fc7f0a2 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -138,6 +138,9 @@ var fnShowBuilderRowCallback = function ( nRow, aData, iDisplayIndex, iDisplayIn fnPrepareSeparatorRow, node; + //save some info for reordering purposes. + $(nRow).data({aData: aData}); + fnPrepareSeparatorRow = function(sRowContent, sClass) { node = nRow.children[1]; @@ -167,6 +170,12 @@ var fnShowBuilderRowCallback = function ( nRow, aData, iDisplayIndex, iDisplayIn sSeparatorHTML = 'Show Footer'; fnPrepareSeparatorRow(sSeparatorHTML, "show-builder-footer"); } + else if (aData.empty === true) { + + } + else { + $(nRow).attr("id", "sched_"+aData.id); + } return nRow; }; @@ -197,7 +206,7 @@ $(document).ready(function() { oTable = $('#show_builder_table').dataTable( { "aoColumns": [ /* checkbox */ {"mDataProp": "checkbox", "sTitle": "", "sWidth": "25px"}, - // /* scheduled id */{"mDataProp": "id", "sTitle": "id", "bVisible": false, "sWidth": "1px"}, + // /* scheduled id */{"mDataProp": "id", "sTitle": "id"}, // /* instance */{"mDataProp": "instance", "sTitle": "si_id"}, /* starts */{"mDataProp": "starts", "sTitle": "Airtime"}, /* ends */{"mDataProp": "ends", "sTitle": "Off Air"}, @@ -215,6 +224,7 @@ $(document).ready(function() { "bProcessing": true, "bServerSide": true, "bInfo": false, + "bAutoWidth": false, "fnServerData": fnServerData, "fnRowCallback": fnShowBuilderRowCallback, @@ -235,8 +245,6 @@ $(document).ready(function() { "sAjaxSource": "/showbuilder/builder-feed" }); - //new FixedHeader( oTable ); - new FixedColumns( oTable ); $( "#show_builder_datepicker_start" ).datepicker(oBaseDatePickerSettings); @@ -263,10 +271,39 @@ $(document).ready(function() { $( "#show_builder_table" ).sortable({ placeholder: "placeholder show-builder-placeholder", - items: 'tr', - cancel: ".show-builder-header .show-builder-footer", + forceHelperSize: true, + forcePlaceholderSize: true, + items: 'tr:not(.show-builder-header):not(.show-builder-footer)', + //cancel: ".show-builder-header .show-builder-footer", receive: function(event, ui) { var x; + }, + update: function(event, ui) { + var oItemData = ui.item.data("aData"), + oPrevData = ui.item.prev().data("aData"), + oRequestData = {format: "json"}; + + //if prev item is a footer, item is not scheduled into a show. + if (oPrevData.footer === false) { + oRequestData.instance = oPrevData.instance; + } + + //set the start time appropriately + if (oPrevData.header === true) { + oRequestData.start = oPrevData.startsUnix; + } + else { + oRequestData.start = oPrevData.endsUnix; + } + + oRequestData.id = oItemData.id; + oRequestData.duration = oItemData.duration; + + /* + $.post("/showbuilder/schedule", oRequestData, function(json){ + var x; + }); + */ } });