-filter by using instance id instead of show id

Conflicts:
	airtime_mvc/application/models/Schedule.php
This commit is contained in:
Martin Konecny 2013-04-30 13:35:28 -04:00
parent af7b2d5347
commit bb36556bb9
6 changed files with 17 additions and 11 deletions

View File

@ -269,7 +269,9 @@ class ShowbuilderController extends Zend_Controller_Action
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); $startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter); $opts = array("myShows" => $my_shows,
"showFilter" => $show_filter,
"showInstanceFilter" => $show_filter);
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts); $showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
$data = $showBuilder->getItems(); $data = $showBuilder->getItems();

View File

@ -309,13 +309,11 @@ SQL;
* @return array $scheduledItems * @return array $scheduledItems
* *
*/ */
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows) public static function GetScheduleDetailItems($p_start, $p_end, $p_shows, $p_show_instances)
{ {
$p_start_str = $p_start->format("Y-m-d H:i:s"); $p_start_str = $p_start->format("Y-m-d H:i:s");
$p_end_str = $p_end->format("Y-m-d H:i:s"); $p_end_str = $p_end->format("Y-m-d H:i:s");
$paramMap = array();
//We need to search 24 hours before and after the show times so that that we //We need to search 24 hours before and after the show times so that that we
//capture all of the show's contents. //capture all of the show's contents.
$p_track_start= $p_start->sub(new DateInterval("PT24H"))->format("Y-m-d H:i:s"); $p_track_start= $p_start->sub(new DateInterval("PT24H"))->format("Y-m-d H:i:s");
@ -355,7 +353,7 @@ SQL;
AND sched.ends >= :fj_ts_6)) AND sched.ends >= :fj_ts_6))
) )
SQL; SQL;
$map = array( $paramMap = array(
":fj_ts_1" => $p_track_start, ":fj_ts_1" => $p_track_start,
":fj_ts_2" => $p_track_end, ":fj_ts_2" => $p_track_end,
":fj_ts_3" => $p_track_start, ":fj_ts_3" => $p_track_start,
@ -363,8 +361,6 @@ SQL;
":fj_ts_5" => $p_track_start, ":fj_ts_5" => $p_track_start,
":fj_ts_6" => $p_track_end, ":fj_ts_6" => $p_track_end,
); );
$paramMap = $paramMap + $map;
$filesSql = str_replace("%%columns%%", $filesSql = str_replace("%%columns%%",
$filesColumns, $filesColumns,
@ -426,6 +422,8 @@ SQL;
$showPredicate = " AND show_id IN (".implode(",", $params).")"; $showPredicate = " AND show_id IN (".implode(",", $params).")";
$paramMap = $paramMap + $map; $paramMap = $paramMap + $map;
} else if (count($p_show_instances) > 0) {
$showPredicate = " AND si_id IN (".implode(",", $p_show_instances).")";
} }
$sql = <<<SQL $sql = <<<SQL

View File

@ -437,15 +437,18 @@ class Application_Model_ShowBuilder
$display_items = array(); $display_items = array();
$shows = array(); $shows = array();
$showInstance = array();
if ($this->opts["myShows"] === 1) { if ($this->opts["myShows"] === 1) {
$shows = $this->getUsersShows(); $shows = $this->getUsersShows();
} elseif ($this->opts["showFilter"] !== 0) { } elseif ($this->opts["showFilter"] !== 0) {
$shows[] = $this->opts["showFilter"]; $shows[] = $this->opts["showFilter"];
} elseif ($this->opts["showInstanceFilter"] !== 0) {
$showInstance[] = $this->opts["showInstanceFilter"];
} }
$scheduled_items = Application_Model_Schedule::GetScheduleDetailItems( $scheduled_items = Application_Model_Schedule::GetScheduleDetailItems(
$this->startDT, $this->endDT, $shows); $this->startDT, $this->endDT, $shows, $showInstance);
for ($i = 0, $rows = count($scheduled_items); $i < $rows; $i++) { for ($i = 0, $rows = count($scheduled_items); $i < $rows; $i++) {

View File

@ -180,7 +180,8 @@ function buildScheduleDialog (json, instance_id) {
fnServer.start = json.start; fnServer.start = json.start;
fnServer.end = json.end; fnServer.end = json.end;
fnServer.ops = {}; fnServer.ops = {};
fnServer.ops.showFilter = instance_id; fnServer.ops.showFilter = 0;
fnServer.ops.showInstanceFilter = instance_id;
fnServer.ops.myShows = 0; fnServer.ops.myShows = 0;
AIRTIME.library.libraryInit(); AIRTIME.library.libraryInit();
@ -354,8 +355,8 @@ $(document).ready(function() {
callback = function() { callback = function() {
$.post(oItems.schedule.url, {format: "json", id: data.showId}, function(json){ $.post(oItems.schedule.url, {format: "json", id: data.id}, function(json){
buildScheduleDialog(json, data.showId); buildScheduleDialog(json, data.id);
}); });
}; };

View File

@ -359,6 +359,7 @@ var AIRTIME = (function(AIRTIME){
if (mod.fnServerData.hasOwnProperty("ops")) { if (mod.fnServerData.hasOwnProperty("ops")) {
aoData.push( { name: "myShows", value: mod.fnServerData.ops.myShows} ); aoData.push( { name: "myShows", value: mod.fnServerData.ops.myShows} );
aoData.push( { name: "showFilter", value: mod.fnServerData.ops.showFilter} ); aoData.push( { name: "showFilter", value: mod.fnServerData.ops.showFilter} );
aoData.push( { name: "showInstanceFilter", value: mod.fnServerData.ops.showInstanceFilter} );
} }
$.ajax({ $.ajax({

View File

@ -266,6 +266,7 @@ AIRTIME = (function(AIRTIME) {
if (fn.hasOwnProperty("ops")) { if (fn.hasOwnProperty("ops")) {
data["myShows"] = fn.ops.myShows; data["myShows"] = fn.ops.myShows;
data["showFilter"] = fn.ops.showFilter; data["showFilter"] = fn.ops.showFilter;
data["showFilter"] = fn.ops.showInstanceFilter;
} }
$.ajax( { $.ajax( {