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 insert_kurikulum() { set_time_limit(0); $nmkurikulum = $this->input->post('nmkurikulum'); $prodi = $this->input->post('prodi'); $berlaku = $this->input->post('berlaku'); $jsemester = $this->input->post('jsemester'); $jumlahsks = $this->input->post('jumlahsks'); $jumlahskswajib = $this->input->post('jumlahskswajib'); $jumlahskspilihan = $this->input->post('jumlahskspilihan'); $griddata = $this->input->post('griddata'); $griddata = json_decode($griddata); /* ================================================================== */ /* ======================== insert kurikulum ======================== */ /* ================================================================== */ //get id prodi from feeder $feeder_prodi = $this->GetRecord('sms', "kode_prodi like '".$prodi."' and id_sp = '".$this->id_sp."'"); //mengambil data prodi feeder if(!isset($feeder_prodi['result']) || empty($feeder_prodi['result'])){ $message = array('success' => false, 'message' => 'terjadi kesalahan. kode prodi tidak dikenali'); echo json_encode($message); die; } //get jenjang studi $q_jenjang = "SELECT prodi.kdprodi, prodi.nmprodi, tbkod.nmkodtbkod, tbkod.nmdata FROM prodi LEFT JOIN tbkod ON prodi.kdjenjangstudi = tbkod.kdkodtbkod AND tbkod.kdapltbkod = '04' WHERE kdprodi = '".$prodi."'"; $data_jenjang = $this->db->query($q_jenjang)->row_array(); if(empty($data_jenjang)){ $message = array('success' => false, 'message' => 'terjadi kesalahan. jenjang studi tidak dikenali'); echo json_encode($message); die; } $remove_strips = array('D-1', 'D-2', 'D-3', 'D-4', 'S-1', 'S-2', 'S-3'); $nmjenjang = (in_array($data_jenjang['nmkodtbkod'], $remove_strips)) ? str_replace('-', '', $data_jenjang['nmkodtbkod']) : $data_jenjang['nmkodtbkod']; $jenjang = $this->GetRecord('jenjang_pendidikan', "nm_jenj_didik like '".$nmjenjang."'"); //mengambil data jenjang dari feeder if(!isset($jenjang['result']) || empty($jenjang['result'])){ $message = array('success' => false, 'message' => 'terjadi kesalahan. jenjang studi tidak dikenali'); echo json_encode($message); die; } //get id_smt_berlaku $jenis_semester = ($jsemester == 1) ? 'Ganjil' : 'Genap'; $nm_smt = $berlaku.'/'.($berlaku + 1).' '.$jenis_semester; $smt = $this->GetRecord('semester', "nm_smt like '".$nm_smt."'"); if(!isset($smt['result']) || empty($smt['result'])){ $message = array('success' => false, 'message' => 'terjadi kesalahan. jenis semester tidak dikenali'); echo json_encode($message); die; } $kurikulum_array = array( #'id_kurikulum_sp' => '', 'nm_kurikulum_sp' => $nmkurikulum, 'jml_sem_normal' => 8, // 8 semester 'jml_sks_lulus' => $jumlahsks, 'jml_sks_wajib' => $jumlahskswajib, 'jml_sks_pilihan' => $jumlahskspilihan, 'id_sms' => $feeder_prodi['result']['id_sms'], 'id_jenj_didik' => $jenjang['result']['id_jenj_didik'], 'id_smt' => $smt['result']['id_smt'], ); $token = $this->_get_token(); $inserted_kurikulum = $this->proxy->InsertRecord($token, 'kurikulum', json_encode($kurikulum_array)); if(!isset($inserted_kurikulum['result']['id_kurikulum_sp']) || empty($inserted_kurikulum['result']['id_kurikulum_sp'])){ $message = array('success' => false, 'message' => 'terjadi kesalahan. gagal mengekspor data kurikulum. ('.$inserted_kurikulum['result']['error_desc'].')'); echo json_encode($message); die; } /* ================================================================== */ /* =================== insert mata kuliah kurikulum ================= */ /* ================================================================== */ if(!empty($griddata)){ $recordset_matkul = array(); foreach($griddata as $matkul) { $feeder_mk = $this->GetRecord('mata_kuliah', "kode_mk = '".$matkul->kdmk."'"); if(!isset($feeder_mk['result']['id_mk']) || empty($feeder_mk['result']['id_mk'])){ $jns_mk = (!empty($matkul->jns_mk)) ? $matkul->jns_mk : 'A'; $kel_mk = (!empty($matkul->jns_mk)) ? $matkul->jns_mk : 'A'; //insert mata kuliah $arr_matakuliah = array( //'id_mk' => '', 'id_sms' => $feeder_prodi['result']['id_sms'], 'id_jenj_didik' => $jenjang['result']['id_jenj_didik'], 'kode_mk' => $matkul->kdmk, 'nm_mk' => $matkul->nmmkind, 'jns_mk' => $jns_mk, 'kel_mk' => $kel_mk, 'sks_mk' => $matkul->jmlsks, 'sks_tm' => $matkul->skstatapmuka, 'sks_prak' => $matkul->skspraktikum, 'sks_prak_lap' => $matkul->sksprakteklap, 'sks_sim' => $matkul->skssimulasi, 'metode_pelaksanaan_kuliah' => '', 'a_sap' => 1, 'a_silabus' => 1, 'a_bahan_ajar' => 1, 'acara_prak' => 1, 'a_diktat' => 1, //'tgl_mulai_efektif' => '', //'tgl_akhir_efektif' => '' ); $token = $this->_get_token(); $inserted_matkul = $this->proxy->InsertRecord($token, 'mata_kuliah', json_encode($arr_matakuliah)); if(!isset($inserted_matkul['result']['id_mk']) || empty($inserted_matkul['result']['id_mk'])){ $message = array('success' => false, 'message' => 'terjadi kesalahan. gagal menyimpan mata kuliah. ('.$inserted_matkul['result']['error_desc'].')'); echo json_encode($message); die; } $feeder_mk['result']['id_mk'] = $inserted_matkul['result']['id_mk']; #$message = array('success' => false, 'message' => 'terjadi kesalahan. matakuliah "'.$matkul->nmmkind.'"" tidak dikenali.'); #echo json_encode($message); #die; } $a_wajib = ($matkul->jnsmk == 'B') ? '0' : 1; $arr_matakuliah_kurikulum = array( 'id_kurikulum_sp' => $inserted_kurikulum['result']['id_kurikulum_sp'], 'id_mk' => $feeder_mk['result']['id_mk'], 'smt' => $matkul->idsemester, 'sks_mk' => $matkul->jmlsks, 'sks_tm' => $matkul->skstatapmuka, 'sks_prak' => $matkul->skspraktikum, 'sks_prak_lap' => $matkul->sksprakteklap, 'sks_sim' => $matkul->skssimulasi, 'a_wajib' => $a_wajib, ); $recordset_matkul[] = $arr_matakuliah_kurikulum; } $token = $this->_get_token(); $inserted_matkul_kurikulum = $this->proxy->InsertRecordset($token, 'mata_kuliah_kurikulum', json_encode($recordset_matkul)); //print_r($inserted_matkul_kurikulum); } $message = array('success' => true, 'message' => 'berhasil mengekspor data.'); echo json_encode($message); die; } function GetRecord($tablename = '', $filter = '', $echo = false) { $token = $this->_get_token(); $GetRecord = $this->proxy->GetRecord($token, $tablename, $filter); if($echo){ echo json_encode($GetRecord); die; }else{ return $GetRecord; } } function GetRecordset($tablename = '', $filter = '', $echo = true ) { $token = $this->_get_token(); $GetRecordset = $this->proxy->GetRecordset($token, $tablename, $filter, '',1000, 0); if($echo){ echo json_encode($GetRecordset); die; }else{ return $GetRecordset; } } } ?>