protected function doSave($con = null) { $career_id = $this->getValue('career_id'); $student_career = CareerStudentPeer::retrieveByCareerAndStudent($career_id, $this->getObject()->getId()); $student_career->setOrientationId($this->getValue('orientation_id')); $student_career->setSubOrientationId($this->getValue('sub_orientation_id')); $student_career->setOrientationChangeObservations($this->getValue('orientation_change_observations')); $student_career->save($con); }
public function save($con = null) { if (!isset($this->widgetSchema['students'])) { // somebody has unset this widget return; } if (is_null($con)) { $con = $this->getConnection(); } $con->beginTransaction(); try { $values = $this->getValue('students'); if (is_array($values)) { foreach ($values as $value) { $c = new Criteria(); $c->addJoin(TentativeRepprovedStudentPeer::STUDENT_CAREER_SCHOOL_YEAR_ID, StudentCareerSchoolYearPeer::ID); $c->add(TentativeRepprovedStudentPeer::IS_DELETED, false); $c->add(StudentCareerSchoolYearPeer::STUDENT_ID, $value); $trs = TentativeRepprovedStudentPeer::retrieveByPK($value); $pathway_student = new PathwayStudent(); $pathway_student->setStudentId($trs->getStudentCareerSchoolYear()->getStudentId()); $pathway_student->setPathway(PathwayPeer::retrieveCurrent()); $pathway_student->setYear($trs->getStudentCareerSchoolYear()->getYear()); $pathway_student->save($con); $trs->setIsDeleted(true); $trs->save($con); $trs->getStudentCareerSchoolYear()->setStatus(StudentCareerSchoolYearStatus::APPROVED); $trs->getStudentCareerSchoolYear()->save($con); $student_id = $trs->getStudentCareerSchoolYear()->getStudentId(); $career_id = $trs->getStudentCareerSchoolYear()->getCareerSchoolYear()->getCareerId(); $next_year = $trs->getStudentCareerSchoolYear()->getYear() + 1; $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career_id, $student_id); // Elimino los Allowed y Allowed Pathway del alumno. $career_student->getStudent()->deleteAllCareerSubjectAllowedPathways($con); $career_student->getStudent()->deleteAllCareerSubjectAlloweds($con); // Creo los Allowed Pathway del alumno. $career_student->createStudentsCareerSubjectAllowedPathways($trs->getStudentCareerSchoolYear()->getYear(), $con); // Creo los Allowed para la cursada normal del alumno. $career_student->createStudentsCareerSubjectAlloweds($next_year, $con); } } $con->commit(); } catch (Exception $e) { $con->rollBack(); throw $e; } }
public function closeStudentExaminationRepprovedSubject(StudentExaminationRepprovedSubject $student_examination_repproved_subject, PropelPDO $con) { if ($student_examination_repproved_subject->getMark() >= $this->getExaminationNote()) { $student_approved_career_subject = new StudentApprovedCareerSubject(); $student_approved_career_subject->setCareerSubject($student_examination_repproved_subject->getExaminationRepprovedSubject()->getCareerSubject()); $student_approved_career_subject->setStudent($student_examination_repproved_subject->getStudent()); $student_approved_career_subject->setSchoolYear($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getSchoolYear()); if ($student_examination_repproved_subject->getExaminationRepprovedSubject()->getExaminationRepproved()->getExaminationType() == ExaminationRepprovedType::REPPROVED) { //Final average is the average of the course_subject_student and the mark of student_examination_repproved_subject $average = (string) (($student_examination_repproved_subject->getStudentRepprovedCourseSubject()->getCourseSubjectStudent()->getMarksAverage() + $student_examination_repproved_subject->getMark()) / 2); $average = sprintf('%.4s', $average); if ($average < self::MIN_NOTE) { $average = self::MIN_NOTE; } $student_approved_career_subject->setMark($average); } else { //Final calification is the mark of student_examination_repproved_subject $student_approved_career_subject->setMark($student_examination_repproved_subject->getMark()); } $student_repproved_course_subject = $student_examination_repproved_subject->getStudentRepprovedCourseSubject(); $student_repproved_course_subject->setStudentApprovedCareerSubject($student_approved_career_subject); $student_repproved_course_subject->save($con); $career = $student_repproved_course_subject->getCourseSubjectStudent()->getCourseSubject()->getCareerSubjectSchoolYear()->getCareerSchoolYear()->getCareer(); ##se corrobora si la previa es la última y del último año, hay que egresarlo $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student_repproved_course_subject->getStudent(), $career); if ($student_repproved_course_subject->getStudent()->getCurrentOrLastStudentCareerSchoolYear()->getYear() >= CareerPeer::getMaxYear() && $previous == 0) { $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career->getId(), $student_repproved_course_subject->getStudent()->getId()); $career_student->setStatus(CareerStudentStatus::GRADUATE); //se guarda el school_year en que termino esta carrera $career_student->setGraduationSchoolYearId(SchoolYearPeer::retrieveCurrent()->getId()); $career_student->save($con); //se guarda el estado en el student_career_school_year $scsy = $student_repproved_course_subject->getCourseSubjectStudent()->getStudent()->getCurrentOrLastStudentCareerSchoolYear(); $scsy->setStatus(StudentCareerSchoolYearStatus::APPROVED); $scsy->save(); } ##se agrega el campo en student_disapproved_course_subject a el link del resultado final $student_repproved_course_subject->getCourseSubjectStudent()->getCourseResult()->setStudentApprovedCareerSubject($student_approved_career_subject)->save($con); $student_approved_career_subject->save($con); } }
?> "><?php echo __('Go back'); ?> </a></div> </div> <?php foreach ($students as $student) { ?> <?php $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $division->getCareerSchoolYear()); ?> <div class="report-wrapper"> <?php include_partial('header', array('student' => $student, 'division' => $division, 'career_id' => $career_id, 'school_year' => $student_career_school_year->getSchoolYear(), 'student_career' => CareerStudentPeer::retrieveByCareerAndStudent($career_id, $student->getId()))); ?> <div class="report-content"> <?php $periods = CareerSchoolYearPeriodPeer::getQuaterlyPeriodsSchoolYear($division->getCareerSchoolYearId()); ?> <?php $school_year = $division->getSchoolYear(); ?> <?php $course_subject_students = $student->getCourseSubjectStudentsForSchoolYear($school_year); ?> <?php
?> </strong> <em><?php echo $student_career_school_year->getStatusString(); ?> </em> </div> <?php $career_school_year = $student_career_school_year->getCareerSchoolYear(); ?> <?php $course_subject_students = $student_career_school_year->getCourses(); ?> <?php $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career_school_year->getCareerId(), $student->getId()); ?> <?php $back_url = isset($back_url) ? $back_url : ''; ?> <?php isset($course_subject_students['ANUAL']) ? include_partial("student/current_course_subjects", array("course_subject_students" => $course_subject_students['ANUAL'], 'career_student' => $career_student, 'back_url' => $back_url, 'student' => $student, 'course_type' => CourseType::TRIMESTER)) : ''; ?> <?php isset($course_subject_students['QUATERLY']) ? include_partial("student/current_course_subjects", array("course_subject_students" => $course_subject_students['QUATERLY'], 'career_student' => $career_student, 'back_url' => $back_url, 'student' => $student, 'course_type' => CourseType::QUATERLY)) : ''; ?>
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; } }
public function executeUpdateChangeStudentStatus(sfWebRequest $request) { $this->student = StudentPeer::retrieveByPK($request->getParameter('student_id')); $this->status = $request->getParameter('student_career_school_year[status]'); $this->motive = $request->getParameter('student_career_school_year[change_status_motive_id]'); $student_career_school_year = $this->student->getLastStudentCareerSchoolYear(); if (is_null($student_career_school_year)) { $this->getUser()->setFlash('error', 'Ocurrió un error al guardar los datos'); } else { switch ($this->status) { case StudentCareerSchoolYearStatus::WITHDRAWN: //Retirado //cambio el estado $this->form = new StudentCareerSchoolYearForm($student_career_school_year); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); $a = $this->form->save(); //desmatricular $s = $this->student->getSchoolYearStudentForSchoolYear($student_career_school_year->getCareerSchoolYear()->getSchoolYear()); if (!is_null($s)) { $s->delete(); } //deshabilito la persona $this->student->getPerson()->setIsActive(false); $this->student->getPerson()->save(); //seteo en sus course_subject_student_mark is_closed en TRUE; $this->student->setCourseSubjectStudentMarksForSchoolYear($student_career_school_year->getCareerSchoolYear()->getSchoolYear(), true); $this->getUser()->setFlash('info', 'The item was updated successfully.'); break; case StudentCareerSchoolYearStatus::WITHDRAWN_WITH_RESERVE: //Retirado con reserva de banco $this->start_date = $request->getParameter('student_career_school_year[start_date_reserve]'); //Si no existe la reserva la creo. $student_reserve = $this->student->hasActiveReserve(); if (is_null($student_reserve)) { if (is_null($this->start_date) || $this->start_date == '') { $this->getUser()->setFlash('error', 'El campo Fecha de inicio de la reserva es obligatorio.'); } else { $this->start_date = str_replace('/', '-', $this->start_date); $this->start_date = date('Y-m-d', strtotime($this->start_date)); $student_reserve = new StudentReserveStatusRecord(); $student_reserve->setStudentId($this->student->getId()); $student_reserve->setStartDate(new DateTime($this->start_date)); StudentReserveStatusRecordPeer::doInsert($student_reserve); //cambio el estado $this->form = new StudentCareerSchoolYearForm($student_career_school_year); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); $a = $this->form->save(); //desmatricular $s = $this->student->getSchoolYearStudentForSchoolYear($student_career_school_year->getSchoolYear()); if (!is_null($s)) { $s->delete(); } //seteo en sus course_subject_student_mark is_closed en TRUE; $this->student->setCourseSubjectStudentMarksForSchoolYear($student_career_school_year->getCareerSchoolYear()->getSchoolYear(), true); $this->getUser()->setFlash('info', 'The item was updated successfully.'); } } else { //Ya existe la reserva solo modifico la fecha $this->start_date = str_replace('/', '-', $this->start_date); $this->start_date = date('Y-m-d', strtotime($this->start_date)); $student_reserve->setStartDate(new DateTime($this->start_date)); $student_reserve->save(); $this->getUser()->setFlash('info', 'The item was updated successfully.'); } break; case StudentCareerSchoolYearStatus::FREE: //Libre $max_year = $student_career_school_year->getCareerSchoolYear()->getCareer()->getMaxYear(); //chequeo que sea el ultimo año. if ($student_career_school_year->getYear() == $max_year) { //chequeo que deba materias. if ($this->student->getCountStudentRepprovedCourseSubject() > 0) { //cambio el estado $this->form = new StudentCareerSchoolYearForm($student_career_school_year); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); $a = $this->form->save(); //si no esta activo, lo activo if (!$this->student->getPerson()->getIsActive()) { $this->student->getPerson()->setIsActive(true); $this->student->getPerson()->save(); } //desmatricular $s = $this->student->getSchoolYearStudentForSchoolYear($student_career_school_year->getSchoolYear()); if (!is_null($s)) { $s->delete(); } $this->getUser()->setFlash('info', 'The item was updated successfully.'); } else { $this->getUser()->setFlash('error', 'El alumno no debe materias.'); } } else { $this->getUser()->setFlash('error', 'El alumno debe estar en el ultimo año de la carrera.'); } break; case StudentCareerSchoolYearStatus::IN_COURSE: //En curso //Chequeo que el estado anterior sea Retirado con Reserva de Banco. if ($student_career_school_year->getStatus() != StudentCareerSchoolYearStatus::WITHDRAWN_WITH_RESERVE) { $this->getUser()->setFlash('error', 'El estado anterior debe ser Retirado con reserva de Banco.'); } else { $this->end_date = $request->getParameter('student_career_school_year[end_date_reserve]'); if (is_null($this->end_date) || $this->end_date == '') { $this->getUser()->setFlash('error', 'El campo Fecha de fin de la reserva es obligatorio.'); } else { //guardo la fecha de fin de la reserva. $this->end_date = str_replace('/', '-', $this->end_date); $this->end_date = date('Y-m-d', strtotime($this->end_date)); $student_reserve = $this->student->hasActiveReserve(); $student_reserve->setEndDate(new DateTime($this->end_date)); $student_reserve->save(); //cambio el estado $this->form = new StudentCareerSchoolYearForm($student_career_school_year); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); $a = $this->form->save(); $this->getUser()->setFlash('info', 'The item was updated successfully.'); } } break; case StudentCareerSchoolYearStatus::APPROVED: if ($student_career_school_year->getStatus() == StudentCareerSchoolYearStatus::IN_COURSE || $student_career_school_year->getStatus() == StudentCareerSchoolYearStatus::FREE) { if ($student_career_school_year->getStatus() == StudentCareerSchoolYearStatus::FREE) { //no debe materias. if ($this->student->getCountStudentRepprovedCourseSubject() == 0) { //cambio el estado $this->form = new StudentCareerSchoolYearForm($student_career_school_year); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); $a = $this->form->save(); //cambio el estado de la carrera. $career = $student_career_school_year->getCareerSchoolYear()->getCareer(); $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career->getId(), $this->student->getId()); $career_student->setStatus(CareerStudentStatus::GRADUATE); $current_school_year = SchoolYearPeer::retrieveCurrent(); $career_student->setGraduationSchoolYearId($current_school_year->getId()); $career_student->save(Propel::getConnection()); //deshabilito la persona $this->student->getPerson()->setIsActive(false); $this->student->getPerson()->save(); $this->getUser()->setFlash('info', 'The item was updated successfully.'); } else { $this->getUser()->setFlash('error', 'El alumno tiene materias previas sin aprobar.'); } } else { /*SOLO CHEQUEA QUE TENGA LAS MATERIAS CERRADAS*/ $course_subject_students = $this->student->getCourseSubjectStudentsForSchoolYear($student_career_school_year->getCareerSchoolYear()->getSchoolYear()); $css = array_shift($course_subject_students); /* Si tengo alguna materia sin cerrar */ if (!$css->areAllMarksClosed()) { $this->getUser()->setFlash('error', "El alumno tiene cursadas sin cerrar."); } else { //cambio el estado $this->form = new StudentCareerSchoolYearForm($student_career_school_year); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); $a = $this->form->save(); $this->getUser()->setFlash('info', 'The item was updated successfully.'); } } } else { $this->getUser()->setFlash('error', 'El alumno debe estar cursando o estar Libre.'); } break; } } $this->redirect('student/changeStudentStatus?id=' . $this->student->getId()); }