public function configureWidgets() { $this->setWidget('student_id', new sfWidgetFormInputHidden()); $this->setWidget('school_year_id', new sfWidgetFormInputHidden()); $this->setWidget('request_date', new csWidgetFormDateInput()); $this->setWidget('resolution_date', new csWidgetFormDateInput()); $this->getWidget('disciplinary_sanction_type_id')->setOption('add_empty', true); $this->getWidget('sanction_type_id')->setOption('add_empty', true); $applicants_criteria = new Criteria(); PersonPeer::doSelectOrderedCriteria($applicants_criteria); $results = array(); foreach (PersonalPeer::doSelect(new Criteria()) as $personal) { $results[$personal->getPersonId()] = $personal->getPersonId(); } foreach (TeacherPeer::doSelect(new Criteria()) as $teacher) { $results[$teacher->getPersonId()] = $teacher->getPersonId(); } $applicants_criteria->add(PersonPeer::ID, $results, Criteria::IN); $this->getWidget('applicant_id')->setOption('criteria', $applicants_criteria); $preceptors_criteria = new Criteria(); PersonPeer::doSelectOrderedCriteria($preceptors_criteria); $preceptors_criteria->addJoin(PersonPeer::ID, PersonalPeer::PERSON_ID); $this->getWidget('responsible_id')->setOption('criteria', $preceptors_criteria); $this->setWidget('document', new sfWidgetFormInputFile()); if ($this->getObject()->getDocument()) { $this->setWidget('current_document', new mtWidgetFormPartial(array('module' => 'student_disciplinary_sanction', 'partial' => 'downloable_document', 'form' => $this))); $this->setWidget('delete_document', new sfWidgetFormInputCheckbox()); $this->getWidgetSchema()->moveField('delete_document', sfWidgetFormSchema::BEFORE, 'document'); $this->getWidgetSchema()->moveField('current_document', sfWidgetFormSchema::BEFORE, 'delete_document'); } }
public static function search($query_string, $sf_user, $limit = 12) { $query_string = trim($query_string); if (!is_null($query_string) && !empty($query_string) && '' != $query_string && strlen($query_string) > 3) { $criteria = new Criteria(); $criteria->setIgnoreCase(true); $criteria->setLimit($limit); $criteria->add(SchoolYearStudentPeer::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId()); $criteria->addJoin(SchoolYearStudentPeer::STUDENT_ID, self::ID); $criteria->addJoin(self::PERSON_ID, PersonPeer::ID, Criteria::INNER_JOIN); $criteria->addAscendingOrderByColumn(PersonPeer::LASTNAME); if (is_numeric($query_string)) { // Search by identification number $criteria->add(PersonPeer::IDENTIFICATION_NUMBER, $query_string . '%', Criteria::LIKE); } else { // Search by firstname or lastname $criterion = $criteria->getNewCriterion(PersonPeer::FIRSTNAME, $query_string . '%', Criteria::LIKE); $criterion->addOr($criteria->getNewCriterion(PersonPeer::LASTNAME, $query_string . '%', Criteria::LIKE)); $criteria->add($criterion); } if ($sf_user->isPreceptor()) { PersonalPeer::joinWithStudents($criteria, $sf_user->getGuardUser()->getId()); } elseif ($sf_user->isTeacher()) { TeacherPeer::joinWithStudents($criteria, $sf_user->getGuardUser()->getId()); } //FALTA HEAD PRECEPTOR return self::doSelectActive($criteria); } return array(); }
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 getObject() { if (!is_null(sfContext::getInstance()->getUser()->getReferenceFor("teacher"))) { $this->back_to = 'teacher'; return TeacherPeer::retrieveByPK(sfContext::getInstance()->getUser()->getReferenceFor("teacher"))->getPerson(); } $this->back_to = 'personal'; return PersonalPeer::retrieveByPK(sfContext::getInstance()->getUser()->getReferenceFor("personal"))->getPerson(); }
/** * redefines preExecute because this action CANT BE RISED WITHOUT A REFERENCE * */ public function preExecute() { if (!$this->getUser()->getReferenceFor('teacher')) { $this->getUser()->setFlash('warning', 'Debe seleccionar un profesor para poder ver sus materias.'); $this->redirect('@teacher'); } $this->teacher = TeacherPeer::retrieveByPK($this->getUser()->getReferenceFor('teacher')); if (is_null($this->teacher)) { $this->getUser()->setFlash('warning', 'Debe seleccionar un profesor para poder ver sus materias.'); $this->redirect('@teacher'); } parent::preExecute(); }
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() { $this->setWidget('student_id', new sfWidgetFormInputHidden()); $this->setWidget('school_year_id', new sfWidgetFormInputHidden()); unset($this['resolution_date']); $this->setWidget('request_date', new csWidgetFormDateInput()); $this->setValidator('request_date', new mtValidatorDateString()); $this->getWidgetSchema()->setLabel('request_date', 'Day'); $this->getWidgetSchema()->setHelp('value', 'This field represents the value of the disciplinary sanction'); $this->setValidator('value', new sfValidatorNumber(array('required' => true))); $this->getWidget('disciplinary_sanction_type_id')->setOption('add_empty', true); $this->getWidget('sanction_type_id')->setOption('add_empty', true); $applicants_criteria = new Criteria(); PersonPeer::doSelectOrderedCriteria($applicants_criteria); $results = array(); foreach (PersonalPeer::doSelect(new Criteria()) as $personal) { $results[$personal->getPersonId()] = $personal->getPersonId(); } foreach (TeacherPeer::doSelect(new Criteria()) as $teacher) { $results[$teacher->getPersonId()] = $teacher->getPersonId(); } $applicants_criteria->add(PersonPeer::ID, $results, Criteria::IN); $this->getWidget('applicant_id')->setOption('criteria', $applicants_criteria); $preceptors_criteria = new Criteria(); PersonPeer::doSelectOrderedCriteria($preceptors_criteria); $preceptors_criteria->addJoin(PersonPeer::ID, PersonalPeer::PERSON_ID); $this->getWidget('responsible_id')->setOption('criteria', $preceptors_criteria); $this->setWidget('document', new sfWidgetFormInputFile()); $this->setValidator('document', new sfValidatorFile(array('path' => StudentDisciplinarySanction::getDocumentDirectory(), 'max_size' => '2097152', 'required' => false))); $this->getWidgetSchema()->setHelp('document', 'The file must be of the following types: jpeg, jpg, gif, png, pdf.'); $this->getValidator('document')->setOption('mime_categories', array('web_images' => array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif'), 'documents' => array('application/pdf'))); $this->getWidgetSchema()->moveField('observation', sfWidgetFormSchema::LAST); $this->getWidgetSchema()->moveField('document', sfWidgetFormSchema::AFTER, 'responsible_id'); if ($this->getObject()->getDocument()) { $this->setWidget('current_document', new mtWidgetFormPartial(array('module' => 'student_disciplinary_sanction', 'partial' => 'downloable_document', 'form' => $this))); $this->setValidator('current_document', new sfValidatorPass(array('required' => false))); $this->setWidget('delete_document', new sfWidgetFormInputCheckbox()); $this->setValidator('delete_document', new sfValidatorBoolean(array('required' => false))); $this->getWidgetSchema()->moveField('delete_document', sfWidgetFormSchema::BEFORE, 'document'); $this->getWidgetSchema()->moveField('current_document', sfWidgetFormSchema::BEFORE, 'delete_document'); } }
public function canAddTeacher() { $c = new Criteria(); $c->add(TeacherPeer::PERSON_ID, $this->getPersonId()); return TeacherPeer::doCount($c) == 0; }
public static function addDivisionTeacherCriteria(Criteria $criteria, $user) { TeacherPeer::joinWithDivisions($criteria, $user->getGuardUser()->getId()); }
public function getExportationTitle() { $teacher = TeacherPeer::retrieveByPK(sfContext::getInstance()->getUser()->getReferenceFor('teacher')); return SchoolBehaviourFactory::getInstance()->getExportationSharedCourseSubjectTitle($teacher); }
public static function search($query_string, $sf_user) { if (strlen($query_string) > 3) { $c = new Criteria(); $c->add(self::NAME, '%' . $query_string . '%', Criteria::LIKE); $c->add(self::SCHOOL_YEAR_ID, SchoolYearPeer::retrieveCurrent()->getId()); if ($sf_user->isPreceptor()) { PersonalPeer::joinWithCourse($c, $sf_user->getGuardUser()->getId(), true); } elseif ($sf_user->isTeacher()) { TeacherPeer::joinWithCourses($c, $sf_user->getGuardUser()->getId()); } return self::doSelect($c); } return array(); }
/** * This method returns an array of active teachers related with the course_subjects of the course. * * @return <array> Teacher[] */ public function getActiveTeachers() { $c = new Criteria(); $c->add(CourseSubjectPeer::COURSE_ID, $this->getId()); $c->addJoin(CourseSubjectPeer::ID, CourseSubjectTeacherPeer::COURSE_SUBJECT_ID, Criteria::INNER_JOIN); $c->addJoin(CourseSubjectTeacherPeer::TEACHER_ID, TeacherPeer::ID); $c->addJoin(PersonPeer::ID, TeacherPeer::PERSON_ID); $c->add(PersonPeer::IS_ACTIVE, true); $c->setDistinct(); return TeacherPeer::doSelect($c); }