SHARE
TWEET

push_mhs.php

a guest Mar 19th, 2016 160 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.  
  10. $config = $db->fetch_single_row('config_user','id',1);
  11.  
  12. if ($config->live=='Y') {
  13.     $url = 'http://'.$config->url.':'.$config->port.'/ws/live.php?wsdl'; // gunakan live
  14. } else {
  15.     $url = 'http://'.$config->url.':'.$config->port.'/ws/sandbox.php?wsdl'; // gunakan sandbox
  16. }
  17. //untuk coba-coba
  18. // $url = 'http://pddikti.uinsgd.ac.id:8082/ws/live.php?wsdl'; // gunakan live bila
  19.  
  20. $client = new nusoap_client($url, true);
  21. $proxy = $client->getProxy();
  22.  
  23.  
  24.  
  25. # MENDAPATKAN TOKEN
  26. $username = $config->username;
  27. $password = $config->password;
  28. $result = $proxy->GetToken($username, $password);
  29. $token = $result;
  30.  
  31. //$token = 'acdbbc82c3b29f99e9096dab1d5eafb4';
  32.  
  33.  
  34.     $id_sms = '';
  35.     $id_mk = '';
  36.     $id_reg_ptk = '';
  37.     $nidn = '';
  38.     $id_ptk = '';
  39.     $sks_mk = '';
  40.     $sks_tm = '';
  41.     $sks_prak = '';
  42.     $sks_prak_lap = '';
  43.     $sks_sim = '';
  44.     $temp_data = array();
  45.     $sukses_count = 0;
  46.     $id_pd = "";
  47.     $sukses_msg = '';
  48.     $error_count = 0;
  49.     $error_msg = array();
  50.     $temp_result = array();
  51.  
  52.     //get id npsn
  53.     $filter_sp = "npsn='".$config->id_sp."'";
  54.     $get_id_sp = $proxy->GetRecord($token,'satuan_pendidikan',$filter_sp);
  55.  
  56.     $id_sp = $get_id_sp['result']['id_sp'];
  57.  
  58. $table1 = 'kelas_kuliah';
  59.  
  60.     $arr_data = $db->fetch_custom("select mhs.*,mhs_pt.nipd from mhs inner join mhs_pt on mhs.id=mhs_pt.id_mhs where kode_jurusan='".$_GET['jurusan']."' and mulai_smt='".$_GET['sem']."' and status_error!=1");
  61.  
  62. $options = array(
  63.     'filename' => $_GET['jurusan'].'_progress.json',
  64.     'autoCalc' => true,
  65.     'totalStages' => 1
  66. );
  67. $pu = new Manticorp\ProgressUpdater($options);
  68.  
  69.  
  70.  
  71. $stageOptions = array(
  72.     'name' => 'This AJAX process takes a long time',
  73.     'message' => 'But this will keep the user updated on it\'s actual progress!',
  74.     'totalItems' => $arr_data->rowCount(),
  75. );
  76.  
  77.  
  78. $pu->nextStage($stageOptions);
  79.  
  80.  
  81.  
  82. $i=1;
  83.  
  84.         function myFilter($var){
  85.               return ($var !== NULL && $var !== FALSE && $var !== '');
  86.             }
  87.  
  88.  
  89.  
  90.     foreach ($arr_data as $value) {
  91.  
  92.         $data_mhs_pt = $db->fetch_single_row('mhs_pt','id_mhs',$value->id);
  93.  
  94.         $filter_nipd = "nipd like '%".$value->nipd."%'";
  95.         $temp_nipd = $proxy->GetRecord($token,'mahasiswa_pt',$filter_nipd);
  96.  
  97.  
  98.         if ($temp_nipd['result']) {
  99.            ++$error_count;
  100.            $db->update('mhs_pt',array('status_error' => 2, 'keterangan'=>"Error ".$value->nipd." ".$value->nm_pd." Sudah ada"),'id',$data_mhs_pt->id);
  101.             $error_msg[] = "<b>Error ".$value->nipd." ".$value->nm_pd." Sudah ada di Feeder";
  102.            
  103.         } else {
  104.            
  105.             $data_mhs = $db->convert_obj_to_array($value);
  106.             unset($data_mhs['id']);
  107.             unset($data_mhs['nipd']);
  108.  
  109.    
  110.             $data_mhs = array_filter($data_mhs, 'myFilter');
  111.  
  112.             $sp = array('id_sp' => $id_sp);
  113.  
  114.             $data_mhs = array_merge($data_mhs,$sp);
  115.  
  116.               $temp_result = $proxy->InsertRecord($token, 'mahasiswa', json_encode($data_mhs));
  117.  
  118.  
  119.               if ($temp_result['result']) {
  120.  
  121.                 $kode_prodi = trim($data_mhs_pt->kode_jurusan);
  122.  
  123.                 $id_pd = $temp_result['result']['id_pd'];
  124.                 $filter_sms = "id_sp='".$id_sp."' and kode_prodi ilike '%".$kode_prodi."%'";
  125.                 $temp_sms = $proxy->GetRecord($token,'sms',$filter_sms);
  126.                 if ($temp_sms['result']) {
  127.                     $id_sms = $temp_sms['result']['id_sms'];
  128.                 }
  129.  
  130.                 $data_insert_mhs_pt = array(
  131.                   'id_sms' => $id_sms,
  132.                   'id_pd' => $id_pd,
  133.                   'id_sp' => $id_sp,
  134.                   'id_jns_daftar' => $data_mhs_pt->id_jns_daftar,
  135.                   'nipd' => $data_mhs_pt->nipd,
  136.                   'tgl_masuk_sp' => $data_mhs_pt->tgl_masuk_sp,
  137.                   'a_pernah_paud' => '1',
  138.                   'a_pernah_tk' => '1',
  139.                   'mulai_smt' => $data_mhs_pt->mulai_smt
  140.                 );
  141.  
  142.  
  143.  
  144.          $insert_mhs_pt =  $proxy->InsertRecord($token, 'mahasiswa_pt', json_encode($data_insert_mhs_pt));
  145.  
  146.  
  147.         if ($insert_mhs_pt['result']['error_desc']==NULL) {
  148.                                     ++$sukses_count;
  149.                                     $db->update('mhs_pt',array('status_error'=>1,'keterangan'=>''),'id',$data_mhs_pt->id);
  150.                                 } else {
  151.                                     ++$error_count;
  152.                                     $db->update('mhs_pt',array('status_error' => 2, 'keterangan'=>"Error".$insert_mhs_pt['result']['error_desc']),'id',$data_mhs_pt->id);
  153.                                     $error_msg[] = "<b>Error </b>".$insert_mhs_pt['result']['error_desc'];
  154.                                 }
  155.  
  156.  
  157.               } else {
  158.                 ++$error_count;
  159.                                     $db->update('mhs_pt',array('status_error' => 2, 'keterangan'=>"Error".$temp_result['result']['error_desc']),'id',$data_mhs_pt->id);
  160.                                     $error_msg[] = "<b>Error </b>".$temp_result['result']['error_desc'];
  161.               }
  162.              
  163.  
  164.  
  165.         }
  166.  
  167. $i++;
  168.  $pu->incrementStageItems(1, true);
  169.  
  170.         }
  171.    
  172.  
  173.  
  174. $msg = '';
  175.     $msg =  "<div class=\"alert alert-warning\" role=\"alert\">
  176.             <font color=\"#3c763d\">".$sukses_count." data Mahasiswa baru berhasil ditambah</font><br />
  177.             <font color=\"#ce4844\" >".$error_count." data tidak bisa ditambahkan </font>";
  178.             if (!$error_count==0) {
  179.                 $msg .= "<a data-toggle=\"collapse\" href=\"#collapseExample\" aria-expanded=\"false\" aria-controls=\"collapseExample\">Detail error</a>";
  180.             }
  181.             //echo "<br />Total: ".$i." baris data";
  182.             $msg .= "<div class=\"collapse\" id=\"collapseExample\">";
  183.                     $i=1;
  184.                     foreach ($error_msg as $pesan) {
  185.                             $msg .= "<div class=\"bs-callout bs-callout-danger\">".$i.". ".$pesan."</div><br />";
  186.                         $i++;
  187.                         }
  188.             $msg .= "</div>
  189.         </div>";
  190.  
  191.  
  192. //echo $msg;
  193.  
  194. $pu->totallyComplete($msg);
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