2011-01-21 00:30:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|
|
|
{
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
2011-02-09 00:22:51 +01:00
|
|
|
//Add type select
|
|
|
|
$this->addElement('select', 'add_show_repeat_type', array(
|
|
|
|
'required' => true,
|
2011-02-10 00:47:49 +01:00
|
|
|
'label' => 'Repeat Type:',
|
|
|
|
'class' => ' input_select',
|
2011-02-09 00:22:51 +01:00
|
|
|
'multiOptions' => array(
|
|
|
|
"0" => "weekly",
|
|
|
|
"1" => "bi-weekly",
|
|
|
|
"2" => "monthly"
|
2011-04-04 19:50:51 +02:00
|
|
|
),
|
2011-02-09 00:22:51 +01:00
|
|
|
));
|
|
|
|
|
2011-01-21 00:30:53 +01:00
|
|
|
// Add days checkboxes
|
|
|
|
$this->addElement(
|
|
|
|
'multiCheckbox',
|
2011-01-21 19:25:12 +01:00
|
|
|
'add_show_day_check',
|
2011-01-21 00:30:53 +01:00
|
|
|
array(
|
|
|
|
'label' => 'Select Days:',
|
|
|
|
'required' => false,
|
|
|
|
'multiOptions' => array(
|
|
|
|
"0" => "Sun",
|
|
|
|
"1" => "Mon",
|
|
|
|
"2" => "Tue",
|
|
|
|
"3" => "Wed",
|
|
|
|
"4" => "Thu",
|
|
|
|
"5" => "Fri",
|
|
|
|
"6" => "Sat",
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
|
|
|
// Add end date element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_end_date', array(
|
2011-01-21 00:30:53 +01:00
|
|
|
'label' => 'Date End:',
|
2011-01-31 02:11:18 +01:00
|
|
|
'class' => 'input_text',
|
2011-02-11 21:59:16 +01:00
|
|
|
'value' => date("Y-m-d"),
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => false,
|
|
|
|
'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
|
|
|
));
|
|
|
|
|
|
|
|
// Add no end element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('checkbox', 'add_show_no_end', array(
|
2011-04-04 19:50:51 +02:00
|
|
|
'label' => 'No End?',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => false,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-01-31 02:11:18 +01:00
|
|
|
public function checkReliantFields($formData) {
|
2011-04-04 19:50:51 +02:00
|
|
|
|
2011-01-31 02:11:18 +01:00
|
|
|
$start_timestamp = $formData['add_show_start_date'];
|
|
|
|
$end_timestamp = $formData['add_show_end_date'];
|
|
|
|
|
|
|
|
$start_epoch = strtotime($start_timestamp);
|
|
|
|
$end_epoch = strtotime($end_timestamp);
|
|
|
|
|
|
|
|
if($end_epoch < $start_epoch) {
|
|
|
|
$this->getElement('add_show_end_date')->setErrors(array('End date must be after start date'));
|
|
|
|
return false;
|
|
|
|
}
|
2011-04-04 19:50:51 +02:00
|
|
|
|
2011-01-31 02:11:18 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|