CC-4961: Show linking

Fixed edit show start/end time bug
This commit is contained in:
denise 2013-03-18 12:34:27 -04:00
parent 896e03d76b
commit 4bdd89f747
2 changed files with 34 additions and 15 deletions

View File

@ -190,7 +190,9 @@ class Application_Service_CalendarService
if ($isUpdate) { if ($isUpdate) {
$this->service_showInstances->deleteInvalidInstances($showData, $isRecorded, $repeatType); $this->service_showInstances->deleteInvalidInstances($showData, $isRecorded, $repeatType);
$this->service_showInstances->updateScheduleStatus($showId); // updates cc_show_instances start/end times, and updates
// schedule start/end times
$this->service_showInstances->applyShowStartEndDifference($showData, $showId);
$this->service_showInstances->deleteRebroadcastInstances($showId); $this->service_showInstances->deleteRebroadcastInstances($showId);
$this->service_showDays->deleteShowDays(); $this->service_showDays->deleteShowDays();
$this->service_show->deleteShowHosts($showId); $this->service_show->deleteShowHosts($showId);
@ -213,6 +215,12 @@ class Application_Service_CalendarService
//create new ccShowInstances //create new ccShowInstances
$this->service_showInstances->delegateShowInstanceCreation($showId, $isRebroadcast, $isUpdate); $this->service_showInstances->delegateShowInstanceCreation($showId, $isRebroadcast, $isUpdate);
//after all instances have been deleted/updated, we need to update
//the schedule playout status
if ($isUpdate) {
$this->service_showInstances->updateScheduleStatus($showId);
}
$con->commit(); $con->commit();
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
} catch (Exception $e) { } catch (Exception $e) {

View File

@ -68,12 +68,6 @@ class Application_Service_ShowInstanceService
$ccShowInstance = new CcShowInstances(); $ccShowInstance = new CcShowInstances();
if ($isUpdate) { if ($isUpdate) {
$ccShowInstance = $this->getInstance($utcStartDateTime, $showDay->getDbShowId()); $ccShowInstance = $this->getInstance($utcStartDateTime, $showDay->getDbShowId());
//update schedule start times
//ccShowDays object of the show being edited
$currentShowDay = $this->service_showDays->getCurrentShowDay();
$diff = $this->calculateShowStartDiff($utcStartDateTime,
$currentShowDay->getUTCStartDateAndTime());
Application_Service_ScheduleService::updateScheduleStartTime(array($ccShowInstance->getDbId()), $diff);
} }
$ccShowInstance->setDbShowId($showDay->getDbShowId()); $ccShowInstance->setDbShowId($showDay->getDbShowId());
$ccShowInstance->setDbStarts($utcStartDateTime); $ccShowInstance->setDbStarts($utcStartDateTime);
@ -126,15 +120,22 @@ class Application_Service_ShowInstanceService
( is_null($utcLastShowDateTime) || ( is_null($utcLastShowDateTime) ||
$utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp()) ) { $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp()) ) {
$ccShowInstance = new CcShowInstances(); /* There may not always be an instance when editing a show
if ($isUpdate) { * This will be the case when we are adding a new show day to
* a repeating show
*/
if ($isUpdate && $this->hasInstance($utcStartDateTime, $show_id)) {
$ccShowInstance = $this->getInstance($utcStartDateTime, $show_id); $ccShowInstance = $this->getInstance($utcStartDateTime, $show_id);
$newInstance = false;
} else {
$newInstance = true;
$ccShowInstance = new CcShowInstances();
} }
/* When editing the start/end time of a repeating show, we don't want to /* When editing the start/end time of a repeating show, we don't want to
* change shows that started in the past. So check the start time. * change shows that started in the past. So check the start time.
*/ */
if (!$isUpdate || $ccShowInstance->getDbStarts() > gmdate("Y-m-d H:i:s")) { if ($newInstance || $ccShowInstance->getDbStarts() > gmdate("Y-m-d H:i:s")) {
$ccShowInstance->setDbShowId($show_id); $ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($utcStartDateTime); $ccShowInstance->setDbStarts($utcStartDateTime);
$ccShowInstance->setDbEnds($utcEndDateTime); $ccShowInstance->setDbEnds($utcEndDateTime);
@ -294,10 +295,15 @@ SQL;
->find(); ->find();
if ($ccShowInstance->isEmpty()) { if ($ccShowInstance->isEmpty()) {
throw new Exception("Show instance not found"); return false;
} else {
return $ccShowInstance[0];
} }
}
return $ccShowInstance[0]; public function hasInstance($starts, $showId)
{
return $this->getInstance($starts, $showId) ? true : false;
} }
public function getAllFutureInstanceIds($showId) public function getAllFutureInstanceIds($showId)
@ -458,9 +464,14 @@ SQL;
} }
} }
}//if repeats }//if repeats
}
/*$newStartDateTime = new DateTime($showData["add_show_start_date"]." ". public function applyShowStartEndDifference($showData, $showId)
$showData["add_show_start_time"], {
$currentShowDay = $this->service_showDays->getCurrentShowDay();
$newStartDateTime = new DateTime($showData["add_show_start_date"]." ".
$showData["add_show_start_time"],
new DateTimeZone(Application_Model_Preference::GetTimezone())); new DateTimeZone(Application_Model_Preference::GetTimezone()));
$diff = $this->calculateShowStartDiff($newStartDateTime, $diff = $this->calculateShowStartDiff($newStartDateTime,
@ -468,7 +479,7 @@ SQL;
$this->updateInstanceStartEndTime($showId, $diff); $this->updateInstanceStartEndTime($showId, $diff);
$instanceIds = $this->getAllFutureInstanceIds($showId); $instanceIds = $this->getAllFutureInstanceIds($showId);
Application_Service_ScheduleService::updateScheduleStartTime($instanceIds, $diff);*/ Application_Service_ScheduleService::updateScheduleStartTime($instanceIds, $diff);
} }
/** /**