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.
575 lines
25 KiB
575 lines
25 KiB
7 months ago
|
<?php
|
||
3 months ago
|
namespace App\Controllers\Kewilayahan\Monitoring;
|
||
7 months ago
|
|
||
6 months ago
|
use App\Libraries\AldLibrary;
|
||
7 months ago
|
use CodeIgniter\API\ResponseTrait;
|
||
|
use CodeIgniter\Controller;
|
||
6 months ago
|
use DateTime;
|
||
|
use DateTimeZone;
|
||
7 months ago
|
|
||
3 months ago
|
class PerubahanPerilaku extends Controller
|
||
7 months ago
|
{
|
||
|
|
||
|
use ResponseTrait;
|
||
6 months ago
|
public function __construct()
|
||
|
{
|
||
|
|
||
|
$kppadm = session('kppadm');
|
||
|
if (!in_array($kppadm, ['000'])) {
|
||
6 months ago
|
// exit;
|
||
6 months ago
|
}
|
||
|
|
||
|
}
|
||
|
|
||
7 months ago
|
public function index()
|
||
|
{
|
||
|
if (session('isLogin')) {
|
||
|
echo view('inc/head');
|
||
|
echo view('inc/navbar');
|
||
|
echo view('inc/sidebar');
|
||
3 months ago
|
echo view('kewilayahan/monitoringPerubahanPerilaku/monitoring');
|
||
7 months ago
|
echo view('inc/footer');
|
||
|
} else {
|
||
|
return redirect()->to('auth');
|
||
|
}
|
||
|
}
|
||
|
|
||
3 months ago
|
public function penambahananwpbayar()
|
||
|
{
|
||
|
$config = config(\Config\App::class, false);
|
||
|
|
||
|
$Ald = new AldLibrary;
|
||
|
$username = session('nip');
|
||
|
$kpp = [];
|
||
|
foreach ($this->request->getPost('kpp') ?? [] as $key => $value) {
|
||
|
$kpp[] = $Ald->decryptMe($value, $username);
|
||
|
}
|
||
|
|
||
|
$tahun = $this->request->getPost('tahun');
|
||
|
// $thn = new DateTime($tahun);
|
||
|
// $thn->setTimezone(new DateTimeZone($config->appTimezone));
|
||
|
// print_r($tahun);
|
||
|
// exit;
|
||
|
$db = \Config\Database::connect();
|
||
|
|
||
|
$sql = "select C.KODE||'-'|| B.KD_KPP ||'-'||A.KD_UNIT_ORGANISASI ||'-'|| A.NIP9 AS KODE_PEG,
|
||
|
C.KODE as KD_KANWIL, B.KD_KPP as KPPADM, A.KD_UNIT_ORGANISASI as KODE_SEKSI, NIP9 as NIP_AR,
|
||
|
C.NAMA as NAMA_KANWIL , B.NM_KANTOR as NAMA_KANTOR , A.NAMA_UNIT_ES4 , A.NAMA as NAMA_PEGAWAI,
|
||
|
COALESCE (BLN_1, 0) BLN_1,
|
||
|
COALESCE (BLN_2, 0) BLN_2,
|
||
|
COALESCE (BLN_3, 0) BLN_3,
|
||
|
COALESCE (BLN_4, 0) BLN_4,
|
||
|
COALESCE (BLN_5, 0) BLN_5,
|
||
|
COALESCE (BLN_6, 0) BLN_6,
|
||
|
COALESCE (BLN_7, 0) BLN_7,
|
||
|
COALESCE (BLN_8, 0) BLN_8,
|
||
|
COALESCE (BLN_9, 0) BLN_9,
|
||
|
COALESCE (BLN_10, 0) BLN_10,
|
||
|
COALESCE (BLN_11, 0) BLN_11,
|
||
|
COALESCE (BLN_12, 0) BLN_12
|
||
|
FROM PEGAWAI A
|
||
|
LEFT JOIN REF_KPP B ON
|
||
|
(A.KPPADM = B.KD_KPP)
|
||
|
LEFT JOIN REF_KANWIL C ON
|
||
|
(B.KD_KANWIL = C.KODE)
|
||
|
LEFT JOIN
|
||
|
(
|
||
|
SELECT
|
||
|
NIP_AR_PENGAMPU ,
|
||
|
sum(CASE WHEN POSISI_BULAN =1 THEN 1 ELSE 0 END) AS BLN_1,
|
||
|
sum(CASE WHEN POSISI_BULAN =2 THEN 1 ELSE 0 END) AS BLN_2,
|
||
|
sum(CASE WHEN POSISI_BULAN =3 THEN 1 ELSE 0 END) AS BLN_3,
|
||
|
sum(CASE WHEN POSISI_BULAN =4 THEN 1 ELSE 0 END) AS BLN_4,
|
||
|
sum(CASE WHEN POSISI_BULAN =5 THEN 1 ELSE 0 END) AS BLN_5,
|
||
|
sum(CASE WHEN POSISI_BULAN =6 THEN 1 ELSE 0 END) AS BLN_6,
|
||
|
sum(CASE WHEN POSISI_BULAN =7 THEN 1 ELSE 0 END) AS BLN_7,
|
||
|
sum(CASE WHEN POSISI_BULAN =8 THEN 1 ELSE 0 END) AS BLN_8,
|
||
|
sum(CASE WHEN POSISI_BULAN =9 THEN 1 ELSE 0 END) AS BLN_9,
|
||
|
sum(CASE WHEN POSISI_BULAN =10 THEN 1 ELSE 0 END) AS BLN_10,
|
||
|
sum(CASE WHEN POSISI_BULAN = 11 THEN 1 ELSE 0 END) AS BLN_11,
|
||
|
sum(CASE WHEN POSISI_BULAN = 12 THEN 1 ELSE 0 END) AS BLN_12
|
||
|
FROM kpdl_mv_penambahan_wp_byr a
|
||
|
WHERE POSISI_TAHUN = :tahun:
|
||
|
GROUP BY NIP_AR_PENGAMPU
|
||
|
) D ON (A.NIP9 = D.NIP_AR_PENGAMPU)
|
||
|
WHERE (A.KD_UNIT_ORGANISASI BETWEEN '0421071700' AND '0421072200' OR A.KD_UNIT_ORGANISASI BETWEEN '0424071800' AND '0424072300')
|
||
|
AND A.KPPADM in :kpp:
|
||
|
ORDER BY KODE_PEG";
|
||
|
$data = $db->query($sql, [
|
||
|
'tahun' => $tahun,
|
||
|
'kpp' => $kpp,
|
||
|
])->getResultArray();
|
||
|
// print_r($data);
|
||
|
// helper('array');
|
||
|
$groupingData = array_group_by($data, ['KD_KANWIL', 'KPPADM', 'KODE_SEKSI']);
|
||
|
// print_r($groupingData);
|
||
|
// exit;
|
||
|
$bentukanArray = [];
|
||
|
$data1 = [];
|
||
|
foreach ($groupingData as $key1 => $value1) { //kanwil
|
||
|
$data1['KEY_LABEL'] = $key1;
|
||
|
$data1['LABEL'] = '';
|
||
|
$data1['BLN_1'] = 0;
|
||
|
$data1['BLN_2'] = 0;
|
||
|
$data1['BLN_3'] = 0;
|
||
|
$data1['BLN_4'] = 0;
|
||
|
$data1['BLN_5'] = 0;
|
||
|
$data1['BLN_6'] = 0;
|
||
|
$data1['BLN_7'] = 0;
|
||
|
$data1['BLN_8'] = 0;
|
||
|
$data1['BLN_9'] = 0;
|
||
|
$data1['BLN_10'] = 0;
|
||
|
$data1['BLN_11'] = 0;
|
||
|
$data1['BLN_12'] = 0;
|
||
|
$data1['TOTAL'] = 0;
|
||
|
$data1['subRows'] = [];
|
||
|
|
||
|
$data2 = [];
|
||
|
foreach ($value1 as $key2 => $value2) { //kpp
|
||
|
$data2['KEY_LABEL'] = $key1 . '-' . $key2;
|
||
|
$data2['LABEL'] = '';
|
||
|
$data2['BLN_1'] = 0;
|
||
|
$data2['BLN_2'] = 0;
|
||
|
$data2['BLN_3'] = 0;
|
||
|
$data2['BLN_4'] = 0;
|
||
|
$data2['BLN_5'] = 0;
|
||
|
$data2['BLN_6'] = 0;
|
||
|
$data2['BLN_7'] = 0;
|
||
|
$data2['BLN_8'] = 0;
|
||
|
$data2['BLN_9'] = 0;
|
||
|
$data2['BLN_10'] = 0;
|
||
|
$data2['BLN_11'] = 0;
|
||
|
$data2['BLN_12'] = 0;
|
||
|
$data2['TOTAL'] = 0;
|
||
|
$data2['subRows'] = [];
|
||
|
|
||
|
$data3 = [];
|
||
|
foreach ($value2 as $key3 => $value3) { //seksi
|
||
|
$data3['KEY_LABEL'] = $key1 . '-' . $key3;
|
||
|
$data3['LABEL'] = '';
|
||
|
$data3['BLN_1'] = 0;
|
||
|
$data3['BLN_2'] = 0;
|
||
|
$data3['BLN_3'] = 0;
|
||
|
$data3['BLN_4'] = 0;
|
||
|
$data3['BLN_5'] = 0;
|
||
|
$data3['BLN_6'] = 0;
|
||
|
$data3['BLN_7'] = 0;
|
||
|
$data3['BLN_8'] = 0;
|
||
|
$data3['BLN_9'] = 0;
|
||
|
$data3['BLN_10'] = 0;
|
||
|
$data3['BLN_11'] = 0;
|
||
|
$data3['BLN_12'] = 0;
|
||
|
$data3['TOTAL'] = 0;
|
||
|
$data3['subRows'] = [];
|
||
|
|
||
|
$data4 = [];
|
||
|
foreach ($value3 as $key4 => $value4) { //AR
|
||
|
$data4['KEY_LABEL'] = $value4['KODE_PEG'];
|
||
|
$data4['LABEL'] = $value4['NAMA_PEGAWAI'];
|
||
|
$data4['BLN_1'] = (float) $value4['BLN_1'];
|
||
|
$data4['BLN_2'] = (float) $value4['BLN_2'];
|
||
|
$data4['BLN_3'] = (float) $value4['BLN_3'];
|
||
|
$data4['BLN_4'] = (float) $value4['BLN_4'];
|
||
|
$data4['BLN_5'] = (float) $value4['BLN_5'];
|
||
|
$data4['BLN_6'] = (float) $value4['BLN_6'];
|
||
|
$data4['BLN_7'] = (float) $value4['BLN_7'];
|
||
|
$data4['BLN_8'] = (float) $value4['BLN_8'];
|
||
|
$data4['BLN_9'] = (float) $value4['BLN_9'];
|
||
|
$data4['BLN_10'] = (float) $value4['BLN_10'];
|
||
|
$data4['BLN_11'] = (float) $value4['BLN_11'];
|
||
|
$data4['BLN_12'] = (float) $value4['BLN_12'];
|
||
|
|
||
|
$data4['TOTAL'] = (float) $value4['BLN_1'] +
|
||
|
(float) $value4['BLN_1'] +
|
||
|
(float) $value4['BLN_2'] +
|
||
|
(float) $value4['BLN_3'] +
|
||
|
(float) $value4['BLN_4'] +
|
||
|
(float) $value4['BLN_5'] +
|
||
|
(float) $value4['BLN_6'] +
|
||
|
(float) $value4['BLN_7'] +
|
||
|
(float) $value4['BLN_8'] +
|
||
|
(float) $value4['BLN_9'] +
|
||
|
(float) $value4['BLN_10'] +
|
||
|
(float) $value4['BLN_11'] +
|
||
|
(float) $value4['BLN_12'];
|
||
|
|
||
|
foreach ($value4 as $key5 => $value5) {
|
||
|
$data4[$key5] = $value5;
|
||
|
}
|
||
|
|
||
|
$data3['LABEL'] = $value4['NAMA_UNIT_ES4'];
|
||
|
$data3['NAMA_KANTOR'] = $value4['NAMA_KANTOR'];
|
||
|
$data2['LABEL'] = $value4['NAMA_KANTOR'];
|
||
|
$data1['LABEL'] = $value4['NAMA_KANWIL'];
|
||
|
|
||
|
$data3['BLN_1'] += (float) $data4['BLN_1'];
|
||
|
$data3['BLN_2'] += (float) $data4['BLN_2'];
|
||
|
$data3['BLN_3'] += (float) $data4['BLN_3'];
|
||
|
$data3['BLN_4'] += (float) $data4['BLN_4'];
|
||
|
$data3['BLN_5'] += (float) $data4['BLN_5'];
|
||
|
$data3['BLN_6'] += (float) $data4['BLN_6'];
|
||
|
$data3['BLN_7'] += (float) $data4['BLN_7'];
|
||
|
$data3['BLN_8'] += (float) $data4['BLN_8'];
|
||
|
$data3['BLN_9'] += (float) $data4['BLN_9'];
|
||
|
$data3['BLN_10'] += (float) $data4['BLN_10'];
|
||
|
$data3['BLN_11'] += (float) $data4['BLN_11'];
|
||
|
$data3['BLN_12'] += (float) $data4['BLN_12'];
|
||
|
$data3['TOTAL'] += (float) $data4['TOTAL'];
|
||
|
// $data3['JUMLAH_AR'] += ($value4['ISEXIST_INWAS'] == 'TRUE' && $value4['NAMA_JABATAN'] == 'Account Representative' ? 1 : 0);
|
||
|
array_push($data3['subRows'], $data4);
|
||
|
}
|
||
|
// $data3['RATA_RATA'] = $data3['JUMLAH_AR'] == 0 ? 0 : $data3['JUMLAH'] / $data3['JUMLAH_AR'];
|
||
|
$data2['BLN_1'] += (float) $data3['BLN_1'];
|
||
|
$data2['BLN_2'] += (float) $data3['BLN_2'];
|
||
|
$data2['BLN_3'] += (float) $data3['BLN_3'];
|
||
|
$data2['BLN_4'] += (float) $data3['BLN_4'];
|
||
|
$data2['BLN_5'] += (float) $data3['BLN_5'];
|
||
|
$data2['BLN_6'] += (float) $data3['BLN_6'];
|
||
|
$data2['BLN_7'] += (float) $data3['BLN_7'];
|
||
|
$data2['BLN_8'] += (float) $data3['BLN_8'];
|
||
|
$data2['BLN_9'] += (float) $data3['BLN_9'];
|
||
|
$data2['BLN_10'] += (float) $data3['BLN_10'];
|
||
|
$data2['BLN_11'] += (float) $data3['BLN_11'];
|
||
|
$data2['BLN_12'] += (float) $data3['BLN_12'];
|
||
|
$data2['TOTAL'] += (float) $data3['TOTAL'];
|
||
|
// $data2['JUMLAH_AR'] += $data3['JUMLAH_AR'];
|
||
|
array_push($data2['subRows'], $data3);
|
||
|
}
|
||
|
// $data2['RATA_RATA'] = $data2['JUMLAH_AR'] == 0 ? 0 : $data2['JUMLAH'] / $data2['JUMLAH_AR'];
|
||
|
$data1['BLN_1'] += (float) $data2['BLN_1'];
|
||
|
$data1['BLN_2'] += (float) $data2['BLN_2'];
|
||
|
$data1['BLN_3'] += (float) $data2['BLN_3'];
|
||
|
$data1['BLN_4'] += (float) $data2['BLN_4'];
|
||
|
$data1['BLN_5'] += (float) $data2['BLN_5'];
|
||
|
$data1['BLN_6'] += (float) $data2['BLN_6'];
|
||
|
$data1['BLN_7'] += (float) $data2['BLN_7'];
|
||
|
$data1['BLN_8'] += (float) $data2['BLN_8'];
|
||
|
$data1['BLN_9'] += (float) $data2['BLN_9'];
|
||
|
$data1['BLN_10'] += (float) $data2['BLN_10'];
|
||
|
$data1['BLN_11'] += (float) $data2['BLN_11'];
|
||
|
$data1['BLN_12'] += (float) $data2['BLN_12'];
|
||
|
$data1['TOTAL'] += (float) $data2['TOTAL'];
|
||
|
// $data1['JUMLAH_AR'] += $data2['JUMLAH_AR'];
|
||
|
array_push($data1['subRows'], $data2);
|
||
|
}
|
||
|
// $data1['RATA_RATA'] = $data1['JUMLAH_AR'] == 0 ? 0 : $data1['JUMLAH'] / $data1['JUMLAH_AR'];
|
||
|
array_push($bentukanArray, $data1);
|
||
|
}
|
||
|
$dataReturn['data'] = $bentukanArray;
|
||
|
// $tempData = $bentukanArray;
|
||
|
$dataChart = $this->urutKanwil($bentukanArray);
|
||
|
$dataReturn['urutKanwil'] = $dataChart['urutKanwil'];
|
||
|
$dataReturn['urutKpp'] = $dataChart['urutKpp'];
|
||
|
$dataReturn['urutSeksi'] = $dataChart['urutSeksi'];
|
||
|
$dataReturn['urutPegawai'] = $dataChart['urutPegawai'];
|
||
|
|
||
|
return $this->respond($dataReturn, 200);
|
||
|
|
||
|
}
|
||
|
|
||
6 months ago
|
public function data()
|
||
|
{
|
||
|
|
||
|
$config = config(\Config\App::class, false);
|
||
|
|
||
|
$Ald = new AldLibrary;
|
||
|
$username = session('nip');
|
||
|
$kanwil = [];
|
||
|
foreach ($this->request->getPost('kanwil') ?? [] as $key => $value) {
|
||
|
$kanwil[] = $Ald->decryptMe($value, $username);
|
||
|
}
|
||
|
$kpp = [];
|
||
|
foreach ($this->request->getPost('kpp') ?? [] as $key => $value) {
|
||
|
$kpp[] = $Ald->decryptMe($value, $username);
|
||
|
}
|
||
|
|
||
|
$tanggalAwal = $this->request->getPost('tanggalAwal');
|
||
|
$tanggalAkhir = $this->request->getPost('tanggalAkhir');
|
||
|
$tgl_awal = new DateTime($tanggalAwal);
|
||
|
$tgl_awal->setTimezone(new DateTimeZone($config->appTimezone));
|
||
|
|
||
|
$tgl_akhir = new DateTime($tanggalAkhir);
|
||
|
$tgl_akhir->setTimezone(new DateTimeZone($config->appTimezone));
|
||
|
|
||
|
$db = \Config\Database::connect();
|
||
|
$sql = "SELECT
|
||
|
A.KD_KANWIL,
|
||
|
A.NAMA_KANWIL ,
|
||
|
A.KPPADM,
|
||
|
A.KODE_SEKSI,
|
||
|
A.KODE_PEG,
|
||
|
A.NAMA_KANTOR,
|
||
|
A.NAMA_UNIT_ES4,
|
||
|
A.NAMA_JABATAN,
|
||
|
A.NAMA,
|
||
|
COALESCE (B.JML,
|
||
|
0) JML,
|
||
|
'TRUE' AS ISEXIST_INWAS
|
||
|
FROM
|
||
|
--KASI DAN AR WAS
|
||
|
(
|
||
|
SELECT
|
||
|
KPPADM,
|
||
|
KPPADM || '-' || KD_UNIT_ORGANISASI AS KODE_SEKSI,
|
||
|
KPPADM || '-' || KD_UNIT_ORGANISASI || '-' || NIP9 AS KODE_PEG,
|
||
|
P.NIP9,
|
||
|
P.NAMA,
|
||
|
NAMA_KANTOR,
|
||
|
KD_UNIT_ORGANISASI,
|
||
|
P.NAMA_UNIT_ES4,
|
||
|
KD_JAB_STRUKTURAL,
|
||
|
NAMA_JABATAN,
|
||
|
B.KD_KANWIL,
|
||
|
C.NAMA AS NAMA_KANWIL
|
||
|
FROM
|
||
|
PEGAWAI P
|
||
|
LEFT JOIN REF_KPP B ON
|
||
|
(P.KPPADM = B.KD_KPP)
|
||
|
LEFT JOIN REF_KANWIL C ON
|
||
|
(B.KD_KANWIL = C.KODE)
|
||
|
WHERE
|
||
|
P.KD_JAB_STRUKTURAL IN ('602', '401')
|
||
|
AND (KD_UNIT_ORGANISASI BETWEEN '0421071700' AND '0421072200'
|
||
|
OR KD_UNIT_ORGANISASI BETWEEN '0424071800' AND '0424072300') AND kppadm in :kpp: ) A
|
||
|
LEFT JOIN -- KPDL_PETUGAS_PEREKAM_AGG
|
||
|
( SELECT KODE_SEKSI_PEREKAM, KODE_PEG_PEREKAM, NIP_PEREKAM , count(1) jml
|
||
|
FROM --KPDL_PETUGAS_REKAM
|
||
6 months ago
|
(SELECT KODE_SEKSI_PEREKAM, KODE_PEG_PEREKAM,
|
||
|
ID_KPDL_SUBJEK, KPP_ADM_PEREKAM , CREATED_BY NIP_PEREKAM,
|
||
|
CREATION_DATE, ORG_APPROVAL_KASI, NIP_APPROVAL_KASI,
|
||
|
TGL_APPROVAL_KASI, STS_APPROVAL_KASI, TGL_APPROVAL_PKD,
|
||
|
STS_APPROVAL_PKD
|
||
|
FROM KPDL_MV_LOKASI_SUBJEK a WHERE trunc(a.CREATION_DATE) BETWEEN DATE :tanggalawal: AND DATE :tanggalakhir:) A
|
||
6 months ago
|
GROUP BY KODE_SEKSI_PEREKAM, KODE_PEG_PEREKAM, NIP_PEREKAM) B ON
|
||
|
(A.KODE_PEG = B.KODE_PEG_PEREKAM)
|
||
|
UNION ALL
|
||
|
-- EX ANGGOTA WAS
|
||
|
SELECT
|
||
|
A.KD_KANWIL,
|
||
|
A.NAMA_KANWIL,
|
||
|
A.KPPADM,
|
||
|
A.KODE_SEKSI,
|
||
|
B.KODE_PEG_PEREKAM,
|
||
|
A.NAMA_KANTOR,
|
||
|
A.NAMA_UNIT_ES4,
|
||
|
' EX ANGGOTA' AS NAMA_JABATAN,
|
||
|
C.NAMA,
|
||
|
COALESCE (B.JML,
|
||
|
0) JML,
|
||
|
'FALSE' AS ISEXIST_INWAS
|
||
|
FROM
|
||
|
-- KPDL_SEKSIWAS_SEINDONESIA
|
||
|
( SELECT
|
||
|
KPPADM,
|
||
|
KPPADM||'-'||KD_UNIT_ORGANISASI AS kode_seksi, KPPADM||'-'||KD_UNIT_ORGANISASI ||'-'||nip9 AS kode_peg, p.NIP9, p.nama,
|
||
|
NAMA_KANTOR, KD_UNIT_ORGANISASI, p.NAMA_UNIT_ES4, KD_JAB_STRUKTURAL, NAMA_JABATAN, b.kd_kanwil, c.nama AS nama_kanwil FROM PEGAWAI p
|
||
|
LEFT JOIN ref_kpp b ON (p.kppadm = b.kd_kpp)
|
||
|
LEFT JOIN ref_kanwil c ON (b.kd_kanwil= c.kode)
|
||
|
WHERE p.KD_JAB_STRUKTURAL ='401'
|
||
|
AND (KD_UNIT_ORGANISASI BETWEEN '0421071700' AND '0421072200' OR KD_UNIT_ORGANISASI BETWEEN '0424071800' AND '0424072300' )
|
||
|
AND kppadm in :kpp:) A
|
||
|
JOIN
|
||
|
--KASI DAN AR WAS
|
||
|
(
|
||
|
SELECT
|
||
|
B.KODE_SEKSI_PEREKAM ,
|
||
|
KODE_PEG_PEREKAM ,
|
||
|
NIP_PEREKAM,
|
||
|
JML
|
||
|
FROM
|
||
|
-- KPDL_PETUGAS_PEREKAM_AGG
|
||
|
( SELECT KODE_SEKSI_PEREKAM, KODE_PEG_PEREKAM, NIP_PEREKAM , count(1) jml
|
||
|
FROM --KPDL_PETUGAS_REKAM
|
||
6 months ago
|
( SELECT KODE_SEKSI_PEREKAM, KODE_PEG_PEREKAM,
|
||
|
ID_KPDL_SUBJEK, KPP_ADM_PEREKAM, CREATED_BY NIP_PEREKAM,
|
||
|
CREATION_DATE, ORG_APPROVAL_KASI, NIP_APPROVAL_KASI,
|
||
|
TGL_APPROVAL_KASI, STS_APPROVAL_KASI, TGL_APPROVAL_PKD,
|
||
|
STS_APPROVAL_PKD
|
||
|
FROM KPDL_MV_LOKASI_SUBJEK a WHERE trunc(a.CREATION_DATE) BETWEEN DATE :tanggalawal: AND DATE :tanggalakhir:) a
|
||
6 months ago
|
GROUP BY KODE_SEKSI_PEREKAM, KODE_PEG_PEREKAM, NIP_PEREKAM) B
|
||
|
WHERE
|
||
|
B.KODE_PEG_PEREKAM NOT IN (
|
||
|
SELECT
|
||
|
KPPADM || '-' || KD_UNIT_ORGANISASI || '-' || NIP9
|
||
|
FROM
|
||
|
PEGAWAI P
|
||
|
WHERE
|
||
|
P.KD_JAB_STRUKTURAL IN ('602', '401')
|
||
|
AND (KD_UNIT_ORGANISASI BETWEEN '0421071700' AND '0421072200'
|
||
|
OR KD_UNIT_ORGANISASI BETWEEN '0424071800' AND '0424072300'))) B
|
||
|
ON
|
||
|
(A.KODE_SEKSI = B.KODE_SEKSI_PEREKAM)
|
||
|
LEFT JOIN PEGAWAI C ON
|
||
|
(B.NIP_PEREKAM = C.NIP9) ORDER BY KD_KANWIL ASC, NAMA_KANTOR DESC, NAMA_UNIT_ES4 ASC, NAMA_JABATAN DESC";
|
||
6 months ago
|
|
||
6 months ago
|
$data = $db->query($sql, [
|
||
|
'tanggalawal' => $tgl_awal->format('Y-m-d'),
|
||
|
'tanggalakhir' => $tgl_akhir->format('Y-m-d'),
|
||
|
'kpp' => $kpp,
|
||
|
])->getResultArray();
|
||
|
helper('array');
|
||
|
$groupingData = array_group_by($data, ['KD_KANWIL', 'KPPADM', 'KODE_SEKSI']);
|
||
|
|
||
|
$bentukanArray = [];
|
||
|
$data1 = [];
|
||
|
foreach ($groupingData as $key1 => $value1) { //kanwil
|
||
|
$data1['KEY_LABEL'] = $key1;
|
||
|
$data1['LABEL'] = '';
|
||
|
$data1['JUMLAH'] = 0;
|
||
|
$data1['JUMLAH_AR'] = 0;
|
||
|
$data1['RATA_RATA'] = 0;
|
||
|
$data1['subRows'] = [];
|
||
|
|
||
|
$data2 = [];
|
||
|
foreach ($value1 as $key2 => $value2) { //kpp
|
||
|
$data2['KEY_LABEL'] = $key1 . '-' . $key2;
|
||
|
$data2['LABEL'] = '';
|
||
|
$data2['JUMLAH'] = 0;
|
||
|
$data2['JUMLAH_AR'] = 0;
|
||
|
$data2['RATA_RATA'] = 0;
|
||
|
$data2['subRows'] = [];
|
||
|
|
||
|
$data3 = [];
|
||
|
foreach ($value2 as $key3 => $value3) { //seksi
|
||
|
$data3['KEY_LABEL'] = $key1 . '-' . $key3;
|
||
|
$data3['LABEL'] = '';
|
||
|
$data3['NAMA_KANTOR'] = '';
|
||
|
$data3['JUMLAH'] = 0;
|
||
|
$data3['JUMLAH_AR'] = 0;
|
||
|
$data3['RATA_RATA'] = 0;
|
||
|
$data3['subRows'] = [];
|
||
|
|
||
|
$data4 = [];
|
||
|
foreach ($value3 as $key4 => $value4) { //AR
|
||
|
$data4['KEY_LABEL'] = $key1 . '-' . $value4['KODE_PEG'];
|
||
|
$data4['LABEL'] = $value4['NAMA'];
|
||
|
$data4['JUMLAH'] = (float) $value4['JML'];
|
||
|
|
||
|
foreach ($value4 as $key5 => $value5) {
|
||
|
$data4[$key5] = $value5;
|
||
|
}
|
||
|
|
||
|
$data3['LABEL'] = $value4['NAMA_UNIT_ES4'];
|
||
|
$data3['NAMA_KANTOR'] = $value4['NAMA_KANTOR'];
|
||
|
$data2['LABEL'] = $value4['NAMA_KANTOR'];
|
||
|
$data1['LABEL'] = $value4['NAMA_KANWIL'];
|
||
|
|
||
|
$data3['JUMLAH'] += $data4['JUMLAH'];
|
||
|
$data3['JUMLAH_AR'] += ($value4['ISEXIST_INWAS'] == 'TRUE' && $value4['NAMA_JABATAN'] == 'Account Representative' ? 1 : 0);
|
||
|
array_push($data3['subRows'], $data4);
|
||
|
}
|
||
|
$data3['RATA_RATA'] = $data3['JUMLAH_AR'] == 0 ? 0 : $data3['JUMLAH'] / $data3['JUMLAH_AR'];
|
||
|
$data2['JUMLAH'] += $data3['JUMLAH'];
|
||
|
$data2['JUMLAH_AR'] += $data3['JUMLAH_AR'];
|
||
|
array_push($data2['subRows'], $data3);
|
||
|
}
|
||
|
$data2['RATA_RATA'] = $data2['JUMLAH_AR'] == 0 ? 0 : $data2['JUMLAH'] / $data2['JUMLAH_AR'];
|
||
|
$data1['JUMLAH'] += $data2['JUMLAH'];
|
||
|
$data1['JUMLAH_AR'] += $data2['JUMLAH_AR'];
|
||
|
array_push($data1['subRows'], $data2);
|
||
|
}
|
||
|
$data1['RATA_RATA'] = $data1['JUMLAH_AR'] == 0 ? 0 : $data1['JUMLAH'] / $data1['JUMLAH_AR'];
|
||
|
array_push($bentukanArray, $data1);
|
||
|
}
|
||
|
$dataReturn['data'] = $bentukanArray;
|
||
|
|
||
|
$tempData = $bentukanArray;
|
||
|
$dataChart = $this->urutKanwil($bentukanArray);
|
||
|
$dataReturn['urutKanwil'] = $dataChart['urutKanwil'];
|
||
|
$dataReturn['urutKpp'] = $dataChart['urutKpp'];
|
||
|
$dataReturn['urutSeksi'] = $dataChart['urutSeksi'];
|
||
|
$dataReturn['urutPegawai'] = $dataChart['urutPegawai'];
|
||
|
|
||
|
return $this->respond($dataReturn, 200);
|
||
|
}
|
||
|
|
||
|
protected function urutKanwil($tempData)
|
||
|
{
|
||
3 months ago
|
array_sort_by_multiple_keys($tempData, ['TOTAL' => SORT_DESC, 'KEY_LABEL' => SORT_ASC]);
|
||
6 months ago
|
//kanwil
|
||
|
$kanwil = array_slice($tempData, 0, 5);
|
||
|
|
||
|
//kpp
|
||
|
$kppInKanwil = [];
|
||
|
foreach ($tempData as $key => $value) {
|
||
|
foreach ($value['subRows'] as $key2 => $value2) {
|
||
|
array_push($kppInKanwil, $value2);
|
||
|
}
|
||
|
}
|
||
3 months ago
|
array_sort_by_multiple_keys($kppInKanwil, ['TOTAL' => SORT_DESC, 'KEY_LABEL' => SORT_ASC]);
|
||
6 months ago
|
$kpp = array_slice($kppInKanwil, 0, 5);
|
||
|
|
||
|
//seksi
|
||
|
$seksiInKpp = [];
|
||
|
foreach ($kppInKanwil as $key => $value) {
|
||
|
foreach ($value['subRows'] as $key2 => $value2) {
|
||
|
array_push($seksiInKpp, $value2);
|
||
|
}
|
||
|
}
|
||
3 months ago
|
array_sort_by_multiple_keys($seksiInKpp, ['TOTAL' => SORT_DESC, 'KEY_LABEL' => SORT_ASC]);
|
||
6 months ago
|
$seksi = array_slice($seksiInKpp, 0, 5);
|
||
|
|
||
|
//ar Aktif
|
||
|
$arInSeksi = [];
|
||
|
foreach ($seksiInKpp as $key => $value) {
|
||
|
foreach ($value['subRows'] as $key2 => $value2) {
|
||
3 months ago
|
// if ($value2['NAMA_JABATAN'] == 'Account Representative' && $value2['ISEXIST_INWAS'] == 'TRUE') {
|
||
|
array_push($arInSeksi, $value2);
|
||
|
// }
|
||
6 months ago
|
}
|
||
|
}
|
||
3 months ago
|
array_sort_by_multiple_keys($arInSeksi, ['TOTAL' => SORT_DESC]);
|
||
6 months ago
|
$ar = array_slice($arInSeksi, 0, 5);
|
||
|
|
||
|
foreach ($kanwil as $key => $value) {
|
||
|
unset($kanwil[$key]['subRows']);
|
||
|
}
|
||
|
|
||
|
foreach ($kpp as $key => $value) {
|
||
|
unset($kpp[$key]['subRows']);
|
||
|
}
|
||
|
foreach ($seksi as $key => $value) {
|
||
|
unset($seksi[$key]['subRows']);
|
||
|
}
|
||
|
|
||
|
$data['urutKanwil'] = $kanwil;
|
||
|
$data['urutKpp'] = $kpp;
|
||
|
$data['urutSeksi'] = $seksi;
|
||
|
$data['urutPegawai'] = $ar;
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
protected function urutKpp($tempData)
|
||
|
{
|
||
|
|
||
|
$kppInKanwil = [];
|
||
|
foreach ($tempData as $key => $value) {
|
||
|
foreach ($value['subRows'] as $key2 => $value2) {
|
||
|
array_push($kppInKanwil, $value2);
|
||
|
// # code...
|
||
|
}
|
||
|
}
|
||
3 months ago
|
array_sort_by_multiple_keys($kppInKanwil, ['TOTAL' => SORT_DESC, 'KEY_LABEL' => SORT_ASC]);
|
||
6 months ago
|
//hilangkan child subRows
|
||
|
$dataRet = array_slice($kppInKanwil, 0, 5);
|
||
|
return $dataRet;
|
||
|
}
|
||
|
|
||
|
protected function urutSeksi($tempData)
|
||
|
{
|
||
|
|
||
|
$kppInKanwil = [];
|
||
|
foreach ($tempData as $key => $value) {
|
||
|
foreach ($value['subRows'] as $key2 => $value2) {
|
||
|
array_push($kppInKanwil, $value2);
|
||
|
}
|
||
|
}
|
||
3 months ago
|
array_sort_by_multiple_keys($kppInKanwil, ['TOTAL' => SORT_DESC, 'KEY_LABEL' => SORT_ASC]);
|
||
6 months ago
|
|
||
|
//hilangkan child subRows
|
||
|
$dataRet = array_slice($kppInKanwil, 0, 5);
|
||
|
return $dataRet;
|
||
|
}
|
||
|
|
||
7 months ago
|
}
|