public function getCareerStudent(PropelPDO $con = null)
 {
     $c = new Criteria();
     $c->add(CareerStudentPeer::STUDENT_ID, $this->getStudentId());
     $c->add(CareerStudentPeer::CAREER_ID, $this->getCareerSubject()->getCareerId());
     return CareerStudentPeer::doSelectOne($c);
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $con = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     $this->createContextInstance('backend');
     $c = new Criteria();
     $student_career_school_years = StudentCareerSchoolYearPeer::doSelect($c);
     try {
         $school_year = SchoolYearPeer::retrieveByPk(3);
         foreach ($student_career_school_years as $student_career_school_year) {
             $year = $student_career_school_year->getYear();
             $c = new Criteria();
             $c->add(StudentCareerSubjectAllowedPeer::STUDENT_ID, $student_career_school_year->getStudentId());
             StudentCareerSubjectAllowedPeer::doDelete($c);
             if ($year < 7) {
                 $year++;
                 if ($year == 1 || $year == 4) {
                     $career = CareerPeer::retrieveByPk(8);
                 } else {
                     $career = CareerPeer::retrieveByPk(4);
                 }
                 $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($career, $school_year);
                 $c = new Criteria();
                 $c->add(CareerStudentPeer::STUDENT_ID, $student_career_school_year->getStudentId());
                 $career_student = CareerStudentPeer::doSelectOne($c);
                 $career_student->setCareer($career);
                 $career_student->setFileNumber($career_student->getFileNumber() + rand());
                 $career_student->save($con);
                 $career_student->createStudentsCareerSubjectAlloweds($year, $con);
                 $new_student_career_school_year = new StudentCareerSchoolYear();
                 $new_student_career_school_year->setStudent($student_career_school_year->getStudent());
                 $new_student_career_school_year->setCareerSchoolYear($career_school_year);
                 $new_student_career_school_year->setYear($year);
                 $new_student_career_school_year->save($con);
             } else {
                 $student_career_school_year->delete($con);
             }
         }
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     // add your code here
 }
 public function fixRepetidores($con)
 {
     $c = new Criteria();
     $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::LAST_YEAR_REPPROVED);
     foreach (StudentCareerSchoolYearPeer::doSelect($c) as $student_career_school_year) {
         $c = new Criteria();
         $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, 2);
         $c->add(StudentCareerSchoolYearPeer::STUDENT_ID, $student_career_school_year->getStudentId());
         $last_year_student = StudentCareerSchoolYearPeer::doSelectOne($c);
         if ($last_year_student->getStatus() == StudentCareerSchoolYearStatus::APPROVED) {
             $year = $student_career_school_year->getYear() + 1;
             $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::IN_COURSE);
             $student_career_school_year->setYear($year);
             $c = new Criteria();
             $c->add(StudentCareerSubjectAllowedPeer::STUDENT_ID, $student_career_school_year->getStudentId());
             StudentCareerSubjectAllowedPeer::doDelete($c);
             $c = new Criteria();
             $c->add(CareerStudentPeer::STUDENT_ID, $student_career_school_year->getStudentId());
             $career_student = CareerStudentPeer::doSelectOne($c);
             $career_student->createStudentsCareerSubjectAlloweds($year, $con);
             $student_career_school_year->save($con);
         }
     }
     /*
      $career_school_year = CareerSchoolYearPeer::retrieveByPk(2);
      $student_career_school_years = StudentCareerSchoolYearPeer::doSelect(StudentCareerSchoolYearPeer::retrieveLastYearRepprovedStudentCriteria($career_school_year));
      foreach ($student_career_school_years  as $student_career_school_year)
      {
      $student = $student_career_school_year->getStudent();
     
      die(var_dump($student));
      }
     */
 }
Exemple #4
0
 public function getGraduationSchoolYear()
 {
     $c = new Criteria();
     $c->addJoin(StudentPeer::ID, CareerStudentPeer::STUDENT_ID);
     $c->add(CareerStudentPeer::STATUS, CareerStudentStatus::GRADUATE);
     $c->add(CareerStudentPeer::STUDENT_ID, $this->getId());
     $c->addDescendingOrderByColumn(CareerStudentPeer::ID);
     $cs = CareerStudentPeer::doSelectOne($c);
     if (!is_null($cs)) {
         $sy = SchoolYearPeer::retrieveByPk($cs->getGraduationSchoolYearId());
     }
     return $sy ? $sy->getYear() : '-';
 }