load->library('session'); $this->load->library('rhlib'); require_once(APPPATH.'libraries/nusoap/nusoap.php'); //includes nusoap require_once(APPPATH.'libraries/nusoap/class.wsdlcache.php'); //includes nusoap $this->client = new nusoap_client($this->url, true); $this->proxy = $this->client->getProxy(); } function _get_token(){ $token = $this->proxy->GetToken($this->username, $this->password); return $token; } function get_mahasiswa_double() { $query = "SELECT nama, tpt_lahir, tgl_lahir, count(*) as duplikat FROM mahasiswa_feeder_temp GROUP BY nama, tpt_lahir, tgl_lahir HAVING duplikat > 1"; $get = $this->db->query($query); $data = $get->result(); $total = $get->num_rows(); $return = array( 'success' => true, 'data' => $data, 'results' => $total, ); echo json_encode($return); die; } function get_double() { $token = $this->_get_token(); $nama = $this->input->post('nama'); $tpt_lahir = $this->input->post('tpt_lahir'); $tgl_lahir = $this->input->post('tgl_lahir'); $get = $this->db->get_where('mahasiswa_feeder_temp', array('nama' => $nama, 'tpt_lahir' => $tpt_lahir, 'tgl_lahir' => $tgl_lahir)); $data = $get->result(); foreach($data as $idx => $dt){ $filter = "nm_pd ilike '".$dt->nama."'"; $GetRecord = $this->proxy->GetRecordSet($token, 'mahasiswa_pt', $filter, '', 1000, 0); if(isset($GetRecord['result']) && !empty($GetRecord['result'])) { foreach($GetRecord['result'] as $result) { if($result['id_pd'] == $dt->id_pd) { $data[$idx]->id_reg_pd = $result['id_reg_pd']; $data[$idx]->nipd = $result['nipd']; $data[$idx]->id_pd = $result['id_pd']; $data[$idx]->nm_pd = $result['nm_pd']; $data[$idx]->tgl_lahir = $result['tgl_lahir']; $data[$idx]->id_sms = $result['id_sms']; $data[$idx]->fk__sms = $result['fk__sms']; $data[$idx]->id_sp = $result['id_sp']; $data[$idx]->fk__sp = $result['fk__sp']; $data[$idx]->tgl_masuk_sp = $result['tgl_masuk_sp']; $data[$idx]->id_jns_daftar = $result['id_jns_daftar']; $data[$idx]->fk__jns_daftar = $result['fk__jns_daftar']; $data[$idx]->fk__jns_keluar = (!empty($result['fk__jns_keluar'])) ? $result['fk__jns_keluar'] : "Aktif"; } } } } $total = $get->num_rows(); $return = array( 'success' => true, 'data' => $data, 'results' => $total, ); echo json_encode($return); die; } function delete_mahasiswa() { $id_pd = $this->input->post('id_pd'); $id_reg_pd = $this->input->post('id_reg_pd'); $nama = $this->input->post('nama'); if(empty($id_pd) || empty($id_reg_pd) || empty($nama)){ echo json_encode(array('success' => false, 'message' => 'Terjadih kesalahan. Gagal menghapus data'));die; } $token = $this->_get_token(); $filter_pd = array('id_pd' => $id_pd); $filter_regpd = array('id_reg_pd' => $id_reg_pd); $delete_nilai_transfer = $this->_delete_nilai_transfer($id_reg_pd, $nama); $delete_nilai = $this->_delete_nilai($id_reg_pd, $nama); $delete_kuliah_mahasiswa = $this->_delete_kuliah_mahasiswa($id_reg_pd); if(!$delete_kuliah_mahasiswa){ echo json_encode(array('success' => false, 'message' => 'Terjadih kesalahan. Gagal menghapus data kuliah mahasiswa'));exit; } if(!$delete_nilai){ echo json_encode(array('success' => false, 'message' => 'Terjadih kesalahan. Gagal menghapus data nilai mahasiswa'));exit; } if(!$delete_nilai_transfer){ echo json_encode(array('success' => false, 'message' => 'Terjadih kesalahan. Gagal menghapus data nilai transfer mahasiswa'));exit; } //hapus mahasiswa_pt $delete_mahasiswa_pt = $this->proxy->DeleteRecord($token, 'mahasiswa_pt', json_encode($filter_pd)); if(!empty($delete_mahasiswa_pt['result']['error_desc'])) { echo json_encode(array('success' => false, 'message' => 'Terjadih kesalahan. gagal menghapus mahasiswa pt.'.$delete_mahasiswa_pt['result']['error_desc']));exit; } //hapus mahasiswa $delete_mahasiswa = $this->proxy->DeleteRecord($token, 'mahasiswa', json_encode($filter_pd)); if(!empty($delete_mahasiswa['result']['error_desc'])) { echo json_encode(array('success' => false, 'message' => 'Terjadih kesalahan. '.$delete_mahasiswa['result']['error_desc']));exit; }else{ $this->db->delete('mahasiswa_feeder_temp', $filter_pd); echo json_encode(array('success' => true, 'message' => 'Berhasil menghapus data'));die; } } function _delete_kuliah_mahasiswa($id_reg_pd) { $token = $this->_get_token(); $filter = "id_reg_pd = '{$id_reg_pd}'"; $GetRecordset_kuliah_mahasiswa = $this->proxy->GetRecordset($token, 'kuliah_mahasiswa', $filter, '',1000, 0); if(!empty($GetRecordset_kuliah_mahasiswa['result'])) { //build filter array $conditions = array(); foreach($GetRecordset_kuliah_mahasiswa['result'] as $kuliah_mhs) { $condition = array( 'id_smt' => $kuliah_mhs['id_smt'], 'id_reg_pd' => $id_reg_pd, ); $conditions[] = $condition; } $delete_kuliah_mahasiswa = $this->proxy->DeleteRecordset($token, 'kuliah_mahasiswa', json_encode($conditions)); if(empty($delete_kuliah_mahasiswa['error_desc'])) return true; else return false; }else{ return true; } } function _delete_nilai($id_reg_pd, $nama) { $token = $this->_get_token(); //$filter = "id_reg_pd = '{$id_reg_pd}'"; $filter = "nm_pd = '{$nama}'"; $GetRecordset_nilai = $this->proxy->GetRecordset($token, 'nilai', $filter, '',1000, 0); if(!empty($GetRecordset_nilai['result'])) { //build filter array $conditions = array(); foreach($GetRecordset_nilai['result'] as $nilai) { if($nilai['id_reg_pd'] == $id_reg_pd){ $condition = array( 'id_kls' => $nilai['id_kls'], 'id_reg_pd' => $nilai['id_reg_pd'], //'asal_data' => $nilai['asal_data'], //'nilai_angka' => $nilai['nilai_angka'], //'nilai_huruf' => $nilai['nilai_huruf'], //'nilai_indeks' => $nilai['nilai_indeks'], ); $conditions[] = $condition; } } $delete_nilai = $this->proxy->DeleteRecordset($token, 'nilai', json_encode($conditions)); if(empty($delete_nilai['error_desc'])) return true; else return false; }else{ return true; } } function _delete_nilai_transfer($id_reg_pd, $nama) { $token = $this->_get_token(); //$filter = "id_reg_pd = '{$id_reg_pd}'"; $filter = "nm_pd = '{$nama}'"; $GetRecordset_nilai_transfer = $this->proxy->GetRecordset($token, 'nilai_transfer', $filter, '',1000, 0); if(!empty($GetRecordset_nilai_transfer['result'])) { //build filter array $conditions = array(); foreach($GetRecordset_nilai_transfer['result'] as $nilai_transfer) { //if id_reg_pd is identic, then add to conditions if($nilai_transfer['id_reg_pd'] == $id_reg_pd){ $condition = array( 'id_ekuivalensi' => $nilai_transfer['id_ekuivalensi'], ); $conditions[] = $condition; } } $delete_nilai_transfer = $this->proxy->DeleteRecordset($token, 'nilai_transfer', json_encode($conditions)); if(empty($delete_nilai_transfer['error_desc'])) return true; else return false; }else{ return true; } } function get_total_mahasiswa() { $token = $this->_get_token(); //check jika ada data di table mahasiswa_feeder_temp, maka muncul error $check = $this->db->get('mahasiswa_feeder_temp')->num_rows(); if($check > 0) { echo json_encode(array('success' => false, 'message' => 'Silahkan hapus data temporary terlebih dahulu sebelum mengimport data mahasiswa'));die; } $CountRecordset = $this->proxy->GetCountRecordset($token, 'mahasiswa', ''); if(!isset($CountRecordset['result'])){ echo json_encode(array('success' => false, 'message' => 'Gagal mengimport data mahasiswa dari feeder'));die; }else{ echo json_encode(array('success' => true, 'message' => 'Berhasil mengimport data mahasiswa dari feeder', 'total_data' => $CountRecordset['result']));die; } } function import_mahasiswa_from_feeder() { $currpage = $this->input->post('curpage'); $mhs_perpage = $this->input->post('mhs_perpage'); $start = ($currpage - 1) * $mhs_perpage; if(empty($currpage) || empty($mhs_perpage)){ echo json_encode(array('success' => false));die; } set_time_limit(0); ini_set('max_execution_time', 10000); $token = $this->_get_token(); $data_mahasiswa = $this->proxy->GetRecordset($token, 'mahasiswa', '', '',$mhs_perpage, $start); if(!empty($data_mahasiswa['result'])) { $insert = ""; foreach($data_mahasiswa['result'] as $idx => $mhs) { $id_pd = mysql_real_escape_string($mhs['id_pd']); $nm_pd = mysql_real_escape_string($mhs['nm_pd']); $tmpt_lahir = mysql_real_escape_string($mhs['tmpt_lahir']); $tgl_lahir = mysql_real_escape_string($mhs['tgl_lahir']); //check if there is duplicate data based on id_pd $check = $this->db->get_where('mahasiswa_feeder_temp', array('id_pd' => $id_pd))->num_rows(); if($check == 0){ $ins = "('".$id_pd."', '".$nm_pd."', '".$tmpt_lahir."', '".$tgl_lahir."')"; if(!empty($insert)) $insert .= ", "; $insert .= $ins; } } if(!empty($insert)){ $this->db->trans_start(); $do_insert = $this->db->query("insert into mahasiswa_feeder_temp (id_pd, nama, tpt_lahir, tgl_lahir) VALUES ".$insert); $this->db->trans_complete(); } echo $currpage;die; } } function truncate_mahasiswa_feeder_temp() { if($this->db->truncate('mahasiswa_feeder_temp')){ echo json_encode(array('success' => true, 'message' => 'Data temporary berhasil dihapus'));die; }else{ echo json_encode(array('success' => false, 'message' => 'Data temporary gagal dihapus'));die; } } } ?>