Example #1
0
 public function executeUpdateAbsence()
 {
     $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');
     $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo');
     $employee = EmployeePeer::retrieveByPK($employee_id);
     $this->forward404Unless($employee);
     $counseling_id = $this->getRequestParameter('counseling_id');
     $counseling = CounselingPeer::retrieveByPK($counseling_id);
     $this->forward404Unless($counseling);
     $accal_id = $this->getRequestParameter('accal_id');
     $academic_calendar = AcademicCalendarPeer::retrieveByPK($accal_id);
     $this->forward404Unless($academic_calendar);
     $student_id = $this->getRequestParameter('student_id');
     $student = StudentPeer::retrieveByPK($student_id);
     $this->forward404Unless($student);
     $date = $this->getRequestParameter('date');
     $tanggal = $this->getRequestParameter('thn') . '-' . $this->getRequestParameter('bln') . '-' . $this->getRequestParameter('tgl');
     $tgl_code = $this->getRequestParameter('tgl') . $this->getRequestParameter('bln') . $this->getRequestParameter('thn');
     $bulan = $this->getRequestParameter('bln');
     $tahun = $this->getRequestParameter('thn');
     $status = $this->getRequestParameter('status');
     if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
         $student_absence = new StudentAbsence();
         $student_absence->setStudentId($student->getId());
         $student_absence->setClassGroupId($counseling->getClassGroupId());
         $student_absence->setAcademicCalendarId($academic_calendar->getId());
         $student_absence->setStatus($status);
         $student_absence->setStart($tanggal);
         $student_absence->setEnd($tanggal);
         $student_absence->setMonth($bulan);
         $student_absence->setYear($tahun);
         $student_absence->save();
     } else {
         $c = new Criteria();
         $c->add(StudentAbsencePeer::STUDENT_ID, $student->getId());
         $c->add(StudentAbsencePeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId());
         $c->add(StudentAbsencePeer::CLASS_GROUP_ID, $counseling->getClassGroupId());
         $c->add(StudentAbsencePeer::START, $date);
         $student_absences = StudentAbsencePeer::doSelect($c);
         foreach ($student_absences as $student_absence) {
             $student_absence->setStudentId($student->getId());
             $student_absence->setClassGroupId($counseling->getClassGroupId());
             $student_absence->setAcademicCalendarId($academic_calendar->getId());
             $student_absence->setStatus($status);
             $student_absence->setStart($tanggal);
             $student_absence->setEnd($tanggal);
             $student_absence->setMonth($bulan);
             $student_absence->setYear($tahun);
             $student_absence->save();
         }
     }
     return $this->redirect('counseling_sd/listAbsence?student_id=' . $student->getId() . '&counseling_id=' . $counseling->getId() . '&accal_id=' . $academic_calendar->getId());
 }
Example #2
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');
     $employee_id = sfContext::getInstance()->getUser()->getAttribute('user_id', null, 'bo');
     $employee = EmployeePeer::retrieveByPK($employee_id);
     $this->forward404Unless($employee);
     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'));
     $class_agenda->setMeetingPoint($this->getRequestParameter('meeting_point'));
     $class_agenda->setActionType($this->getRequestParameter('action_type'));
     $class_agenda->setDay($this->getRequestParameter('day'));
     if ($this->getRequestParameter('class_group_id')) {
         $class_agenda->setClassGroupId($this->getRequestParameter('class_group_id'));
     } else {
         $cs = CourseSchedulePeer::retrieveByPk($this->getRequestParameter('course_schedule_id'));
         $this->forward404Unless($cs);
         $class_agenda->setClassGroupId($cs->getClassGroupId());
     }
     $class_agenda->setDescription($this->getRequestParameter('description'));
     $class_agenda->save();
     $status = $this->getRequestParameter('status');
     if ($status) {
         foreach ($status as $stu_id => $status) {
             $c = new Criteria();
             $c->add(StudentAbsencePeer::ID, $stu_id);
             $g = StudentAbsencePeer::doSelectOne($c);
             if ($g == null) {
                 $g = new StudentAbsence();
             }
             $g->setId($stu_id);
             $g->setStatus($status);
             $g->save();
         }
     }
     return $this->forward('agenda', 'list');
     #return $this->redirect('agenda/list');
 }
Example #3
0
 public function addStudentAbsence(StudentAbsence $l)
 {
     $this->collStudentAbsences[] = $l;
     $l->setAcademicCalendar($this);
 }
Example #4
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')) {
         $student_absence = new StudentAbsence();
         $class_agenda = ClassAgendaPeer::retrieveByPk($this->getRequestParameter('agenda_id'));
         $this->forward404Unless($class_agenda);
         $student_absence->setStudentId($this->getRequestParameter('student_id'));
         $student_absence->setAcademicCalendarId($class_agenda->getCourseSchedule()->getAcademicCalendarId());
         $student_absence->setClassGroupId($class_agenda->getClassGroupId());
         $student_absence->setStatus(5);
         $student_absence->setStart($class_agenda->getDate());
         $student_absence->setEnd($class_agenda->getDate());
         $student_absence->setDetail($this->getRequestParameter('detail'));
         $student_absence->setHoliday($this->getRequestParameter('holiday'));
         $start = strtotime($this->getRequestParameter('start'));
         $end = strtotime($this->getRequestParameter('end'));
         $count = 0;
         for ($i = $start; $i <= $end; $i + 86400) {
             $dn = strftime('%u', $i);
             $i += 86400;
             if ($dn < 6) {
                 ++$count;
             }
         }
         $count -= $student_absence->getHoliday();
         $student_absence->setTotalDays($count);
         $student_absence->save();
         $class_absence = new ClassAbsence();
         $class_absence->setClassAgendaId($class_agenda->getId());
         $class_absence->setStudentAbsence($student_absence);
         $class_absence->save();
     } else {
         $student_absence = StudentAbsencePeer::retrieveByPk($this->getRequestParameter('id'));
         $this->forward404Unless($student_absence);
         $class_agenda = ClassAgendaPeer::retrieveByPk($this->getRequestParameter('agenda_id'));
         $this->forward404Unless($class_agenda);
         $student_absence->setId($this->getRequestParameter('id'));
         $student_absence->setStudentId($this->getRequestParameter('student_id'));
         $student_absence->setAcademicCalendarId($class_agenda->getCourseSchedule()->getAcademicCalendarId());
         $student_absence->setClassGroupId($class_agenda->getClassGroupId());
         $student_absence->setStatus(5);
         $student_absence->setStart($class_agenda->getDate());
         $student_absence->setEnd($class_agenda->getDate());
         $student_absence->setDetail($this->getRequestParameter('detail'));
         $student_absence->setHoliday($this->getRequestParameter('holiday'));
         $start = strtotime($this->getRequestParameter('start'));
         $end = strtotime($this->getRequestParameter('end'));
         $count = 0;
         for ($i = $start; $i <= $end; $i + 86400) {
             $dn = strftime('%u', $i);
             $i += 86400;
             if ($dn < 6) {
                 ++$count;
             }
         }
         $count -= $student_absence->getHoliday();
         $student_absence->setTotalDays($count);
         $student_absence->save();
     }
     return $this->redirect('leave/listByEmployee?agenda_id=' . $this->getRequestParameter('agenda_id'));
 }
Example #5
0
 public function executeSave()
 {
     $course_schedule = CourseSchedulePeer::retrieveByPk($this->getRequestParameter('course_schedule_id'));
     $tanggal = $this->getRequestParameter('thn') . '-' . $this->getRequestParameter('bln') . '-' . $this->getRequestParameter('tgl');
     $tgl_code = $this->getRequestParameter('tgl') . $this->getRequestParameter('bln') . $this->getRequestParameter('thn');
     $bulan = $this->getRequestParameter('bln');
     $tahun = $this->getRequestParameter('thn');
     $status = $this->getRequestParameter('status');
     if ($status) {
         foreach ($status as $stu_id => $status) {
             $stu = StudentPeer::retrieveByPk($stu_id);
             if ($status == AbsenceCourse::STATUS_PRESENT) {
                 $cr = new Criteria();
                 $cr->add(StudentAbsencePeer::STUDENT_ID, $stu_id);
                 $cr->add(StudentAbsencePeer::CLASS_GROUP_ID, $course_schedule->getClassGroupId());
                 $cr->add(StudentAbsencePeer::ACADEMIC_CALENDAR_ID, $course_schedule->getAcademicCalendarId());
                 $cr->add(StudentAbsencePeer::START, $tanggal);
                 $sa = StudentAbsencePeer::doSelectOne($cr);
                 if ($sa != null) {
                     StudentAbsencePeer::doDelete($cr);
                 }
             } else {
                 $cr = new Criteria();
                 $cr->add(StudentAbsencePeer::STUDENT_ID, $stu_id);
                 $cr->add(StudentAbsencePeer::CLASS_GROUP_ID, $course_schedule->getClassGroupId());
                 $cr->add(StudentAbsencePeer::ACADEMIC_CALENDAR_ID, $course_schedule->getAcademicCalendarId());
                 $cr->add(StudentAbsencePeer::START, $tanggal);
                 $student_absence = StudentAbsencePeer::doSelectOne($cr);
                 if ($student_absence == null) {
                     $student_absence = new StudentAbsence();
                 }
                 $student_absence->setStudentId($stu_id);
                 $student_absence->setClassGroupId($course_schedule->getClassGroupId());
                 $student_absence->setAcademicCalendarId($course_schedule->getAcademicCalendarId());
                 $student_absence->setStatus($status);
                 $student_absence->setStart($tanggal);
                 $student_absence->setEnd($tanggal);
                 $student_absence->setMonth($bulan);
                 $student_absence->setYear($tahun);
                 $student_absence->save();
             }
         }
     }
     $cd = new Criteria();
     $cd->add(AttendanceClassPeer::ACADEMIC_CALENDAR_ID, $course_schedule->getAcademicCalendarId());
     $cd->add(AttendanceClassPeer::CLASS_GROUP_ID, $course_schedule->getClassGroupId());
     $cd->add(AttendanceClassPeer::DATETIME, $tanggal);
     $class_attend = AttendanceClassPeer::doSelectOne($cd);
     if ($class_attend == null) {
         $class_attend = new AttendanceClass();
     }
     $class_attend->setClassGroupId($course_schedule->getClassGroupId());
     $class_attend->setAcademicCalendarId($course_schedule->getAcademicCalendarId());
     $class_attend->setDatetime($tanggal);
     $class_attend->save();
     $co = new Criteria();
     $co->add(VAttendancePeer::DATETIME, $tanggal);
     $co->add(VAttendancePeer::CLASS_GROUP_ID, $course_schedule->getClassGroupId());
     $attends = VAttendancePeer::doSelect($co);
     $student_codes = array();
     foreach ($attends as $attend) {
         $student_codes[] = $attend->getFingercode();
     }
     $cm = new Criteria();
     $cm->add(AttendancePeer::STUDENT_ID, $student_codes, Criteria::IN);
     AttendancePeer::doDelete($cm);
     return $this->redirect('course_absence/listShow?course_id=' . $course_schedule->getId());
 }