SHARE
TWEET

push_akm.php

a guest Mar 20th, 2016 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //include "inc/config.php";
  3. include "../../lib/nusoap/nusoap.php";
  4.  
  5. include "../../inc/config.php";
  6.  
  7. include "../../lib/prosesupdate/ProgressUpdater.php";
  8.  
  9. $options = array(
  10.     'filename' => $_GET['jurusan'].'_progress.json',
  11.     'autoCalc' => true,
  12.     'totalStages' => 1
  13. );
  14.  
  15. $pu = new Manticorp\ProgressUpdater($options);
  16. $check = $db->fetch_custom("select *,nilai_akm.id as id_akm from nilai_akm inner join jurusan on nilai_akm.kode_jurusan=jurusan.kode_jurusan where jurusan.kode_jurusan='".$_GET['jurusan']."' and nilai_akm.semester='".$_GET['sem']."' and valid=0 or valid=2");
  17. $jumlah_error = $check->rowCount();
  18. if ($jumlah_error>0) {
  19.     $msg = "Pastikan Anda Sudah Melakukan validasi AKM dan semua data valid";
  20.  
  21.     $pu->totallyComplete($msg);
  22.     exit();
  23. }
  24. $config = $db->fetch_single_row('config_user','id',1);
  25.  
  26. if ($config->live=='Y') {
  27.     $url = 'http://'.$config->url.':'.$config->port.'/ws/live.php?wsdl'; // gunakan live
  28. } else {
  29.     $url = 'http://'.$config->url.':'.$config->port.'/ws/sandbox.php?wsdl'; // gunakan sandbox
  30. }
  31. //untuk coba-coba
  32. // $url = 'http://pddikti.uinsgd.ac.id:8082/ws/live.php?wsdl'; // gunakan live bila
  33.  
  34. $client = new nusoap_client($url, true);
  35. $proxy = $client->getProxy();
  36.  
  37.  
  38.  
  39. # MENDAPATKAN TOKEN
  40. $username = $config->username;
  41. $password = $config->password;
  42. $result = $proxy->GetToken($username, $password);
  43. $token = $result;
  44.  
  45. //$token = 'acdbbc82c3b29f99e9096dab1d5eafb4';
  46.  
  47.  
  48.     $id_sms = '';
  49.     $id_mk = '';
  50.     $sks_mk = '';
  51.     $sks_tm = '';
  52.     $sks_prak = '';
  53.     $sks_prak_lap = '';
  54.     $sks_sim = '';
  55.     $temp_data = array();
  56.     $sukses_count = 0;
  57.     $sukses_msg = '';
  58.     $error_count = 0;
  59.     $error_msg = array();
  60.     $data_id = array();
  61.     $error_id = array();
  62.     //get id npsn
  63.     $filter_sp = "npsn='".$config->id_sp."'";
  64.     $get_id_sp = $proxy->GetRecord($token,'satuan_pendidikan',$filter_sp);
  65.  
  66.     $id_sp = $get_id_sp['result']['id_sp'];
  67.  
  68.     $arr_data = $db->fetch_custom("select *,nilai_akm.id as id_akm from nilai_akm inner join jurusan on nilai_akm.kode_jurusan=jurusan.kode_jurusan where jurusan.kode_jurusan='".$_GET['jurusan']."' and nilai_akm.semester='".$_GET['sem']."' and status_error!=1");
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. $stageOptions = array(
  76.     'name' => 'This AJAX process takes a long time',
  77.     'message' => 'But this will keep the user updated on it\'s actual progress!',
  78.     'totalItems' => $arr_data->rowCount(),
  79. );
  80.  
  81.  
  82. $pu->nextStage($stageOptions);
  83.  
  84.  
  85.  
  86. $i=1;
  87.  
  88. $insert_data_akm = array();
  89.  
  90.     foreach ($arr_data as $value) {
  91.  
  92.         $nim = $value->nim;
  93.         $filter_npm = "nipd like '%".$nim."%'";
  94.         $temp_npm = $proxy->GetRecord($token,'mahasiswa_pt',$filter_npm);
  95.         //var_dump($temp_npm);
  96.         if ($temp_npm['result']) {
  97.             $id_reg_pd = $temp_npm['result']['id_reg_pd'];
  98.             $stat_reg = TRUE;
  99.         }
  100.  
  101.         if ($_GET['method']=='up') {
  102.             $filter_akm = "id_reg_pd='".$id_reg_pd."' and id_smt='".$value->semester."'";
  103.             $temp_akm = $proxy->GetRecord($token,'kuliah_mahasiswa',$filter_akm);
  104.             $array_key = array('id_smt' => $value->semester, 'id_reg_pd' => $temp_akm['result']['id_reg_pd']);
  105.             $array_data = array('id_smt' => $value->semester,
  106.                           'id_reg_pd' => $id_reg_pd,
  107.                                 'ips' => $value->ips,
  108.                             'sks_smt' => $value->sks_smt,
  109.                                 'ipk' => $value->ipk,
  110.                           'sks_total' => $value->sks_total,
  111.                          'id_stat_mhs' => $value->status_kuliah
  112.                         );
  113.             $final_up = array('key' => $array_key, 'data' => $array_data
  114.                 );
  115.             $up_result = $proxy->UpdateRecord($token, 'kuliah_mahasiswa', json_encode($final_up));
  116.  
  117.             if ($up_result['result']['error_desc']==NULL) {
  118.                                     ++$sukses_count;
  119.                                
  120.                                     $db->update('nilai_akm',array('status_error'=>1,'keterangan'=>''),'id',$value->id_akm);
  121.                                 } else {
  122.                                     ++$error_count;
  123.                                     $error_msg[] = "<h4>Error $nim</h4>".$up_result['result']['error_desc'];
  124.                                     $db->update('nilai_akm',array('status_error' => 2, 'keterangan'=>$up_result['result']['error_desc']),'id',$value->id_akm);
  125.                                 }
  126.             $i++;
  127.      $pu->incrementStageItems(1, true);
  128.  
  129.         } else {
  130.  
  131.  
  132.         $filter_nim = "id_reg_pd='".$id_reg_pd."' and id_smt='".$value->semester."' and soft_delete='1'";
  133.         $check_delete = $proxy->GetRecord($token,'kuliah_mahasiswa',$filter_nim);
  134.  
  135.         if ($check_delete['result']) {
  136.             $restore_data = array('id_reg_pd' => $check_delete['result']['id_reg_pd']);
  137.             $restore = $proxy->RestoreRecord($token,'kuliah_mahasiswa',json_encode($restore_data));
  138.  
  139.  
  140.             $array_key = array('id_smt' => $value->semester, 'id_reg_pd' => $check_delete['result']['id_reg_pd']);
  141.             $array_data = array('id_smt' => $value->semester,
  142.                           'id_reg_pd' => $id_reg_pd,
  143.                                 'ips' => $value->ips,
  144.                             'sks_smt' => $value->sks_smt,
  145.                                 'ipk' => $value->ipk,
  146.                           'sks_total' => $value->sks_total,
  147.                          'id_stat_mhs' => $value->status_kuliah
  148.                         );
  149.                     $final_up = array('key' => $array_key, 'data' => $array_data
  150.                 );
  151.             $temp_result = $proxy->UpdateRecord($token, 'kuliah_mahasiswa', json_encode($final_up));
  152.  
  153.  
  154.         } else {
  155.  
  156.                     $temp_data = array('id_smt' => $value->semester,
  157.                           'id_reg_pd' => $id_reg_pd,
  158.                                 'ips' => $value->ips,
  159.                             'sks_smt' => $value->sks_smt,
  160.                                 'ipk' => $value->ipk,
  161.                           'sks_total' => $value->sks_total,
  162.                          'id_stat_mhs' => $value->status_kuliah
  163.                         );
  164.                     $temp_result = $proxy->InsertRecord($token, 'kuliah_mahasiswa', json_encode($temp_data));
  165.  
  166.         }
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.     if ($temp_result['result']['error_desc']==NULL) {
  174.                                     ++$sukses_count;
  175.                                
  176.                                     $db->update('nilai_akm',array('status_error'=>1,'keterangan'=>''),'id',$value->id_akm);
  177.                                 } else {
  178.                                     ++$error_count;
  179.                                     $error_msg[] = "<h4>Error $nim</h4>".$temp_result['result']['error_desc'];
  180.                                     $db->update('nilai_akm',array('status_error' => 2, 'keterangan'=>$temp_result['result']['error_desc']),'id',$value->id_akm);
  181.                                 }
  182.         $i++;
  183.      $pu->incrementStageItems(1, true);
  184.                     }
  185.  
  186.    
  187.  
  188.  
  189.     }
  190.  
  191. $msg = '';
  192. if ((!$sukses_count==0) || (!$error_count==0)) {
  193.     $msg =  "<div class=\"alert alert-warning \" role=\"alert\">
  194.             <font color=\"#3c763d\">".$sukses_count." data Akm baru berhasil di Upload</font><br />
  195.             <font color=\"#ce4844\" >".$error_count." data tidak bisa diupload </font>";
  196.            
  197.             if (!$error_count==0) {
  198.                 $msg .= "<a data-toggle=\"collapse\" href=\"#collapseExample\" aria-expanded=\"false\" aria-controls=\"collapseExample\">Detail error</a>";
  199.             }
  200.             //echo "<br />Total: ".$i." baris data";
  201.             $msg .= "<div class=\"collapse\" id=\"collapseExample\">";
  202.                     $i=1;
  203.                     foreach ($error_msg as $pesan) {
  204.                             $msg .= "<div class=\"bs-callout bs-callout-danger\">".$i.". ".$pesan."</div><br />";
  205.                         $i++;
  206.                         }
  207.             $msg .= "</div>
  208.         </div>";
  209. }
  210.  
  211. $pu->totallyComplete($msg);
  212.  
  213.  
  214. //$pu->totallyComplete();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top