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 static function getPeriods($widget, $values) { $c = CareerSchoolYearPeriodPeer::retrieveCurrentsCriteria(); $c->add(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_ID, $values); $widget->setOption('criteria', $c); sfContext::getInstance()->getUser()->setAttribute('career_school_year_id', $values); }
public function setStudents($students, $career_school_year) { $this->students = $students; $this->career_school_year = $career_school_year; $csp = CareerSchoolYearPeriodPeer::getPeriodsSchoolYear($career_school_year->getId()); $this->periods = $csp; foreach ($students as $student) { $student_id = $student->getId(); //$student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year); $this->setWidget("student_{$student_id}", new mtWidgetFormPlain(array("object" => $student, "add_hidden_input" => false, "use_retrieved_value" => false))); $this->setValidator("student_{$student_id}", new sfValidatorPass()); //$this->setDefault("student_$student_id", $student_id); $this->widgetSchema->setLabel("student_{$student_id}", "Student"); foreach ($csp as $period) { $name = "conduct_" . $student->getId() . "_" . $period->getId(); $student_conduct = $student->getConductPeriod($period); if ($period->getIsClosed()) { $this->setWidget($name, new mtWidgetFormPlain(array("object" => $student_conduct, "add_hidden_input" => false, "use_retrieved_value" => false))); $this->setValidator($name, new sfValidatorPass()); } else { $this->setWidget($name, new sfWidgetFormPropelChoice(array('model' => 'Conduct', 'add_empty' => true))); $this->setValidator($name, new sfValidatorPropelChoice(array('model' => 'Conduct', 'required' => false))); if ($student_conduct) { $this->setDefault($name, $student_conduct->getConductId()); } } # $this->widgetSchema->setLabel("conduct_$student_id", "Conducta"); } } }
public function doSave($con = null) { if (is_null($con)) { $con = $this->getConnection(); } $course_subject = $this->getObject(); $values = $this->getValues(); $c = new Criteria(); if ($this->getCourseType() == CourseType::BIMESTER) { $c->add(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_PERIOD_ID, $values['quaterly_id']); } else { $c->add(CareerSchoolYearPeriodPeer::ID, $values['quaterly_id']); } $periods = CareerSchoolYearPeriodPeer::doSelect($c); try { $con->beginTransaction(); $cscs = CourseSubjectConfigurationPeer::retrieveBySubject($course_subject); foreach ($cscs as $csc) { $csc->delete($con); } foreach ($periods as $period) { $csc = new CourseSubjectConfiguration(); $csc->setCourseSubject($course_subject); $csc->setCareerSchoolYearPeriod($period); $csc->save($con); } $con->commit(); } catch (Exception $e) { $con->rollBack(); throw $e; } }
public function configure() { $sf_formatter_revisited = new sfWidgetFormSchemaFormatterRevisited($this); $this->getWidgetSchema()->addFormFormatter('Revisited', $sf_formatter_revisited); $this->getWidgetSchema()->setFormFormatterName('Revisited'); $course_subject = $this->getObject(); $course_type = $course_subject->getCareerSubjectSchoolYear()->getConfiguration()->getCourseType(); if (!$course_subject->getCourseSubjectConfigurations()) { $c = new Criteria(); $c->add(CareerSchoolYearPeriodPeer::COURSE_TYPE, $course_type); $c->add(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_ID, $course_subject->getCareerSubjectSchoolYear()->getCareerSchoolYearId()); $c->addAscendingOrderByColumn('start_at'); $periods = CareerSchoolYearPeriodPeer::doSelect($c); foreach ($periods as $period) { $csc = new CourseSubjectConfiguration(); $csc->setCareerSchoolYearPeriod($period); $course_subject->addCourseSubjectConfiguration($csc); $csc->save(); } } foreach ($course_subject->getCourseSubjectConfigurations() as $course_configuration) { $name = 'course_configuration_' . $course_configuration->getId(); $this->setWidget($name, new dcWidgetI18nNumberInput()); $this->getWidget($name)->setDefault($course_configuration->getMaxAbsence()); $this->setValidator($name, new dcValidatorI18NDecimal()); $this->getWidgetSchema()->setLabel($name, $course_configuration->getCareerSchoolYearPeriod()); } $this->getWidgetSchema()->setNameFormat('course_subject[%s]'); }
public function __toString() { if ($this->isBimester()) { $parent = CareerSchoolYearPeriodPeer::retrieveByPk($this->getCareerSchoolYearPeriodId()); return sprintf('%s del %s (%s)', $this->getName(), $parent->getName(), $this->getTermStr()); } return sprintf('%s (%s)', $this->getName(), $this->getTermStr()); }
public function doSave($con = null) { parent::doSave($con); $student = StudentPeer::retrieveByPk($this->getValue('student_id')); $career_school_year_period = CareerSchoolYearPeriodPeer::retrieveByPk($this->getValue('career_school_year_period_id')); $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year_period->getCareerSchoolYear()); $course_subject = CourseSubjectPeer::retrieveByPk($this->getValue('course_subject_id')); $student_free = StudentFreePeer::retrieveByStudentCareerSchoolYearCareerSchoolYearPeriodAndCourse($student_career_school_year, $career_school_year_period, $course_subject); $student_free->setIsFree(false); $student_free->save($con); }
public function setCourseTypes($course_type) { $division = $this->getObject(); if (!$division->getCourseSubjectConfigurations()) { $c = new Criteria(); $c->add(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_ID, $division->getCareerSchoolYearId()); $c->add(CareerSchoolYearPeriodPeer::COURSE_TYPE, $course_type); $c->addAscendingOrderByColumn('start_at'); $periods = CareerSchoolYearPeriodPeer::doSelect($c); foreach ($periods as $period) { $csc = new CourseSubjectConfiguration(); $csc->setCareerSchoolYearPeriod($period); $division->addCourseSubjectConfiguration($csc); $csc->save(); } } }
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; }
public function addIsFreeInSomePeriodColumnCriteria($criteria, $field, $value) { if ($value != '') { $criteria->addJoin(StudentFreePeer::STUDENT_ID, StudentPeer::ID); $criteria->add(StudentFreePeer::IS_FREE, $value); $criteria->addAnd(StudentFreePeer::CAREER_SCHOOL_YEAR_PERIOD_ID, CareerSchoolYearPeriodPeer::retrieveCurrentPeriodsIds(), Criteria::IN); } }
<td><?php echo StudentDisciplinarySanctionPeer::countStudentDisciplinarySanctionsForPeriod($student, $division->getSchoolYear(), $period); ?> </td> <?php } ?> </tr> </table> </div> <?php } elseif ($division->hasCourseType(CourseType::BIMESTER)) { ?> <?php $periods = CareerSchoolYearPeriodPeer::getBimesterPeriodsSchoolYear($division->getCareerSchoolYearId()); ?> <?php if ($division->hasAttendanceForDay()) { ?> <?php include_partial('bimester_attendance_for_day', array('student' => $student, 'periods' => $periods, 'division' => $division, 'has_to_show_repproveds' => $has_to_show_repproveds)); ?> <?php } ?> <?php if ($has_to_show_repproveds) { ?> <?php
<hr class="hr_break"> <?php include_partial('career_subject_repproved_details', array('examination_repproveds' => $examination_repproveds)); ?> <?php } ?> <div style="clear:both"></div> <hr class="hr_break"> <div class="title"><?php echo __('Admonition details'); ?> </div> <?php $periods_array = CareerSchoolYearPeriodPeer::getPeriodsArrayForCourseType($division->getCourseType(), $division->getCareerSchoolYearId()); ?> <div class="admonition_details"> <?php foreach ($periods_array as $short_name => $period) { ?> <?php if ($period->getIsClosed()) { ?> <table class="gridtable"> <thead> <tr> <td colspan="4" class="partial_average"><?php echo $period->getName(); ?>
/** * Este método recupera el periodo de un curso cuatrimestral y devuelve true si es el mismo es el primer cuatrimestre. * Devuelve false en caso de ser el 2do cuatrimeste. * * @return boolean */ public function isForFirstQuaterly() { $first_quaterly = CareerSchoolYearPeriodPeer::retrieveCurrentFirstQuaterly(); return $first_quaterly->getStartAt() == $this->getPeriod()->getStartAt(); }
public function getCareerSchoolYearPeriods() { if ($this->hasAttendanceForSubject()) { $c = new Criteria(); $c->addJoin(CareerSchoolYearPeriodPeer::ID, CourseSubjectConfigurationPeer::CAREER_SCHOOL_YEAR_PERIOD_ID); $c->add(CourseSubjectConfigurationPeer::COURSE_SUBJECT_ID, $this->getId()); $c->addAscendingOrderByColumn(CareerSchoolYearPeriodPeer::COURSE_TYPE); $c->addAscendingOrderByColumn(CareerSchoolYearPeriodPeer::START_AT); $periods = CareerSchoolYearPeriodPeer::doSelect($c); if (count($periods) == 0) { $periods = $this->getCareerSchoolYear()->getCareerSchoolYearPeriodsForYearAndCourseType($this->getYear(), $this->getCourseType()); } return $periods; } else { $periods = $this->getCareerSchoolYear()->getCareerSchoolYearPeriodsForYearAndCourseType($this->getYear(), $this->getCourseType()); return $periods; } }
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>
public function getCareerSchoolyearPeriods() { $c = new Criteria(); $c->add(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_ID, $this->getCareerSchoolYearId()); $c->add(CareerSchoolYearPeriodPeer::COURSE_TYPE, $this->getCourseType()); $c->addAscendingOrderByColumn(CareerSchoolYearPeriodPeer::COURSE_TYPE); $c->addAscendingOrderByColumn(CareerSchoolYearPeriodPeer::START_AT); return CareerSchoolYearPeriodPeer::doSelect($c); }
public function isFreeInDay($day, $course_subject) { if (is_null($course_subject_id)) { $career_school_year_period_type = SchoolBehaviourFactory::getInstance()->getDivisionCourseType(); } else { $career_school_year_period_type = $course_subject->getCourseType(); } $career_school_year_period = CareerSchoolYearPeriodPeer::retrieveByDateAndCourseType($day, $career_school_year_period_type); return $this->isFree($career_school_year_period, $course_subject); }
$clasz = is_null($period) ? '' : $student->getFreeClass($period, $course_subject, CareerSchoolYearPeer::retrieveByPk($career_school_year_id), $division); ?> <?php if (is_null($period)) { ?> <?php $period = CareerSchoolYearPeriodPeer::retrieveByDay($day, $division->getCourseType()); ?> <?php $clasz = is_null($period) ? '' : $student->getFreeClass($period, $course_subject, CareerSchoolYearPeer::retrieveByPk($career_school_year_id), $division); ?> <?php } elseif ($period->getEndAt() < date('Y-m-d', $day)) { ?> <?php $period = CareerSchoolYearPeriodPeer::retrieveByDay($day, $division->getCourseType()); ?> <?php $clasz = is_null($period) ? '' : $student->getFreeClass($period, $course_subject, CareerSchoolYearPeer::retrieveByPk($career_school_year_id), $division); ?> <?php } ?> <?php } ?> <?php $student_attendance = StudentAttendancePeer::retrieveByDateAndStudent(date('Y-m-d', $day), $student, $course_subject_id, $career_school_year_id); ?>