CC-4538: Cannot edit title or change time of repeating show if first instance has ended

- fixed by populating the edit show form with the next repeating show that is not in the past
This commit is contained in:
denise 2013-02-13 11:55:27 -05:00
parent eb38503d6e
commit 76cb04e296
2 changed files with 37 additions and 3 deletions

View File

@ -627,7 +627,11 @@ class ScheduleController extends Zend_Controller_Action
if (!$showInstance->getShow()->isRepeating()) { if (!$showInstance->getShow()->isRepeating()) {
$formWhen->disableStartDateAndTime(); $formWhen->disableStartDateAndTime();
} else { } else {
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true)); $nextFutureRepeatShow = $show->getNextFutureRepeatShowTime();
$formWhen->getElement('add_show_start_date')->setValue($nextFutureRepeatShow["starts"]->format("Y-m-d"));
$formWhen->getElement('add_show_start_time')->setValue($nextFutureRepeatShow["starts"]->format("H:i"));
$formWhen->getElement('add_show_end_date_no_repeat')->setValue($nextFutureRepeatShow["ends"]->format("Y-m-d"));
$formWhen->getElement('add_show_end_time')->setValue($nextFutureRepeatShow["ends"]->format("H:i"));
} }
} }
@ -802,10 +806,16 @@ class ScheduleController extends Zend_Controller_Action
} }
$data['add_show_record'] = $show->isRecorded(); $data['add_show_record'] = $show->isRecorded();
$origianlShowStartDateTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime()); if ($show->isRepeating()) {
$nextFutureRepeatShow = $show->getNextFutureRepeatShowTime();
$originalShowStartDateTime = $nextFutureRepeatShow["starts"];
} else {
$originalShowStartDateTime = Application_Common_DateHelper::ConvertToLocalDateTime(
$show->getStartDateAndTime());
}
$success = Application_Model_Schedule::addUpdateShow($data, $this, $success = Application_Model_Schedule::addUpdateShow($data, $this,
$validateStartDate, $origianlShowStartDateTime, true, $validateStartDate, $originalShowStartDateTime, true,
$data['add_show_instance_id']); $data['add_show_instance_id']);
if ($success) { if ($success) {

View File

@ -663,6 +663,30 @@ SQL;
$con->exec($sql); $con->exec($sql);
} }
public function getNextFutureRepeatShowTime()
{
$sql = <<<SQL
SELECT starts, ends FROM cc_show_instances
WHERE ends > now() at time zone 'UTC'
AND show_id = :showId
ORDER BY starts
LIMIT 1
SQL;
$result = Application_Common_Database::prepareAndExecute( $sql,
array( 'showId' => $this->getId() ), 'all' );
foreach ($result as $r) {
$show["starts"] = new DateTime($r["starts"], new DateTimeZone('UTC'));
$show["ends"] = new DateTime($r["ends"], new DateTimeZone('UTC'));
}
$currentUser = Application_Model_User::getCurrentUser();
$currentUserId = $currentUser->getId();
$userTimezone = Application_Model_Preference::GetUserTimezone($currentUserId);
$show["starts"]->setTimezone(new DateTimeZone($userTimezone));
$show["ends"]->setTimezone(new DateTimeZone($userTimezone));
return $show;
}
/** /**
* Get the start date of the current show in UTC timezone. * Get the start date of the current show in UTC timezone.
* *