Example #1
0
 protected function doSave($con = null)
 {
     //parent::doSave($con);
     $con = is_null($con) ? Propel::getConnection() : $con;
     $values = $this->getValues();
     try {
         $con->beginTransaction();
         if (array_key_exists('division_courses', $values)) {
             if (array_key_exists('division_title_ids', $values)) {
                 $division_title_ids = $values['division_title_ids'];
                 foreach ($division_title_ids as $division_title_id) {
                     if (DivisionPeer::checkUnique($division_title_id, $values['career_school_year_id'], $values['year'])) {
                         $division = new Division();
                         $division->setDivisionTitleId($division_title_id);
                         $division->setCareerSchoolYearId($values['career_school_year_id']);
                         $division->setShiftId($values['shift_id']);
                         $division->setYear($values['year']);
                         $this->createPreceptor($division, $con);
                         if ($this->getObject()->isNew()) {
                             foreach ($this->values['division_courses'] as $career_subject_school_year_id) {
                                 $division->createCourse($career_subject_school_year_id, $con);
                             }
                         }
                         $division->save($con);
                     }
                 }
             }
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
Example #2
0
 public function createCopyForSchoolYear(PropelPDO $con = null, $career_school_year)
 {
     $copy_division = new Division();
     $copy_division->setDivisionTitle($this->getDivisionTitle());
     $copy_division->setCareerSchoolYear($career_school_year);
     $copy_division->setShift($this->getShift());
     $copy_division->setYear($this->getYear());
     $copy_division->save($con);
     $this->copyPreceptorsToDivision($con, $copy_division);
     $this->copyCoursesToDivision($con, $copy_division, $career_school_year);
     if ($this->getYear() <= $career_school_year->getCareer()->getQuantityYears() && $this->getYear() > 1) {
         $copy_division->createStudentsForNextYear($con, $this->getCareerSchoolYear());
     }
     $copy_division->clearAllReferences(true);
     unset($copy_division);
     $career_school_year->clearAllReferences(true);
     unset($career_school_year);
     $this->clearAllReferences(true);
 }