From 0a851f3c964cb9c71cea186dfee633580335430c Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 23 Aug 2012 17:41:05 -0400 Subject: [PATCH] CC-4263: Calendar: Can create one show contains another show (overlapping) -fixed --- airtime_mvc/application/models/Schedule.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 43986c2e8..70e820666 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1062,13 +1062,21 @@ SQL; $con = Propel::getConnection(); + /* If a show is being edited, exclude it from the query + * In both cases (new and edit) we only grab shows that + * are scheduled 2 days prior + */ if ($update) { $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." - where ends <= '{$show_end->format('Y-m-d H:i:s')}' + where (ends <= '{$show_end->format('Y-m-d H:i:s')}' + or starts <= '{$show_end->format('Y-m-d H:i:s')}') + and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days') and modified_instance = false and id != ".$instanceId. " order by ends"; } else { $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." - where ends <= '{$show_end->format('Y-m-d H:i:s')}' + where (ends <= '{$show_end->format('Y-m-d H:i:s')}' + or starts <= '{$show_end->format('Y-m-d H:i:s')}') + and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days') and modified_instance = false order by ends"; } $rows = $con->query($sql);