From 1b3a9f6e6af6f0f293dce77a0dc8065e3b875cb7 Mon Sep 17 00:00:00 2001 From: drigato Date: Thu, 9 Jul 2015 12:18:21 -0400 Subject: [PATCH 1/3] SAAS-924: Cannot edit repeating show if first instance has ended Reverted old behaviour where we set the show start and end date/time to the next repeating instance start and end. --- .../application/services/ShowFormService.php | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 92ffa4907..24c66e3ef 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -155,19 +155,14 @@ class Application_Service_ShowFormService if ($ccShowDay->isShowStartInPast()) { //for a non-repeating show, we should never allow user to change the start time. //for a repeating show, we should allow because the form works as repeating template form - $form->disableStartDateAndTime(); - - // Removing this - if there is no future instance, this will throw an error. - // If there is a future instance, then we get a WHEN block representing the next instance - // which may be confusing. - /*if (!$ccShowDay->isRepeating()) { + if (!$ccShowDay->isRepeating()) { $form->disableStartDateAndTime(); } else { list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime(); if ($this->hasShowStarted($showStart)) { $form->disableStartDateAndTime(); } - }*/ + } } $form->populate( @@ -183,6 +178,29 @@ class Application_Service_ShowFormService return $showStart; } + public function getNextFutureRepeatShowTime() + { + $ccShowInstance = CcShowInstancesQuery::create() + ->filterByDbShowId($this->ccShow->getDbId()) + ->filterByDbModifiedInstance(false) + ->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN) + ->orderByDbStarts() + ->findOne(); + + if (!$ccShowInstance) { + return null; + } + + $starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC")); + $ends = new DateTime($ccShowInstance->getDbEnds(), new DateTimeZone("UTC")); + $showTimezone = $this->ccShow->getFirstCcShowDay()->getDbTimezone(); + + $starts->setTimezone(new DateTimeZone($showTimezone)); + $ends->setTimezone(new DateTimeZone($showTimezone)); + + return array($starts, $ends); + } + private function populateInstanceFormWhen($form) { $ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId); @@ -437,7 +455,7 @@ class Application_Service_ShowFormService $ccShowInstance = CcShowInstancesQuery::create() ->filterByDbShowId($this->ccShow->getDbId()) ->filterByDbModifiedInstance(false) - ->filterByDbStarts(gmdate("Y-m-d"), Criteria::GREATER_EQUAL) + ->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_EQUAL) ->orderByDbStarts() ->findOne(); From 721cd5a31bbfdbc880c07d7caa4c05f0f5f9c43d Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 13 Jul 2015 09:04:49 -0400 Subject: [PATCH 2/3] SAAS-924: Cannot edit repeating show if first instance has ended Added safeguard in case we don't find a future show instance --- airtime_mvc/application/services/ShowFormService.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 24c66e3ef..8af6a78fa 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -158,7 +158,11 @@ class Application_Service_ShowFormService if (!$ccShowDay->isRepeating()) { $form->disableStartDateAndTime(); } else { - list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime(); + $showStartAndEnd = $this->getNextFutureRepeatShowTime(); + if (!is_null($showStartAndEnd)) { + $showStart = $showStartAndEnd["starts"]; + $showEnd = $showStartAndEnd["ends"]; + } if ($this->hasShowStarted($showStart)) { $form->disableStartDateAndTime(); } @@ -198,7 +202,7 @@ class Application_Service_ShowFormService $starts->setTimezone(new DateTimeZone($showTimezone)); $ends->setTimezone(new DateTimeZone($showTimezone)); - return array($starts, $ends); + return array("starts" => $starts, "ends" => $ends); } private function populateInstanceFormWhen($form) From 66caf2574a2aa51f66748189054b7604d5e51d26 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Tue, 14 Jul 2015 10:35:21 -0400 Subject: [PATCH 3/3] CC-6064: Allow shows to be started "now" --- .../controllers/ScheduleController.php | 18 ++++++- airtime_mvc/application/forms/AddShowWhen.php | 21 ++++++-- .../application/services/ShowFormService.php | 7 +++ .../views/scripts/form/add-show-when.phtml | 15 +++++- .../public/js/airtime/schedule/add-show.js | 53 +++++++++++++------ .../schedule/full-calendar-functions.js | 5 ++ ...moment-timezone-with-data-2010-2020.min.js | 6 +++ .../public/js/libs/moment-timezone.min.js | 6 +++ airtime_mvc/public/js/libs/moment.min.js | 7 +++ 9 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 airtime_mvc/public/js/libs/moment-timezone-with-data-2010-2020.min.js create mode 100644 airtime_mvc/public/js/libs/moment-timezone.min.js create mode 100644 airtime_mvc/public/js/libs/moment.min.js diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 4760e7f3d..157d86f14 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -98,6 +98,9 @@ class ScheduleController extends Zend_Controller_Action $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.columnFilter.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/libs/moment.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/libs/moment-timezone-with-data-2010-2020.min.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); @@ -584,7 +587,20 @@ class ScheduleController extends Zend_Controller_Action $forms = $this->createShowFormAction(); $this->view->addNewShow = true; - + + if ($data['add_show_start_now'] == "now") { + + //have to use the timezone the user has entered in the form to check past/present + $showTimezone = new DateTimeZone($data["add_show_timezone"]); + $nowDateTime = new DateTime("now", $showTimezone); + //$showStartDateTime = new DateTime($start_time, $showTimezone); + //$showEndDateTime = new DateTime($end_time, $showTimezone); + + $data['add_show_start_time'] = $nowDateTime->format("H:i"); + $data['add_show_start_date'] = $nowDateTime->format("Y-m-d"); + } + + if ($service_showForm->validateShowForms($forms, $data)) { // Get the show ID from the show service to pass as a parameter to the RESTful ShowImageController $this->view->showId = $service_show->addUpdateShow($data); diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index d6edbe0cd..0f8f4094e 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -15,11 +15,26 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm "/^[0-2]?[0-9]:[0-5][0-9]$/", _("'%value%' does not fit the time format 'HH:mm'")); + + // Add start date element + $startNow = new Zend_Form_Element_Radio('add_show_start_now'); + $startNow->setRequired(false) + ->setLabel(_('Start Time:')) + ->addMultiOptions(array( + 'now' => 'Now', + 'future' => 'In the Future:' + )) + ->setValue('future') + ->setDecorators(array('ViewHelper')); + //$startDate->setAttrib('alt', 'date'); + $this->addElement($startNow); + + // Add start date element $startDate = new Zend_Form_Element_Text('add_show_start_date'); $startDate->class = 'input_text'; $startDate->setRequired(true) - ->setLabel(_('Date/Time Start:')) + ->setLabel(_('In the Future:')) ->setValue(date("Y-m-d")) ->setFilters(array('StringTrim')) ->setValidators(array( @@ -46,7 +61,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $endDate = new Zend_Form_Element_Text('add_show_end_date_no_repeat'); $endDate->class = 'input_text'; $endDate->setRequired(true) - ->setLabel(_('Date/Time End:')) + ->setLabel(_('End Time:')) ->setValue(date("Y-m-d")) ->setFilters(array('StringTrim')) ->setValidators(array( @@ -119,7 +134,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $showStartDateTime = new DateTime($start_time, $showTimezone); $showEndDateTime = new DateTime($end_time, $showTimezone); - if ($validateStartDate) { + if ($validateStartDate && ($formData['add_show_start_now'] != "now")) { if ($showStartDateTime < $nowDateTime) { $this->getElement('add_show_start_time')->setErrors(array(_('Cannot create show in the past'))); $valid = false; diff --git a/airtime_mvc/application/services/ShowFormService.php b/airtime_mvc/application/services/ShowFormService.php index 8af6a78fa..962a4de67 100644 --- a/airtime_mvc/application/services/ShowFormService.php +++ b/airtime_mvc/application/services/ShowFormService.php @@ -169,6 +169,9 @@ class Application_Service_ShowFormService } } + //Disable starting a show 'now' when editing an existing show. + $form->getElement('add_show_start_now')->setAttrib('disable', array('now')); + $form->populate( array( 'add_show_start_date' => $showStart->format("Y-m-d"), @@ -225,8 +228,12 @@ class Application_Service_ShowFormService $form->disableStartDateAndTime(); } + //Disable starting a show 'now' when editing an existing show. + $form->getElement('add_show_start_now')->setAttrib('disable', array('now')); + $form->populate( array( + 'add_show_start_now' => 'future', 'add_show_start_date' => $showStart->format("Y-m-d"), 'add_show_start_time' => $showStart->format("H:i"), 'add_show_end_date_no_repeat' => $showEnd->format("Y-m-d"), diff --git a/airtime_mvc/application/views/scripts/form/add-show-when.phtml b/airtime_mvc/application/views/scripts/form/add-show-when.phtml index 5a5cc1725..e33d2f3a5 100644 --- a/airtime_mvc/application/views/scripts/form/add-show-when.phtml +++ b/airtime_mvc/application/views/scripts/form/add-show-when.phtml @@ -1,8 +1,18 @@
+
+ +
+
+ element->getElement('add_show_start_now') ?> +
+ +
@@ -19,6 +29,9 @@ + + +