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 @@