Advertisement
jamboljack

Save Data Lokasi Bangunan

Sep 2nd, 2018
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.77 KB | None | 0 0
  1. public function savedatalokasi_post()
  2.     {
  3.         $username = trim($this->post('username'));
  4.  
  5.         if ($username == '') {
  6.             $response = [
  7.                 'resp_error' => true,
  8.                 'resp_msg'   => 'Username Kosong.',
  9.             ];
  10.         } elseif ($this->post('id') == '') {
  11.             $response = [
  12.                 'resp_error' => true,
  13.                 'resp_msg'   => 'ID Permohonan Tidak Boleh Kosong.',
  14.             ];
  15.         } elseif ($this->post('provinsi_id') == '') {
  16.             $response = [
  17.                 'resp_error' => true,
  18.                 'resp_msg'   => 'Provinsi Tidak Boleh Kosong.',
  19.             ];
  20.         } elseif ($this->post('kabupaten_id') == '') {
  21.             $response = [
  22.                 'resp_error' => true,
  23.                 'resp_msg'   => 'Kabupaten Tidak Boleh Kosong.',
  24.             ];
  25.         } elseif ($this->post('kecamatan_id') == '') {
  26.             $response = [
  27.                 'resp_error' => true,
  28.                 'resp_msg'   => 'Kecamatan Tidak Boleh Kosong.',
  29.             ];
  30.         } elseif ($this->post('desa_id') == '') {
  31.             $response = [
  32.                 'resp_error' => true,
  33.                 'resp_msg'   => 'Desa/Kelurahan Tidak Boleh Kosong.',
  34.             ];
  35.         } elseif ($this->post('alamat') == '') {
  36.             $response = [
  37.                 'resp_error' => true,
  38.                 'resp_msg'   => 'Alamat Bangunan Tidak Boleh Kosong.',
  39.             ];
  40.         } elseif ($this->post('jml_lantai') == '') {
  41.             $response = [
  42.                 'resp_error' => true,
  43.                 'resp_msg'   => 'Jumlah Lantai Tidak Boleh Kosong.',
  44.             ];
  45.         } else {
  46.             $id        = $this->post('id');
  47.             $checkdata = $this->db->get_where('c39_imb_bangunan', array('id_pemohon' => $id))->row();
  48.             if (count($checkdata) > 0) {
  49.                 $data = array(
  50.                     'propinsi'           => $this->post('provinsi_id', 'true'),
  51.                     'kabupaten'          => $this->post('kabupaten_id', 'true'),
  52.                     'kecamatan'          => $this->post('kecamatan_id', 'true'),
  53.                     'kelurahan'          => $this->post('desa_id', 'true'),
  54.                     'alamat_bangunan'    => strtoupper(trim($this->post('alamat', 'true'))),
  55.                     'jum_lantai_fsutama' => $this->post('jml_lantai', 'true'),
  56.                     'ket_lantai_lain'    => trim($this->post('keterangan', 'true')),
  57.                 );
  58.  
  59.                 $this->db->where('id_pemohon', $id);
  60.                 $this->db->update('c39_imb_bangunan', $data);
  61.  
  62.                 $response = [
  63.                     'resp_error' => false,
  64.                     'resp_msg'   => 'Data Lokasi Bangunan Ter-Update.',
  65.                 ];
  66.             } else {
  67.                 $data = array(
  68.                     'id_pemohon'         => $this->post('id', 'true'),
  69.                     'propinsi'           => $this->post('provinsi_id', 'true'),
  70.                     'kabupaten'          => $this->post('kabupaten_id', 'true'),
  71.                     'kecamatan'          => $this->post('kecamatan_id', 'true'),
  72.                     'kelurahan'          => $this->post('desa_id', 'true'),
  73.                     'alamat_bangunan'    => strtoupper(trim($this->post('alamat', 'true'))),
  74.                     'jum_lantai_fsutama' => $this->post('jml_lantai', 'true'),
  75.                     'ket_lantai_lain'    => trim($this->post('keterangan', 'true')),
  76.                 );
  77.  
  78.                 $this->db->insert('c39_imb_bangunan', $data);
  79.  
  80.                 $response = [
  81.                     'resp_error' => false,
  82.                     'resp_msg'   => 'Data Lokasi Bangunan Tersimpan.',
  83.                 ];
  84.             }
  85.         }
  86.  
  87.         $this->response($response, 200);
  88.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement