Esempio n. 1
0
 public function executeEdit()
 {
     $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo');
     $c = new Criteria();
     $c->add(JobPeer::CODE, $this->getModuleName());
     $job = JobPeer::doSelectOne($c);
     $acl = AclPeer::retrieveByPK($group_id, $job->getId());
     if (!$acl) {
         $this->forward('default', 'error404');
     }
     $this->can_add = $acl->getAddPriv() == 1;
     $this->can_edit = $acl->getEditPriv() == 1;
     $this->can_remove = $acl->getRemovePriv() == 1;
     $class_agenda = ClassAgendaPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($class_agenda);
     $this->subtitle = '';
     if (sfContext::getInstance()->getUser()->getAttribute('usertype', null, 'bo') == 'lector') {
         $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo');
         $employee = EmployeePeer::retrieveByPK($employee_id);
         $this->forward404Unless($employee);
         $this->subtitle = $employee->toString();
         $this->employee_id = $employee_id;
     }
     $accal_options = array();
     $c = new Criteria();
     $dept = $this->getContext()->getUser()->getAttribute('department', null, 'bo');
     $c->add(AcademicCalendarPeer::DEPARTMENT_ID, $dept->getChildRecurs(), Criteria::IN);
     $c->addDescendingOrderByColumn(AcademicCalendarPeer::CODE);
     $accals = AcademicCalendarPeer::doSelect($c);
     foreach ($accals as $accal) {
         if ($accal->getParent() != null) {
             $accal_options[$accal->getId()] = '·  ' . $accal->toString();
         } else {
             $accal_options[$accal->getId()] = $accal->toString();
         }
     }
     $this->accal_options = $accal_options;
     $this->actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value")), array('name' => 'cancel', 'url' => 'agenda/list', 'color' => 'black'));
     $this->subtitle = '';
     $this->type = 'add';
     $this->class_agenda = $class_agenda;
     $c = new Criteria();
     $c->add(SubjectGradingPeer::SUBJECT_CURR_ID, $class_agenda->getCourseSchedule()->getSubjectCurrId(), Criteria::IN);
     $c->addAscendingOrderByColumn(SubjectGradingPeer::ID);
     $objs = SubjectGradingPeer::doSelect($c);
     $grades = array();
     foreach ($objs as $o) {
         $grades[$o->getId()] = $o->getGradeComponent()->toString();
     }
     $this->grades = $grades;
     $this->selected_grade = $class_agenda->getSubjectGradingId();
     $scheds_options = array();
     $c = new Criteria();
     $c->add(CourseScheduleTutorPeer::EMPLOYEE_ID, $employee_id, Criteria::IN);
     $c->add(CourseSchedulePeer::ACADEMIC_CALENDAR_ID, $class_agenda->getCourseSchedule()->getAcademicCalendarId(), Criteria::IN);
     $c->addJoin(CourseSchedulePeer::ID, CourseScheduleTutorPeer::COURSE_SCHEDULE_ID);
     $c->addJoin(CourseScheduleDetailPeer::COURSE_SCHEDULE_ID, CourseSchedulePeer::ID);
     $c->addAscendingOrderByColumn(CourseScheduleDetailPeer::CLASS_SESSION_ID);
     $csds = CourseScheduleDetailPeer::doSelect($c);
     foreach ($csds as $csd) {
         $scheds_options[$csd->getCourseScheduleId()] = $csd->getCourseSchedule()->getSubjectCurr()->getSubject()->getName() . ' # ' . $csd->getCourseSchedule()->getClassGroup()->getName();
     }
     $this->scheds = $scheds_options;
     $this->selected_sched = $class_agenda->getCourseScheduleId();
     $c = new Criteria();
     $cton4 = $c->getNewCriterion(StudentAbsencePeer::END, $class_agenda->getDate(), Criteria::IN);
     $cton3 = $c->getNewCriterion(StudentAbsencePeer::START, $class_agenda->getDate(), Criteria::IN);
     $cton2 = $c->getNewCriterion(StudentAbsencePeer::ACADEMIC_CALENDAR_ID, $class_agenda->getCourseSchedule()->getAcademicCalendarId(), Criteria::IN);
     $cton1 = $c->getNewCriterion(StudentAbsencePeer::CLASS_GROUP_ID, $class_agenda->getClassGroupId(), Criteria::IN);
     $cton3->addOr($cton4);
     $cton2->addAnd($cton3);
     $cton1->addAnd($cton2);
     $c->add($cton1);
     $this->student_absences = StudentAbsencePeer::doSelect($c);
     $this->stu_count = StudentAbsencePeer::doCount($c);
 }
Esempio n. 2
0
 public function countStudentAbsences($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseStudentAbsencePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(StudentAbsencePeer::ACADEMIC_CALENDAR_ID, $this->getId());
     return StudentAbsencePeer::doCount($criteria, $distinct, $con);
 }