CC-4072: Improve the check overlapping shows function

-done
This commit is contained in:
denise 2012-07-05 11:24:49 -04:00
parent 771974433b
commit 4441bf18b7
1 changed files with 4 additions and 3 deletions

View File

@ -922,11 +922,11 @@ class Application_Model_Schedule {
if ($update) { if ($update) {
$sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." $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"; and id != ".$instanceId. " order by ends";
} else { } else {
$sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." $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); $rows = $con->query($sql);
@ -934,7 +934,8 @@ class Application_Model_Schedule {
$start = new DateTime($row["starts"], new DateTimeZone('UTC')); $start = new DateTime($row["starts"], new DateTimeZone('UTC'));
$end = new DateTime($row["ends"], 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; $overlapping = true;
break; break;
} }