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); }
/** * Redefines preExecute because this action CANT BE RISED WITHOUT A REFERENCE * */ public function preExecute() { if (!$this->getUser()->getReferenceFor('career_school_year')) { $this->getUser()->setFlash('warning', 'Debe seleccionar una carrera del año lectivo para poder administrar sus materias.'); $this->redirect('@career_school_year'); } $this->career_school_year = CareerSchoolYearPeer::retrieveByPK($this->getUser()->getReferenceFor('career_school_year')); if (is_null($this->career_school_year)) { $this->getUser()->setFlash('warning', 'Debe seleccionar una carrera del año lectivo para poder administrar sus materias.'); $this->redirect('@career_school_year'); } parent::preExecute(); }
public function executeUpdateEquivalence(sfWebRequest $request) { $parametrs = $request->getPostParameters(); $this->career_school_year = CareerSchoolYearPeer::retrieveByPK($parametrs['career_school_year_id']); $this->career = $this->career_school_year->getCareer(); $this->career_subject_school_years = array(); $this->years = array(); $this->forms = array(); for ($y = 1; $y <= $this->career->getQuantityYears(); $y++) { $this->years[] = $y; $this->career_subject_school_years[$y] = $this->career->getCareerSubjectsForYear($y, true); } unset($parametrs['_save']); unset($parametrs['career_school_year_id']); $valid = true; foreach ($parametrs as $parameter) { $career_subject_id = $parameter['career_subject_id']; $student_id = $parameter['student_id']; $school_year_id = $parameter['school_year']; $career_subject = CareerSubjectPeer::retrieveByPK($career_subject_id); $student = StudentPeer::retrieveByPK($student_id); $student_approved_career_subject = StudentApprovedCareerSubjectPeer::retrieveOrCreateByCareerSubjectAndStudent($career_subject->getId(), $student->getId()); $student_approved_career_subject->setSchoolYearId($school_year_id); $parameter['career_subject_id'] = $student_approved_career_subject->getCareerSubjectId(); $this->form = new EquivalenceForm($student_approved_career_subject); $this->form->setCareerSubjectAndStudent($career_subject, $student); if (isset($parameter['mark']) && $parameter['mark'] != "") { $this->form->bind($parameter); if ($this->form->isValid()) { $this->form->save(); } else { $valid = false; } } $this->form = new EquivalenceForm($student_approved_career_subject); $this->form->setCareerSubjectAndStudent($career_subject, $student); $this->forms[$career_subject->getId()] = $this->form; $parameter['career_subject_id'] = $career_subject_id; } if ($valid) { $this->getUser()->setFlash('notice', 'subjects are updated correctly'); } else { $this->setProcessFormErrorFlash(); } $this->module = $this->getModuleName(); $this->setTemplate('makeUpEquivalence'); }
public static function getCourseSUbjects($widget, $values) { $sf_user = sfContext::getInstance()->getUser(); $career_school_year = CareerSchoolYearPeer::retrieveByPK(sfContext::getInstance()->getUser()->getAttribute('career_school_year_id')); $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->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); } $widget->setOption('criteria', $c); }
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; } } }
private function generateStructureReports($params) { if ($params['career_school_year_id'] != "") { $career_school_years = array(CareerSchoolYearPeer::retrieveByPK($params['career_school_year_id'])); } else { $career_school_years = CareerSchoolYearPeer::retrieveBySchoolYear(); } $this->shift = isset($params['shift_id']) ? $params['shift_id'] : ""; $this->division = isset($params['division_id']) ? $params['division_id'] : ""; $this->year = isset($params['year']) ? $params['year'] : ""; $this->stats_table = array(); $this->school_year = $career_school_years[0]->getSchoolYear(); if (count($career_school_years) == 1) { $this->career_school_year = $career_school_years[0]; } $this->stats_table['structure_reports'] = $this->generateGeneralReports($career_school_years); $this->stats_table['shift_reports'] = $this->generateShiftReports($career_school_years, $this->shift); $this->stats_table['shift_division_reports'] = $this->generateShiftDivisionReports($career_school_years, $this->shift, $this->division); $this->stats_table['year_reports'] = $this->generateYearReports($career_school_years, $this->year); $this->stats_table['year_shift_reports'] = $this->generateYearShiftReports($career_school_years, $this->year, $this->shift); $this->stats_table['year_shift_division_reports'] = $this->generateYearShiftDivisionReports($career_school_years, $this->year, $this->shift, $this->division); }
public function executeUpdateShowConfiguration(sfWebRequest $request) { $this->career_school_year = CareerSchoolYearPeer::retrieveByPK($request->getParameter('id')); if (null === $this->career_school_year) { $this->getUser()->setFlash('error', 'Debe seleccionar una carrera para editar su configuracion'); $this->redirect('@career_school_year'); } $subject_configuration = $this->career_school_year->getSubjectConfiguration(); $this->career_school_year->setSubjectConfiguration($subject_configuration); $this->form = new ShowSubjectConfigurationForm($subject_configuration); $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName())); if ($this->form->isValid()) { $notice = $this->getProcessFormNotice(false); $this->form->save(); $this->getUser()->setFlash('notice', $notice); } else { $this->setProcessFormErrorFlash(); } $this->setTemplate('showConfiguration'); }
echo link_to_function(__('Filtros', array(), 'sf_admin'), "\$('sf_admin_filters_body').toggle();", array('class' => 'sf_admin_filter_toggle')); ?> </th> </tr> </thead> <tbody id="sf_admin_filters_body"> <tr> <th class="th_stats"><?php echo __('School year'); ?> </th> <?php if (!isset($filters['school_year']) || is_null($filters['school_year'])) { ?> <td><?php echo CareerSchoolYearPeer::retrieveByPK($filters['career_school_year'])->getSchoolYear(); ?> </td> <?php } else { ?> <td><?php echo SchoolYearPeer::retrieveByPK($filters['school_year']); ?> </td> <?php } ?> </tr> <tr> <th class="th_stats"><?php
public function getCareerFromStudentStatsFilters() { $user = sfContext::getInstance()->getUser(); $filters = $user->getAttribute('student_stats.filters', null, 'admin_module'); if (!isset($filters['career_school_year']) || is_null($filters['career_school_year'])) { $school_year = SchoolYearPeer::retrieveByPK($filters['school_year']); $result = implode(', ', CareerSchoolYearPeer::retrieveBySchoolYear(null, $school_year)); } else { $result = CareerSchoolYearPeer::retrieveByPK($filters['career_school_year']); } return $result; }