This commit is contained in:
2026-06-10 19:26:40 +07:00
parent 02c8394972
commit 7e2d324c2e
49 changed files with 6334 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
<?php
include 'koneksi.php';
header('Content-Type: application/json');
$id = (int)$_POST['id'];
$tipe = $_POST['tipe'] ?? '';
if ($tipe === 'ibadah') {
$stmt = $conn->prepare("DELETE FROM rumah_ibadah WHERE id=?");
$stmt->bind_param("i", $id);
$stmt->execute()
? print json_encode(["status" => "success"])
: print json_encode(["status" => "error", "msg" => $stmt->error]);
} elseif ($tipe === 'penduduk') {
// Hapus histori & pelatihan dulu (FK)
foreach (['histori_bantuan', 'pelatihan'] as $tbl) {
$s = $conn->prepare("DELETE FROM $tbl WHERE penduduk_id=?");
$s->bind_param("i", $id);
$s->execute();
}
$stmt = $conn->prepare("DELETE FROM penduduk WHERE id=?");
$stmt->bind_param("i", $id);
$stmt->execute()
? print json_encode(["status" => "success"])
: print json_encode(["status" => "error", "msg" => $stmt->error]);
} elseif ($tipe === 'laporan') {
$stmt = $conn->prepare("DELETE FROM laporan WHERE id=?");
$stmt->bind_param("i", $id);
$stmt->execute()
? print json_encode(["status" => "success"])
: print json_encode(["status" => "error", "msg" => $stmt->error]);
} else {
http_response_code(400);
echo json_encode(["status" => "error", "msg" => "Tipe tidak dikenal"]);
}