/**
  * This method filters all holidays for the school year given.
  *
  * @param Criteria $criteria
  * @param string $field
  * @param array $values
  */
 public function addSchoolYearColumnCriteria(Criteria $criteria, $field, $values)
 {
     $school_year = SchoolYearPeer::retrieveByPk($values);
     $date = date('Y-m-d', strtotime("first day of January " . $school_year->getYear()));
     $end_date = date('Y-m-d', strtotime("last day of December " . $school_year->getYear()));
     $criteria->add(HolidayPeer::DAY, $date, Criteria::GREATER_EQUAL);
     $criteria->addAnd($criteria->getNewCriterion(HolidayPeer::DAY, $end_date, Criteria::LESS_EQUAL));
 }
 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 fixApproved($con)
 {
     $c = new Criteria();
     $c->add(StudentApprovedCareerSubjectPeer::MARK, null, Criteria::ISNULL);
     $school_year = SchoolYearPeer::retrieveByPk(1);
     foreach (StudentApprovedCareerSubjectPeer::doSelect($c) as $student_approved_career_subject) {
         $course_subject_student = CourseSubjectStudentPeer::retrieveByStudentApprovedCareerSubject($student_approved_career_subject, $school_year);
         $mark = $course_subject_student->getCourseResult()->getMark();
         $student_approved_career_subject->setMark($mark);
         $student_approved_career_subject->save($con);
     }
 }
Beispiel #4
0
 public function canCreateCareerCareerSchoolYear()
 {
     $school_year = SchoolYearPeer::retrieveByPk($this->getReferenceFor('schoolyear'));
     if (is_null($school_year)) {
         return false;
     }
     return true;
 }
Beispiel #5
0
 public function executeCareerSchoolYearActions()
 {
     $this->school_year = SchoolYearPeer::retrieveByPk($this->getVar('school_year_id'));
     $this->careers = $this->school_year->getUnrelatedCareers();
 }
Beispiel #6
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() : '-';
 }