prepare("SELECT * FROM rumah_ibadah WHERE id=? AND deleted_at IS NULL"); $r->bind_param('i', $ibadah_id); $r->execute(); $ib = $r->get_result()->fetch_assoc(); $r->close(); if (!$ib) { http_response_code(404); die('Tidak ditemukan'); } $s = $conn->prepare(" SELECT COUNT(*) AS jml_kk, COALESCE(SUM(jumlah_jiwa), 0) AS jml_jiwa, COALESCE(SUM(CASE WHEN status_bantuan='Sudah Ditangani' THEN 1 ELSE 0 END), 0) AS ditangani FROM penduduk_miskin WHERE ibadah_id=? AND is_active=1 AND deleted_at IS NULL "); $s->bind_param('i', $ibadah_id); $s->execute(); $st = $s->get_result()->fetch_assoc(); $s->close(); $pct = $st['jml_kk'] > 0 ? round($st['ditangani'] / $st['jml_kk'] * 100) : 0; $w = $conn->prepare(" SELECT nama_kk, jumlah_jiwa, kategori, status_bantuan FROM penduduk_miskin WHERE ibadah_id=? AND is_active=1 AND deleted_at IS NULL ORDER BY nama_kk "); $w->bind_param('i', $ibadah_id); $w->execute(); $warga_res = $w->get_result(); $warga_list = []; while ($row = $warga_res->fetch_assoc()) $warga_list[] = $row; $w->close(); $conn->close(); $tanggal = date('d F Y'); header('Content-Type: text/html; charset=utf-8'); ?>
= htmlspecialchars($ib['jenis']) ?> · = htmlspecialchars($ib['alamat'] ?? '-') ?>
Digenerate: = $tanggal ?>
| # | Nama KK | Jiwa | Kategori | Status Bantuan |
|---|---|---|---|---|
| = $i + 1 ?> | = htmlspecialchars($warga['nama_kk']) ?> | = $warga['jumlah_jiwa'] ?> | = $warga['kategori'] ?> | = $warga['status_bantuan'] ?> |