Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Simpan Data dari Member
- public function savedata_post()
- {
- $username = trim($this->post('username'));
- if ($username == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Username Kosong.',
- ];
- } elseif ($this->post('nama') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Nama Pemohon Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('tempat_lahir') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Tempat Lahir Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('tanggal_lahir') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Tanggal Lahir Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('alamat') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Alamat Pemohon Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('provinsi_id') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Provinsi Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('kabupaten_id') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Kabupaten Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('kecamatan_id') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Kecamatan Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('desa_id') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Desa/Kelurahan Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('kode_pos') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Kode Pos Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('email') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Email Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('no_telepon') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'No. Telepon Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('no_ktp') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'No. KTP Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('pekerjaan') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Pekerjaan Tidak Boleh Kosong.',
- ];
- } elseif ($this->post('id_imb') == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Jenis IMB Tidak Boleh Kosong.',
- ];
- } else {
- $id = $this->post('id');
- $checkdata = $this->db->get_where('c39_imb_pemohon', array('id' => $id))->row();
- if (count($checkdata) > 0) {
- // Update Data
- $data = array(
- 'nama' => strtoupper(trim($this->post('nama'))),
- 'tempat_lahir' => strtoupper(trim($this->post('tempat_lahir'))),
- 'tanggal_lahir' => date('Y-m-d', strtotime($this->post('tanggal_lahir'))),
- 'alamat' => strtoupper(trim($this->post('alamat'))),
- 'provinsi_id' => $this->post('provinsi_id'),
- 'kabupaten_id' => $this->post('kabupaten_id', 'true'),
- 'kecamatan_id' => $this->post('kecamatan_id', 'true'),
- 'desa_id' => $this->post('desa_id', 'true'),
- 'kode_pos' => trim($this->post('kode_pos')),
- 'email' => trim($this->post('email')),
- 'no_telepon' => trim($this->post('no_telepon')),
- 'no_ktp' => trim($this->post('no_ktp')),
- 'pekerjaan' => strtoupper(trim($this->post('pekerjaan'))),
- 'id_imb' => trim($this->post('id_imb')),
- 'pemohon_date_update' => date('Y-m-d'),
- 'pemohon_time_update' => date('Y-m-d H:i:s'),
- );
- $this->db->where('id', $id);
- $this->db->update('c39_imb_pemohon', $data);
- $dataPerus = array(
- 'nama_pemilik' => strtoupper(trim($this->post('nama_pemilik'))),
- 'alamat_prsh' => strtoupper(trim($this->post('alamat_prsh'))),
- 'telp_prsh' => trim($this->post('telp_prsh')),
- 'fax_prsh' => trim($this->post('fax_prsh')),
- 'email_prsh' => trim($this->post('email_prsh')),
- 'nama_pjwb' => strtoupper(trim($this->post('nama_pjwb'))),
- );
- $this->db->where('id_pemohon', $id);
- $this->db->update('c39_imb_perusahaan', $dataPerus);
- $response = [
- 'resp_error' => false,
- 'resp_msg' => 'Data Permohonan Ter-Update.',
- ];
- } else {
- $no_register = $this->db->get_where('c39_imb_noreg_tmp', array('tahun' => date('Y')))->row();
- if (count($no_register) > 0) {
- $xno = $no_register->nomor;
- $zno = ($xno + 1);
- } else {
- $zno = 1;
- }
- $noreg = $zno . "." . date('m') . "/IMB.SIPTO/15.04/" . date('Y');
- $query = $this->db->get('c39_imb_noreg_tmp');
- if ($query->num_rows() > 0) {
- $data_reg = array(
- 'nomor' => trim($zno),
- 'tahun' => date('Y'),
- 'no_reg' => trim($noreg),
- );
- $this->db->where('id', 1);
- $this->db->update('c39_imb_noreg_tmp', $data_reg);
- } else {
- $data_reg = array(
- 'nomor' => trim($zno),
- 'tahun' => trim($thn),
- 'no_reg' => trim($noreg),
- );
- $this->db->insert('c39_imb_noreg_tmp', $data_reg);
- }
- $data = array(
- 'user_username' => $username,
- 'tanggal' => date('Y-m-d'),
- 'no_register' => trim($noreg),
- 'nama' => strtoupper(trim($this->post('nama'))),
- 'tempat_lahir' => strtoupper(trim($this->post('tempat_lahir'))),
- 'tanggal_lahir' => date('Y-m-d', strtotime($this->post('tanggal_lahir'))),
- 'alamat' => strtoupper(trim($this->post('alamat'))),
- 'provinsi_id' => $this->post('provinsi_id'),
- 'kabupaten_id' => $this->post('kabupaten_id', 'true'),
- 'kecamatan_id' => $this->post('kecamatan_id', 'true'),
- 'desa_id' => $this->post('desa_id', 'true'),
- 'kode_pos' => trim($this->post('kode_pos')),
- 'email' => trim($this->post('email')),
- 'no_telepon' => trim($this->post('no_telepon')),
- 'no_ktp' => trim($this->post('no_ktp')),
- 'pekerjaan' => strtoupper(trim($this->post('pekerjaan'))),
- 'id_imb' => trim($this->post('id_imb')),
- 'pemohon_date_update' => date('Y-m-d'),
- 'pemohon_time_update' => date('Y-m-d H:i:s'),
- );
- $this->db->insert('c39_imb_pemohon', $data);
- $id = $this->db->insert_id();
- $dataPerus = array(
- 'id_pemohon' => $id,
- 'nama_pemilik' => strtoupper(trim($this->post('nama_pemilik'))),
- 'alamat_prsh' => strtoupper(trim($this->post('alamat_prsh'))),
- 'telp_prsh' => trim($this->post('telp_prsh')),
- 'fax_prsh' => trim($this->post('fax_prsh')),
- 'email_prsh' => trim($this->post('email_prsh')),
- 'nama_pjwb' => strtoupper(trim($this->post('nama_pjwb'))),
- );
- $this->db->insert('c39_imb_perusahaan', $dataPerus);
- $response = [
- 'resp_error' => false,
- 'resp_msg' => 'Data Permohonan Tersimpan.',
- ];
- }
- }
- $this->response($response, 200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement