SAAS-924: Cannot edit repeating show if first instance has ended

Reverted old behaviour where we set the show start and end date/time to
the next repeating instance start and end.
This commit is contained in:
drigato 2015-07-09 12:18:21 -04:00
parent 7c927dcb31
commit 1b3a9f6e6a
1 changed files with 26 additions and 8 deletions

View File

@ -155,19 +155,14 @@ class Application_Service_ShowFormService
if ($ccShowDay->isShowStartInPast()) {
//for a non-repeating show, we should never allow user to change the start time.
//for a repeating show, we should allow because the form works as repeating template form
$form->disableStartDateAndTime();
// Removing this - if there is no future instance, this will throw an error.
// If there is a future instance, then we get a WHEN block representing the next instance
// which may be confusing.
/*if (!$ccShowDay->isRepeating()) {
if (!$ccShowDay->isRepeating()) {
$form->disableStartDateAndTime();
} else {
list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime();
if ($this->hasShowStarted($showStart)) {
$form->disableStartDateAndTime();
}
}*/
}
}
$form->populate(
@ -183,6 +178,29 @@ class Application_Service_ShowFormService
return $showStart;
}
public function getNextFutureRepeatShowTime()
{
$ccShowInstance = CcShowInstancesQuery::create()
->filterByDbShowId($this->ccShow->getDbId())
->filterByDbModifiedInstance(false)
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
->orderByDbStarts()
->findOne();
if (!$ccShowInstance) {
return null;
}
$starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC"));
$ends = new DateTime($ccShowInstance->getDbEnds(), new DateTimeZone("UTC"));
$showTimezone = $this->ccShow->getFirstCcShowDay()->getDbTimezone();
$starts->setTimezone(new DateTimeZone($showTimezone));
$ends->setTimezone(new DateTimeZone($showTimezone));
return array($starts, $ends);
}
private function populateInstanceFormWhen($form)
{
$ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId);
@ -437,7 +455,7 @@ class Application_Service_ShowFormService
$ccShowInstance = CcShowInstancesQuery::create()
->filterByDbShowId($this->ccShow->getDbId())
->filterByDbModifiedInstance(false)
->filterByDbStarts(gmdate("Y-m-d"), Criteria::GREATER_EQUAL)
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_EQUAL)
->orderByDbStarts()
->findOne();