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.

535 lines
22 KiB

<?php
namespace App\Controllers\Kewilayahan\IdentAktifitasHasil\PerubahanPerilaku;
use App\Libraries\AldLibrary;
use App\Libraries\KpdlLibrary;
class Perubahan extends \App\Controllers\Kewilayahan\Kytp
{
protected function dataPerilakuPembayaran($request)
{
$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);
}
$db = \Config\Database::connect();
$KpdlLibrary = new KpdlLibrary;
$npwp = $db->table('KPDL_MV_LOKASI_SUBJEK A')
->select('COUNT(DISTINCT A.NPWP) as JML_WP')
->join('KPDL_MV_PEMBAYARAN_PERTAMA B', "A.NPWP = B.NPWP AND A.CREATION_DATE<= B.TGL_BYR", 'inner')
->where('A.JUMLAH_PEMBAYARAN_THN_TERAKHIR >', 0);
if ($opsiWilZona == 'wilayah') {
$npwp = $npwp->whereIn('ADM4_PCODE', $adm4_pcode);
}
if ($opsiWilZona == 'zona') {
$npwp = $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona);
}
if ($opsiWilZona == 'perekam') {
$npwp = $npwp->whereIn('A.CREATED_BY', $nip_ar_perekam);
}
if ($opsiWilZona == 'pengampu') {
$npwp = $npwp->whereIn('NIP_AR_PENGAMPU', $nip_ar_pengampu);
}
//pembatasan
if (!in_array(session('tpkantor'), ['KPDJP', 'Kanwil', 'KPP'])) {
return [];
}
if (session('kppadm') != '000') {
$npwp->groupStart();
if (session('tpkantor') == 'Kanwil') { // kanwil
$npwp->join('KPDL_ZP_NAS_DIFF B', 'ID_POLY_ZONA = B.OGC_FID');
$npwp->orGroupStart();
$npwp->where('B.KD_KANWIL', session('kwladm'));
$npwp->groupEnd();
}
if (session('tpkantor') == 'KPP') { //KPP
$npwp->join('KPDL_ZP_NAS_DIFF B', 'ID_POLY_ZONA = B.OGC_FID');
$currentPegawai = currentPegawai();
if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['602'])) { //AR
//zona
$npwp->orGroupStart()
->where('B.KD_UNIT_OR', $currentPegawai->KD_UNIT_ORGANISASI)
->where('A.KPPADM_ZONA', session('kppadm'))
->where('A.NIP_AR_ZONA', session('nip'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KODE_PEG_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI . '-' . session('nip')) //direkam saat di seksi aktif saat ini
->groupEnd();
//pengampu
$npwp->orGroupStart()
->where('A.NIP_AR_PENGAMPU', session('nip'))
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['401'])) { //kasi
//zona
$npwp->orGroupStart()
->where('B.KD_UNIT_OR', $currentPegawai->KD_UNIT_ORGANISASI)
->where('A.KPPADM_ZONA', session('kppadm'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KODE_SEKSI_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI)
->groupEnd();
//pengampu
$npwp->join('PEGAWAI C', 'A.NIP_AR_PENGAMPU=C.NIP9', 'left');
$npwp->orGroupStart()
->where('C.KD_UNIT_ORGANISASI', $currentPegawai->KD_UNIT_ORGANISASI)
->where('C.KPPADM', session('kppadm'))
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['304'])) { //Kepala Kantor
//zona
$npwp->orGroupStart()
->where('A.KPPADM_ZONA', session('kppadm'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KPP_ADM_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI)
->groupEnd();
//pengampu
$npwp->join('PEGAWAI C', 'A.NIP_AR_PENGAMPU=C.NIP9', 'left');
$npwp->orGroupStart()
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else {
return [];
}
}
$npwp->groupEnd();
}
$data = $npwp->get()->getRow()->JML_WP;
return $data;
}
protected function dataPerilakuPembayaranRupiah($request)
{
$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);
}
$db = \Config\Database::connect();
$KpdlLibrary = new KpdlLibrary;
$npwp = $db->table('KPDL_MV_LOKASI_SUBJEK A')
->select('A.NPWP, A.JUMLAH_PEMBAYARAN_THN_TERAKHIR')->distinct()
->join('KPDL_MV_PEMBAYARAN_PERTAMA B', "A.NPWP = B.NPWP AND A.CREATION_DATE<= B.TGL_BYR", 'inner')
->where('A.JUMLAH_PEMBAYARAN_THN_TERAKHIR >', 0);
if ($opsiWilZona == 'wilayah') {
$npwp = $npwp->whereIn('ADM4_PCODE', $adm4_pcode);
}
if ($opsiWilZona == 'zona') {
$npwp = $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona);
}
if ($opsiWilZona == 'perekam') {
$npwp = $npwp->whereIn('A.CREATED_BY', $nip_ar_perekam);
}
if ($opsiWilZona == 'pengampu') {
$npwp = $npwp->whereIn('NIP_AR_PENGAMPU', $nip_ar_pengampu);
}
//pembatasan
if (!in_array(session('tpkantor'), ['KPDJP', 'Kanwil', 'KPP'])) {
return [];
}
if (session('kppadm') != '000') {
$npwp->groupStart();
if (session('tpkantor') == 'Kanwil') { // kanwil
$npwp->join('KPDL_ZP_NAS_DIFF B', 'ID_POLY_ZONA = B.OGC_FID');
$npwp->orGroupStart();
$npwp->where('B.KD_KANWIL', session('kwladm'));
$npwp->groupEnd();
}
if (session('tpkantor') == 'KPP') { //KPP
$npwp->join('KPDL_ZP_NAS_DIFF B', 'ID_POLY_ZONA = B.OGC_FID');
$currentPegawai = currentPegawai();
if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['602'])) { //AR
//zona
$npwp->orGroupStart()
->where('B.KD_UNIT_OR', $currentPegawai->KD_UNIT_ORGANISASI)
->where('A.KPPADM_ZONA', session('kppadm'))
->where('A.NIP_AR_ZONA', session('nip'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KODE_PEG_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI . '-' . session('nip')) //direkam saat di seksi aktif saat ini
->groupEnd();
//pengampu
$npwp->orGroupStart()
->where('A.NIP_AR_PENGAMPU', session('nip'))
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['401'])) { //kasi
//zona
$npwp->orGroupStart()
->where('B.KD_UNIT_OR', $currentPegawai->KD_UNIT_ORGANISASI)
->where('A.KPPADM_ZONA', session('kppadm'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KODE_SEKSI_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI)
->groupEnd();
//pengampu
$npwp->join('PEGAWAI C', 'A.NIP_AR_PENGAMPU=C.NIP9', 'left');
$npwp->orGroupStart()
->where('C.KD_UNIT_ORGANISASI', $currentPegawai->KD_UNIT_ORGANISASI)
->where('C.KPPADM', session('kppadm'))
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['304'])) { //Kepala Kantor
//zona
$npwp->orGroupStart()
->where('A.KPPADM_ZONA', session('kppadm'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KPP_ADM_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI)
->groupEnd();
//pengampu
$npwp->join('PEGAWAI C', 'A.NIP_AR_PENGAMPU=C.NIP9', 'left');
$npwp->orGroupStart()
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else {
return [];
}
}
$npwp->groupEnd();
}
// print_r($npwp->getCompiledSelect());
// exit;
$data = $npwp->get()->getResultArray();
$ret = array_sum(array_map(fn($item) => $item['JUMLAH_PEMBAYARAN_THN_TERAKHIR'], $data)); // 5
return $ret;
}
protected function dataPerilakuPelaporan($request)
{
$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);
}
$db = \Config\Database::connect();
$KpdlLibrary = new KpdlLibrary;
$npwp = $db->table('KPDL_MV_LOKASI_SUBJEK A')
->select('COUNT(DISTINCT A.NPWP) as JML_WP')
->join('KPDL_MV_SPT_TAHUNAN_PERTAMA B', "A.NPWP = B.NPWP AND A.CREATION_DATE<= B.TGL_TERIMA", 'inner');
if ($opsiWilZona == 'wilayah') {
$npwp = $npwp->whereIn('ADM4_PCODE', $adm4_pcode);
}
if ($opsiWilZona == 'zona') {
$npwp = $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona);
}
if ($opsiWilZona == 'perekam') {
$npwp = $npwp->whereIn('A.CREATED_BY', $nip_ar_perekam);
}
if ($opsiWilZona == 'pengampu') {
$npwp = $npwp->whereIn('NIP_AR_PENGAMPU', $nip_ar_pengampu);
}
//pembatasan
if (!in_array(session('tpkantor'), ['KPDJP', 'Kanwil', 'KPP'])) {
return [];
}
if (session('kppadm') != '000') {
$npwp->groupStart();
if (session('tpkantor') == 'Kanwil') { // kanwil
$npwp->join('KPDL_ZP_NAS_DIFF B', 'ID_POLY_ZONA = B.OGC_FID');
$npwp->orGroupStart();
$npwp->where('B.KD_KANWIL', session('kwladm'));
$npwp->groupEnd();
}
if (session('tpkantor') == 'KPP') { //KPP
$npwp->join('KPDL_ZP_NAS_DIFF B', 'ID_POLY_ZONA = B.OGC_FID');
$currentPegawai = currentPegawai();
if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['602'])) { //AR
//zona
$npwp->orGroupStart()
->where('B.KD_UNIT_OR', $currentPegawai->KD_UNIT_ORGANISASI)
->where('A.KPPADM_ZONA', session('kppadm'))
->where('A.NIP_AR_ZONA', session('nip'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KODE_PEG_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI . '-' . session('nip')) //direkam saat di seksi aktif saat ini
->groupEnd();
//pengampu
$npwp->orGroupStart()
->where('A.NIP_AR_PENGAMPU', session('nip'))
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['401'])) { //kasi
//zona
$npwp->orGroupStart()
->where('B.KD_UNIT_OR', $currentPegawai->KD_UNIT_ORGANISASI)
->where('A.KPPADM_ZONA', session('kppadm'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KODE_SEKSI_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI)
->groupEnd();
//pengampu
$npwp->join('PEGAWAI C', 'A.NIP_AR_PENGAMPU=C.NIP9', 'left');
$npwp->orGroupStart()
->where('C.KD_UNIT_ORGANISASI', $currentPegawai->KD_UNIT_ORGANISASI)
->where('C.KPPADM', session('kppadm'))
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['304'])) { //Kepala Kantor
//zona
$npwp->orGroupStart()
->where('A.KPPADM_ZONA', session('kppadm'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KPP_ADM_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI)
->groupEnd();
//pengampu
$npwp->join('PEGAWAI C', 'A.NIP_AR_PENGAMPU=C.NIP9', 'left');
$npwp->orGroupStart()
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else {
return [];
}
}
$npwp->groupEnd();
}
$data = $npwp->get()->getRow()->JML_WP;
return $data;
}
protected function dataPerilakuPendaftaran($request)
{
$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);
}
$db = \Config\Database::connect();
$KpdlLibrary = new KpdlLibrary;
$npwp = $db->table('KPDL_MV_LOKASI_SUBJEK A')
->select('COUNT(A.NO_IDENTITAS) as JML_WP')
->join('KPDL_MV_PENDAFTARAN_PERTAMA B', "A.NO_IDENTITAS = B.NO_IDENTITAS AND A.CREATION_DATE <= B.TGL_DAFTAR", 'inner');
if ($opsiWilZona == 'wilayah') {
$npwp = $npwp->whereIn('ADM4_PCODE', $adm4_pcode);
}
if ($opsiWilZona == 'zona') {
$npwp = $npwp->whereIn('ID_POLY_ZONA', $id_poly_zona);
}
if ($opsiWilZona == 'perekam') {
$npwp = $npwp->whereIn('A.CREATED_BY', $nip_ar_perekam);
}
if ($opsiWilZona == 'pengampu') {
$npwp = $npwp->whereIn('NIP_AR_PENGAMPU', $nip_ar_pengampu);
}
//pembatasan
if (!in_array(session('tpkantor'), ['KPDJP', 'Kanwil', 'KPP'])) {
return [];
}
if (session('kppadm') != '000') {
$npwp->groupStart();
if (session('tpkantor') == 'Kanwil') { // kanwil
$npwp->join('KPDL_ZP_NAS_DIFF B', 'ID_POLY_ZONA = B.OGC_FID');
$npwp->orGroupStart();
$npwp->where('B.KD_KANWIL', session('kwladm'));
$npwp->groupEnd();
}
if (session('tpkantor') == 'KPP') { //KPP
$npwp->join('KPDL_ZP_NAS_DIFF B', 'ID_POLY_ZONA = B.OGC_FID');
$currentPegawai = currentPegawai();
if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['602'])) { //AR
//zona
$npwp->orGroupStart()
->where('B.KD_UNIT_OR', $currentPegawai->KD_UNIT_ORGANISASI)
->where('A.KPPADM_ZONA', session('kppadm'))
->where('A.NIP_AR_ZONA', session('nip'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KODE_PEG_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI . '-' . session('nip')) //direkam saat di seksi aktif saat ini
->groupEnd();
//pengampu
$npwp->orGroupStart()
->where('A.NIP_AR_PENGAMPU', session('nip'))
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['401'])) { //kasi
//zona
$npwp->orGroupStart()
->where('B.KD_UNIT_OR', $currentPegawai->KD_UNIT_ORGANISASI)
->where('A.KPPADM_ZONA', session('kppadm'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KODE_SEKSI_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI)
->groupEnd();
//pengampu
$npwp->join('PEGAWAI C', 'A.NIP_AR_PENGAMPU=C.NIP9', 'left');
$npwp->orGroupStart()
->where('C.KD_UNIT_ORGANISASI', $currentPegawai->KD_UNIT_ORGANISASI)
->where('C.KPPADM', session('kppadm'))
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else if (in_array($currentPegawai->KD_JAB_STRUKTURAL, ['304'])) { //Kepala Kantor
//zona
$npwp->orGroupStart()
->where('A.KPPADM_ZONA', session('kppadm'))
->groupEnd();
//perekam
$npwp->orGroupStart()
->where('A.KPP_ADM_PEREKAM', session('kppadm') . '-' . $currentPegawai->KD_UNIT_ORGANISASI)
->groupEnd();
//pengampu
$npwp->join('PEGAWAI C', 'A.NIP_AR_PENGAMPU=C.NIP9', 'left');
$npwp->orGroupStart()
->where('A.KPPADM_PENGAMPU', session('kppadm'))
->groupEnd();
} else {
return [];
}
}
$npwp->groupEnd();
}
$data = $npwp->get()->getRow()->JML_WP;
return $data;
}
}