예제 #1
0
 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(ScheduleTutorPeer::ID, $pks, Criteria::IN);
         $objs = ScheduleTutorPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
예제 #2
0
 public function getScheduleTutorsJoinSchedule($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseScheduleTutorPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collScheduleTutors === null) {
         if ($this->isNew()) {
             $this->collScheduleTutors = array();
         } else {
             $criteria->add(ScheduleTutorPeer::EMPLOYEE_ID, $this->getId());
             $this->collScheduleTutors = ScheduleTutorPeer::doSelectJoinSchedule($criteria, $con);
         }
     } else {
         $criteria->add(ScheduleTutorPeer::EMPLOYEE_ID, $this->getId());
         if (!isset($this->lastScheduleTutorCriteria) || !$this->lastScheduleTutorCriteria->equals($criteria)) {
             $this->collScheduleTutors = ScheduleTutorPeer::doSelectJoinSchedule($criteria, $con);
         }
     }
     $this->lastScheduleTutorCriteria = $criteria;
     return $this->collScheduleTutors;
 }
예제 #3
0
 public function executeDelete()
 {
     $schedule = SchedulePeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($schedule);
     #$ref_error = 0;
     #foreach ($schedule->getRefCountMethods() as $ref) {
     #	$method = "count".$ref['affix'];
     #	$count = $schedule->$method();
     #	if ($count > 0) {
     #		++$ref_error;
     #		$this->getRequest()->setError('extracurricular/delete/'.sfInflector::camelize($ref['table']), $count);
     #	}
     #}
     #if ($ref_error > 0) {
     #	$this->getRequest()->setError('extracurricular/delete', '_ERR_DELETE_ ('.$schedule->toString().' - id:'.$schedule->getId().')');
     #} else {
     $c = new Criteria();
     $c->add(ScheduleDetailPeer::SCHEDULE_ID, $this->getRequestParameter('id'));
     $sc_details = ScheduleDetailPeer::doSelect($c);
     foreach ($sc_details as $sc_detail) {
         $sc_detail->delete();
     }
     $cb = new Criteria();
     $cb->add(ScheduleTutorPeer::SCHEDULE_ID, $this->getRequestParameter('id'));
     $sc_tutors = ScheduleTutorPeer::doSelect($cb);
     foreach ($sc_tutors as $sc_tutor) {
         $sc_tutor->delete();
     }
     $cw = new Criteria();
     $cw->add(StudentRaportPeer::SCHEDULE_ID, $this->getRequestParameter('id'));
     $sc_raports = StudentRaportPeer::doSelect($cw);
     foreach ($sc_raports as $sc_raport) {
         $sc_raport->delete();
     }
     $schedule->delete();
     #}
     return $this->forward('extracurricular', 'list');
 }
예제 #4
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ScheduleTutorPeer::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->setScheduleId($arr[$keys[2]]);
     }
 }
예제 #5
0
 public function executeListEkskul()
 {
     $user_tipe = $this->getContext()->getUser()->getAttribute('usertype', null, 'bo');
     $accal_id = $this->getRequestParameter('academic_calendar_id');
     $academic_calendar = AcademicCalendarPeer::retrieveByPK($accal_id);
     $this->forward404Unless($academic_calendar);
     $this->academic_calendar = $academic_calendar;
     if ($user_tipe == 'lector') {
         $this->byEmployee = true;
         $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo');
         $employee = EmployeePeer::retrieveByPK($employee_id);
         $this->forward404Unless($employee);
         ##Tampilan untuk Kepala Sekolah dan Coordinator
         if ($employee->getStaffTypeId() == 13 || $employee->getStaffTypeId() == 14 || $employee->getStaffTypeId() == 26) {
             $c = new Criteria();
             $c->add(SchedulePeer::TYPE, Schedule::IS_EKSKUL);
             $c->add(SchedulePeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId());
         } else {
             $cw = new Criteria();
             $cw->add(ScheduleTutorPeer::EMPLOYEE_ID, $employee->getId());
             $tutor = ScheduleTutorPeer::doSelectOne($cw);
             if ($tutor) {
                 $c = new Criteria();
                 $c->add(ScheduleTutorPeer::EMPLOYEE_ID, $employee->getId(), Criteria::IN);
                 $c->addJoin(SchedulePeer::ID, ScheduleTutorPeer::SCHEDULE_ID);
                 $c->add(SchedulePeer::TYPE, Schedule::IS_EKSKUL, Criteria::IN);
                 $c->add(SchedulePeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId(), Criteria::IN);
             } else {
                 $c = new Criteria();
                 $c->add(SchedulePeer::EMPLOYEE_ID, $employee->getId(), Criteria::IN);
                 $c->add(SchedulePeer::TYPE, Schedule::IS_EKSKUL, Criteria::IN);
                 $c->add(SchedulePeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId(), Criteria::IN);
             }
         }
     } else {
         $this->byEmployee = false;
         $c = new Criteria();
         $c->add(SchedulePeer::TYPE, Schedule::IS_EKSKUL);
         $c->add(SchedulePeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId());
     }
     $this->sort($c);
     if ($this->getRequest()->hasParameter('filters')) {
         $filters = $this->getRequestParameter('filters');
         if ($filters == 'clear') {
             $this->filters = null;
         } else {
             $defined_filter = false;
             foreach ($filters as $f) {
                 if (is_array($f)) {
                     if (strlen($f['from']) > 0 || strlen($f['to']) > 0) {
                         $defined_filter = true;
                         break;
                     }
                 } else {
                     if ($f != null && $f != '') {
                         $defined_filter = true;
                         break;
                     }
                 }
             }
             if ($defined_filter) {
                 $this->filters = $filters;
                 $this->filter($c, $this->getRequestParameter('filters'));
             }
         }
     }
     $rpp = $this->getRequestParameter('max_per_page', $this->getUser()->getAttribute('max_per_page', ParamsPeer::retrieveByCode('row_per_page')->getValue(), 'schedule'));
     $this->getUser()->setAttribute('max_per_page', $rpp, 'schedule');
     $pager = new sfPropelPager('Schedule', $rpp);
     $pager->setCriteria($c);
     $page = $this->getRequestParameter('page', $this->getUser()->getAttribute('page', 1, 'schedule'));
     $this->getUser()->setAttribute('page', $page, 'schedule');
     $pager->setPage($page);
     $pager->init();
     $this->pager = $pager;
     $actions = array();
     $this->actions = $actions;
     $this->type = 'list';
     $this->subtitle = $academic_calendar->toString();
     $this->academic_calendar = $academic_calendar;
 }
예제 #6
0
 public function executeUpdate()
 {
     $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);
     }
     $schedule->setId($this->getRequestParameter('id'));
     $schedule->setSubjectCurrId($this->getRequestParameter('subject_curr_id'));
     $schedule->setGradeComponentId($this->getRequestParameter('grade_component_id'));
     $schedule->setClassGroupId($this->getRequestParameter('class_group_id'));
     $schedule->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id'));
     $schedule->setDay($this->getRequestParameter('day'));
     $schedule->setName($this->getRequestParameter('name'));
     $schedule->setSemester($this->getRequestParameter('semester'));
     $schedule->setKkm($this->getRequestParameter('kkm'));
     $schedule->setType(2);
     $schedule->setClassSessionId($this->getRequestParameter('class_session_id'));
     $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();
     $c = new Criteria();
     $c->add(ScheduleTutorPeer::SCHEDULE_ID, $schedule->getId());
     ScheduleTutorPeer::doDelete($c);
     $tutors = $this->getRequestParameter('isSelected');
     if ($tutors) {
         foreach ($tutors as $id) {
             $cr = new ScheduleTutor();
             $cr->setSchedule($schedule);
             $cr->setEmployeeId($id);
             $cr->save();
         }
     }
     return $this->redirect('extracurricular/list');
 }