D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
grievance
/
application
/
controllers
/
Filename :
GrievanceCategory.php
back
Copy
<?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/"); } } }