D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
www
/
ci_panel
/
application
/
controllers
/
admin
/
Filename :
Prev_principal.php
back
Copy
<?php class Prev_principal 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'] = 'academic'; $data['subModule'] = 'prevp'; $this->load->library('form_validation'); $this->load->model('Prev_principal_model'); $prevp = $this->Prev_principal_model->get_prevp(); $data['prevp'] = $prevp; // ====> view code end $this->form_validation->set_rules('pname', 'principal name', 'trim|required'); $this->form_validation->set_rules('tenure', 'Tenure', 'trim|required'); $this->form_validation->set_error_delimiters('<p class="invalid-feedback">', '</p>'); if($this->form_validation->run()==true){ $formArray['pp_name'] = $this->input->post('pname'); $formArray['pp_tenure'] = $this->input->post('tenure'); $formArray['added_on'] = date('Y-m-d H:i:s'); $this->Prev_principal_model->add_pervp($formArray); $this->session->set_flashdata('success', 'Previous Principal added successfully!'); redirect(base_url().'admin/prev_principal/create'); }else{ $this->load->view('admin/prev_principal', $data); } } public function delete($id) { # code... $this->load->model('Prev_principal_model'); $pp = $this->Prev_principal_model->getPrevPri($id); if(empty($pp)){ $this->session->set_flashdata('error', 'Previous Principal data not found!'); redirect(base_url().'admin/prev_principal/create'); }else{ $this->Prev_principal_model->deletePrevPri($id); $this->session->set_flashdata('success', 'Previous Principal deleted successfully!'); redirect(base_url().'admin/prev_principal/create'); } } public function getDataAjax($id) { # code... $this->load->model('Prev_principal_model'); $temp_pp = $this->Prev_principal_model->getPrevPri($id); $pp = json_encode($temp_pp); echo $pp; } public function edit() { # code... $this->load->model('Prev_principal_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('epp_name', 'Principal Name', 'trim|required'); $this->form_validation->set_rules('etenure', 'Tenure', 'trim|required'); if($this->form_validation->run()==true){ // main threat for updation ---> $id = $this->input->post('eid'); $formArray = []; $formArray['pp_name'] = $this->input->post('epp_name'); $formArray['pp_tenure'] = $this->input->post('etenure'); $this->Prev_principal_model->editPrevPrincipal($id, $formArray); $this->session->set_flashdata('success', 'Previous Principal Updated Successfully!'); redirect(base_url().'admin/prev_principal/create'); }else{ $this->session->set_flashdata('error', 'Previous Principal not found!'); redirect(base_url().'admin/prev_principal/create'); } } }