Advertisement
rahmatrian

controler

Mar 18th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.63 KB | None | 0 0
  1. public function updatedb($id)
  2. {
  3. $this->form_validation->set_rules('nama', 'Nama Lengkap', 'trim|required');
  4. $this->form_validation->set_rules('tempat', 'tempatlahir', 'trim|required');
  5. $this->form_validation->set_rules('tanggallahir', 'tanggallahir', 'trim|required');
  6. $this->form_validation->set_rules('kebangsaan', 'kebangsaan', 'required');
  7. $this->form_validation->set_rules('agama', 'agama', 'trim|required');
  8. $this->form_validation->set_rules('jk', 'jk', 'trim|required');
  9. $this->form_validation->set_rules('kawin', 'status', 'trim|required');
  10. $this->form_validation->set_rules('pekerjaan', 'pekerjaan', 'trim|required');
  11. $this->form_validation->set_rules('alamat_sekarang', 'alamat', 'trim|required');
  12.  
  13. if ($this->form_validation->run() == FALSE) {
  14. $data['title'] = ''; // set title pada tiap halaman website
  15. $data['page'] = 'updatedb'; // load file halaman
  16. $data['jk'] = $this->m_admin->getData('jeniskelamin');
  17. $data['agama'] = $this->m_admin->getData('agama');
  18. $data['status'] = $this->m_admin->getData('kawin');
  19. $data['db'] = $this->m_admin->getdbid($id);
  20. $data['lampiran'] = $this->m_admin->getlampiranid($id);
  21. $this->load->view('admin/master', $data); // load file master di folder home
  22. } else {
  23. $object = array(
  24.  
  25. 'nama_lengkap' => $this->input->post('nama'),
  26. 'tempatlahir' => $this->input->post('tempat'),
  27. 'tanggallahir' => $this->input->post('tanggallahir'),
  28. 'agama' => $this->input->post('agama'),
  29. 'kebangsaan' => $this->input->post('kebangsaan'),
  30. 'jk' => $this->input->post('jk'),
  31. 'ktp' => $this->input->post('no_ktp'),
  32. 'sidik_jari_1' => $this->input->post('kanan'),
  33. 'sidik_jari_2' => $this->input->post('kiri'),
  34. 'kawin' => $this->input->post('kawin'),
  35. 'pekerjaan' => $this->input->post('pekerjaan'),
  36. 'alamat' => $this->input->post('alamat_sekarang'),
  37. 'status' => 1,
  38. );
  39. $where = "id = ".$id;
  40. $this->m_admin->updateData('dta_pribadi', $object, $where);
  41.  
  42. if (!empty($_FILES['foto']['name'])) {
  43. // file uploading params
  44. $config['upload_path'] = './assets/files/foto/';
  45. $config['allowed_types'] = 'gif|jpg|png|PNG|jpeg';
  46. $config['remove_spaces'] = FALSE;
  47. // load upload library
  48. $this->load->library('upload' , $config,'fotoupload');
  49.  
  50.  
  51. if ( ! $this->fotoupload->do_upload('foto')){
  52. $error = array('error' => $this->upload->display_errors());
  53. // please do some display error here.
  54. } else {
  55. // remove old images
  56. $this->delFile('./assets/files/foto/', $this->input->post('filefoto'));
  57. $imgData = $this->fotoupload->data();
  58. }
  59.  
  60.  
  61. $object = array(
  62.  
  63.  
  64. 'foto' => $imgData['file_name'],
  65. 'ktp' => $this->input->post('filektp'),
  66. 'akta' => $this->input->post('fileakta'),
  67. 'kk' => $this->input->post('filekk'),
  68.  
  69.  
  70.  
  71. );
  72. // update data
  73. $where = "id = ".$this->input->post('txtId');
  74.  
  75. $this->m_admin->updateData('lampiran', $object, $where);
  76.  
  77.  
  78. }
  79.  
  80. if (!empty($_FILES['ktp']['name'])) {
  81. // file uploading params
  82. $config['upload_path'] = './assets/files/ktp/';
  83. $config['allowed_types'] = 'gif|jpg|png|PNG|jpeg';
  84. $config['remove_spaces'] = FALSE;
  85. // load upload library
  86. $this->load->library('upload' , $config, 'ktpupload');
  87.  
  88.  
  89. if ( ! $this->ktpupload->do_upload('ktp')){
  90. $error = array('error' => $this->upload->display_errors());
  91. // please do some display error here.
  92. } else {
  93. // remove old images
  94. $this->delFile('./assets/files/ktp/', $this->input->post('filefoto'));
  95. $ktpData = $this->ktpupload->data();
  96. }
  97.  
  98.  
  99. $object = array(
  100.  
  101.  
  102. 'ktp' => $ktpData['file_name'],
  103. 'kk' => $this->input->post('filekk'),
  104. 'akta' => $this->input->post('fileakta'),
  105. 'foto' => $this->input->post('filefoto'),
  106.  
  107.  
  108.  
  109. );
  110. // update data
  111. $where = "id = ".$this->input->post('txtId');
  112.  
  113. $this->m_admin->updateData('lampiran', $object, $where);
  114.  
  115.  
  116. }
  117.  
  118. if (!empty($_FILES['akta']['name'])) {
  119. // file uploading params
  120. $config['upload_path'] = './assets/files/akta/';
  121. $config['allowed_types'] = 'gif|jpg|png|PNG|jpeg';
  122. $config['remove_spaces'] = FALSE;
  123. // load upload library
  124. $this->load->library('upload' , $config, 'aktaupload');
  125.  
  126.  
  127. if ( ! $this->aktaupload->do_upload('akta')){
  128. $error = array('error' => $this->upload->display_errors());
  129. // please do some display error here.
  130. } else {
  131. // remove old images
  132. $this->delFile('./assets/files/akta/', $this->input->post('filefoto'));
  133. $aktaData = $this->aktaupload->data();
  134. }
  135.  
  136.  
  137. $object = array(
  138.  
  139.  
  140. 'akta' => $aktaData['file_name'],
  141. 'kk' => $this->input->post('filekk'),
  142. 'ktp' => $this->input->post('filektp'),
  143. 'foto' => $this->input->post('filefoto'),
  144.  
  145.  
  146. );
  147. // update data
  148. $where = "id = ".$this->input->post('txtId');
  149.  
  150. $this->m_admin->updateData('lampiran', $object, $where);
  151.  
  152.  
  153. }
  154.  
  155.  
  156. if (!empty($_FILES['kk']['name'])) {
  157. // file uploading params
  158. $config['upload_path'] = './assets/files/keluarga/';
  159. $config['allowed_types'] = 'gif|jpg|png|PNG|jpeg';
  160. $config['remove_spaces'] = FALSE;
  161. // load upload library
  162. $this->load->library('upload' , $config, 'kkupload');
  163.  
  164.  
  165. if ( ! $this->kkupload->do_upload('kk')){
  166. $error = array('error' => $this->upload->display_errors());
  167. // please do some display error here.
  168. } else {
  169. // remove old images
  170. $this->delFile('./assets/files/keluarga/', $this->input->post('filefoto'));
  171. $kkData = $this->kkupload->data();
  172. }
  173.  
  174.  
  175. $object = array(
  176.  
  177.  
  178. 'kk' => $kkData['file_name'],
  179. 'ktp' => $this->input->post('filektp'),
  180. 'akta' => $this->input->post('fileakta'),
  181. 'foto' => $this->input->post('filefoto'),
  182.  
  183.  
  184. );
  185. // update data
  186. $where = "id = ".$this->input->post('txtId');
  187.  
  188. $this->m_admin->updateData('lampiran', $object, $where);
  189.  
  190.  
  191. }
  192.  
  193.  
  194. $this->session->set_flashdata("pesan", "<script>alert('Data berhasil disimpan.');</script>");
  195. redirect(base_url('admin/db'),'refresh');
  196. }
  197.  
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement