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.

83 lines
2.5 KiB

7 months ago
<?php
namespace App\Controllers\Kewilayahan\Sebaran;
use App\Libraries\KpdlLibrary;
class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp
{
protected function dataAgg($request, $bulan)
7 months ago
{
$opsiWilZona = $request->getPost('opsiWilZona');
$adm4_pcode = $request->getPost('adm4_pcode') ?? [];
$id_poly_zona = $request->getPost('id_poly_zona') ?? [];
$db = \Config\Database::connect();
7 months ago
if ($bulan == 'semua') {
$npwp = $db->table('KPDL_MV_JML_KPDL_AGG A')
7 months ago
->select('BULAN, SUM(JML) JML')
->where("TAHUN =" . date('Y'))
->where('BULAN <=', date('m'))
->groupBy('BULAN');
if ($opsiWilZona == 'wilayah') {
$npwp = $npwp->whereIn('ADM4_PCODE', $adm4_pcode);
}
if ($opsiWilZona == 'zona') {
$npwp = $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona);
}
$npwp = $npwp->getCompiledSelect();
$data = $db->table('BULAN A')
->select("A.KODE AS BULAN, C.JML")
7 months ago
->join("(" . $npwp . ") C", 'A.KODE = C.BULAN', 'left')
->orderBy('BULAN');
$KpdlLibrary = new KpdlLibrary;
7 months ago
return $KpdlLibrary->single_array($data->get()->getResult(), 'JML');
}
}
7 months ago
protected function dataKpdl($request, $bulan)
{
$opsiWilZona = $request->getPost('opsiWilZona');
$adm4_pcode = $request->getPost('adm4_pcode') ?? [];
$id_poly_zona = $request->getPost('id_poly_zona') ?? [];
$db = \Config\Database::connect();
if ($bulan == 'semua') {
$npwp = $db->table('KPDL_MV_JML_KPDL A')
->select('BULAN, SUM(JML) JML')
->where("TAHUN =" . date('Y'))
->where('BULAN <=', date('m'))
->groupBy('BULAN');
7 months ago
if ($opsiWilZona == 'wilayah') {
$npwp = $npwp->whereIn('ADM4_PCODE', $adm4_pcode);
7 months ago
}
if ($opsiWilZona == 'zona') {
$npwp = $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona);
7 months ago
}
$npwp = $npwp->getCompiledSelect();
7 months ago
$data = $db->table('BULAN A')
->select("A.KODE as BULAN, C.JML")
->join("(" . $npwp . ") C", 'A.KODE = C.BULAN', 'left')
->orderBy('BULAN');
$KpdlLibrary = new KpdlLibrary;
return $KpdlLibrary->single_array($data->get()->getResult(), 'JML');
7 months ago
}
}
}