Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Rekonsiliasi Data
- public function rekonsiliasi_post()
- {
- if (empty($_FILES['filecsv']['name'])) {
- $response = [
- 'resp_code' => '99',
- 'resp_desc' => 'File Rekonsiliasi tidak boleh Kosong.',
- ];
- } else {
- $jam = time();
- $config['file_name'] = 'File_Rekonsiliasi_' . $jam . '.csv';
- $config['upload_path'] = 'rekonsiliasi_file/';
- $config['allowed_types'] = 'csv';
- $config['overwrite'] = true;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if (!$this->upload->do_upload("filecsv")) {
- $response = [
- 'resp_code' => '01',
- 'resp_desc' => 'File Gagal Terupload',
- ];
- } else {
- $file = $this->upload->data();
- $csvupload = $file['file_name'];
- $inputFileName = 'rekonsiliasi_file/' . $csvupload;
- $objReader = new PHPExcel_Reader_CSV();
- $objReader->setInputEncoding('CP1252');
- $objReader->setDelimiter(';');
- $objReader->setEnclosure('');
- $excel = $objReader->load($inputFileName);
- $numrow = 1;
- $kosong = 0;
- $worksheet = $excel->getActiveSheet();
- foreach ($worksheet->getRowIterator() as $row) {
- $cellIterator = $row->getCellIterator();
- $cellIterator->setIterateOnlyExistingCells(false);
- $get = array();
- foreach ($cellIterator as $cell) {
- array_push($get, $cell->getValue());
- }
- $id_billing = $get[0];
- $tanggal = $get[3];
- $no_ref = $get[7];
- $tgl_bayar = substr($tanggal, 0, 4) . '-' . substr($tanggal, 4, 2) . '-' . substr($tanggal, 6, 2);
- $jenisret = substr($id_billing, 5, 1);
- if ($jenisret == 1) {
- // IMB
- $dataResp = $this->db->get_where('v_imb_dpm', array('no_billing' => $id_billing))->row();
- if (count($dataResp) > 0) {
- if ($dataResp->tgl_bayar == '') {
- // Proses Bayar
- $id = $dataResp->id;
- $data = array(
- 'sts_proses' => 12,
- 'no_ref' => $no_ref,
- 'tgl_validasi' => date('Y-m-d'),
- 'user_validasi' => '',
- 'pemohon_date_update' => date('Y-m-d'),
- 'tgl_bayar' => $tgl_bayar,
- 'pemohon_time_update' => date('Y-m-d H:i:s'),
- );
- $this->db->where('id', $id);
- $this->db->update('c39_imb_pemohon', $data);
- }
- }
- } elseif ($jenisret == 2) {
- // Trayek
- $dataResp = $this->db->get_where('v_trayek_dpm', array('no_billing' => $id_billing))->row();
- if (count($dataResp) > 0) {
- if ($dataResp->tgl_bayar == '') {
- $id = $dataResp->id;
- $data = array(
- 'sts_proses' => 12,
- 'no_ref' => $no_ref,
- 'tgl_validasi' => date('Y-m-d'),
- 'user_validasi' => '',
- 'pemohon_date_update' => date('Y-m-d'),
- 'tgl_bayar' => $tgl_bayar,
- 'pemohon_time_update' => date('Y-m-d H:i:s'),
- );
- $this->db->where('id', $id);
- $this->db->update('c39_trayek_pemohon', $data);
- }
- }
- } elseif ($jenisret == 3) {
- // Pemakaman
- $dataResp = $this->db->get_where('v_makam', array('no_billing' => $id_billing))->row();
- if (count($dataResp) > 0) {
- if ($dataResp->tgl_bayar == '') {
- // Proses Bayar
- $id = $dataResp->id;
- $data = array(
- 'sts_proses' => 6,
- 'no_ref' => $no_ref,
- 'tgl_validasi' => date('Y-m-d'),
- 'user_validasi' => '',
- 'pemohon_date_update' => date('Y-m-d'),
- 'tgl_bayar' => $tgl_bayar,
- 'pemohon_time_update' => date('Y-m-d H:i:s'),
- );
- $this->db->where('id', $id);
- $this->db->update('c39_makam_pemohon', $data);
- }
- }
- }
- $numrow++;
- }
- $response = [
- 'resp_code' => '00',
- 'resp_desc' => 'Rekonsiliasi Data Sukses',
- ];
- }
- }
- $this->response($response, 200);
- }
Add Comment
Please, Sign In to add comment