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
|
2012-07-11 00:55:44 +02:00
|
|
|
$this->addElement('select', 'add_show_repeat_type', array(
|
2011-02-09 00:22:51 +01:00
|
|
|
'required' => true,
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Repeat Type:'),
|
2011-02-10 00:47:49 +01:00
|
|
|
'class' => ' input_select',
|
2011-02-09 00:22:51 +01:00
|
|
|
'multiOptions' => array(
|
2012-11-22 23:32:24 +01:00
|
|
|
"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
|
2012-07-11 00:55:44 +02:00
|
|
|
$this->addElement(
|
2011-01-21 00:30:53 +01:00
|
|
|
'multiCheckbox',
|
2011-01-21 19:25:12 +01:00
|
|
|
'add_show_day_check',
|
2011-01-21 00:30:53 +01:00
|
|
|
array(
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Select Days:'),
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => false,
|
|
|
|
'multiOptions' => array(
|
2012-11-22 23:32:24 +01:00
|
|
|
"0" => _("Sun"),
|
|
|
|
"1" => _("Mon"),
|
|
|
|
"2" => _("Tue"),
|
|
|
|
"3" => _("Wed"),
|
|
|
|
"4" => _("Thu"),
|
|
|
|
"5" => _("Fri"),
|
|
|
|
"6" => _("Sat"),
|
2011-01-21 00:30:53 +01:00
|
|
|
),
|
|
|
|
));
|
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add end date element
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_end_date', array(
|
2012-11-15 16:59:06 +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'),
|
2012-07-11 00:55:44 +02:00
|
|
|
'validators' => array(
|
|
|
|
'NotEmpty',
|
|
|
|
array('date', false, array('YYYY-MM-DD'))
|
|
|
|
)
|
2011-01-21 00:30:53 +01:00
|
|
|
));
|
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add no end element
|
|
|
|
$this->addElement('checkbox', 'add_show_no_end', array(
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('No End?'),
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => false,
|
2012-01-04 23:06:58 +01:00
|
|
|
'checked' => true,
|
2012-07-11 00:55:44 +02:00
|
|
|
));
|
2011-01-21 00:30:53 +01:00
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function disable()
|
|
|
|
{
|
2012-03-30 21:11:24 +02:00
|
|
|
$elements = $this->getElements();
|
2012-08-29 05:04:55 +02:00
|
|
|
foreach ($elements as $element) {
|
|
|
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
2012-04-05 22:01:27 +02:00
|
|
|
$element->setAttrib('disabled','disabled');
|
2012-03-30 21:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function checkReliantFields($formData)
|
|
|
|
{
|
|
|
|
if (!$formData['add_show_no_end']) {
|
2011-04-12 06:14:26 +02:00
|
|
|
$start_timestamp = $formData['add_show_start_date'];
|
|
|
|
$end_timestamp = $formData['add_show_end_date'];
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2011-04-12 06:14:26 +02:00
|
|
|
$start_epoch = strtotime($start_timestamp);
|
|
|
|
$end_epoch = strtotime($end_timestamp);
|
2011-01-31 02:11:18 +01:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
if ($end_epoch < $start_epoch) {
|
2012-11-15 16:59:06 +01:00
|
|
|
$this->getElement('add_show_end_date')->setErrors(array(_('End date must be after start date')));
|
2012-08-29 05:04:55 +02:00
|
|
|
|
2011-04-12 06:14:26 +02:00
|
|
|
return false;
|
|
|
|
}
|
2011-01-31 02:11:18 +01:00
|
|
|
}
|
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
|
|
|
|
|
|
|
}
|