CC-2116 : Add Extra Form Validation For Rebroadcasts
can only schedule rebroadcast shows an hour after original broadcast or later. zend date validator passes '09:0f' which it shouldn't...
This commit is contained in:
parent
7a49137edd
commit
132c78453a
6 changed files with 148 additions and 15 deletions
|
@ -178,6 +178,38 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
|
|||
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData) {
|
||||
|
||||
$valid = true;
|
||||
|
||||
for($i=1; $i<=5; $i++) {
|
||||
|
||||
$day = $formData['add_show_rebroadcast_absolute_date_'.$i];
|
||||
|
||||
if($day == "") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$show_start_time = $formData['add_show_start_date']."".$formData['add_show_start_time'];
|
||||
$show_end = new DateTime($show_start_time);
|
||||
|
||||
$duration = $formData['add_show_duration'];
|
||||
$duration = explode(":", $duration);
|
||||
|
||||
$show_end->add(new DateInterval("PT$duration[0]H"));
|
||||
$show_end->add(new DateInterval("PT$duration[1]M"));
|
||||
$show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast
|
||||
|
||||
$rebroad_start = $day."".$formData['add_show_rebroadcast_absolute_time_'.$i];
|
||||
$rebroad_start = new DateTime($rebroad_start);
|
||||
|
||||
if($rebroad_start < $show_end) {
|
||||
$this->getElement('add_show_rebroadcast_absolute_time_'.$i)->setErrors(array("Must wait at least 1 hour to rebroadcast"));
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue