CC-2289:Differentiate between time and duration
- End date and time is added - duration field is readonly now and is autocalculated - now playing duration field format is changed( 0h 0m 0s ) - removed millisecond from start and end time in now playing
This commit is contained in:
parent
143e68bd56
commit
1dabbacca2
7 changed files with 207 additions and 32 deletions
|
@ -11,7 +11,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
|
||||
// Add start date element
|
||||
$this->addElement('text', 'add_show_start_date', array(
|
||||
'label' => 'Date Start:',
|
||||
'label' => 'Date/Time Start:',
|
||||
'class' => 'input_text',
|
||||
'required' => true,
|
||||
'value' => date("Y-m-d"),
|
||||
|
@ -21,13 +21,13 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
array('date', false, array('YYYY-MM-DD'))
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// Add start time element
|
||||
$this->addElement('text', 'add_show_start_time', array(
|
||||
'label' => 'Start Time:',
|
||||
$startTime = $this->addElement('text', 'add_show_start_time', array(
|
||||
'decorators' => array('ViewHelper', array('HtmlTag', array('tag'=>'dd'))),
|
||||
'class' => 'input_text',
|
||||
'required' => true,
|
||||
'value' => '0:00',
|
||||
'value' => '00:00',
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'NotEmpty',
|
||||
|
@ -36,19 +36,40 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
)
|
||||
));
|
||||
|
||||
// Add duration element
|
||||
$this->addElement('text', 'add_show_duration', array(
|
||||
'label' => 'Duration:',
|
||||
// Add end date element
|
||||
$this->addElement('text', 'add_show_end_date_no_repeat', array(
|
||||
'label' => 'Date/Time End:',
|
||||
'class' => 'input_text',
|
||||
'value' => '1:00',
|
||||
'required' => true,
|
||||
'value' => date("Y-m-d"),
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))
|
||||
)
|
||||
));
|
||||
|
||||
// Add end time element
|
||||
$this->addElement('text', 'add_show_end_time', array(
|
||||
'decorators' => array('ViewHelper', array('HtmlTag', array('tag'=>'dd'))),
|
||||
'class' => 'input_text',
|
||||
'required' => true,
|
||||
'value' => '01:00',
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'NotEmpty',
|
||||
array('regex', false,
|
||||
array('/^\d+:[0-5][0-9]$/',
|
||||
'messages' => 'enter a duration: HH:mm'))
|
||||
)
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))
|
||||
)
|
||||
|
||||
));
|
||||
|
||||
// Add duration element
|
||||
$this->addElement('text', 'add_show_duration', array(
|
||||
'label' => 'Duration:',
|
||||
'class' => 'input_text',
|
||||
'value' => '01h00m',
|
||||
'readonly' => true
|
||||
));
|
||||
|
||||
// Add repeats element
|
||||
|
@ -69,15 +90,19 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
$now_epoch = strtotime($now_timestamp);
|
||||
$start_epoch = strtotime($start_timestamp);
|
||||
|
||||
if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){
|
||||
if($start_epoch < $now_epoch) {
|
||||
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(strtotime("00:00") == strtotime($formData["add_show_duration"])) {
|
||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00:00'));
|
||||
if ((($formData['add_show_id'] != -1) && $startDateModified) || ($formData['add_show_id'] == -1)){
|
||||
if($start_epoch < $now_epoch) {
|
||||
$this->getElement('add_show_start_date')->setErrors(array('Cannot create show in the past'));
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if( $formData["add_show_duration"] == "0m" ) {
|
||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 0m'));
|
||||
$valid = false;
|
||||
}elseif(strpos($formData["add_show_duration"], 'h') !== false && intval(substr($formData["add_show_duration"], 0, strpos($formData["add_show_duration"], 'h'))) > 23) {
|
||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration > 24h'));
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue