Advertisement
yhoezt_27

Untitled

Aug 7th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.87 KB | None | 0 0
  1. function index($offset=0,$order_column='id',$order_type='asc')
  2. {
  3. $user = $this->session->userdata('username');
  4. $user_lvl = $this->session->userdata('level');
  5.  
  6. if ($user_lvl == '1')
  7. {
  8. $cek_jns_client = $this->m_all->cekList('tb_jenis_client','jenis_client','0','hapus');
  9. $cek_type_client = $this->m_all->cekList('tb_type_client','type_client','0','hapus');
  10. $check_hapus_jenis_client = $this->m_all->cari('1', NULL, NULL, NULL, NULL, 'hapus', NULL, NULL, 'tb_jenis_client');
  11. $check_hapus_type_client = $this->m_all->cari('1', NULL, NULL, NULL, NULL, 'hapus', NULL, NULL, 'tb_type_client');
  12. }
  13. else
  14. {
  15. $cek_jns_client = $this->m_all->cari('0', $user,'','','','hapus','user','','tb_jenis_client');
  16. $cek_type_client = $this->m_all->cari('0', $user,'','','','hapus','user','','tb_type_client');
  17. $check_hapus_jenis_client = $this->m_all->cari('1', $user, NULL, NULL, NULL, 'hapus', 'user', NULL, 'tb_jenis_client');
  18. $check_hapus_type_client = $this->m_all->cari('1',$user, NULL, NULL, NULL, 'hapus', 'user', NULL, 'tb_type_client');
  19. }
  20.  
  21. if($this->m_all->cekList('tb_jenis_client','jenis_client','0','hapus')->num_rows() > 0)
  22. {
  23. if($this->m_all->cekList('tb_type_client','type_client','0','hapus')->num_rows() > 0)
  24. {
  25. if($this->m_all->cekList('kota_kabupaten','kota_kabupaten')->num_rows() > 0)
  26. {
  27. //cari($cari, $cari1 = NULL, $cari2 = NULL, $limit = NULL, $offset = NULL, $primary, $jenis1 = NULL, $jenis2 = NULL,$table)
  28.  
  29. $tgl = date('Y/m/d');
  30.  
  31. $info = array(
  32. 'updated' => $tgl,
  33. 'username' => $user,
  34. 'hapus' => '1'
  35. );
  36.  
  37. $check_hapus_jenis_client = $this->m_all->cari('1', NULL, NULL, NULL, NULL, 'hapus', NULL, NULL, 'tb_jenis_client');
  38. if ($check_hapus_jenis_client->num_rows() > 0)
  39. {
  40. foreach ($check_hapus_jenis_client->result() as $rows)
  41. {
  42. $check_jenis_data_client = $this->m_all->cari($rows->id_jenis_client,'0',NULL, NULL, NULL,'SUBSTRING_INDEX(SUBSTRING_INDEX(id_client,"_",2),"_",-1)', 'hapus', NULL, $this->table);
  43. if ($check_jenis_data_client->num_rows() > 0)
  44. {
  45. foreach ($check_jenis_data_client->result() as $cjdc)
  46. {
  47. $this->m_all->update($cjdc->id_client, $info, 'id_client', $this->table);
  48. }
  49. }
  50. }
  51. }
  52.  
  53. $check_hapus_type_client = $this->m_all->cari('1', NULL, NULL, NULL, NULL, 'hapus', NULL, NULL, 'tb_type_client');
  54. if ($check_hapus_type_client->num_rows() > 0)
  55. {
  56. foreach ($check_hapus_type_client->result() as $value)
  57. {
  58. $check_type_data_client = $this->m_all->cari($value->id_type_client,'0',NULL,NULL,NULL,'SUBSTRING_INDEX(id_client,"_",1)','hapus', NULL, $this->table);
  59. if ($check_type_data_client->num_rows() > 0)
  60. {
  61. foreach ($check_type_data_client->result() as $ctdc)
  62. {
  63. $this->m_all->update($ctdc->id_client, $info, 'id_client', $this->table);
  64. }
  65. }
  66. }
  67. }
  68.  
  69. if(empty($offset)) $offset=0;
  70. if(empty($order_column)) $order_column='id';
  71. if(empty($order_type)) $order_type='asc';
  72.  
  73. $data_client = $this->m_all->semua($this->table, $this->limit ,$offset=0);
  74.  
  75. //if ($data_client->num_rows() > 0)
  76. //{
  77. $config['base_url']= site_url('data_client/index');
  78. $config['total_rows']=$data_client->num_rows();
  79. $config['per_page']=$this->limit;
  80. $config['uri_segment']=3;
  81. $this->pagination->initialize($config);
  82.  
  83. if($this->uri->segment(3)=="delete_success")
  84. {
  85. ?>
  86. <script type="text/javascript">
  87. alert("Data berhasil dihapus");
  88. </script>
  89. <?php
  90. echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index')."'>";
  91. }
  92. else if($this->uri->segment(3)=="add_success")
  93. {
  94. ?>
  95. <script type="text/javascript">
  96. alert("Data Berhasil disimpan");
  97. </script>
  98. <?php
  99. echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index')."'>";
  100. }
  101.  
  102. $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
  103. $var = explode('+', $ktgr_alamat);
  104.  
  105. $data['kategori'] = $var['0'];
  106. $data['alamat'] = $var['1'];
  107. $data['data_client'] = $data_client->result_array();
  108. $data['alamat1'] = 'data_client/index';
  109. $data['title']="Index Data Client";
  110. //getList($table, $primary, $spek = NULL, $input_post = NULL)
  111. $data['list_type_client'] = $this->m_all->getList('tb_type_client', 'id_type_client', NULL, '0');
  112. $data['list_jns_client'] = $this->m_all->getList('tb_jenis_client', 'id_jenis_client', NULL, '0');
  113. $data['pagination']=$this->pagination->create_links();
  114.  
  115. $this->template->display('data_client/index',$data);
  116. //}
  117. //else
  118. //{
  119. //
  120. // echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/tambah')."'>";
  121. //}
  122. }
  123. else
  124. {
  125. ?>
  126. <script type="text/javascript">
  127. alert("Data Kota-Kabupaten-Propinsi masih kosong, konfirmasi ke Admin");
  128. </script>
  129. <?php
  130. echo "<meta http-equiv='refresh' content='0; url=".site_url('dashboard/index')."'>";
  131. }
  132. }
  133. else
  134. {
  135. ?>
  136. <script type="text/javascript">
  137. alert("Data Type-Client masih kosong, harap di-isi terlebih dahulu");
  138. </script>
  139. <?php
  140. echo "<meta http-equiv='refresh' content='0; url=".site_url('type_client/index')."'>";
  141. }
  142. }
  143. else
  144. {
  145. ?>
  146. <script type="text/javascript">
  147. alert("Data Jenis-Client masih kosong, harap di-isi terlebih dahulu");
  148. </script>
  149. <?php
  150. echo "<meta http-equiv='refresh' content='0; url=".site_url('jenis_client/index')."'>";
  151. }
  152. }
  153.  
  154. function get_client($id)
  155. {
  156. $nama_petugas = '';
  157. $cari = $this->m_all->cari($id, NULL, NULL, NULL, NULL, $this->primary, NULL, NULL, $this->table);
  158. $get_petugas = $this->m_all->getNama('data_client', $id, NULL, 'client', 'kd');
  159. if ($get_petugas->num_rows() > 0)
  160. {
  161. foreach ($get_petugas->result() as $gp)
  162. {
  163. $nama_petugas = $gp->client;
  164. }
  165. }
  166.  
  167. $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
  168. $var = explode('+', $ktgr_alamat);
  169.  
  170. $data['kategori'] = $var['0'];
  171. $data['alamat'] = $var['1'];
  172. $data['cari_client'] = $cari->result_array();
  173. $data['alamat1'] = 'data_client/index';
  174. $data['title']="Index Data Client";
  175. $data['title1']='Get '.$nama_petugas;
  176.  
  177. $this->template->display('data_client/get_client', $data);
  178. }
  179.  
  180. function tambah()
  181. {
  182. if(isset($_POST['simpan']))
  183. {
  184. $client = db_clean($this->input->post('client'));
  185. $type = db_clean($this->input->post('id_type_client'));
  186. $jenis = db_clean($this->input->post('id_jenis_client'));
  187.  
  188. if ((!is_null($client)) && (!is_null($type)) && (!is_null($jenis)))
  189. $proses = TRUE;
  190. else $proses = FALSE;
  191.  
  192. if ($proses)
  193. {
  194. $propinsi = db_clean($this->input->post('provinsi_id'));
  195.  
  196. $kota = db_clean($this->input->post('kota_id'));
  197.  
  198. $carikota = $this->m_all->cari($kota, $propinsi, NULL, NULL, NULL, 'kota_id', NULL, NULL, 'kota_kabupaten')->result();
  199.  
  200. foreach ($carikota as $row)
  201. {
  202. $newkota = $row->kota_id;
  203. }
  204.  
  205. $this->_set_rules_tambah();
  206.  
  207. if($this->form_validation->run() == true)
  208. {
  209.  
  210. $arr = array($type, $jenis, $newkota, $propinsi, $client);
  211.  
  212. $telp_1 = db_clean($this->input->post('telp_client_1'));
  213. if (empty($telp_1))
  214. {
  215. $telp_1 = NULL;
  216. }
  217. $telp_2 = db_clean($this->input->post('telp_client_2'));
  218. if(empty($telp_2))
  219. {
  220. $telp_2 = NULL;
  221. }
  222. $pinbbm = db_clean($this->input->post('pin_bbm'));
  223. if(empty($pinbbm))
  224. {
  225. $pinbbm = NULL;
  226. }
  227. $alamat = db_clean($this->input->post('alamat'));
  228. if(empty($alamat))
  229. {
  230. $alamat = NULL;
  231. }
  232.  
  233. $tgl = date('Y/m/d');
  234. $user = $this->session->userdata('username');
  235.  
  236. $info = array(
  237. 'id' => $this->db->insert_id(),
  238. 'id_client' => join('_', $arr),
  239. 'client' => $client,
  240. 'telp_client_1' => $telp_1,
  241. 'telp_client_2' => $telp_2,
  242. 'pin_bbm' => $pinbbm,
  243. 'alamat' => $alamat,
  244. 'updated' => $tgl,
  245. 'username' => $user,
  246. 'keterangan' => db_clean($this->input->post('keterangan')),
  247. 'hapus' => '0'
  248. );
  249.  
  250. $this->m_all->simpan($info, $this->table);
  251. echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index/add_success')."'>";
  252. }
  253. else
  254. {
  255. ?>
  256. <script type="text/javascript">
  257. alert("Harap Periksa Validitas Data");
  258. </script>
  259. <?php
  260. echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/tambah')."'>";
  261. }
  262. }
  263. else
  264. {
  265. ?>
  266. <script type="text/javascript">
  267. alert("Penambahan data tidak boleh kosong");
  268. </script>
  269. <?php
  270. echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/tambah')."'>";
  271. }
  272. }
  273.  
  274. if (isset($_POST['cancel']))
  275. {
  276. echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index')."'>";
  277. }
  278.  
  279. $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
  280. $var = explode('+', $ktgr_alamat);
  281.  
  282. $data['kategori'] = $var['0'];
  283. $data['alamat'] = $var['1'];
  284. $data['alamat1'] = 'data_client/index';
  285. $data['title']="Index Data Client";
  286. $data['alamat2'] = 'data_client/tambah';
  287. $data['title1'] = 'Tambah Data';
  288. $data['list_type_client'] = $this->m_all->getList('tb_type_client','id_type_client', null,'0');
  289. $data['list_jns_client'] = $this->m_all->getList('tb_jenis_client','id_jenis_client', null, '0');
  290. $data['list_propinsi'] = $this->m_all->getList('propinsi','propinsi_id', null, null);
  291.  
  292. $this->template->display('data_client/tambah', $data);
  293. }
  294.  
  295. function select_kota()
  296. {
  297. if('IS_AJAX')
  298. {
  299. $data['list_kota'] = $this->m_all->getList('kota_kabupaten','kota_id', null, $this->input->post('propinsi_id'));
  300. //$data['option_kota'] = $this->MChain->getKotaList();
  301. $this->load->view('data_client/kota',$data);
  302. }
  303. else echo 'ajax gagal';
  304. }
  305.  
  306. function cari()
  307. {
  308. $id_jns_client = db_clean($this->input->post('id_jenis_client'));
  309. $id_type_client = db_clean($this->input->post('id_type_client'));
  310.  
  311. if (($id_jns_client != '0') && ($id_type_client != '0'))
  312. {
  313. if(empty($offset)) $offset=0;
  314. if(empty($order_column)) $order_column='id';
  315. if(empty($order_type)) $order_type='asc';
  316.  
  317. $cek=$this->m_all->cari($id_type_client.'_'.$id_jns_client,'','',$this->limit,$offset,'SUBSTRING_INDEX(id_client,"_",2)', '','',$this->table);
  318.  
  319. if ($cek->num_rows() > 0)
  320. {
  321. $nama_type = '';
  322. $nama_jenis = '';
  323.  
  324. $config['base_url']= site_url('data_client/cari');
  325. $config['total_rows']=$cek->num_rows();
  326. $config['per_page']=$this->limit;
  327. $config['uri_segment']=3;
  328. $this->pagination->initialize($config);
  329.  
  330. $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
  331. $var = explode('+', $ktgr_alamat);
  332.  
  333. $get_nm_type = $this->m_all->getNama('tb_type_client', $id_type_client, NULL, 'type_client', 'id_type_client');
  334. if ($get_nm_type->num_rows() > 0)
  335. {
  336. foreach ($get_nm_type->result() as $gnt)
  337. {
  338. $nama_type = $gnt->type_client;
  339. }
  340. }
  341.  
  342. $get_nm_jns = $this->m_all->getNama('tb_jenis_client', $id_jns_client, NULL, 'jenis_client', 'id_jenis_client');
  343. if ($get_nm_jns->num_rows() > 0)
  344. {
  345. foreach ($get_nm_jns->result() as $gnj)
  346. {
  347. $nama_jenis = $gnj->jenis_client;
  348. }
  349. }
  350.  
  351. $data['kategori'] = $var['0'];
  352. $data['alamat'] = $var['1'];
  353. $data['alamat1'] = 'data_client/index';
  354. $data['title']="Index Data Client";
  355. $data['title1'] = 'Browse : '.$nama_type.'/'.$nama_jenis;
  356. $data['pagination']=$this->pagination->create_links();
  357. $data['cari_client']=$cek->result_array();
  358. $this->template->display('data_client/cari',$data);
  359. }
  360. else
  361. {
  362. ?>
  363. <script type="text/javascript">
  364. alert("Tidak Terdapat Data");
  365. </script>
  366. <?php
  367. echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index')."'>";
  368. }
  369. }
  370. }
  371.  
  372.  
  373. function edit($id)
  374. {
  375. $kode= $this->input->post('id');
  376.  
  377. if($kode)
  378. {
  379. if (isset($_POST['simpan']))
  380. {
  381. $hapus = $this->input->post('hapus');
  382.  
  383. if (!empty($hapus))
  384. {
  385. if (!is_null($hapus))
  386. {
  387. if (is_numeric($hapus))
  388. {
  389. if (($hapus == '1') || ($hapus == '0'))
  390. $valid_hapus = TRUE;
  391. else $valid_hapus = FALSE;
  392. }
  393. else $valid_hapus = FALSE;
  394. }
  395. else $valid_hapus = FALSE;
  396. }
  397. else $valid_hapus = TRUE;
  398.  
  399. if ($valid_hapus == TRUE)
  400. {
  401. $tgl = date('Y/m/d');
  402. $user = $this->session->userdata('username');
  403.  
  404. $info = array(
  405. 'alamat' => db_clean($this->input->post('alamat')),
  406. 'telp_client_1' => db_clean($this->input->post('telp_client_1')),
  407. 'telp_client_2' => db_clean($this->input->post('telp_client_2')),
  408. 'pin_bbm' => db_clean($this->input->post('pin_bbm')),
  409. 'updated' => $tgl,
  410. 'username' => $user,
  411. 'keterangan' => db_clean($this->input->post('keterangan')),
  412. 'hapus' => $hapus
  413. );
  414.  
  415. $this->m_all->update($kode, $info, $this->primary, $this->table);
  416. redirect('data_client/index');
  417. }
  418. else
  419. {
  420. ?>
  421. <script type="text/javascript">
  422. alert("Harap periksa kembali validitas data");
  423. </script>
  424. <?php
  425. echo "<meta http-equiv='refresh' content='0;url=".site_url('data_client/edit/'.$kode)."'>";
  426. }
  427. }
  428. }
  429.  
  430. if (isset($_POST['cancel']))
  431. {
  432. redirect('data_client/index');
  433. }
  434.  
  435. $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
  436. $var = explode('+', $ktgr_alamat);
  437.  
  438. $data['kategori'] = $var['0'];
  439. $data['alamat'] = $var['1'];
  440. $data['alamat1'] = 'data_client/index';
  441. $data['title']="Index Data Client";
  442. $data['title1'] = 'Edit Data';
  443. $data['edit_data_client'] = $this->m_all->cek($id, $this->primary, $this->table)->result_array();
  444.  
  445. $this->template->display('data_client/edit', $data);
  446. //}
  447. //else
  448. // echo "<meta http-equiv='refresh' content='0;url=".site_url('data_client/index')."'>";
  449. }
  450.  
  451. function konfirmasi()
  452. {
  453. $kode='';
  454.  
  455. if ($this->uri->segment(3) === FALSE)
  456. $kode='';
  457. else
  458. $kode = $this->uri->segment(3);
  459.  
  460. if ($kode != '')
  461. {
  462.  
  463. $tgl = date('Y/m/d');
  464. $user = $this->session->userdata('username');
  465.  
  466. $info = array(
  467. 'hapus' => '1',
  468. 'updated' => $tgl,
  469. 'username' => $user
  470. );
  471.  
  472. $data["upd"] = $this->m_all->update($kode, $info, $this->primary, $this->table);
  473. echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index/delete_success')."'>";
  474. }
  475. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement