load->model('Semester_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 semester_list() { $data['sem']=$this->Semester_model->list_sem(); $this->load->view('semester/semester_list',$data); } function add_semester() { $this->load->view('semester/add_semester'); if($this->input->post('submit')) { $name=$this->input->post('name'); $hod=$this->input->post('hod'); $staff=$this->input->post('staff'); $table="semester"; $values=array('name'=>$name, 'hod'=>$hod, 'staff'=>$staff, '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('semester'); } else { $this->session->set_userdata('err','Please try again'); redirect('semester'); } } } function edit_semester($id) { $data['sem']=$this->Semester_model->get_sem($id); $this->load->view('semester/edit_semester',$data); if($this->input->post('submit')) { $name=$this->input->post('name'); $hod=$this->input->post('hod'); $staff=$this->input->post('staff'); $table="semester"; $where=array("id"=>$id); $values=array('name'=>$name, 'hod'=>$hod, 'staff'=>$staff, //'update_on'=>date('Y-m-d'), // 'update_by'=>1, 'status'=>1); $result=$this->Commonsql_model->updateTable($table,$where,$values); if($result) { $this->session->set_userdata('suc','successfully Updated'); redirect('semester'); } else { $this->session->set_userdata('err','Please try again'); redirect('semester'); } } //echo "sdsd";exit; //echo $this->db->last_query();exit; } function deleted_semester() { if($this->input->post('submit')) { $id=$this->input->post('hiddenpass'); $table="semester"; $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('semester'); } else { $this->session->set_userdata('err','Please try again'); redirect('semester'); } } } }