Browse Source

identifikasi

main^2
= 7 months ago
parent
commit
db7a2b9134
  1. 92
      app/Controllers/Kewilayahan/Sebaran/IdentifikasiLapangan.php
  2. 55
      app/Controllers/Kewilayahan/Sebaran/KLU.php
  3. 46
      app/Controllers/Kewilayahan/Sebaran/SPTTAhunan.php
  4. 23
      app/Libraries/KpdlLibrary.php
  5. 191
      app/Views/kewilayahan/kytp/componentProgresifitas/ChartKPDL.js
  6. 98
      app/Views/kewilayahan/kytp/componentProgresifitas/KLU.js

92
app/Controllers/Kewilayahan/Sebaran/IdentifikasiLapangan.php

@ -0,0 +1,92 @@
<?php
namespace App\Controllers\Kewilayahan\Sebaran;
use App\Libraries\KpdlLibrary;
class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp
{
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();
$KpdlLibrary = new KpdlLibrary;
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');
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")
->join("(" . $npwp . ") C", 'A.KODE = C.BULAN', 'left')
->orderBy('BULAN');
return $KpdlLibrary->single_array($data->get()->getResult(), 'JML');
} else {
$tgl_format = date('Y') . '-' . $bulan . '-' . '01';
$generateTgl = "SELECT TO_CHAR(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD')) - level + 1,'DD') AS TGL
FROM
dual
CONNECT BY LEVEL <= (trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD'))) - to_date('" . $tgl_format . "','YYYY-MM-DD') + 1)";
$data = $db->table('KPDL_MV_LOKASI_SUBJEK B')
->select("TO_CHAR(CREATION_DATE,'DD') as TGL, COUNT(1) JML")
->where("to_char(CREATION_DATE,'YYYY') = ", date('Y'))
->where("to_char(CREATION_DATE,'MM') = " . $bulan)
->groupBy("TO_CHAR(CREATION_DATE,'DD')");
if ($opsiWilZona == 'wilayah') {
$data = $data->whereIn('ADM4_PCODE', $adm4_pcode);
}
if ($opsiWilZona == 'zona') {
$data = $data->whereIn('ID_POLY_ZONA', $id_poly_zona);
}
$data = $data->getCompiledSelect();
$dataRet = $db->newQuery()
->select("A.TGL, B.JML")
->from("(" . $generateTgl . ") A")
->join("(" . $data . ") B", "A.TGL = B.TGL", 'left')
->orderBy("TGL");
return $KpdlLibrary->single_array($dataRet->get()->getResult(), 'JML');
}
}
protected function generateSeries($bulan)
{
$db = \Config\Database::connect();
$tgl_format = date('Y') . '-' . $bulan . '-' . '01';
$generateTgl = $db->query("SELECT TO_CHAR(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD')) - level + 1,'DD') AS TGL
FROM
dual
CONNECT BY LEVEL <= (trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD'))) - to_date('" . $tgl_format . "','YYYY-MM-DD') + 1) ORDER BY TGL");
$data = $generateTgl->getResult();
$data_arr = [];
foreach ($data as $row) {
array_push($data_arr, $row->TGL);
}
return $data_arr;
}
}

55
app/Controllers/Kewilayahan/Sebaran/KLU.php

@ -0,0 +1,55 @@
<?php
namespace App\Controllers\Kewilayahan\Sebaran;
class KLU extends \App\Controllers\Kewilayahan\Kytp
{
protected function data($request, $jenischart)
{
$opsiWilZona = $request->getPost('opsiWilZona');
$adm4_pcode = $request->getPost('adm4_pcode') ?? [];
$id_poly_zona = $request->getPost('id_poly_zona') ?? [];
$db = \Config\Database::connect();
$npwp = $db->table('KPDL_MV_LOKASI_SUBJEK A')->select('NPWP, KD_GOLPOK, NM_GOLPOK, JUMLAH_PEMBAYARAN_THN_TERAKHIR')->distinct()
->where('NPWP IS NOT NULL');
if ($jenischart == 'dataKluYgBayar') {
$npwp = $npwp->where("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);
}
$agg = "count(1) as JML";
if ($jenischart == 'dataRupiahBayar') {
$agg = "SUM(JUMLAH_PEMBAYARAN_THN_TERAKHIR) as JML";
}
$data = $db->newQuery()
->fromSubquery($npwp, "A")
->select("KD_GOLPOK, NM_GOLPOK," . $agg)
->groupBy("KD_GOLPOK, NM_GOLPOK")->orderBy("JML", "desc")->limit(5);
$data = $data->get()->getResult();
$ret = [];
foreach ($data as $b) {
array_push($ret,
[
'name' => $b->NM_GOLPOK,
'id' => $b->KD_GOLPOK,
'y' => floatval($b->JML),
]
);
}
return $ret;
}
}

46
app/Controllers/Kewilayahan/Sebaran/SPTTAhunan.php

@ -0,0 +1,46 @@
<?php
namespace App\Controllers\Kewilayahan\Sebaran;
class SPTTAhunan extends \App\Controllers\Kewilayahan\Kytp
{
protected function data($request, $tahun)
{
$opsiWilZona = $request->getPost('opsiWilZona');
$adm4_pcode = $request->getPost('adm4_pcode') ?? [];
$id_poly_zona = $request->getPost('id_poly_zona') ?? [];
$db = \Config\Database::connect();
$npwp = $db->table('KPDL_MV_LOKASI_SUBJEK A')->select('NPWP, B.KETERANGAN')->distinct()
->join('KPDL_REF_STATUS_SPT B', "A.STATUS_SPT_TAHUNAN_TERAKHIR = B.ID_STATUS_SPT", "left")
->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);
}
$data = $db->newQuery()
->fromSubquery($npwp, "A")
->select("KETERANGAN, count(1) as JML")
->groupBy("A.KETERANGAN");
$data = $data->get()->getResult();
$ret = [];
foreach ($data as $b) {
array_push($ret, ['name' => $b->KETERANGAN,
// 'color' => $b->IDENTIFIKASI == 'NON NPWP' ? 'orange' : 'green',
'y' => floatval($b->JML),
]
);
}
return $ret;
}
}

23
app/Libraries/KpdlLibrary.php

@ -0,0 +1,23 @@
<?php
namespace App\Libraries;
class KpdlLibrary
{
//private $fixedKey = session('nip');
public function single_array($a, $key)
{
$ret = [];
foreach ($a as $b) {
array_push($ret, floatval($b->$key));
}
for ($i = 0; $i < 12; $i++) {
if (!isset($ret[$i])) {
array_push($ret, 0);
}
}
return $ret;
}
}

191
app/Views/kewilayahan/kytp/componentProgresifitas/ChartKPDL.js

@ -0,0 +1,191 @@
import React, { useEffect, useRef, useState } from "react"
import Highcharts from "highcharts"
import HighchartsReact from "highcharts-react-official"
import { Col, Row } from "reactstrap"
import { Badge } from "primereact/badge"
import { Button as ButtonP } from "primereact/button"
import { format_angka } from "../util"
import collect from "collect.js"
import jQuery from "jquery"
import "primereact/resources/themes/bootstrap4-light-blue/theme.css"
import "primeflex/primeflex.css"
const ChartKpdl = ({ dataSend }) => {
const base_url = "<?=base_url()?>"
const refChart = useRef(null)
const [data, setData] = useState({
kpdl: [],
akum: [],
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
})
const [selectedBulan, setSelectedBulan] = useState("semua")
const [bulan, setBulan] = useState([])
useEffect(() => {
jQuery.get({
url: base_url + "kewilayahan/kytp/identifikasiLapangan",
dataType: "json",
type: "POST",
data: {
...dataSend,
bulan: selectedBulan
},
success: (data) => {
setData(data)
}
})
}, [dataSend, selectedBulan])
useEffect(() => {
jQuery.get({
url: base_url + "kewilayahan/kytp/getBulan",
dataType: "json",
type: "GET",
success: (data) => {
setBulan(data)
}
})
}, [])
const optionsChart1 = () => {
return {
chart: {
zoomType: "xy",
height: "320pt"
},
title: {
text: "",
align: "left"
},
subtitle: {
align: "left"
},
xAxis: [
{
categories: data.categories,
crosshair: true
}
],
yAxis: [
{
labels: {
style: {
color: Highcharts.getOptions().colors[2]
}
},
title: {
text: "Lokasi KPDL",
style: {
color: Highcharts.getOptions().colors[2]
}
},
opposite: true
},
{
title: {
text: "Lokasi KPDL s.d.",
style: {
color: Highcharts.getOptions().colors[0]
}
},
labels: {
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}
],
tooltip: {
shared: true
},
legend: {
layout: "horizontal",
align: "center",
verticalAlign: "top",
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || // theme
"rgba(255,255,255,0.25)"
},
// plotOptions: {
// // series: hijau_klik_series
// },
series: [
{
name: "Lokasi KPDL",
type: "column",
yAxis: 0,
color: Highcharts.getOptions().colors[2],
data: data.kpdl,
marker: {
enabled: true
},
tooltip: {
valueSuffix: " Kpdl"
}
},
{
name: "Lokasi KPDL akumulasi",
type: "spline",
yAxis: 1,
data: data.akum,
marker: {
enabled: true
},
tooltip: {
valueSuffix: " data"
},
visible: false
}
]
}
}
const refBulanOnClick = (e) => {
const kodeBulan = e.target.dataset.value
console.log(kodeBulan)
setSelectedBulan(kodeBulan)
}
return (
<>
<Row>
<Col md="12">
<div className="d-flex justify-content-between ">
<div>
<span className="mr-2">Bulan :</span>
{bulan.map((val, idx) => {
return (
<Badge
id={idx}
data-value={val}
severity="warning"
value={val}
className="ref_bulan_a cursor-pointer mr-10"
onClick={(e) => refBulanOnClick(e)}
></Badge>
)
})}
</div>
<div>
<span>Bulan terpilih : </span>
<span>{selectedBulan}</span>
</div>
</div>
</Col>
</Row>
<Row>
<Col>
<HighchartsReact ref={refChart} highcharts={Highcharts} options={optionsChart1()} />
</Col>
</Row>
</>
)
}
export default ChartKpdl

98
app/Views/kewilayahan/kytp/componentProgresifitas/KLU.js

@ -0,0 +1,98 @@
import React, { useEffect, useRef, useState } from "react"
import Highcharts from "highcharts"
import HighchartsReact from "highcharts-react-official"
import { Col, Row } from "reactstrap"
import { format_angka } from "../util"
import collect from "collect.js"
const KLU = ({ dataSend }) => {
const base_url = "<?=base_url()?>"
const refChart = useRef(null)
const refChart1 = useRef(null)
const refChart2 = useRef(null)
const [dataKluTerdaftar, setDataKluTerdaftar] = useState(null)
const [dataKluYgBayar, setDataKluYgbayar] = useState(null)
const [dataRupiahBayar, setDataRupiahBayar] = useState(null)
useEffect(() => {
jQuery.get({
url: base_url + "kewilayahan/kytp/sebaranKLU",
dataType: "json",
type: "POST",
data: {
...dataSend
},
success: (resp) => {
setDataKluTerdaftar(resp.dataKluTerdaftar)
setDataKluYgbayar(resp.dataKluYgBayar)
setDataRupiahBayar(resp.dataRupiahBayar)
}
})
}, [dataSend])
const optionsChart = (data, title, attribute1) => {
const total_wp = collect(data).sum("y")
return {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: "pie",
zoomType: "xy",
height: "300"
},
title: {
text: title,
style: { fontSize: "10px" }
},
tooltip: {
pointFormat: "<b>{point.percentage:.1f}%</b><br>: {point.y} dari " + format_angka(total_wp) + " total " + attribute1
},
accessibility: {
point: {
valueSuffix: "%"
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: "pointer",
dataLabels: {
enabled: true,
style: { fontSize: "10px" },
format: "{point.name}: <br> {point.percentage:.1f} %"
}
}
// series: pie_click
},
series: [
{
name: "",
data
}
]
}
}
return (
<>
<Row>
<Col md="6">
<HighchartsReact ref={refChart} highcharts={Highcharts} options={optionsChart(dataKluTerdaftar, "KLU Terdaftar", "NPWP")} />
</Col>
<Col md="6">
<HighchartsReact ref={refChart1} highcharts={Highcharts} options={optionsChart(dataKluYgBayar, "KLU Yang Bayar", "NPWP")} />
</Col>
<Col md="12">
<HighchartsReact
ref={refChart2}
highcharts={Highcharts}
options={optionsChart(dataRupiahBayar, "Dominasi KLU berdarkan Jumlah Bayar", "Keseluruhan Pembayaran")}
/>
</Col>
</Row>
</>
)
}
export default KLU
Loading…
Cancel
Save