Exemplo n.º 1
0
 public function copyConfiguration(PropelPDP $con = null)
 {
     $con = is_null($con) ? Propel::getConnection() : $con;
     $c = new Criteria();
     $c->add(CareerSchoolYearPeer::CAREER_ID, $this->getCareerId());
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId(), Criteria::NOT_EQUAL);
     $c->addDescendingOrderByColumn(CareerSchoolYearPeer::ID);
     try {
         $con->beginTransaction();
         //First copy the career configuration.
         $last_career = CareerSchoolYearPeer::doSelectOne($c);
         $configuration = $last_career->getSubjectConfiguration()->copy();
         $this->setSubjectConfiguration($configuration);
         //Second copy the career_subjects configurations
         foreach ($this->getCareerSubjectSchoolYears() as $cssy) {
             $c = new Criteria();
             $c->add(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, $cssy->getCareerSubjectId());
             $c->add(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $last_career->getId());
             $last_career_subject = CareerSubjectSchoolYearPeer::doSelectOne($c);
             if (!is_null($last_career_subject) && !is_null($last_career_subject->getSubjectConfiguration())) {
                 $cssy->setSubjectConfiguration($last_career_subject->getSubjectConfiguration()->copy());
                 $cssy->save($con);
             }
         }
         $this->save($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e->getMessage();
     }
 }
Exemplo n.º 2
0
 public function getCareerSchoolYear()
 {
     $c = new Criteria();
     $c->add(CareerSchoolYearPeer::CAREER_ID, $this->getCareerId());
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     return CareerSchoolYearPeer::doSelectOne($c);
 }
Exemplo n.º 3
0
 public function getCareerSchoolYear()
 {
     $c = new Criteria();
     $c->add(CareerSchoolYearPeer::SUBJECT_CONFIGURATION_ID, $this->getId());
     return CareerSchoolYearPeer::doSelectOne($c);
 }