Advertisement
jamboljack

Save Data Bangunan

Sep 1st, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.76 KB | None | 0 0
  1. // Simpan Data Bangunan Gedung
  2.     public function savedatabangunan_post()
  3.     {
  4.         $username = trim($this->post('username'));
  5.  
  6.         if ($username == '') {
  7.             $response = [
  8.                 'resp_error' => true,
  9.                 'resp_msg'   => 'Username Kosong.',
  10.             ];
  11.         } elseif ($this->post('id') == '') {
  12.             $response = [
  13.                 'resp_error' => true,
  14.                 'resp_msg'   => 'ID Permohonan Tidak Boleh Kosong.',
  15.             ];
  16.         } elseif ($this->post('id_fbangun') == '') {
  17.             $response = [
  18.                 'resp_error' => true,
  19.                 'resp_msg'   => 'Fungsi Utama Tidak Boleh Kosong.',
  20.             ];
  21.         } elseif ($this->post('id_jenisbangun') == '') {
  22.             $response = [
  23.                 'resp_error' => true,
  24.                 'resp_msg'   => 'Jenis Bangunan Tidak Boleh Kosong.',
  25.             ];
  26.         } else {
  27.             $id        = trim($this->post('id'));
  28.             $checkdata = $this->db->get_where('c39_imb_bangunan', array('id_pemohon' => $id))->row();
  29.             if (count($checkdata) > 0) {
  30.                 $data = array(
  31.                     'id_fbangun'      => $this->post('id_fbangun', 'true'),
  32.                     'id_jenisbangun'  => $this->post('id_jenisbangun', 'true'),
  33.                     'nm_bangunan_gdg' => strtoupper(trim($this->post('nm_bangunan_gdg', 'true'))),
  34.                     'peruntukan'      => strtoupper(trim($this->post('peruntukan', 'true'))),
  35.                     'rencana_kota'    => strtoupper(trim($this->post('rencana_kota', 'true'))),
  36.                 );
  37.  
  38.                 $this->db->where('id_pemohon', $id);
  39.                 $this->db->update('c39_imb_bangunan', $data);
  40.  
  41.                 $response = [
  42.                     'resp_error' => false,
  43.                     'resp_msg'   => 'Data Bangunan Gedung Ter-Update.',
  44.                 ];
  45.             } else {
  46.                 $data = array(
  47.                     'id_pemohon'      => $this->post('id', 'true'),
  48.                     'id_fbangun'      => $this->post('id_fbangun', 'true'),
  49.                     'id_jenisbangun'  => $this->post('id_jenisbangun', 'true'),
  50.                     'nm_bangunan_gdg' => strtoupper(trim($this->post('nm_bangunan_gdg', 'true'))),
  51.                     'peruntukan'      => strtoupper(trim($this->post('peruntukan', 'true'))),
  52.                     'rencana_kota'    => strtoupper(trim($this->post('rencana_kota', 'true'))),
  53.                 );
  54.  
  55.                 $this->db->insert('c39_imb_bangunan', $data);
  56.  
  57.                 $response = [
  58.                     'resp_error' => false,
  59.                     'resp_msg'   => 'Data Bangunan Gedung Tersimpan.',
  60.                 ];
  61.             }
  62.         }
  63.  
  64.         $this->response($response, 200);
  65.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement