Exemplo n.º 1
0
 public function executeUpdate()
 {
     $counseling = CounselingPeer::retrieveByPk($this->getRequestParameter('counseling_id'));
     $this->forward404Unless($counseling);
     $academic_calendar = AcademicCalendarPeer::retrieveByPK($this->getRequestParameter('accal_id'));
     $this->forward404Unless($academic_calendar);
     $status = $this->getRequestParameter('status');
     $tanggal = $this->getRequestParameter('thn') . '-' . $this->getRequestParameter('bln') . '-' . $this->getRequestParameter('tgl');
     if ($this->getRequestParameter('bln') < 10) {
         $tanggal2 = $this->getRequestParameter('thn') . '-0' . $this->getRequestParameter('bln') . '-' . $this->getRequestParameter('tgl');
     } else {
         $tanggal2 = $this->getRequestParameter('thn') . '-' . $this->getRequestParameter('bln') . '-' . $this->getRequestParameter('tgl');
     }
     $tgl_cetak = $this->getRequestParameter('tgl');
     $catatan = $this->getRequestParameter('note');
     $term = $this->getRequestParameter('term');
     $cw = new Criteria();
     $cw->add(TempTablePeer::COUNSELING_ID, $counseling->getId());
     TempTablePeer::doDelete($cw);
     $student_list_ser = $this->getRequestParameter('student_list_ser');
     $params = array();
     foreach (explode('&', $this->getRequestParameter('student_list_ser')) as $p) {
         $p = explode('=', $p);
         $params[rawurldecode($p[0])][] = rawurldecode($p[1]);
     }
     if (array_key_exists('students', $params)) {
         foreach ($params['students'] as $student_id) {
             $cr = new Criteria();
             $cr->add(TempTablePeer::COUNSELING_ID, $counseling->getId());
             $cr->add(TempTablePeer::TIME, $tanggal);
             $cr->add(TempTablePeer::STUDENT_ID, $student_id);
             $temp_table = TempTablePeer::doSelectOne($cr);
             if ($temp_table == null) {
                 $temp_table = new TempTable();
             }
             $temp_table->setStudentId($student_id);
             $temp_table->setCounselingId($this->getRequestParameter('counseling_id'));
             $temp_table->setTime($tanggal);
             $temp_table->save();
             if ($counseling->getAcademicCalendar()->getDepartmentId() == 7) {
                 if ($catatan != null || $catatan != '') {
                     $cb = new Criteria();
                     $cb->add(StudentNotePeer::STUDENT_ID, $student_id);
                     $cb->add(StudentNotePeer::COUNSELING_ID, $counseling->getId());
                     $cb->add(StudentNotePeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId());
                     $cb->add(StudentNotePeer::RANKING, $term);
                     $note = StudentNotePeer::doSelectOne($cb);
                     if ($note == null) {
                         $note = new StudentNote();
                     }
                     $note->setStudentId($student_id);
                     $note->setCounselingId($counseling->getId());
                     $note->setClassGroupId($counseling->getClassGroupId());
                     $note->setAcademicCalendarId($academic_calendar->getId());
                     $note->setNote($catatan);
                     $note->setRanking($term);
                     $note->save();
                 }
             } else {
                 if ($catatan != null || $catatan != '') {
                     $cb = new Criteria();
                     $cb->add(StudentNotePeer::STUDENT_ID, $student_id);
                     $cb->add(StudentNotePeer::COUNSELING_ID, $counseling->getId());
                     $cb->add(StudentNotePeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId());
                     $note = StudentNotePeer::doSelectOne($cb);
                     if ($note == null) {
                         $note = new StudentNote();
                     }
                     $note->setStudentId($student_id);
                     $note->setCounselingId($counseling->getId());
                     $note->setClassGroupId($counseling->getClassGroupId());
                     $note->setAcademicCalendarId($academic_calendar->getId());
                     $note->setNote($catatan);
                     $note->save();
                 }
             }
         }
     }
     $this->counseling = $counseling;
     $this->tanggal = $tanggal;
     $this->tgl_cetak = $tgl_cetak;
     $this->status = $status;
     $this->catatan = $catatan;
     $this->term = $term;
     if ($academic_calendar->getDepartment()->getCourseModel() == Department::CM_TK) {
         return $this->redirect('counseling/preview?counseling_id=' . $counseling->getId() . '&accal_id=' . $academic_calendar->getId() . '&time=' . $tanggal . '&time2=' . $tanggal2 . '&tgl_cetak=' . $tgl_cetak . '&term=' . $term);
     } else {
         if ($academic_calendar->getDepartmentId() == 7) {
             return $this->redirect('counseling/preview?counseling_id=' . $counseling->getId() . '&accal_id=' . $academic_calendar->getId() . '&time=' . $tanggal . '&time2=' . $tanggal2 . '&tgl_cetak=' . $tgl_cetak . '&term=' . $term . '&note=' . $catatan);
         } else {
             return $this->redirect('counseling/preview?counseling_id=' . $counseling->getId() . '&accal_id=' . $academic_calendar->getId() . '&time=' . $tanggal . '&time2=' . $tanggal2 . '&tgl_cetak=' . $tgl_cetak . '&note=' . $catatan);
         }
     }
 }
Exemplo n.º 2
0
 public function executeSaveNotes()
 {
     $course_id = $this->getRequestParameter('course_id');
     $course_schedule = CourseSchedulePeer::retrieveByPK($course_id);
     $this->forward404Unless($course_schedule);
     $descs = $this->getRequestParameter('desc');
     foreach ($descs as $m => $desc) {
         if ($desc != null) {
             if ($desc != '-') {
                 $ced = new Criteria();
                 $ced->add(StudentNotePeer::STUDENT_ID, $m);
                 $ced->add(StudentNotePeer::ACADEMIC_CALENDAR_ID, $course_schedule->getAcademicCalendarId());
                 $ced->add(StudentNotePeer::CLASS_GROUP_ID, $course_schedule->getClassGroupId());
                 $ced->add(StudentNotePeer::RANKING, 5);
                 $note = StudentNotePeer::doSelectOne($ced);
                 if ($note == null) {
                     $note = new StudentNote();
                 }
                 $note->setStudentId($m);
                 $note->setAcademicCalendarId($course_schedule->getAcademicCalendarId());
                 $note->setClassGroupId($course_schedule->getClassGroupId());
                 $note->setNote($desc);
                 $note->setRanking(5);
                 $note->save();
             } else {
                 $ced = new Criteria();
                 $ced->add(StudentNotePeer::STUDENT_ID, $m);
                 $ced->add(StudentNotePeer::ACADEMIC_CALENDAR_ID, $course_schedule->getAcademicCalendarId());
                 $ced->add(StudentNotePeer::CLASS_GROUP_ID, $course_schedule->getClassGroupId());
                 $ced->add(StudentNotePeer::RANKING, 5);
                 $note = StudentNotePeer::doSelectOne($ced);
                 if ($note != null) {
                     $note->delete();
                 }
             }
         }
     }
     return $this->redirect('course_score/listPersonality?course_id=' . $course_schedule->getId());
 }