fitur kelola bantuan melalui rumah ibadah
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include 'db_config.php';
|
||||
|
||||
$sql = "SELECT id, nama_ketua_kk, jumlah_anggota, latitude, longitude, rumah_ibadah_id, rumah_ibadah_nama, jarak_ke_rumah_ibadah_m, bantuan_status, bantuan_catatan, bantuan_updated_at, created_at
|
||||
FROM penduduk_miskin
|
||||
ORDER BY created_at DESC";
|
||||
|
||||
$result = $conn->query($sql);
|
||||
$data = [];
|
||||
|
||||
if (!$result) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]);
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$row['latitude'] = (float)$row['latitude'];
|
||||
$row['longitude'] = (float)$row['longitude'];
|
||||
$row['jumlah_anggota'] = (int)$row['jumlah_anggota'];
|
||||
$row['rumah_ibadah_id'] = $row['rumah_ibadah_id'] !== null ? (int)$row['rumah_ibadah_id'] : null;
|
||||
$row['jarak_ke_rumah_ibadah_m'] = $row['jarak_ke_rumah_ibadah_m'] !== null ? (float)$row['jarak_ke_rumah_ibadah_m'] : null;
|
||||
$row['bantuan_status'] = $row['bantuan_status'] ?: 'belum';
|
||||
$row['bantuan_catatan'] = $row['bantuan_catatan'] ?? '';
|
||||
$data[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($data);
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user