jamboljack

Rekonsiliasi Bank

Nov 23rd, 2018
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.97 KB | None | 0 0
  1. // Rekonsiliasi Data
  2.     public function rekonsiliasi_post()
  3.     {
  4.         if (empty($_FILES['filecsv']['name'])) {
  5.             $response = [
  6.                 'resp_code' => '99',
  7.                 'resp_desc' => 'File Rekonsiliasi tidak boleh Kosong.',
  8.             ];
  9.         } else {
  10.             $jam                     = time();
  11.             $config['file_name']     = 'File_Rekonsiliasi_' . $jam . '.csv';
  12.             $config['upload_path']   = 'rekonsiliasi_file/';
  13.             $config['allowed_types'] = 'csv';
  14.             $config['overwrite']     = true;
  15.             $this->load->library('upload', $config);
  16.             $this->upload->initialize($config);
  17.             if (!$this->upload->do_upload("filecsv")) {
  18.                 $response = [
  19.                     'resp_code' => '01',
  20.                     'resp_desc' => 'File Gagal Terupload',
  21.                 ];
  22.             } else {
  23.                 $file          = $this->upload->data();
  24.                 $csvupload     = $file['file_name'];
  25.                 $inputFileName = 'rekonsiliasi_file/' . $csvupload;
  26.                 $objReader     = new PHPExcel_Reader_CSV();
  27.                 $objReader->setInputEncoding('CP1252');
  28.                 $objReader->setDelimiter(';');
  29.                 $objReader->setEnclosure('');
  30.                 $excel     = $objReader->load($inputFileName);
  31.                 $numrow    = 1;
  32.                 $kosong    = 0;
  33.                 $worksheet = $excel->getActiveSheet();
  34.                 foreach ($worksheet->getRowIterator() as $row) {
  35.                     $cellIterator = $row->getCellIterator();
  36.                     $cellIterator->setIterateOnlyExistingCells(false);
  37.                     $get = array();
  38.  
  39.                     foreach ($cellIterator as $cell) {
  40.                         array_push($get, $cell->getValue());
  41.                     }
  42.  
  43.                     $id_billing = $get[0];
  44.                     $tanggal    = $get[3];
  45.                     $no_ref     = $get[7];
  46.                     $tgl_bayar  = substr($tanggal, 0, 4) . '-' . substr($tanggal, 4, 2) . '-' . substr($tanggal, 6, 2);
  47.                    
  48.                     $jenisret   = substr($id_billing, 5, 1);
  49.                     if ($jenisret == 1) {
  50.                         // IMB
  51.                         $dataResp = $this->db->get_where('v_imb_dpm', array('no_billing' => $id_billing))->row();
  52.                         if (count($dataResp) > 0) {
  53.                             if ($dataResp->tgl_bayar == '') {
  54.                                 // Proses Bayar
  55.                                 $id   = $dataResp->id;
  56.                                 $data = array(
  57.                                     'sts_proses'          => 12,
  58.                                     'no_ref'              => $no_ref,
  59.                                     'tgl_validasi'        => date('Y-m-d'),
  60.                                     'user_validasi'       => '',
  61.                                     'pemohon_date_update' => date('Y-m-d'),
  62.                                     'tgl_bayar'           => $tgl_bayar,
  63.                                     'pemohon_time_update' => date('Y-m-d H:i:s'),
  64.                                 );
  65.  
  66.                                 $this->db->where('id', $id);
  67.                                 $this->db->update('c39_imb_pemohon', $data);
  68.                             }
  69.                         }
  70.                     } elseif ($jenisret == 2) {
  71.                         // Trayek
  72.                         $dataResp = $this->db->get_where('v_trayek_dpm', array('no_billing' => $id_billing))->row();
  73.                         if (count($dataResp) > 0) {
  74.                             if ($dataResp->tgl_bayar == '') {
  75.                                 $id   = $dataResp->id;
  76.                                 $data = array(
  77.                                     'sts_proses'          => 12,
  78.                                     'no_ref'              => $no_ref,
  79.                                     'tgl_validasi'        => date('Y-m-d'),
  80.                                     'user_validasi'       => '',
  81.                                     'pemohon_date_update' => date('Y-m-d'),
  82.                                     'tgl_bayar'           => $tgl_bayar,
  83.                                     'pemohon_time_update' => date('Y-m-d H:i:s'),
  84.                                 );
  85.  
  86.                                 $this->db->where('id', $id);
  87.                                 $this->db->update('c39_trayek_pemohon', $data);
  88.                             }
  89.                         }
  90.                     } elseif ($jenisret == 3) {
  91.                         // Pemakaman
  92.                         $dataResp = $this->db->get_where('v_makam', array('no_billing' => $id_billing))->row();
  93.                         if (count($dataResp) > 0) {
  94.                             if ($dataResp->tgl_bayar == '') {
  95.                                 // Proses Bayar
  96.                                 $id   = $dataResp->id;
  97.                                 $data = array(
  98.                                     'sts_proses'          => 6,
  99.                                     'no_ref'              => $no_ref,
  100.                                     'tgl_validasi'        => date('Y-m-d'),
  101.                                     'user_validasi'       => '',
  102.                                     'pemohon_date_update' => date('Y-m-d'),
  103.                                     'tgl_bayar'           => $tgl_bayar,
  104.                                     'pemohon_time_update' => date('Y-m-d H:i:s'),
  105.                                 );
  106.  
  107.                                 $this->db->where('id', $id);
  108.                                 $this->db->update('c39_makam_pemohon', $data);
  109.                             }
  110.                         }
  111.                     }
  112.                     $numrow++;
  113.                 }
  114.  
  115.                 $response = [
  116.                     'resp_code' => '00',
  117.                     'resp_desc' => 'Rekonsiliasi Data Sukses',
  118.                 ];
  119.             }
  120.         }
  121.  
  122.         $this->response($response, 200);
  123.     }
Add Comment
Please, Sign In to add comment