2011-01-21 00:30:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|
|
|
{
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
2011-03-17 23:23:05 +01:00
|
|
|
|
|
|
|
//$this->setDisableLoadDefaultDecorators(true);
|
|
|
|
//$this->removeDecorator('DtDdWrapper');
|
|
|
|
|
2011-01-21 00:30:53 +01:00
|
|
|
// Add start date element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_start_date', array(
|
2011-06-03 20:53:01 +02:00
|
|
|
'label' => 'Date/Time Start:',
|
2011-01-31 02:11:18 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
2011-02-11 21:59:16 +01:00
|
|
|
'value' => date("Y-m-d"),
|
2011-01-21 00:30:53 +01:00
|
|
|
'filters' => array('StringTrim'),
|
|
|
|
'validators' => array(
|
|
|
|
'NotEmpty',
|
|
|
|
array('date', false, array('YYYY-MM-DD'))
|
2011-04-04 19:50:51 +02:00
|
|
|
)
|
2011-01-21 00:30:53 +01:00
|
|
|
));
|
2011-06-03 20:53:01 +02:00
|
|
|
|
2011-01-21 00:30:53 +01:00
|
|
|
// Add start time element
|
2011-06-03 20:53:01 +02:00
|
|
|
$startTime = $this->addElement('text', 'add_show_start_time', array(
|
|
|
|
'decorators' => array('ViewHelper', array('HtmlTag', array('tag'=>'dd'))),
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
2011-06-03 20:53:01 +02:00
|
|
|
'value' => '00:00',
|
2011-01-21 00:30:53 +01:00
|
|
|
'filters' => array('StringTrim'),
|
|
|
|
'validators' => array(
|
|
|
|
'NotEmpty',
|
2011-04-02 01:43:57 +02:00
|
|
|
array('date', false, array('HH:mm')),
|
|
|
|
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))
|
2011-04-04 19:50:51 +02:00
|
|
|
)
|
2011-01-21 00:30:53 +01:00
|
|
|
));
|
|
|
|
|
2011-06-03 20:53:01 +02:00
|
|
|
// Add end date element
|
|
|
|
$this->addElement('text', 'add_show_end_date_no_repeat', array(
|
|
|
|
'label' => 'Date/Time End:',
|
|
|
|
'class' => 'input_text',
|
|
|
|
'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'))),
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
2011-06-03 20:53:01 +02:00
|
|
|
'value' => '01:00',
|
2011-01-21 00:30:53 +01:00
|
|
|
'filters' => array('StringTrim'),
|
2011-02-13 00:40:17 +01:00
|
|
|
'validators' => array(
|
|
|
|
'NotEmpty',
|
2011-06-03 20:53:01 +02:00
|
|
|
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
|
2011-01-21 00:30:53 +01:00
|
|
|
));
|
|
|
|
|
|
|
|
// Add repeats element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('checkbox', 'add_show_repeats', array(
|
2011-04-04 19:50:51 +02:00
|
|
|
'label' => 'Repeats?',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-30 18:24:39 +02:00
|
|
|
public function checkReliantFields($formData, $startDateModified) {
|
2011-04-04 19:50:51 +02:00
|
|
|
|
2011-01-31 03:42:53 +01:00
|
|
|
$valid = true;
|
|
|
|
|
2011-01-28 23:37:31 +01:00
|
|
|
$now_timestamp = date("Y-m-d H:i:s");
|
2011-05-30 18:24:39 +02:00
|
|
|
$start_timestamp = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
|
2011-01-28 23:37:31 +01:00
|
|
|
|
|
|
|
$now_epoch = strtotime($now_timestamp);
|
|
|
|
$start_epoch = strtotime($start_timestamp);
|
|
|
|
|
2011-01-31 03:42:53 +01:00
|
|
|
|
2011-06-03 20:53:01 +02: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'));
|
2011-01-31 03:42:53 +01:00
|
|
|
$valid = false;
|
2011-06-06 18:49:52 +02:00
|
|
|
}elseif( strstr($formData["add_show_duration"], '-') ){
|
|
|
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m'));
|
|
|
|
$valid = false;
|
2011-01-28 23:37:31 +01:00
|
|
|
}
|
2011-04-04 19:50:51 +02:00
|
|
|
|
2011-01-31 03:42:53 +01:00
|
|
|
return $valid;
|
2011-01-28 23:37:31 +01:00
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|