CC-5090: Unscheduled tracks are still marked at Scheduled in linked show

This commit is contained in:
denise 2013-05-14 10:58:06 -04:00
parent bfd525395a
commit c173744929
4 changed files with 48 additions and 8 deletions

View file

@ -1322,7 +1322,9 @@ SQL;
}
}
public static function setIsScheduled($p_scheduleItem, $p_status, $p_fileId=null) {
public static function setIsScheduled($p_scheduleItem, $p_status,
$p_fileId=null, $instanceId=null) {
if (is_null($p_fileId)) {
$fileId = Application_Model_Schedule::GetFileId($p_scheduleItem);
} else {
@ -1331,7 +1333,8 @@ SQL;
$file = self::RecallById($fileId);
$updateIsScheduled = false;
if (!is_null($fileId) && !in_array($fileId, Application_Model_Schedule::getAllFutureScheduledFiles())) {
if (!is_null($fileId) && !in_array($fileId,
Application_Model_Schedule::getAllFutureScheduledFiles($instanceId))) {
$file->_file->setDbIsScheduled($p_status)->save();
$updateIsScheduled = true;
}
@ -1341,15 +1344,23 @@ SQL;
public static function updatePastFilesIsScheduled()
{
/* Retrieve files that are scheduled in the past OR that belong
* to a show that has ended. We need to check if the show has
* ended incase a track is overbooked, since that alone will
* indicate the show is still scheduled in the future
*/
$sql = <<<SQL
SELECT file_id FROM cc_schedule
WHERE ends < now() at time zone 'UTC'
SELECT s.file_id, s.instance_id FROM cc_schedule AS s
LEFT JOIN cc_show_instances AS i
ON s.instance_id = i.id
WHERE s.ends < now() at time zone 'UTC'
OR i.ends < now() at time zone 'UTC'
SQL;
$files = Application_Common_Database::prepareAndExecute($sql);
foreach ($files as $file) {
if (!is_null($file['file_id'])) {
self::setIsScheduled(null, false, $file['file_id']);
self::setIsScheduled(null, false, $file['file_id'], $file['instance_id']);
}
}