diff --git a/app/Http/Controllers/Lainnya/SimulasiJabatan/SimulasiJabatanController.php b/app/Http/Controllers/Lainnya/SimulasiJabatan/SimulasiJabatanController.php
index e93134fb..74f42846 100644
--- a/app/Http/Controllers/Lainnya/SimulasiJabatan/SimulasiJabatanController.php
+++ b/app/Http/Controllers/Lainnya/SimulasiJabatan/SimulasiJabatanController.php
@@ -120,6 +120,65 @@ class SimulasiJabatanController extends Controller
return response()->json($totals->all());
}
+ /**
+ * Agregat Total P2 per unit kerja untuk visualisasi grafik batang.
+ * Pengelompokan mengikuti menu Remunerasi > P2: fakultas 1-9 + "Universitas"
+ * (seluruh unit non-fakultas). Filter unit kerja diabaikan supaya seluruh
+ * unit tetap tampil; filter periode & jenis pegawai tetap dihormati.
+ */
+ public function chart(Request $request)
+ {
+ @set_time_limit(300);
+ $periode = (int) ($request->input('periode') ?: optional(Periode::where('status', true)->first())->id_periode);
+
+ $rows = $this->dataset($periode);
+ if ($request->filled('jenis_pegawai')) {
+ $rows = $rows->where('jenis_pegawai', $request->input('jenis_pegawai'));
+ }
+
+ $parse = fn ($value) => (float) str_replace(',', '.', str_replace('.', '', (string) $value));
+
+ $labels = [
+ 1 => 'Fakultas Hukum',
+ 2 => 'Fakultas Ekonomi dan Bisnis',
+ 3 => 'Fakultas Pertanian',
+ 4 => 'Fakultas Teknik',
+ 5 => 'Fakultas Ilmu Sosial dan Ilmu Politik',
+ 6 => 'Fakultas Keguruan dan Ilmu Pendidikan',
+ 7 => 'Fakultas Kehutanan',
+ 8 => 'Fakultas Matematika dan Ilmu Pengetahuan Alam',
+ 9 => 'Fakultas Kedokteran',
+ SimulasiJabatanExport::UNIT_UNIVERSITAS => 'Universitas',
+ ];
+ $short = [
+ 1 => 'FH', 2 => 'FEB', 3 => 'FP', 4 => 'FT', 5 => 'FISIP',
+ 6 => 'FKIP', 7 => 'FHUT', 8 => 'FMIPA', 9 => 'FK',
+ SimulasiJabatanExport::UNIT_UNIVERSITAS => 'UNIV',
+ ];
+
+ $groups = collect($labels)->map(function ($nama, $id) use ($rows, $parse, $short) {
+ $subset = (int) $id === SimulasiJabatanExport::UNIT_UNIVERSITAS
+ ? $rows->whereNotIn('unit_kerja_id', SimulasiJabatanExport::FAKULTAS_IDS)
+ : $rows->where('unit_kerja_id', (int) $id);
+
+ $sum = fn ($key) => round($subset->sum(fn ($r) => $parse($r[$key])), 2);
+
+ return [
+ 'unit_kerja' => $nama,
+ 'unit_kerja_short' => $short[$id],
+ 'pegawai' => $subset->count(),
+ 'p2_374' => $sum('p2_total_374'),
+ 'p2_377' => $sum('p2_total_377'),
+ 'p2_excel' => $sum('p2_total_excel'),
+ 'p2_374_g12' => $sum('p2_total_374_g12'),
+ 'p2_377_g12' => $sum('p2_total_377_g12'),
+ 'p2_excel_g12' => $sum('p2_total_excel_g12'),
+ ];
+ })->values();
+
+ return response()->json($groups->all());
+ }
+
/**
* Bangun dan cache seluruh baris simulasi untuk satu periode.
*
diff --git a/resources/views/lainnya/simulasi-jabatan/index.blade.php b/resources/views/lainnya/simulasi-jabatan/index.blade.php
index 483c5842..affedf47 100644
--- a/resources/views/lainnya/simulasi-jabatan/index.blade.php
+++ b/resources/views/lainnya/simulasi-jabatan/index.blade.php
@@ -103,6 +103,30 @@
+
@include('components.datatable-header', [
@@ -349,6 +373,72 @@
table.on('draw', refreshSummary);
refreshSummary();
+ // ---- Visualisasi Total P2 per Unit Kerja (grafik batang) ----
+ var rpShort = function(v) {
+ v = Number(v) || 0;
+ if (Math.abs(v) >= 1e9) return 'Rp ' + (v / 1e9).toLocaleString('id-ID', { maximumFractionDigits: 2 }) + ' M';
+ if (Math.abs(v) >= 1e6) return 'Rp ' + (v / 1e6).toLocaleString('id-ID', { maximumFractionDigits: 1 }) + ' jt';
+ return 'Rp ' + v.toLocaleString('id-ID');
+ };
+ var rpFull = function(v) {
+ return 'Rp ' + (Number(v) || 0).toLocaleString('id-ID', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
+ };
+ var shortToFull = {};
+
+ function baseChartOptions() {
+ return {
+ chart: { type: 'bar', height: 340, toolbar: { show: false }, fontFamily: 'inherit' },
+ plotOptions: { bar: { columnWidth: '75%', borderRadius: 3 } },
+ dataLabels: { enabled: false },
+ stroke: { show: true, width: 2, colors: ['transparent'] },
+ colors: ['#4e73df', '#1cc88a', '#f6c23e'],
+ series: [],
+ xaxis: { categories: [] },
+ yaxis: { labels: { formatter: rpShort } },
+ legend: { position: 'top', horizontalAlign: 'left' },
+ grid: { borderColor: '#edf0f3' },
+ tooltip: {
+ shared: true,
+ intersect: false,
+ y: { formatter: rpFull },
+ x: { formatter: function(val) { return shortToFull[val] || val; } }
+ },
+ noData: { text: 'Memuat data…' }
+ };
+ }
+
+ var chartP2 = new ApexCharts(document.querySelector('#chart-p2-unit'), baseChartOptions());
+ var chartP2g12 = new ApexCharts(document.querySelector('#chart-p2-unit-g12'), baseChartOptions());
+ chartP2.render();
+ chartP2g12.render();
+
+ function loadCharts() {
+ $.get('{{ route('lainnya.simulasi-jabatan.chart') }}', {
+ periode: $('#periode').val(),
+ jenis_pegawai: $('#jenis_pegawai').val()
+ }, function(res) {
+ var cats = res.map(function(r) { return r.unit_kerja_short; });
+ shortToFull = {};
+ res.forEach(function(r) { shortToFull[r.unit_kerja_short] = r.unit_kerja + ' (' + r.pegawai + ' pegawai)'; });
+
+ chartP2.updateOptions({ xaxis: { categories: cats } });
+ chartP2.updateSeries([
+ { name: 'P2 2022', data: res.map(function(r) { return r.p2_374; }) },
+ { name: 'P2 2023', data: res.map(function(r) { return r.p2_377; }) },
+ { name: 'P2 Excel', data: res.map(function(r) { return r.p2_excel; }) }
+ ]);
+
+ chartP2g12.updateOptions({ xaxis: { categories: cats } });
+ chartP2g12.updateSeries([
+ { name: 'P2 2022 (+12)', data: res.map(function(r) { return r.p2_374_g12; }) },
+ { name: 'P2 2023 (+12)', data: res.map(function(r) { return r.p2_377_g12; }) },
+ { name: 'P2 Excel (+12)', data: res.map(function(r) { return r.p2_excel_g12; }) }
+ ]);
+ });
+ }
+ $('#periode, #jenis_pegawai').on('change', loadCharts);
+ loadCharts();
+
$('#warm-cache-btn').on('click', function() {
var $btn = $(this);
var modalEl = document.getElementById('warmCacheModal');
@@ -388,6 +478,7 @@
' baris (' + (res.seconds || 0) + ' detik).');
table.ajax.reload(null, false);
refreshSummary();
+ loadCharts();
}, 450);
}).fail(function(xhr) {
clearInterval(timer);
diff --git a/routes/prefix/lainnya.php b/routes/prefix/lainnya.php
index 13f9260b..7bfa4d41 100644
--- a/routes/prefix/lainnya.php
+++ b/routes/prefix/lainnya.php
@@ -13,6 +13,7 @@ Route::prefix('/lainnya')->name('lainnya.')->group(function () {
Route::get('/', [SimulasiJabatanController::class, 'index'])->name('index');
Route::get('/data', [SimulasiJabatanController::class, 'data'])->name('data');
Route::get('/summary', [SimulasiJabatanController::class, 'summary'])->name('summary');
+ Route::get('/chart', [SimulasiJabatanController::class, 'chart'])->name('chart');
Route::get('/export', [SimulasiJabatanController::class, 'export'])->name('export');
Route::post('/warm-cache', [SimulasiJabatanController::class, 'warmCache'])->name('warm-cache');
Route::get('/detail/{nip}', [SimulasiJabatanController::class, 'detail'])->name('detail');