public function getCourseSubjectStudentResult(CourseSubjectStudent $course_subject_student, PropelPDO $con = null) { $average = $course_subject_student->getMarksAverage($con); $sum_marks = 0; $year = $course_subject_student->getCourseSubject()->getCourse()->getYear(); foreach ($course_subject_student->getCourseSubjectStudentMarks() as $cssm) { $sum_marks += $cssm->getMark(); } if ($average >= $course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getConfiguration()->getCourseMinimunMark() && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks())->getMark() >= self::POSTPONED_NOTE || $year > 1 && $year < 5 && $sum_marks >= 21 && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks())->getMark() >= 4) { $school_year = $course_subject_student->getCourseSubject()->getCourse()->getSchoolYear(); $student_approved_course_subject = new StudentApprovedCourseSubject(); $student_approved_course_subject->setCourseSubject($course_subject_student->getCourseSubject()); $student_approved_course_subject->setStudent($course_subject_student->getStudent()); $student_approved_course_subject->setSchoolYear($school_year); $student_approved_course_subject->setMark($average); $course_subject_student->setStudentApprovedCourseSubject($student_approved_course_subject); ###Liberando memoria #### $school_year->clearAllReferences(true); unset($school_year); SchoolYearPeer::clearInstancePool(); unset($average); unset($sum_marks); ########################## //$student_approved_course_subject->save(); return $student_approved_course_subject; } else { $school_year = $course_subject_student->getCourseSubject()->getCourse()->getSchoolYear(); $career_school_year = CareerSchoolYearPeer::retrieveBySchoolYear(null, $school_year); if ($course_subject_student->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSubject()->getIsOption() && $year == 6) { $student_disapproved_course_subject = new StudentDisapprovedCourseSubject(); $student_disapproved_course_subject->setExaminationNumber(self::DECEMBER); $student_disapproved_course_subject->setCourseSubjectStudent($course_subject_student); unset($average); unset($sum_marks); return $student_disapproved_course_subject; } else { $student_disapproved_course_subject = new StudentDisapprovedCourseSubject(); $student_disapproved_course_subject->setCourseSubjectStudent($course_subject_student); // si un alumno es de primer año, no puede ir a febrero siempre va a diciembre. if ($year == 1) { $student_disapproved_course_subject->setExaminationNumber(self::DECEMBER); } elseif ($year > 1 && $year < 5 && $course_subject_student->countCourseSubjectStudentMarks() == 3) { //Suma menor a 21 pero mayor o igual que 12: mesa de diciembre (examen regular) if ($sum_marks < 21 && $sum_marks >= 12) { $student_disapproved_course_subject->setExaminationNumber(self::DECEMBER); } elseif ($sum_marks >= 21 && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks())->getMark() < 4) { $student_disapproved_course_subject->setExaminationNumber(self::DECEMBER); } elseif ($sum_marks < 12) { $student_disapproved_course_subject->setExaminationNumber(self::FEBRUARY); } } else { $student_disapproved_course_subject->setExaminationNumber($this->getExaminationNumberFor($average)); } unset($average); unset($sum_marks); //$student_disapproved_course_subject->save(); return $student_disapproved_course_subject; } } }
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(); $c1 = new Criteria(); $career_school_year = CareerSchoolYearPeer::retrieveBySchoolYear(); $c1->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $career_school_year[0]->getId()); $c1->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::LAST_YEAR_REPPROVED); $students_career_school_year = StudentCareerSchoolYearPeer::doSelectJoinCareerSchoolYear($c1); foreach ($students_career_school_year as $student_career_school_year) { $this->logSection('STUDENT CAREER SCHOOL YEAR ID', $student_career_school_year->getId()); $previous_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($student_career_school_year->getCareerSchoolYear()->getSchoolYear()); if (is_null($previous_school_year)) { $this->logSection('action', 'continue'); continue; } $c = new Criteria(); $c->add(StudentCareerSchoolYearPeer::STUDENT_ID, $student_career_school_year->getStudent()->getId()); $c->addJoin(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID, Criteria::INNER_JOIN); $c->addJoin(CareerSchoolYearPeer::CAREER_ID, CareerPeer::ID, Criteria::INNER_JOIN); $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $previous_school_year->getId()); $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::APPROVED); if (StudentCareerSchoolYearPeer::doCount($c)) { $this->logSection('action', 'fix'); $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::IN_COURSE); $student_career_school_year->save(); } } }
public static function getYears($widget, $values) { $career = CareerSchoolYearPeer::retrieveByPk($values)->getCareer(); $choices = $career->getYearsForOption(true); $widget->setOption('choices', $choices); sfContext::getInstance()->getUser()->setAttribute('career_school_year_id', $values); }
public function executeStudyYear() { $this->career = $this->getVar('career'); $this->year = $this->getVar('year'); $this->school_year = $this->getVar('school_year'); if (is_null($this->school_year)) { $this->career_subjects = $this->career->getCareerSubjectsForYear($this->year, true); } else { $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($this->career, $this->school_year); $this->career_subjects = $career_school_year->getCareerSubjectForYear($this->year, true); } }
/** * Redefines preExecute because this action CANT BE RISED WITHOUT A REFERENCE * */ public function preExecute() { if (!$this->getUser()->getReferenceFor('career_school_year')) { $this->getUser()->setFlash('warning', 'Debe seleccionar una carrera del año lectivo para poder administrar sus materias.'); $this->redirect('@career_school_year'); } $this->career_school_year = CareerSchoolYearPeer::retrieveByPK($this->getUser()->getReferenceFor('career_school_year')); if (is_null($this->career_school_year)) { $this->getUser()->setFlash('warning', 'Debe seleccionar una carrera del año lectivo para poder administrar sus materias.'); $this->redirect('@career_school_year'); } parent::preExecute(); }
/** * Creates career_subject_school_year if the career has already have an instance of career_school_year of the actual school year. * * @param CareerSubject $career_subject * @param PropelPDO $con */ public function updateCareerSubjectSchoolYear(CareerSubject $career_subject, PropelPDO $con) { if ($career_subject->isNew()) { $school_year = SchoolYearPeer::retrieveCurrent(); $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($career_subject->getCareer(), $school_year); if (!is_null($career_school_year) && !$career_school_year->getIsProcessed()) { $career_subject_school_year = new CareerSubjectSchoolYear(); $career_subject_school_year->setCareerSubjectId($career_subject->getId()); $career_subject_school_year->setCareerSchoolYearId($career_school_year->getId()); $career_subject_school_year->save($con); } } }
public function executeUpdateEquivalence(sfWebRequest $request) { $parametrs = $request->getPostParameters(); $this->career_school_year = CareerSchoolYearPeer::retrieveByPK($parametrs['career_school_year_id']); $this->career = $this->career_school_year->getCareer(); $this->career_subject_school_years = array(); $this->years = array(); $this->forms = array(); for ($y = 1; $y <= $this->career->getQuantityYears(); $y++) { $this->years[] = $y; $this->career_subject_school_years[$y] = $this->career->getCareerSubjectsForYear($y, true); } unset($parametrs['_save']); unset($parametrs['career_school_year_id']); $valid = true; foreach ($parametrs as $parameter) { $career_subject_id = $parameter['career_subject_id']; $student_id = $parameter['student_id']; $school_year_id = $parameter['school_year']; $career_subject = CareerSubjectPeer::retrieveByPK($career_subject_id); $student = StudentPeer::retrieveByPK($student_id); $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($career_subject->getId(), $student->getId()); $student_approved_career_subject->setSchoolYearId($school_year_id); $parameter['career_subject_id'] = $student_approved_career_subject->getCareerSubjectId(); $this->form = new EquivalenceForm($student_approved_career_subject); $this->form->setCareerSubjectAndStudent($career_subject, $student); if (isset($parameter['mark']) && $parameter['mark'] != "") { $this->form->bind($parameter); if ($this->form->isValid()) { $this->form->save(); } else { $valid = false; } } $this->form = new EquivalenceForm($student_approved_career_subject); $this->form->setCareerSubjectAndStudent($career_subject, $student); $this->forms[$career_subject->getId()] = $this->form; $parameter['career_subject_id'] = $career_subject_id; } if ($valid) { $this->getUser()->setFlash('notice', 'subjects are updated correctly'); } else { $this->setProcessFormErrorFlash(); } $this->module = $this->getModuleName(); $this->setTemplate('makeUpEquivalence'); }
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 static function getCourseSUbjects($widget, $values) { $sf_user = sfContext::getInstance()->getUser(); $career_school_year = CareerSchoolYearPeer::retrieveByPK(sfContext::getInstance()->getUser()->getAttribute('career_school_year_id')); $c = new Criteria(); $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID); $c->add(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $career_school_year->getId()); $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID); $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID, CareerSubjectPeer::ID); $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID); $c->add(CareerSubjectPeer::YEAR, $values); if ($sf_user->isPreceptor()) { $course_ids = PersonalPeer::retrieveCourseIdsjoinWithDivisionCourseOrCommission($sf_user->getGuardUser()->getId(), true); $c->add(CoursePeer::ID, $course_ids, Criteria::IN); $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID); } $widget->setOption('criteria', $c); }
public function configure() { sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N', 'Url')); $this->setWidget('student_id', new sfWidgetFormInputHidden()); $this->setWidget('is_free', new sfWidgetFormInputHidden()); $this->getWidget('career_school_year_id')->setOption('criteria', CareerSchoolYearPeer::retrieveCurrentForStudentCriteria($this->getObject()->getStudent())); #widget de periodos $w = new sfWidgetFormPropelChoice(array('model' => 'CareerSchoolYearPeriod', 'add_empty' => true)); $this->setWidget('career_school_year_period_id', new dcWidgetAjaxDependence(array('dependant_widget' => $w, 'observe_widget_id' => 'student_free_career_school_year_id', "message_with_no_value" => "Seleccione una carrera y apareceran los periodos que correspondan", 'get_observed_value_callback' => array(get_class($this), 'getPeriods')))); $this->getWidgetSchema()->moveField('career_school_year_period_id', 'after', 'career_school_year_id'); $this->getWidget('career_school_year_period_id')->setLabel('Periodo'); $this->getWidgetSchema()->setHelp('career_school_year_period_id', 'Elegir en caso de que quede libre para un período en especial.'); $this->getWidget('course_subject_id')->setOption('criteria', $this->getCourseSubjectCriteria()); $this->getWidget('course_subject_id')->setLabel('Course subject'); $this->getWidgetSchema()->setHelp('course_subject_id', 'Elegir curso en caso de que quede libre para un curso en especial.'); if ($this->getObject()->isNew()) { $this->getValidatorSchema()->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'validateUnique')))); } }
public function save() { $origin_career_school_year = CareerSchoolYearPeer::retrieveByPk($this->getValue('career_school_year_id')); $destiny_career_school_year = CareerSchoolYearPeer::retrieveByPk($this->getOption('destiny_career_id')); $last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear(SchoolYearPeer::retrieveCurrent()); $students = CareerStudentPeer::retrieveLastYearCareerGraduatedStudents($origin_career_school_year); $con = Propel::getConnection(); try { $con->beginTransaction(); foreach ($students as $student) { $student->registerToCareer($destiny_career_school_year->getCareer(), null, null, $destiny_career_school_year->getCareer()->getMinYear(), $con); $shift = $student->getShiftForSchoolYear($last_year_school_year); if (!$student->getIsRegistered($destiny_career_school_year->getSchoolYear())) { $student->registerToSchoolYear($destiny_career_school_year->getSchoolYear(), $shift, $con); } } $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } }
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; } }
private function generateStructureReports($params) { if ($params['career_school_year_id'] != "") { $career_school_years = array(CareerSchoolYearPeer::retrieveByPK($params['career_school_year_id'])); } else { $career_school_years = CareerSchoolYearPeer::retrieveBySchoolYear(); } $this->shift = isset($params['shift_id']) ? $params['shift_id'] : ""; $this->division = isset($params['division_id']) ? $params['division_id'] : ""; $this->year = isset($params['year']) ? $params['year'] : ""; $this->stats_table = array(); $this->school_year = $career_school_years[0]->getSchoolYear(); if (count($career_school_years) == 1) { $this->career_school_year = $career_school_years[0]; } $this->stats_table['structure_reports'] = $this->generateGeneralReports($career_school_years); $this->stats_table['shift_reports'] = $this->generateShiftReports($career_school_years, $this->shift); $this->stats_table['shift_division_reports'] = $this->generateShiftDivisionReports($career_school_years, $this->shift, $this->division); $this->stats_table['year_reports'] = $this->generateYearReports($career_school_years, $this->year); $this->stats_table['year_shift_reports'] = $this->generateYearShiftReports($career_school_years, $this->year, $this->shift); $this->stats_table['year_shift_division_reports'] = $this->generateYearShiftDivisionReports($career_school_years, $this->year, $this->shift, $this->division); }
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 executeUpdateShowConfiguration(sfWebRequest $request) { $this->career_school_year = CareerSchoolYearPeer::retrieveByPK($request->getParameter('id')); if (null === $this->career_school_year) { $this->getUser()->setFlash('error', 'Debe seleccionar una carrera para editar su configuracion'); $this->redirect('@career_school_year'); } $subject_configuration = $this->career_school_year->getSubjectConfiguration(); $this->career_school_year->setSubjectConfiguration($subject_configuration); $this->form = new ShowSubjectConfigurationForm($subject_configuration); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { $notice = $this->getProcessFormNotice(false); $this->form->save(); $this->getUser()->setFlash('notice', $notice); } else { $this->setProcessFormErrorFlash(); } $this->setTemplate('showConfiguration'); }
public function getCareerFromStudentStatsFilters() { $user = sfContext::getInstance()->getUser(); $filters = $user->getAttribute('student_stats.filters', null, 'admin_module'); if (!isset($filters['career_school_year']) || is_null($filters['career_school_year'])) { $school_year = SchoolYearPeer::retrieveByPK($filters['school_year']); $result = implode(', ', CareerSchoolYearPeer::retrieveBySchoolYear(null, $school_year)); } else { $result = CareerSchoolYearPeer::retrieveByPK($filters['career_school_year']); } return $result; }
public function getCareerSchoolYear() { $c = new Criteria(); $c->add(CareerSchoolYearPeer::SUBJECT_CONFIGURATION_ID, $this->getId()); return CareerSchoolYearPeer::doSelectOne($c); }
<th class="th_stats"><?php echo __('Career school year'); ?> </th> <?php if (!isset($filters['career_school_year']) || is_null($filters['career_school_year'])) { ?> <td class="td_stats"><?php echo __('Not specified'); ?> </td> <?php } else { ?> <td><?php echo CareerSchoolYearPeer::retrieveByPk($filters['career_school_year']); ?> </td> <?php } ?> </tr> <tr> <th class="th_stats"><?php echo __('Career year'); ?> </th> <?php if (!isset($filters['year']) || is_null($filters['year'])) { ?>
public static function sorted(Criteria $c, $career = null) { $has_school_year = !is_null($career) && !is_null(CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($this->getCareer(), SchoolYearPeer::retrieveCurrent())); if ($has_school_year) { CareerSubjectSchoolYearPeer::sorted($c); } $c->addAscendingOrderByColumn(SubjectPeer::NAME); $c->addJoin(self::SUBJECT_ID, SubjectPeer::ID); }
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(); $username = '******'; $user = sfContext::getInstance()->getUser(); $sf_user = sfGuardUserPeer::retrieveByUsername($username); $user->signin($sf_user, false); $new_career_school_year_2014 = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK(8), SchoolYearPeer::retrieveCurrent()); $old_career_school_year_2013 = CareerSchoolYearPeer::retrieveByPk(21); $new_career_school_year_2013 = CareerSchoolYearPeer::retrieveByPk(22); $old_career_school_year_2014 = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK(4), SchoolYearPeer::retrieveCurrent()); $last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear(SchoolYearPeer::retrieveCurrent()); // ---------------------------------------------------------------------------------------------- // // Alumnos que promueven 6to deben seguir en el plan viejo $this->log('1 -Alumnos que promueven 6to deben seguir en el plan viejo'); $c = new Criteria(); $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $old_career_school_year_2013->getId()); $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true); $c->add(StudentCareerSchoolYearPeer::YEAR, 6); $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::APPROVED); $students_to_old_career_school_years = StudentCareerSchoolYearPeer::doSelect($c); try { $connection->beginTransaction(); foreach ($students_to_old_career_school_years as $socsy) { $shift = $socsy->getStudent()->getShiftForSchoolYear($last_year_school_year); if (!$socsy->getStudent()->getIsRegistered($old_career_school_year_2014->getSchoolYear())) { $socsy->getStudent()->registerToSchoolYear($old_career_school_year_2014->getSchoolYear(), $shift, $connection); } } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // ---------------------------------------------------------------------------------------------- // // 2 - Resto de los alumnos que no son del CBFE van al plan nuevo en el año que les corresponda $this->log('2 - Resto de los alumnos que no son del CBFE van al plan nuevo en el año que les corresponda'); try { $connection->beginTransaction(); // con este criteria voy a excluir a los que aprueban 6to y deben ir a 7mo del plan viejo $c = new Criteria(); $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $old_career_school_year_2013->getId()); $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true); $c->add(StudentCareerSchoolYearPeer::YEAR, 6); $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::APPROVED); $c->clearSelectColumns(); $c->addSelectColumn(StudentCareerSchoolYearPeer::STUDENT_ID); $stmt = StudentCareerSchoolYearPeer::doSelectStmt($c); $students_to_old_career_school_years_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); // con este criteria voy a excluir a los que son del CBFE $c = new Criteria(); $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, 23); $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true); $c->clearSelectColumns(); $c->addSelectColumn(StudentCareerSchoolYearPeer::STUDENT_ID); $stmt = StudentCareerSchoolYearPeer::doSelectStmt($c); $student_cbfe_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); // al total le saco $students_to_old_career_school_years_ids y los // student_cbfe_ids $c = new Criteria(); //$c = StudentCareerSchoolYearPeer::retrieveLastYearStudentNotGraduatedCriteria($new_career_school_year_2014); $c->add(StudentCareerSchoolYearPeer::YEAR, 7, Criteria::NOT_EQUAL); $c->addJoin(StudentCareerSchoolYearPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN); $c->add(StudentPeer::ID, array_merge($students_to_old_career_school_years_ids, $student_cbfe_ids), Criteria::NOT_IN); $students = StudentPeer::doSelectActive($c); foreach ($students as $student) { $shift = $student->getShiftForSchoolYear($last_year_school_year); if (!$student->getIsRegistered($new_career_school_year_2014->getSchoolYear()) && $shift) { $slcsy = $student->getLastStudentCareerSchoolYear(); $slcs = $student->getLastCareerStudent(); if ($slcsy->getStatus() == StudentCareerSchoolYearStatus::APPROVED) { $start_year = $slcsy->getYear() + 1; } else { $start_year = $slcsy->getYear(); } if ($slcs->getCareerId() != $new_career_school_year_2014->getCareerId()) { $student->registerToCareer($new_career_school_year_2014->getCareer(), null, null, $start_year, $connection); $sys = new SchoolYearStudent(); $sys->setStudentId($student->getId()); $sys->setSchoolYearId($new_career_school_year_2014->getSchoolYear()->getId()); $sys->setShift($shift); $sys->save($connection); $this->verify($student, $new_career_school_year_2014, $connection); } else { $sys = new SchoolYearStudent(); $sys->setStudentId($student->getId()); $sys->setSchoolYearId($new_career_school_year_2014->getSchoolYear()->getId()); $sys->setShift($shift); $sys->save($connection); $this->verify($student, $new_career_school_year_2014, $connection); } if (!is_null($shift)) { $shift->clearAllReferences(true); } $student->clearAllReferences(true); unset($student); unset($shift); } StudentPeer::clearInstancePool(); unset($students); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } }
public function getCareerSchoolYear() { $c = new Criteria(); $c->add(CareerSchoolYearPeer::CAREER_ID, $this->getCareerId()); $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId()); return CareerSchoolYearPeer::doSelectOne($c); }
protected function doSave($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (is_null($con)) { $con = $this->getConnection(); } // Delete only the subjects off the selected career $c = new Criteria(); $c->add(StudentCareerSubjectAllowedPeer::STUDENT_ID, $this->object->getPrimaryKey()); // added: $subc = new Criteria(); $subc->clearSelectColumns(); $subc->addSelectColumn(CareerSubjectPeer::ID); $subc->add(CareerSubjectPeer::CAREER_ID, $this->getValue("career_id")); $stmt = CareerSubjectPeer::doSelectStmt($subc); $ids = $stmt->fetchAll(PDO::FETCH_COLUMN); $c->add(StudentCareerSubjectAllowedPeer::CAREER_SUBJECT_ID, $ids, Criteria::IN); $allowed = StudentCareerSubjectAllowedPeer::doSelectOne($c, $con); if ($allowed) { // Se consulta si el alumno esta en trayectorias antes de eliminarlo $student_id = $this->object->getPrimaryKey(); $criteria = new Criteria(); $criteria->add(PathwayStudentPeer::STUDENT_ID, $student_id); $pathway = PathwayStudentPeer::doSelectOne($criteria, $con); if (!$pathway) { StudentCareerSubjectAllowedPeer::doDelete($c, $con); } } $year = $this->getValue('year'); $career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK($this->getValue('career_id')), SchoolYearPeer::retrieveCurrent()); //First update the year at student_career_school_year // var_dump($career_school_year);die(); $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($this->getObject(), $career_school_year); // if (!$student_career_school_year) // { // $student_career_school_year = new StudentCareerSchoolYear(); // $student_career_school_year->setCareerSchoolYear($career_school_year); // $student_career_school_year->setStudent($this->getObject()); // $student_career_school_year->save(); // } $career_student = CareerStudentPeer::retrieveByCareerAndStudent($this->getValue('career_id'), $this->getObject()->getId()); try { $con->beginTransaction(); $student_career_school_year->setYear($year); $student_career_school_year->save($con); $c = new Criteria(); $c->add(CareerSubjectPeer::CAREER_ID, $this->getValue('career_id')); $c->add(CareerSubjectPeer::YEAR, $year); foreach (CareerSubjectPeer::doSelect($c) as $career_subject) { $obj = new StudentCareerSubjectAllowed(); $obj->setStudentId($this->object->getPrimaryKey()); $obj->setCareerSubject($career_subject); $obj->save($con); } $prev_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($career_school_year->getSchoolYear()); if ($prev_school_year) { $prev_student_career_school_year = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($this->getObject(), $prev_school_year); } if (!empty($prev_student_career_school_year)) { $prev_student_career_school_year = array_shift($prev_student_career_school_year); if ($year <= $prev_student_career_school_year->getYear()) { $prev_student_career_school_year->setStatus(StudentCareerSchoolYearStatus::REPPROVED); $prev_student_career_school_year->save($con); } } $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } }
if (is_null($period)) { ?> <?php $period = CareerSchoolYearPeriodPeer::retrieveByDay($day, $division->getCourseType()); ?> <?php $clasz = is_null($period) ? '' : $student->getFreeClass($period, $course_subject, CareerSchoolYearPeer::retrieveByPk($career_school_year_id), $division); ?> <?php } elseif ($period->getEndAt() < date('Y-m-d', $day)) { ?> <?php $period = CareerSchoolYearPeriodPeer::retrieveByDay($day, $division->getCourseType()); ?> <?php $clasz = is_null($period) ? '' : $student->getFreeClass($period, $course_subject, CareerSchoolYearPeer::retrieveByPk($career_school_year_id), $division); ?> <?php } ?> <?php } ?> <?php $student_attendance = StudentAttendancePeer::retrieveByDateAndStudent(date('Y-m-d', $day), $student, $course_subject_id, $career_school_year_id); ?> <?php if ($student_attendance) { ?>
public function createLastYearCommissions() { $last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($this->getSchoolYear()); $last_year_career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($this->getCareer(), $last_year_school_year); SchoolYearPeer::clearInstancePool(); CareerSchoolYearPeer::clearInstancePool(); $con = Propel::getConnection(); try { $con->beginTransaction(); $commissions = CoursePeer::retrieveComissionsForCareerSchoolYear($last_year_career_school_year); foreach ($commissions as $commission) { $commission->createCopyForSchoolYear($con, null, $this); $commission->clearAllReferences(true); unset($commission); } unset($commissions); $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } }
public function getUnrelatedCareers() { $already = array(); $c = new Criteria(); $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $this->getId()); foreach (CareerSchoolYearPeer::doSelect($c) as $csy) { $already[] = $csy->getCareerId(); } $c2 = new Criteria(); $c2->add(CareerPeer::ID, $already, Criteria::NOT_IN); return CareerPeer::doSelect($c2); }
public function getCareerSchoolYear() { return CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($this->getCareerSubject()->getCareer(), $this->getSchoolYear()); }