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();
         }
     }
 }
Example #2
0
 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 static function retrieveByStudentId($student_id)
 {
     $c = new Criteria();
     $student = StudentPeer::retrieveByPK($student_id);
     $scsy = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($student, SchoolYearPeer::retrieveCurrent());
     $c->add(self::STUDENT_CAREER_SCHOOL_YEAR_ID, $scsy[0]->getId());
     $c->add(self::IS_DELETED, true, Criteria::EQUAL);
     return self::doSelectOne($c);
 }
 public function doSave($con = null)
 {
     parent::doSave($con);
     $student = StudentPeer::retrieveByPk($this->getValue('student_id'));
     $career_school_year_period = CareerSchoolYearPeriodPeer::retrieveByPk($this->getValue('career_school_year_period_id'));
     $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year_period->getCareerSchoolYear());
     $course_subject = CourseSubjectPeer::retrieveByPk($this->getValue('course_subject_id'));
     $student_free = StudentFreePeer::retrieveByStudentCareerSchoolYearCareerSchoolYearPeriodAndCourse($student_career_school_year, $career_school_year_period, $course_subject);
     $student_free->setIsFree(false);
     $student_free->save($con);
 }
Example #5
0
 public function executePrintStudent(sfWebRequest $request)
 {
     $this->student_career_school_year = StudentCareerSchoolYearPeer::retrieveByPK($request->getParameter('student_career_school_year_id'));
     $this->students = array($this->student_career_school_year->getStudent());
     $this->career_id = $this->student_career_school_year->getCareerSchoolYear()->getCareerId();
     $this->division = DivisionPeer::retrieveByStudentCareerSchoolYear($this->student_career_school_year);
     $this->getUser()->setAttribute('division_id', $this->division->getId());
     $this->getUser()->setAttribute('students', $this->students);
     $this->back_url = '@student';
     $this->setLayout('cleanLayout');
     $this->setTemplate('index');
 }
 /**
  * Adds the reference for the ExaminationRepprovedSubject to StudentExaminationRepprovedSubjects.
  * If student is withdrawn then it does not add the reference.
  *
  * @param ExaminationRepprovedSubject $examination_repproved_subject
  * @param PropelPDO $con
  */
 public function updateStudentExaminationRepprovedSubjects($examination_repproved_subject, PropelPDO $con)
 {
     if ($examination_repproved_subject->isNew()) {
         $student_repproved_course_subjects = SchoolBehaviourFactory::getInstance()->getAvailableStudentsForExaminationRepprovedSubject($examination_repproved_subject);
         foreach ($student_repproved_course_subjects as $student_repproved_course_subject) {
             $student = $student_repproved_course_subject->getCourseSubjectStudent()->getStudent();
             $scsys = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($student, SchoolYearPeer::retrieveCurrent());
             if (!empty($scsys) && $scsys[0]->getStatus() != StudentCareerSchoolYearStatus::WITHDRAWN) {
                 $student_examination_repproved_subject = new StudentExaminationRepprovedSubject();
                 $student_examination_repproved_subject->setStudentRepprovedCourseSubjectId($student_repproved_course_subject->getId());
                 $examination_repproved_subject->addStudentExaminationRepprovedSubject($student_examination_repproved_subject);
             }
         }
     }
 }
Example #7
0
 public function getCriteriaForCourseSubjectExamination()
 {
     $criteria = new Criteria();
     $criteria->add(CourseSubjectStudentExaminationPeer::EXAMINATION_SUBJECT_ID, $this->getId());
     $criteria->addJoin(CourseSubjectStudentExaminationPeer::COURSE_SUBJECT_STUDENT_ID, CourseSubjectStudentPeer::ID, Criteria::INNER_JOIN);
     $criteria->addJoin(CourseSubjectStudentPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN);
     //quito los retirados
     $withdrawn_criteria = new Criteria();
     $withdrawn_criteria->addJoin(StudentCareerSchoolYearPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN);
     $withdrawn_criteria->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::WITHDRAWN);
     $withdrawn_criteria->clearSelectColumns();
     $withdrawn_criteria->addSelectColumn(StudentCareerSchoolYearPeer::STUDENT_ID);
     $stmt_w = StudentCareerSchoolYearPeer::doSelectStmt($withdrawn_criteria);
     $not_in_w = $stmt_w->fetchAll(PDO::FETCH_COLUMN);
     $criteria->add(StudentPeer::ID, $not_in_w, Criteria::NOT_IN);
     return $criteria;
 }
 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;
         }
     }
 }
 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;
     }
 }
 public function verify($student, $new_career_school_year_2014, $connection)
 {
     //este metodo verifica si se creo mas de una tupla studentcareerschoolyear para el alumno en este
     //año lectivo, borra la que no es de la career que se recibio como parametro. Es un método parche que
     //hice porque se disparaban los hooks y quedaban inscriptos 2 veces si no.
     $scsys = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($student, $new_career_school_year_2014->getSchoolYear());
     foreach ($scsys as $scsy) {
         if ($scsy->getCareerSchoolYear()->getCareerId() != $new_career_school_year_2014->getCareerId()) {
             $scsy->delete($connection);
         }
     }
 }
Example #12
0
 public function getLastStudentCareerSchoolYear($career_school_year = null)
 {
     $c = new Criteria();
     $c->addDescendingOrderByColumn(StudentCareerSchoolYearPeer::YEAR);
     $c->addDescendingOrderByColumn(StudentCareerSchoolYearPeer::CREATED_AT);
     $c->add(StudentCareerSchoolYearPeer::STUDENT_ID, $this->getId());
     if (!is_null($career_school_year)) {
         $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $career_school_year->getId(), Criteria::LESS_THAN);
     }
     return StudentCareerSchoolYearPeer::doSelectOne($c);
 }
 public function stepToNextYear(Student $student, SchoolYear $school_year, PropelPDO $con = null)
 {
     $student_career_school_years = StudentCareerSchoolYearPeer::retrieveCareerSchoolYearForStudentAndYear($student, $school_year);
     foreach ($student_career_school_years as $student_career_school_year) {
         $career_school_year = $student_career_school_year->getCareerSchoolYear();
         if ($this->checkRepeationCondition($student, $student_career_school_year)) {
             $this->saveTentativeRepprovedStudent($student_career_school_year);
         } else {
             $career_student = CareerStudentPeer::retrieveByCareerAndStudent($career_school_year->getCareerId(), $student->getId());
             // solo se chequea si existe esto, por que cuando viene desde una mesa de previa no tiene por que existir el student_career_school_year
             $next_year = $student_career_school_year->getYear() + 1;
             $previous = StudentRepprovedCourseSubjectPeer::countRepprovedForStudentAndCareer($student, $student_career_school_year->getCareerSchoolYear()->getCareer());
             if ($next_year > $career_student->getCareer()->getMaxYear()) {
                 //EGRESADO
                 if ($previous == 0) {
                     $career_student->setStatus(CareerStudentStatus::GRADUATE);
                     //se guarda el school_year en que termino esta carrera
                     $career_student->setGraduationSchoolYearId($school_year->getId());
                     $career_student->save($con);
                     $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::APPROVED);
                     $student_career_school_year->save($con);
                 } else {
                     //LIBRE
                     $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::FREE);
                     $student_career_school_year->save($con);
                 }
             } elseif ($student_career_school_year->getStatus() != StudentCareerSchoolYearStatus::APPROVED) {
                 // Elimina los Allowed y Allowed Pathway del alumno.
                 $student->deleteAllCareerSubjectAlloweds($con);
                 $student->deleteAllCareerSubjectAllowedPathways($con);
                 //Se agregan las materias que puede cursar el alumno.
                 $career_student->createStudentsCareerSubjectAlloweds($next_year, $con);
                 // y decimos que aprobó
                 $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::APPROVED);
                 $student_career_school_year->save($con);
             }
         }
     }
     return true;
 }
 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;
     }
 }
Example #15
0
 public function deleteStudentCareerSchoolYear()
 {
     $con = Propel::getConnection();
     try {
         $con->beginTransaction();
         $criteria = new Criteria();
         $criteria->add(CareerPeer::ID, $this->getCareerId());
         $criteria->addJoin(CareerPeer::ID, CareerSchoolYearPeer::CAREER_ID);
         $criteria->addJoin(CareerSchoolYearPeer::ID, StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID);
         $criteria->add(StudentCareerSchoolYearPeer::STUDENT_ID, $this->getStudentId());
         foreach (StudentCareerSchoolYearPeer::doSelect($criteria) as $student_career_school_year) {
             $student_career_school_year->delete($con);
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * This method check if exists a student_free with the parameters.
  * IF NOT exists then the student inst free, otherwise check the value of the student_free
  *
  * @see StudentPeer::retrieveByStudentCarreerSchoolyearPeriodAndCourse
  *
  * @param Student $student
  * @param CareerSchoolYearPeriod $career_school_year_period
  * @param type $course_subject
  *
  * @return boolean
  */
 public function isFreeStudent(Student $student, CareerSchoolYearPeriod $career_school_year_period = null, CourseSubject $course_subject = null, CareerSchoolYear $career_school_year)
 {
     $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year);
     $student_free = StudentFreePeer::retrieveByStudentCareerSchoolYearCareerSchoolYearPeriodAndCourse($student_career_school_year, $career_school_year_period, $course_subject);
     return is_null($student_free) ? false : $student_free->getIsFree();
 }
 public function getAvailableStudentsForExaminationSubject(ExaminationSubject $examination_subject)
 {
     $c = new Criteria();
     $c->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $examination_subject->getCareerSubjectSchoolYearId());
     $c->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID, Criteria::INNER_JOIN);
     $c->addJoin(CourseSubjectStudentPeer::ID, StudentDisapprovedCourseSubjectPeer::COURSE_SUBJECT_STUDENT_ID, Criteria::INNER_JOIN);
     $c->add(CourseSubjectStudentPeer::STUDENT_APPROVED_COURSE_SUBJECT_ID, null, Criteria::ISNULL);
     $c->addJoin(CourseSubjectStudentPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN);
     $c->addJoin(CourseSubjectStudentPeer::ID, CourseSubjectStudentExaminationPeer::COURSE_SUBJECT_STUDENT_ID, Criteria::INNER_JOIN);
     $c->add(CourseSubjectStudentExaminationPeer::EXAMINATION_NUMBER, $examination_subject->getExamination()->getExaminationNumber());
     $c->add(CourseSubjectStudentExaminationPeer::IS_ABSENT, false);
     $c->addAnd(CourseSubjectStudentExaminationPeer::MARK, null, Criteria::ISNULL);
     //Quito los que ya la aprobaron
     $approved_criteria = new Criteria();
     $approved_criteria->addJoin(StudentApprovedCareerSubjectPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN);
     $approved_criteria->add(StudentApprovedCareerSubjectPeer::CAREER_SUBJECT_ID, $examination_subject->getCareerSubjectSchoolYear()->getCareerSubjectId());
     $approved_criteria->clearSelectColumns();
     $approved_criteria->addSelectColumn(StudentApprovedCareerSubjectPeer::STUDENT_ID);
     $stmt = StudentApprovedCareerSubjectPeer::doSelectStmt($approved_criteria);
     $not_in = $stmt->fetchAll(PDO::FETCH_COLUMN);
     //quito los retirados.
     $withdrawn_criteria = new Criteria();
     $withdrawn_criteria->addJoin(StudentCareerSchoolYearPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN);
     $withdrawn_criteria->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::WITHDRAWN);
     $withdrawn_criteria->clearSelectColumns();
     $withdrawn_criteria->addSelectColumn(StudentCareerSchoolYearPeer::STUDENT_ID);
     $stmt_w = StudentCareerSchoolYearPeer::doSelectStmt($withdrawn_criteria);
     $not_in_w = $stmt_w->fetchAll(PDO::FETCH_COLUMN);
     $c->add(StudentPeer::ID, $not_in, Criteria::NOT_IN);
     $c->addAnd(StudentPeer::ID, $not_in_w, Criteria::NOT_IN);
     return StudentPeer::doSelect($c);
 }
 public function fixRepetidores($con)
 {
     $c = new Criteria();
     $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::LAST_YEAR_REPPROVED);
     foreach (StudentCareerSchoolYearPeer::doSelect($c) as $student_career_school_year) {
         $c = new Criteria();
         $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, 2);
         $c->add(StudentCareerSchoolYearPeer::STUDENT_ID, $student_career_school_year->getStudentId());
         $last_year_student = StudentCareerSchoolYearPeer::doSelectOne($c);
         if ($last_year_student->getStatus() == StudentCareerSchoolYearStatus::APPROVED) {
             $year = $student_career_school_year->getYear() + 1;
             $student_career_school_year->setStatus(StudentCareerSchoolYearStatus::IN_COURSE);
             $student_career_school_year->setYear($year);
             $c = new Criteria();
             $c->add(StudentCareerSubjectAllowedPeer::STUDENT_ID, $student_career_school_year->getStudentId());
             StudentCareerSubjectAllowedPeer::doDelete($c);
             $c = new Criteria();
             $c->add(CareerStudentPeer::STUDENT_ID, $student_career_school_year->getStudentId());
             $career_student = CareerStudentPeer::doSelectOne($c);
             $career_student->createStudentsCareerSubjectAlloweds($year, $con);
             $student_career_school_year->save($con);
         }
     }
     /*
      $career_school_year = CareerSchoolYearPeer::retrieveByPk(2);
      $student_career_school_years = StudentCareerSchoolYearPeer::doSelect(StudentCareerSchoolYearPeer::retrieveLastYearRepprovedStudentCriteria($career_school_year));
      foreach ($student_career_school_years  as $student_career_school_year)
      {
      $student = $student_career_school_year->getStudent();
     
      die(var_dump($student));
      }
     */
 }
Example #19
0
 public function canBeDeleted(PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(StudentCareerSchoolYearPeer::CHANGE_STATUS_MOTIVE_ID, $this->getId());
     return !StudentCareerSchoolYearPeer::doCount($criteria);
 }
Example #20
0
 public function getStudentsWithDisapprovedSubjects()
 {
     $students = array();
     foreach ($this->getStudents() as $student) {
         $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $this->getCareerSchoolYear());
         if (is_null($student_career_school_year->getAnualAverage())) {
             $students[] = $student;
         }
     }
     return $students;
 }
Example #21
0
      <?php 
}
?>
    </tr>
  </thead>
  <tbody>
    <?php 
foreach ($students as $student) {
    ?>
      <tr>
        <td><?php 
    echo $student;
    ?>
</td>
        <?php 
    $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $division->getCareerSchoolYear());
    ?>
        <?php 
    foreach ($periods as $period) {
        ?>
          <td><?php 
        echo $form['conduct_' . $student->getId() . '_' . $period->getId()]->render();
        include_partial('changelog', array('student_career_school_year_conduct' => StudentCareerSchoolYearConductPeer::retrieveOrCreate($student_career_school_year, $period)));
        ?>
</td>
          <?php 
        echo $form->renderHiddenFields();
        ?>
        <?php 
    }
    ?>
 public function save($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     try {
         $con->beginTransaction();
         $values = $this->getValues();
         $students = $this->getStudents();
         $periods = $this->getPeriods();
         $career_school_year = $this->getCareerSchoolYear();
         foreach ($students as $student) {
             $student_career_school_year = StudentCareerSchoolYearPeer::getCurrentForStudentAndCareerSchoolYear($student, $career_school_year);
             foreach ($periods as $period) {
                 if (!$period->getIsClosed()) {
                     $conduct_id = $values['conduct_' . $student->getId() . '_' . $period->getId()];
                     $scsyc = StudentCareerSchoolYearConductPeer::retrieveOrCreate($student_career_school_year, $period);
                     if (!is_null($conduct_id)) {
                         $scsyc->setConductId($conduct_id);
                         $scsyc->save();
                     } elseif (!is_null($scsyc->getConduct())) {
                         $scsyc->delete();
                     }
                 }
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #23
0
 public function matriculateLastYearStudents()
 {
     $con = Propel::getConnection();
     try {
         $con->beginTransaction();
         $criteria = StudentCareerSchoolYearPeer::retrieveLastYearStudentNotGraduatedCriteria($this);
         $last_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($this->getSchoolYear());
         $pager = new sfPropelPager('Student', 100);
         $pager->setCriteria($criteria);
         $pager->init();
         $last_page = $pager->getLastPage();
         for ($i = 1; $i <= $last_page; $i++) {
             $pager->setPage($i);
             $pager->init();
             $students = $pager->getResults();
             foreach ($students as $student) {
                 //no tiene reserva de banco y no es libre
                 if ($student->getLastStudentCareerSchoolYear()->getStatus() != StudentCareerSchoolYearStatus::WITHDRAWN && $student->getLastStudentCareerSchoolYear()->getStatus() != StudentCareerSchoolYearStatus::FREE) {
                     if ($student->getPerson()->getIsActive()) {
                         $shift = $student->getShiftForSchoolYear($last_school_year);
                         if (!$student->getIsRegistered($this->getSchoolYear())) {
                             $student->registerToSchoolYear($this->getSchoolYear(), $shift, $con);
                         }
                         if (!is_null($shift)) {
                             $shift->clearAllReferences(true);
                         }
                         $student->clearAllReferences(true);
                         unset($student);
                         unset($shift);
                     }
                 }
             }
             StudentPeer::clearInstancePool();
             unset($students);
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #24
0
 private function generateYearReports($career_school_years, $year)
 {
     $year_reports_by_career = array();
     foreach ($career_school_years as $csy) {
         $year_reports = array();
         if ($year == "") {
             for ($y = 1; $y <= $csy->getCareer()->getQuantityYears(); $y++) {
                 $title = 'Estudiantes en el año N°' . $y . ' de la carrera';
                 $filters = array('year' => $y, 'career_school_year' => $csy->getId(), 'school_year' => $this->school_year->getId());
                 $year_reports[] = $this->generateReportArray($title, StudentCareerSchoolYearPeer::doCountForCareerSchoolYearAndYear($csy, $y), $filters);
             }
         } else {
             $title = 'Estudiantes en el año N°' . $year . ' de la carrera';
             $filters = array('year' => $year, 'career_school_year' => $csy->getId(), 'school_year' => $this->school_year->getId());
             $year_reports[] = $this->generateReportArray($title, StudentCareerSchoolYearPeer::doCountForCareerSchoolYearAndYear($csy, $year), $filters);
         }
         $year_reports_by_career['Carrera: ' . $csy->getCareer()->getCareerName()] = $year_reports;
     }
     return $year_reports_by_career;
 }