Advertisement
Bannip73

model

Nov 24th, 2020
1,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.49 KB | None | 0 0
  1. function get_data_karyawan($id = null, $offset = null, $limit = null, $order = null, $filters = null)
  2.     {
  3.         $this->db->select("a.id, a.nipbaru, a.nama, a.jabatan, b.nama_unitkerja, b.eselon, a.unit_id, a.foto, a.golongan, a.is_pns, a.unor, a.unker");
  4.         $this->db->from($this->table.' a');
  5.         $this->db->join("m_ehrm_unit b","a.kdunit=b.kode_unit");
  6.        
  7.  
  8.         if ($id == null OR $id == "") {
  9.              // $this->db->where("a.active", "1"); // data tidak aktif tidak ditampilkan
  10.  
  11.             if (!empty($filters)) {
  12.                 if (is_array($filters) && count($filters) >= 1) {
  13.                     $this->db->group_start();
  14.                     $this->db->like('id', $filters[0]['value']);
  15.                     $this->db->or_like('nipbaru', $filters[0]['value']);
  16.                     $this->db->or_like('nama', $filters[0]['value']);
  17.                     $this->db->or_like('jabatan', $filters[0]['value']);
  18.                     $this->db->or_like('unit_id', $filters[0]['value']);
  19.                     $this->db->or_like('eselon', $filters[0]['value']);
  20.                     $this->db->or_like('foto', $filters[0]['value']);
  21.                     $this->db->or_like('golongan', $filters[0]['value']);
  22.                     $this->db->or_like('is_pns', $filters[0]['value']);
  23.                     $this->db->or_like('unor', $filters[0]['value']);
  24.                     $this->db->or_like('unker', $filters[0]['value']);
  25.                     $this->db->group_end();
  26.                 }
  27.             }
  28.  
  29.             if (!empty($order)) {
  30.                 $this->db->order_by($order[0]['field'], $order[0]['dir'], TRUE);
  31.             } else {
  32.                 $this->db->order_by('id');
  33.             }
  34.  
  35.             if (empty($offset)) $offset = 0;
  36.             if (empty($limit)) $limit = 10;
  37.             $this->db->limit($limit, $offset);
  38.  
  39.             $Q = $this->db->get();
  40.             $this->_data = $Q->result();
  41.         } else {
  42.             $this->db->where("id", $id);
  43.  
  44.             $Q = $this->db->get();
  45.             $this->_data = $Q->row();
  46.         }
  47.  
  48.         $Q->free_result();
  49.         return $this->_data;
  50.     }
  51.  
  52.     function get_data_cnt_karyawan($filters = null)
  53.     {
  54.         $this->db->select("count(1) _cnt");
  55.         $this->db->from($this->table.' a');
  56.         $this->db->join("m_ehrm_unit b","a.kdunit=b.kode_unit");
  57.          // $this->db->where("a.active", "1"); // data tidak aktif tidak ditampilkan
  58.  
  59.         if (!empty($filters)) {
  60.             if (is_array($filters) && count($filters) >= 1) {
  61.                 $this->db->group_start();
  62.                 $this->db->like('id', $filters[0]['value']);
  63.                 $this->db->or_like('nipbaru', $filters[0]['value']);
  64.                 $this->db->or_like('nama', $filters[0]['value']);
  65.                 $this->db->or_like('jabatan', $filters[0]['value']);
  66.                 $this->db->or_like('unit_id', $filters[0]['value']);
  67.                 $this->db->or_like('eselon', $filters[0]['value']);
  68.                 $this->db->or_like('foto', $filters[0]['value']);
  69.                 $this->db->or_like('golongan', $filters[0]['value']);
  70.                 $this->db->or_like('is_pns', $filters[0]['value']);
  71.                 $this->db->or_like('unor', $filters[0]['value']);
  72.                 $this->db->or_like('unker', $filters[0]['value']);
  73.                 $this->db->group_end();
  74.             }
  75.         }
  76.  
  77.         $Q = $this->db->get();
  78.         $this->_data = $Q->row()->_cnt;
  79.         $Q->free_result();
  80.         return $this->_data;
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement