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.

79 lines
2.5 KiB

7 months ago
<?php
namespace App\Controllers\Kewilayahan\Sebaran;
use App\Libraries\AldLibrary;
7 months ago
use CodeIgniter\Database\RawSql;
class PayComp extends \App\Controllers\Kewilayahan\Kytp
{
protected function dataC($request, $tahun, $bulan)
{
$Ald = new AldLibrary;
$username = session('nip');
$opsiWilZona = $Ald->decryptMe($request->getPost('opsiWilZona'), $username);
$adm4_pcode = [];
foreach ($request->getPost('adm4_pcode') ?? [] as $key => $value) {
$adm4_pcode[] = $Ald->decryptKpdl($value, $username);
}
$id_poly_zona = [];
foreach ($request->getPost('id_poly_zona') ?? [] as $key => $value) {
$id_poly_zona[] = $Ald->decryptMe($value, $username);
}
$nip_ar_perekam = [];
foreach ($request->getPost('nip_ar_perekam') ?? [] as $key => $value) {
$nip_ar_perekam[] = $Ald->decryptMe($value, $username);
}
$nip_ar_pengampu = [];
foreach ($request->getPost('nip_ar_pengampu') ?? [] as $key => $value) {
$nip_ar_pengampu[] = $Ald->decryptMe($value, $username);
}
7 months ago
$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);
}
if ($opsiWilZona == 'perekam') {
$npwp = $npwp->whereIn('CREATED_BY', $nip_ar_perekam);
}
if ($opsiWilZona == 'pengampu') {
$npwp = $npwp->whereIn('NIP_AR_PENGAMPU', $nip_ar_pengampu);
}
7 months ago
$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;
}
}