load->model('m_data'); if(isset($_SESSION['role'])){ if(in_array("wr",$_SESSION['role'])){ $this->db_ = $this->load->database('skpv',TRUE); }else if(in_array("wd",$_SESSION['role'])){ $this->db_ = $this->load->database('skpv',TRUE); }else if(in_array("staff",$_SESSION['role'])){ $this->db_ = $this->load->database('skpv',TRUE); }else if(in_array("spmu",$_SESSION['role'])){ $this->db_ = $this->load->database('skpv',TRUE); }else{ $this->session->set_flashdata('flash_error', 'Silahkan Login Terlebih dahulu.'); redirect('landing','refresh'); } } else { $this->session->set_flashdata('flash_error', 'Silahkan Login Terlebih dahulu.'); redirect('landing','refresh'); } } function get_dhmd(){ $data = $this->m_data->get_data('dhmd'); echo json_encode($data->result()); } function get_dhmd_orderByIDJK(){ $this->db->select('idjk, nidu, nama_dosen, matkul, prodi, fakultas, kdstsemester, COUNT(idjk) as total_jadwal'); $this->db->group_by('idjk, nama_dosen'); $data = $this->db->get('dhmd'); echo json_encode($data->result()); } function get_dhmd_byid(){ $id = $this->input->get('id'); $this->db->where('id', $id); $data = $this->db->get('dhmd'); echo json_encode($data->result()); } function get_dhmd_byAllFilter(){ $fak = $this->input->get('fak'); $this->db->where('fakultas', $fak); $data = $this->db->get('dhmd'); echo json_encode($data->result()); } // function get_totalIDJK_byNiduKdstsm(){ // $this->db->select('COUNT(idjk) as total_idjk'); // $this->db->group_by('nidu, kdstsemester'); // // $this->db->where('nidu', $nidu); // // $this->db->where('kdstsemester', $kdst); // $data = $this->db->get('jadwalkuliah'); // echo json_encode($data->result()); // } //menampilkan view header, index dan footer function index(){ redirect(base_url().'dashboard'); } function dhmd(){ $data['fakultas'] = $this->db_->get('fakultas')->result_array(); $data['prodi'] = $this->db_->get('prodi')->result_array(); if (in_array("wd",$_SESSION['role'])){ $iddosen = $_SESSION['username']; $where = array( 'nidu' => $iddosen ); $data['dosen'] = $this->db_->get_where('v_dosen_cari',$where)->result_array(); } $this->load->view('aio/v_dhmd',$data); } function get_fakultas(){ $nidu = $_SESSION['username']; $this->db_->select('nmfakultas'); $this->db_->where('nidu', $nidu); $prodi = $this->db_->get('v_dosen_cari')->result_array(); echo json_encode($prodi[0]['nmfakultas']); } function get_fakultas_(){ $nidu = $_SESSION['username']; $this->db_->select('nmfakultas'); $this->db_->where('nidu', $nidu); $prodi = $this->db_->get('v_dosen_cari')->result_array(); return $prodi[0]['nmfakultas']; } function get_prodi(){ $fakultas = $this->get_fakultas_(); $this->db_->select('nmfakultas, nmprodi '); $this->db_->where('nmfakultas', $fakultas); $data = $this->db_->get('v_prodi'); echo json_encode($data->result()); } function cetak(){ $fak = urldecode($this->uri->segment(3)); $prod = urldecode($this->uri->segment(4)); $thn = urldecode($this->uri->segment(5)); $bln = urldecode($this->uri->segment(6)); $mg = urldecode($this->uri->segment(7)); $sms = urldecode($this->uri->segment(8)); if($fak != 'null'){ $data['fak'] = 'Fakultas '.substr(urldecode($this->uri->segment(3)), 4); list($f1, $f2) = explode('-',$fak); $this->db->where('fakultas', $f2); } if($prod != 'null'){ $data['prod'] = 'Prodi '.substr(urldecode($this->uri->segment(4)), 5); list($p1, $p2) = explode('-',$prod); $this->db->where('prodi', $p2); } if($sms != 'null'){ if(substr(urldecode($this->uri->segment(8)), 8, 1) == '1') $gg = 'Ganjil'; else if(substr(urldecode($this->uri->segment(8)), 8, 1) == '2') $gg = 'Genap'; $data['sms'] = 'Tahun '.substr(urldecode($this->uri->segment(8)), 4, 4).' Semester '.$gg; list($s1, $s2) = explode('-',$sms); $this->db->where('kdstsemester', $s2); } if($thn != 'null'){ $data['thn'] = substr(urldecode($this->uri->segment(5)), 4, 4); list($t1, $t2) = explode('-',$thn); $this->db->where('YEAR(`created_at`)', $t2); } if($bln != 'null'){ $cekbulan = substr(urldecode($this->uri->segment(6)), 4, 2); switch ($cekbulan) { case '01': $data['bln'] = 'Januari'; break; case '02': $data['bln'] = 'Februari'; break; case '03': $data['bln'] = 'Maret'; break; case '04': $data['bln'] = 'April'; break; case '05': $data['bln'] = 'Mei'; break; case '06': $data['bln'] = 'Juni'; break; case '07': $data['bln'] = 'Juli'; break; case '08': $data['bln'] = 'Agustus'; break; case '09': $data['bln'] = 'September'; break; case '10': $data['bln'] = 'Oktober'; break; case '11': $data['bln'] = 'November'; break; case '12': $data['bln'] = 'Desember'; break; default: $data['bln'] = 'error'; break; } list($b1, $b2) = explode('-',$bln); $this->db->where('MONTH(`created_at`)', $b2); } if($mg != 'null'){ $data['mg'] = substr(urldecode($this->uri->segment(7)), 3, 1); list($m1, $m2) = explode('-',$mg); if($m2 == '1'){ $day1 = 1; $day2 = 7; }else if($m2 == '2'){ $day1 = 8; $day2 = 14; }else if($m2 == '3'){ $day1 = 15; $day2 = 21; }else if($m2 == '4'){ $day1 = 22; $day2 = 31; } $this->db->where('DAY(`created_at`) >=', $day1); $this->db->where('DAY(`created_at`) <=', $day2); } $data['dhmd'] = $this->db->get('dhmd')->result_array(); $this->load->view('aio/cetak',$data); } function logout(){ $this->session->sess_destroy(); redirect(base_url().'landing'); } 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('aio/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) { $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('aio/edit_profile'); } else { $this->session->set_flashdata('flash_error','Password Salah.'); redirect('aio/edit_profile'); } } } else { $this->load->view('v_profile'); } } } /* End of file Dosen.php */ ?>