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');
|
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||||
}
|
}
|
||||||
else {
|
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');
|
$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.
|
//repeat option was toggled or show is recorded.
|
||||||
$p_show->deleteAllInstances();
|
$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()){
|
if ($p_data['add_show_duration'] != $p_show->getDuration()){
|
||||||
//duration has changed
|
//duration has changed
|
||||||
$p_show->updateDurationTime($p_data);
|
$p_show->updateDurationTime($p_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($p_data['add_show_repeats']){
|
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()){
|
if ($repeatType != $p_show->getRepeatType()){
|
||||||
//repeat type changed.
|
//repeat type changed.
|
||||||
$p_show->deleteAllInstances();
|
$p_show->deleteAllInstances();
|
||||||
|
@ -863,21 +865,26 @@ class Show {
|
||||||
|
|
||||||
$show = new Show($show_id);
|
$show = new Show($show_id);
|
||||||
if ($show->hasInstance()){
|
if ($show->hasInstance()){
|
||||||
$showInstance = $show->getInstance();
|
$ccShowInstance = $show->getInstance();
|
||||||
|
$newInstance = false;
|
||||||
} else {
|
} else {
|
||||||
$showInstance = new CcShowInstances();
|
$ccShowInstance = new CcShowInstances();
|
||||||
|
$newInstance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$showInstance->setDbShowId($show_id);
|
$ccShowInstance->setDbShowId($show_id);
|
||||||
$showInstance->setDbStarts($start);
|
$ccShowInstance->setDbStarts($start);
|
||||||
$showInstance->setDbEnds($end);
|
$ccShowInstance->setDbEnds($end);
|
||||||
$showInstance->setDbRecord($record);
|
$ccShowInstance->setDbRecord($record);
|
||||||
$showInstance->save();
|
$ccShowInstance->save();
|
||||||
//$show->addInstance($showInstance);
|
|
||||||
|
|
||||||
|
|
||||||
$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}";
|
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
|
@ -929,19 +936,24 @@ class Show {
|
||||||
$end = $CC_DBC->GetOne($sql);
|
$end = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if ($show->hasInstanceOnDate($start)){
|
if ($show->hasInstanceOnDate($start)){
|
||||||
$showInstance = $show->getInstanceOnDate($start);
|
$ccShowInstance = $show->getInstanceOnDate($start);
|
||||||
|
$newInstance = false;
|
||||||
} else {
|
} else {
|
||||||
$showInstance = new CcShowInstances();
|
$ccShowInstance = new CcShowInstances();
|
||||||
|
$newInstance = true;
|
||||||
}
|
}
|
||||||
$showInstance->setDbShowId($show_id);
|
$ccShowInstance->setDbShowId($show_id);
|
||||||
$showInstance->setDbStarts($start);
|
$ccShowInstance->setDbStarts($start);
|
||||||
$showInstance->setDbEnds($end);
|
$ccShowInstance->setDbEnds($end);
|
||||||
$showInstance->setDbRecord($record);
|
$ccShowInstance->setDbRecord($record);
|
||||||
$showInstance->save();
|
$ccShowInstance->save();
|
||||||
//$show->addInstance($showInstance);
|
|
||||||
|
|
||||||
|
|
||||||
$show_instance_id = $showInstance->getDbId();
|
$show_instance_id = $ccShowInstance->getDbId();
|
||||||
|
$showInstance = new ShowInstance($show_instance_id);
|
||||||
|
|
||||||
|
if (!$newInstance){
|
||||||
|
$showInstance->correctScheduleStartTimes();
|
||||||
|
}
|
||||||
|
|
||||||
foreach($rebroadcasts as $rebroadcast) {
|
foreach($rebroadcasts as $rebroadcast) {
|
||||||
|
|
||||||
|
@ -1305,6 +1317,34 @@ class ShowInstance {
|
||||||
RabbitMq::PushSchedule();
|
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)
|
public function moveShow($deltaDay, $deltaMin)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
|
@ -10,12 +10,15 @@ function scheduleRefetchEvents() {
|
||||||
|
|
||||||
function openAddShowForm() {
|
function openAddShowForm() {
|
||||||
|
|
||||||
if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none')) {
|
if($("#add-show-form").length == 1) {
|
||||||
$("#add-show-form").show();
|
if( ($("#add-show-form").css('display')=='none')) {
|
||||||
var y = $("#schedule_calendar").width();
|
$("#add-show-form").show();
|
||||||
var z = $("#schedule-add-show").width();
|
var y = $("#schedule_calendar").width();
|
||||||
$("#schedule_calendar").width(y-z-50);
|
var z = $("#schedule-add-show").width();
|
||||||
$("#schedule_calendar").fullCalendar('render');
|
$("#schedule_calendar").width(y-z-50);
|
||||||
|
$("#schedule_calendar").fullCalendar('render');
|
||||||
|
}
|
||||||
|
$("#schedule-show-what").show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue