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

@ -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;
}
}