From c2efc4414ff34d6d56cca02f58eca32fc1c47762 Mon Sep 17 00:00:00 2001 From: Mhanif26 Date: Tue, 12 May 2026 10:16:16 +0700 Subject: [PATCH 1/3] first --- create_tables.php | 30 + delete_aduan_warga.php | 38 + delete_verifikasi_lapangan.php | 38 + fitur_jalan_parsel/api.php | 3 + fitur_jalan_parsel/delete_jalan_rusak.php | 46 ++ fitur_jalan_parsel/get_jalan_rusak.php | 29 + fitur_jalan_parsel/index.html | 49 ++ fitur_jalan_parsel/save_jalan_rusak.php | 72 ++ get_aduan_warga.php | 24 + get_verifikasi_lapangan.php | 24 + global/leaflet-loader.js | 17 + index.html | 766 +++++++++++++++++- layer_groups_choropleth/api.php | 3 + layer_groups_choropleth/delete_feature.php | 36 + layer_groups_choropleth/get_features.php | 29 + layer_groups_choropleth/index.html | 36 + layer_groups_choropleth/save_feature.php | 50 ++ layer_groups_choropleth/update_feature.php | 45 + rancangan_sistem/README.md | 29 + rancangan_sistem/delete_penduduk_miskin.php | 26 + rancangan_sistem/delete_rumah_ibadah.php | 26 + rancangan_sistem/get_penduduk_miskin.php | 34 + .../get_penduduk_miskin_geojson.php | 24 + rancangan_sistem/get_rumah_ibadah.php | 30 + rancangan_sistem/get_rumah_ibadah_geojson.php | 24 + rancangan_sistem/index.html | 57 ++ rancangan_sistem/save_penduduk_miskin.php | 80 ++ rancangan_sistem/save_rumah_ibadah.php | 35 + rancangan_sistem/update_bantuan_penduduk.php | 48 ++ rancangan_sistem/update_penduduk_miskin.php | 82 ++ rancangan_sistem/update_rumah_ibadah.php | 36 + save_aduan_warga.php | 75 ++ save_verifikasi_lapangan.php | 75 ++ uji_spbu/api.php | 12 + uji_spbu/index.html | 44 + update_aduan_warga.php | 84 ++ update_verifikasi_lapangan.php | 84 ++ 37 files changed, 2222 insertions(+), 18 deletions(-) create mode 100644 delete_aduan_warga.php create mode 100644 delete_verifikasi_lapangan.php create mode 100644 fitur_jalan_parsel/api.php create mode 100644 fitur_jalan_parsel/delete_jalan_rusak.php create mode 100644 fitur_jalan_parsel/get_jalan_rusak.php create mode 100644 fitur_jalan_parsel/index.html create mode 100644 fitur_jalan_parsel/save_jalan_rusak.php create mode 100644 get_aduan_warga.php create mode 100644 get_verifikasi_lapangan.php create mode 100644 global/leaflet-loader.js create mode 100644 layer_groups_choropleth/api.php create mode 100644 layer_groups_choropleth/delete_feature.php create mode 100644 layer_groups_choropleth/get_features.php create mode 100644 layer_groups_choropleth/index.html create mode 100644 layer_groups_choropleth/save_feature.php create mode 100644 layer_groups_choropleth/update_feature.php create mode 100644 rancangan_sistem/README.md create mode 100644 rancangan_sistem/delete_penduduk_miskin.php create mode 100644 rancangan_sistem/delete_rumah_ibadah.php create mode 100644 rancangan_sistem/get_penduduk_miskin.php create mode 100644 rancangan_sistem/get_penduduk_miskin_geojson.php create mode 100644 rancangan_sistem/get_rumah_ibadah.php create mode 100644 rancangan_sistem/get_rumah_ibadah_geojson.php create mode 100644 rancangan_sistem/index.html create mode 100644 rancangan_sistem/save_penduduk_miskin.php create mode 100644 rancangan_sistem/save_rumah_ibadah.php create mode 100644 rancangan_sistem/update_bantuan_penduduk.php create mode 100644 rancangan_sistem/update_penduduk_miskin.php create mode 100644 rancangan_sistem/update_rumah_ibadah.php create mode 100644 save_aduan_warga.php create mode 100644 save_verifikasi_lapangan.php create mode 100644 uji_spbu/api.php create mode 100644 uji_spbu/index.html create mode 100644 update_aduan_warga.php create mode 100644 update_verifikasi_lapangan.php diff --git a/create_tables.php b/create_tables.php index c6851e0..18cffcb 100644 --- a/create_tables.php +++ b/create_tables.php @@ -37,6 +37,36 @@ $statements = [ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, INDEX idx_penduduk_coords (latitude, longitude), INDEX idx_penduduk_rumah_ibadah (rumah_ibadah_id) +)", + "CREATE TABLE IF NOT EXISTS verifikasi_lapangan ( + id INT AUTO_INCREMENT PRIMARY KEY, + jenis_target VARCHAR(50) NOT NULL DEFAULT 'penduduk_miskin', + target_nama VARCHAR(255) DEFAULT NULL, + petugas_nama VARCHAR(255) NOT NULL, + status_verifikasi VARCHAR(30) NOT NULL DEFAULT 'menunggu', + hasil_temuan TEXT, + tindak_lanjut TEXT, + foto VARCHAR(255) DEFAULT NULL, + latitude DECIMAL(10, 8) NOT NULL, + longitude DECIMAL(11, 8) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + INDEX idx_verifikasi_coords (latitude, longitude), + INDEX idx_verifikasi_target (jenis_target, target_nama) +)", + "CREATE TABLE IF NOT EXISTS aduan_warga ( + id INT AUTO_INCREMENT PRIMARY KEY, + kategori VARCHAR(100) NOT NULL, + pelapor_nama VARCHAR(255) NOT NULL, + kontak_pelapor VARCHAR(100) DEFAULT NULL, + deskripsi TEXT NOT NULL, + status_tindak_lanjut VARCHAR(30) NOT NULL DEFAULT 'baru', + tindak_lanjut TEXT, + foto VARCHAR(255) DEFAULT NULL, + latitude DECIMAL(10, 8) NOT NULL, + longitude DECIMAL(11, 8) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + INDEX idx_aduan_coords (latitude, longitude), + INDEX idx_aduan_status (status_tindak_lanjut) )" ]; diff --git a/delete_aduan_warga.php b/delete_aduan_warga.php new file mode 100644 index 0000000..9a95f44 --- /dev/null +++ b/delete_aduan_warga.php @@ -0,0 +1,38 @@ + 'error', 'message' => 'ID aduan tidak valid']); + $conn->close(); + exit; + } + + $stmt = $conn->prepare('DELETE FROM aduan_warga 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' => 'Aduan warga 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(); +?> \ No newline at end of file diff --git a/delete_verifikasi_lapangan.php b/delete_verifikasi_lapangan.php new file mode 100644 index 0000000..4af316d --- /dev/null +++ b/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(); +?> \ No newline at end of file diff --git a/fitur_jalan_parsel/api.php b/fitur_jalan_parsel/api.php new file mode 100644 index 0000000..2b86e94 --- /dev/null +++ b/fitur_jalan_parsel/api.php @@ -0,0 +1,3 @@ +true,'msg'=>'API placeholder untuk fitur jalan/parsel']); diff --git a/fitur_jalan_parsel/delete_jalan_rusak.php b/fitur_jalan_parsel/delete_jalan_rusak.php new file mode 100644 index 0000000..728a14b --- /dev/null +++ b/fitur_jalan_parsel/delete_jalan_rusak.php @@ -0,0 +1,46 @@ + 'error', 'message' => 'ID wajib diisi']); + exit; + } + + // Ambil data gambar untuk dihapus + $stmt = $conn->prepare("SELECT gambar FROM jalan_rusak WHERE id = ?"); + $stmt->bind_param("i", $id); + $stmt->execute(); + $result = $stmt->get_result(); + $row = $result->fetch_assoc(); + + if ($row && $row['gambar'] && file_exists(__DIR__ . '/../' . $row['gambar'])) { + unlink(__DIR__ . '/../' . $row['gambar']); + } + + $stmt->close(); + + // Hapus record + $stmt = $conn->prepare("DELETE FROM jalan_rusak WHERE id = ?"); + $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_parsel/get_jalan_rusak.php b/fitur_jalan_parsel/get_jalan_rusak.php new file mode 100644 index 0000000..742dac4 --- /dev/null +++ b/fitur_jalan_parsel/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_parsel/index.html b/fitur_jalan_parsel/index.html new file mode 100644 index 0000000..fbaf33c --- /dev/null +++ b/fitur_jalan_parsel/index.html @@ -0,0 +1,49 @@ + + + + + + Fitur Jalan & Parsel + + + + + +
+ +
+
+ + + + + + diff --git a/fitur_jalan_parsel/save_jalan_rusak.php b/fitur_jalan_parsel/save_jalan_rusak.php new file mode 100644 index 0000000..f2e168f --- /dev/null +++ b/fitur_jalan_parsel/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 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/get_aduan_warga.php b/get_aduan_warga.php new file mode 100644 index 0000000..748c588 --- /dev/null +++ b/get_aduan_warga.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(); +?> \ No newline at end of file diff --git a/get_verifikasi_lapangan.php b/get_verifikasi_lapangan.php new file mode 100644 index 0000000..1fbc570 --- /dev/null +++ b/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(); +?> \ No newline at end of file diff --git a/global/leaflet-loader.js b/global/leaflet-loader.js new file mode 100644 index 0000000..b46fe29 --- /dev/null +++ b/global/leaflet-loader.js @@ -0,0 +1,17 @@ +// Simple loader to make Leaflet resources available globally to pages +(function(){ + if(window._leafletLoaderRan) return; window._leafletLoaderRan = true; + var link = document.createElement('link'); + link.rel = 'stylesheet'; + link.href = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css'; + document.head.appendChild(link); + + var script = document.createElement('script'); + script.src = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js'; + script.defer = false; + script.onload = function(){ + console.log('Leaflet loaded'); + var ev = document.createEvent('Event'); ev.initEvent('leaflet:loaded', true, true); window.dispatchEvent(ev); + }; + document.head.appendChild(script); +})(); diff --git a/index.html b/index.html index 3885645..40d1f9d 100644 --- a/index.html +++ b/index.html @@ -155,6 +155,12 @@ + + @@ -251,6 +257,12 @@ + + @@ -401,6 +413,14 @@ Penduduk Miskin + +