Advertisement
jamboljack

Send Data FO

Sep 6th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.62 KB | None | 0 0
  1. public function senddata_post()
  2.     {
  3.         $username            = trim($this->post('username'));
  4.         $id                  = $this->post('id');
  5.         $id_fbangun          = trim($this->post('id_fbangun'));
  6.         $id_jenisbangun      = trim($this->post('id_jenisbangun'));
  7.         $id_statustanah      = trim($this->post('id_statustanah'));
  8.         $kecamatan_id_lokasi = trim($this->post('kecamatan_id_lokasi'));
  9.         $desa_id_lokasi      = trim($this->post('desa_id_lokasi'));
  10.         $nop                 = trim($this->post('nop'));
  11.  
  12.         if ($username == '') {
  13.             $response = [
  14.                 'resp_error' => true,
  15.                 'resp_msg'   => 'Username Kosong.',
  16.             ];
  17.         } elseif ($id == '') {
  18.             $response = [
  19.                 'resp_error' => true,
  20.                 'resp_msg'   => 'ID Permohonan Tidak di Temukan.',
  21.             ];
  22.         } elseif ($id_fbangun == '') {
  23.             $response = [
  24.                 'resp_error' => true,
  25.                 'resp_msg'   => 'Fungsi Utama Bangunan belum dipilih.',
  26.             ];
  27.         } elseif ($id_jenisbangun == '') {
  28.             $response = [
  29.                 'resp_error' => true,
  30.                 'resp_msg'   => 'Jenis Bangunan belum dipilih.',
  31.             ];
  32.         } elseif ($id_statustanah == '') {
  33.             $response = [
  34.                 'resp_error' => true,
  35.                 'resp_msg'   => 'Status Tanah belum dipilih.',
  36.             ];
  37.         } elseif ($kecamatan_id_lokasi == '') {
  38.             $response = [
  39.                 'resp_error' => true,
  40.                 'resp_msg'   => 'Kecamatan Lokasi Bangunan belum dipilih.',
  41.             ];
  42.         } elseif ($desa_id_lokasi == '') {
  43.             $response = [
  44.                 'resp_error' => true,
  45.                 'resp_msg'   => 'Desa/Kelurahan Lokasi Bangunan belum dipilih.',
  46.             ];
  47.         } elseif ($nop == '') {
  48.             $response = [
  49.                 'resp_error' => true,
  50.                 'resp_msg'   => 'N.O.P belum diisi.',
  51.             ];
  52.         } else {
  53.             // Ubah Status ke Belum Validasi
  54.             $data = array(
  55.                 'tanggal'    => date('Y-m-d'),
  56.                 'sts_proses' => 0,
  57.             );
  58.  
  59.             $this->db->where('id', $id);
  60.             $this->db->update('c39_imb_pemohon', $data);
  61.  
  62.             // Insert Data ke Tabel Notifikasi
  63.             $dataijin  = $this->db->get_where('v_imb_dpm', array('id' => $id))->row();
  64.             $pesan     = 'Permohonan Baru IMB No. ' . $dataijin->no_register . ' Atas Nama : ' . $dataijin->nama;
  65.             $dataNotif = array(
  66.                 'user_pengirim'          => $username,
  67.                 'user_username'          => $username,
  68.                 'id'                     => $id,
  69.                 'notifikasi_no_register' => $dataijin->no_register,
  70.                 'notifikasi_date'        => date('Y-m-d'),
  71.                 'notifikasi_desc'        => $pesan,
  72.                 'notifikasi_level'       => 'Front Office',
  73.             );
  74.  
  75.             $this->db->insert('bpmppt_notifikasi', $dataNotif);
  76.  
  77.             // Kirim Notifikasi
  78.             $listUser = $this->db->get_where('bpmppt_users', array('device_id !=' => '', 'user_level' => 'Front Office'))->result();
  79.             if (count($listUser) > 0) {
  80.                 foreach ($listUser as $r) {
  81.                     sendNotification($r->device_id, $pesan);
  82.                 }
  83.             }
  84.  
  85.             $response = [
  86.                 'resp_error' => false,
  87.                 'resp_msg'   => 'Permohonan Berhasil Terkirim.',
  88.             ];
  89.         }
  90.  
  91.         $this->response($response, 200);
  92.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement