コード例 #1
0
ファイル: CareerSchoolYear.php プロジェクト: nvidela/kimkelen
 public function createLastYearDivisions()
 {
     $last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($this->getSchoolYear());
     $last_year_career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($this->getCareer(), $last_year_school_year);
     SchoolYearPeer::clearInstancePool();
     CareerSchoolYearPeer::clearInstancePool();
     $con = Propel::getConnection();
     try {
         $con->beginTransaction();
         $criteria = new Criteria();
         $criteria->add(DivisionPeer::CAREER_SCHOOL_YEAR_ID, $last_year_career_school_year->getId());
         $pager = new sfPropelPager('Division', 10);
         $pager->setCriteria($criteria);
         $pager->init();
         $last_page = $pager->getLastPage();
         for ($i = 1; $i <= $last_page; $i++) {
             $pager->setPage($i);
             $pager->init();
             $divisions = $pager->getResults();
             //This creates all the divisions, courses and courses subjects of the last year.
             foreach ($divisions as $division) {
                 $division->createCopyForSchoolYear($con, $this);
                 $division->clearAllReferences(true);
                 unset($division);
             }
             DivisionPeer::clearInstancePool();
         }
         unset($criteria);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
コード例 #2
0
 /**
  * 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();
     }
 }