Changed schedule to use james' helper function
This commit is contained in:
parent
7f9642dcd2
commit
dd68f6d945
1 changed files with 33 additions and 29 deletions
|
@ -1106,45 +1106,49 @@ SQL;
|
||||||
|
|
||||||
public static function checkOverlappingShows($show_start, $show_end, $update=false, $instanceId=null)
|
public static function checkOverlappingShows($show_start, $show_end, $update=false, $instanceId=null)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
|
||||||
|
|
||||||
$overlapping = false;
|
$overlapping = false;
|
||||||
|
|
||||||
$con = Propel::getConnection();
|
|
||||||
|
|
||||||
/* If a show is being edited, exclude it from the query
|
/* If a show is being edited, exclude it from the query
|
||||||
* In both cases (new and edit) we only grab shows that
|
* In both cases (new and edit) we only grab shows that
|
||||||
* are scheduled 2 days prior
|
* are scheduled 2 days prior
|
||||||
*/
|
*/
|
||||||
//$se = $show_end->format('Y-m-d H:i:s');
|
//$se = $show_end->format('Y-m-d H:i:s');
|
||||||
if ($update) {
|
if ($update) {
|
||||||
$stmt = $con->prepare("SELECT id, starts, ends FROM {$CC_CONFIG['showInstances']}
|
$sql = <<<SQL
|
||||||
where (ends <= :show_end1
|
SELECT id,
|
||||||
or starts <= :show_end2)
|
starts,
|
||||||
and date(starts) >= (date(:show_end3) - INTERVAL '2 days')
|
ends
|
||||||
and modified_instance = false and id != :instanceId order by ends");
|
FROM cc_show_instances
|
||||||
|
WHERE (ends <= :show_end1
|
||||||
$stmt->execute(array(
|
OR starts <= :show_end2)
|
||||||
|
AND date(starts) >= (date(:show_end3) - INTERVAL '2 days')
|
||||||
|
AND modified_instance = FALSE
|
||||||
|
AND id != :instanceId
|
||||||
|
ORDER BY ends
|
||||||
|
SQL;
|
||||||
|
$rows = Application_Common_Database::prepareAndExecute($sql, array(
|
||||||
':show_end1' => $show_end->format('Y-m-d H:i:s'),
|
':show_end1' => $show_end->format('Y-m-d H:i:s'),
|
||||||
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
||||||
':show_end3' => $show_end->format('Y-m-d H:i:s'),
|
':show_end3' => $show_end->format('Y-m-d H:i:s'),
|
||||||
':instanceId' => $instanceId
|
':instanceId' => $instanceId
|
||||||
));
|
), 'all');
|
||||||
} else {
|
} else {
|
||||||
$stmt = $con->prepare("SELECT id, starts, ends FROM
|
$sql = <<<SQL
|
||||||
{$CC_CONFIG['showInstances']}
|
SELECT id,
|
||||||
where (ends <= :show_end1 or starts <= :show_end2)
|
starts,
|
||||||
and date(starts) >= (date(:show_end3) - INTERVAL '2 days')
|
ends
|
||||||
and modified_instance = false order by ends");
|
FROM cc_show_instances
|
||||||
|
WHERE (ends <= :show_end1
|
||||||
|
OR starts <= :show_end2)
|
||||||
|
AND date(starts) >= (date(:show_end3) - INTERVAL '2 days')
|
||||||
|
AND modified_instance = FALSE
|
||||||
|
ORDER BY ends
|
||||||
|
SQL;
|
||||||
|
|
||||||
$stmt->execute(array(
|
$rows = Application_Common_Database::prepareAndExecute($sql, array(
|
||||||
':show_end1' => $show_end->format('Y-m-d H:i:s'),
|
':show_end1' => $show_end->format('Y-m-d H:i:s'),
|
||||||
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
':show_end2' => $show_end->format('Y-m-d H:i:s'),
|
||||||
':show_end3' => $show_end->format('Y-m-d H:i:s')
|
':show_end3' => $show_end->format('Y-m-d H:i:s')), 'all');
|
||||||
));
|
|
||||||
}
|
}
|
||||||
$rows = $stmt->fetchAll();
|
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$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'));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue