menambahkan fitur edit data pengguna dan memperbarui landing page
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis"); // UBAH DB
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
if ($data && isset($data['id'])) {
|
||||
$id = $data['id'];
|
||||
$stmt = $conn->prepare("DELETE FROM area_polygon WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["status" => "success"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => $stmt->error]);
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Konfigurasi Database (Sesuaikan dengan milik Anda)
|
||||
$host = "localhost";
|
||||
$user = "root";
|
||||
$pass = "";
|
||||
$db = "webgis"; // UBAH INI
|
||||
|
||||
$conn = new mysqli($host, $user, $pass, $db);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if ($data && isset($data['id'])) {
|
||||
$id = $data['id'];
|
||||
|
||||
// Hapus data dari tabel jalan_polyline berdasarkan ID
|
||||
$stmt = $conn->prepare("DELETE FROM jalan_polyline WHERE id = ?");
|
||||
$stmt->bind_param("i", $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["status" => "success", "message" => "Garis jalan berhasil dihapus"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Gagal menghapus data: " . $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "ID tidak valid"]);
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -23,20 +23,6 @@
|
||||
<button class="mode-btn active" data-mode="point" onclick="ubahMode('point')">
|
||||
<i class="fa-solid fa-gas-pump"></i> SPBU
|
||||
</button>
|
||||
<button class="mode-btn" data-mode="polyline" onclick="ubahMode('polyline')">
|
||||
<i class="fa-solid fa-road"></i> Jalan
|
||||
</button>
|
||||
<button class="mode-btn" data-mode="polygon" onclick="ubahMode('polygon')">
|
||||
<i class="fa-solid fa-draw-polygon"></i> Kavling
|
||||
</button>
|
||||
</div><br>
|
||||
<div class="mode-buttons">
|
||||
<button class="mode-btn" data-mode="edit_jalan" onclick="ubahMode('edit_jalan')" style="background-color: #fcf3cf; border-color: #f1c40f; color: #d35400;">
|
||||
<i class="fa-solid fa-pen-ruler"></i> Edit Jalan
|
||||
</button>
|
||||
<button class="mode-btn" data-mode="edit_kavling" onclick="ubahMode('edit_kavling')" style="background-color: #d4efdf; border-color: #27ae60; color: #1e8449;">
|
||||
<i class="fa-solid fa-pen-ruler"></i> Edit Kavling
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
|
||||
$sql = "SELECT * FROM area_polygon";
|
||||
$result = $conn->query($sql);
|
||||
$data_area = array();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
// Mengubah string geojson dari database kembali menjadi Object JSON
|
||||
// Ini wajib agar Leaflet.geoJSON() di Javascript bisa merendernya
|
||||
$row['geojson'] = json_decode($row['geojson']);
|
||||
$data_area[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($data_area);
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis"); // UBAH DB
|
||||
|
||||
$sql = "SELECT * FROM jalan_polyline";
|
||||
$result = $conn->query($sql);
|
||||
$data_jalan = array();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
// Parse string geojson menjadi object agar mudah dibaca Javascript
|
||||
$row['geojson'] = json_decode($row['geojson']);
|
||||
$data_jalan[] = $row;
|
||||
}
|
||||
}
|
||||
echo json_encode($data_jalan);
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
// Pastikan data yang dikirim dari JS sesuai dengan variabel baru
|
||||
if ($data && isset($data['nama_kavling']) && isset($data['geojson'])) {
|
||||
$nama_kavling = $data['nama_kavling'];
|
||||
$status = $data['status'];
|
||||
$luas_m2 = $data['luas_m2'];
|
||||
|
||||
// Ubah object GeoJSON menjadi string agar bisa disimpan di MySQL
|
||||
$geojson_string = json_encode($data['geojson']);
|
||||
|
||||
// Sesuaikan query INSERT dengan nama kolom di tabel database yang baru
|
||||
$stmt = $conn->prepare("INSERT INTO area_polygon (nama_kavling, status_kepemilikan, luas_m2, geojson) VALUES (?, ?, ?, ?)");
|
||||
|
||||
// Parameter: "ssds" berarti String, String, Double (Desimal), String
|
||||
$stmt->bind_param("ssds", $nama_kavling, $status, $luas_m2, $geojson_string);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["status" => "success", "id" => $stmt->insert_id]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => $stmt->error]);
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Tambahkan pesan error jika data tidak lengkap
|
||||
echo json_encode(["status" => "error", "message" => "Data area tidak lengkap"]);
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "webgis"); // UBAH DB
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if ($data && isset($data['nama_jalan']) && isset($data['geojson'])) {
|
||||
$nama_jalan = $data['nama_jalan'];
|
||||
$status = $data['status'];
|
||||
$panjang_m = $data['panjang_m'];
|
||||
$geojson_string = json_encode($data['geojson']); // Jadikan string untuk disimpan
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO jalan_polyline (nama_jalan, status, panjang_m, geojson) VALUES (?, ?, ?, ?)");
|
||||
$stmt->bind_param("ssds", $nama_jalan, $status, $panjang_m, $geojson_string);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["status" => "success", "id" => $stmt->insert_id]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => $stmt->error]);
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Data tidak lengkap"]);
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
// Sesuaikan dengan konfigurasi database Anda
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
|
||||
if ($conn->connect_error) {
|
||||
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if ($data && isset($data['id']) && isset($data['geojson'])) {
|
||||
$id = $data['id'];
|
||||
$luas_m2 = $data['luas_m2'];
|
||||
$geojson_string = json_encode($data['geojson']);
|
||||
|
||||
$stmt = $conn->prepare("UPDATE area_polygon SET luas_m2 = ?, geojson = ? WHERE id = ?");
|
||||
$stmt->bind_param("dsi", $luas_m2, $geojson_string, $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["status" => "success"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => $stmt->error]);
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Data tidak lengkap"]);
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
// Sesuaikan dengan konfigurasi database Anda
|
||||
$conn = new mysqli("localhost", "root", "", "webgis");
|
||||
|
||||
if ($conn->connect_error) {
|
||||
echo json_encode(["status" => "error", "message" => "Koneksi database gagal"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if ($data && isset($data['id']) && isset($data['geojson'])) {
|
||||
$id = $data['id'];
|
||||
$panjang_m = $data['panjang_m'];
|
||||
$geojson_string = json_encode($data['geojson']);
|
||||
|
||||
$stmt = $conn->prepare("UPDATE jalan_polyline SET panjang_m = ?, geojson = ? WHERE id = ?");
|
||||
$stmt->bind_param("dsi", $panjang_m, $geojson_string, $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(["status" => "success"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => $stmt->error]);
|
||||
}
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Data tidak lengkap"]);
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user