From bde929158bbcc710135af113dc422f0497f83a83 Mon Sep 17 00:00:00 2001 From: MAGHFIRA IZZATI Date: Sun, 7 Jun 2026 21:22:22 +0700 Subject: [PATCH] update --- 01/api/add_columns.php | 4 +- 01/api/check_db.php | 24 +++++++++ 01/api/debug_input.php | 15 ++++++ 01/api/fix_tables.php | 46 ++++++++++++++++ 01/api/save_data.php | 60 +++++++++++++++------ 01/api/save_jalan.php | 59 +++++++++++++++------ 01/api/save_parsil.php | 63 +++++++++++++++------- 01/api/test_desc.php | 5 ++ 01/api/test_enum.php | 11 ++++ 01/index.html | 117 ++++++++++++++++++++++++++--------------- 01/test_jalan.php | 10 ++++ 01/test_jalan2.php | 10 ++++ 12 files changed, 328 insertions(+), 96 deletions(-) create mode 100644 01/api/check_db.php create mode 100644 01/api/debug_input.php create mode 100644 01/api/fix_tables.php create mode 100644 01/api/test_desc.php create mode 100644 01/api/test_enum.php create mode 100644 01/test_jalan.php create mode 100644 01/test_jalan2.php diff --git a/01/api/add_columns.php b/01/api/add_columns.php index a10a181..d2af4e9 100644 --- a/01/api/add_columns.php +++ b/01/api/add_columns.php @@ -1,7 +1,7 @@ errno == 1060) { echo "Kolom $colName: Sudah ada (skip)\n"; } else { diff --git a/01/api/check_db.php b/01/api/check_db.php new file mode 100644 index 0000000..736e7bc --- /dev/null +++ b/01/api/check_db.php @@ -0,0 +1,24 @@ +query("SHOW TABLES"); +if($res) { + while($row = $res->fetch_array()) { + echo $row[0] . "
"; + } +} else { + echo "Error showing tables: " . $conn->error; +} + +echo "
"; + +$sql = "INSERT INTO spbu (nama,no,status,lat,lng) VALUES ('Test','123','Ya','0','0')"; +if($conn->query($sql)){ + echo "Insert SPBU success: ID " . $conn->insert_id; +}else{ + echo "Insert SPBU error: " . $conn->error; +} +?> diff --git a/01/api/debug_input.php b/01/api/debug_input.php new file mode 100644 index 0000000..1f5123f --- /dev/null +++ b/01/api/debug_input.php @@ -0,0 +1,15 @@ + $raw, + "json_decoded" => json_decode($raw, true), + "json_error" => json_last_error_msg(), + "request_method" => $_SERVER['REQUEST_METHOD'], + "content_type" => $_SERVER['CONTENT_TYPE'] ?? 'not set', +]); +?> diff --git a/01/api/fix_tables.php b/01/api/fix_tables.php new file mode 100644 index 0000000..7a23885 --- /dev/null +++ b/01/api/fix_tables.php @@ -0,0 +1,46 @@ +query($sql) === TRUE) { + echo "Tabel berhasil dibuat/diperbarui.
"; + } else { + echo "Error: " . $conn->error . "
"; + } +} +echo "Selesai!"; +?> diff --git a/01/api/save_data.php b/01/api/save_data.php index 62fef23..62b6c1f 100644 --- a/01/api/save_data.php +++ b/01/api/save_data.php @@ -1,23 +1,53 @@ "error", "message" => "Data tidak lengkap"]); + exit; +} -if($conn->query($sql)){ -echo json_encode([ -"status"=>"success", -"id"=>$conn->insert_id -]); -}else{ -echo json_encode(["status"=>"error"]); +try { + $stmt = $conn->prepare("INSERT INTO spbu (nama,no,status,lat,lng) VALUES (?,?,?,?,?)"); + if(!$stmt) { + $err = $conn->error; + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " SPBU PREPARE ERR: $err\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"prepare","message"=>$err]); + exit; + } + + $stmt->bind_param("sssdd", $nama, $no, $status, $lat, $lng); + + if($stmt->execute()){ + $id = $stmt->insert_id; + ob_clean(); + echo json_encode(["status"=>"success","id"=>$id]); + } else { + $err = $stmt->error; + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " SPBU EXEC ERR: $err | Payload: $raw\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"execute","message"=>$err]); + } + $stmt->close(); +} catch (Exception $e) { + $err = $e->getMessage(); + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " SPBU EXCEPTION: $err | Payload: $raw\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"exception","message"=>$err]); } ?> \ No newline at end of file diff --git a/01/api/save_jalan.php b/01/api/save_jalan.php index d0ab26f..828e75c 100644 --- a/01/api/save_jalan.php +++ b/01/api/save_jalan.php @@ -1,13 +1,17 @@ "error", "message" => "Nama tidak boleh kosong"]); + exit; +} -if($conn->query($sql)){ -echo json_encode([ -"status"=>"success", -"id"=>$conn->insert_id -]); -}else{ -echo json_encode([ -"status"=>"error", -"error"=>$conn->error -]); +try { + $stmt = $conn->prepare("INSERT INTO jalan (nama,status,panjang,koordinat) VALUES (?,?,?,?)"); + if(!$stmt) { + $err = $conn->error; + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " JALAN PREPARE ERR: $err\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"prepare","message"=>$err]); + exit; + } + + $stmt->bind_param("ssds", $nama, $status, $panjang, $koordinat); + + if($stmt->execute()){ + $id = $stmt->insert_id; + ob_clean(); + echo json_encode(["status"=>"success","id"=>$id]); + } else { + $err = $stmt->error; + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " JALAN EXEC ERR: $err | Payload: $raw\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"execute","message"=>$err]); + } + $stmt->close(); +} catch (Exception $e) { + $err = $e->getMessage(); + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " JALAN EXCEPTION: $err | Payload: $raw\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"exception","message"=>$err]); } ?> \ No newline at end of file diff --git a/01/api/save_parsil.php b/01/api/save_parsil.php index eea07a6..2542008 100644 --- a/01/api/save_parsil.php +++ b/01/api/save_parsil.php @@ -1,14 +1,18 @@ "error", "message" => "Nama tidak boleh kosong"]); + exit; +} -if($conn->query($sql)){ -echo json_encode([ -"status"=>"success", -"id"=>$conn->insert_id -]); -}else{ -echo json_encode([ -"status"=>"error", -"message"=>$conn->error -]); +try { + $stmt = $conn->prepare("INSERT INTO parsil (nama, pemilik, status, luas, koordinat) VALUES (?,?,?,?,?)"); + if(!$stmt) { + $err = $conn->error; + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " PARSIL PREPARE ERR: $err\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"prepare","message"=>$err]); + exit; + } + + $stmt->bind_param("sssds", $nama, $pemilik, $status, $luas, $koordinat); + + if($stmt->execute()){ + $id = $stmt->insert_id; + ob_clean(); + echo json_encode(["status"=>"success","id"=>$id]); + } else { + $err = $stmt->error; + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " PARSIL EXEC ERR: $err | Payload: $raw\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"execute","message"=>$err]); + } + $stmt->close(); +} catch (Exception $e) { + $err = $e->getMessage(); + file_put_contents('error_log.txt', date('[Y-m-d H:i:s]') . " PARSIL EXCEPTION: $err | Payload: $raw\n", FILE_APPEND); + ob_clean(); + echo json_encode(["status"=>"error","step"=>"exception","message"=>$err]); } ?> \ No newline at end of file diff --git a/01/api/test_desc.php b/01/api/test_desc.php new file mode 100644 index 0000000..1631c60 --- /dev/null +++ b/01/api/test_desc.php @@ -0,0 +1,5 @@ +query('DESCRIBE jalan'); +while($row = $res->fetch_assoc()) echo json_encode($row)."\n"; +?> diff --git a/01/api/test_enum.php b/01/api/test_enum.php new file mode 100644 index 0000000..0f1aa06 --- /dev/null +++ b/01/api/test_enum.php @@ -0,0 +1,11 @@ +prepare("INSERT INTO jalan (nama, status, panjang, koordinat) VALUES (?, ?, ?, ?)"); +$nama = 'Test'; +$status = 'Jalan Kabupaten'; +$panjang = 10; +$koordinat = '[]'; +$stmt->bind_param("ssds", $nama, $status, $panjang, $koordinat); +$stmt->execute(); +echo $stmt->error; +?> diff --git a/01/index.html b/01/index.html index 8578e3b..a94c94b 100644 --- a/01/index.html +++ b/01/index.html @@ -2946,9 +2946,10 @@ color: #64748b !important; margin: 12px 16px 5px !important; } - .pf input, .pf select { + .pf input, .pf select, .pf textarea { display: block; - width: calc(100% - 32px); + box-sizing: border-box !important; + width: auto !important; margin: 0 16px; padding: 9px 12px !important; border: 1.5px solid #e2e8f0 !important; @@ -2959,7 +2960,14 @@ outline: none; transition: border-color .2s, box-shadow .2s, background .2s; } - .pf input:focus, .pf select:focus { + .pf textarea { + resize: vertical; + min-height: 60px; + font-family: monospace !important; + font-size: 11px !important; + font-weight: 500 !important; + } + .pf input:focus, .pf select:focus, .pf textarea:focus { border-color: #3b82f6 !important; background: #fff !important; box-shadow: 0 0 0 3px rgba(59,130,246,.12) !important; @@ -2992,7 +3000,8 @@ .pf .pbtn { display: block !important; - width: calc(100% - 32px) !important; + box-sizing: border-box !important; + width: auto !important; margin: 12px 16px 14px !important; padding: 10px !important; border-radius: 10px !important; @@ -3258,6 +3267,9 @@ + + +
@@ -4262,15 +4274,17 @@ } setMode(null); + ensureLayerVisible('spbu', d.id); + focusFeature('spbu', d.id); } else { - alert("Gagal simpan database"); + alert("Gagal menyimpan: " + (response.message || "Periksa database")); } }) .catch(err => { - console.log(err); - alert("Terjadi error"); + console.error(err); + alert("Terjadi error jaringan"); }); } @@ -4281,9 +4295,11 @@ const m = L.marker([d.lat, d.lng], { icon, draggable: true }); m.bindPopup(`

${d.nama}

-
No. SPBU${d.no}
-
Status${d.status === 'Ya' ? '✓ Buka 24 Jam' : '✗ Tidak Buka 24 Jam'}
-
Koordinat${d.lat.toFixed(5)}, ${d.lng.toFixed(5)}
+
+
No. SPBU${d.no}
+
Status${d.status === 'Ya' ? '✔ Buka 24 Jam' : '✖ Tidak Buka 24 Jam'}
+
Koordinat${d.lat.toFixed(5)}, ${d.lng.toFixed(5)}
+
@@ -4301,13 +4317,15 @@ state.tempMarkers.push(vm); if (state.tempPolyline) map.removeLayer(state.tempPolyline); state.tempPolyline = L.polyline(state.tempPoints, { color: '#e74c3c', weight: 3, dashArray: '7,5', opacity: 0.8 }).addTo(map); - document.getElementById('hint').textContent = `ðŸ›£ï¸ ${state.tempPoints.length} titik — klik ganda untuk selesai`; + document.getElementById('hint').textContent = `📍 ${state.tempPoints.length} titik — klik ganda untuk selesai`; } function finishLine(e) { if (state.tempPoints.length < 2) { alert('Minimal 2 titik!'); return; } const pts = [...state.tempPoints]; const len = calcLen(pts); + window._tempLinePts = pts; + window._tempLineLen = len; clearTemp(); L.popup({ closeOnClick: false, keepInView: true, autoPanPaddingTopLeft: [0, 80], autoPanPaddingBottomRight: [0, 20] }) .setLatLng(pts[Math.floor(pts.length / 2)]) @@ -4326,11 +4344,13 @@ Panjang terukur: ${fmtLen(len)}
- +
`).addTo(map); } - function saveLine(pts, len) { + function saveLine() { + const pts = window._tempLinePts || []; + const len = window._tempLineLen || 0; const nama = document.getElementById('j-nama').value.trim(); const status = document.getElementById('j-status').value; @@ -4382,6 +4402,8 @@ map.closePopup(); setMode(null); + ensureLayerVisible('jalan', jalan.id); + focusFeature('jalan', jalan.id); } else { @@ -4423,14 +4445,15 @@

${d.nama}

-
-Status -${d.status} -
- -
-Panjang -${fmtLen(d.len)} +
+
+ Status + ${d.status} +
+
+ Panjang + ${fmtLen(d.len)} +
@@ -4549,9 +4572,11 @@ if (state.tempPoints.length < 3) { alert('Minimal 3 titik!'); return; } const pts = [...state.tempPoints]; const area = calcArea(pts); + window._tempPolyPts = pts; + window._tempPolyArea = area; clearTemp(); const center = L.polygon(pts).getBounds().getCenter(); - L.popup({ closeOnClick: false, keepInView: true }) + L.popup({ closeOnClick: false, keepInView: true, autoPanPaddingTopLeft: [0, 80], autoPanPaddingBottomRight: [0, 20] }) .setLatLng(center) .setContent(`

Tambah Parsil / Lahan

@@ -4571,11 +4596,13 @@ Luas terukur: ${fmtArea(area)}
- +
`).addTo(map); } - function saveParsil(pts, area) { + function saveParsil() { + const pts = window._tempPolyPts || []; + const area = window._tempPolyArea || 0; const nama = document.getElementById('ps-nama').value.trim(); const pemilik = document.getElementById('ps-pemilik').value.trim(); @@ -4630,6 +4657,8 @@ map.closePopup(); setMode(null); + ensureLayerVisible('parsil', parsil.id); + focusFeature('parsil', parsil.id); } @@ -4666,19 +4695,19 @@

${d.nama}

-
-Pemilik -${d.pemilik || '-'} -
- -
-Status -${d.status} -
- -
-Luas -${fmtArea(d.area)} +
+
+ Pemilik + ${d.pemilik || '-'} +
+
+ Status + ${d.status} +
+
+ Luas + ${fmtArea(d.area)} +
@@ -4929,7 +4958,7 @@
`; map.closePopup(); - L.popup({ maxWidth: 290 }).setLatLng([ll.lat, ll.lng]).setContent(html).openOn(map); + L.popup({ maxWidth: 290, autoPanPaddingTopLeft: [0, 80], autoPanPaddingBottomRight: [0, 20] }).setLatLng([ll.lat, ll.lng]).setContent(html).openOn(map); } function saveEditSpbu(id) { @@ -4990,7 +5019,7 @@
`; map.closePopup(); - L.popup({ maxWidth: 330 }).setLatLng(center).setContent(html).openOn(map); + L.popup({ maxWidth: 330, autoPanPaddingTopLeft: [0, 80], autoPanPaddingBottomRight: [0, 20] }).setLatLng(center).setContent(html).openOn(map); } function saveEditJalan(id) { @@ -5057,7 +5086,7 @@
`; map.closePopup(); - L.popup({ maxWidth: 330 }).setLatLng(center).setContent(html).openOn(map); + L.popup({ maxWidth: 330, autoPanPaddingTopLeft: [0, 80], autoPanPaddingBottomRight: [0, 20] }).setLatLng(center).setContent(html).openOn(map); } function saveEditParsil(id) { @@ -5195,6 +5224,7 @@ const ref = state.featureRefs[type][String(id)]; if (!ref) return; + map.invalidateSize(); ensureLayerVisible(type, id); setActiveCard(type, id); @@ -5229,6 +5259,7 @@ focusFeature(type, id); } }; + if (!c) { console.warn('addCard: container list-' + type + ' not found'); return; } c.appendChild(el); } @@ -5623,6 +5654,8 @@ renderDashboard(); if (window._tmpM) { map.closePopup(); map.removeLayer(window._tmpM); window._tmpM = null; } setMode(null); + ensureLayerVisible('jalan', jalan.id); + focusFeature('jalan', jalan.id); } else { alert("Gagal simpan: " + (response.message || 'Error')); } @@ -5764,7 +5797,7 @@
`; map.closePopup(); - L.popup({ maxWidth: 330 }).setLatLng([d.lat, d.lng]).setContent(html).openOn(map); + L.popup({ maxWidth: 330, autoPanPaddingTopLeft: [0, 80], autoPanPaddingBottomRight: [0, 20] }).setLatLng([d.lat, d.lng]).setContent(html).openOn(map); } function saveEditKemiskinan(id) { @@ -6072,7 +6105,7 @@
`; map.closePopup(); - L.popup({ maxWidth: 340 }).setLatLng([d.lat, d.lng]).setContent(html).openOn(map); + L.popup({ maxWidth: 340, autoPanPaddingTopLeft: [0, 80], autoPanPaddingBottomRight: [0, 20] }).setLatLng([d.lat, d.lng]).setContent(html).openOn(map); } function saveEditMasjid(id) { diff --git a/01/test_jalan.php b/01/test_jalan.php new file mode 100644 index 0000000..e6e781b --- /dev/null +++ b/01/test_jalan.php @@ -0,0 +1,10 @@ + diff --git a/01/test_jalan2.php b/01/test_jalan2.php new file mode 100644 index 0000000..32a4ea1 --- /dev/null +++ b/01/test_jalan2.php @@ -0,0 +1,10 @@ +