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 validateUnique($validator, $values) { $c = new Criteria(); $c->add(StudentFreePeer::STUDENT_ID, $values['student_id']); $c->add(StudentFreePeer::CAREER_SCHOOL_YEAR_PERIOD_ID, $values['career_school_year_period_id']); if (!is_null($values['course_subject_id'])) { $c->add(StudentFreePeer::COURSE_SUBJECT_ID, $values['course_subject_id']); } $student_free = StudentFreePeer::doSelectOne($c); if (!is_null($student_free)) { throw new sfValidatorError($validator, 'Ya existe esta tupla.'); } return $values; }
public function updateFree(PropelPDO $con = null, $is_free) { if (is_null($con)) { $con = Propel::getConnection(StudentReincorporationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } try { $con->beginTransaction(); $c = new Criteria(); $c->add(StudentFreePeer::STUDENT_ID, $this->getStudentId()); $c->add(StudentFreePeer::COURSE_SUBJECT_ID, $this->getCourseSubjectId()); $c->add(StudentFreePeer::CAREER_SCHOOL_YEAR_PERIOD_ID, $this->getCareerSchoolYearPeriodId()); $student_free = StudentFreePeer::doSelectOne($c); if ($student_free) { $student_free->setIsFree($is_free); $student_free->save($con); } $con->commit(); } catch (Exception $e) { $con->rollBack(); } }
/** * This method check if exists a student_free with the parameters. * IF NOT exists then the student inst free, otherwise check the value of the student_free * * @see StudentPeer::retrieveByStudentCarreerSchoolyearPeriodAndCourse * * @param Student $student * @param CareerSchoolYearPeriod $career_school_year_period * @param type $course_subject * * @return boolean */ public function isFreeStudent(Student $student, CareerSchoolYearPeriod $career_school_year_period = null, CourseSubject $course_subject = null, CareerSchoolYear $career_school_year) { $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year); $student_free = StudentFreePeer::retrieveByStudentCareerSchoolYearCareerSchoolYearPeriodAndCourse($student_career_school_year, $career_school_year_period, $course_subject); return is_null($student_free) ? false : $student_free->getIsFree(); }
/** * This method returns true if has been free at least one time in the current year and if flag is_free is true. * @return boolean */ public function canBeReincorporated() { return count(StudentFreePeer::retrieveCurrentAndIsFree(null, $this->getId())) > 0; }
/** * This method returns all the free studens of the student in this year. * Depending of the configuration of the course , if has day attendance or course_subject attendance */ public function getStudentFrees() { $c = new Criteria(); $c->add(StudentFreePeer::STUDENT_ID, $this->getStudentId()); $c->add(StudentFreePeer::IS_FREE, true); if ($this->getCourseSubject()->hasAttendanceForSubject()) { $c->add(StudentFreePeer::COURSE_SUBJECT_ID, $this->getCourseSubjectId()); } //else //{ //$c->add(StudentFreePeer::COURSE_SUBJECT_ID, null, Criteria::ISNULL); //} return StudentFreePeer::doSelect($c); }