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 getMaxAbsenceForPeriod($period = null) { if ($this->getIsAbsenceForPeriod()) { $c = new Criteria(); $c->add(CourseSubjectConfigurationPeer::DIVISION_ID, $this->getId()); $c->add(CourseSubjectConfigurationPeer::CAREER_SCHOOL_YEAR_PERIOD_ID, $period->getId()); $course_configuration = CourseSubjectConfigurationPeer::doSelectOne($c); $max_absence = is_null($course_configuration) ? sfConfig::get('app_max_absence', 10) : $course_configuration->getMaxAbsence(); } else { $max_absence = $this->getCareerSchoolYear()->getMaxAbsenceInYear($this->getYear()); } return $max_absence; }
public function deleteCourseSubjectConfiguration() { foreach (CourseSubjectConfigurationPeer::retrieveBySubject($this) as $csc) { $csc->delete(); } }
public function getCourseSubjectStudentsForBimesterQuaterly($quaterly, $student_career_school_year = null) { $results = array(); foreach ($this->getCourseSubjectStudentsForCourseType(CourseType::BIMESTER, $student_career_school_year) as $css) { $subject_configurations = CourseSubjectConfigurationPeer::retrieveBySubject($css->getCourseSubject()); foreach ($subject_configurations as $sc) { if ($sc->getCareerSchoolYearPeriod()->getCareerSchoolYearPeriodId() == $quaterly->getId()) { $results[$css->getId()] = $css; } } } return $results; }
public function getCourseSubjectConfigurationForms($course_subjects) { $forms = array(); $i = 0; $c = new Criteria(); foreach ($course_subjects as $course_subject) { $course_type = $course_subject->getCareerSubjectSchoolYear()->getConfiguration()->getCourseType(); $first_form = $course_type == CourseType::BIMESTER || $course_type == CourseType::QUATERLY_OF_A_TERM; $c->add(CourseSubjectConfigurationPeer::COURSE_SUBJECT_ID, $course_subject->getId()); $new = CourseSubjectConfigurationPeer::doSelect($c); #var_dump($is_bimester,!count($new), 'OR',$course_subject->hasAttendanceForDay()); if ($first_form && !count($new) || $first_form && $course_subject->hasAttendanceForDay()) { $forms[$course_subject->getId()] = new CourseSubjectConfigurationFirstForm($course_subject); $forms[$course_subject->getId()]->setCourseType($course_type); } else { $forms[$course_subject->getId()] = new CourseSubjectConfigurationManyForm($course_subject); } $forms[$course_subject->getId()]->getWidgetSchema()->setNameFormat("course_subject_{$i}[%s]"); $i++; } return $forms; }