Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include "../../lib/nusoap/nusoap.php";
- include "../../inc/config.php";
- $json_response = array();
- if ($_POST['total_data']>0) {
- $config = $db->fetch_single_row('config_user','id',1);
- if ($config->live=='Y') {
- $url = 'http://'.$config->url.':'.$config->port.'/ws/live.php?wsdl'; // gunakan live
- } else {
- $url = 'http://'.$config->url.':'.$config->port.'/ws/sandbox.php?wsdl'; // gunakan sandbox
- }
- $client = new nusoap_client($url, true);
- $proxy = $client->getProxy();
- # MENDAPATKAN TOKEN
- $username = $config->username;
- $password = $config->password;
- $result = $proxy->GetToken($username, $password);
- $token = $result;
- $sukses_count = 0;
- $error_count = 0;
- $error_count_in = 0;
- $error_msg = array();
- $array_id_pt = array();
- $array_sms_asal = array();
- $array_sks_diakui = array();
- $error_pt_asal = "";
- $error_nim = "";
- $error_prodi_asal = "";
- $update_data = array();
- $update_data_status = array();
- $update_data_er =array();
- $update_data_er_status =array();
- $error_mk = "";
- $id_pt_asal = "";
- $data_id_sukses = array();
- $data_id_error= array();
- $all_errors = array();
- $all_error = array();
- $query_not_in = "";
- $jurusan = "";
- $msg = "";
- $sem = "";
- if ($_POST['sem']!='all') {
- $sem = "and mulai_smt='".$_POST['sem']."'";
- }
- if (!empty($_POST['all_id'])) {
- $trim_data_id = rtrim($_POST['all_id'], ',');
- $query_not_in = "and history_pendidikan.id not in(".$trim_data_id.")";
- }
- if ($_POST['jurusan']!='all') {
- $jurusan = "and trim(jurusan.kode_jurusan)='".trim($_POST['jurusan'])."'";
- } else {
- if ($_SESSION['level']!=1) {
- $jurusan = "and trim(jurusan.kode_jurusan)='".$_SESSION['jurusan']."'";
- }
- }
- $data = $db->fetch_custom("select history_pendidikan.*,id_sms from history_pendidikan inner join jurusan on history_pendidikan.kode_jurusan=jurusan.kode_jurusan where history_pendidikan.id is not null $sem $jurusan and status_error!=1 and status_error!=1 $query_not_in limit 50");
- foreach ($data as $value) {
- $id_reg_filter = "trim(p.nipd)='".trim($value->nipd)."' and p.id_sms='".$value->id_sms."' and p.mulai_smt='".$value->mulai_smt."'";
- $id_reg_pd = $proxy->GetRecord($token,'mahasiswa_pt',$id_reg_filter);
- if (!empty($id_reg_pd['result'])) {
- if ($value->kode_pt_asal!='') {
- $filter_satuan_pendidikan = "trim(p.npsn)='".trim($value->kode_pt_asal)."' and soft_delete='0'";
- $id_pt_asal = $proxy->GetRecord($token,'satuan_pendidikan',$filter_satuan_pendidikan);
- if ($id_pt_asal['result']) {
- $id_pt_asals = $id_pt_asal['result']['id_sp'];
- $array_id_pt = array('id_pt_asal' => $id_pt_asals,'nm_pt_asal' => $id_pt_asal['result']['nm_lemb']);
- if ($value->kode_prodi_asal!='') {
- $kode_prodi_asal_data = trim($value->kode_prodi_asal);
- $filter_sms = "id_sp='".$id_pt_asals."' and trim(kode_prodi)='".$kode_prodi_asal_data."'";
- $temp_sms = $proxy->GetRecord($token,'sms',$filter_sms);
- if ($temp_sms['result']) {
- $array_sms_asal = array('id_prodi_asal' => $temp_sms['result']['id_sms'],'nm_prodi_asal' => $temp_sms['result']['nm_lemb']);
- } else {
- $error_prodi_asal = "Kode Prodi Asal Tidak Ditemukan di Feeder. Perbaiki atau kosongkan Saja";
- }
- }
- } else {
- $error_pt_asal = "Kode PT Asal tidak ditemukan di Feeder";
- }
- }
- if ($value->sks_diakui!='') {
- $array_sks_diakui = array('sks_diakui' => $value->sks_diakui);
- }
- } else {
- $error_nim = "Nipd/NIm tidak ditemukan di feeder";
- }
- if ($error_nim=="" && $error_pt_asal=="" && $error_prodi_asal=="") {
- $data_ids[] = $value->id;
- $data_nim[$value->id] = $value->nipd;
- $temp_key = array(
- 'id_reg_pd' => $id_reg_pd['result']['id_reg_pd'],
- 'mulai_smt' => $value->mulai_smt
- );
- $temp_data = array(
- 'id_jns_daftar' => $value->id_jns_daftar,
- 'id_jalur_masuk' => $value->id_jalur_masuk,
- 'tgl_masuk_sp' => $value->tgl_masuk_sp
- );
- $temp_data = array_merge($temp_data,$array_id_pt);
- $temp_data = array_merge($temp_data,$array_sms_asal);
- $temp_data = array_merge($temp_data,$array_sks_diakui);
- $array_history[] = array('key'=>$temp_key,'data'=>$temp_data);
- } else {
- $error_msg[] = "Error $error_nim $error_pt_asal $error_prodi_asal";
- $update_data_er[] = "WHEN $value->id THEN 'Error, $error_nim $error_pt_asal $error_prodi_asal' ";
- $update_data_er_status[]= "WHEN $value->id THEN '2' ";
- $data_id_error[] = $value->id;
- $error_count++;
- }
- $all_id[] = $value->id;
- $array_sms_asal = array();
- $error_prodi_asal = "";
- $error_pt_asal = "";
- $error_nim = "";
- }
- /* echo "<pre>";
- print_r($array_history);
- print_r($value);
- exit();*/
- if (!empty($array_history)) {
- $result = $proxy->UpdateRecordset($token, 'mahasiswa_pt',json_encode($array_history));
- foreach ($result['result'] as $key => $value) {
- $value_data = $value['error_desc'];
- $data_key = $data_ids[$key];
- if ($value_data!='') {
- //$db->update('kelas_kuliah',array('status_error' => 2,'keterangan' => $value),'id',$key);
- $error_msg[] = $data_nim[$data_key]." $value_data";
- $update_data_er[] = "WHEN $data_key THEN '".str_replace("'",'',$value_data)."'";
- $update_data_er_status[]= "WHEN $data_key THEN '2' ";
- $data_id_error[] = $data_key;
- $error_count++;
- } else {
- //$db->update('kelas_kuliah',array('status_error' => 1,'keterangan' => $value),'id',$key);
- $update_data[]= "WHEN $data_key THEN '' ";
- $update_data_status[]= "WHEN $data_key THEN '1' ";
- $data_id_sukses[] = $data_key;
- $sukses_count++;
- }
- }
- }
- if ($error_count>0) {
- $id_error_update = implode(",", $data_id_error);
- $data_er_update = implode(" ", $update_data_er);
- $data_er_update_status = implode(" ", $update_data_er_status);
- $bulk_update_error = "UPDATE history_pendidikan
- SET keterangan = (CASE id
- $data_er_update
- END),status_error = (CASE id
- $data_er_update_status
- END)
- WHERE id IN($id_error_update);";
- //echo $bulk_update_error;
- $db->fetch_custom($bulk_update_error);
- }
- if ($sukses_count>0) {
- $id_update = implode(",", $data_id_sukses);
- $data_update = implode(" ", $update_data);
- $data_update_status = implode(" ", $update_data_status);
- $bulk_update_sukses = "UPDATE history_pendidikan
- SET keterangan = (CASE id
- $data_update
- END),status_error = (CASE id
- $data_update_status
- END)
- WHERE id IN($id_update);";
- //echo $bulk_update_sukses;
- $db->fetch_custom($bulk_update_sukses);
- }
- //$jumlah['not_in'] = $query_not_in;
- $jumlah['all_id'] = $all_id;
- $jumlah['jumlah_error'] = $error_count;
- $jumlah['jumlah_sukses'] = $sukses_count;
- $jumlah['error_msg'] = $error_msg;
- if (isset($_POST['id_data'])) {
- $jumlah_sukses = $_POST['jumlah_sukses']+$sukses_count;
- $jumlah_error = $_POST['jumlah_error']+$error_count;
- $msg = "<div class=\"alert alert-warning \" role=\"alert\">
- <font color=\"#3c763d\">".$jumlah_sukses." data History berhasil ditambah</font><br />
- <font color=\"#ce4844\" >".$jumlah_error." data tidak bisa ditambahkan </font>";
- if (!$jumlah_error==0) {
- $msg .= "<a data-toggle=\"collapse\" href=\"#collapseExample\" aria-expanded=\"false\" aria-controls=\"collapseExample\">Detail error</a>";
- //pesan error
- if (!empty($_POST['error_msg'])) {
- $trim_error = rtrim($_POST['error_msg'], ',');
- $all_error = explode(",", $trim_error);
- }
- $all_errors = array_merge($all_error,$error_msg);
- }
- //echo "<br />Total: ".$i." baris data";
- $msg .= "<div class=\"collapse\" id=\"collapseExample\">";
- $i=1;
- foreach ($all_errors as $pesan) {
- $msg .= "<div class=\"bs-callout bs-callout-danger\">".$i.". ".$pesan."</div><br />";
- $i++;
- }
- $msg .= "</div>
- </div>";
- $jumlah['last_notif'] = $msg;
- }
- } else {
- $msg = "Tidak ada data yang bisa diproses<p>";
- $jumlah['last_notif'] = $msg;
- }
- array_push($json_response, $jumlah);
- echo json_encode($json_response);
- //echo convert(memory_get_usage(true)); // 123 kb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement