Advertisement
jamboljack

Save Data Info Tanah

Sep 2nd, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.27 KB | None | 0 0
  1. // Simpan Data Info Tanah
  2.     public function savedatainfotanah_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('luas') == '') {
  17.             $response = [
  18.                 'resp_error' => true,
  19.                 'resp_msg'   => 'Luas Tanah Tidak Boleh Kosong.',
  20.             ];
  21.         } elseif ($this->post('id_statustanah') == '') {
  22.             $response = [
  23.                 'resp_error' => true,
  24.                 'resp_msg'   => 'Status Tanah Tidak Boleh Kosong.',
  25.             ];
  26.         } elseif ($this->post('no_sertifikat') == '') {
  27.             $response = [
  28.                 'resp_error' => true,
  29.                 'resp_msg'   => 'No. Sertifikat Tanah Tidak Boleh Kosong.',
  30.             ];
  31.         } elseif ($this->post('pemilik') == '') {
  32.             $response = [
  33.                 'resp_error' => true,
  34.                 'resp_msg'   => 'Nama Pemilik Tanah Tidak Boleh Kosong.',
  35.             ];
  36.         } elseif ($this->post('nop') == '') {
  37.             $response = [
  38.                 'resp_error' => true,
  39.                 'resp_msg'   => 'N.O.P Tidak Boleh Kosong.',
  40.             ];
  41.         } else {
  42.             $id        = $this->post('id');
  43.             $checkdata = $this->db->get_where('c39_imb_bangunan', array('id_pemohon' => $id))->row();
  44.             if (count($checkdata) > 0) {
  45.                 $data = array(
  46.                     'luas_tanah'        => $this->post('luas', 'true'),
  47.                     'id_statustanah'    => $this->post('id_statustanah', 'true'),
  48.                     'nomor_statustanah' => trim($this->post('no_sertifikat', 'true')),
  49.                     'pemilik_tanah'     => strtoupper(trim($this->post('pemilik', 'true'))),
  50.                     'nop'               => trim($this->post('nop', 'true')),
  51.                 );
  52.  
  53.                 $this->db->where('id_pemohon', $id);
  54.                 $this->db->update('c39_imb_bangunan', $data);
  55.  
  56.                 $response = [
  57.                     'resp_error' => false,
  58.                     'resp_msg'   => 'Data Info Tanah Ter-Update.',
  59.                 ];
  60.             } else {
  61.                 $data = array(
  62.                     'id_pemohon'        => $this->post('id', 'true'),
  63.                     'luas_tanah'        => $this->post('luas', 'true'),
  64.                     'id_statustanah'    => $this->post('id_statustanah', 'true'),
  65.                     'nomor_statustanah' => trim($this->post('no_sertifikat', 'true')),
  66.                     'pemilik_tanah'     => strtoupper(trim($this->post('pemilik', 'true'))),
  67.                     'nop'               => trim($this->post('nop', 'true')),
  68.                 );
  69.  
  70.                 $this->db->insert('c39_imb_bangunan', $data);
  71.  
  72.                 $response = [
  73.                     'resp_error' => false,
  74.                     'resp_msg'   => 'Data Info Tanah Tersimpan.',
  75.                 ];
  76.             }
  77.         }
  78.  
  79.         $this->response($response, 200);
  80.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement