jamboljack

Save Data Batas Tanah

Sep 2nd, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.94 KB | None | 0 0
  1. // Simpan Data Batas-Batas Tanah
  2.     public function savedatabatas_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('utara') == '') {
  17.             $response = [
  18.                 'resp_error' => true,
  19.                 'resp_msg'   => 'Batas Utara Tidak Boleh Kosong.',
  20.             ];
  21.         } elseif ($this->post('selatan') == '') {
  22.             $response = [
  23.                 'resp_error' => true,
  24.                 'resp_msg'   => 'Batas Selatan Tidak Boleh Kosong.',
  25.             ];
  26.         } elseif ($this->post('timur') == '') {
  27.             $response = [
  28.                 'resp_error' => true,
  29.                 'resp_msg'   => 'Batas Timur Tidak Boleh Kosong.',
  30.             ];
  31.         } elseif ($this->post('barat') == '') {
  32.             $response = [
  33.                 'resp_error' => true,
  34.                 'resp_msg'   => 'Batas Barat Tidak Boleh Kosong.',
  35.             ];
  36.         } else {
  37.             $id        = $this->post('id');
  38.             $checkdata = $this->db->get_where('c39_imb_bangunan', array('id_pemohon' => $id))->row();
  39.             if (count($checkdata) > 0) {
  40.                 $data = array(
  41.                     'batas_utara'   => strtoupper(trim($this->post('utara', 'true'))),
  42.                     'batas_selatan' => strtoupper(trim($this->post('selatan', 'true'))),
  43.                     'batas_timur'   => strtoupper(trim($this->post('timur', 'true'))),
  44.                     'batas_barat'   => strtoupper(trim($this->post('barat', 'true'))),
  45.                 );
  46.  
  47.                 $this->db->where('id_pemohon', $id);
  48.                 $this->db->update('c39_imb_bangunan', $data);
  49.  
  50.                 $response = [
  51.                     'resp_error' => false,
  52.                     'resp_msg'   => 'Data Batas Bangunan Ter-Update.',
  53.                 ];
  54.             } else {
  55.                 $data = array(
  56.                     'id_pemohon'    => $this->post('id', 'true'),
  57.                     'batas_utara'   => strtoupper(trim($this->post('utara', 'true'))),
  58.                     'batas_selatan' => strtoupper(trim($this->post('selatan', 'true'))),
  59.                     'batas_timur'   => strtoupper(trim($this->post('timur', 'true'))),
  60.                     'batas_barat'   => strtoupper(trim($this->post('barat', 'true'))),
  61.                 );
  62.  
  63.                 $this->db->insert('c39_imb_bangunan', $data);
  64.  
  65.                 $response = [
  66.                     'resp_error' => false,
  67.                     'resp_msg'   => 'Data Batas Bangunan Tersimpan.',
  68.                 ];
  69.             }
  70.         }
  71.  
  72.         $this->response($response, 200);
  73.     }
Add Comment
Please, Sign In to add comment