db->query("SELECT NPWP,NAMA,KATEGORI,TOTAL FROM DASHBOARD_BESAR_MAPKJS WHERE THNBYR = '" . $tahun . "' AND KWLADM = '" . $kwl . "' AND BLNBYR <= '" . $bln . "' AND KATEGORI='" . $kategori . "' $cekkpp $cekseksi $ceknip"); return $query; } function detKat($param) { $tahun = $param['tahun']; $bln = $param['bln']; $kwl = $param['kwl']; $kpp = $param['kpp']; $seksi = $param['seksi']; $nip = $param['nip']; $offset = $param['page']; $limit = $param['perPage']; $kategori = $param['kategori']; if ($kpp == "SEMUA" && $seksi == "SEMUA" && $nip == "SEMUA") { $array = ['KWLADM' => $kwl ]; } else if($kpp != "SEMUA" && $seksi == "SEMUA" && $nip == "SEMUA") { $array = [ 'KWLADM' => $kwl, 'KPPADM' => $kpp]; }else if ($kpp != "SEMUA" && $seksi != "SEMUA" && $nip == "SEMUA"){ $array = [ 'KWLADM' => $kwl, 'KPPADM' => $kpp, 'KODESIE' => $seksi]; } else if ($kpp != "SEMUA" && $seksi != "SEMUA" && $nip != "SEMUA") { $array = [ 'KWLADM' => $kwl, 'KODESIE' => $seksi, 'NIP' => $nip]; } $this->builder() ->select('NPWP,NAMA') ->selectSum('TOTAL') ->where('THNBYR' ,$tahun) ->where('KATEGORI', $kategori) ->where('BLNBYR <=', $bln) ->where($array) ->groupBy('NPWP,NAMA') ->limit($limit, $offset); return $this; } }