public function createStudentsForNextYear(PropelPDO $con = null, CareerSchoolYear $last_career_school_year) { //$old_division = DivisionPeer::retrieveByDivisionTitleAndYearAndSchoolYear($this->getDivisionTitle(), $this->getYear() - 1, $last_career_school_year); //$students = $old_division->getStudents(); $c = new Criteria(); $c->addJoin(StudentPeer::ID, DivisionStudentPeer::STUDENT_ID, Criteria::INNER_JOIN); $c->addJoin(DivisionStudentPeer::DIVISION_ID, DivisionPeer::ID, Criteria::INNER_JOIN); $c->addAnd(DivisionPeer::YEAR, $this->getYear() - 1); $c->addAnd(DivisionPeer::DIVISION_TITLE_ID, $this->getDivisionTitleId()); $c->addAnd(DivisionPeer::CAREER_SCHOOL_YEAR_ID, $last_career_school_year->getId()); $c->addAnd(StudentPeer::ID, SchoolYearStudentPeer::retrieveStudentIdsForSchoolYear($last_career_school_year->getSchoolYear()), Criteria::IN); $students = StudentPeer::doSelect($c); foreach ($students as $student) { $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $this->getCareerSchoolYear()); StudentCareerSchoolYearPeer::clearInstancePool(); //If the student has not repeated last year. if (!is_null($student_career_school_year) && !$student_career_school_year->getIsRepproved()) { $division_student = new DivisionStudent(); $division_student->setStudent($student); $division_student->setDivision($this); $division_student->save($con); $division_student->clearAllReferences(true); unset($division_student); $student_career_school_year->clearAllReferences(true); unset($student_career_school_year); } $student->clearAllReferences(true); unset($student); } StudentPeer::clearInstancePool(); unset($students); }
public function createCopyForSchoolYear(PropelPDO $con = null, Division $division = null, CareerSchoolYear $career_school_year) { $copy_course = new Course(); $copy_course->setDivision($division); $copy_course->setName($this->getName()); $copy_course->setQuota($this->getQuota()); $copy_course->setSchoolYear($career_school_year->getSchoolYear()); $copy_course->save($con); $this->copyCourseSubjects($con, $division, $career_school_year, $copy_course); $copy_course->clearAllReferences(true); unset($copy_course); $this->clearAllReferences(true); }