Пример #1
0
 public function executeSaveTerm()
 {
     $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');
     $course_schedule = CourseSchedulePeer::retrieveByPk($this->getRequestParameter('course_id'));
     $this->forward404Unless($course_schedule);
     $cur13_ki = Cur13KiPeer::retrieveByPK($this->getRequestParameter('cur13_ki_id'));
     $this->forward404Unless($cur13_ki);
     if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
         $cur13_term = new Cur13Term();
         $cur13_term->setId($this->getRequestParameter('id'));
         $cur13_term->setCourseScheduleId($course_schedule->getId());
         $cur13_term->setCur13KiId($cur13_ki->getId());
         $cur13_term->setCode($this->getRequestParameter('code'));
         $cur13_term->setName($this->getRequestParameter('name'));
         $cur13_term->setDescription($this->getRequestParameter('description'));
         $cur13_term->save();
     } else {
         $cur13_term = Cur13TermPeer::retrieveByPk($this->getRequestParameter('id'));
         $this->forward404Unless($cur13_term);
         $cur13_term->setId($this->getRequestParameter('id'));
         $cur13_term->setCourseScheduleId($course_schedule->getId());
         $cur13_term->setCur13KiId($cur13_ki->getId());
         $cur13_term->setCode($this->getRequestParameter('code'));
         $cur13_term->setName($this->getRequestParameter('name'));
         $cur13_term->setDescription($this->getRequestParameter('description'));
         $cur13_term->save();
         ## Simpan Komponen Penilaian
         $subs = $this->getRequestParameter('sub');
         $bobot = $this->getRequestParameter('bobot');
         foreach ($subs as $m => $sub) {
             $ids = split('_', $m);
             $ct = new Criteria();
             $ct->add(Cur13TermSpecPeer::CUR13_TERM_ID, $ids[1]);
             $ct->add(Cur13TermSpecPeer::GRADE_SPEC_ID, $ids[0]);
             $ga_spec = Cur13TermSpecPeer::doSelectOne($ct);
             if ($ga_spec == null) {
                 $ga_spec = new Cur13TermSpec();
             }
             $ga_spec->setCur13TermId($ids[1]);
             $ga_spec->setGradeSpecId($ids[0]);
             $ga_spec->setBobot($bobot[$m]);
             $ga_spec->save();
         }
         ## Hapus Komponen
         $delsubs = $this->getRequestParameter('delsub');
         foreach ($delsubs as $m => $delsub) {
             $ids = split('_', $m);
             $ct = new Criteria();
             $ct->add(Cur13TermSpecPeer::CUR13_TERM_ID, $ids[1]);
             $ct->add(Cur13TermSpecPeer::GRADE_SPEC_ID, $ids[0]);
             $ga_spec = Cur13TermSpecPeer::doSelectOne($ct);
             if ($ga_spec != null) {
                 $ga_spec->delete();
             }
         }
     }
     return $this->redirect('course_sd/listTerm?course_id=' . $course_schedule->getId() . '&cur13_ki_id=' . $cur13_ki->getId());
 }
Пример #2
0
 public function executeSave()
 {
     $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');
     $subject_curr_id = $this->getRequestParameter('subject_curr_id');
     $subject_curr = SubjectCurrPeer::retrieveByPK($subject_curr_id);
     $this->forward404Unless($subject_curr);
     $academic_calendar_id = $this->getRequestParameter('accal_id');
     $academic_calendar = AcademicCalendarPeer::retrieveByPK($academic_calendar_id);
     $this->forward404Unless($academic_calendar);
     $class_group_id = $this->getRequestParameter('class_group_id');
     $class_group = ClassGroupPeer::retrieveByPK($class_group_id);
     $this->forward404Unless($class_group);
     $bobotki3 = $this->getRequestParameter('bobotki3');
     $bobotki4 = $this->getRequestParameter('bobotki4');
     $kis = $this->getRequestParameter('ki');
     foreach ($kis as $m => $ki) {
         $subs = $this->getRequestParameter('sub');
         foreach ($subs as $k => $sub) {
             $c = new Criteria();
             $c->add(CourseSchedulePeer::CLASS_GROUP_ID, $k);
             $c->add(CourseSchedulePeer::SUBJECT_CURR_ID, $subject_curr->getId());
             $c->add(CourseSchedulePeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId());
             $course_sched = CourseSchedulePeer::doSelectOne($c);
             if ($course_sched) {
                 $cur13_term = new Cur13Term();
                 $cur13_term->setCourseScheduleId($course_sched->getId());
                 $cur13_term->setCode($this->getRequestParameter('code'));
                 $cur13_term->setName($this->getRequestParameter('name'));
                 $cur13_term->setDescription($this->getRequestParameter('description'));
                 $cur13_term->setCur13KiId($m);
                 $cur13_term->save();
                 ##KI.3
                 if ($m == ScoreRule::THREE) {
                     $spki3s = $this->getRequestParameter('spki3');
                     foreach ($spki3s as $l => $spki3) {
                         $ct = new Criteria();
                         $ct->add(Cur13TermSpecPeer::CUR13_TERM_ID, $cur13_term->getId());
                         $ct->add(Cur13TermSpecPeer::GRADE_SPEC_ID, $l);
                         $cur13_ts = Cur13TermSpecPeer::doSelectOne($ct);
                         if ($cur13_ts == null) {
                             $cur13_ts = new Cur13TermSpec();
                         }
                         $cur13_ts->setCur13TermId($cur13_term->getId());
                         $cur13_ts->setGradeSpecId($l);
                         $cur13_ts->setBobot($bobotki3[$l]);
                         $cur13_ts->save();
                     }
                     ##KI.4
                 } elseif ($m == ScoreRule::FOUR) {
                     $spki4s = $this->getRequestParameter('spki4');
                     foreach ($spki4s as $l => $spki4) {
                         $ct = new Criteria();
                         $ct->add(Cur13TermSpecPeer::CUR13_TERM_ID, $cur13_term->getId());
                         $ct->add(Cur13TermSpecPeer::GRADE_SPEC_ID, $l);
                         $cur13_ts = Cur13TermSpecPeer::doSelectOne($ct);
                         if ($cur13_ts == null) {
                             $cur13_ts = new Cur13TermSpec();
                         }
                         $cur13_ts->setCur13TermId($cur13_term->getId());
                         $cur13_ts->setGradeSpecId($l);
                         $cur13_ts->setBobot($bobotki4[$l]);
                         $cur13_ts->save();
                     }
                 }
             } else {
                 if (SF_ENVIRONMENT == 'dev') {
                     echo 'course schedule not found';
                     die;
                 }
             }
         }
     }
     return $this->redirect('cur13_term/getSubject?subject_curr_id=' . $subject_curr->getId() . '&accal_id=' . $academic_calendar->getId() . '&class_group_id=' . $class_group->getId());
 }