Upload perdana untuk deploy

This commit is contained in:
2026-06-11 13:17:31 +07:00
parent 5857b15aec
commit 72133d0a9a
63 changed files with 10057 additions and 457 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
include '../koneksi.php';
header('Content-Type: application/json');
try {
// 1. Fetch all fasilitas_publik
$stmtFp = $pdo->query("SELECT * FROM fasilitas_publik ORDER BY id DESC");
$fasilitasPublik = $stmtFp->fetchAll();
// 2. Fetch all penduduk_miskin (dengan nama FP jika ada join)
$stmtPm = $pdo->query("
SELECT p.*, f.nama as fp_nama
FROM penduduk_miskin p
LEFT JOIN fasilitas_publik f ON p.fasilitas_publik_id = f.id
ORDER BY p.id DESC
");
$pendudukMiskin = $stmtPm->fetchAll();
echo json_encode([
'status' => 'success',
'fasilitasPublik' => $fasilitasPublik,
'pendudukMiskin' => $pendudukMiskin
]);
} catch (PDOException $e) {
echo json_encode([
'status' => 'error',
'message' => 'Database error: ' . $e->getMessage()
]);
}
?>
+24
View File
@@ -0,0 +1,24 @@
<?php
include '../koneksi.php';
header('Content-Type: application/json');
$id = $_GET['id'] ?? null;
if (!$id) {
echo json_encode(['status' => 'error', 'message' => 'ID tidak diberikan']);
exit;
}
try {
$stmt = $pdo->prepare("SELECT * FROM points WHERE id = ?");
$stmt->execute([$id]);
$data = $stmt->fetch(PDO::FETCH_ASSOC);
if ($data) {
echo json_encode(['status' => 'success', 'data' => $data]);
} else {
echo json_encode(['status' => 'error', 'message' => 'Data tidak ditemukan']);
}
} catch (PDOException $e) {
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
}
+28
View File
@@ -0,0 +1,28 @@
<?php
session_start();
if (!isset($_SESSION['role']) || !in_array($_SESSION['role'], ['admin', 'petugas'])) {
header('Content-Type: application/json');
http_response_code(403);
echo json_encode(['status'=>'error','message'=>'Akses ditolak.']);
exit;
}
include '../koneksi.php';
header('Content-Type: application/json');
$id = (int)($_POST['id'] ?? 0);
$status_bantuan = trim($_POST['status_bantuan'] ?? '');
if (!$id || !$status_bantuan) {
echo json_encode(['status'=>'error','message'=>'Data tidak valid.']);
exit;
}
try {
$stmt = $pdo->prepare("UPDATE penduduk_miskin SET status_bantuan=? WHERE id=?");
$stmt->execute([$status_bantuan, $id]);
echo json_encode(['status'=>'success']);
} catch (PDOException $e) {
echo json_encode(['status'=>'error','message'=>$e->getMessage()]);
}
?>