public function validateDateRange(sfValidatorBase $validator, $values, $arguments = array()) { $from_date = strtotime($values['date_range']['from']); $to_date = strtotime($values['date_range']['to']); $periods = CareerSchoolYearPeriodPeer::retrieveCurrents(); $dates = array(); foreach ($periods as $p) { $dates[] = $p->getStartAt(); $dates[] = $p->getEndAt(); } sort($dates); $last_date = array_pop($dates); $first_date = array_shift($dates); $first_date = strtotime($first_date); $last_date = strtotime($last_date); if ($from_date < $first_date || $to_date > $last_date) { throw new sfValidatorErrorSchema($validator, array(new sfValidatorError($validator, 'Range chosen is not valid'))); } return $values; }
if ($course_subject_students_trimester) { ?> <?php $periods = CareerSchoolYearPeriodPeer::retrieveCurrents(CourseType::TRIMESTER); ?> <?php include_partial('absence_day_table', array('student_career_school_year' => $student_career_school_year, 'student' => $student, 'periods' => $periods)); ?> <?php } ?> <?php $course_subject_students_bimester = $student->getCourseSubjectStudentsForCourseType(CourseType::BIMESTER); ?> <?php if ($course_subject_students_bimester) { ?> <?php $periods = CareerSchoolYearPeriodPeer::retrieveCurrents(CourseType::BIMESTER); ?> <?php include_partial('absence_day_table', array('student_career_school_year' => $student_career_school_year, 'student' => $student, 'periods' => $periods)); ?> <?php } ?> </div> <div style="margin-top: 1px; clear: both;"></div> </div>