db->query("SELECT NPWP,NAMA,SUM(TOTAL) FROM( SELECT NPWP, NAMA, TOTAL,COUNT(1) JMLBLN FROM DASHBOARD_WP_BLN WHERE TAHUN = '" . $tahun . "' AND KWLADM = '" . $kwl . "'$cekkpp $cekseksi $ceknip GROUP BY NPWP,NAMA,TOTAL) WHERE JMLBLN = '" . $jmlbln . "' GROUP BY NPWP,NAMA "); return $query; } function detKat($param) { $tahun = $param['tahun']; $kwl = $param['kwl']; $kpp = $param['kpp']; $seksi = $param['seksi']; $nip = $param['nip']; $jmlbln = $param['jmlbln']; $offset = $param['page']; $limit = $param['perPage']; 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') ->selectCount('1', 'JMLBLN') ->where('TAHUN', $tahun) ->where($array) ->groupBy('NPWP,NAMA') ->having('COUNT(1)', $jmlbln, TRUE) ->limit($limit, $offset); return $this; } }