D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
public_html
/
ci_panel
/
application
/
controllers
/
admin
/
Filename :
Committee_mem.php
back
Copy
<?php class Committee_mem 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_mem'; $this->load->library('form_validation'); $this->load->model('Department_model'); $this->load->model('Committee_model'); $this->load->model('Committee_mem_model'); $department = $this->Department_model->index(); $data['department'] = $department; $committee = $this->Committee_model->get_committee(); $data['committee'] = $committee; $committee_mem = $this->Committee_mem_model->get_committee_mem(); $data['committee_mem'] = $committee_mem; // ===> view code end $this->form_validation->set_rules('name', 'Member Name', 'trim|required'); $this->form_validation->set_rules('designation', 'Member Designation', 'trim|required'); $this->form_validation->set_rules('department', 'Department', 'trim|required'); $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['mem_name'] = $this->input->post('name'); $formArray['mem_deg'] = $this->input->post('designation'); $formArray['cc_id'] = $this->input->post('committee'); $formArray['dept_id'] = $this->input->post('department'); $this->Committee_mem_model->add_committee_mem($formArray); $this->session->set_flashdata('success', 'Committee Member added successfully!'); redirect(base_url().'admin/committee_mem/create'); }else{ $this->load->view('admin/committee_mem', $data); } } public function delete($id) { # code... $this->load->model('Committee_mem_model'); $commem = $this->Committee_mem_model->getSingleComMem($id); if(empty($commem)){ $this->session->set_flashdata('error', 'Committee member not found!'); redirect(base_url().'admin/committee_mem/create'); }else{ $this->Committee_mem_model->deleteComMem($id); $this->session->set_flashdata('success', 'Committee member deleted successfully!'); redirect(base_url().'admin/committee_mem/create'); } } public function edit($id) { # code... $data = []; // for sidebar $data['mainModule'] = 'committee'; $data['subModule'] = ''; $this->load->library('form_validation'); $this->load->model('Department_model'); $this->load->model('Committee_model'); $this->load->model('Committee_mem_model'); $commem = $this->Committee_mem_model->getSingleComMem($id); if(empty($commem)){ $this->session->set_flashdata('error', 'Committee member not found!'); redirect(base_url().'admin/committee_mem/create'); } $data['commem'] = $commem; $department = $this->Department_model->index(); $data['department'] = $department; $committee = $this->Committee_model->get_committee(); $data['committee'] = $committee; $this->form_validation->set_rules('name', 'Member Name', 'trim|required'); $this->form_validation->set_rules('designation', 'Member Designation', 'trim|required'); $this->form_validation->set_rules('department', 'Department', 'trim|required'); $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['mem_name'] = $this->input->post('name'); $formArray['mem_deg'] = $this->input->post('designation'); $formArray['cc_id'] = $this->input->post('committee'); $formArray['dept_id'] = $this->input->post('department'); $this->Committee_mem_model->updateComMem($id, $formArray); $this->session->set_flashdata('success', 'Committee Member updated successfully!'); redirect(base_url().'admin/committee_mem/create'); }else{ $this->load->view('admin/committee_mem_edit', $data); } } }