getPost('opsiWilZona'); $adm4_pcode = $request->getPost('adm4_pcode') ?? []; $id_poly_zona = $request->getPost('id_poly_zona') ?? []; $db = \Config\Database::connect(); //npwp $npwp = $db->table('KPDL_MV_LOKASI_SUBJEK')->select('NPWP')->distinct()->where('NPWP IS NOT NULL'); if ($opsiWilZona == 'wilayah') { $npwp->whereIn('ADM4_PCODE', $adm4_pcode); } if ($opsiWilZona == 'zona') { $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona); } $data = $db->newQuery() ->select("'" . $tahun . '-' . $bulan . "' AS THN_BLN, B.JML|| ' bulan' as KETERANGAN, COUNT(1) AS Y", false) ->fromSubquery($npwp, 'A') ->join('KPDL_MV_PENERIMAAN_AGG_PC B', new RawSql("A.NPWP=B.NPWP and B.THNBYR = " . $tahun . " and B.BULAN=" . $bulan), 'inner') ->groupBy("B.JML")->orderBy("KETERANGAN"); $data = $data->get()->getResult(); $ret = []; foreach ($data as $b) { array_push($ret, ['name' => $b->KETERANGAN, // 'color' => $b->WARNA_BYR, 'y' => floatval($b->Y), 'thn_bln' => $b->THN_BLN, ] ); } return $ret; } }