diff --git a/create_tables.php b/create_tables.php index 18cffcb..de69f10 100644 --- a/create_tables.php +++ b/create_tables.php @@ -67,6 +67,27 @@ $statements = [ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, INDEX idx_aduan_coords (latitude, longitude), INDEX idx_aduan_status (status_tindak_lanjut) +)", + "CREATE TABLE IF NOT EXISTS locations ( + id INT AUTO_INCREMENT PRIMARY KEY, + nama VARCHAR(255) NOT NULL, + nomor VARCHAR(100) NOT NULL, + buka_24jam VARCHAR(10) NOT NULL DEFAULT 'tidak', + latitude DECIMAL(10, 8) NOT NULL, + longitude DECIMAL(11, 8) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + INDEX idx_locations_coords (latitude, longitude) +)", + "CREATE TABLE IF NOT EXISTS spatial_features ( + id INT AUTO_INCREMENT PRIMARY KEY, + nama_objek VARCHAR(255) NOT NULL, + kategori VARCHAR(100) NOT NULL, + status_objek VARCHAR(100) NOT NULL, + type VARCHAR(50) NOT NULL, + geometry_data LONGTEXT NOT NULL, + nilai_ukur DECIMAL(15, 2) NOT NULL DEFAULT 0.00, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + INDEX idx_features_kategori (kategori) )" ]; @@ -85,7 +106,11 @@ $alterStatements = [ ]; foreach ($alterStatements as $alterSql) { - $conn->query($alterSql); + try { + @$conn->query($alterSql); + } catch (Exception $e) { + // Abaikan jika kolom sudah ada + } } echo json_encode(['status' => 'success', 'message' => 'Tabel berhasil dibuat atau sudah ada']); diff --git a/fitur_bantuan/api/delete_penduduk_miskin.php b/fitur_bantuan/api/delete_penduduk_miskin.php new file mode 100644 index 0000000..ead1310 --- /dev/null +++ b/fitur_bantuan/api/delete_penduduk_miskin.php @@ -0,0 +1,26 @@ + 'error', 'message' => 'ID tidak valid']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("DELETE FROM penduduk_miskin WHERE id = ?"); + $stmt->bind_param("i", $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data penduduk miskin dihapus']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_bantuan/api/delete_rumah_ibadah.php b/fitur_bantuan/api/delete_rumah_ibadah.php new file mode 100644 index 0000000..468db6b --- /dev/null +++ b/fitur_bantuan/api/delete_rumah_ibadah.php @@ -0,0 +1,26 @@ + 'error', 'message' => 'ID tidak valid']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("DELETE FROM rumah_ibadah WHERE id = ?"); + $stmt->bind_param("i", $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Rumah ibadah berhasil dihapus']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_bantuan/api/delete_verifikasi_lapangan.php b/fitur_bantuan/api/delete_verifikasi_lapangan.php new file mode 100644 index 0000000..2a7230e --- /dev/null +++ b/fitur_bantuan/api/delete_verifikasi_lapangan.php @@ -0,0 +1,38 @@ + 'error', 'message' => 'ID verifikasi tidak valid']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare('DELETE FROM verifikasi_lapangan WHERE id = ?'); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param('i', $id); + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Verifikasi lapangan berhasil dihapus']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_bantuan/api/get_penduduk_miskin.php b/fitur_bantuan/api/get_penduduk_miskin.php new file mode 100644 index 0000000..aff4290 --- /dev/null +++ b/fitur_bantuan/api/get_penduduk_miskin.php @@ -0,0 +1,34 @@ +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(); +?> diff --git a/fitur_bantuan/api/get_rumah_ibadah.php b/fitur_bantuan/api/get_rumah_ibadah.php new file mode 100644 index 0000000..9bcdeb1 --- /dev/null +++ b/fitur_bantuan/api/get_rumah_ibadah.php @@ -0,0 +1,30 @@ +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['radius_m'] = (int)$row['radius_m']; + $data[] = $row; + } +} + +echo json_encode($data); +$conn->close(); +?> diff --git a/fitur_bantuan/api/get_verifikasi_lapangan.php b/fitur_bantuan/api/get_verifikasi_lapangan.php new file mode 100644 index 0000000..dc983a7 --- /dev/null +++ b/fitur_bantuan/api/get_verifikasi_lapangan.php @@ -0,0 +1,24 @@ +query($sql); + +if (!$result) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); + $conn->close(); + exit; +} + +$data = []; +while ($row = $result->fetch_assoc()) { + $row['latitude'] = (float)$row['latitude']; + $row['longitude'] = (float)$row['longitude']; + $data[] = $row; +} + +echo json_encode($data); +$conn->close(); +?> diff --git a/fitur_bantuan/api/save_penduduk_miskin.php b/fitur_bantuan/api/save_penduduk_miskin.php new file mode 100644 index 0000000..f195285 --- /dev/null +++ b/fitur_bantuan/api/save_penduduk_miskin.php @@ -0,0 +1,77 @@ +query("SELECT id, nama, latitude, longitude FROM rumah_ibadah ORDER BY created_at DESC"); + if (!$result || $result->num_rows === 0) { + return null; + } + + $nearest = null; + while ($row = $result->fetch_assoc()) { + $distance = distanceMeters($lat, $lng, (float)$row['latitude'], (float)$row['longitude']); + if ($nearest === null || $distance < $nearest['distance']) { + $nearest = [ + 'id' => (int)$row['id'], + 'nama' => $row['nama'], + 'distance' => $distance + ]; + } + } + + return $nearest; +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $namaKetuaKk = trim($_POST['nama_ketua_kk'] ?? ''); + $jumlahAnggota = (int)($_POST['jumlah_anggota'] ?? 0); + $lat = $_POST['latitude'] ?? null; + $lng = $_POST['longitude'] ?? null; + + if ($namaKetuaKk === '' || $jumlahAnggota <= 0 || $lat === null || $lng === null) { + echo json_encode(['status' => 'error', 'message' => 'Data penduduk miskin tidak lengkap']); + $conn->close(); + exit; + } + + $lat = (float)$lat; + $lng = (float)$lng; + $nearest = findNearestRumahIbadah($conn, $lat, $lng); + + if (!$nearest) { + echo json_encode(['status' => 'error', 'message' => 'Tambahkan rumah ibadah terlebih dahulu']); + $conn->close(); + exit; + } + + $jarak = $nearest['distance']; + $rumahIbadahId = $nearest['id']; + $rumahIbadahNama = $nearest['nama']; + + $stmt = $conn->prepare("INSERT INTO penduduk_miskin (nama_ketua_kk, jumlah_anggota, latitude, longitude, rumah_ibadah_id, rumah_ibadah_nama, jarak_ke_rumah_ibadah_m) VALUES (?, ?, ?, ?, ?, ?, ?)"); + $stmt->bind_param("siddisd", $namaKetuaKk, $jumlahAnggota, $lat, $lng, $rumahIbadahId, $rumahIbadahNama, $jarak); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Penduduk miskin berhasil disimpan']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_bantuan/api/save_rumah_ibadah.php b/fitur_bantuan/api/save_rumah_ibadah.php new file mode 100644 index 0000000..e47b3c2 --- /dev/null +++ b/fitur_bantuan/api/save_rumah_ibadah.php @@ -0,0 +1,35 @@ + 'error', 'message' => 'Data rumah ibadah tidak lengkap']); + $conn->close(); + exit; + } + + $lat = (float)$lat; + $lng = (float)$lng; + $radius = max(50, (int)$radius); + + $stmt = $conn->prepare("INSERT INTO rumah_ibadah (nama, alamat, pic, latitude, longitude, radius_m) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt->bind_param("sssddi", $nama, $alamat, $pic, $lat, $lng, $radius); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Rumah ibadah berhasil disimpan']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_bantuan/api/save_verifikasi_lapangan.php b/fitur_bantuan/api/save_verifikasi_lapangan.php new file mode 100644 index 0000000..8a6ed64 --- /dev/null +++ b/fitur_bantuan/api/save_verifikasi_lapangan.php @@ -0,0 +1,76 @@ + 'error', 'message' => 'Nama petugas dan koordinat wajib diisi']); + $conn->close(); + exit; + } + + $foto = null; + if (isset($_FILES['foto']) && $_FILES['foto']['error'] === UPLOAD_ERR_OK) { + $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp']; + $filename = $_FILES['foto']['name']; + $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); + + if (!in_array($ext, $allowed, true)) { + http_response_code(400); + echo json_encode(['status' => 'error', 'message' => 'Format foto hanya JPG, PNG, GIF, WEBP']); + $conn->close(); + exit; + } + + // Folder is in root + if (!is_dir(__DIR__ . '/../../uploads')) { + mkdir(__DIR__ . '/../../uploads', 0755, true); + } + + $foto = 'uploads/' . time() . '_' . basename($filename); + if (!move_uploaded_file($_FILES['foto']['tmp_name'], __DIR__ . '/../../' . $foto)) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => 'Gagal upload foto']); + $conn->close(); + exit; + } + } + + $stmt = $conn->prepare('INSERT INTO verifikasi_lapangan (jenis_target, target_nama, petugas_nama, status_verifikasi, hasil_temuan, tindak_lanjut, foto, latitude, longitude) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $latitude = (float)$latitude; + $longitude = (float)$longitude; + $stmt->bind_param('sssssssdd', $jenisTarget, $targetNama, $petugasNama, $statusVerifikasi, $hasilTemuan, $tindakLanjut, $foto, $latitude, $longitude); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Verifikasi lapangan berhasil disimpan', 'id' => $stmt->insert_id]); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_bantuan/api/update_bantuan_penduduk.php b/fitur_bantuan/api/update_bantuan_penduduk.php new file mode 100644 index 0000000..7ccb17f --- /dev/null +++ b/fitur_bantuan/api/update_bantuan_penduduk.php @@ -0,0 +1,48 @@ + 'error', 'message' => 'Metode tidak diizinkan']); + $conn->close(); + exit; +} + +$id = (int)($_POST['id'] ?? 0); +$status = strtolower(trim($_POST['bantuan_status'] ?? 'belum')); +$catatan = trim($_POST['bantuan_catatan'] ?? ''); + +if ($id <= 0) { + echo json_encode(['status' => 'error', 'message' => 'ID tidak valid']); + $conn->close(); + exit; +} + +if (!in_array($status, ['belum', 'proses', 'sudah'], true)) { + $status = 'belum'; +} + +$stmt = $conn->prepare("UPDATE penduduk_miskin SET bantuan_status = ?, bantuan_catatan = ?, bantuan_updated_at = CURRENT_TIMESTAMP WHERE id = ?"); +$stmt->bind_param("ssi", $status, $catatan, $id); + +if ($stmt->execute()) { + $updatedAtResult = $conn->query("SELECT bantuan_updated_at FROM penduduk_miskin WHERE id = " . (int)$id . " LIMIT 1"); + $updatedAt = null; + if ($updatedAtResult && $updatedAtResult->num_rows > 0) { + $row = $updatedAtResult->fetch_assoc(); + $updatedAt = $row['bantuan_updated_at'] ?? null; + } + + echo json_encode([ + 'status' => 'success', + 'message' => 'Status bantuan berhasil diperbarui', + 'bantuan_updated_at' => $updatedAt + ]); +} else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); +} + +$stmt->close(); +$conn->close(); +?> diff --git a/fitur_bantuan/api/update_penduduk_miskin.php b/fitur_bantuan/api/update_penduduk_miskin.php new file mode 100644 index 0000000..170f67d --- /dev/null +++ b/fitur_bantuan/api/update_penduduk_miskin.php @@ -0,0 +1,79 @@ +query("SELECT id, nama, latitude, longitude FROM rumah_ibadah ORDER BY created_at DESC"); + if (!$result || $result->num_rows === 0) { + return null; + } + + $nearest = null; + while ($row = $result->fetch_assoc()) { + $distance = distanceMeters($lat, $lng, (float)$row['latitude'], (float)$row['longitude']); + if ($nearest === null || $distance < $nearest['distance']) { + $nearest = [ + 'id' => (int)$row['id'], + 'nama' => $row['nama'], + 'distance' => $distance + ]; + } + } + + return $nearest; +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $id = (int)($_POST['id'] ?? 0); + $namaKetuaKk = trim($_POST['nama_ketua_kk'] ?? ''); + $jumlahAnggota = (int)($_POST['jumlah_anggota'] ?? 0); + $lat = $_POST['latitude'] ?? null; + $lng = $_POST['longitude'] ?? null; + + if ($id <= 0 || $namaKetuaKk === '' || $jumlahAnggota <= 0 || $lat === null || $lng === null) { + echo json_encode(['status' => 'error', 'message' => 'Data penduduk miskin tidak lengkap']); + $conn->close(); + exit; + } + + $lat = (float)$lat; + $lng = (float)$lng; + $nearest = findNearestRumahIbadah($conn, $lat, $lng); + + if (!$nearest) { + echo json_encode(['status' => 'error', 'message' => 'Tambahkan rumah ibadah terlebih dahulu']); + $conn->close(); + exit; + } + + $jarak = $nearest['distance']; + $rumahIbadahId = $nearest['id']; + $rumahIbadahNama = $nearest['nama']; + + $stmt = $conn->prepare("UPDATE penduduk_miskin SET nama_ketua_kk = ?, jumlah_anggota = ?, latitude = ?, longitude = ?, rumah_ibadah_id = ?, rumah_ibadah_nama = ?, jarak_ke_rumah_ibadah_m = ? WHERE id = ?"); + $stmt->bind_param("siddisdi", $namaKetuaKk, $jumlahAnggota, $lat, $lng, $rumahIbadahId, $rumahIbadahNama, $jarak, $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data penduduk miskin berhasil diperbarui']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} + +$conn->close(); +?> diff --git a/fitur_bantuan/api/update_rumah_ibadah.php b/fitur_bantuan/api/update_rumah_ibadah.php new file mode 100644 index 0000000..db600ce --- /dev/null +++ b/fitur_bantuan/api/update_rumah_ibadah.php @@ -0,0 +1,36 @@ + 'error', 'message' => 'Data rumah ibadah tidak lengkap']); + $conn->close(); + exit; + } + + $lat = (float)$lat; + $lng = (float)$lng; + $radius = max(50, (int)$radius); + + $stmt = $conn->prepare("UPDATE rumah_ibadah SET nama = ?, alamat = ?, pic = ?, latitude = ?, longitude = ?, radius_m = ? WHERE id = ?"); + $stmt->bind_param("sssddii", $nama, $alamat, $pic, $lat, $lng, $radius, $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Rumah ibadah berhasil diperbarui']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_bantuan/api/update_verifikasi_lapangan.php b/fitur_bantuan/api/update_verifikasi_lapangan.php new file mode 100644 index 0000000..119ccce --- /dev/null +++ b/fitur_bantuan/api/update_verifikasi_lapangan.php @@ -0,0 +1,84 @@ + 'error', 'message' => 'Data verifikasi tidak lengkap']); + $conn->close(); + exit; + } + + $fotoSql = ''; + $foto = null; + if (isset($_FILES['foto']) && $_FILES['foto']['error'] === UPLOAD_ERR_OK) { + $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp']; + $filename = $_FILES['foto']['name']; + $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); + + if (!in_array($ext, $allowed, true)) { + http_response_code(400); + echo json_encode(['status' => 'error', 'message' => 'Format foto hanya JPG, PNG, GIF, WEBP']); + $conn->close(); + exit; + } + + if (!is_dir(__DIR__ . '/../../uploads')) { + mkdir(__DIR__ . '/../../uploads', 0755, true); + } + + $foto = 'uploads/' . time() . '_' . basename($filename); + if (!move_uploaded_file($_FILES['foto']['tmp_name'], __DIR__ . '/../../' . $foto)) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => 'Gagal upload foto']); + $conn->close(); + exit; + } + + $fotoSql = ', foto = ?'; + } + + $sql = 'UPDATE verifikasi_lapangan SET jenis_target = ?, target_nama = ?, petugas_nama = ?, status_verifikasi = ?, hasil_temuan = ?, tindak_lanjut = ?, latitude = ?, longitude = ?' . $fotoSql . ' WHERE id = ?'; + $stmt = $conn->prepare($sql); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $latitude = (float)$latitude; + $longitude = (float)$longitude; + if ($foto !== null) { + $stmt->bind_param('sssssssddi', $jenisTarget, $targetNama, $petugasNama, $statusVerifikasi, $hasilTemuan, $tindakLanjut, $foto, $latitude, $longitude, $id); + } else { + $stmt->bind_param('ssssssddi', $jenisTarget, $targetNama, $petugasNama, $statusVerifikasi, $hasilTemuan, $tindakLanjut, $latitude, $longitude, $id); + } + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Verifikasi lapangan berhasil diperbarui']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_bantuan/index.html b/fitur_bantuan/index.html new file mode 100644 index 0000000..9587fcf --- /dev/null +++ b/fitur_bantuan/index.html @@ -0,0 +1,1275 @@ + + + + + + Sistem GIS — Manajemen Bantuan + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+ + + +
+ Informatika UNTAN +
+
+

Manajemen Bantuan

+

Penyaluran bantuan penduduk miskin berbasis wilayah tempat ibadah.

+
+ + +
+ + + + +
+ + +
+
+
+ + +
+
+ + +
+
Memuat data...
+
+ + + + + + + + + +
+ + +
+ + + +
+
+ + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + diff --git a/fitur_jalan/api/delete_feature.php b/fitur_jalan/api/delete_feature.php new file mode 100644 index 0000000..9d1dd69 --- /dev/null +++ b/fitur_jalan/api/delete_feature.php @@ -0,0 +1,39 @@ + 'error', 'message' => 'ID jalan tidak valid']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("DELETE FROM spatial_features WHERE id = ?"); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param("i", $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data jalan berhasil dihapus']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_jalan/api/delete_jalan_rusak.php b/fitur_jalan/api/delete_jalan_rusak.php new file mode 100644 index 0000000..1f37e9e --- /dev/null +++ b/fitur_jalan/api/delete_jalan_rusak.php @@ -0,0 +1,52 @@ + 'error', 'message' => 'ID laporan tidak valid']); + $conn->close(); + exit; + } + + // Optional: Get file path and delete physical image file + $stmtSelect = $conn->prepare('SELECT gambar FROM jalan_rusak WHERE id = ?'); + if ($stmtSelect) { + $stmtSelect->bind_param('i', $id); + $stmtSelect->execute(); + $stmtSelect->bind_result($gambar); + if ($stmtSelect->fetch()) { + if ($gambar && file_exists(__DIR__ . '/../../' . $gambar)) { + @unlink(__DIR__ . '/../../' . $gambar); + } + } + $stmtSelect->close(); + } + + $stmt = $conn->prepare('DELETE FROM jalan_rusak WHERE id = ?'); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param('i', $id); + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Laporan jalan rusak berhasil dihapus']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_jalan/api/get_features.php b/fitur_jalan/api/get_features.php new file mode 100644 index 0000000..6703d66 --- /dev/null +++ b/fitur_jalan/api/get_features.php @@ -0,0 +1,30 @@ +query($sql); +$features = []; + +if (!$result) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); + $conn->close(); + exit; +} + +if ($result && $result->num_rows > 0) { + while($row = $result->fetch_assoc()) { + $row['geometry_data'] = json_decode($row['geometry_data']); + $row['nilai_ukur'] = (float)$row['nilai_ukur']; + $features[] = $row; + } +} + +echo json_encode($features); +$conn->close(); +?> diff --git a/fitur_jalan/api/get_jalan_rusak.php b/fitur_jalan/api/get_jalan_rusak.php new file mode 100644 index 0000000..cf9aaf4 --- /dev/null +++ b/fitur_jalan/api/get_jalan_rusak.php @@ -0,0 +1,29 @@ +query($sql); +$data = []; + +if (!$result) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); + $conn->close(); + exit; +} + +if ($result && $result->num_rows > 0) { + while ($row = $result->fetch_assoc()) { + $row['latitude'] = (float)$row['latitude']; + $row['longitude'] = (float)$row['longitude']; + $data[] = $row; + } +} + +echo json_encode($data); +$conn->close(); +?> diff --git a/fitur_jalan/api/save_feature.php b/fitur_jalan/api/save_feature.php new file mode 100644 index 0000000..5a921f3 --- /dev/null +++ b/fitur_jalan/api/save_feature.php @@ -0,0 +1,45 @@ + 'error', 'message' => 'Data jalan tidak lengkap']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("INSERT INTO spatial_features (nama_objek, kategori, status_objek, type, geometry_data, nilai_ukur) VALUES (?, ?, ?, ?, ?, ?)"); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param("sssssd", $nama, $kategori, $status, $type, $geometry, $nilai); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data jalan berhasil disimpan']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_jalan/api/save_jalan_rusak.php b/fitur_jalan/api/save_jalan_rusak.php new file mode 100644 index 0000000..15725a2 --- /dev/null +++ b/fitur_jalan/api/save_jalan_rusak.php @@ -0,0 +1,72 @@ + 'error', 'message' => 'Latitude, longitude, dan jenis kerusakan wajib diisi']); + exit; + } + + $gambar = null; + + // Handle file upload + if (isset($_FILES['gambar']) && $_FILES['gambar']['error'] === UPLOAD_ERR_OK) { + $allowed = ['jpg', 'jpeg', 'png', 'gif']; + $filename = $_FILES['gambar']['name']; + $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); + + if (!in_array($ext, $allowed)) { + http_response_code(400); + echo json_encode(['status' => 'error', 'message' => 'Format gambar hanya JPG, PNG, GIF']); + exit; + } + + // Buat folder uploads di root jika belum ada + if (!is_dir(__DIR__ . '/../../uploads')) { + mkdir(__DIR__ . '/../../uploads', 0755, true); + } + + // Generate nama file unik + $gambar = 'uploads/' . time() . '_' . basename($filename); + + if (!move_uploaded_file($_FILES['gambar']['tmp_name'], __DIR__ . '/../../' . $gambar)) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => 'Gagal upload gambar']); + exit; + } + } + + $stmt = $conn->prepare("INSERT INTO jalan_rusak (latitude, longitude, jenis_kerusakan, deskripsi, severity, gambar) VALUES (?, ?, ?, ?, ?, ?)"); + + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + exit; + } + + $stmt->bind_param("ddssss", $latitude, $longitude, $jenis_kerusakan, $deskripsi, $severity, $gambar); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Laporan jalan rusak berhasil disimpan', 'id' => $stmt->insert_id]); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_jalan/api/update_feature.php b/fitur_jalan/api/update_feature.php new file mode 100644 index 0000000..c0e7083 --- /dev/null +++ b/fitur_jalan/api/update_feature.php @@ -0,0 +1,66 @@ + 'error', 'message' => 'ID jalan tidak valid']); + $conn->close(); + exit; + } + + $isGeometryUpdate = isset($_POST['geometry']); + + if ($isGeometryUpdate) { + $geometry = $_POST['geometry'] ?? ''; + $nilai = (float)($_POST['nilai'] ?? 0); + + if ($geometry === '') { + http_response_code(400); + echo json_encode(['status' => 'error', 'message' => 'Data geometri kosong']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("UPDATE spatial_features SET geometry_data = ?, nilai_ukur = ? WHERE id = ?"); + $stmt->bind_param("sdi", $geometry, $nilai, $id); + } else { + $nama = trim($_POST['nama'] ?? ''); + $status = trim($_POST['status'] ?? ''); + + if ($nama === '' || $status === '') { + http_response_code(400); + echo json_encode(['status' => 'error', 'message' => 'Nama atau status tidak boleh kosong']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("UPDATE spatial_features SET nama_objek = ?, status_objek = ? WHERE id = ?"); + $stmt->bind_param("ssi", $nama, $status, $id); + } + + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data jalan berhasil diperbarui']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_jalan/index.html b/fitur_jalan/index.html new file mode 100644 index 0000000..8115fd1 --- /dev/null +++ b/fitur_jalan/index.html @@ -0,0 +1,951 @@ + + + + + + Sistem GIS — Infrastruktur Jalan + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+ + + +
+ Informatika UNTAN +
+
+

Infrastruktur Jalan

+

Pemetaan jaringan jalan beserta pelaporan titik kerusakan jalan.

+
+ + +
+ + +
+ + +
+
Visibilitas Layer
+ + + +
+ + +
+
+
+ + +
+
+ + +
+ +
Memuat data jalan...
+
+ + + +
+ + +
+ +
+ Gunakan tool Draw Polyline di sisi kanan peta untuk menambahkan ruas jalan baru dan menghitung panjangnya. +
+
+
+ + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + diff --git a/fitur_parsil_tanah/api/delete_feature.php b/fitur_parsil_tanah/api/delete_feature.php new file mode 100644 index 0000000..9864228 --- /dev/null +++ b/fitur_parsil_tanah/api/delete_feature.php @@ -0,0 +1,39 @@ + 'error', 'message' => 'ID parsel tidak valid']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("DELETE FROM spatial_features WHERE id = ?"); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param("i", $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Parsil tanah berhasil dihapus']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_parsil_tanah/api/get_features.php b/fitur_parsil_tanah/api/get_features.php new file mode 100644 index 0000000..8abe16a --- /dev/null +++ b/fitur_parsil_tanah/api/get_features.php @@ -0,0 +1,30 @@ +query($sql); +$features = []; + +if (!$result) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); + $conn->close(); + exit; +} + +if ($result && $result->num_rows > 0) { + while($row = $result->fetch_assoc()) { + $row['geometry_data'] = json_decode($row['geometry_data']); + $row['nilai_ukur'] = (float)$row['nilai_ukur']; + $features[] = $row; + } +} + +echo json_encode($features); +$conn->close(); +?> diff --git a/fitur_parsil_tanah/api/save_feature.php b/fitur_parsil_tanah/api/save_feature.php new file mode 100644 index 0000000..d5bc6be --- /dev/null +++ b/fitur_parsil_tanah/api/save_feature.php @@ -0,0 +1,45 @@ + 'error', 'message' => 'Data parsel tidak lengkap']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("INSERT INTO spatial_features (nama_objek, kategori, status_objek, type, geometry_data, nilai_ukur) VALUES (?, ?, ?, ?, ?, ?)"); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param("sssssd", $nama, $kategori, $status, $type, $geometry, $nilai); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Parsil tanah berhasil disimpan']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_parsil_tanah/api/update_feature.php b/fitur_parsil_tanah/api/update_feature.php new file mode 100644 index 0000000..103cf80 --- /dev/null +++ b/fitur_parsil_tanah/api/update_feature.php @@ -0,0 +1,67 @@ + 'error', 'message' => 'ID parsel tidak valid']); + $conn->close(); + exit; + } + + // Check if it is a geometry update or attribute update + $isGeometryUpdate = isset($_POST['geometry']); + + if ($isGeometryUpdate) { + $geometry = $_POST['geometry'] ?? ''; + $nilai = (float)($_POST['nilai'] ?? 0); + + if ($geometry === '') { + http_response_code(400); + echo json_encode(['status' => 'error', 'message' => 'Data geometri kosong']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("UPDATE spatial_features SET geometry_data = ?, nilai_ukur = ? WHERE id = ?"); + $stmt->bind_param("sdi", $geometry, $nilai, $id); + } else { + $nama = trim($_POST['nama'] ?? ''); + $status = trim($_POST['status'] ?? ''); + + if ($nama === '' || $status === '') { + http_response_code(400); + echo json_encode(['status' => 'error', 'message' => 'Nama atau status tidak boleh kosong']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare("UPDATE spatial_features SET nama_objek = ?, status_objek = ? WHERE id = ?"); + $stmt->bind_param("ssi", $nama, $status, $id); + } + + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Parsil tanah berhasil diperbarui']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + $stmt->close(); + $conn->close(); + exit; +} + +http_response_code(405); +echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); +$conn->close(); +?> diff --git a/fitur_parsil_tanah/index.html b/fitur_parsil_tanah/index.html new file mode 100644 index 0000000..30d6779 --- /dev/null +++ b/fitur_parsil_tanah/index.html @@ -0,0 +1,651 @@ + + + + + + Sistem GIS — Parsil Tanah + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+ + + +
+ Informatika UNTAN +
+
+

Parsil Tanah

+

Kelola dan ukur luas parsel tanah (polygon) secara realtime.

+
+ + +
+ Total Parsil + 0 +
+ + +
+
+
+ + +
+
+ +
+ +
+ + + + + Memuat data parsel... +
+
+
+ + +
+ +
+ Tips: Gunakan tombol gambar di peta (sisi kanan) untuk menggambar batas parsel tanah baru, lalu isi nama pemilik & status sertifikat. +
+
+
+ + +
+
+ + + +
+
+ + + + + + + + + + + + + + + diff --git a/fitur_spbu/api/delete_location.php b/fitur_spbu/api/delete_location.php new file mode 100644 index 0000000..985cd1a --- /dev/null +++ b/fitur_spbu/api/delete_location.php @@ -0,0 +1,33 @@ + 'error', 'message' => 'ID tidak valid']); + exit; + } + + $stmt = $conn->prepare("DELETE FROM locations WHERE id = ?"); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param("i", $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'SPBU berhasil dihapus']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_spbu/api/get_location.php b/fitur_spbu/api/get_location.php new file mode 100644 index 0000000..0e6cb99 --- /dev/null +++ b/fitur_spbu/api/get_location.php @@ -0,0 +1,25 @@ +query($sql); + +$locations = []; + +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()) { + $locations[] = $row; + } +} + +echo json_encode($locations); +$conn->close(); +?> diff --git a/fitur_spbu/api/save_location.php b/fitur_spbu/api/save_location.php new file mode 100644 index 0000000..bf03477 --- /dev/null +++ b/fitur_spbu/api/save_location.php @@ -0,0 +1,39 @@ + 'error', 'message' => 'Data tidak lengkap']); + exit; + } + + $stmt = $conn->prepare("INSERT INTO locations (nama, nomor, buka_24jam, latitude, longitude) VALUES (?, ?, ?, ?, ?)"); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param("sssdd", $nama, $nomor, $status, $lat, $lng); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data SPBU berhasil disimpan']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_spbu/api/update_coords.php b/fitur_spbu/api/update_coords.php new file mode 100644 index 0000000..b42af04 --- /dev/null +++ b/fitur_spbu/api/update_coords.php @@ -0,0 +1,36 @@ + 'error', 'message' => 'Data tidak lengkap']); + exit; + } + + $stmt = $conn->prepare("UPDATE locations SET latitude = ?, longitude = ? WHERE id = ?"); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param("ddi", $lat, $lng, $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Koordinat SPBU berhasil diperbarui']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_spbu/api/update_details.php b/fitur_spbu/api/update_details.php new file mode 100644 index 0000000..6b6ee78 --- /dev/null +++ b/fitur_spbu/api/update_details.php @@ -0,0 +1,37 @@ + 'error', 'message' => 'Data tidak lengkap']); + exit; + } + + $stmt = $conn->prepare("UPDATE locations SET nama = ?, nomor = ?, buka_24jam = ? WHERE id = ?"); + if (!$stmt) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $conn->error]); + $conn->close(); + exit; + } + + $stmt->bind_param("sssi", $nama, $nomor, $status, $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Detail SPBU berhasil diperbarui']); + } else { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> diff --git a/fitur_spbu/index.html b/fitur_spbu/index.html new file mode 100644 index 0000000..e4c4c31 --- /dev/null +++ b/fitur_spbu/index.html @@ -0,0 +1,600 @@ + + + + + + Sistem GIS — Lokasi SPBU + + + + + + + + + + + + + + + +
+ + +
+ +
+
+ + + +
+ Informatika UNTAN +
+
+

Lokasi SPBU

+

Pemetaan Stasiun Pengisian Bahan Bakar Umum (SPBU) beserta jam operasional.

+
+ + +
+
+ Total SPBU + 0 +
+
+ Buka 24 Jam + 0 +
+
+ + +
+
+
+ + +
+
+ +
+ +
+ + + + + Memuat data SPBU... +
+
+
+ + +
+ +
+ Cara Menambah SPBU: Klik tombol Tambah Titik di atas peta, lalu klik lokasi SPBU pada peta. +
+
+
+ + +
+
+ + +
+ +
+ + + +
+
+ + + + + + + + + + + + + diff --git a/index.html b/index.html index 28136aa..afa23cb 100644 --- a/index.html +++ b/index.html @@ -3,4789 +3,244 @@ - Sistem GIS + GIS Portal Program Studi Informatika Untan - - - + + + + - + -
-
- -