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.
 
 
 
 
 
 

70 lines
2.3 KiB

<?php
namespace App\Controllers\Kewilayahan\Sebaran;
use CodeIgniter\Database\RawSql;
class Pembayaran extends \App\Controllers\Kewilayahan\Kytp
{
protected function dataC($request, $tahun, $bulan)
{
$opsiWilZona = $request->getPost('opsiWilZona');
$adm4_pcode = $request->getPost('adm4_pcode') ?? [];
$id_poly_zona = $request->getPost('id_poly_zona') ?? [];
// $tahun = $this->request->getPost('tahun') ?? date('Y');
// $bulan = $this->request->getPost('bulan') ?? date('m');
// $opsiWilZona = '';
// $adm4_pcode = '';
// $id_poly_zona = '';
// $tahun = date('Y');
// $bulan = date('m');
$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, NVL(WARNA_BYR, 'black') WARNA_BYR, COUNT(1) AS Y")
->fromSubquery($npwp, 'A')
->join('KPDL_MV_PENERIMAAN_AGG B', new RawSql("A.NPWP=B.NPWP and B.THNBYR = " . $tahun . " and B.BULAN=" . $bulan), 'left')
->groupBy("NVL(WARNA_BYR, 'black')")->orderBy("WARNA_BYR");
$data = $data->get()->getResult();
$ret = [];
foreach ($data as $b) {
$name = '';
switch ($b->WARNA_BYR) {
case 'black':$name = '<=0';
break;
case 'red':$name = '< 5 jt';
break;
case 'yellow':$name = '<48 jt';
break;
case 'green':$name = '<100 jt';
break;
case 'blue':$name = '> 100 jt';
break;
}
array_push($ret, ['name' => $name,
'color' => $b->WARNA_BYR,
'y' => floatval($b->Y),
'thn_bln' => $b->THN_BLN,
]
);
}
return $ret;
}
}