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['semester']=$this->Semester_model->list_semester(); $this->load->view('semester/semester_list',$data); } public function viewSemester($id) { if($this->session->userdata('id')==""){redirect('');} $data['viewSemester']=$this->Semester_model->viewSemester($id); //echo $this->db->last_query();exit; $this->load->view('semester/view_semester',$data); } function add_semester() { $data['subject']=$this->Semester_model->listSubject(); $data['department']=$this->Semester_model->listDepartment(); $data['degree']=$this->Semester_model->listDegree(); //$this->load->view('semester/add_semester'); if($this->input->post('submit')) { $name=$this->input->post('name'); $year=$this->input->post('year'); $subjectId=$this->input->post('subjectId'); $departmentId=$this->input->post('departmentId'); $degreeId=$this->input->post('degreeId'); $subjectIdd = implode(",", (array)$subjectId); //echo $subjectIdd;exit; //echo $degreeId; $table="semester"; $values=array('name'=>$name, 'year'=>$year, 'subjectId'=>$subjectIdd, 'departmentId'=>$departmentId, 'degreeId'=>$degreeId, 'createdOn'=>date('Y-m-d'), 'createdBy'=>1, 'status'=>1); $result=$this->Commonsql_model->insert_table($table,$values); //echo $this->db->last_query();exit; if($result) { $this->session->set_userdata('suc','successfully added'); redirect('semester'); } else { $this->session->set_userdata('err','Please try again'); redirect('semester'); } } $this->load->view('semester/add_semester',$data); } function editSemester($id) { if($this->input->post('submit')) { $name=$this->input->post('name'); $year=$this->input->post('year'); $subjectId=$this->input->post('subjectId'); $departmentId=$this->input->post('departmentId'); $degreeId=$this->input->post('degreeId'); $subjectIdd = implode(",", (array)$subjectId); $table="semester"; $where=array("id"=>$id); $values=array( 'name'=>$name, 'year'=>$year, 'subjectId'=>$subjectIdd, 'departmentId'=>$departmentId, 'degreeId'=>$degreeId, 'updatedOn'=>date('Y-m-d'), 'updatedby'=>1); $result=$this->Commonsql_model->updateTable($table,$where,$values); //echo $this->db->last_query();exit; if($result) { $this->session->set_userdata('suc','successfully Updated'); redirect('semester'); } else { $this->session->set_userdata('err','Please try again'); redirect('semester'); } } $data['subject']=$this->Semester_model->listSubject(); $data['department']=$this->Semester_model->listDepartment(); $data['degree']=$this->Semester_model->listDegree(); $data['getData']=$this->Semester_model->getSemester($id); $this->load->view('semester/edit_semester',$data); } function deleteSemester() { if($this->input->post('submit')) { $semesterId=$this->input->post('semesterId'); $table="semester"; $where=array("id"=>$semesterId); $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'); } } } }