load->model('Dashboard_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 index() { $this->load->view('front/index'); } function login() { $this->load->view('admin/login'); } function dashboard() { if($this->session->userdata('id')==""){redirect('admin/login');} $data['quo']=$this->Dashboard_model->get_quotes(); $data['req']=$this->Dashboard_model->get_request(); $data['res']=$this->Dashboard_model->get_response(); $data['ongo']=$this->Dashboard_model->get_onboard(); $data['com']=$this->Dashboard_model->get_completed(); $data['quo_det']=$this->Dashboard_model->get_quotes_details(); $data['req_det']=$this->Dashboard_model->get_request_details(); $data['res_det']=$this->Dashboard_model->get_response_details(); $data['on_det']=$this->Dashboard_model->get_onboard_details(); $data['com_det']=$this->Dashboard_model->get_complete_details(); $this->load->view('admin/dashboard',$data); } function login_validation() { // echo "sdfdsf";exit; $username = $this->input->post('username'); $password = $this->input->post('password'); $check_user=$this->commonsql_model->user($username,$password); //echo $this->db->last_query();exit; if($check_user->num_rows()>0) { $ch = $check_user->row(); $this->session->set_userdata('id',$ch->id); $this->session->set_userdata('name',$ch->name); $this->session->set_userdata('role_id',$ch->role); $this->session->set_userdata('email',$ch->email); $this->session->set_userdata('mobile',$ch->mobile); $this->session->set_userdata('suc','Successfully Logged in..!'); redirect('admin/dashboard'); } else { $this->session->set_userdata('err','The username or password you entered is incorrect.'); redirect('admin/login'); } } function logout() { $session_data=array('username'=>''); $this->session->unset_userdata($session_data); $this->session->sess_destroy(); redirect('admin/login'); } function profile() { if($this->session->userdata('id')==""){redirect('admin/login');} if($this->input->post('update_profile')) { $username=$this->input->post('username'); $new_password=$this->input->post('new_password'); $unique_id=$this->input->post('unique_id'); $old_password=$this->input->post('old_password'); $password=$old_password; if($username==""){$this->session->set_userdata('err','User Name is a required field');redirect('admin/profile');} if($new_password!=""){$password=md5($new_password);} $values=array('username'=>$username,'password'=>$password); $tablename="staff";$wheredata=array('id'=>$unique_id); $update_user=$this->commonsql_model->updateTable($tablename,$wheredata,$values); if($update_user) { $this->session->set_userdata('suc'," Successfully updated!"); redirect('admin/profile'); } else { $this->session->set_userdata('err'," Please try again"); redirect('admin/profile'); } } $this->load->view('admin/profile'); } } ?>