load->model('m_data'); // cek session yang login, jika session status tidak sama dengan session admin_login,maka halaman akan di alihkan kembali ke halaman login. if($this->session->userdata('status')!="admin_login"){ $this->session->set_flashdata('flash_error', 'Silahkan Login Terlebih dahulu.'); redirect('landing','refresh'); } } //menampilkan view header, index dan footer function index(){ // $data['user'] = $this->m_data->get_data('user')->num_rows(); $data['user'] = $this->m_data->get_data('user')->num_rows(); $this->db->where('nmdosdgngelar !=', 'Belum Ada'); $data['dosen'] = $this->db->get('mk_mbkm')->num_rows(); $data['matkul'] = $this->db->get('mk_mbkm')->num_rows(); $data['mhs'] = '-'; $data['mhs_int'] = $this->db->get('mahasiswa_mbkm_dalam')->num_rows(); $data['mhs_ext'] = $this->db->get('mahasiswa_mbkm_luar')->num_rows(); $data['pengajuan'] = $this->db->get('pengajuan_mbkm')->num_rows(); $this->load->view('admin/v_dashboard',$data); } 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('admin/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('admin/edit_profile'); } else { $this->session->set_flashdata('flash_error','Password Salah.'); redirect('admin/edit_profile'); } } } else { $this->load->view('v_profile'); } } // ============================================ MANAGE DATA MASTER ========================================================== function master_dosen(){ $this->load->view('admin/v_mDosen.php'); } function get_dosen(){ $data = $this->m_data->get_data('dosen'); echo json_encode($data->result()); } function master_matkul(){ $this->load->view('admin/v_mMatkul.php'); } function get_matkul(){ $data= $this->m_data->get_data('matakuliah'); echo json_encode($data->result()); } function master_mahasiswa(){ $this->load->view('admin/v_mMahasiswa.php'); } // function get_mahasiswa(){ // $data = $this->m_data->get_data('mahasiswa'); // echo json_encode($data->result()); // } function v_MatkulDosen(){ $this->load->view('admin/v_matkuldosen.php'); } function get_vmatkuldosen(){ $data = $this->m_data->get_data('v_matkulprodi'); $data = $this->m_data->get_data('v_matkuldosen'); echo json_encode($data->result()); } function v_MatkulProdi(){ $this->load->view('admin/v_matkulprodi.php'); } function get_vmatkulprodi(){ $data = $this->m_data->get_data('v_matkulprodi'); echo json_encode($data->result()); } function v_MatkulSemester(){ $this->load->view('admin/v_matkulsemester.php'); } function get_vmatkulsemester(){ $data = $this->m_data->get_data('v_matkulsmster'); echo json_encode($data->result()); } function getIDdosen_bynidu(){ $nidu = $this->input->get('nidu'); $this->db->select('iddsn'); $this->db->where('nidu', $nidu); $data = $this->db->get('dosen'); echo json_encode($data->result()); } //================================================= CRUD USER ========================================== function user(){ if($this->input->post()){ if($this->input->post('pw') == $this->input->post('conf')){ $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $status = $this->input->post('status',true); $sub; if($status == 'staff') $sub = $this->input->post('substatus_staff',true); else if($status == 'mahasiswa') $sub = $this->input->post('substatus_mhs',true); else if($status == 'staff-mbkm') $sub = 'STAFF-MBKM'; else if($status == 'staff-mbkm-internal') $sub = 'STAFF-MBKM-INTERNAL'; else if($status == 'staff-mbkm-external') $sub = 'STAFF-MBKM-EXTERNAL'; $data = array( 'username' => $this->input->post('username',true), 'password' => MD5($this->input->post('pw')), 'status' => $status, 'sub_lvl' => $sub, 'created_at' => $time ); $this->db->insert('user', $data); $this->session->set_flashdata('flash_success','ditambahkan.'); redirect('admin/user'); }else{ $this->session->set_flashdata('flash_error','Konfirmasi Password salah.'); redirect('admin/user'); } } // $data['user'] = $this->db->get('user'); $this->load->view('admin/v_user.php'); } function userapproval(){ // $data['user'] = $this->db->get('user'); $this->load->view('admin/v_userapproval.php'); } function get_all_user(){ $data = $this->m_data->get_data('user'); echo json_encode($data->result()); } function get_all_userapproval(){ $this->db->order_by('create_at', 'desc'); $data = $this->db->get('admin_luar'); echo json_encode($data->result()); } function get_user() { $id=$this->input->get('id'); $where = array( 'id' => $id ); $hsl=$this->m_data->cek_where('user',$where); if($hsl->num_rows()>0){ foreach ($hsl->result() as $i) { $data = array( 'id' => $i->id, 'username' => $i->username, 'status' => $i->status, 'sub_lvl' => $i->sub_lvl ); } } echo json_encode($data); } function get_userapproval() { $id=$this->input->get('id'); $where = array( 'id' => $id ); $hsl=$this->m_data->cek_where('admin_luar',$where); if($hsl->num_rows()>0){ foreach ($hsl->result() as $i) { $data = array( 'id' => $i->id, 'namadepan' => $i->namadepan, 'namabelakang' => $i->namabelakang, 'email' => $i->email, 'username' => $i->username, 'asaluniv' => $i->asaluniv, 'status' => $i->status ); } } echo json_encode($data); } function approve_user($id = NULL) { if ($this->input->post('ed_pw') == $this->input->post('ed_conf')) { $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $status = $this->input->post('ed_status',true); $sub; if($status == 'staff') $sub = $this->input->post('ed_substatus_staff',true); else if($status == 'mahasiswa') $sub = $this->input->post('ed_substatus_mhs',true); $pw = $this->input->post('ed_pw'); $update; if($pw == null){ $update = array( 'username' => $this->input->post('ed_username'), 'sub_lvl' => $sub, 'updated_at' => $time ); }else{ $update = array( 'username' => $this->input->post('ed_username'), 'password' => MD5($this->input->post('ed_pw')), 'sub_lvl' => $sub, 'updated_at' => $time ); } $where = array( 'id' => $id ); $this->m_data->update_data($where,$update,'user'); }else{ $this->session->set_flashdata('flash_error', 'Konfirmasi Password salah.'); redirect('admin/user'); } $this->session->set_flashdata('flash_success', 'Data User Telah Diperbaharui.'); redirect('admin/user'); } function edit_user($id = NULL) { if ($this->input->post('ed_pw') == $this->input->post('ed_conf')) { $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $status = $this->input->post('ed_status',true); $sub; if($status == 'staff') $sub = $this->input->post('ed_substatus_staff',true); else if($status == 'mahasiswa') $sub = $this->input->post('ed_substatus_mhs',true); $pw = $this->input->post('ed_pw'); $update; if($pw == null){ $update = array( 'username' => $this->input->post('ed_username'), 'sub_lvl' => $sub, 'updated_at' => $time ); }else{ $update = array( 'username' => $this->input->post('ed_username'), 'password' => MD5($this->input->post('ed_pw')), 'sub_lvl' => $sub, 'updated_at' => $time ); } $where = array( 'id' => $id ); $this->m_data->update_data($where,$update,'user'); }else{ $this->session->set_flashdata('flash_error', 'Konfirmasi Password salah.'); redirect('admin/user'); } $this->session->set_flashdata('flash_success', 'Data User Telah Diperbaharui.'); redirect('admin/user'); } function edit_userapproval($id = NULL) { if($this->input->post('status') == 'tervalidasi'){ $this->session->set_flashdata('flash_error', 'Data User Telah Tervalidasi.'); redirect('admin/userapproval'); }else{ $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $update = array( 'status' => 'tervalidasi', 'update_at' => $time ); $insert = array( 'username' => $this->input->post('username'), 'password' => MD5($this->input->post('username')), 'status' => 'staff-ext', 'sub_lvl' => '69-'.$this->input->post('asaluniv'), 'created_at' => $time ); $where = array( 'id' => $id ); $this->db->insert('user', $insert); $this->m_data->update_data($where,$update,'admin_luar'); $this->session->set_flashdata('flash_success', 'Data User Telah Diperbaharui.'); redirect('admin/userapproval'); } } function mhs(){ if($this->input->post()){ $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $data = array( 'npm' => $this->input->post('npm',true), 'nmmhs' => $this->input->post('nama'), 'jnskelamin' => $this->input->post('jnskelamin',true), 'stsemester' => $this->input->post('stsemester',true), 'universitas' => $this->input->post('universitas',true), 'fakultas' => $this->input->post('fakultas',true), 'prodi' => $this->input->post('prodi',true), 'thnmasuk' => $this->input->post('thnmasuk',true), 'status' => 'menunggu', 'created_at' => $time, 'input_by' => $_SESSION['id'] ); $this->db->insert('mahasiswa_mbkm_luar', $data); $this->session->set_flashdata('flash_success',' Mahasiswa ditambahkan.'); redirect('admin/mhs'); }else{ $this->load->view('admin/v_mhs'); } } function edit_mhs($idmhs = NULL) { if ($this->input->post() ) { $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $status = $this->input->post('status2'); if ($status == 'tervalidasi') { $this->session->set_flashdata('flash_error', 'Data sudah tervalidasi sebelumnya.'); redirect('admin/mhs'); }else{ $update = array( 'status' => 'tervalidasi' ); $insert = array( 'username' => $this->input->post('npm2'), 'password' => MD5($this->input->post('npm2')), 'status' => 'mahasiswa', 'sub_lvl' => 'ext-'.$this->input->post('universitas2'), 'created_at' => $time ); $where = array( 'idmhs' => $idmhs ); $this->db->insert('user', $insert); $this->db->where('idmhs', $idmhs); $this->db->update('mahasiswa_mbkm_luar', $update); $this->session->set_flashdata('flash_success', 'Data User Telah Diperbaharui.'); redirect('admin/mhs'); } } } function get_mahasiswa(){ $this->db->order_by('created_at', 'desc'); $data = $this->db->get('mahasiswa_mbkm_luar'); echo json_encode($data->result()); } function get_mhs() { $idmhs=$this->input->get('idmhs'); $where = array( 'idmhs' => $idmhs ); $this->db->where('idmhs', $idmhs); $hsl=$this->db->get('mahasiswa_mbkm_luar',1); echo json_encode($hsl->result()); } function delete_user($id = NULL) { $this->db->where('id', $id); $this->db->delete('user'); $this->session->set_flashdata('flash_success','dihapus.'); redirect('admin/user'); } function delete_userapproval($id = NULL) { $this->db->where('id', $id); $this->db->delete('admin_luar'); $this->session->set_flashdata('flash_success','dihapus.'); redirect('admin/userapproval'); } //================================================== Kelola DHMD ============================================== //================================================== Validasi MBKM ============================================== function sertifikat(){ $this->load->view('admin/v_sertifikat'); } function cetaksertifikat($id){ $this->db->select('a.nim_mhs, a.nama_mhs, a.kdmk, a.total_nilai, a.nilai_huruf, b.nmmkind, c.isi, c.ttd, c.judul, c.tujuan'); $this->db->from('nilai_mbkm as a'); $this->db->join('mk_mbkm as b', 'b.kdmk = a.kdmk', 'left'); $this->db->join('template as c', 'c.isi=c.isi', 'left'); $this->db->where('a.id', $id); $data['data'] = $this->db->get()->result_array(); $this->load->view('admin/cetaksertifikat', $data); } function mbkm(){ $this->load->view('admin/v_mbkm'); } function get_template(){ $data = $this->m_data->get_data('template'); echo json_encode($data->result()); } function get_templatebyid(){ $id = $this->input->get('id'); $this->db->where('id', $id); $data = $this->db->get('template'); echo json_encode($data->result()); } function edit_template($id){ if($this->input->post()){ $data = array( // 'nama_mahasiswa' => $_SESSION['username'], 'judul' => $this->input->post('judul', true), 'tujuan' => $this->input->post('tujuan', true), 'isi' => $this->input->post('isi', true), 'ttd' => $this->input->post('ttd', true) ); $this->db->where('id', $id); $this->db->update('template', $data); $this->session->set_flashdata('flash_success','berhasil.'); redirect('admin/sertifikat'); } } function get_dhmd(){ $data = $this->m_data->get_data('dhmd'); echo json_encode($data->result()); } function logout(){ $this->session->sess_destroy(); redirect(base_url().'landing'); } }