CC-5074: Editing a linked instance sets incorrect schedule start times

This commit is contained in:
denise 2013-04-30 13:58:03 -04:00
parent 1384c5d39d
commit 4ca60ca676
4 changed files with 21 additions and 13 deletions

View File

@ -634,10 +634,7 @@ class Application_Model_Scheduler
$pstart = microtime(true);
//recalculate the start/end times after the inserted items.
Logging::info($excludeIds);
Logging::info($initalStartDT);
foreach ($followingSchedItems as $item) {
Logging::info($item);
$endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
$item->setDbStarts($nextStartDT);

View File

@ -185,4 +185,10 @@ class CcShowInstances extends BaseCcShowInstances {
return $this->getDbRebroadcast() == 1 ? true : false;
}
public function getLocalStartDateTime()
{
$startDT = $this->getDbStarts(null);
return $startDT->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone()));
}
} // CcShowInstances

View File

@ -69,9 +69,14 @@ class Application_Service_SchedulerService
->filterByDbInstanceId($instanceIds, Criteria::IN)
->find();
foreach ($ccSchedules as $ccSchedule) {
$interval = new DateInterval("PT".$diff."S");
$start = new DateTime($ccSchedule->getDbStarts());
$newStart = $start->add($interval);
$end = new DateTime($ccSchedule->getDbEnds());
$newEnd = $end->add($interval);
$ccSchedule
->setDbStarts($ccSchedule->getDbStarts() + $diff)
->setDbEnds($ccSchedule->getDbEnds() + $diff)
->setDbStarts($newStart->format("Y-m-d H:i:s"))
->setDbEnds($newEnd->format("Y-m-d H:i:s"))
->save();
}
}

View File

@ -52,18 +52,21 @@ class Application_Service_ShowService
//so we can get the original start date and time
$oldCcShow = CcShowQuery::create()
->findPk($showData["add_show_id"]);
$currentShowDay = $oldCcShow->getFirstCcShowDay();
//DateTime in user's local time
$newStartDateTime = new DateTime($showData["add_show_start_date"]." ".
$showData["add_show_start_time"],
new DateTimeZone(Application_Model_Preference::GetTimezone()));
$ccShowInstanceOrig = CcShowInstancesQuery::create()
->findPk($showData["add_show_instance_id"]);
$diff = $this->calculateShowStartDiff($newStartDateTime,
$currentShowDay->getLocalStartDateAndTime());
$ccShowInstanceOrig->getLocalStartDateTime());
if ($diff > 0) {
Application_Service_SchedulerService::updateScheduleStartTime(
array($showData["add_show_instance_id"]), $diff);
}
/****** UPDATE SCHEDULE START TIME ENDS******/
$this->setCcShow($showData);
@ -89,10 +92,7 @@ class Application_Service_ShowService
}
//delete the edited instance from the repeating sequence
CcShowInstancesQuery::create()
->findPk($showData["add_show_instance_id"])
->setDbModifiedInstance(true)
->save();
$ccShowInstanceOrig->setDbModifiedInstance(true)->save();
$service_showForm = new Application_Service_ShowFormService($showData["add_show_id"]);
list($start, $end) = $service_showForm->getNextFutureRepeatShowTime();