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.
71 lines
3.0 KiB
71 lines
3.0 KiB
<?php |
|
namespace App\Controllers\Kewilayahan\Sebaran; |
|
|
|
use CodeIgniter\Database\RawSql; |
|
|
|
class Sof 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') ?? []; |
|
$nip_ar_perekam = $request->getPost('nip_ar_perekam') ?? []; |
|
$nip_ar_pengampu = $request->getPost('nip_ar_pengampu') ?? []; |
|
|
|
$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); |
|
} |
|
|
|
$sqlBulanIni = $db->newQuery() |
|
->select("'" . $tahun . '-' . $bulan . "' AS THN_BLN, B.LAPISAN, count(1) JML", false) |
|
->fromSubquery($npwp, 'A') |
|
->join("KPDL_MV_PENERIMAAN_AGG_SF B", new RawSql("A.NPWP=B.NPWP and B.THNBYR = " . $tahun . " and B.BULAN=" . $bulan), 'inner') |
|
->groupBy("B.LAPISAN")->getCompiledSelect(); |
|
|
|
$sqlBulanLalu = $db->newQuery() |
|
->select("'" . $tahun . '-' . $bulan - 1 . "' AS THN_BLN, B.LAPISAN, count(1) JML", false) |
|
->fromSubquery($npwp, 'A') |
|
->join("KPDL_MV_PENERIMAAN_AGG_SF B", new RawSql("A.NPWP=B.NPWP and B.THNBYR = " . $tahun . " and B.BULAN=" . $bulan - 1), 'inner') |
|
->groupBy("B.LAPISAN")->getCompiledSelect(); |
|
|
|
$sql2BulanLalu = $db->newQuery() |
|
->select("'" . $tahun . '-' . $bulan - 2 . "' AS THN_BLN, B.LAPISAN, count(1) JML", false) |
|
->fromSubquery($npwp, 'A') |
|
->join("KPDL_MV_PENERIMAAN_AGG_SF B", new RawSql("A.NPWP=B.NPWP and B.THNBYR = " . $tahun . " and B.BULAN=" . $bulan - 2), 'inner') |
|
->groupBy("B.LAPISAN")->getCompiledSelect(); |
|
|
|
$sqlSemua = $db->newQuery() |
|
->select("L.LAPISAN , NVL(A.JML, 0) AS JML_C, NVL(B.JML,0) JML_P1, NVL(C.JML,0) JML_P2") |
|
->from('KPDL_REF_LAPISAN L') |
|
->join("(" . $sqlBulanIni . ") A", "L.LAPISAN = A.LAPISAN", "left", false) |
|
->join("(" . $sqlBulanLalu . ") B", "L.LAPISAN = B.LAPISAN", "left", false) |
|
->join("(" . $sql2BulanLalu . ") C", "L.LAPISAN = C.LAPISAN", "left", false) |
|
->orderBy("L.LAPISAN"); |
|
|
|
$data = $sqlSemua->get()->getResult(); |
|
foreach ($data as $key => $value) { |
|
$value->JML_C = floatval($value->JML_C); |
|
$value->JML_P1 = floatval($value->JML_P1); |
|
$value->JML_P2 = floatval($value->JML_P2); |
|
} |
|
return $data; |
|
} |
|
}
|
|
|