D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
www
/
ci_panel
/
application
/
controllers
/
admin
/
Filename :
Committee.php
back
Copy
<?php class Committee extends CI_controller{ public function __construct() { # code... parent::__construct(); $admin = $this->session->userdata('admin'); if(empty($admin)){ $this->session->set_flashdata('msg', 'Your session has been expired'); redirect(base_url('admin/login/index')); } } public function create() { // ====> view code start # code... $data = []; // for sidebar $data['mainModule'] = 'committee'; $data['subModule'] = 'committee'; $this->load->library('form_validation'); $this->load->model('Committee_model'); $committee = $this->Committee_model->get_committee(); $data['committee'] = $committee; // ====> view code end $this->form_validation->set_rules('committee', 'Committee', 'trim|required'); $this->form_validation->set_error_delimiters('<p class="invalid-feedback">', '</p>'); if($this->form_validation->run()==true){ $formArray['committee_name'] = $this->input->post('committee'); $formArray['created_at'] = date('Y-m-d H:i:s'); $this->Committee_model->add_committee($formArray); $this->session->set_flashdata('success', 'Committee added successfully!'); redirect(base_url().'admin/committee/create'); }else{ $this->load->view('admin/committee', $data); } } public function delete($id) { # code... $this->load->model('Committee_model'); $comm = $this->Committee_model->getSingleCom($id); if(empty($comm)){ $this->session->set_flashdata('error', 'Committee not found!'); redirect(base_url().'admin/committee/create'); }else{ $this->Committee_model->deleteCom($id); $this->session->set_flashdata('success', 'Committee deleted successfully!'); redirect(base_url().'admin/committee/create'); } } public function getDataAjax($id) { # code... $this->load->model('Committee_model'); $temp_comm = $this->Committee_model->getSingleCom($id); $comm = json_encode($temp_comm); echo $comm; } public function edit() { # code... $this->load->model('Committee_model'); $this->load->library('form_validation'); // Validation start $this->form_validation->set_error_delimiters('<p class="invalid-feedback">', '</p>'); $this->form_validation->set_rules('eid', 'ID', 'trim|required'); $this->form_validation->set_rules('ecommittee', 'Committee', 'trim|required'); if($this->form_validation->run()==true){ // main threat for updation ---> $id = $this->input->post('eid'); $formArray = []; $formArray['committee_name'] = $this->input->post('ecommittee'); $this->Committee_model->editCommittee($id, $formArray); $this->session->set_flashdata('success', 'Committee Updated Successfully!'); redirect(base_url().'admin/committee/create'); }else{ $this->session->set_flashdata('error', 'Committee not found!'); redirect(base_url().'admin/committee/create'); } } }