From 4441bf18b7d7bbbcd2d893e12ce947ec64b0ad2d Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 5 Jul 2012 11:24:49 -0400 Subject: [PATCH] CC-4072: Improve the check overlapping shows function -done --- airtime_mvc/application/models/Schedule.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index a315478e0..b4c87d0f9 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -922,11 +922,11 @@ class Application_Model_Schedule { if ($update) { $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." - where starts <= '{$show_start->format('Y-m-d H:i:s')}' + where ends <= '{$show_end->format('Y-m-d H:i:s')}' and id != ".$instanceId. " order by ends"; } else { $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." - where starts <= '{$show_start->format('Y-m-d H:i:s')}' order by ends"; + where ends <= '{$show_end->format('Y-m-d H:i:s')}' order by ends"; } $rows = $con->query($sql); @@ -934,7 +934,8 @@ class Application_Model_Schedule { $start = new DateTime($row["starts"], new DateTimeZone('UTC')); $end = new DateTime($row["ends"], new DateTimeZone('UTC')); - if ($show_start->getTimestamp() < $end->getTimestamp()) { + if ($show_start->getTimestamp() < $end->getTimestamp() && + $show_end->getTimestamp() > $start->getTimestamp()) { $overlapping = true; break; }