6 changed files with 254 additions and 6 deletions
@ -0,0 +1,54 @@
|
||||
<?php |
||||
namespace App\Controllers\Kewilayahan\Sebaran; |
||||
|
||||
class Pengampu extends \App\Controllers\Kewilayahan\Kytp |
||||
|
||||
{ |
||||
protected function data($request, $jenis) |
||||
{ |
||||
$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')->select("NM_KPP_ADM, count(1) JML", false) |
||||
->groupBy("NM_KPP_ADM")->orderBy("JML", 'desc'); |
||||
$kolom = "JNS_WP_MFWP"; |
||||
|
||||
switch ($jenis) { |
||||
case 'assign': |
||||
|
||||
break; |
||||
case 'unassign': |
||||
$npwp = $npwp->where("NIP_AR_PENGAMPU", "NPWP TIDAK DITEMUKAN"); |
||||
break; |
||||
default: |
||||
|
||||
break; |
||||
} |
||||
|
||||
if ($opsiWilZona == 'wilayah') { |
||||
$npwp->whereIn('ADM4_PCODE', $adm4_pcode); |
||||
} |
||||
|
||||
if ($opsiWilZona == 'zona') { |
||||
$npwp->whereIn('ID_POLY_ZONA', $id_poly_zona); |
||||
} |
||||
|
||||
$data = $npwp->get()->getResult(); |
||||
|
||||
$ret = []; |
||||
|
||||
foreach ($data as $b) { |
||||
|
||||
array_push($ret, ['name' => $b->NM_KPP_ADM, |
||||
// 'color' => , |
||||
'y' => floatval($b->JML), |
||||
] |
||||
); |
||||
} |
||||
|
||||
return $ret; |
||||
} |
||||
} |
@ -0,0 +1,88 @@
|
||||
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 Pengampu = ({ dataSend }) => { |
||||
const base_url = "<?=base_url()?>" |
||||
|
||||
const refChart = useRef(null) |
||||
const refChart2 = useRef(null) |
||||
const [dataAssign, setDataAssign] = useState(null) |
||||
const [dataUnAssign, setDataUnAssign] = useState(null) |
||||
|
||||
useEffect(() => { |
||||
jQuery.get({ |
||||
url: base_url + "kewilayahan/kytp/sebaranPengampu", |
||||
dataType: "json", |
||||
type: "POST", |
||||
data: { |
||||
...dataSend |
||||
}, |
||||
success: (data) => { |
||||
setDataAssign(data.assign) |
||||
setDataUnAssign(data.unassign) |
||||
} |
||||
}) |
||||
}, [dataSend]) |
||||
|
||||
const optionsChart = (data, title) => { |
||||
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 NPWP" |
||||
}, |
||||
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(dataAssign, "KPP Terdaftar")} /> |
||||
</Col> |
||||
<Col md="6"> |
||||
<HighchartsReact ref={refChart2} highcharts={Highcharts} options={optionsChart(dataUnAssign, "Status UnAssign")} /> |
||||
</Col> |
||||
</Row> |
||||
</> |
||||
) |
||||
} |
||||
|
||||
export default Pengampu |
Loading…
Reference in new issue