First commit / commit pertama
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* partials/laporan_body.php — Konten halaman Laporan & Cetak (Fase F).
|
||||
* Di-include oleh admin/pelaporan.php & pimpinan/pelaporan.php (butuh $pdo).
|
||||
*/
|
||||
$wilOpt = $pdo->query("SELECT id, nama FROM wilayah ORDER BY nama")->fetchAll();
|
||||
?>
|
||||
<div class="page-header">
|
||||
<div class="breadcrumb"><span>Laporan</span><span class="sep">/</span><span>Cetak</span></div>
|
||||
<h1>📄 Laporan & Cetak</h1>
|
||||
<p>Laporan per wilayah, rekap penerima bantuan, dan grafik komparatif antar kelurahan (KF-29/30/31).</p>
|
||||
</div>
|
||||
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:18px;margin-bottom:18px;">
|
||||
<div class="card">
|
||||
<h3 style="font-size:0.95rem;margin-bottom:10px;">📍 Laporan per Kelurahan</h3>
|
||||
<p style="font-size:0.84rem;color:var(--text-secondary);margin-bottom:10px;">Pilih kelurahan untuk laporan lengkap (statistik + daftar rumah tangga), siap dicetak/PDF.</p>
|
||||
<div style="display:flex;gap:8px;">
|
||||
<select id="lapWilayah" class="form-control">
|
||||
<?php foreach ($wilOpt as $w): ?><option value="<?= $w['id'] ?>"><?= htmlspecialchars($w['nama']) ?></option><?php endforeach; ?>
|
||||
</select>
|
||||
<button class="btn btn-primary" onclick="bukaLaporanWilayah()"><i class="fas fa-file-lines"></i> Buka</button>
|
||||
</div>
|
||||
<div id="lapPreview" style="margin-top:12px;font-size:0.85rem;"></div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3 style="font-size:0.95rem;margin-bottom:10px;">💳 Rekap Penerima Bantuan</h3>
|
||||
<p style="font-size:0.84rem;color:var(--text-secondary);margin-bottom:10px;">Daftar seluruh penerima bantuan aktif, dikelompokkan per jenis (PKH, BPNT, dll).</p>
|
||||
<a class="btn btn-success" href="<?= app_url('api/laporan_bantuan.php?format=print') ?>" target="_blank"><i class="fas fa-file-pdf"></i> Buka Rekap Bantuan</a>
|
||||
<a class="btn btn-ghost" href="<?= app_url('api/warga_export.php?format=csv') ?>"><i class="fas fa-file-csv"></i> Export Data CSV</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3 style="font-size:0.95rem;margin-bottom:10px;">📊 Grafik Komparatif Antar Kelurahan</h3>
|
||||
<div style="height:340px;"><canvas id="cKomparatif"></canvas></div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
|
||||
<script>
|
||||
const LAPI = APP_BASE + '/api';
|
||||
function bukaLaporanWilayah(){
|
||||
const id = document.getElementById('lapWilayah').value;
|
||||
window.open(`${LAPI}/laporan_wilayah.php?wilayah_id=${id}&format=print`, '_blank');
|
||||
}
|
||||
// preview ringkas saat ganti pilihan
|
||||
async function previewWilayah(){
|
||||
const id = document.getElementById('lapWilayah').value;
|
||||
const d = (await (await fetch(`${LAPI}/laporan_wilayah.php?wilayah_id=${id}&format=json`)).json()).data;
|
||||
document.getElementById('lapPreview').innerHTML =
|
||||
`<b>${d.nama}</b> — ${d.miskin} RT miskin (${d.persen}%), cakupan ${d.cakupan}%, ${d.terverif} terverifikasi`;
|
||||
}
|
||||
document.getElementById('lapWilayah').addEventListener('change', previewWilayah);
|
||||
|
||||
(async ()=>{
|
||||
const km = (await (await fetch(`${LAPI}/komparatif.php`)).json()).data;
|
||||
new Chart(cKomparatif,{type:'bar',data:{labels:km.labels,datasets:[
|
||||
{label:'% Penduduk Miskin',data:km.persentase_miskin,backgroundColor:'#EF4444'},
|
||||
{label:'Cakupan Bantuan %',data:km.cakupan_bantuan,backgroundColor:'#10B981'},
|
||||
{label:'% Terverifikasi',data:km.persen_verifikasi,backgroundColor:'#2563EB'}
|
||||
]},options:{responsive:true,maintainAspectRatio:false,animation:false,scales:{y:{beginAtZero:true}},plugins:{legend:{position:'bottom'}}}});
|
||||
previewWilayah();
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user