public function configure()
 {
     $student_id = $this->getOption('student_id');
     $this->student = StudentPeer::retrieveByPK($student_id);
     $this->career_school_year_id = $this->getOption('career_school_year_id');
     $this->course_subject_id = $this->getOption('course_subject_id');
     $this->division_id = $this->getOption('division_id');
     $sf_formatter_attendance_week = new sfWidgetFormSchemaFormatterAttendanceWeek($this->getWidgetSchema());
     $this->getWidgetSchema()->addFormFormatter("AttendanceWeek", $sf_formatter_attendance_week);
     $this->getWidgetSchema()->setFormFormatterName('AttendanceWeek');
     $day = $this->getOption('day');
     $this->widgetSchema->setNameFormat('attendance_' . $student_id . '][%s]');
     #student
     $this->setWidget("student_id", new sfWidgetFormInputHidden());
     $this->setValidator("student_id", new sfValidatorPropelChoice(array("model" => "Student", "required" => true)));
     $this->setWidget("student", new mtWidgetFormPlain(array('object' => $this->student)));
     for ($i = 0; $i <= 6; $i++) {
         $day_i = date('Y-m-d', strtotime($day . '-' . $i . 'day a go'));
         $student_attendance = StudentAttendancePeer::retrieveOrCreateByDateAndStudent($day_i, $this->student, $this->getOption('course_subject_id'));
         if ($student_attendance) {
             $this->setDefault("value_" . $i, $student_attendance->getAbsenceTypeId());
         }
         $this->setWidget("value_" . $i, $this->getAttendanceWidget());
         $this->getWidget("value_" . $i, $this->getAttendanceWidget())->setAttribute('class', 'attendance_week_input');
         $this->setValidator("value_" . $i, $this->getAttendanceValidator());
     }
     $this->setDefault("student_id", $student_id);
     $this->disableCSRFProtection();
     $this->course_subject = CourseSubjectPeer::retrieveByPK($this->course_subject_id);
     $period = CareerSchoolYearPeriodPeer::retrieveByPK($this->course_subject->getCourse()->getCurrentPeriod());
     $this->setWidget('period', new mtWidgetFormPartial(array('module' => 'student_attendance', 'partial' => 'totalAbsences', 'form' => $this, 'parameters' => array('career_school_year_id' => $this->career_school_year_id, 'period' => $period, 'course_subject_id' => $this->course_subject_id, 'student' => $this->student))));
     $this->getWidgetSchema()->moveField('period', sfWidgetFormSchema::LAST);
 }
 /**
  * Este metodo recupera el periodo padre de un curso bimestral y devuelve true si es el primero del cuatrimestre
  *Siempre va a exisistir solo un periodo padre distinto al que recupero, porque los cuatrimestres son siempre dos.
  *
  * @return boolean
  */
 public function parentIsFirst()
 {
     $parent_period = CareerSchoolYearPeriodPeer::retrieveByPK($this->getPeriod()->getCareerSchoolYearPeriodId());
     $c = new Criteria();
     $c->add(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_ID, $parent_period->getCareerSchoolYearId());
     $c->add(CareerSchoolYearPeriodPeer::COURSE_TYPE, $parent_period->getCourseType());
     $c->add(CareerSchoolYearPeriodPeer::ID, $parent_period->getId(), Criteria::NOT_EQUAL);
     $compare_period = CareerSchoolYearPeriodPeer::doSelectOne($c);
     return $parent_period->getStartAt() < $compare_period->getStartAt();
 }