CC-1805: Ability to edit a show
-Fixed bug with scheduled data start time not shifting with show instance start time -What "tab" now automatically open when form appears.
This commit is contained in:
parent
88362a2c52
commit
d5b914fa84
|
@ -652,6 +652,11 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||
}
|
||||
else {
|
||||
//the form still needs to be "update" since
|
||||
//the validity test failed.
|
||||
if ($data['add_show_id'] != -1){
|
||||
$this->view->addNewShow = false;
|
||||
}
|
||||
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
}
|
||||
|
|
|
@ -536,24 +536,26 @@ class Show {
|
|||
//repeat option was toggled or show is recorded.
|
||||
$p_show->deleteAllInstances();
|
||||
}
|
||||
if ($p_data['add_show_start_date'] != $p_show->getStartDate()
|
||||
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){
|
||||
//start date/time has changed
|
||||
|
||||
$newDate = strtotime($p_data['add_show_start_date']);
|
||||
$oldDate = strtotime($p_show->getStartDate());
|
||||
if ($newDate > $oldDate){
|
||||
$p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
|
||||
}
|
||||
|
||||
$p_show->updateStartDateTime($p_data, $p_endDate);
|
||||
}
|
||||
if ($p_data['add_show_duration'] != $p_show->getDuration()){
|
||||
//duration has changed
|
||||
$p_show->updateDurationTime($p_data);
|
||||
}
|
||||
|
||||
if ($p_data['add_show_repeats']){
|
||||
if ($p_data['add_show_start_date'] != $p_show->getStartDate()
|
||||
|| $p_data['add_show_start_time'] != $p_show->getStartTime()){
|
||||
//start date/time has changed
|
||||
|
||||
$newDate = strtotime($p_data['add_show_start_date']);
|
||||
$oldDate = strtotime($p_show->getStartDate());
|
||||
if ($newDate > $oldDate){
|
||||
$p_show->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
|
||||
}
|
||||
|
||||
$p_show->updateStartDateTime($p_data, $p_endDate);
|
||||
}
|
||||
|
||||
if ($repeatType != $p_show->getRepeatType()){
|
||||
//repeat type changed.
|
||||
$p_show->deleteAllInstances();
|
||||
|
@ -863,21 +865,26 @@ class Show {
|
|||
|
||||
$show = new Show($show_id);
|
||||
if ($show->hasInstance()){
|
||||
$showInstance = $show->getInstance();
|
||||
$ccShowInstance = $show->getInstance();
|
||||
$newInstance = false;
|
||||
} else {
|
||||
$showInstance = new CcShowInstances();
|
||||
$ccShowInstance = new CcShowInstances();
|
||||
$newInstance = true;
|
||||
}
|
||||
|
||||
$showInstance->setDbShowId($show_id);
|
||||
$showInstance->setDbStarts($start);
|
||||
$showInstance->setDbEnds($end);
|
||||
$showInstance->setDbRecord($record);
|
||||
$showInstance->save();
|
||||
//$show->addInstance($showInstance);
|
||||
|
||||
$ccShowInstance->setDbShowId($show_id);
|
||||
$ccShowInstance->setDbStarts($start);
|
||||
$ccShowInstance->setDbEnds($end);
|
||||
$ccShowInstance->setDbRecord($record);
|
||||
$ccShowInstance->save();
|
||||
|
||||
$show_instance_id = $showInstance->getDbId();
|
||||
$show_instance_id = $ccShowInstance->getDbId();
|
||||
$showInstance = new ShowInstance($show_instance_id);
|
||||
|
||||
if (!$newInstance){
|
||||
$showInstance->correctScheduleStartTimes();
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
|
||||
|
@ -929,19 +936,24 @@ class Show {
|
|||
$end = $CC_DBC->GetOne($sql);
|
||||
|
||||
if ($show->hasInstanceOnDate($start)){
|
||||
$showInstance = $show->getInstanceOnDate($start);
|
||||
$ccShowInstance = $show->getInstanceOnDate($start);
|
||||
$newInstance = false;
|
||||
} else {
|
||||
$showInstance = new CcShowInstances();
|
||||
$ccShowInstance = new CcShowInstances();
|
||||
$newInstance = true;
|
||||
}
|
||||
$showInstance->setDbShowId($show_id);
|
||||
$showInstance->setDbStarts($start);
|
||||
$showInstance->setDbEnds($end);
|
||||
$showInstance->setDbRecord($record);
|
||||
$showInstance->save();
|
||||
//$show->addInstance($showInstance);
|
||||
|
||||
$ccShowInstance->setDbShowId($show_id);
|
||||
$ccShowInstance->setDbStarts($start);
|
||||
$ccShowInstance->setDbEnds($end);
|
||||
$ccShowInstance->setDbRecord($record);
|
||||
$ccShowInstance->save();
|
||||
|
||||
$show_instance_id = $showInstance->getDbId();
|
||||
$show_instance_id = $ccShowInstance->getDbId();
|
||||
$showInstance = new ShowInstance($show_instance_id);
|
||||
|
||||
if (!$newInstance){
|
||||
$showInstance->correctScheduleStartTimes();
|
||||
}
|
||||
|
||||
foreach($rebroadcasts as $rebroadcast) {
|
||||
|
||||
|
@ -1305,6 +1317,34 @@ class ShowInstance {
|
|||
RabbitMq::PushSchedule();
|
||||
}
|
||||
|
||||
public function correctScheduleStartTimes(){
|
||||
global $CC_DBC;
|
||||
|
||||
$instance_id = $this->getShowInstanceId();
|
||||
$sql = "SELECT starts from cc_schedule"
|
||||
." WHERE instance_id = $instance_id"
|
||||
." ORDER BY starts"
|
||||
." LIMIT 1";
|
||||
|
||||
$scheduleStarts = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (!is_null($scheduleStarts)){
|
||||
$scheduleStartsEpoch = strtotime($scheduleStarts);
|
||||
$showStartsEpoch = strtotime($this->getShowStart());
|
||||
|
||||
$diff = $showStartsEpoch - $scheduleStartsEpoch;
|
||||
|
||||
if ($diff != 0){
|
||||
$sql = "UPDATE cc_schedule"
|
||||
." SET starts = starts + INTERVAL '$diff' second,"
|
||||
." ends = ends + INTERVAL '$diff' second"
|
||||
." WHERE instance_id = $instance_id";
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function moveShow($deltaDay, $deltaMin)
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
|
|
@ -10,12 +10,15 @@ function scheduleRefetchEvents() {
|
|||
|
||||
function openAddShowForm() {
|
||||
|
||||
if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none')) {
|
||||
$("#add-show-form").show();
|
||||
var y = $("#schedule_calendar").width();
|
||||
var z = $("#schedule-add-show").width();
|
||||
$("#schedule_calendar").width(y-z-50);
|
||||
$("#schedule_calendar").fullCalendar('render');
|
||||
if($("#add-show-form").length == 1) {
|
||||
if( ($("#add-show-form").css('display')=='none')) {
|
||||
$("#add-show-form").show();
|
||||
var y = $("#schedule_calendar").width();
|
||||
var z = $("#schedule-add-show").width();
|
||||
$("#schedule_calendar").width(y-z-50);
|
||||
$("#schedule_calendar").fullCalendar('render');
|
||||
}
|
||||
$("#schedule-show-what").show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue