public static function retrieveLastYearStudentNotGraduatedCriteria($career_school_year)
 {
     $school_year = SchoolYearPeer::retrieveLastYearSchoolYear($career_school_year->getSchoolYear());
     $c = new Criteria();
     $c->addJoin(StudentPeer::ID, CareerStudentPeer::STUDENT_ID, Criteria::INNER_JOIN);
     $c->addAnd(CareerStudentPeer::STATUS, CareerStudentStatus::GRADUATE, criteria::NOT_EQUAL);
     $c->addAnd(CareerStudentPeer::CAREER_ID, $career_school_year->getCareer()->getId());
     $c->addAnd(StudentPeer::ID, SchoolYearStudentPeer::retrieveStudentIdsForSchoolYear($school_year), Criteria::IN);
     return $c;
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 public function createStudentCareerSchoolYear(PropelPDO $con)
 {
     $c = new Criteria();
     $c->addJoin(SchoolYearPeer::ID, SchoolYearStudentPeer::SCHOOL_YEAR_ID);
     $c->add(SchoolYearPeer::IS_ACTIVE, true);
     $c->add(SchoolYearStudentPeer::STUDENT_ID, $this->getStudentId());
     $school_year_student = SchoolYearStudentPeer::doSelectOne($c, $con);
     if ($school_year_student) {
         $career_school_year = $this->getCareer()->getCareerSchoolYear($school_year_student->getSchoolYear($con));
         if ($career_school_year && StudentCareerSchoolYearPeer::countByCareerAndStudent($this->getCareerId(), $this->getStudentId(), $school_year_student->getSchoolYearId(), $con) == 0) {
             $student_career_school_year = new StudentCareerSchoolYear();
             $student_career_school_year->setCareerSchoolYearId($career_school_year->getId());
             $student_career_school_year->setStudentId($this->getStudentId());
             $student_career_school_year->setYear($this->suggestYear());
             $student_career_school_year->save($con);
         }
     }
 }
 /**
  * This method check if the students pass the year or not
  *
  * @param SchoolYear $school_year
  * @param PropelPDO $con
  */
 public function closeSchoolYear(SchoolYear $school_year, PropelPDO $con = null)
 {
     $criteria = SchoolYearStudentPeer::retrieveStudentsForSchoolYearCriteria($school_year);
     $pager = new sfPropelPager('Student', 100);
     $pager->setCriteria($criteria);
     $pager->init();
     $last_page = $pager->getLastPage();
     for ($i = 1; $i <= $last_page; $i++) {
         $pager->setPage($i);
         $pager->init();
         $students = $pager->getResults();
         foreach ($students as $student) {
             if ($student->getLastStudentCareerSchoolYear()->getStatus() != StudentCareerSchoolYearStatus::WITHDRAWN_WITH_RESERVE) {
                 $this->stepToNextYear($student, $school_year, $con);
             }
         }
         $school_year->setIsClosed(true);
         $school_year->save($con);
         StudentPeer::clearInstancePool();
     }
 }
Beispiel #5
0
 public function getHealthInfoString()
 {
     $school_year = SchoolYearPeer::retrieveCurrent();
     $c = new Criteria();
     $c->add(SchoolYearStudentPeer::STUDENT_ID, $this->getId());
     $c->add(SchoolYearStudentPeer::SCHOOL_YEAR_ID, $school_year->getId());
     $school_year_student = SchoolYearStudentPeer::doSelectOne($c);
     SchoolYearStudentPeer::clearInstancePool();
     return is_null($school_year_student) ? ' ' : $school_year_student->getHealthInfo();
 }
Beispiel #6
0
 /**
  * This action deletes a created SchoolYear registration for selected student
  *
  * @see executeRegisterForCurrentSchoolYear
  * @param sfWebRequest $request
  */
 public function executeDeleteRegistrationForCurrentSchoolYear(sfWebRequest $request)
 {
     if ($request->isMethod("POST")) {
         $s = SchoolYearStudentPeer::retrieveByPK($request->getParameter('school_year_student_id'));
         if (!is_null($s)) {
             $s->delete();
             $this->getUser()->setFlash('info', 'The item was deleted successfully.');
             $this->redirect('@student');
         }
     }
     $this->getUser()->setFlash('error', "The current school year student registration can't be deleted");
     $this->redirect('@student');
 }