public function countCourseSchedules($criteria = null, $distinct = false, $con = null) { include_once 'lib/model/om/BaseCourseSchedulePeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(CourseSchedulePeer::EMPLOYEE_ID, $this->getId()); return CourseSchedulePeer::doCount($criteria, $distinct, $con); }
public function executePreviewCopy() { $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; #Copy dari $class1 = $this->getRequestParameter('class1'); $accal1 = $this->getRequestParameter('accal1'); #Copy ke $class2 = $this->getRequestParameter('class2'); $accal2 = $this->getRequestParameter('accal2'); $c = new Criteria(); $c->add(CourseSchedulePeer::ACADEMIC_CALENDAR_ID, $accal1); $c->add(CourseSchedulePeer::CLASS_GROUP_ID, $class1); $course_schedules = CourseSchedulePeer::doSelect($c); $counts = CourseSchedulePeer::doCount($c); $actions = array(array('name' => 'copy', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value")), array('name' => 'cancel', 'url' => 'course_sched/copy', 'color' => 'white')); $this->subtitle = ''; $this->type = 'copy'; $this->course_schedules = $course_schedules; $this->counts = $counts; $this->actions = $actions; $this->class1 = $class1; $this->accal1 = $accal1; $this->class2 = $class2; $this->accal2 = $accal2; $rpp = $this->getRequestParameter('max_per_page', 999); $pager = new sfPropelPager('CourseSchedule', $rpp); $pager->setCriteria($c); $pager->setPage($this->getRequestParameter('page', 1)); $pager->init(); $this->pager = $pager; }
public function executeGetLectors() { $subject_id = $this->getRequestParameter('subject_id'); $accal_id = $this->getRequestParameter('accal_id'); $accal = AcademicCalendarPeer::retrieveByPK($accal_id); $this->forward404Unless($accal); $subject = SubjectPeer::retrieveByPK($subject_id); $subject_academic = null; if (!$subject) { $subject_academic_id = $this->getRequestParameter('subject_academic_id'); $subject_academic = SubjectAccalPeer::retrieveByPK($subject_academic_id); $subject = $subject_academic->getSubject(); } $this->forward404Unless($subject); $subject_id = $subject->getId(); if ($subject_academic == null) { $c = new Criteria(); $c->add(SubjectAccalPeer::ACADEMIC_CALENDAR_ID, $accal_id); $c->add(SubjectAccalPeer::SUBJECT_ID, $subject_id); $subject_academic = SubjectAccalPeer::doSelectOne($c); } $c = new Criteria(); $c->add(TeachingCompetencyPeer::SUBJECT_ID, $subject_id); $c->addJoin(TeachingCompetencyPeer::EMPLOYEE_ID, EmployeePeer::ID); $c->addAscendingOrderByColumn(EmployeePeer::EMP_NO); $objs = EmployeePeer::doSelect($c); $lectors = array(); $disabled = array(); $cs_counts = array(); foreach ($objs as $o) { $lectors[$o->getId()] = $o->toString(); if ($subject_academic) { $c = new Criteria(); $c->add(CourseSchedulePeer::EMPLOYEE_ID, $o->getId()); $c->add(CourseSchedulePeer::SUBJECT_ACCAL_ID, $subject_academic->getId()); $cs_count = CourseSchedulePeer::doCount($c); $cs_counts[$o->getId()] = $cs_count; } } $this->selected_lectors = array(); if ($subject_academic) { $sals = $subject_academic->getSubjectAccalLectors(); foreach ($sals as $sal) { $this->selected_lectors[$sal->getEmployeeId()] = 1; } } $this->cs_counts = $cs_counts; $this->lectors = $lectors; $this->forward404Unless($subject); $this->setTemplate('buildCheckBoxes'); $this->disabled = $disabled; $this->accal = $accal; $this->subject_academic = $subject_academic; }
public function executeSavePreview() { $class_id = $this->getRequestParameter('class_group_id'); $accal_id = $this->getRequestParameter('academic_calendar_id'); $c = new Criteria(); $c->add(StudentPeer::CLASS_GROUP_ID, $this->getRequestParameter('class_group_id')); $students = StudentPeer::doSelect($c); $counts = StudentPeer::doCount($c); $c = new Criteria(); $c->add(GradeComponentPeer::GRADE_SPEC_ID, '20'); $c->add(GradeComponentPeer::PUBLISHED, '1'); $components = GradeComponentPeer::doSelect($c); $accal = AcademicCalendarPeer::retrieveByPk($this->getRequestParameter('academic_calendar_id')); $c = new Criteria(); $c->add(CourseSchedulePeer::ACADEMIC_CALENDAR_ID, $accal_id); $c->add(CourseSchedulePeer::CLASS_GROUP_ID, $class_id); $course_schedules = CourseSchedulePeer::doSelect($c); $counts = CourseSchedulePeer::doCount($c); if ($accal->getCurriculum()->getCourseModel() == Curriculum::CM_PACKAGED || $accal->getCurriculum()->getCourseModel() == Curriculum::CM_PACKAGED_CUSTOM) { #if ($counts > 1) { foreach ($course_schedules as $course_schedule) { foreach ($students as $student) { $c = new Criteria(); $c->add(StudentCoursePeer::SUBJECT_CURR_ID, $course_schedule->getSubjectCurrId()); $c->add(StudentCoursePeer::STUDENT_ID, $student->getId()); $stu_courses = StudentCoursePeer::doCount($c); if ($stu_courses < 1) { $student_course = new StudentCourse(); $student_course->setStudentId($student->getId()); $student_course->setSubjectCurrId($course_schedule->getSubjectCurrId()); $student_course->setStatus(1); $student_course->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id')); $student_course->setClassGroupId($this->getRequestParameter('class_group_id')); $student_course->save(); } } } foreach ($students as $student) { foreach ($components as $component) { $c = new Criteria(); $c->add(StudentCoursePeer::STUDENT_ID, $student->getId()); $c->add(StudentCoursePeer::GRADE_COMPONENT_ID, $component->getId()); $com_courses = StudentCoursePeer::doCount($c); if ($com_courses < 1) { $student_course = new StudentCourse(); $student_course->setStudentId($student->getId()); $student_course->setStatus(1); $student_course->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id')); $student_course->setClassGroupId($this->getRequestParameter('class_group_id')); $student_course->setGradeComponentId($component->getId()); $student_course->save(); } } } #} } return $this->redirect('course_schedule/list'); }