load->model('Faculty_model'); $this->load->model('Commonsql_model'); } /** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/ * @see https://codeigniter.com/user_guide/general/urls.html */ public function faculty_list() { $data['fac']=$this->Faculty_model->list_fa(); $this->load->view('faculty/faculty_list',$data); } function add_faculty() { $this->load->view('faculty/add_faculty'); if($this->input->post('submit')) { $faculty=$this->input->post('code'); $name=$this->input->post('name'); $email=$this->input->post('email'); //$dob=$this->input->post('dob'); $gender=$this->input->post('gender'); $number=$this->input->post('mobile'); $address=$this->input->post('address'); $desi=$this->input->post('designation'); $f_img=$this->input->post('image'); $table="faculty"; $values=array('code'=>$faculty, 'name'=>$name, 'email'=>$email, //'dob'=>$dob, 'gender'=>$gender, 'mobile'=>$number, 'address'=>$address, 'designation'=>$desi, 'image'=>$f_img, 'created_on'=>date('Y-m-d'), 'created_by'=>1, 'status'=>1); $result=$this->Commonsql_model->insert_table($table,$values); if($result) { $this->session->set_userdata('suc','successfully added'); redirect('faculty'); } else { $this->session->set_userdata('err','Please try again'); redirect('faculty'); } } } function edit_faculty($id) { $data['fac']=$this->Faculty_model->get_fac($id); $this->load->view('faculty/edit_faculty',$data); if($this->input->post('submit')) { $faculty=$this->input->post('code'); $name=$this->input->post('name'); $email=$this->input->post('email'); //$dob=$this->input->post('dob'); $gender=$this->input->post('gender'); $number=$this->input->post('number'); $address=$this->input->post('address'); $desi=$this->input->post('designation'); $f_img=$this->input->post('image'); $table="faculty"; $where=array("id"=>$id); $values=array('code'=>$faculty, 'name'=>$name, 'email'=>$email, //'dob'=>$dob, 'gender'=>$gender, 'mobile'=>$number, 'address'=>$address, 'designation'=>$desi, 'image'=>$f_img, 'updated_on'=>date('Y-m-d'), 'updated_by'=>1, 'status'=>1); $result=$this->Commonsql_model->updateTable($table,$where,$values); if($result) { $this->session->set_userdata('suc','successfully Updated'); redirect('faculty'); } else { $this->session->set_userdata('err','Please try again'); redirect('faculty'); } } //echo "sdsd";exit; //echo $this->db->last_query();exit; } function deleted_faculty() { if($this->input->post('submit')) { $id=$this->input->post('hiddenpass'); $table="faculty"; $where=array("id"=>$id); $values=array( 'status'=>0); $result=$this->Commonsql_model->updateTable($table,$where,$values); if($result) { $this->session->set_userdata('suc','successfully deleted'); redirect('faculty'); } else { $this->session->set_userdata('err','Please try again'); redirect('faculty'); } } } }