D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
ksclnmuac
/
www
/
ci_panel
/
application
/
controllers
/
admin
/
Filename :
Non_teaching.php
back
Copy
<?php class Non_teaching 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 index() { # code... $data = []; // for sidebar $data['mainModule'] = 'non_teacher'; $data['subModule'] = 'non_teacher_view'; $this->load->model('Non_teacher_model'); $nonteacher = $this->Non_teacher_model->get_non_teaching(); $data['nonteacher'] = $nonteacher; $this->load->view("admin/non_teaching/non_teaching_view", $data); } public function non_teaching_add() { # code... $data = []; // for sidebar $data['mainModule'] = 'non_teacher'; $data['subModule'] = 'non_teacher_add'; $config['upload_path'] = './public/uploads/non_teacher/'; $config['allowed_types'] = 'png|jpeg|jpg'; $config['encrypt_name'] = TRUE; $this->load->model('Non_teacher_model'); $this->load->library('form_validation'); $this->load->library('upload', $config); $this->form_validation->set_rules('name', 'Staff Name', 'required|trim'); $this->form_validation->set_rules('gender', 'Gender', 'required|trim'); $this->form_validation->set_rules('fname', 'Father Name', 'required|trim'); $this->form_validation->set_rules('designation', 'Designation', 'required|trim'); $this->form_validation->set_rules('mob', 'Mobile Number', 'required|trim|min_length[10]|max_length[13]'); $this->form_validation->set_rules('qualification', 'Qualification', 'required|trim'); $this->form_validation->set_rules('address', 'Address', 'required|trim'); $this->form_validation->set_error_delimiters('<p class="invalid-feedback">', '</p>'); if($this->form_validation->run()==true){ if(!empty($_FILES['file']['name'])){ if($this->upload->do_upload('file')){ $data = $this->upload->data(); $formArray['name'] = $this->input->post('name'); $formArray['gender'] = $this->input->post('gender'); $formArray['fname'] = $this->input->post('fname'); $formArray['designation'] = $this->input->post('designation'); $formArray['mobile'] = $this->input->post('mob'); $formArray['qualification'] = $this->input->post('qualification'); $formArray['address'] = $this->input->post('address'); $formArray['dor'] = date('Y-m-d H:i:s'); $formArray['pic'] = $data['file_name']; $this->Non_teacher_model->add_non_teaching($formArray); $this->session->set_flashdata('success', 'Non Teaching Staff added successfully.'); redirect(base_url().'admin/non_teaching/index'); }else{ $error = $this->upload->display_errors("<p class='invalid-feedback'>", "</p>"); $data['errorImageUpload'] = $error; $this->load->view('admin/non_teaching/non_teaching_add', $data); } }else{ $formArray['name'] = $this->input->post('name'); $formArray['gender'] = $this->input->post('gender'); $formArray['fname'] = $this->input->post('fname'); $formArray['designation'] = $this->input->post('designation'); $formArray['mobile'] = $this->input->post('mob'); $formArray['qualification'] = $this->input->post('qualification'); $formArray['address'] = $this->input->post('address'); $formArray['dor'] = date('Y-m-d H:i:s'); $this->Non_teacher_model->add_non_teaching($formArray); $this->session->set_flashdata('success', 'Non teaching staff added successfully.'); redirect(base_url().'admin/non_teaching/index'); } }else{ $this->load->view("admin/non_teaching/non_teaching_add", $data); } } public function delete($id) { # code... $this->load->model('Non_teacher_model'); $nonTech = $this->Non_teacher_model->getNonTeach($id); if(empty($nonTech)){ $this->session->set_flashdata('error', 'Staff data not found!'); redirect(base_url().'admin/non_teaching/index'); }else{ if(file_exists('./public/uploads/non_teacher/'.$nonTech[0]['pic'])){ unlink('./public/uploads/non_teacher/'.$nonTech[0]['pic']); } $this->Non_teacher_model->deleteNonTeacher($id); $this->session->set_flashdata('success', 'Staff deleted successfully!'); redirect(base_url().'admin/non_teaching/index'); } } public function edit($id) { $data = []; // for sidebar $data['mainModule'] = 'non_teacher'; $data['subModule'] = ''; $config['upload_path'] = './public/uploads/non_teacher/'; $config['allowed_types'] = 'png|jpeg|jpg'; $config['encrypt_name'] = TRUE; $this->load->model('Non_teacher_model'); $this->load->library('form_validation'); $this->load->library('upload', $config); $nonTech = $this->Non_teacher_model->getNonTeach($id); if(empty($nonTech)){ $this->session->set_flashdata('error', 'Non teaching staff not found!'); redirect(base_url('admin/non_teaching/index')); } $data['nontech'] = $nonTech; $this->form_validation->set_rules('name', 'Staff Name', 'required|trim'); $this->form_validation->set_rules('gender', 'Gender', 'required|trim'); $this->form_validation->set_rules('fname', 'Father Name', 'required|trim'); $this->form_validation->set_rules('designation', 'Designation', 'required|trim'); $this->form_validation->set_rules('mob', 'Mobile Number', 'required|trim|min_length[10]|max_length[13]'); $this->form_validation->set_rules('qualification', 'Qualification', 'required|trim'); $this->form_validation->set_rules('address', 'Address', 'required|trim'); $this->form_validation->set_error_delimiters('<p class="invalid-feedback">', '</p>'); if($this->form_validation->run()==true){ if(!empty($_FILES['file']['name'])){ if($this->upload->do_upload('file')){ $data = $this->upload->data(); $path = './public/uploads/non_teacher/'.$nonTech[0]['pic']; if(file_exists($path)){ unlink($path); } $formArray['name'] = $this->input->post('name'); $formArray['gender'] = $this->input->post('gender'); $formArray['fname'] = $this->input->post('fname'); $formArray['designation'] = $this->input->post('designation'); $formArray['mobile'] = $this->input->post('mob'); $formArray['qualification'] = $this->input->post('qualification'); $formArray['address'] = $this->input->post('address'); $formArray['dor'] = date('Y-m-d H:i:s'); $formArray['pic'] = $data['file_name']; $this->Non_teacher_model->update_non_teaching($id, $formArray); $this->session->set_flashdata('success', 'Non Teaching Staff updated successfully.'); redirect(base_url().'admin/non_teaching/index'); }else{ $error = $this->upload->display_errors("<p class='invalid-feedback'>", "</p>"); $data['errorImageUpload'] = $error; $this->load->view('admin/non_teaching/non_teaching_edit', $data); } }else{ $formArray['name'] = $this->input->post('name'); $formArray['gender'] = $this->input->post('gender'); $formArray['fname'] = $this->input->post('fname'); $formArray['designation'] = $this->input->post('designation'); $formArray['mobile'] = $this->input->post('mob'); $formArray['qualification'] = $this->input->post('qualification'); $formArray['address'] = $this->input->post('address'); $formArray['dor'] = date('Y-m-d H:i:s'); $this->Non_teacher_model->update_non_teaching($id, $formArray); $this->session->set_flashdata('success', 'Non teaching staff updated successfully.'); redirect(base_url().'admin/Non_teaching/index'); } }else{ $this->load->view("admin/non_teaching/non_teaching_edit", $data); } } }