CC-3174 : show builder

made sure the column reordering/visibility selection works with
modified show header/footer rows (their td spans the entire tr)
This commit is contained in:
Naomi Aro 2012-01-26 15:21:04 +01:00
parent ecaebbeb67
commit b0c3bace1c
9 changed files with 261 additions and 70 deletions

View file

@ -43,7 +43,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.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.ColReorderResize.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.FixedColumns.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript');

View file

@ -19,10 +19,6 @@ class ShowbuilderController extends Zend_Controller_Action
$this->_helper->actionStack('library', 'library');
$this->_helper->actionStack('builder', 'showbuilder');
//user is allowed to schedule this show.
//if ($user->isAdmin() || $user->isHost($show_instance->getShowId())) {
//}
}
public function builderAction() {
@ -33,9 +29,9 @@ class ShowbuilderController extends Zend_Controller_Action
$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.ColReorderResize.js','text/javascript');
//$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/airtime/showbuilder/builder.js','text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
@ -46,23 +42,21 @@ class ShowbuilderController extends Zend_Controller_Action
public function builderFeedAction() {
$request = $this->getRequest();
$current_time = microtime(true);
$current_time = time();
$starts_epoch = $request->getParam("start", $current_time);
//default ends is 24 hours after starts.
$ends_epoch = $request->getParam("end", $current_time + (60*60*24));
$startsDT = DateTime::createFromFormat("U.u", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U.u", $ends_epoch, new DateTimeZone("UTC"));
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$scheduled_items = Application_Model_Schedule::GetItems($startsDT->format("Y-m-d H:i:s.u"), $endsDT->format("Y-m-d H:i:s.u"), false);
Logging::log("showbuilder starts {$startsDT->format("Y-m-d H:i:s")}");
Logging::log("showbuilder ends {$endsDT->format("Y-m-d H:i:s")}");
foreach ($scheduled_items as &$item) {
$itemStartsDT = DateTime::createFromFormat("Y-m-d H:i:s.u", $item["starts"], new DateTimeZone("UTC"));
$itemEndsDT = DateTime::createFromFormat("Y-m-d H:i:s.u", $item["ends"], new DateTimeZone("UTC"));
}
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT);
$this->view->schedule = $scheduled_items;
$this->view->schedule = $showBuilder->GetItems();
}
public function scheduleAction() {

View file

@ -309,10 +309,15 @@ class Application_Model_Schedule {
$sql = "SELECT DISTINCT
showt.name, showt.color, showt.background_color,
si.starts, si.ends, si.time_filled, si.record, si.rebroadcast,
sched.starts, sched.ends,
ft.track_title, ft.artist_name, ft.album_title, ft.length
showt.name AS show_name, showt.color AS show_color, showt.background_color AS show_background_colour,
si.starts AS si_starts, si.ends AS si_ends, si.time_filled AS si_time_filled,
si.record AS si_record, si.rebroadcast AS si_rebroadcast, si.id AS si_id,
sched.starts AS sched_starts, sched.ends AS sched_ends,
ft.track_title AS file_track_title, ft.artist_name AS file_artist_name,
ft.album_title AS file_album_title, ft.length AS file_length
FROM
((cc_schedule AS sched JOIN cc_files AS ft ON (sched.file_id = ft.id)
@ -320,7 +325,11 @@ class Application_Model_Schedule {
JOIN cc_show AS showt ON (showt.id = si.show_id)
)
ORDER BY sched.starts;";
WHERE si.starts >= '{$p_startDateTime}' AND si.ends <= '{$p_endDateTime}'
ORDER BY si.starts, sched.starts;";
//Logging::log($sql);
$rows = $CC_DBC->GetAll($sql);
return $rows;

View file

@ -0,0 +1,111 @@
<?php
class Application_Model_ShowBuilder {
private $timezone;
private $startDT;
private $endDT;
private $defaultRowArray = array(
"header" => false,
"footer" => false,
"empty" => false,
"instance" => "",
"starts" => "",
"ends" => "",
"title" => ""
);
/*
* @param DateTime $p_startsDT
* @param DateTime $p_endsDT
*/
public function __construct($p_startDT, $p_endDT) {
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
}
private function makeFooterRow() {
$row = $this->defaultRowArray;
$row["footer"] = true;
return $row;
}
private function makeHeaderRow($p_item) {
$row = $this->defaultRowArray;
$showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC"));
$showStartDT->setTimezone(new DateTimeZone($this->timezone));
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
$row["header"] = true;
$row["starts"] = $showStartDT->format("Y-m-d H:i");
$row["ends"] = $showEndDT->format("Y-m-d H:i");
$row["title"] = $p_item["show_name"];
return $row;
}
private function makeScheduledItemRow($p_item) {
$row = $this->defaultRowArray;
if (isset($p_item["sched_starts"])) {
$schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC"));
$schedStartDT->setTimezone(new DateTimeZone($this->timezone));
$schedEndDT = new DateTime($p_item["sched_ends"], new DateTimeZone("UTC"));
$schedEndDT->setTimezone(new DateTimeZone($this->timezone));
$row["instance"] = $p_item["si_id"];
$row["starts"] = $schedStartDT->format("Y-m-d H:i:s");
$row["ends"] = $schedEndDT->format("Y-m-d H:i:s");
$row["title"] = $p_item["file_track_title"];
}
//show is empty
else {
$row["empty"] = true;
}
return $row;
}
public function GetItems() {
$current_id = -1;
$display_items = array();
$scheduled_items = Application_Model_Schedule::GetScheduleDetailItems($this->startDT->format("Y-m-d H:i:s"), $this->endDT->format("Y-m-d H:i:s"));
foreach ($scheduled_items as $item) {
//make a header row.
if ($current_id !== $item["si_id"]) {
//make a footer row.
if ($current_id !== -1) {
$display_items[] = $this->makeFooterRow();
}
$display_items[] = $this->makeHeaderRow($item);
$current_id = $item["si_id"];
}
//make a normal data row.
$display_items[] = $this->makeScheduledItemRow($item);
}
//make the last footer if there were any scheduled items.
if (count($scheduled_items) > 0) {
$display_items[] = $this->makeFooterRow();
}
return $display_items;
}
}