diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 233128433..b668f13e5 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -263,6 +263,15 @@ SQL; global $CC_CONFIG; $con = Propel::getConnection(); + $p_start_str = $p_start->format("Y-m-d H:i:s"); + $p_end_str = $p_end->format("Y-m-d H:i:s"); + + + //We need to search 24 hours before and after the show times so that that we + //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_end = $p_end->add(new DateInterval("PT24H"))->format("Y-m-d H:i:s"); + $templateSql = <<= '{$p_start}' - AND sched.starts < '{$p_end}') - OR (sched.ends > '{$p_start}' - AND sched.ends <= '{$p_end}') - OR (sched.starts <= '{$p_start}' - AND sched.ends >= '{$p_end}')) + AND ((sched.starts >= '{$p_track_start}' + AND sched.starts < '{$p_track_end}') + OR (sched.ends > '{$p_track_start}' + AND sched.ends <= '{$p_track_end}') + OR (sched.starts <= '{$p_track_start}' + AND sched.ends >= '{$p_track_end}')) ) SQL; @@ -315,12 +324,12 @@ SQL; $streamJoin = <<= '{$p_start}' - AND sched.starts < '{$p_end}') - OR (sched.ends > '{$p_start}' - AND sched.ends <= '{$p_end}') - OR (sched.starts <= '{$p_start}' - AND sched.ends >= '{$p_end}')) + AND ((sched.starts >= '{$p_track_start}' + AND sched.starts < '{$p_track_end}') + OR (sched.ends > '{$p_track_start}' + AND sched.ends <= '{$p_track_end}') + OR (sched.starts <= '{$p_track_start}' + AND sched.ends >= '{$p_track_end}')) ) LEFT JOIN cc_subjs AS sub ON (ws.creator_id = sub.id) SQL; @@ -358,12 +367,12 @@ SELECT showt.name AS show_name, JOIN cc_show AS showt ON (showt.id = si.show_id) WHERE si.modified_instance = FALSE $showPredicate - AND ((si.starts >= '{$p_start}' - AND si.starts < '{$p_end}') - OR (si.ends > '{$p_start}' - AND si.ends <= '{$p_end}') - OR (si.starts <= '{$p_start}' - AND si.ends >= '{$p_end}')) + AND ((si.starts >= '{$p_start_str}' + AND si.starts < '{$p_end_str}') + OR (si.ends > '{$p_start_str}' + AND si.ends <= '{$p_end_str}') + OR (si.starts <= '{$p_start_str}' + AND si.ends >= '{$p_end_str}')) ORDER BY si_starts, sched_starts; SQL; diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 90a67a1d6..8436c3011 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -423,8 +423,7 @@ class Application_Model_ShowBuilder } $scheduled_items = Application_Model_Schedule::GetScheduleDetailItems( - $this->startDT->format("Y-m-d H:i:s"), $this->endDT->format( - "Y-m-d H:i:s"), $shows); + $this->startDT, $this->endDT, $shows); for ($i = 0, $rows = count($scheduled_items); $i < $rows; $i++) {