예제 #1
0
 /**
  * This method try to find if there are new CareerSubjects for our Career, recently
  * created but without a CareerSubjectSchoolYear created
  *
  */
 public function checkCareerSubjectOptionsIntegrity()
 {
     $criteria = new Criteria();
     $criteria->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID, Criteria::INNER_JOIN);
     $criteria->addAnd(CareerSchoolYearPeer::CAREER_ID, $this->getCareerId());
     $all_career_subjects_sy = array_map(create_function('$cs', 'return $cs->getCareerSubjectId();'), CareerSubjectSchoolYearPeer::doSelect($criteria));
     $criteria->clear();
     $criteria->addAnd(CareerSubjectPeer::CAREER_ID, $this->getCareerId());
     $criteria->addAnd(CareerSubjectPeer::ID, $all_career_subjects_sy, Criteria::NOT_IN);
     $con = Propel::getConnection(SchoolYearPeer::DATABASE_NAME);
     try {
         foreach (CareerSubjectPeer::doSelect($criteria) as $career_subject) {
             $career_subject_school_year = new CareerSubjectSchoolYear();
             $career_subject_school_year->setCareerSchoolYear($this);
             $career_subject_school_year->setCareerSubject($career_subject);
             $career_subject_school_year->save($con);
         }
         $con->commit();
     } catch (PropelPDOException $e) {
         $con->rollBack();
         throw $e;
     }
 }
예제 #2
0
 public function addToCurrentCareerSchoolYear(PropelPDO $con = null)
 {
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     $career_school_year = $this->getCareerSchoolYear();
     try {
         $con->beginTransaction();
         $career_subject_school_year = new CareerSubjectSchoolYear();
         $career_subject_school_year->setCareerSubject($this);
         $career_subject_school_year->setCareerSchoolYear($career_school_year);
         $career_subject_school_year->save($con);
         $students = StudentPeer::retrieveForCareerSchoolYearAndYear($career_school_year, $this->getYear());
         foreach ($students as $student) {
             $student_career_subject_allowed = new StudentCareerSubjectAllowed();
             $student_career_subject_allowed->setCareerSubject($this);
             $student_career_subject_allowed->setStudent($student);
             $student_career_subject_allowed->save($con);
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
예제 #3
0
 public function createCareerSchoolYear($career)
 {
     $con = Propel::getConnection(SchoolYearPeer::DATABASE_NAME);
     try {
         $con->beginTransaction();
         $career_school_year = new CareerSchoolYear();
         $career_school_year->setSchoolYear($this);
         $career_school_year->setCareer($career);
         $subject_configuration = $this->createOrCopyLastYearSubjectConfiguration($career, $con);
         $career_school_year->setSubjectConfiguration($subject_configuration);
         $career_school_year->save($con);
         foreach ($career->getCareerSubjects() as $career_subject) {
             $career_subject_school_year = new CareerSubjectSchoolYear();
             $career_subject_school_year->setCareerSchoolYear($career_school_year);
             $career_subject_school_year->setCareerSubject($career_subject);
             $career_subject_school_year->copyLastYearConfiguration();
             $career_subject_school_year->copyLastYearSort();
             $career_subject_school_year->save($con);
         }
         $con->commit();
     } catch (PropelPDOException $e) {
         $con->rollBack();
         throw $e;
     }
 }