getPost('opsiWilZona'); $adm4_pcode = $request->getPost('adm4_pcode') ?? []; $id_poly_zona = $request->getPost('id_poly_zona') ?? []; $db = \Config\Database::connect(); $npwp = $db->table('KPDL_MV_LOKASI_SUBJEK')->select("CASE WHEN (NPWP IS NULL) THEN 'NON NPWP' ELSE 'BER NPWP' END AS IDENTIFIKASI, count(1) JML", false) ->groupBy("CASE WHEN (NPWP IS NULL) THEN 'NON NPWP' ELSE 'BER NPWP' END"); if ($opsiWilZona == 'wilayah') { $npwp->whereIn('ADM4_PCODE', $adm4_pcode); } if ($opsiWilZona == 'zona') { $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona); } $data = $npwp->get()->getResult(); $ret = []; foreach ($data as $b) { array_push($ret, ['name' => $b->IDENTIFIKASI, 'color' => $b->IDENTIFIKASI == 'NON NPWP' ? 'orange' : 'green', 'y' => floatval($b->JML), ] ); } return $ret; } }