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); }
public function configureStudents() { $this->year = $this->getDefault('year'); $this->division_id = $this->getDefault('division_id'); $this->course_subject_id = $this->getDefault('course_subject_id') == '' || $this->getDefault('course_subject_id') === null ? null : $this->getDefault('course_subject_id'); $this->division = DivisionPeer::retrieveByPK($this->division_id); $this->course_subject = CourseSubjectPeer::retrieveByPK($this->course_subject_id); $this->career_school_year_id = $this->getDefault('career_school_year_id'); $this->configureDays(); $sf_user = sfContext::getInstance()->getUser(); //$this->students = StudentPeer::getStudentsForAttendance($sf_user, $this->division_id, $this->course_subject_id, $this->career_school_year_id); $this->students = $this->getStudents(); $days_disabled = array(); foreach ($this->students as $student) { $name = 'student_name_' . $student->getId(); $this->setWidget($name, new mtWidgetFormPlain(array('object' => $student))); $this->setValidator($name, new sfValidatorPass()); foreach ($this->days as $day => $day_i) { if (!isset($days_disabled[$day])) { $days_disabled[$day] = true; } $name = 'student_attendance_' . $student->getId() . '_' . $day; $this->setAbsenceWidget($name); $student_attendance = StudentAttendancePeer::retrieveByDateAndStudent($day_i, $student, $this->course_subject_id, $this->career_school_year_id); if (!is_null($student_attendance)) { $this->setAttendanceDefault($name, $student_attendance); $days_disabled[$day] = false; } } } $this->configureDaysWidget($days_disabled); return $days_disabled; }
public function executeDeleteSubject(sfWebRequest $request) { //TODO: Ver de extenderlo de commissionActions $cs = CourseSubjectPeer::retrieveByPK($request->getParameter('course_subject_id')); if ($cs and $course = $cs->getCourse() and $course->isPathway()) { try { $cs->delete(); $this->getUser()->setFlash("notice", "The item was deleted successfully."); } catch (PropelException $e) { $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items.'); } } else { $this->getUser()->setFlash('error', 'The selected item is not a pathway commission.'); } $this->redirect("@pathway_commission"); }
public function executePrintAttendanceTemplate(sfWebRequest $request) { $this->month = $request->getParameter('month'); $this->url = $request->getParameter('url'); $this->id = $request->getParameter('id'); $this->nextMonth = $this->month < 12 ? $this->month + 1 : 1; $this->prevMonth = $this->month > 1 ? $this->month - 1 : 12; $this->monthName = date("F", mktime(0, 0, 0, $this->month, 1, 2015)); if ($this->url == "division") { $this->division_id = $request->getParameter('division_id'); $this->division = DivisionPeer::retrieveByPK($this->id); $this->students = $this->division->getStudents(); $this->days = $this->getDaysOfMonth($this->month); $this->course_subject = null; } elseif ($this->url == "commission") { $this->course_subject = CourseSubjectPeer::retrieveByPK($this->id); $this->students = $this->course_subject->getStudents(); $this->days = $this->getDaysOfMonth($this->month); } $this->setLayout('cleanLayout'); }
</div> <?php } ?> <?php echo $form->renderHiddenFields(); ?> <?php echo $form->renderGlobalErrors(); ?> <?php $course_subject_id = isset($form->course_subject_id) ? $form->course_subject_id : null; ?> <?php $course_subject = CourseSubjectPeer::retrieveByPK($course_subject_id); ?> <?php $career_school_year = $form->getCareerSchoolYear(); ?> <?php $absence_for_period = $form->isAbsenceForPeriod(); ?> <?php if ($absence_for_period) { ?> <?php $career_school_year_periods = $form->getCareerSchoolYearPeriods(); ?>
public function executeDeleteSubject(sfWebRequest $request) { $cs = CourseSubjectPeer::retrieveByPK($request->getParameter('course_subject_id')); try { $cs->delete(); $this->getUser()->setFlash("notice", "The item was deleted successfully."); } catch (PropelException $e) { $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items.'); } $this->redirect("@commission"); }
public function executeUpdateMoveStudents(sfWebRequest $request) { $this->origin_course_subject = CourseSubjectPeer::retrieveByPK($request->getParameter('id')); $this->form = new MoveStudentsToCourseSubjectForm(array(), array('course_subject' => $this->origin_course_subject)); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { try { $parameters = $request->getParameter('move_students'); $destiny_course_subject = CourseSubjectPeer::retrieveByPK($parameters['destiny_course_subject_id']); $students = $parameters['students']; $destiny_course_subject->addStudentsFromCourseSubject($students, $this->origin_course_subject); $this->getUser()->setFlash('notice', 'Los alumnos seleccionados han sido correctamente movidos de comisión.'); } catch (Exception $e) { $this->getUser()->setFlash('error', 'Ocurrieron errores que no permitieron concretar la acción. Compruebe que las comisiones origen y destino no estén cerradas. Tampoco se permitirá mover alumnos si ya se calificó a alguno o si se pasó asistencia al curso origen.'); } } else { $this->setProcessFormErrorFlash(); } $this->setTemplate('moveStudents'); }