Advertisement
jamboljack

RTLH

Feb 28th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.06 KB | None | 0 0
  1. private function _get_datatables_query_rtlh()
  2.     {
  3.         $anggaran_id = $this->uri->segment(4);
  4.         $no_kec      = $this->uri->segment(5);
  5.         $no_kel      = $this->uri->segment(6);
  6.  
  7.         $this->db->select('rtlh_no_urut, rtlh_post, penduduk_nik, penduduk_nama, penduduk_alamat,
  8.            penduduk_rt, penduduk_rw, nama_kec, nama_kel, rtlh_budget, rtlh_pbdt, rtlh_status,
  9.            rtlh_prioritas');
  10.         $this->db->from('v_rtlh');
  11.         $this->db->where('anggaran_id', $anggaran_id);
  12.         $this->db->where('no_kec', $no_kec);
  13.         $this->db->where('no_kel', $no_kel);
  14.         $this->db->where('rtlh_step', 4);
  15.         $this->db->where_not_in('penduduk_nik', 'SELECT penduduk_nik FROM rtlh_pokmas_anggota');
  16.         // $this->db->get('v_rtlh')->result();
  17.  
  18.         // $sql = 'SELECT rtlh_no_urut, rtlh_post, penduduk_nik, penduduk_nama, penduduk_alamat,
  19.         //     penduduk_rt, penduduk_rw, nama_kec, nama_kel, rtlh_budget, rtlh_pbdt, rtlh_status,
  20.         //     rtlh_prioritas FROM v_rtlh
  21.         //     WHERE anggaran_id = '.$anggaran_id.' AND no_kec='.$no_kec.' AND no_kel='.$no_kel.' AND rtlh_step=4
  22.         //     AND penduduk_nik NOT IN (SELECT penduduk_nik FROM rtlh_pokmas_anggota)';
  23.  
  24.         // $this->db->query($sql)->result();
  25.  
  26.         $i = 0;
  27.         foreach ($this->column_search3 as $item) {
  28.             if ($_POST['search']['value']) {
  29.                 if ($i === 0) {
  30.                     $this->db->group_start();
  31.                     $this->db->like($item, $_POST['search']['value']);
  32.                 } else {
  33.                     $this->db->or_like($item, $_POST['search']['value']);
  34.                 }
  35.                 if (count($this->column_search3) - 1 == $i) {
  36.                     $this->db->group_end();
  37.                 }
  38.             }
  39.             $i++;
  40.         }
  41.  
  42.         if (isset($_POST['order'])) {
  43.             $this->db->order_by($this->column_order3[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);
  44.         } else if (isset($this->order3)) {
  45.             $order = $this->order3;
  46.             $this->db->order_by(key($order), $order[key($order)]);
  47.         }
  48.     }
  49.  
  50.     public function get_datatables_rtlh()
  51.     {
  52.         $this->_get_datatables_query_rtlh();
  53.         if ($_POST['length'] != -1) {
  54.             $this->db->limit($_POST['length'], $_POST['start']);
  55.         }
  56.         $query = $this->db->get();
  57.         return $query->result();
  58.     }
  59.  
  60.     public function count_filtered_rtlh()
  61.     {
  62.         $this->_get_datatables_query_rtlh();
  63.         $query = $this->db->get();
  64.         return $query->num_rows();
  65.     }
  66.  
  67.     public function count_all_rtlh()
  68.     {
  69.         $anggaran_id = $this->uri->segment(4);
  70.         $no_kec      = $this->uri->segment(5);
  71.         $no_kel      = $this->uri->segment(6);
  72.  
  73.         $this->db->from($this->table3);
  74.         $this->db->where('anggaran_id', $anggaran_id);
  75.         $this->db->where('no_kec', $no_kec);
  76.         $this->db->where('no_kel', $no_kel);
  77.         $this->db->where('rtlh_step', 4); // RAB
  78.  
  79.         return $this->db->count_all_results();
  80.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement