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; } /* ========================================================================================================= */ /* KELAS PERKULIAHAN */ /* ========================================================================================================= */ function get_struprogdet() { $kdprodi = $this->input->post('kdprodi'); $kdstsemester = $this->input->post('kdstsemester'); if(empty($kdprodi) || empty($kdstsemester)){ $message = array('success' => false, 'message' => 'terjadi kesalahan. kode prodi & kode semester tidak lengkap'); echo json_encode($message); die; } $query = "SELECT struprogdet.idstruprogdet , struprogdet.kdprodi , struprogdet.kdstsemester , struprogdet.kdmk , struprogdet.nidu , struprogdet.idkelas , struprogdet.kdjenjangstudi , struprogdet.silabus , struprogdet.satuanacarakuliah , struprogdet.bahanajar , struprogdet.diktat , struprogdet.idjnsdosen , struprog.idsemester , struprog.jmlsks , struprog.skstatapmuka , struprog.skspraktikum , struprog.sksprakteklap , '0' AS skssim , struprog.jnskurikulum , struprog.jnsmk , struprog.stmk , matakuliah.nmmkind , kelas.nmkelas FROM struprogdet LEFT JOIN struprog ON struprogdet.kdprodi = struprog.kdprodi AND struprogdet.kdstsemester = struprog.kdstsemester AND struprogdet.kdmk = struprog.kdmk LEFT JOIN matakuliah ON struprogdet.kdmk = matakuliah.kdmk AND struprogdet.kdprodi = matakuliah.kdprodi LEFT JOIN kelas ON struprogdet.idkelas = kelas.idkelas AND struprogdet.kdprodi = kelas.kdprodi WHERE struprogdet.kdprodi = '{$kdprodi}' AND struprogdet.kdstsemester = '{$kdstsemester}' AND struprogdet.idjnsdosen = 1 group by kdprodi, kdstsemester, kdmk, idkelas"; $this->rhlib->jsonFromQuery($query); } function view() { /*$token = $this->_get_token(); //$filter = "kode_mk = 'MIH103'" $mata_kuliah = $this->proxy->GetRecordSet($token, 'mata_kuliah'); //print_r($sms); print_r($mata_kuliah);*/ $token = $this->_get_token(); $filter_mk = "kode_prodi = '61201' and id_sp = '".$this->id_sp."'"; $mata_kuliah = $this->proxy->GetRecord($token, 'sms', $filter_mk); echo $mata_kuliah['result']['id_sms']; } function view2() { $token = $this->_get_token(); //$filter = "id_sms = 'bd335419-0972-437c-b46c-86227868bd37"; $mata_kuliah = $this->proxy->GetRecordSet($token, 'mata_kuliah'); //print_r($sms); print_r($mata_kuliah); } function view3() { //get id_sms (id prodi in feeder) $token = $this->_get_token(); $filter_prodi = "kode_prodi = '61201' "; $sms = $this->proxy->GetRecord($token, 'sms', $filter_prodi); if(!isset($sms['result']['id_sms'])){ echo $sms['result']['id_sms']; echo $this->id_sp; }else{ echo $sms['result']['id_sms'];} } function insert_kelas_kuliah() { $prodi = $this->input->post('prodi'); $stsemester = $this->input->post('stsemester'); $griddata = $this->input->post('griddata'); $token = $this->_get_token(); $tahun_ajar = substr($stsemester, 0, -1); if(empty($prodi) || empty($stsemester) || empty($griddata)) { echo json_encode(array('success' => false, 'message' => 'Data tidak boleh kosong')); exit; } //get id_sms (id prodi in feeder) $filter_prodi = "kode_prodi = '".$prodi."' and id_sp = '".$this->id_sp."'"; $sms = $this->proxy->GetRecord($token, 'sms', $filter_prodi); if(!isset($sms['result']['id_sms'])){ echo json_encode(array('success' => false, 'message' => array('Kode Prodi tidak dikenali'))); exit; }; //get id_smt (id semester in feeder) $filter_semester = "id_smt = '".$stsemester."'"; $semester = $this->proxy->GetRecord($token, 'semester', $filter_semester); if(!isset($semester['result']['id_smt'])){ echo json_encode(array('success' => false, 'message' => array('Kode Semester tidak dikenali'))); exit; } $data_kelaskuliah = json_decode($griddata, true); $errors = array(); foreach($data_kelaskuliah as $idx => $kelaskuliah) { //get id_mk (id mata kuliah in feeder) //$clean_kdmk = str_replace(' ', '',$kelaskuliah['kdmk']); $filter_mk = "kode_mk = '".$kelaskuliah['kdmk']."'"; $mata_kuliah = $this->proxy->GetRecord($token, 'mata_kuliah', $filter_mk); if(!isset($mata_kuliah['result']['id_mk'])){ $errors[] = $filter_mk; //$errors[] = "Mata kuliah ".$kelaskuliah['kdmk']." ".$sms['result']['id_sms']." Tidak diketahui."; continue; } //insert kelas kuliah $insert_kelaskuliah = array( 'id_sms' => $sms['result']['id_sms'], 'id_smt' => $semester['result']['id_smt'], 'id_mk' => $mata_kuliah['result']['id_mk'], 'nm_kls' => $kelaskuliah['idkelas'], 'sks_mk' => $kelaskuliah['jmlsks'], 'sks_tm' => $kelaskuliah['skstatapmuka'], 'sks_prak' => $kelaskuliah['skspraktikum'], 'sks_prak_lap' => $kelaskuliah['sksprakteklap'], 'sks_sim' => $kelaskuliah['skssim'], 'bahasan_case' => '', ); $inserted_kelaskuliah = $this->proxy->InsertRecord($token, 'kelas_kuliah', json_encode($insert_kelaskuliah)); if(!isset($inserted_kelaskuliah['result']['id_kls'])) { if(!empty($inserted_kelaskuliah['error_desc'])){ $errors[] = '"'.$kelaskuliah['nmmkind'].'" '.$inserted_kelaskuliah['error_desc']; }elseif(isset($inserted_kelaskuliah['result']['error_desc']) && !empty($inserted_kelaskuliah['result']['error_desc'])) { $errors[] = '"'.$kelaskuliah['nmmkind'].'" '.$inserted_kelaskuliah['result']['error_desc']; } } } $success = (empty($errors)); $return = array( 'success' => $success, 'errors' => $errors ); echo json_encode($return); } /* ========================================================================================================= */ /* DOSEN PENGAJAR & PESERTA KELAS */ /* ========================================================================================================= */ function get_kelaskuliah_feeder() { $kdprodi = $this->input->post('kdprodi'); $kdstsemester = $this->input->post('kdstsemester'); $token = $this->_get_token(); if(empty($kdprodi) || empty($kdstsemester)){ $message = array('success' => false, 'data' => array(), 'message' => 'terjadi kesalahan. kode prodi & kode semester tidak lengkap'); echo json_encode($message); die; } //get id_sms (id prodi in feeder) $filter_prodi = "kode_prodi = '".$kdprodi."' and id_sp = '".$this->id_sp."'"; $sms = $this->proxy->GetRecord($token, 'sms', $filter_prodi); if(!isset($sms['result']['id_sms'])){ echo json_encode(array('success' => false, 'data' => array(), 'message' => array('Kode Prodi tidak dikenali'))); exit; } //get id_smt (id semester in feeder) $filter_semester = "id_smt = '".$kdstsemester."'"; $semester = $this->proxy->GetRecord($token, 'semester', $filter_semester); if(!isset($semester['result']['id_smt'])){ echo json_encode(array('success' => false,'data' => array(), 'message' => array('Kode Semester tidak dikenali'))); exit; } //get kelas perkuliahan based on semester & prodi $filter_kelaskuliah = "p.id_sms = '".$sms['result']['id_sms']."' AND p.id_smt = '".$semester['result']['id_smt']."'"; $get_kelaskuliah = $this->proxy->GetRecordset($token, 'kelas_kuliah', $filter_kelaskuliah, '',1000, 0); echo json_encode(array('success' => true, 'data' => $get_kelaskuliah['result'])); exit; } function get_dosen_kelaskuliah(){ $prodi = $this->input->post('prodi'); $stsemester = $this->input->post('stsemester'); $id_kls = $this->input->post('id_kls'); $nm_kls = $this->input->post('nm_kls'); // nm_kls in feeder = id_kls in siak $id_mk = $this->input->post('id_mk'); if(empty($prodi) || empty($stsemester) || empty($id_kls) || empty($nm_kls) || empty($id_mk)){ $message = array('success' => false, 'data' => array(), 'message' => 'terjadi kesalahan. kode prodi & kode semester tidak lengkap'); echo json_encode($message); die; } $token = $this->_get_token(); //get kdmk siak based on id_mk feeder $filter_mk = "id_mk = '".$id_mk."'"; $mata_kuliah_feeder = $this->proxy->GetRecord($token, 'mata_kuliah', $filter_mk); if(!isset($mata_kuliah_feeder['result']['kode_mk']) || empty($mata_kuliah_feeder['result']['kode_mk'])) { $message = array('success' => false, 'data' => array(), 'message' => 'mata kuliah tidak dikenali'); echo json_encode($message); die; } $kdmk = $mata_kuliah_feeder['result']['kode_mk']; //get list dosen in mata kuliah $query = "SELECT struprogdet.nidu ,struprogdet.idjnsdosen ,dosen.nidn ,dosen.nmdostpgelar ,dosen.nmdosdgngelar ,jdosen.nmjnsdosen ,16 as rencana_pt ,16 as real_pt FROM struprogdet LEFT JOIN dosen ON struprogdet.nidu = dosen.nidu LEFT JOIN jdosen ON struprogdet.idjnsdosen = jdosen.idjnsdosen WHERE struprogdet.kdprodi = '".$prodi."' AND struprogdet.kdstsemester = '".$stsemester."' AND struprogdet.kdmk = '".$kdmk."' AND struprogdet.idkelas = '".$nm_kls."' ORDER BY struprogdet.idjnsdosen ASC, dosen.nmdostpgelar ASC "; $this->rhlib->jsonFromQuery($query); } function get_peserta_kelaskuliah(){ $prodi = $this->input->post('prodi'); $stsemester = $this->input->post('stsemester'); $kdmk = $this->input->post('kdmk'); $id_kls = $this->input->post('id_kls'); $nm_kls = $this->input->post('nm_kls'); // nm_kls in feeder = id_kls in siak $id_mk = $this->input->post('id_mk'); if(empty($prodi) || empty($stsemester) || empty($id_kls) || empty($nm_kls) || empty($id_mk)){ $message = array('success' => false, 'data' => array(), 'message' => 'terjadi kesalahan. kode prodi & kode semester tidak lengkap'); echo json_encode($message); die; } $token = $this->_get_token(); //get kdmk siak based on id_mk feeder $filter_mk = "id_mk = '".$id_mk."'"; $mata_kuliah_feeder = $this->proxy->GetRecord($token, 'mata_kuliah', $filter_mk); if(!isset($mata_kuliah_feeder['result']['kode_mk']) || empty($mata_kuliah_feeder['result']['kode_mk'])) { $message = array('success' => false, 'data' => array(), 'message' => 'mata kuliah tidak dikenali'); echo json_encode($message); die; } $kdmk = $mata_kuliah_feeder['result']['kode_mk']; $query = "SELECT absenmhs.nim , mahasiswa.nmmhs FROM absenmhs LEFT JOIN mahasiswa ON mahasiswa.nim = absenmhs.nim LEFT JOIN nilai n ON absenmhs.kdmk = n.kdmk AND absenmhs.kdprodi = n.kdprodi AND absenmhs.kdstsemester = n.kdstsemester AND absenmhs.nidu = n.nidu AND absenmhs.nim = n.nim LEFT JOIN stmhssemester s ON absenmhs.nim = s.nim AND absenmhs.kdstsemester = s.kdstsemester WHERE absenmhs.kdprodi = '$prodi' AND absenmhs.kdstsemester = '$stsemester' AND absenmhs.kdmk = '$kdmk' AND absenmhs.idkelas = '$nm_kls' AND s.kdstaktivitasmhs = 'A' AND n.idstsetuju=1 ORDER BY absenmhs.nim"; $this->rhlib->jsonFromQuery($query); } function insert_dosen_peserta_kelas(){ $prodi = $this->input->post('prodi'); $stsemester = $this->input->post('stsemester'); $id_kls = $this->input->post('id_kls'); $nm_kls = $this->input->post('nm_kls'); // nm_kls in feeder = id_kls in siak $id_mk = $this->input->post('id_mk'); $dosen_data = $this->input->post('dosen_data'); $peserta_data = $this->input->post('peserta_data'); $tahun_ajar = substr($stsemester,0,4); if(empty($prodi) || empty($stsemester) || empty($id_kls) || empty($nm_kls) || empty($id_mk) || empty($dosen_data)){ $message = array('success' => false, 'data' => array(), 'message' => 'terjadi kesalahan. data tidak lengkap'); echo json_encode($message); die; } $token = $this->_get_token(); $errors = array(); //insert ajar dosen $dosen_data = json_decode($dosen_data, true); foreach($dosen_data as $idx => $dosen) { //get id pt & id reg ptk $siak_dosen = $this->db->get_where('dosen', array('nidu' => $dosen['nidu']))->row_array(); if(empty($siak_dosen) || empty($siak_dosen['nidn'])){ $errors[] = "Dosen ".$dosen['nmdostpgelar']." tidak terdaftar"; continue; } $filter_dosen = "nidn = '".$siak_dosen['nidn']."' AND p.id_sp = '".$this->id_sp."'"; $dosen_feeder = $this->proxy->GetRecord($token, 'dosen', $filter_dosen); if(!isset($dosen_feeder['result']['id_ptk'])){ $errors[] = "Dosen ".$dosen['nmdostpgelar']." tidak terdaftar di feeder"; continue; } $filter_dosen_pt = "p.id_ptk = '".$dosen_feeder['result']['id_ptk']."' and p.id_thn_ajaran = '".$tahun_ajar."'"; $dosen_pt_feeder = $this->proxy->GetRecord($token, 'dosen_pt', $filter_dosen_pt); if(!isset($dosen_pt_feeder['result']['id_reg_ptk'])){ $errors[] = "Dosen ".$dosen['nmdostpgelar']." tidak terdaftar di feeder"; continue; } $insert_dosen = array( //'id_ajar' => '', 'id_reg_ptk' => $dosen_pt_feeder['result']['id_reg_ptk'], //'id_subst' => '', 'id_kls' => $id_kls, 'sks_subst_tot' => 0, 'sks_tm_subst' => 0, 'sks_prak_subst' => 0, 'sks_prak_lap_subst' => 0, 'sks_sim_subst' => 0, 'jml_tm_renc' => $dosen['rencana_pt'], 'jml_tm_real' => $dosen['real_pt'], 'id_jns_eval' => 1, ); $inserted_dosen_ajar = $this->proxy->InsertRecord($token, 'ajar_dosen', json_encode($insert_dosen)); if(!empty($inserted_dosen_ajar['error_desc'])){ $errors[] = "Gagal menginput dosen ".$dosen['nmdostpgelar'].". ".$inserted_dosen_ajar['error_desc']; continue; } if(!empty($inserted_dosen_ajar['result']['error_desc'])){ $errors[] = "Gagal menginput dosen ".$dosen['nmdostpgelar'].". ".$inserted_dosen_ajar['result']['error_desc']; continue; } } //insert mahasiswa if(!empty($peserta_data)) { $peserta_data = json_decode($peserta_data, true); foreach($peserta_data as $idx => $peserta) { $filter_mahasiswa = "trim(nipd) = '".$peserta['nim']."'"; $mahasiswa_pt = $this->proxy->GetRecord($token, 'mahasiswa_pt', $filter_mahasiswa); if(!isset($mahasiswa_pt['result']['id_reg_pd'])){ $errors[] = "Mahasiswa ".$peserta['nmmhs']." tidak terdaftar di feeder"; continue; } $insert_peserta = array( 'id_kls' => $id_kls, 'id_reg_pd' => $mahasiswa_pt['result']['id_reg_pd'], 'asal_data' => 9, //'nilai_angka' => '', //'nilai_huruf' => '', //'nilai_indeks ' => '', ); $inserted_peserta = $this->proxy->InsertRecord($token, 'nilai', json_encode($insert_peserta)); if(!empty($inserted_peserta['error_desc'])){ $errors[] = "Gagal menginput mahasiswa ".$peserta['nmmhs'].". ".$inserted_peserta['error_desc']; continue; } if(!empty($inserted_peserta['result']['error_desc'])){ $errors[] = "Gagal menginput mahasiswa ".$peserta['nmmhs'].". ".$inserted_peserta['result']['error_desc']; continue; } } } $success = (empty($errors)); $return = array( 'success' => $success, 'errors' => $errors, 'message' => '', ); echo json_encode($return);die; } /* ========================================================================================================= */ /* UTILITY */ /* ========================================================================================================= */ function get_dosen_store() { $query = "SELECT iddsn, kdprodi, nidu, nup, nidn, nmdostpgelar, nmdosdgngelar, CONCAT('( ', (IF(nidn IS NULL or nidn = '', '-', nidn)), ' ) ', nmdosdgngelar) as nidnnama FROM dosen ORDER BY nidu ASC"; $this->rhlib->jsonFromQuery($query); } function get_dosen() { $query = "SELECT nidu, nidn, nmdosdgngelar, CONCAT('( ', nidu, ' ) ', nmdosdgngelar) as nidunama FROM dosen ORDER BY nidu ASC"; $get = $this->db->query($query)->result(); $data = array(); foreach($get as $idx => $dt) { $data[$dt->nidu] = array($dt->nidn, $dt->nmdosdgngelar, $dt->nidunama); } echo json_encode($data); } } ?>