$p['status_bantuan'] === 'sudah_dibantu')); $belum = count(array_filter($allPenduduk, fn($p) => $p['status_bantuan'] === 'belum_dibantu')); $menunggu = count(array_filter($allPenduduk, fn($p) => $p['status_bantuan'] === 'menunggu_verifikasi')); $pctSudah = $total > 0 ? round($sudah / $total * 100, 1) : 0; $bulan = ['','Januari','Februari','Maret','April','Mei','Juni', 'Juli','Agustus','September','Oktober','November','Desember']; $tgl = date('j') . ' ' . $bulan[(int)date('n')] . ' ' . date('Y'); $cetakOleh = htmlspecialchars(currentUser()['nama'] ?? 'Admin'); // ── Baris tabel ibadah ──────────────────────────────────────────────────────── $rowsIbadah = ''; foreach ($allIbadah as $i => $ib) { $binaan = count(array_filter($allPenduduk, fn($p) => $p['rumah_ibadah_id'] == $ib['id'])); $bg = ($i % 2 === 0) ? '#ffffff' : '#f9fafb'; $rowsIbadah .= " " . ($i + 1) . " " . htmlspecialchars($ib['nama']) . " " . htmlspecialchars($ib['jenis']) . " {$ib['radius']} m {$binaan} "; } if (!$rowsIbadah) { $rowsIbadah = "Belum ada data rumah ibadah."; } // ── Baris tabel penduduk ───────────────────────────────────────────────────── $statusLabel = [ 'belum_dibantu' => 'Belum Dibantu', 'sudah_dibantu' => 'Sudah Dibantu', 'menunggu_verifikasi'=> 'Menunggu Verifikasi', ]; $statusColor = [ 'belum_dibantu' => '#c0392b', 'sudah_dibantu' => '#1a7a3e', 'menunggu_verifikasi'=> '#856404', ]; $rowsPenduduk = ''; foreach ($allPenduduk as $i => $p) { $bg = ($i % 2 === 0) ? '#ffffff' : '#f9fafb'; $status = $p['status_bantuan']; $slbl = $statusLabel[$status] ?? $status; $scol = $statusColor[$status] ?? '#333'; $jml = $p['jumlah_anggota'] ?? ($anggotaCounts[$p['id']] ?? 1); $jarak = $p['jarak_meter'] ? round($p['jarak_meter']) . ' m' : '-'; $tglB = $p['tanggal_bantuan'] ? date('d/m/Y', strtotime($p['tanggal_bantuan'])) : '-'; $rowsPenduduk .= " " . ($i + 1) . " " . htmlspecialchars($p['kk_nama']) . "" . ($p['nik'] ? "
{$p['nik']}" : '') . " " . htmlspecialchars($p['alamat'] ?? '-') . " {$jml} " . htmlspecialchars($p['ibadah_nama'] ?? '-') . " {$jarak} {$slbl} " . htmlspecialchars($p['jenis_bantuan'] ?? '-') . " {$tglB} "; } if (!$rowsPenduduk) { $rowsPenduduk = "Belum ada data penduduk miskin."; } // ── HTML Template ───────────────────────────────────────────────────────────── $html = << body { font-family: sans-serif; font-size: 10.5px; color: #1a1a1a; } h1 { font-size: 15px; text-align: center; color: #1e3a5f; margin-bottom: 2px; } .sub { text-align: center; font-size: 9.5px; color: #555; margin-bottom: 14px; } .section { font-size: 11px; font-weight: bold; color: #1e3a5f; border-bottom: 2px solid #1e3a5f; padding-bottom: 3px; margin: 12px 0 7px; } table { width: 100%; border-collapse: collapse; font-size: 9.5px; } th { background: #1e3a5f; color: white; padding: 5px 4px; text-align: center; } td { padding: 4px 5px; border-bottom: 1px solid #e5e7eb; vertical-align: middle; } .sg { width: 100%; border-collapse: collapse; margin-bottom: 6px; } .sc { width: 25%; padding: 8px; text-align: center; border: 1px solid #d1d5db; border-radius: 4px; } .sn { font-size: 20px; font-weight: bold; margin-bottom: 2px; } .sl { font-size: 8.5px; color: #6b7280; } .g { color: #1a7a3e; } .r { color: #c0392b; } .y { color: #856404; }

LAPORAN SEBARAN PENDUDUK MISKIN

Sistem WebGIS GeoMiskin — Universitas Tanjungpura  |  Dicetak: {$tgl}  |  Oleh: {$cetakOleh}
Ringkasan Statistik
{$total}
Total KK Miskin
{$sudah}
Sudah Dibantu ({$pctSudah}%)
{$belum}
Belum Dibantu
{$menunggu}
Menunggu Verifikasi
Data Rumah Ibadah
{$rowsIbadah}
No Nama Rumah Ibadah Jenis Radius KK Binaan
Daftar Penduduk Miskin
{$rowsPenduduk}
No Nama KK / NIK Alamat Jiwa Rumah Ibadah Jarak Status Jenis Bantuan Tgl Bantuan
HTML; // ── Generate PDF ─────────────────────────────────────────────────────────────── try { $mpdf = new \Mpdf\Mpdf([ 'mode' => 'utf-8', 'format' => 'A4-L', 'margin_top' => 12, 'margin_bottom' => 12, 'margin_left' => 10, 'margin_right' => 10, ]); $mpdf->SetTitle('Laporan Sebaran Penduduk Miskin'); $mpdf->SetAuthor('GeoMiskin WebGIS'); $mpdf->WriteHTML($html); $fname = 'laporan_penduduk_miskin_' . date('Y-m-d') . '.pdf'; $mpdf->Output($fname, 'D'); } catch (\Mpdf\MpdfException $e) { http_response_code(500); echo '
Gagal membuat PDF: ' . htmlspecialchars($e->getMessage()) . '

Pastikan extension GD aktif di XAMPP:
  1. Buka C:\\xampp\\php\\php.ini
  2. Cari ;extension=gd → hapus tanda titik koma
  3. Restart Apache di XAMPP Control Panel
'; }