load->model('m_data'); if($_SESSION['status'] == "staff_login"){ // $this->API="http://localhost/rest_unla/api"; // $this->load->library('curl'); $this->db2_ = $this->load->database('skpv',TRUE); }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 index(){ $this->load->view('staff/v_dashboard'); } 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('staff/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('staff/edit_profile'); } else { $this->session->set_flashdata('flash_error','Password Salah.'); redirect('staff/edit_profile'); } } } else { $this->load->view('v_profile'); } } // ====================================== START FUNGSI MBKM =================================================== function mbkm(){ if($this->input->post()){ $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); if($this->kdmk_exists($this->input->post('kdmk',true))){ $this->session->set_flashdata('flash_error','Mata Kuliah tersebut sudah terdaftar sebagai Mata Kuliah MBKM.'); }else{ $dosen = $this->input->post('pilih-dosen',true); $email = $this->input->post('email',true); $ndnm = explode('-',$dosen); if (empty($dosen)) { $data = array( 'kdprodi' => $this->input->post('kdprodi',true), 'kdmk' => $this->input->post('kdmk',true), 'nmmkind' => $this->input->post('nmmkind',true), 'sks' => $this->input->post('sks',true), 'nidu' => $ndnm[0], 'nmdosdgngelar' => 'Belum Ada', 'email_dosen' => 'Belum Ada', 'keterangan' => $this->input->post('ket',true), 'cpl' => $this->input->post('cpl',true), 'created_at' => $time, 'created_by' => $_SESSION['status_lvl'].'-'.$_SESSION['sub_lvl'], ); $this->m_data->insert_data('mk_mbkm',$data); $this->session->set_flashdata('flash_success',' matkul MBKM sudah ditambahkan (Settings kembali Dosen dan Email dikarenakan masih kosong pada form edit)'); }elseif (empty($email)) { $this->session->set_flashdata('flash_error',' . Apabila input nama dosen, harus menyertakan email untuk mengirim detail user login.'); }else{ // fungsi mengirim email ke email dosen // $this->load->library('email'); // $to = $this->input->post('email',true); // $subject = 'Akses Dosen MBKM Unla'; // $pesan = 'Kepada Yth, Bapak/Ibu '.$ndnm[1].'.

Anda telah didaftarkan oleh pihak Administrasi MBKM Universitas Langlangbuana sebagai Dosen MBKM untuk Mata Kuliah '.$this->input->post('nmmkind',true).'.
Silahkan gunakan akun berikut untuk login ke dalam Website MBKM Unla sebagai Dosen.

Id: '.$ndnm[0].'
Password: '.$ndnm[0].'**

Terima Kasih.'; // $config = array(); // $config['charset'] = 'utf-8'; // $config['useragent'] = 'Codeigniter'; // $config['protocol']= "smtp"; // $config['mailtype']= "html"; // $config['smtp_host']= "ssl://smtp.googlemail.com"; // $config['smtp_port']= "465"; // $config['smtp_timeout']= "400"; // $config['smtp_user']= "mbkmunla01@gmail.com"; // $config['smtp_pass']= "Mbkm2021Unla"; // $config['crlf']="\r\n"; // $config['newline']="\r\n"; // $config['wordwrap'] = TRUE; // $this->email->initialize($config); //end config // $this->email->from('mbkmunla01@gmail.com'); // $this->email->to($to); // $this->email->subject($subject); // $this->email->message($pesan); // if($this->email->send()){ //apabila email sudah terkirim //masukkan mata kuliah ke dalam tabel mk_mbkm $data = array( 'kdprodi' => $this->input->post('kdprodi',true), 'kdmk' => $this->input->post('kdmk',true), 'nmmkind' => $this->input->post('nmmkind',true), 'sks' => $this->input->post('sks',true), 'nidu' => $ndnm[0], 'nmdosdgngelar' => $ndnm[1], 'email_dosen' => $this->input->post('email',true), 'keterangan' => $this->input->post('ket',true), 'cpl' => $this->input->post('cpl',true), 'created_at' => $time, 'created_by' => $_SESSION['status_lvl'].'-'.$_SESSION['sub_lvl'], ); $this->m_data->insert_data('mk_mbkm',$data); // cek apakah nidu dosen sudah terdaftar sebagai user if($this->nidu_exists($ndnm[0])){ //apabila nidu dosen sudah terdaftar sebagai user //tidak ada inputan ke dalam data user $this->session->set_flashdata('flash_success',' ditambahkan dan email telah dikirim. Akun dosen sudah terdaftar'); }else{ //apabila nidu dosen belum terdaftar //masukkan nidu ke dalam data user $sub = $this->input->post('kdprodi',true); $data = array( 'username' => $ndnm[0], 'password' => MD5($ndnm[0].'**'), 'status' => 'dosen', 'sub_lvl' => $sub, 'created_at' => $time ); $this->db->insert('user', $data); $this->session->set_flashdata('flash_success',' ditambahkan dan email telah dikirim. Akun dosen sudah ditambahkan dengan akun Id: '.$ndnm[0].' dan Password: '.$ndnm[0].'** Terima Kasih.'); } // }else{ // $this->session->set_flashdata('flash_error',show_error($this->email->print_debugger())); // } } } redirect('staff/mbkm'); } // $data['matkul'] = json_decode($this->curl->simple_get($this->API.'/sincData/sk/s_'.$table))->data; $data['tes'] = 'tes'; $this->load->view('staff/v_mbkm',$data); } function get_sks() { $db_ = $this->db2_; $where = $this->input->get('kdmk',TRUE); $db_->select('idkurikulum, kdmk, jmlsks'); $db_->where('kdmk', $where); $data = $db_->get('kurikulum'); echo json_encode($data->result()); } function get_dosen() { $db_ = $this->db2_; $where = $this->input->get('kdprodi',TRUE); $db_->select('kdprodi, nidu, nmdostpgelar, nmdosdgngelar'); $db_->where('kdprodi', $where); $db_->order_by('nmdostpgelar','asc'); $data = $db_->get('dosen'); echo json_encode($data->result()); } function tampil_mk() { $db_ = $this->db2_; // $db_->distinct(); $where = $this->input->get('kdprodi',TRUE); $data = $db_->query('SELECT kdprodi,kdmk, nmmkind, MAX(thnmasuk) as tahun FROM (SELECT a.kdprodi,a.kdmk, a.nmmkind, b.thnmasuk FROM v_matakuliah AS a JOIN kurikulum AS b ON a.kdmk = b.kdmk WHERE a.kdprodi = '.$where.' ORDER BY a.kdmk, a.nmmkind, b.thnmasuk ASC) AS tbl_a GROUP BY kdmk,nmmkind ORDER BY nmmkind ASC '); echo json_encode($data->result()); } function nidu_exists($nidu) { $this->db->where('username',$nidu); $query = $this->db->get('user'); if ($query->num_rows() > 0){ return true; } else{ return false; } } function kdmk_exists($kdmk) { $this->db->where('kdmk',$kdmk); $query = $this->db->get('mk_mbkm'); if ($query->num_rows() > 0){ return true; } else{ return false; } } function get_mbkm_byKdprodi($kdprodi = NULL){ $this->db->where('kdprodi', $kdprodi); $this->db->order_by('nmmkind', 'asc'); $data = $this->db->get('mk_mbkm'); echo json_encode($data->result()); } function get_mbkm_byKDMK(){ $kdmk=$this->input->get('kdmk'); $where = array( 'kdmk' => $kdmk ); $hsl=$this->m_data->cek_where('mk_mbkm',$where); if($hsl->num_rows()>0){ foreach ($hsl->result() as $i) { $data = array( 'kdmk' => $i->kdmk, 'kdprodi' => $i->kdprodi, 'nmmkind' => $i->nmmkind, 'sks' => $i->sks, 'dosen' => $i->nmdosdgngelar, 'nidu' => $i->nidu, 'email' => $i->email_dosen, 'keterangan' => $i->keterangan, 'cpl' => $i->cpl ); } } echo json_encode($data); } function delete_data($kdmk = NULL){ $where = array( 'kdmk' => $kdmk ); $this->m_data->delete_data('mk_mbkm',$where); $this->session->set_flashdata('flash_success','dihapus.'); redirect('staff/mbkm'); } function edit_data($id = NULL) { if ($this->input->post() ) { $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', '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/edit_userapproval'); } redirect('admin/userapproval'); } function delete_user($id = NULL) { $this->db->where('id', $id); $this->db->delete('user'); $this->session->set_flashdata('flash_success','dihapus.'); redirect('admin/user'); } // ====================================== END FUNGSI MBKM =================================================== function get_mahasiswa(){ $data = $this->m_data->get_data('mahasiswa_mbkm_luar'); echo json_encode($data->result()); } function get_mahasiswa_byid(){ $id = $this->input->get('idmhs'); $this->db->where('idmhs', $id); $data = $this->db->get('mahasiswa_mbkm_luar'); echo json_encode($data->result()); } function get_mhs() { $idmhs=$this->input->get('idmhs'); $where = array( 'idmhs' => $idmhs ); $hsl=$this->m_data->cek_where('mahasiswa_mbkm_luar',$where); if($hsl->num_rows()>0){ foreach ($hsl->result() as $i) { $data = array( 'idmhs' => $i->idmhs, 'npm' => $i->npm, 'nmmhs' => $i->nmmhs, 'jnskelamin' => $i->jnskelamin, 'stsemester' => $i->stsemester, 'universitas' => $i->universitas, 'fakultas' => $i->fakultas, 'prodi' => $i->prodi, 'thnmasuk' => $i->thnmasuk, 'status' => $i->status, 'created_at' => $i->created_at, 'updated_at' => $i->updated_at, 'input_by' => $i->input_by ); } } echo json_encode($data); } // ====================================== START FUNGSI APPROVAL MBKM =================================================== function app_mbkm(){ $this->db->where('status', '1'); $data['stsemester'] = $this->db->get('stsemester')->result_array(); $this->load->view('staff/v_app_mbkm',$data); } function get_appmbkm_byKdprodi($kdprodi = NULL){ $kdprodi_=urldecode($kdprodi); $this->db->where('kdprodi', $kdprodi_); $this->db->order_by('waktu_pengajuan', 'asc'); $data = $this->db->get('pengajuan_mbkm'); echo json_encode($data->result()); } function get_appmbkm_byKdmk($kdmk = NULL){ $this->db->where('kdmk', $kdmk); $this->db->order_by('waktu_pengajuan', 'asc'); $data = $this->db->get('pengajuan_mbkm'); echo json_encode($data->result()); } function get_appmbkm_byId($id = NULL){ $where = array( 'id' => $id ); $data = $this->m_data->getwhere_data('pengajuan_mbkm',$where); echo json_encode($data->result()); } function validasi_byid($param = NULL){ $konversi = $this->input->post('konversi',true); $this->db->where('id', $param); $update = array( 'status' => $this->input->post('status',true), 'konversi' => $konversi ); $this->db->update('pengajuan_mbkm', $update); // Pengecekan apabila statusnya di acc maka nama dan nim mahasiswa dimasukkan ke dalam tabel nilai if($this->input->post('status',true) == 'acc'){ $idmhs = $this->input->post('up_idmhs',true); $exp = explode("-",$idmhs); $status = ''; $nama = ''; $nim = ''; if($exp[0] == 'ext'){ $status = 'inbound-'.$exp[3]; $nama = $exp[1]; $nim = $exp[2]; }else{ $status = 'internal'; $nama = $exp[0]; $nim = $exp[1]; } $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $dtnilai = array( 'nim_mhs' => $nim, 'nama_mhs' => $nama, 'kdmk' => $this->input->post('up_kdmk',true), 'stsemester' => $this->input->post('up_stsemester',true), 'nilai_kehadiran' => 0, 'tugas' => 0, 'quiz' => 0, 'uts' => 0, 'uas' => 0, 'total_nilai' => 0, 'nilai_huruf' => 'T', 'status' => $status, 'created_at' => $time ); $this->db->insert('nilai_mbkm', $dtnilai); } $this->session->set_flashdata('flash_success', 'Status Mata Kuliah MBKM telah diperbaharui.'); redirect('staff/app_mbkm'); } // ====================================== END FUNGSI APPROVAL MBKM ============================================================== // ====================================== START FUNGSI MAHASISWA =================================================== 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), 'email' => $this->input->post('email',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('staff/mhs'); }else{ $this->load->view('staff/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); $update = array( 'status' => 'tervalidasi', 'updated_at' => $time ); $insert = array( 'username' => $this->input->post('npm2'), 'password' => MD5($this->input->post('npm2')), 'status' => 'mahasiswa', 'sub_lvl' => '01-'.$this->input->post('universitas2'), 'created_at' => $time ); $where = array( 'idmhs' => $idmhs ); $this->db->insert('user', $insert); $this->m_data->update_data($where,$update,'mahasiswa_mbkm_luar'); $this->session->set_flashdata('flash_success', 'Data User Telah Diperbaharui.'); redirect('staff/mhs'); } } function edit_mkmbkm($kdmk = NULL) { if ($this->input->post() ) { $this->load->helper('date'); $waktu = time(); $time = mdate('%Y-%m-%d %H:%i:%s', $waktu); $dosen = $this->input->post('pilih-dosen-edit',true); $email = $this->input->post('email-edit',true); $ndnm = explode('-',$dosen); if (empty($dosen)) { $update = array( 'nidu' => 'Belum Ada', 'nmdosdgngelar' => 'Belum Ada', 'email_dosen' => 'Belum Ada', 'keterangan' => $this->input->post('ket-edit'), 'cpl' => $this->input->post('cpl-edit'), ); $where = array( 'kdmk' => $kdmk ); $this->m_data->update_data($where,$update,'mk_mbkm'); $this->session->set_flashdata('flash_success',' matkul MBKM sudah dirubah (Settings kembali Dosen dan Email dikarenakan masih kosong pada form edit)'); }elseif (empty($email)) { $this->session->set_flashdata('flash_error',' . Apabila input nama dosen, harus menyertakan email untuk mengirim detail user login.'); }else{ $this->load->library('email'); $to = $this->input->post('email-edit',true); $subject = 'Akses Dosen MBKM Unla'; $pesan = 'Kepada Yth, Bapak/Ibu '.$ndnm[1].'.

Anda telah didaftarkan oleh pihak Administrasi MBKM Universitas Langlangbuana sebagai Dosen MBKM untuk Mata Kuliah '.$this->input->post('nmmkind',true).'.
Silahkan gunakan akun berikut untuk login ke dalam Website MBKM Unla sebagai Dosen.

Id: '.$ndnm[0].'
Password: '.$ndnm[0].'**

Terima Kasih.'; $config = array(); $config['charset'] = 'utf-8'; $config['useragent'] = 'Codeigniter'; $config['protocol']= "smtp"; $config['mailtype']= "html"; $config['smtp_host']= "ssl://smtp.googlemail.com"; $config['smtp_port']= "465"; $config['smtp_timeout']= "400"; $config['smtp_user']= "mbkmunla01@gmail.com"; $config['smtp_pass']= "Mbkm2021Unla"; $config['crlf']="\r\n"; $config['newline']="\r\n"; $config['wordwrap'] = TRUE; $this->email->initialize($config); //end config $this->email->from('mbkmunla01@gmail.com'); $this->email->to($to); $this->email->subject($subject); $this->email->message($pesan); if($this->email->send()){ //apabila email sudah terkirim //update mata kuliah ke dalam tabel mk_mbkm $update = array( 'nidu' => $ndnm[0], 'nmdosdgngelar' => $ndnm[1], 'email_dosen' => $this->input->post('email-edit',true), 'keterangan' => $this->input->post('ket-edit'), 'cpl' => $this->input->post('cpl-edit'), 'created_at' => $time ); $where = array( 'kdmk' => $kdmk ); $this->m_data->update_data($where,$update,'mk_mbkm'); // cek apakah nidu dosen sudah terdaftar sebagai user if($this->nidu_exists($ndnm[0])){ //apabila nidu dosen sudah terdaftar sebagai user //tidak ada inputan ke dalam data user $this->session->set_flashdata('flash_success',' diperbarui dan email telah dikirim. Akun dosen sudah terdaftar'); }else{ //apabila nidu dosen belum terdaftar //masukkan nidu ke dalam data user $sub = $this->input->post('kdprodi-edit',true); $data = array( 'username' => $ndnm[0], 'password' => MD5($ndnm[0].'**'), 'status' => 'dosen', 'sub_lvl' => $sub, 'created_at' => $time ); $this->db->insert('user', $data); $this->session->set_flashdata('flash_success',' ditambahkan dan email telah dikirim. Akun dosen sudah ditambahkan'); } }else{ $this->session->set_flashdata('flash_error',show_error($this->email->print_debugger())); } } redirect('staff/mbkm'); } } // ====================================== END FUNGSI MAHASISWA ============================================================== // ====================================== START FUNGSI LIST MAHASISWA =================================================== function list_mhs(){ $this->load->view('staff/v_list_mhs'); } function get_mhs_nilai(){ $this->db->select('a.*, b.kdprodi, b.nmmkind, c.tahun, c. semester'); $this->db->from('nilai_mbkm as a'); $this->db->join('mk_mbkm as b', 'a.kdmk = b.kdmk', 'left'); $this->db->join('stsemester as c', 'a.stsemester = c.kdstsemester', 'left'); $data = $this->db->get(); echo json_encode($data->result()); } // ====================================== END FUNGSI LIST MAHASISWA ============================================================== function cetak(){ $this->load->view('staff/cetak'); } function logout(){ $this->session->sess_destroy(); redirect(base_url().'landing'); } } /* End of file Staff.php */ ?>