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.
 
 
 
 
 
 

46 lines
1.4 KiB

<?php
namespace App\Controllers\Kewilayahan\Sebaran;
class SPTTAhunan extends \App\Controllers\Kewilayahan\Kytp
{
protected function data($request, $tahun)
{
$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, B.KETERANGAN')->distinct()
->join('KPDL_REF_STATUS_SPT B', "A.STATUS_SPT_TAHUNAN_TERAKHIR = B.ID_STATUS_SPT", "left")
->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()
->fromSubquery($npwp, "A")
->select("KETERANGAN, count(1) as JML")
->groupBy("A.KETERANGAN");
$data = $data->get()->getResult();
$ret = [];
foreach ($data as $b) {
array_push($ret, ['name' => $b->KETERANGAN,
// 'color' => $b->IDENTIFIKASI == 'NON NPWP' ? 'orange' : 'green',
'y' => floatval($b->JML),
]
);
}
return $ret;
}
}