diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index a0087f97c..f806b8ff5 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -258,7 +258,13 @@ class ScheduleController extends Zend_Controller_Action $menu["cancel_recorded"] = array("name"=> "Cancel Current Show", "icon" => "delete"); } } else { - $menu["edit"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/edit-show"); + if($instance->isRepeating()){ + $menu["edit"] = array("name"=> "Edit", "icon" => "edit", "items" => array()); + $menu["edit"]["items"]["instance"] = array("name"=> "Edit Show Instance", "icon" => "edit", "url" => "/Schedule/edit-show"); + $menu["edit"]["items"]["all"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/edit-show"); + }else{ + $menu["edit"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/edit-show"); + } if($isAdminOrPM){ $menu["cancel"] = array("name"=> "Cancel Current Show", "icon" => "delete"); } @@ -269,7 +275,13 @@ class ScheduleController extends Zend_Controller_Action if ($isAdminOrPM || $isDJ) { - $menu["edit"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/edit-show"); + if($instance->isRepeating()){ + $menu["edit"] = array("name"=> "Edit", "icon" => "edit", "items" => array()); + $menu["edit"]["items"]["instance"] = array("name"=> "Edit Show Instance", "icon" => "edit", "url" => "/Schedule/edit-show"); + $menu["edit"]["items"]["all"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/edit-show"); + }else{ + $menu["edit"] = array("name"=> "Edit Show", "icon" => "edit", "url" => "/Schedule/edit-show"); + } if ($instance->getShow()->isRepeating() && $isAdminOrPM) { @@ -420,6 +432,9 @@ class ScheduleController extends Zend_Controller_Action $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $showInstanceId = $this->_getParam('id'); + // $type is used to determine if this edit is for the specific instance or for all + // repeating shows. It's value is either "instance" or "all" + $type = $this->_getParam('type'); try{ $showInstance = new Application_Model_ShowInstance($showInstanceId); @@ -549,7 +564,7 @@ class ScheduleController extends Zend_Controller_Action $i++; } $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues); - if(!$isAdminOrPM){ + if(!$isAdminOrPM || $type == "instance"){ $formRecord->disable(); $formAbsoluteRebroadcast->disable(); $formRebroadcast->disable(); @@ -563,6 +578,14 @@ class ScheduleController extends Zend_Controller_Action $formRepeats->disable(); $formStyle->disable(); } + + if($type == "instance"){ + $formWhat->disable(); + $formWho->disable(); + $formWhen->disableRepeatCheckbox(); + $formRepeats->disable(); + $formStyle->disable(); + } $this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); $this->view->entries = 5; diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 4ed91ad3e..cbae215cf 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -124,5 +124,14 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } } } + + public function disableRepeatCheckbox(){ + $element = $this->getElement('add_show_repeats'); + if ($element->getType() != 'Zend_Form_Element_Hidden') + { + $element->setAttrib('readonly',true); + $element->setAttribs(array('style' => 'color: #B1B1B1; ')); + } + } } diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 75564dc12..142b2998c 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -743,4 +743,12 @@ class Application_Model_ShowInstance { return $CC_DBC->GetAll($sql); } + + function isRepeating(){ + if ($this->getShow()->isRepeating()){ + return true; + }else{ + return false; + } + } } diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index 76938235e..e5a47e00c 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -297,13 +297,32 @@ $(document).ready(function() { //define an edit callback. if (oItems.edit !== undefined) { - - callback = function() { - $.get(oItems.edit.url, {format: "json", id: data.id}, function(json){ - beginEditShow(json); - }); - }; - oItems.edit.callback = callback; + if(oItems.edit.items !== undefined){ + var edit = oItems.edit.items; + + //edit a single instance + callback = function() { + $.get(edit.instance.url, {format: "json", id: data.id, type: "instance"}, function(json){ + beginEditShow(json); + }); + }; + edit.instance.callback = callback; + + //edit this instance and all + callback = function() { + $.get(edit.all.url, {format: "json", id: data.id, type: "all"}, function(json){ + beginEditShow(json); + }); + }; + edit.all.callback = callback; + }else{ + callback = function() { + $.get(oItems.edit.url, {format: "json", id: data.id, type: "all"}, function(json){ + beginEditShow(json); + }); + }; + oItems.edit.callback = callback; + } } //define a content callback.