load->model('m_data'); if($_SESSION['status_login'] == "login"){ $this->db_ = $this->load->database('skpv',TRUE); }elseif ($this->session->userdata('status_login') !="login") { $this->session->set_flashdata('flash_error', 'Silahkan Login Terlebih dahulu.'); redirect('landing','refresh'); } } //menampilkan view header, index dan footer function index(){ $data=[]; if (in_array("admin",$_SESSION['role'])){ $data['mhs'] = $this->db_->get('mahasiswa')->num_rows(); $data['dosen'] = $this->db_->get('dosen')->num_rows(); $data['matkul'] = $this->db_->get('matakuliah')->num_rows(); $data['user'] = $this->m_data->get_data('user')->num_rows(); $data['dhmd'] = $this->m_data->get_data('dhmd')->num_rows(); } if (in_array("kaprodi",$_SESSION['role'])){ $nidu = $_SESSION['username']; $this->db->where('nidu', $nidu); $data['dhmd'] = $this->db->get('dhmd')->num_rows(); $this->db->where('nidu', $nidu); $this->db->where('status', '1'); $data['valid'] = $this->db->get('dhmd')->num_rows(); $data['nonvalid'] = $data['dhmd'] - $data['valid']; } $this->load->view('v_dashboard',$data); } // fungsi edit profile coba disatukan untuk seluruh role public function edit_profile() { if ($this->input->post()) { $uname = $this->input->post('username', true); $pw = MD5($this->input->post('old_pw')); $npw = MD5($this->input->post('new_pw')); $cpw = MD5($this->input->post('conf')); if ($npw != $cpw) { $this->session->set_flashdata('flash_error','Konfirmasi Password Salah.'); redirect('dashboard/edit_profile'); } else { $where = array( 'username' => $uname, 'password' => $pw ); $this->load->model('m_login'); $cek = $this->m_login->cek_login('user', $where); if ($cek > 0) { // harus ada pengecekan multi role, yang artinya akunnya akan lebih dari satu // maka dari itu harus mengganti seluruh akunnya if($_SESSION['multiple']){ $value = array( 'password' => $npw ); $this->db->where('username', $_SESSION['username']); $this->db->update('user', $value); }else{ $value = array( 'password' => $npw ); $this->db->where('id', $_SESSION['id']); $this->db->update('user', $value); } $this->session->set_flashdata('flash_success','Password berhasil diperbaharui.'); redirect('dashboard'); } else { $this->session->set_flashdata('flash_error','Password Salah.'); redirect('dashboard/edit_profile'); } } } else { $this->load->view('v_profile'); } } function logout(){ $this->session->sess_destroy(); redirect(base_url().'landing'); } } /* End of file Dashboard.php */ ?>