You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
7 months ago
|
<?php
|
||
|
namespace App\Controllers\Kewilayahan\Sebaran;
|
||
|
|
||
|
class KLU extends \App\Controllers\Kewilayahan\Kytp
|
||
|
|
||
|
{
|
||
|
protected function data($request, $jenischart)
|
||
|
{
|
||
|
$opsiWilZona = $request->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 A')->select('NPWP, KD_GOLPOK, NM_GOLPOK, JUMLAH_PEMBAYARAN_THN_TERAKHIR')->distinct()
|
||
|
->where('NPWP IS NOT NULL');
|
||
|
|
||
|
if ($jenischart == 'dataKluYgBayar') {
|
||
|
$npwp = $npwp->where("JUMLAH_PEMBAYARAN_THN_TERAKHIR >", 0);
|
||
|
}
|
||
|
|
||
|
if ($opsiWilZona == 'wilayah') {
|
||
|
$npwp = $npwp->whereIn('ADM4_PCODE', $adm4_pcode);
|
||
|
}
|
||
|
|
||
|
if ($opsiWilZona == 'zona') {
|
||
|
$npwp = $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona);
|
||
|
}
|
||
|
|
||
|
$agg = "count(1) as JML";
|
||
|
if ($jenischart == 'dataRupiahBayar') {
|
||
|
$agg = "SUM(JUMLAH_PEMBAYARAN_THN_TERAKHIR) as JML";
|
||
|
}
|
||
|
$data = $db->newQuery()
|
||
|
->fromSubquery($npwp, "A")
|
||
|
->select("KD_GOLPOK, NM_GOLPOK," . $agg)
|
||
|
->groupBy("KD_GOLPOK, NM_GOLPOK")->orderBy("JML", "desc")->limit(5);
|
||
|
|
||
|
$data = $data->get()->getResult();
|
||
|
|
||
|
$ret = [];
|
||
|
|
||
|
foreach ($data as $b) {
|
||
|
|
||
|
array_push($ret,
|
||
|
[
|
||
|
'name' => $b->NM_GOLPOK,
|
||
|
'id' => $b->KD_GOLPOK,
|
||
|
'y' => floatval($b->JML),
|
||
|
]
|
||
|
);
|
||
|
}
|
||
|
|
||
|
return $ret;
|
||
|
}
|
||
|
}
|