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); } } } }
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); } } }