Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function index($offset=0,$order_column='id',$order_type='asc')
- {
- $user = $this->session->userdata('username');
- $user_lvl = $this->session->userdata('level');
- if ($user_lvl == '1')
- {
- $cek_jns_client = $this->m_all->cekList('tb_jenis_client','jenis_client','0','hapus');
- $cek_type_client = $this->m_all->cekList('tb_type_client','type_client','0','hapus');
- $check_hapus_jenis_client = $this->m_all->cari('1', NULL, NULL, NULL, NULL, 'hapus', NULL, NULL, 'tb_jenis_client');
- $check_hapus_type_client = $this->m_all->cari('1', NULL, NULL, NULL, NULL, 'hapus', NULL, NULL, 'tb_type_client');
- }
- else
- {
- $cek_jns_client = $this->m_all->cari('0', $user,'','','','hapus','user','','tb_jenis_client');
- $cek_type_client = $this->m_all->cari('0', $user,'','','','hapus','user','','tb_type_client');
- $check_hapus_jenis_client = $this->m_all->cari('1', $user, NULL, NULL, NULL, 'hapus', 'user', NULL, 'tb_jenis_client');
- $check_hapus_type_client = $this->m_all->cari('1',$user, NULL, NULL, NULL, 'hapus', 'user', NULL, 'tb_type_client');
- }
- if($this->m_all->cekList('tb_jenis_client','jenis_client','0','hapus')->num_rows() > 0)
- {
- if($this->m_all->cekList('tb_type_client','type_client','0','hapus')->num_rows() > 0)
- {
- if($this->m_all->cekList('kota_kabupaten','kota_kabupaten')->num_rows() > 0)
- {
- //cari($cari, $cari1 = NULL, $cari2 = NULL, $limit = NULL, $offset = NULL, $primary, $jenis1 = NULL, $jenis2 = NULL,$table)
- $tgl = date('Y/m/d');
- $info = array(
- 'updated' => $tgl,
- 'username' => $user,
- 'hapus' => '1'
- );
- $check_hapus_jenis_client = $this->m_all->cari('1', NULL, NULL, NULL, NULL, 'hapus', NULL, NULL, 'tb_jenis_client');
- if ($check_hapus_jenis_client->num_rows() > 0)
- {
- foreach ($check_hapus_jenis_client->result() as $rows)
- {
- $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);
- if ($check_jenis_data_client->num_rows() > 0)
- {
- foreach ($check_jenis_data_client->result() as $cjdc)
- {
- $this->m_all->update($cjdc->id_client, $info, 'id_client', $this->table);
- }
- }
- }
- }
- $check_hapus_type_client = $this->m_all->cari('1', NULL, NULL, NULL, NULL, 'hapus', NULL, NULL, 'tb_type_client');
- if ($check_hapus_type_client->num_rows() > 0)
- {
- foreach ($check_hapus_type_client->result() as $value)
- {
- $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);
- if ($check_type_data_client->num_rows() > 0)
- {
- foreach ($check_type_data_client->result() as $ctdc)
- {
- $this->m_all->update($ctdc->id_client, $info, 'id_client', $this->table);
- }
- }
- }
- }
- if(empty($offset)) $offset=0;
- if(empty($order_column)) $order_column='id';
- if(empty($order_type)) $order_type='asc';
- $data_client = $this->m_all->semua($this->table, $this->limit ,$offset=0);
- //if ($data_client->num_rows() > 0)
- //{
- $config['base_url']= site_url('data_client/index');
- $config['total_rows']=$data_client->num_rows();
- $config['per_page']=$this->limit;
- $config['uri_segment']=3;
- $this->pagination->initialize($config);
- if($this->uri->segment(3)=="delete_success")
- {
- ?>
- <script type="text/javascript">
- alert("Data berhasil dihapus");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index')."'>";
- }
- else if($this->uri->segment(3)=="add_success")
- {
- ?>
- <script type="text/javascript">
- alert("Data Berhasil disimpan");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index')."'>";
- }
- $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
- $var = explode('+', $ktgr_alamat);
- $data['kategori'] = $var['0'];
- $data['alamat'] = $var['1'];
- $data['data_client'] = $data_client->result_array();
- $data['alamat1'] = 'data_client/index';
- $data['title']="Index Data Client";
- //getList($table, $primary, $spek = NULL, $input_post = NULL)
- $data['list_type_client'] = $this->m_all->getList('tb_type_client', 'id_type_client', NULL, '0');
- $data['list_jns_client'] = $this->m_all->getList('tb_jenis_client', 'id_jenis_client', NULL, '0');
- $data['pagination']=$this->pagination->create_links();
- $this->template->display('data_client/index',$data);
- //}
- //else
- //{
- //
- // echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/tambah')."'>";
- //}
- }
- else
- {
- ?>
- <script type="text/javascript">
- alert("Data Kota-Kabupaten-Propinsi masih kosong, konfirmasi ke Admin");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0; url=".site_url('dashboard/index')."'>";
- }
- }
- else
- {
- ?>
- <script type="text/javascript">
- alert("Data Type-Client masih kosong, harap di-isi terlebih dahulu");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0; url=".site_url('type_client/index')."'>";
- }
- }
- else
- {
- ?>
- <script type="text/javascript">
- alert("Data Jenis-Client masih kosong, harap di-isi terlebih dahulu");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0; url=".site_url('jenis_client/index')."'>";
- }
- }
- function get_client($id)
- {
- $nama_petugas = '';
- $cari = $this->m_all->cari($id, NULL, NULL, NULL, NULL, $this->primary, NULL, NULL, $this->table);
- $get_petugas = $this->m_all->getNama('data_client', $id, NULL, 'client', 'kd');
- if ($get_petugas->num_rows() > 0)
- {
- foreach ($get_petugas->result() as $gp)
- {
- $nama_petugas = $gp->client;
- }
- }
- $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
- $var = explode('+', $ktgr_alamat);
- $data['kategori'] = $var['0'];
- $data['alamat'] = $var['1'];
- $data['cari_client'] = $cari->result_array();
- $data['alamat1'] = 'data_client/index';
- $data['title']="Index Data Client";
- $data['title1']='Get '.$nama_petugas;
- $this->template->display('data_client/get_client', $data);
- }
- function tambah()
- {
- if(isset($_POST['simpan']))
- {
- $client = db_clean($this->input->post('client'));
- $type = db_clean($this->input->post('id_type_client'));
- $jenis = db_clean($this->input->post('id_jenis_client'));
- if ((!is_null($client)) && (!is_null($type)) && (!is_null($jenis)))
- $proses = TRUE;
- else $proses = FALSE;
- if ($proses)
- {
- $propinsi = db_clean($this->input->post('provinsi_id'));
- $kota = db_clean($this->input->post('kota_id'));
- $carikota = $this->m_all->cari($kota, $propinsi, NULL, NULL, NULL, 'kota_id', NULL, NULL, 'kota_kabupaten')->result();
- foreach ($carikota as $row)
- {
- $newkota = $row->kota_id;
- }
- $this->_set_rules_tambah();
- if($this->form_validation->run() == true)
- {
- $arr = array($type, $jenis, $newkota, $propinsi, $client);
- $telp_1 = db_clean($this->input->post('telp_client_1'));
- if (empty($telp_1))
- {
- $telp_1 = NULL;
- }
- $telp_2 = db_clean($this->input->post('telp_client_2'));
- if(empty($telp_2))
- {
- $telp_2 = NULL;
- }
- $pinbbm = db_clean($this->input->post('pin_bbm'));
- if(empty($pinbbm))
- {
- $pinbbm = NULL;
- }
- $alamat = db_clean($this->input->post('alamat'));
- if(empty($alamat))
- {
- $alamat = NULL;
- }
- $tgl = date('Y/m/d');
- $user = $this->session->userdata('username');
- $info = array(
- 'id' => $this->db->insert_id(),
- 'id_client' => join('_', $arr),
- 'client' => $client,
- 'telp_client_1' => $telp_1,
- 'telp_client_2' => $telp_2,
- 'pin_bbm' => $pinbbm,
- 'alamat' => $alamat,
- 'updated' => $tgl,
- 'username' => $user,
- 'keterangan' => db_clean($this->input->post('keterangan')),
- 'hapus' => '0'
- );
- $this->m_all->simpan($info, $this->table);
- echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index/add_success')."'>";
- }
- else
- {
- ?>
- <script type="text/javascript">
- alert("Harap Periksa Validitas Data");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/tambah')."'>";
- }
- }
- else
- {
- ?>
- <script type="text/javascript">
- alert("Penambahan data tidak boleh kosong");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/tambah')."'>";
- }
- }
- if (isset($_POST['cancel']))
- {
- echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index')."'>";
- }
- $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
- $var = explode('+', $ktgr_alamat);
- $data['kategori'] = $var['0'];
- $data['alamat'] = $var['1'];
- $data['alamat1'] = 'data_client/index';
- $data['title']="Index Data Client";
- $data['alamat2'] = 'data_client/tambah';
- $data['title1'] = 'Tambah Data';
- $data['list_type_client'] = $this->m_all->getList('tb_type_client','id_type_client', null,'0');
- $data['list_jns_client'] = $this->m_all->getList('tb_jenis_client','id_jenis_client', null, '0');
- $data['list_propinsi'] = $this->m_all->getList('propinsi','propinsi_id', null, null);
- $this->template->display('data_client/tambah', $data);
- }
- function select_kota()
- {
- if('IS_AJAX')
- {
- $data['list_kota'] = $this->m_all->getList('kota_kabupaten','kota_id', null, $this->input->post('propinsi_id'));
- //$data['option_kota'] = $this->MChain->getKotaList();
- $this->load->view('data_client/kota',$data);
- }
- else echo 'ajax gagal';
- }
- function cari()
- {
- $id_jns_client = db_clean($this->input->post('id_jenis_client'));
- $id_type_client = db_clean($this->input->post('id_type_client'));
- if (($id_jns_client != '0') && ($id_type_client != '0'))
- {
- if(empty($offset)) $offset=0;
- if(empty($order_column)) $order_column='id';
- if(empty($order_type)) $order_type='asc';
- $cek=$this->m_all->cari($id_type_client.'_'.$id_jns_client,'','',$this->limit,$offset,'SUBSTRING_INDEX(id_client,"_",2)', '','',$this->table);
- if ($cek->num_rows() > 0)
- {
- $nama_type = '';
- $nama_jenis = '';
- $config['base_url']= site_url('data_client/cari');
- $config['total_rows']=$cek->num_rows();
- $config['per_page']=$this->limit;
- $config['uri_segment']=3;
- $this->pagination->initialize($config);
- $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
- $var = explode('+', $ktgr_alamat);
- $get_nm_type = $this->m_all->getNama('tb_type_client', $id_type_client, NULL, 'type_client', 'id_type_client');
- if ($get_nm_type->num_rows() > 0)
- {
- foreach ($get_nm_type->result() as $gnt)
- {
- $nama_type = $gnt->type_client;
- }
- }
- $get_nm_jns = $this->m_all->getNama('tb_jenis_client', $id_jns_client, NULL, 'jenis_client', 'id_jenis_client');
- if ($get_nm_jns->num_rows() > 0)
- {
- foreach ($get_nm_jns->result() as $gnj)
- {
- $nama_jenis = $gnj->jenis_client;
- }
- }
- $data['kategori'] = $var['0'];
- $data['alamat'] = $var['1'];
- $data['alamat1'] = 'data_client/index';
- $data['title']="Index Data Client";
- $data['title1'] = 'Browse : '.$nama_type.'/'.$nama_jenis;
- $data['pagination']=$this->pagination->create_links();
- $data['cari_client']=$cek->result_array();
- $this->template->display('data_client/cari',$data);
- }
- else
- {
- ?>
- <script type="text/javascript">
- alert("Tidak Terdapat Data");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index')."'>";
- }
- }
- }
- function edit($id)
- {
- $kode= $this->input->post('id');
- if($kode)
- {
- if (isset($_POST['simpan']))
- {
- $hapus = $this->input->post('hapus');
- if (!empty($hapus))
- {
- if (!is_null($hapus))
- {
- if (is_numeric($hapus))
- {
- if (($hapus == '1') || ($hapus == '0'))
- $valid_hapus = TRUE;
- else $valid_hapus = FALSE;
- }
- else $valid_hapus = FALSE;
- }
- else $valid_hapus = FALSE;
- }
- else $valid_hapus = TRUE;
- if ($valid_hapus == TRUE)
- {
- $tgl = date('Y/m/d');
- $user = $this->session->userdata('username');
- $info = array(
- 'alamat' => db_clean($this->input->post('alamat')),
- 'telp_client_1' => db_clean($this->input->post('telp_client_1')),
- 'telp_client_2' => db_clean($this->input->post('telp_client_2')),
- 'pin_bbm' => db_clean($this->input->post('pin_bbm')),
- 'updated' => $tgl,
- 'username' => $user,
- 'keterangan' => db_clean($this->input->post('keterangan')),
- 'hapus' => $hapus
- );
- $this->m_all->update($kode, $info, $this->primary, $this->table);
- redirect('data_client/index');
- }
- else
- {
- ?>
- <script type="text/javascript">
- alert("Harap periksa kembali validitas data");
- </script>
- <?php
- echo "<meta http-equiv='refresh' content='0;url=".site_url('data_client/edit/'.$kode)."'>";
- }
- }
- }
- if (isset($_POST['cancel']))
- {
- redirect('data_client/index');
- }
- $ktgr_alamat = $this->auth->find_ktgr_alamat('data_client/index', 'menu_uri', 'menu', 'id_kategori', 'kategori_menu');
- $var = explode('+', $ktgr_alamat);
- $data['kategori'] = $var['0'];
- $data['alamat'] = $var['1'];
- $data['alamat1'] = 'data_client/index';
- $data['title']="Index Data Client";
- $data['title1'] = 'Edit Data';
- $data['edit_data_client'] = $this->m_all->cek($id, $this->primary, $this->table)->result_array();
- $this->template->display('data_client/edit', $data);
- //}
- //else
- // echo "<meta http-equiv='refresh' content='0;url=".site_url('data_client/index')."'>";
- }
- function konfirmasi()
- {
- $kode='';
- if ($this->uri->segment(3) === FALSE)
- $kode='';
- else
- $kode = $this->uri->segment(3);
- if ($kode != '')
- {
- $tgl = date('Y/m/d');
- $user = $this->session->userdata('username');
- $info = array(
- 'hapus' => '1',
- 'updated' => $tgl,
- 'username' => $user
- );
- $data["upd"] = $this->m_all->update($kode, $info, $this->primary, $this->table);
- echo "<meta http-equiv='refresh' content='0; url=".site_url('data_client/index/delete_success')."'>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement