public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(CourseScheduleTutorPeer::ID, $pks, Criteria::IN);
         $objs = CourseScheduleTutorPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
예제 #2
0
 public function executeUpdate()
 {
     $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo');
     $employee = EmployeePeer::retrieveByPK($employee_id);
     $this->forward404Unless($employee);
     $i18n = new sfI18N();
     $i18n->initialize($this->getContext());
     $i18n->setCulture($this->getUser()->getCulture());
     $action_i18n = $i18n->globalMessageFormat->format('save as new');
     $action_type = $this->getRequestParameter('action_type');
     if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
         $schedule = new Schedule();
     } else {
         $schedule = SchedulePeer::retrieveByPk($this->getRequestParameter('id'));
         $this->forward404Unless($schedule);
     }
     $course_schedule = CourseSchedulePeer::retrieveByPk($this->getRequestParameter('course_id'));
     $this->forward404Unless($course_schedule);
     $schedule->setId($this->getRequestParameter('id'));
     $schedule->setSubjectCurrId($course_schedule->getSubjectCurrId());
     $schedule->setClassGroupId($course_schedule->getClassGroupId());
     $schedule->setAcademicCalendarId($course_schedule->getAcademicCalendarId());
     $schedule->setDay($this->getRequestParameter('day'));
     $schedule->setName($this->getRequestParameter('name'));
     $schedule->setSemester($this->getRequestParameter('semester'));
     $schedule->setKkm($this->getRequestParameter('kkm'));
     $schedule->setType(1);
     $schedule->setClassSessionId($this->getRequestParameter('class_session_id'));
     $c = new Criteria();
     $c->add(CourseScheduleTutorPeer::COURSE_SCHEDULE_ID, $course_schedule->getId());
     $cst = CourseScheduleTutorPeer::doSelectOne($c);
     if ($employee->getStaffTypeId() != 21) {
         $schedule->setEmployeeId($this->getRequestParameter('employee_id'));
     } else {
         $schedule->setEmployeeId($cst->getEmployeeId());
     }
     #$schedule->setEmployeeId($this->getRequestParameter('employee_id'));
     $schedule->setLocationId($this->getRequestParameter('location_id'));
     $schedule->setGradeSpecId($this->getRequestParameter('grade_spec_id'));
     $schedule->setDate($this->getRequestParameter('date'));
     $schedule->setDetail($this->getRequestParameter('detail'));
     $schedule->save();
     /* SMS Add */
     if (SF_ENVIRONMENT == 'dev') {
         if ($this->getRequestParameter('send_message') == 1) {
             $lekarSms = new lekarSms();
             $userType = $this->getContext()->getUser()->getAttribute('usertype', '', 'bo');
             $lekarSms->sendSmsCourseTest($schedule, $userType);
         }
     }
     /* --- */
     return $this->redirect('course_test/list?course_id=' . $course_schedule->getId());
 }
예제 #3
0
 public function getCourseScheduleTutorsJoinCourseSchedule($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseCourseScheduleTutorPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collCourseScheduleTutors === null) {
         if ($this->isNew()) {
             $this->collCourseScheduleTutors = array();
         } else {
             $criteria->add(CourseScheduleTutorPeer::EMPLOYEE_ID, $this->getId());
             $this->collCourseScheduleTutors = CourseScheduleTutorPeer::doSelectJoinCourseSchedule($criteria, $con);
         }
     } else {
         $criteria->add(CourseScheduleTutorPeer::EMPLOYEE_ID, $this->getId());
         if (!isset($this->lastCourseScheduleTutorCriteria) || !$this->lastCourseScheduleTutorCriteria->equals($criteria)) {
             $this->collCourseScheduleTutors = CourseScheduleTutorPeer::doSelectJoinCourseSchedule($criteria, $con);
         }
     }
     $this->lastCourseScheduleTutorCriteria = $criteria;
     return $this->collCourseScheduleTutors;
 }
예제 #4
0
 public function executeSelectByClass()
 {
     $class_id = $this->getRequestParameter('class_id');
     $accal_id = $this->getRequestParameter('accal_id');
     $c = new Criteria();
     $c->add(CourseSchedulePeer::CLASS_GROUP_ID, $class_id);
     $c->add(CourseSchedulePeer::ACADEMIC_CALENDAR_ID, $accal_id);
     $c->addAscendingOrderByColumn(CourseSchedulePeer::ID);
     $objs = CourseSchedulePeer::doSelect($c);
     $content = array();
     $disabled = array();
     foreach ($objs as $o) {
         $c = new Criteria();
         $c->add(CourseScheduleTutorPeer::COURSE_SCHEDULE_ID, $o->getId());
         $cst = CourseScheduleTutorPeer::doSelect($c);
         $tutors = array();
         foreach ($cst as $cr) {
             $tutors[] = $cr->getEmployee() ? $cr->getEmployee()->getName() : '-';
         }
         $content[$o->getId()] = $o->getSubjectCurr()->getSubject()->getName() . ' # ' . join("‚", $tutors);
     }
     $this->content = $content;
     $this->disabled = $disabled;
 }
예제 #5
0
 public function executeDeleteSubject()
 {
     $course_schedule = CourseSchedulePeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($course_schedule);
     $accal_id = $this->getRequestParameter('accal_id');
     $this->accal_id = $accal_id;
     $class_id = $this->getRequestParameter('class_id');
     $this->class_id = $class_id;
     $ref_error = 0;
     foreach ($course_schedule->getRefCountMethods() as $ref) {
         $method = "count" . $ref['affix'];
         $count = $course_schedule->{$method}();
         if ($count > 0) {
             ++$ref_error;
             $this->getRequest()->setError('course_sched/deleteSubject/' . sfInflector::camelize($ref['table']), $count);
         }
     }
     if ($ref_error > 0) {
         $this->getRequest()->setError('course_sched/deleteSubject', '_ERR_DELETE_ (' . $course_schedule->toString() . ' - id:' . $course_schedule->getId() . ')');
     } else {
         $c = new Criteria();
         $c->add(CourseScheduleTutorPeer::COURSE_SCHEDULE_ID, $course_sched->getId());
         $cs_tutors = CourseScheduleTutorPeer::doSelect($c);
         foreach ($cs_tutors as $o) {
             $o->delete();
         }
         $course_schedule->delete();
     }
     return $this->redirect('course_sched/preview?class_group_id=' . $class_id . '&accal_id=' . $accal_id);
 }
예제 #6
0
 public function executeDeleteLector()
 {
     $course_schedule = CourseSchedulePeer::retrieveByPk($this->getRequestParameter('course_id'));
     $this->course_schedule = $course_schedule;
     $cs_tutor = CourseScheduleTutorPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($cs_tutor);
     $cs_tutor->delete();
     return $this->redirect('course_schedule/detail?id=' . $course_schedule->getId() . '&accal_id=' . $course_schedule->getAcademicCalendarId() . '&semester=' . $course_schedule->getSemester() . '&class_id=' . $course_schedule->getClassGroupId());
 }
예제 #7
0
 public function executeUpdate()
 {
     $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo');
     $employee = EmployeePeer::retrieveByPK($employee_id);
     $this->forward404Unless($employee);
     $i18n = new sfI18N();
     $i18n->initialize($this->getContext());
     $i18n->setCulture($this->getUser()->getCulture());
     $action_i18n = $i18n->globalMessageFormat->format('save as new');
     $action_type = $this->getRequestParameter('action_type');
     if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
         $class_agenda = new ClassAgenda();
     } else {
         $class_agenda = ClassAgendaPeer::retrieveByPk($this->getRequestParameter('id'));
         $this->forward404Unless($class_agenda);
     }
     $class_agenda->setId($this->getRequestParameter('id'));
     $class_agenda->setCourseScheduleId($this->getRequestParameter('course_schedule_id'));
     $class_agenda->setDetail($this->getRequestParameter('detail'));
     if ($this->getRequestParameter('date')) {
         $class_agenda->setDate($this->getRequestParameter('date'));
     }
     $class_agenda->setStatus($this->getRequestParameter('status'));
     $class_agenda->setSubjectGradingId($this->getRequestParameter('subject_grading_id'));
     $cs = CourseSchedulePeer::retrieveByPk($this->getRequestParameter('course_schedule_id'));
     $this->forward404Unless($cs);
     $c = new Criteria();
     $c->add(CourseScheduleTutorPeer::COURSE_SCHEDULE_ID, $cs->getId());
     $cst = CourseScheduleTutorPeer::doSelectOne($c);
     if ($employee->getStaffTypeId() != 21) {
         $class_agenda->setEmployeeId($this->getRequestParameter('employee_id'));
     } else {
         $class_agenda->setEmployeeId($cst->getEmployeeId());
     }
     $class_agenda->setMeetingPoint($this->getRequestParameter('meeting_point'));
     $class_agenda->setActionType($this->getRequestParameter('action_type'));
     $class_agenda->setDay($this->getRequestParameter('day'));
     $class_agenda->setClassGroupId($cs->getClassGroupId());
     $class_agenda->setClassSessionId($this->getRequestParameter('subject_grading_id'));
     $class_agenda->setDescription($this->getRequestParameter('description'));
     $class_agenda->save();
     if ($this->hasRequestParameter('file') && $this->getRequestParameter('file') != '' && $this->getRequestParameter('file') != null) {
         $fileName = $this->getRequestParameter('file');
         $ca_file = new ClassAgendaFile();
         $ca_file->setClassAgenda($class_agenda);
         $ca_file->setFile($fileName);
         $ca_file->save();
     }
     if ($this->hasRequestParameter('file_1') && $this->getRequestParameter('file_1') != '' && $this->getRequestParameter('file_1') != null) {
         $fileName = $this->getRequestParameter('file_1');
         $ca_file = new ClassAgendaFile();
         $ca_file->setClassAgenda($class_agenda);
         $ca_file->setFile($fileName);
         $ca_file->save();
     }
     if ($this->hasRequestParameter('file_2') && $this->getRequestParameter('file_2') != '' && $this->getRequestParameter('file_2') != null) {
         $fileName = $this->getRequestParameter('file_2');
         $ca_file = new ClassAgendaFile();
         $ca_file->setClassAgenda($class_agenda);
         $ca_file->setFile($fileName);
         $ca_file->save();
     }
     if ($this->hasRequestParameter('file_3') && $this->getRequestParameter('file_3') != '' && $this->getRequestParameter('file_3') != null) {
         $fileName = $this->getRequestParameter('file_3');
         $ca_file = new ClassAgendaFile();
         $ca_file->setClassAgenda($class_agenda);
         $ca_file->setFile($fileName);
         $ca_file->save();
     }
     if ($this->hasRequestParameter('file_4') && $this->getRequestParameter('file_4') != '' && $this->getRequestParameter('file_4') != null) {
         $fileName = $this->getRequestParameter('file_4');
         $ca_file = new ClassAgendaFile();
         $ca_file->setClassAgenda($class_agenda);
         $ca_file->setFile($fileName);
         $ca_file->save();
     }
     if ($this->hasRequestParameter('file_5') && $this->getRequestParameter('file_5') != '' && $this->getRequestParameter('file_5') != null) {
         $fileName = $this->getRequestParameter('file_5');
         $ca_file = new ClassAgendaFile();
         $ca_file->setClassAgenda($class_agenda);
         $ca_file->setFile($fileName);
         $ca_file->save();
     }
     $class = $this->getRequestParameter('filter_class');
     $subject = $this->getRequestParameter('filter_subject');
     if ($class) {
         return $this->redirect('course_agenda/list?course_id=' . $this->getRequestParameter('course_schedule_id') . '&class=' . $class);
     } elseif ($subject) {
         return $this->redirect('course_agenda/list?course_id=' . $this->getRequestParameter('course_schedule_id') . '&subject=' . $subject);
     } else {
         return $this->redirect('course_agenda/list?course_id=' . $this->getRequestParameter('course_schedule_id'));
     }
 }
예제 #8
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = CourseScheduleTutorPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setEmployeeId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCourseScheduleId($arr[$keys[2]]);
     }
 }