public function createStudentCareerSchoolYear($con)
 {
     $c = new Criteria();
     $c->add(CareerStudentPeer::STUDENT_ID, $this->getStudentId());
     foreach (CareerStudentPeer::doSelect($c) as $career_student) {
         /*
          * @CareerStudent $career_student
          */
         $career_school_year = $career_student->getCareer()->getCareerSchoolYear($this->getSchoolYear());
         if ($career_school_year && StudentCareerSchoolYearPeer::countByCareerAndStudent($career_student->getCareerId(), $career_student->getStudentId(), $this->getSchoolYearId()) == 0) {
             $last_student_career_school_year = $career_student->getCurrentStudentCareerSchoolYear();
             $year = is_null($last_student_career_school_year) ? $career_student->getStartYear() : $last_student_career_school_year->suggestYear();
             if ($year <= $career_school_year->getCareer()->getQuantityYears()) {
                 $student_career_school_year = new StudentCareerSchoolYear();
                 $student_career_school_year->setCareerSchoolYear($career_school_year);
                 $student_career_school_year->setStudentId($this->getStudentId());
                 //SI REPITIO
                 if (!is_null($last_student_career_school_year) && $last_student_career_school_year->getStatus() == StudentCareerSchoolYearStatus::REPPROVED) {
                     $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::LAST_YEAR_REPPROVED);
                 }
                 $student_career_school_year->setYear($year);
                 $student_career_school_year->save($con);
             }
         }
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $this->createContextInstance('backend');
     $c = new Criteria();
     //$c->add(CareerStudentPeer::STUDENT_ID, 1080);
     $school_year = SchoolYearPeer::retrieveCurrent();
     try {
         $connection->beginTransaction();
         foreach (CareerStudentPeer::doSelect($c) as $career_student) {
             $student = $career_student->getStudent();
             $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($career_student->getCareer(), $school_year);
             $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year);
             if (is_null($student_career_school_year)) {
                 $this->logSection("Continue", '1');
                 continue;
             }
             $year = $student_career_school_year->getYear();
             $c = new Criteria();
             $c->add(CareerSubjectPeer::CAREER_ID, $career_student->getCareerId());
             $c->add(CareerSubjectPeer::YEAR, $year);
             foreach (CareerSubjectPeer::doSelect($c) as $career_subject) {
                 if (StudentCareerSubjectAllowedPeer::doCountStudentAndCareerSubject($student, $career_subject) == 0) {
                     $obj = new StudentCareerSubjectAllowed();
                     $obj->setStudentId($student->getId());
                     $obj->setCareerSubject($career_subject);
                     $obj->save($connection);
                     $this->logSection("Allowed agregado: ", $career_subject->getId());
                 }
             }
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollback();
         throw $e;
     }
 }