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:
parent
eb38503d6e
commit
76cb04e296
|
@ -627,7 +627,11 @@ class ScheduleController extends Zend_Controller_Action
|
|||
if (!$showInstance->getShow()->isRepeating()) {
|
||||
$formWhen->disableStartDateAndTime();
|
||||
} 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();
|
||||
|
||||
$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,
|
||||
$validateStartDate, $origianlShowStartDateTime, true,
|
||||
$validateStartDate, $originalShowStartDateTime, true,
|
||||
$data['add_show_instance_id']);
|
||||
|
||||
if ($success) {
|
||||
|
|
|
@ -663,6 +663,30 @@ 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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue