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); $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 }
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(); // add your code here $this->createContextInstance(); $i = 0; $students = StudentPeer::doSelect(new Criteria()); $career_school_year = CareerSchoolYearPeer::retrieveByPK(4); foreach ($students as $student) { $this->logSection("Evaluando student ID = ", $student->getId()); $career_student = $student->getCareerStudent(); if ($career_student == null) { $this->logSection("ceando CarrerStudent", $student->getId()); $career_student = new CareerStudent(); $career_student->setStudent($student); $career_student->setCareerId(1); $career_student->setStartYear(1); $career_student->setFileNumber($student->getGlobalFileNumber()); $career_student->save($connection); #$career_student->createStudentsCareerSubjectAlloweds(1, $connection); $this->logSection("Fin creacion careerStudent", $career_student->getId()); } $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year); if ($student_career_school_year == null) { $i++; $this->logSection("Creando studentCareerSchoolYear", $student->getId()); $student_career_school_year = new StudentCareerSchoolYear(); $student_career_school_year->setCareerSchoolYear($career_school_year); $student_career_school_year->setStudent($student); $student_career_school_year->setYear($student->getCareerStudent()->getStartYear()); $student_career_school_year->save($connection); $this->logSection("Fin creacion studentCareerSchoolYear", $career_student->getId()); $this->logSection("Guardando", $student); echo $i; } } }
public function createStudentCareerSchoolYear(PropelPDO $con) { $c = new Criteria(); $c->addJoin(SchoolYearPeer::ID, SchoolYearStudentPeer::SCHOOL_YEAR_ID); $c->add(SchoolYearPeer::IS_ACTIVE, true); $c->add(SchoolYearStudentPeer::STUDENT_ID, $this->getStudentId()); $school_year_student = SchoolYearStudentPeer::doSelectOne($c, $con); if ($school_year_student) { $career_school_year = $this->getCareer()->getCareerSchoolYear($school_year_student->getSchoolYear($con)); if ($career_school_year && StudentCareerSchoolYearPeer::countByCareerAndStudent($this->getCareerId(), $this->getStudentId(), $school_year_student->getSchoolYearId(), $con) == 0) { $student_career_school_year = new StudentCareerSchoolYear(); $student_career_school_year->setCareerSchoolYearId($career_school_year->getId()); $student_career_school_year->setStudentId($this->getStudentId()); $student_career_school_year->setYear($this->suggestYear()); $student_career_school_year->save($con); } } }