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-01-21 00:30:53 +01:00
|
|
|
'label' => 'Date 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'))
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
// Add start time element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_start_time', array(
|
2011-01-21 00:30:53 +01:00
|
|
|
'label' => 'Start Time:',
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
2011-02-12 23:21:37 +01:00
|
|
|
'value' => '0: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-01-21 00:30:53 +01:00
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
// Add duration element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_duration', array(
|
2011-01-21 00:30:53 +01:00
|
|
|
'label' => 'Duration:',
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-02-11 01:53:41 +01:00
|
|
|
'value' => '1:00',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
|
|
|
'filters' => array('StringTrim'),
|
2011-02-13 00:40:17 +01:00
|
|
|
'validators' => array(
|
|
|
|
'NotEmpty',
|
|
|
|
array('regex', false,
|
|
|
|
array('/^\d+:[0-5][0-9]$/',
|
|
|
|
'messages' => 'enter a duration: HH:mm'))
|
|
|
|
)
|
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-01-21 00:30:53 +01:00
|
|
|
'label' => 'repeats',
|
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-31 02:11:18 +01:00
|
|
|
public function checkReliantFields($formData) {
|
2011-01-28 23:37:31 +01: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");
|
|
|
|
$start_timestamp = $formData['add_show_start_date']."".$formData['add_show_start_time'];
|
|
|
|
|
|
|
|
$now_epoch = strtotime($now_timestamp);
|
|
|
|
$start_epoch = strtotime($start_timestamp);
|
|
|
|
|
|
|
|
if($start_epoch < $now_epoch) {
|
|
|
|
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
|
2011-01-31 03:42:53 +01:00
|
|
|
$valid = false;
|
|
|
|
}
|
|
|
|
|
2011-01-31 03:47:59 +01:00
|
|
|
if(strtotime("00:00") == strtotime($formData["add_show_duration"])) {
|
|
|
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00:00'));
|
2011-01-31 03:42:53 +01:00
|
|
|
$valid = false;
|
2011-01-28 23:37:31 +01: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
|
|
|
|
|
|
|
}
|
|
|
|
|