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() { 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 getCareersCriteria() { $criteria = new Criteria(); $school_year = SchoolYearPeer::retrieveCurrent(); $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId()); return $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()); }
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); }
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 executeShow(sfWebRequest $request) { $this->school_year = $this->getRoute()->getObject(); $this->getUser()->setReferenceFor($this); $this->form = new TentativeRepprovedStudentForm(); $this->students = PathwayStudentPeer::getStudentsForSchoolYear(SchoolYearPeer::retrieveCurrent()); }
public function canManualExamination(PropelPDO $con = null) { $count_careers = $this->countCareerSchoolYears(); if ($count_careers == 0) { return false; } return $this->getId() == SchoolYearPeer::retrieveCurrent()->getId(); }
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; }
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 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; }
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()); }
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; }
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; }
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); }
/** * 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); } } } }
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); }
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); }
/** * Returns an arrays of WeekDaysindicating each course that uses * this classroom * * @return array */ public function getWeekCalendar(SchoolYear $school_year = null) { if (is_null($school_year)) { $school_year = SchoolYearPeer::retrieveCurrent(); } $career_subject_school_years = array(); foreach ($school_year->getCareerSchoolYearsJoinCareer() as $career_school_year) { foreach ($career_school_year->getCareerSubjectSchoolYears() as $css) { $career_subject_school_years[] = $css->getId(); } } $criteria = new Criteria(); $criteria->add(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, $career_subject_school_years, Criteria::IN); $days = array(); foreach ($this->getCourseSubjectDaysJoinCourseSubject($criteria) as $course_day) { $days[] = $course_day->getWeekDay(); } return $days; }
public function getOptionalCourseSubjectStudents($student, $school_year = null) { if (is_null($school_year)) { $school_year = SchoolYearPeer::retrieveCurrent(); } $c = new Criteria(); $c->add(CoursePeer::SCHOOL_YEAR_ID, $school_year->getId()); $c->addJoin(CourseSubjectPeer::COURSE_ID, CoursePeer::ID); $c->addJoin(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, CourseSubjectPeer::ID); $c->addJoin(CourseSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID, CareerSubjectSchoolYearPeer::ID); $c->addJoin(CareerSubjectPeer::ID, CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID); $c->add(CareerSubjectPeer::IS_OPTION, true); CareerSubjectSchoolYearPeer::sorted($c); $course_subject_students = $student->getCourseSubjectStudents($c); $results = array(); foreach ($course_subject_students as $css) { $results[] = $css; } return $results; }
public function buildCriteria(Criteria $criteria = null) { if (null === $criteria) { $criteria = new Criteria(); } $params = $this->getFilterCriteria(); $criteria->setLimit(50); if (isset($params['attendance_subject']) && $params['attendance_subject']) { $criteria->add(StudentAttendancePeer::COURSE_SUBJECT_ID, null, Criteria::ISNOTNULL); } if (isset($params['from_date']) && trim($params['from_date']) != '') { $criteria->add(StudentAttendancePeer::DAY, $params['from_date'], Criteria::GREATER_EQUAL); } if (isset($params['to_date']) && trim($params['to_date']) != '') { $criteria->addAnd(StudentAttendancePeer::DAY, $params['to_date'], Criteria::LESS_EQUAL); } if (isset($params['student']) && trim($params['student']) != '') { if (is_numeric($params['student'])) { //si es un nro chequeo documento $criteria->add(PersonPeer::IDENTIFICATION_NUMBER, (int) $params['student']); $criteria->addJoin(StudentPeer::PERSON_ID, PersonPeer::ID); $criteria->addJoin(StudentPeer::ID, StudentAttendancePeer::STUDENT_ID); } else { $criteria->add(PersonPeer::LASTNAME, '%' . $params['student'] . '%', Criteria::LIKE); $criteria->addJoin(StudentPeer::PERSON_ID, PersonPeer::ID); $criteria->addJoin(StudentPeer::ID, StudentAttendancePeer::STUDENT_ID); } } if ($this->getUser()->isPreceptor()) { PersonalPeer::joinWithStudents($criteria, $this->getUser()->getGuardUser()->getId()); $criteria->addJoin(StudentPeer::ID, StudentAttendancePeer::STUDENT_ID); } $school_year = SchoolYearPeer::retrieveCurrent(); //Filtro solo las que son faltas. $criteria->add(StudentAttendancePeer::VALUE, 0, Criteria::GREATER_THAN); $criteria->addJoin(StudentAttendancePeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID); $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year->getId()); $criteria->addDescendingOrderByColumn(StudentAttendancePeer::DAY); return $criteria; }
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 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; } }
public function configure() { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url')); $sf_formatter_revisited = new sfWidgetFormSchemaFormatterRevisited($this); $this->getWidgetSchema()->addFormFormatter("Revisited", $sf_formatter_revisited); $this->getWidgetSchema()->setFormFormatterName("Revisited"); $this->widgetSchema->setNameFormat('multiple_student_attendance[%s]'); $this->validatorSchema->setOption("allow_extra_fields", true); $c = new Criteria(); $c->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId()); $this->setWidget('career_school_year_id', new sfWidgetFormPropelChoice(array('model' => 'CareerSchoolYear', 'add_empty' => true, 'criteria' => $c))); $this->setValidator('career_school_year_id', new sfValidatorPropelChoice(array('model' => 'CareerSchoolYear', 'required' => true))); #widget de año lectivo $w = new sfWidgetFormChoice(array('choices' => array())); $this->setWidget('year', new dcWidgetAjaxDependence(array('dependant_widget' => $w, 'observe_widget_id' => 'multiple_student_attendance_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')))); $this->setValidator('year', new sfValidatorString(array('required' => true))); #widget division $division_widget = new sfWidgetFormPropelChoice(array('model' => 'Division', 'add_empty' => true)); $this->setWidget('division_id', new dcWidgetAjaxDependence(array('dependant_widget' => $division_widget, 'observe_widget_id' => 'multiple_student_attendance_year', "message_with_no_value" => "Seleccione una carrera y un año", 'get_observed_value_callback' => array(get_class($this), 'getDivisions')))); $this->setValidator('division_id', new sfValidatorPropelChoice(array('required' => true, 'model' => 'Division'))); #widget Fecha $this->setWidget('day', new csWidgetFormDateInput()); $this->setValidator('day', new mtValidatorDateString(array('required' => true, 'date_output' => 'Y-m-d'))); }
<link rel="shortcut icon" href="/images/favicon.ico" /> </head> <body onLoad="setFontSize()"> <?php include_partial('global/flashes'); ?> <div id="wrapper"> <div id="header"> <div class="logo"> <?php echo link_to(image_tag("logobba.gif", array('alt' => sfConfig::get('app_institution_name'))), '@homepage', array('title' => __('Ir al inicio'))); ?> <?php $school_year = SchoolYearPeer::retrieveCurrent(); ?> <?php if ($school_year) { ?> <div id="header-school-year"> <?php echo __("Año lectivo vigente: %%school_year%%", array('%%school_year%%' => $school_year)); ?> </div> <?php } ?> </div> <div class="navigation">
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); } }
/** * Event listener function that should be registered to * 'admin.build_criteria' event in order to add some * personalized criteria restrictions. * * @param sfEvent $event * @param Criteria $criteria */ static function applyRestrictions(sfEvent $event, $criteria) { $user = sfContext::getInstance()->getUser(); if ($event->getSubject() instanceof schoolyearActions) { // Restrictions for schoolyear module // $criteria->add(...); } elseif ($event->getSubject() instanceof career_subjectActions) { // Restrictions for careersubject module if ($user->getReferenceFor('career')) { $criteria->add(CareerSubjectPeer::CAREER_ID, $user->getReferenceFor('career')); CareerSubjectPeer::OrderByYearAndName($criteria); } } elseif ($event->getSubject() instanceof career_subject_optionActions) { // Restrictions for careersubject module if ($user->getReferenceFor('career')) { $criteria->add(CareerSubjectPeer::IS_OPTION, true); $criteria->add(CareerSubjectPeer::CAREER_ID, $user->getReferenceFor('career')); } } elseif ($event->getSubject() instanceof career_school_yearActions) { if ($school_year_id = $user->getReferenceFor('schoolyear')) { $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, $school_year_id); } } elseif ($event->getSubject() instanceof career_subject_school_yearActions) { if ($career_school_year_id = $user->getReferenceFor('career_school_year')) { $criteria->add(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $career_school_year_id); $criteria->add(CareerSubjectPeer::IS_OPTION, false); $criteria->addJoin(CareerSubjectPeer::ID, CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID); CareerSubjectSchoolYearPeer::sorted($criteria); } } elseif ($event->getSubject() instanceof optional_school_yearActions) { if ($career_school_year_id = $user->getReferenceFor('career_school_year')) { $criteria->add(CareerSubjectSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $career_school_year_id); $criteria->add(CareerSubjectPeer::HAS_OPTIONS, true); $criteria->addJoin(CareerSubjectPeer::ID, CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID); } } elseif ($event->getSubject() instanceof division_courseActions) { if ($division_id = $user->getReferenceFor('division')) { $criterion = $criteria->getNewCriterion(CoursePeer::DIVISION_ID, $division_id); $criterion->addOr($criteria->getNewCriterion(CoursePeer::RELATED_DIVISION_ID, $division_id)); $criteria->add($criterion); } if ($user->isPreceptor()) { self::addCoursePreceptorCriteria($criteria, $user); } if ($user->isTeacher()) { self::addCourseTeacherCriteria($criteria, $user); } $criteria->setDistinct(); } elseif ($event->getSubject() instanceof divisionActions) { DivisionPeer::sorted($criteria); if ($user->isPreceptor()) { self::addDivisionPreceptorCriteria($criteria, $user); } elseif ($user->isTeacher()) { self::addDivisionTeacherCriteria($criteria, $user); } elseif ($user->isHeadPreceptor()) { self::addDivisionHeadPersonalCriteria($criteria, $user); } } else { if ($event->getSubject() instanceof shared_studentActions) { $reference_array = sfContext::getInstance()->getUser()->getReferenceFor("shared_student"); $peer = $reference_array["peer"]; $fk = $reference_array["fk"]; if (isset($reference_array["object_id"])) { $object_id = $reference_array["object_id"]; } else { $object_ids = $reference_array["object_ids"]; } $criteria->addJoin(constant("{$peer}::STUDENT_ID"), StudentPeer::ID); $criteria->addGroupByColumn(StudentPeer::ID); if (isset($object_id)) { $criteria->add(constant("{$peer}::{$fk}"), $object_id); } else { $criteria->add(constant("{$peer}::{$fk}"), $object_ids, Criteria::IN); } $criteria->addJoin(StudentPeer::PERSON_ID, PersonPeer::ID); $criteria->add(PersonPeer::IS_ACTIVE, true); } else { if ($event->getSubject() instanceof examinationActions || $event->getSubject() instanceof manual_examinationActions) { $school_year_id = sfContext::getInstance()->getUser()->getReferenceFor("schoolyear"); $criteria->add(ExaminationPeer::SCHOOL_YEAR_ID, $school_year_id); if ($user->isTeacher()) { $criteria->addJoin(ExaminationPeer::ID, ExaminationSubjectPeer::EXAMINATION_ID); $criteria->addJoin(ExaminationSubjectPeer::ID, ExaminationSubjectTeacherPeer::EXAMINATION_SUBJECT_ID); $criteria->addJoin(ExaminationSubjectTeacherPeer::TEACHER_ID, TeacherPeer::ID); $criteria->addJoin(TeacherPeer::PERSON_ID, PersonPeer::ID); $criteria->add(PersonPeer::IS_ACTIVE, true); $criteria->add(PersonPeer::USER_ID, $user->getGuardUser()->getId()); } } else { if ($event->getSubject() instanceof examination_subjectActions) { $examination_id = sfContext::getInstance()->getUser()->getReferenceFor("examination"); $criteria->add(ExaminationSubjectPeer::EXAMINATION_ID, $examination_id); $criteria->addJoin(CareerSubjectSchoolYearPeer::ID, ExaminationSubjectPeer::CAREER_SUBJECT_SCHOOL_YEAR_ID); $criteria->addJoin(CareerSubjectPeer::ID, CareerSubjectSchoolYearPeer::CAREER_SUBJECT_ID); $criteria->addAscendingOrderByColumn(CareerSubjectPeer::YEAR); if ($user->isTeacher()) { $criteria->addJoin(ExaminationSubjectPeer::ID, ExaminationSubjectTeacherPeer::EXAMINATION_SUBJECT_ID); $criteria->addJoin(ExaminationSubjectTeacherPeer::TEACHER_ID, TeacherPeer::ID); $criteria->addJoin(TeacherPeer::PERSON_ID, PersonPeer::ID); $criteria->add(PersonPeer::IS_ACTIVE, true); $criteria->add(PersonPeer::USER_ID, $user->getGuardUser()->getId()); } } else { if ($event->getSubject() instanceof manual_examination_subjectActions) { $examination_id = sfContext::getInstance()->getUser()->getReferenceFor("manual_examination"); $criteria->add(ExaminationSubjectPeer::EXAMINATION_ID, $examination_id); if ($user->isTeacher()) { $criteria->addJoin(ExaminationSubjectPeer::ID, ExaminationSubjectTeacherPeer::EXAMINATION_SUBJECT_ID); $criteria->addJoin(ExaminationSubjectTeacherPeer::TEACHER_ID, TeacherPeer::ID); $criteria->addJoin(TeacherPeer::PERSON_ID, PersonPeer::ID); $criteria->add(PersonPeer::IS_ACTIVE, true); $criteria->add(PersonPeer::USER_ID, $user->getGuardUser()->getId()); } } elseif ($event->getSubject() instanceof examination_repprovedActions) { $school_year_id = sfContext::getInstance()->getUser()->getReferenceFor("schoolyear"); $criteria->add(ExaminationRepprovedPeer::SCHOOL_YEAR_ID, $school_year_id); if ($user->isTeacher()) { $criteria->addJoin(ExaminationRepprovedPeer::ID, ExaminationRepprovedSubjectPeer::EXAMINATION_REPPROVED_ID); $criteria->addJoin(ExaminationRepprovedSubjectPeer::ID, ExaminationRepprovedSubjectTeacherPeer::EXAMINATION_REPPROVED_SUBJECT_ID); $criteria->addJoin(ExaminationRepprovedSubjectTeacherPeer::TEACHER_ID, TeacherPeer::ID); $criteria->addJoin(TeacherPeer::PERSON_ID, PersonPeer::ID); $criteria->add(PersonPeer::IS_ACTIVE, true); $criteria->add(PersonPeer::USER_ID, $user->getGuardUser()->getId()); } } elseif ($event->getSubject() instanceof examination_repproved_subjectActions) { $examination_repproved_id = sfContext::getInstance()->getUser()->getReferenceFor("examination_repproved"); $criteria->add(ExaminationRepprovedSubjectPeer::EXAMINATION_REPPROVED_ID, $examination_repproved_id); ExaminationRepprovedSubjectPeer::sortedBySubject($criteria); if ($user->isTeacher()) { $criteria->addJoin(ExaminationRepprovedSubjectPeer::ID, ExaminationRepprovedSubjectTeacherPeer::EXAMINATION_REPPROVED_SUBJECT_ID); $criteria->addJoin(ExaminationRepprovedSubjectTeacherPeer::TEACHER_ID, TeacherPeer::ID); $criteria->addJoin(TeacherPeer::PERSON_ID, PersonPeer::ID); $criteria->add(PersonPeer::IS_ACTIVE, true); $criteria->add(PersonPeer::USER_ID, $user->getGuardUser()->getId()); } } else { if ($event->getSubject() instanceof courseActions) { $school_year = SchoolYearPeer::retrieveCurrent(); $criteria->add(CoursePeer::DIVISION_ID, null, Criteria::ISNULL); $criteria->add(CoursePeer::SCHOOL_YEAR_ID, $school_year->getId()); if ($user->isPreceptor()) { PersonalPeer::joinWithCourse($criteria, $user->getGuardUser()->getId()); } if ($user->isTeacher()) { $criteria->addJoin(CoursePeer::ID, CourseSubjectPeer::COURSE_ID); $criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectTeacherPeer::COURSE_SUBJECT_ID); $criteria->addJoin(CourseSubjectTeacherPeer::TEACHER_ID, TeacherPeer::ID); $criteria->addJoin(TeacherPeer::PERSON_ID, PersonPeer::ID); $criteria->add(PersonPeer::IS_ACTIVE, true); $criteria->add(PersonPeer::USER_ID, $user->getGuardUser()->getId()); $criteria->setDistinct(); } } else { if ($event->getSubject() instanceof commissionActions) { /* $school_year = SchoolYearPeer::retrieveCurrent(); $criteria->add(CoursePeer::SCHOOL_YEAR_ID, $school_year->getId()); */ CoursePeer::sorted($criteria); $criteria->add(CoursePeer::DIVISION_ID, null, Criteria::ISNULL); $criteria->add(CoursePeer::IS_PATHWAY, false); if ($user->isPreceptor()) { PersonalPeer::joinWithCourse($criteria, $user->getGuardUser()->getId()); } elseif ($user->isTeacher()) { TeacherPeer::joinWithCourses($criteria, $user->getGuardUser()->getId(), true); } if ($user->isHeadPreceptor()) { self::addCommissionHeadPreceptorCriteria($criteria, $user); } } else { if ($event->getSubject() instanceof final_examinationActions) { $school_year_id = sfContext::getInstance()->getUser()->getReferenceFor("schoolyear"); $criteria->add(FinalExaminationPeer::SCHOOL_YEAR_ID, $school_year_id); } else { if ($event->getSubject() instanceof final_examination_subjectActions) { $final_examination_id = sfContext::getInstance()->getUser()->getReferenceFor("final_examination"); $criteria->add(FinalExaminationSubjectPeer::FINAL_EXAMINATION_ID, $final_examination_id); if ($user->isTeacher()) { $criteria->addJoin(FinalExaminationSubjectTeacherPeer::TEACHER_ID, TeacherPeer::ID); $criteria->addJoin(TeacherPeer::PERSON_ID, PersonPeer::ID); $criteria->add(PersonPeer::IS_ACTIVE, true); $criteria->add(PersonPeer::USER_ID, $user->getGuardUser()->getId()); } } else { if ($event->getSubject() instanceof equivalenceActions) { $student_id = sfContext::getInstance()->getUser()->getReferenceFor("student"); $criteria->add(StudentCareerSchoolYearPeer::STUDENT_ID, $student_id); } else { if ($event->getSubject() instanceof sub_orientationActions) { $orientation_id = sfContext::getInstance()->getUser()->getReferenceFor("orientation"); $criteria->add(SubOrientationPeer::ORIENTATION_ID, $orientation_id); } else { if ($event->getSubject() instanceof student_reincorporationActions) { $student_id = sfContext::getInstance()->getUser()->getReferenceFor("student"); if (is_null($student_id)) { $student_id = $user->getAttribute('student_id'); } $criteria->add(StudentReincorporationPeer::STUDENT_ID, $student_id); $criteria->addJoin(StudentReincorporationPeer::CAREER_SCHOOL_YEAR_PERIOD_ID, CareerSchoolYearPeriodPeer::ID); $criteria->addJoin(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_ID, CareerSchoolYearPeer::ID); $criteria->add(CareerSchoolYearPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId()); } elseif ($event->getSubject() instanceof shared_course_subjectActions) { $teacher_id = sfContext::getInstance()->getUser()->getReferenceFor("teacher"); $criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectTeacherPeer::COURSE_SUBJECT_ID); $criteria->addJoin(CourseSubjectTeacherPeer::TEACHER_ID, $teacher_id); $criteria->setDistinct(); } elseif ($event->getSubject() instanceof personalActions) { $criteria->add(PersonalPeer::PERSONAL_TYPE, PersonalType::PRECEPTOR); } elseif ($event->getSubject() instanceof head_personalActions) { $criteria->add(PersonalPeer::PERSONAL_TYPE, PersonalType::HEAD_PRECEPTOR); } elseif ($event->getSubject() instanceof student_officeActions) { $criteria->add(PersonalPeer::PERSONAL_TYPE, PersonalType::STUDENTS_OFFICE); } elseif ($event->getSubject() instanceof studentActions) { if ($user->isPreceptor()) { SchoolBehaviourFactory::getInstance()->joinPreceptorWithStudents($criteria, $user->getGuardUser()->getId()); } elseif ($user->isTeacher()) { TeacherPeer::joinWithStudents($criteria, $user->getGuardUser()->getId()); } if ($user->isHeadPreceptor()) { $criteria->addJoin(DivisionStudentPeer::STUDENT_ID, StudentPeer::ID); $criteria->addJoin(DivisionStudentPeer::DIVISION_ID, DivisionPeer::ID); self::addDivisionHeadPersonalCriteria($criteria, $user); } } elseif ($event->getSubject() instanceof licenseActions) { if (!is_null(sfContext::getInstance()->getUser()->getReferenceFor("teacher"))) { $person_id = TeacherPeer::retrieveByPK(sfContext::getInstance()->getUser()->getReferenceFor("teacher"))->getPersonId(); } else { $person_id = PersonalPeer::retrieveByPK(sfContext::getInstance()->getUser()->getReferenceFor("personal"))->getPersonId(); } $criteria->add(LicensePeer::PERSON_ID, $person_id); } elseif ($event->getSubject() instanceof teacherActions) { $criteria->setDistinct(); } else { if ($event->getSubject() instanceof career_school_year_periodActions) { $career_school_year_id = sfContext::getInstance()->getUser()->getReferenceFor("career_school_year"); $criteria->add(CareerSchoolYearPeriodPeer::CAREER_SCHOOL_YEAR_ID, $career_school_year_id); } else { if ($event->getSubject() instanceof student_freeActions) { $student_id = sfContext::getInstance()->getUser()->getReferenceFor("student"); if (is_null($student_id)) { $student_id = $user->getAttribute('student_id'); } $criteria->add(StudentFreePeer::STUDENT_ID, $student_id); } else { if ($event->getSubject() instanceof course_subject_student_examinationActions) { $examination_subject_id = sfContext::getInstance()->getUser()->getReferenceFor("examination_subject"); $criteria->add(CourseSubjectStudentExaminationPeer::EXAMINATION_SUBJECT_ID, $examination_subject_id); } else { if ($event->getSubject() instanceof student_examination_repproved_subjectActions) { $examination_repproved_subject_id = sfContext::getInstance()->getUser()->getReferenceFor("examination_repproved_subject"); $criteria->add(StudentExaminationRepprovedSubjectPeer::EXAMINATION_REPPROVED_SUBJECT_ID, $examination_repproved_subject_id); } else { if ($event->getSubject() instanceof pathway_commissionActions) { $criteria->add(CoursePeer::IS_PATHWAY, true); } } } } } } } } } } } } } } } } } return $criteria; }