public function save($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (is_null($con)) {
         $con = Propel::getConnection();
     }
     try {
         $con->beginTransaction();
         $values = $this->getValues();
         $school_year = SchoolYearPeer::retrieveByPK($values["school_year_id"]);
         $shift = ShiftPeer::retrieveByPK($values["shift_id"]);
         unset($values["school_year_id"]);
         unset($values["shift_id"]);
         foreach ($values as $student_id) {
             $student = StudentPeer::retrieveByPk($student_id);
             if (!$student->getIsRegistered($school_year)) {
                 $student->registerToSchoolYear($school_year, $shift, $con);
             }
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
示例#2
0
 public function executeShow(sfWebRequest $request)
 {
     $this->school_year = $this->getRoute()->getObject();
     $this->getUser()->setReferenceFor($this);
     $this->form = new TentativeRepprovedStudentForm();
     $this->students = PathwayStudentPeer::getStudentsForSchoolYear(SchoolYearPeer::retrieveCurrent());
 }
示例#3
0
 public function executeGeneralInformation()
 {
     $this->current_school_year = SchoolYearPeer::retrieveCurrent();
     $this->amount_sy_students = $this->current_school_year->countSchoolYearStudents();
     $this->amount_teachers = TeacherPeer::doCount(new Criteria());
     $this->amount_students = StudentPeer::doCount(new Criteria());
 }
 public function configure()
 {
     parent::configure();
     //Widgets
     $this->setWidget('school_year_id', new sfWidgetFormReadOnly(array('plain' => false, 'value_callback' => array('SchoolYearPeer', 'retrieveByPk'))));
     $school_year = SchoolYearPeer::retrieveCurrent();
     $this->setDefault('school_year_id', $school_year->getId());
     $criteria_career = new Criteria();
     $criteria_career->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId());
     $this->setWidget('career_school_year_id', new sfWidgetFormPropelChoice(array('model' => 'CareerSchoolYear', 'criteria' => $criteria_career, 'add_empty' => true)));
     $w = new sfWidgetFormChoice(array('choices' => array()));
     $this->widgetSchema['year'] = new dcWidgetAjaxDependence(array('dependant_widget' => $w, 'observe_widget_id' => 'course_career_school_year_id', "message_with_no_value" => "Seleccione una carrera y apareceran los años que correspondan", 'get_observed_value_callback' => array(get_class($this), 'getYears')));
     //Check if all the subjects has the same CareerSchoolYear
     $career_school_year = $this->getObject()->getCareerSchoolYear();
     $career_school_year_id = is_null($career_school_year) ? null : $career_school_year->getId();
     $this->getWidget('career_school_year_id')->setDefault($career_school_year_id);
     //Check if all the subjects has the same Year
     $year = $this->getObject()->getYear();
     $this->getWidget('year')->setDefault($year);
     $widget = new sfWidgetFormPropelChoice(array('model' => 'CareerSubjectSchoolYear', 'multiple' => true));
     $this->widgetSchema['course_subjects'] = new dcWidgetAjaxDependence(array('dependant_widget' => $widget, 'observe_widget_id' => 'course_year', "message_with_no_value" => "Seleccione una carrera y un año", 'get_observed_value_callback' => array(get_class($this), 'getSubjects')));
     //Validators
     $this->setValidator('career_school_year_id', new sfValidatorPropelChoice(array('model' => 'CareerSchoolYear', 'criteria' => $criteria_career)));
     $this->setValidator('course_subjects', new sfValidatorPropelChoice(array('model' => 'CareerSubjectSchoolYear', 'required' => true, 'multiple' => true)));
     $this->setValidator('school_year_id', new sfValidatorPass());
     $this->setValidator('year', new sfValidatorNumber());
 }
 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 getCareersCriteria()
 {
     $criteria = new Criteria();
     $school_year = SchoolYearPeer::retrieveCurrent();
     $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId());
     return $criteria;
 }
示例#7
0
 public function configure()
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Asset', 'Tag', 'Url', 'Javascript', 'I18N'));
     if ($this->getObject()->isNew()) {
         $this->setWidget('division_title_ids', new sfWidgetFormPropelChoice(array('model' => 'DivisionTitle', 'multiple' => true, "renderer_class" => "csWidgetFormSelectDoubleList")));
         $this->setValidator('division_title_ids', new sfValidatorPropelChoice(array('model' => 'DivisionTitle', 'column' => 'id', 'multiple' => true)));
         unset($this['division_title_id']);
         //$this->setValidator('division_title_ids',new sfValidatorPass());
     } else {
         $this->getWidget('division_title_id')->setOption('add_empty', true);
     }
     $school_year = SchoolYearPeer::retrieveCurrent();
     $criteria = new Criteria();
     $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId());
     $criteria->add(CareerSchoolYearPeer::IS_PROCESSED, false);
     $this->getWidget('career_school_year_id')->setOption('criteria', $criteria);
     $this->getWidget('career_school_year_id')->setOption('add_empty', true);
     $this->getWidget('shift_id')->setOption('add_empty', true);
     $w = new sfWidgetFormChoice(array('choices' => array()));
     $this->setWidget('year', new dcWidgetAjaxDependence(array('dependant_widget' => $w, 'observe_widget_id' => 'division_career_school_year_id', "message_with_no_value" => "Seleccione una carrera y apareceran los años que correspondan", 'get_observed_value_callback' => array(get_class($this), 'getYears'))));
     $courses_choices = new sfWidgetFormPropelChoice(array('model' => 'CareerSubjectSchoolYear', 'multiple' => true, "renderer_class" => "csWidgetFormSelectDoubleList"));
     $this->setWidget('division_courses', new dcWidgetAjaxDependence(array('dependant_widget' => $courses_choices, 'observe_widget_id' => 'division_year', "message_with_no_value" => "Seleccione una carrera y un año", 'get_observed_value_callback' => array(get_class($this), 'getCourses'))));
     $this->setValidator('division_courses', new sfValidatorPass());
     //$this->getWidgetSchema()->setLabel('division_title_ids', __('Division'));
 }
 public static function retrieveCurrentsCriteria()
 {
     $c = new Criteria();
     $c->addJoin(self::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID);
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     return $c;
 }
 public function getCourseSubjectStudentResult(CourseSubjectStudent $course_subject_student, PropelPDO $con = null)
 {
     $average = $course_subject_student->getMarksAverage($con);
     if ($average >= $course_subject_student->getCourseSubject($con)->getCareerSubjectSchoolYear($con)->getConfiguration($con)->getCourseMinimunMark() && $course_subject_student->getMarkFor($course_subject_student->countCourseSubjectStudentMarks(null, false, $con), $con)->getMark() >= self::POSTPONED_NOTE) {
         $school_year = $course_subject_student->getCourseSubject($con)->getCourse($con)->getSchoolYear($con);
         $student_approved_course_subject = new StudentApprovedCourseSubject();
         $student_approved_course_subject->setCourseSubject($course_subject_student->getCourseSubject($con));
         $student_approved_course_subject->setStudent($course_subject_student->getStudent($con));
         $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);
         ##########################
         return $student_approved_course_subject;
     } else {
         $student_disapproved_course_subject = new StudentDisapprovedCourseSubject();
         $student_disapproved_course_subject->setCourseSubjectStudent($course_subject_student);
         if ($course_subject_student->hasSomeMarkFree()) {
             if (is_null(StudentRepprovedCourseSubjectPeer::retrieveByCourseSubjectStudent($course_subject_student))) {
                 $srcs = new StudentRepprovedCourseSubject();
                 $srcs->setCourseSubjectStudent($course_subject_student);
                 $srcs->save();
             }
         }
         $examination_number = $this->getExaminationNumberFor($average, $course_subject_student->hasSomeMarkFree());
         $student_disapproved_course_subject->setExaminationNumber($examination_number);
         unset($average);
         return $student_disapproved_course_subject;
     }
 }
示例#10
0
 /**
  * This method deactive all the SchoolYear (put STATE's of the school years in false)
  */
 public static function setAllUnactive()
 {
     foreach (SchoolYearPeer::doSelect(new Criteria()) as $year) {
         $year->setIsActive(false);
         $year->save();
     }
 }
 public static function getCourseSubjects($widget, $values)
 {
     $sf_user = sfContext::getInstance()->getUser();
     $career_school_year = CareerSchoolYearPeer::retrieveByPK(sfContext::getInstance()->getUser()->getAttribute('career_school_year_id'));
     $career = $career_school_year->getCareer();
     $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->add(CoursePeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     $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);
     }
     $course_ids = array();
     foreach (CourseSubjectPeer::doSelect($c) as $course_subject) {
         if ($course_subject->hasAttendanceForSubject()) {
             $course_ids[] = $course_subject->getId();
         }
     }
     $criteria = new Criteria();
     $criteria->add(CourseSubjectPeer::ID, $course_ids, Criteria::IN);
     $criteria->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
     CareerSubjectSchoolYearPeer::sorted($criteria);
     $widget->setOption('criteria', $criteria);
 }
示例#12
0
 public static function retrieveCurrentForStudentCriteria(Student $student, Criteria $c = null)
 {
     $c = is_null($c) ? new Criteria() : $c;
     $c->add(self::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     $c->addJoin(self::ID, StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID);
     $c->add(StudentCareerSchoolYearPeer::STUDENT_ID, $student->getId());
     return $c;
 }
 /**
  * This method filters all holidays for the school year given.
  *
  * @param Criteria $criteria
  * @param string $field
  * @param array $values
  */
 public function addSchoolYearColumnCriteria(Criteria $criteria, $field, $values)
 {
     $school_year = SchoolYearPeer::retrieveByPk($values);
     $date = date('Y-m-d', strtotime("first day of January " . $school_year->getYear()));
     $end_date = date('Y-m-d', strtotime("last day of December " . $school_year->getYear()));
     $criteria->add(HolidayPeer::DAY, $date, Criteria::GREATER_EQUAL);
     $criteria->addAnd($criteria->getNewCriterion(HolidayPeer::DAY, $end_date, Criteria::LESS_EQUAL));
 }
 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);
 }
示例#15
0
 public static function doSelectOrderedAndActive(Criteria $criteria = null)
 {
     $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     $criteria->addJoin(CareerSchoolYearPeer::CAREER_ID, CareerSubjectPeer::CAREER_ID);
     $criteria->addJoin(CareerSubjectPeer::SUBJECT_ID, SubjectPeer::ID);
     $criteria->setDistinct();
     $criteria->addAscendingOrderByColumn(self::NAME);
     return self::doSelect($criteria);
 }
 public function validatePathway($validator, $values)
 {
     $criteria = new Criteria();
     $criteria->add(PathwayPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     if (PathwayPeer::doCount($criteria) == 0) {
         throw new sfValidatorError($validator, "No se puede guardar el formulario si no existe una trayectoria para el año lectivo actual.");
     }
     return $values;
 }
示例#17
0
 public function configure()
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Asset'));
     unset($this["is_closed"], $this["division_id"], $this["current_period"], $this['related_division_id'], $this['is_pathway']);
     $this->setWidget('starts_at', new csWidgetFormDateInput());
     $this->setValidator('starts_at', new mtValidatorDateString());
     $this->widgetSchema->moveField("starts_at", "after", "quota");
     $this->widgetSchema["school_year_id"] = new sfWidgetFormInputHidden();
     $this->setDefault("school_year_id", SchoolYearPeer::retrieveCurrent()->getId());
 }
示例#18
0
 public static function retrieveCriteriaForCurrentYear($criteria)
 {
     if (is_null($criteria)) {
         $criteria = new Criteria();
     }
     $criteria->addJoin(self::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID);
     $criteria->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID);
     $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     return $criteria;
 }
示例#19
0
 public static function retrieveByStudentAndSchoolYear($student_id, $school_year_id = null)
 {
     if (is_null($school_year_id)) {
         $school_year_id = SchoolYearPeer::retrieveCurrent()->getId();
     }
     $c = new Criteria();
     $c->addJoin(PathwayPeer::ID, self::PATHWAY_ID, Criteria::INNER_JOIN);
     $c->add(PathwayPeer::SCHOOL_YEAR_ID, $school_year_id);
     $c->add(PathwayStudentPeer::STUDENT_ID, $student_id);
     return self::doSelectOne($c);
 }
示例#20
0
 public static function retrieveCurrentCriteria(Criteria $criteria = null, $student_id)
 {
     if (is_null($criteria)) {
         $criteria = new Criteria();
     }
     $criteria->add(self::STUDENT_ID, $student_id);
     $criteria->addJoin(StudentFreePeer::CAREER_SCHOOL_YEAR_PERIOD_ID, CareerSchoolYearPeriodPeer::ID, Criteria::INNER_JOIN);
     $criteria->addJoin(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID, Criteria::INNER_JOIN);
     $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     return $criteria;
 }
示例#21
0
 public function configure()
 {
     $this->widgetSchema["school_year_id"] = new sfWidgetFormInputHidden();
     $this->setWidget('date_from', new csWidgetFormDateInput());
     $this->setWidget('date_to', new csWidgetFormDateInput());
     $this->setValidator('date_from', new mtValidatorDateString());
     $this->setValidator('date_to', new mtValidatorDateString());
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare("date_from", sfValidatorSchemaCompare::LESS_THAN_EQUAL, "date_to", array(), array("invalid" => "Date from must be lesser than date to.")));
     $school_year = SchoolYearPeer::retrieveByPK(sfContext::getInstance()->getUser()->getReferenceFor("schoolyear"));
     $this->getValidator('examination_number')->setOption('max', $school_year->getMaxCourseExaminationCount());
     $this->getValidator('examination_number')->setMessage('max', 'El número de instancia de mesa no puede ser mayor que %max%');
 }
示例#22
0
 /**
  * Redefines preExecute because this action CANT BE RISED WITHOUT A REFERENCE
  *
  */
 public function preExecute()
 {
     if (!$this->getUser()->getReferenceFor('schoolyear')) {
         $this->getUser()->setFlash('warning', 'Debe seleccionar un año lectivo para poder administrar sus carreras.');
         $this->redirect('@schoolyear');
     }
     $this->school_year = SchoolYearPeer::retrieveByPK($this->getUser()->getReferenceFor('schoolyear'));
     if (is_null($this->school_year)) {
         $this->getUser()->setFlash('warning', 'Debe seleccionar un año lectivo para poder administrar sus carreras.');
         $this->redirect('@schoolyear');
     }
     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 configure()
 {
     parent::configure();
     unset($this['is_closed']);
     $this->setWidget("examination_id", new sfWidgetFormInputHidden());
     $c = new Criteria();
     $c->addJoin(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID, Criteria::INNER_JOIN);
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     $this->setWidget("career_subject_school_year_id", new sfWidgetFormPropelChoice(array('model' => 'CareerSubjectSchoolYear', 'method' => 'getFullToString', 'add_empty' => false, 'criteria' => $c)));
     $this->widgetSchema["examination_subject_teacher_list"]->setOption("multiple", true);
     $this->widgetSchema["examination_subject_teacher_list"]->setOption("peer_method", 'doSelectActive');
     $this->widgetSchema["examination_subject_teacher_list"]->setOption("renderer_class", "csWidgetFormSelectDoubleList");
 }
 /**
  * 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);
             }
         }
     }
 }
示例#26
0
 public function configure()
 {
     unset($this['student_school_year_list']);
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Asset', 'Tag', 'Url'));
     //widgets
     $this->widgetSchema['year'] = new sfWidgetFormInput(array());
     $date = SchoolYearPeer::suggestYear();
     $this->widgetSchema['year']->setDefault($date);
     //validators
     $this->validatorSchema['year'] = new sfValidatorInteger(array('max' => 9999, 'min' => 1900));
     $this->validatorSchema['year']->addMessage('max', '"%value%" debe ser menor a %max%.');
     $this->validatorSchema['year']->addMessage('min', '"%value%" debe ser mayor a  %min%.');
     $this->validatorSchema['year']->addMessage('invalid', 'Debe ingresar un número.');
     $this->validatorSchema->setPostValidator(new sfValidatorPropelUnique(array('model' => 'SchoolYear', 'column' => 'year'), array('invalid' => 'El año lectivo ya existe en el sistema.')));
 }
示例#27
0
 public static function search($query, $sf_user)
 {
     $c = new Criteria();
     $c->addJoin(self::DIVISION_TITLE_ID, DivisionTitlePeer::ID);
     $criterion = $c->getNewCriterion(DivisionTitlePeer::NAME, $query, Criteria::LIKE);
     $criterion->addOr($c->getNewCriterion(self::YEAR, $query));
     $c->add($criterion);
     if ($sf_user->isPreceptor()) {
         PersonalPeer::joinWithDivisions($c, $sf_user->getGuardUser()->getId());
     } elseif ($sf_user->isTeacher()) {
         TeacherPeer::joinWithDivisions($c, $sf_user->getGuardUser()->getId());
     }
     $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     $c->addJoin(self::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID);
     return self::doSelect($c);
 }
 public function configure()
 {
     $w = new sfWidgetFormChoice(array("choices" => array()));
     $w2 = new sfWidgetFormPropelChoice(array('model' => 'SubOrientation', 'add_empty' => true));
     $criteria = new Criteria();
     $criteria->addJoin(CareerPeer::ID, CareerSchoolYearPeer::CAREER_ID);
     $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId());
     $criteria->add(CareerSchoolYearPeer::IS_PROCESSED, false);
     $this->setWidgets(array("career_id" => new sfWidgetFormPropelChoice(array("model" => "Career", 'criteria' => $criteria)), "orientation_id" => new dcWidgetAjaxDependence(array("dependant_widget" => $w, "observe_widget_id" => "multiple_career_registration_career_id", "message_with_no_value" => "Seleccione una carrera y apareceran las orientaciones que correspondan", "get_observed_value_callback" => array(get_class($this), "getOrientations"))), "start_year" => new dcWidgetAjaxDependence(array("dependant_widget" => $w, "observe_widget_id" => "multiple_career_registration_career_id", "message_with_no_value" => "Seleccione una carrera y apareceran los años que correspondan", "get_observed_value_callback" => array(get_class($this), "getYears"))), 'sub_orientation_id' => new dcWidgetAjaxDependencePropel(array('dependant_widget' => $w2, 'observe_widget_id' => 'multiple_career_registration_orientation_id', 'related_column' => 'orientation_id'))));
     $this->setValidators(array("career_id" => new sfValidatorPropelChoice(array("model" => "Career", "required" => true)), "orientation_id" => new sfValidatorPropelChoice(array("model" => "Orientation", "required" => false)), "sub_orientation_id" => new sfValidatorPropelChoice(array("model" => "SubOrientation", "required" => false)), "start_year" => new sfValidatorInteger()));
     $sf_formatter_revisited = new sfWidgetFormSchemaFormatterRevisited($this);
     $this->getWidgetSchema()->addFormFormatter("Revisited", $sf_formatter_revisited);
     $this->getWidgetSchema()->setFormFormatterName("Revisited");
     $this->widgetSchema->setNameFormat('multiple_career_registration[%s]');
     $this->validatorSchema->setOption("allow_extra_fields", true);
 }
 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
 }
示例#30
0
 public function updateOptionalCareerSubject($widget, $value)
 {
     $school_year_id = array_shift($value);
     $criteria = new Criteria();
     if ($school_year_id != "") {
         $career_subject = $this->getObject()->getCareerSubject();
         $school_year = SchoolYearPeer::retrieveByPK($school_year_id);
         $career_subject_school_year = CareerSubjectSchoolYearPeer::retrieveByCareerSubjectAndSchoolYear($career_subject, $school_year);
         $opcions = array();
         foreach ($career_subject_school_year->getChoices() as $optional_career_subject_school_year) {
             $cs = CareerSubjectPeer::retrieveByCareerSubjectSchoolYearId($optional_career_subject_school_year->getChoiceCareerSubjectSchoolYearId());
             $opcions[] = $cs->getId();
         }
         //$opcions es un arreglo con todas las posibles optativas
         $criteria->add(CareerSubjectPeer::ID, $opcions, Criteria::IN);
         $widget->getOption('widget')->setOption('criteria', $criteria);
     }
 }