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(); set_time_limit(0); } function _get_token(){ $token = $this->proxy->GetToken($this->username, $this->password); return $token; } function get_mhs_feeder($nim = '') { $token = $this->_get_token(); $filter = "nisn ilike ='%".$nim."%'"; $GetRecord = $this->proxy->GetRecord($token, 'mahasiswa', $filter); echo json_encode($GetRecord); } function get_semester() { $token = $this->_get_token(); $GetRecordset = $this->proxy->GetRecordset($token, 'semester', '', '',1000, 0); $GetRecordset['total'] = count($GetRecordset['result']); echo json_encode($GetRecordset); } function upload_excel() { $fileName = $_FILES['excelmahasiswa']['name']; $tmpName = $_FILES['excelmahasiswa']['tmp_name']; $fileSize = $_FILES['excelmahasiswa']['size']; $fileType = $_FILES['excelmahasiswa']['type']; if (strpos($fileName,'.xls') !== false) { $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); fclose($fp); $return_data = array(); $rows = explode("\n", $content); //split whole data to row array $token = $this->_get_token(); foreach($rows as $idx => $row) { if($idx == 0) continue; //skip the header $fields = explode("\t", $row); //split row to field data /* data $fields [0] => Nama mahasiswa [1] => JK [2] => NISN [3] => NIM [4] => NIK [5] => Kode Prodi [6] => Jenis Pendaftar [7] => Tanggal Masuk [8] => Smt. Awal Sbg. Mahasiswa [9] => Tempat lahir [10] => tgl lahir [11] => agama [12] => kelurahan [13] => nama ibu [14] => nama ayah [15] => kode pos [16] => status mahasiswa [17] => penerima kps [18] => email [19] => telepon rumah [20] => telepon seluler [21] => Pernah TK [22] => Pernah PAUD */ if(!isset($fields[22])) continue; $a_pernah_paud = str_replace("\r", '', $fields[22]); if(!empty($fields[0])){ $nim = str_replace("'", "", $fields[3]); //check if nim already in feeder $check_nim = $this->proxy->GetRecord($token, 'mahasiswa_pt', "'".$nim."' = trim(both ' ' from nipd)"); if(isset($check_nim['result']) && !empty($check_nim['result'])){ $already_in_feeder = 1; $id_reg_pd = $check_nim['result']['id_reg_pd']; $id_pd = $check_nim['result']['id_pd']; }else{ $already_in_feeder = 0; $id_reg_pd = ''; $id_pd = ''; } $rowdata = array( 'already_in_feeder' => $already_in_feeder, 'id_reg_pd' => $id_reg_pd, 'id_pd' => $id_pd, 'nm_pd' => strtoupper($fields[0]), 'jk' => $fields[1], 'nisn' => str_replace("'", "", $fields[2]), 'nim' => $nim, 'nik' => str_replace("'", "", $fields[4]), 'kdprodi' => str_replace("'", "", $fields[5]), 'id_jns_daftar' => $fields[6], 'tgl_masuk_sp' => str_replace("'", "", $fields[7]), 'mulai_smt' => $fields[8], 'tmpt_lahir' => $fields[9], 'tgl_lahir' => str_replace("'", "", $fields[10]), 'id_agama' => $fields[11], 'ds_kel' => $fields[12], 'nm_ibu_kandung' => strtoupper($fields[13]), 'nm_ayah' => strtoupper($fields[14]), 'kode_pos' => $fields[15], 'stat_pd' => $fields[16], 'a_terima_kps' => $fields[17], 'email' => $fields[18], 'telepon_rumah' => str_replace("'", "", $fields[19]), 'telepon_seluler' => str_replace("'", '', $fields[20]), 'a_pernah_tk' => (!empty($fields[21])) ? $fields[21] : 0, 'a_pernah_paud' => (!empty($a_pernah_paud)) ? $a_pernah_paud : 0, ); $return_data[] = $rowdata; } } $return = array( 'success' => true, 'message' => 'data berhasil di export', 'data' => $return_data, ); echo json_encode($return); die; } else { $return = array( 'success' => false, 'message' => 'sistem hanya menerima file berekstensi .xls', 'data' => array(), ); echo json_encode($return); die; } } function export_to_feeder() { $data = $this->input->post('json_mahasiswa'); if(empty($data)){ $return = array( 'success' => false, 'message' => 'data yang dimasukkan kosong', ); echo json_encode($return); die; } $data = json_decode($data); //get id satuan pendidikan $token = $this->_get_token(); $nama_pt = 'Universitas Langlang Buana'; $sp = $this->proxy->GetRecord($token, 'satuan_pendidikan', "nm_lemb ilike '%{$nama_pt}%'"); $success_all = true; $errors = array(); foreach($data as $idx => $dt){ $dt_mhs = (array) $dt; $nim = $dt_mhs['nim']; $kdprodi = $dt_mhs['kdprodi']; $id_jns_daftar = $dt_mhs['id_jns_daftar']; $tgl_masuk_sp = $dt_mhs['tgl_masuk_sp']; $mulai_smt = $dt_mhs['mulai_smt']; $a_pernah_tk = $dt_mhs['a_pernah_tk']; $a_pernah_paud = $dt_mhs['a_pernah_paud']; unset($dt_mhs['nim']); unset($dt_mhs['kdprodi']); unset($dt_mhs['id_jns_daftar']); unset($dt_mhs['tgl_masuk_sp']); unset($dt_mhs['mulai_smt']); unset($dt_mhs['a_pernah_tk']); unset($dt_mhs['a_pernah_paud']); //if already in feeder, update if($dt_mhs['already_in_feeder']){ $id_pd = $dt_mhs['id_pd']; unset($dt_mhs['already_in_feeder']); unset($dt_mhs['id_reg_pd']); unset($dt_mhs['id_pd']); $dt_mhs['id_kk']= 0; $dt_mhs['id_wil']= 999999; $dt_mhs['id_kebutuhan_khusus_ayah']= 0; $dt_mhs['id_kebutuhan_khusus_ibu']= 0; $dt_mhs['kewarganegaraan']= 'ID'; $dt_mhs['id_sp']= $sp['result']['id_sp']; //badan hukum $update = array( 'key' => array('id_pd' => $id_pd), 'data' => $dt_mhs, ); $updated_mahasiswa = $this->proxy->UpdateRecord($token, 'mahasiswa', json_encode($update)); if(isset($updated_mahasiswa['result']['error_desc']) && !empty($updated_mahasiswa['result']['error_desc'])){ $success_all = false; $errors[] = $updated_mahasiswa['result']['error_desc']; } }else{ //insert unset($dt_mhs['already_in_feeder']); unset($dt_mhs['id_reg_pd']); unset($dt_mhs['id_pd']); $dt_mhs['id_kk']= 0; $dt_mhs['id_wil']= 999999; $dt_mhs['id_kebutuhan_khusus_ayah']= 0; $dt_mhs['id_kebutuhan_khusus_ibu']= 0; $dt_mhs['kewarganegaraan']= 'ID'; $dt_mhs['id_sp']= $sp['result']['id_sp']; //badan hukum $inserted_mahasiswa = $this->proxy->InsertRecord($token, 'mahasiswa', json_encode($dt_mhs)); if(!isset($inserted_mahasiswa['result']['id_pd'])){ $success_all = false; $errors[] = $inserted_mahasiswa['result']['error_desc']; }else{ $id_pd = $inserted_mahasiswa['result']['id_pd']; //get sms (prodi) $sms = $this->proxy->GetRecord($token, 'sms', "kode_prodi = '".$kdprodi."' AND p.id_sp = '".$this->id_sp."'"); if(isset($sms['result']['id_sms']) && !empty($sms['result']['id_sms'])){ //add mahasiswa pt $dtmahasiswa_pt = array(); $dtmahasiswa_pt['nipd'] = $nim; $dtmahasiswa_pt['id_pd'] = $id_pd; $dtmahasiswa_pt['id_sp'] = $sp['result']['id_sp']; $dtmahasiswa_pt['id_sms'] = $sms['result']['id_sms']; $dtmahasiswa_pt['id_jns_daftar'] = $id_jns_daftar; $dtmahasiswa_pt['tgl_masuk_sp'] = $tgl_masuk_sp; $dtmahasiswa_pt['mulai_smt'] = $mulai_smt; $dtmahasiswa_pt['a_pernah_tk'] = $a_pernah_tk; $dtmahasiswa_pt['a_pernah_paud'] = $a_pernah_paud; $inserted_mahasiswa_pt = $this->proxy->InsertRecord($token, 'mahasiswa_pt', json_encode($dtmahasiswa_pt)); } } } } $message = ""; if(!empty($errors)){ $message .= "Terjadi kesalahan :
"; foreach($errors as $idx => $error) { $message .= ($idx+1).'. '.$error.'
'; } } $return = array( 'success' => $success_all, 'message' => $message, ); echo json_encode($return); die; } function update_mahasiswa() { $nim = 'L230150008'; $id_reg_pd = '3d672471-1f3a-4b1f-9b3d-5df1225aa937'; $id_sms = 'a4265a05-5dcf-4de3-aab5-ee816a378ad0'; //ilmu pemerintahan s2 $token = $this->_get_token(); $update = array( 'key' => array('id_reg_pd' => $id_reg_pd), 'data' => array('id_sms' => $id_sms), ); $updated_mahasiswa = $this->proxy->UpdateRecord($token, 'mahasiswa_pt', json_encode($update)); print_r($updated_mahasiswa); } } ?>