public function executeDeleteStudent(sfWebRequest $request, $con = null) { $ps = PathwayStudentPeer::retrieveByStudentAndSchoolYear($request->getParameter('student_id')); $trs = TentativeRepprovedStudentPeer::retrieveByStudentId($request->getParameter('student_id')); try { $ps->delete(); $trs->setIsDeleted(false); $trs->save(); $this->getUser()->setFlash("notice", "The item was deleted successfully."); } catch (PropelException $e) { $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items.'); } $this->redirect("@school_year"); }
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 hasTentativeRepprovedStudents() { return TentativeRepprovedStudentPeer::countPending() > 0; }