Add WebGIS source code

This commit is contained in:
ocabacaa
2026-06-11 23:48:02 +07:00
parent ce48dbcddc
commit b212ca27fd
37 changed files with 5764 additions and 0 deletions
+242
View File
@@ -0,0 +1,242 @@
<?php
session_start();
if(!isset($_SESSION['role'])){
header("Location: ../index.php");
exit;
}
if($_SESSION['role'] != 'warga'){
header("Location: ../index.php");
exit;
}
include '../config/koneksi.php';
$id = intval($_SESSION['id']);
$total = mysqli_num_rows(
mysqli_query($conn,
"SELECT * FROM laporan
WHERE pelapor_id='$id'")
);
$pending = mysqli_num_rows(
mysqli_query($conn,
"SELECT * FROM laporan
WHERE pelapor_id='$id'
AND status='pending'")
);
$disetujui = mysqli_num_rows(
mysqli_query($conn,
"SELECT * FROM laporan
WHERE pelapor_id='$id'
AND status='disetujui'")
);
$diproses = mysqli_num_rows(
mysqli_query($conn,
"SELECT * FROM laporan
WHERE pelapor_id='$id'
AND status='diproses'")
);
$selesai = mysqli_num_rows(
mysqli_query($conn,
"SELECT * FROM laporan
WHERE pelapor_id='$id'
AND status='selesai'")
);
$ditolak = mysqli_num_rows(
mysqli_query($conn,
"SELECT * FROM laporan
WHERE pelapor_id='$id'
AND status='ditolak'")
);
$persentase = 0;
if($total > 0){
$persentase = round(($selesai/$total)*100);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Dashboard Warga</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" />
</head>
<body class="bg-slate-100 min-h-screen">
<!-- NAVBAR -->
<nav class="bg-slate-800 text-white shadow">
<div class="max-w-7xl mx-auto px-4 py-4 flex flex-col md:flex-row justify-between items-center gap-3">
<h2 class="font-bold text-xl">
WebGIS Kemiskinan
</h2>
<div class="flex flex-col sm:flex-row items-center gap-3">
<span>
Halo,
<?= htmlspecialchars($_SESSION['nama']) ?>
</span>
<a href="../logout.php" onclick="return confirm('Logout sekarang?');"
class="bg-red-500 hover:bg-red-600 px-4 py-2 rounded-lg transition">
Logout
</a>
</div>
</div>
</nav>
<!-- CONTENT -->
<div class="max-w-7xl mx-auto p-6">
<!-- HERO -->
<div class="bg-gradient-to-r from-cyan-600 to-blue-600 text-white rounded-3xl p-8 shadow-lg">
<h1 class="text-3xl font-bold">
Selamat Datang 👋
<?= htmlspecialchars($_SESSION['nama']) ?>
</h1>
<p class="mt-3 text-cyan-100">
Laporkan kondisi warga yang membutuhkan bantuan sosial
di sekitar lingkungan Anda.
</p>
<div class="flex flex-col sm:flex-row gap-3 mt-6">
<a href="laporan.php"
class="bg-white text-blue-600 font-semibold px-6 py-3 rounded-xl shadow hover:shadow-lg transition">
<i class="fa-solid fa-plus mr-2"></i>
Buat Laporan
</a>
<a href="status.php"
class="bg-slate-800 text-white font-semibold px-6 py-3 rounded-xl shadow hover:bg-slate-900 transition">
<i class="fa-solid fa-list-check mr-2"></i>
Lihat Laporan
</a>
</div>
<div class="bg-white rounded-2xl shadow p-6 mt-6">
<p class="font-semibold">
Progress Bantuan
</p>
<div class="w-full bg-slate-200 rounded-full h-4 mt-3">
<div class="bg-green-500 h-4 rounded-full" style="width: <?= $persentase ?>%">
</div>
</div>
<p class="mt-2 text-sm text-slate-500">
<?= $persentase ?>% laporan telah selesai
</p>
</div>
</div>
<!-- CARDS -->
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6 mt-8">
<!-- Total -->
<div class="bg-white rounded-2xl shadow p-6">
<i class="fa-solid fa-file text-4xl text-blue-600"></i>
<p class="text-slate-500 mt-3">Total Laporan</p>
<h2 class="text-4xl font-bold"><?= $total ?></h2>
</div>
<!-- Pending -->
<div class="bg-white rounded-2xl shadow p-6">
<i class="fa-solid fa-clock text-4xl text-yellow-500"></i>
<p class="text-slate-500 mt-3">Pending</p>
<h2 class="text-4xl font-bold"><?= $pending ?></h2>
</div>
<!-- Disetujui -->
<div class="bg-white rounded-2xl shadow p-6">
<i class="fa-solid fa-circle-check text-4xl text-green-500"></i>
<p class="text-slate-500 mt-3">Disetujui</p>
<h2 class="text-4xl font-bold"><?= $disetujui ?></h2>
</div>
<!-- Diproses -->
<div class="bg-white rounded-2xl shadow p-6">
<i class="fa-solid fa-spinner animate-spin text-4xl text-blue-500"></i>
<p class="text-slate-500 mt-3">Diproses</p>
<h2 class="text-4xl font-bold"><?= $diproses ?></h2>
</div>
<!-- Selesai -->
<div class="bg-white rounded-2xl shadow p-6">
<i class="fa-solid fa-hand-holding-heart text-4xl text-purple-500"></i>
<p class="text-slate-500 mt-3">Selesai</p>
<h2 class="text-4xl font-bold"><?= $selesai ?></h2>
</div>
<!-- Ditolak -->
<div class="bg-white rounded-2xl shadow p-6">
<i class="fa-solid fa-circle-xmark text-4xl text-red-500"></i>
<p class="text-slate-500 mt-3">Ditolak</p>
<h2 class="text-4xl font-bold"><?= $ditolak ?></h2>
</div>
</div>
</div>
</body>
</html>
+201
View File
@@ -0,0 +1,201 @@
<?php
session_start();
if(!isset($_SESSION['role'])){
header("Location: ../index.php");
exit;
}
if($_SESSION['role'] != 'warga'){
header("Location: ../index.php");
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Buat Laporan</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
</head>
<body class="bg-slate-100 min-h-screen">
<div class="max-w-5xl mx-auto p-6">
<a href="dashboard.php"
class="inline-flex items-center gap-2 bg-slate-800 hover:bg-slate-900 text-white px-4 py-3 rounded-xl shadow">
← Kembali ke Dashboard
</a>
<div class="bg-white rounded-3xl shadow-lg p-8 mt-6">
<div class="mb-8">
<h1 class="text-3xl font-bold text-slate-800">
Buat Laporan Warga
</h1>
<p class="text-slate-500 mt-2">
Isi data warga yang membutuhkan bantuan sosial dan pilih lokasi pada peta.
</p>
</div>
<form action="simpan_laporan.php" method="POST" enctype="multipart/form-data" class="space-y-5">
<div>
<label class="block mb-2 font-medium text-slate-700">
Nama Warga
</label>
<input type="text" name="nama_warga" required
class="w-full border rounded-xl px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:outline-none">
</div>
<div>
<label class="block mb-2 font-medium text-slate-700">
Alamat
</label>
<textarea name="alamat" rows="3" required
class="w-full border rounded-xl px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:outline-none"></textarea>
</div>
<div>
<label class="block mb-2 font-medium text-slate-700">
Kondisi Warga
</label>
<textarea name="kondisi" rows="4" required
class="w-full border rounded-xl px-4 py-3 focus:ring-2 focus:ring-blue-500 focus:outline-none"></textarea>
</div>
<div>
<label class="block mb-2 font-medium text-slate-700">
Foto Kondisi Warga
</label>
<input type="file" name="foto" accept="image/*" required class="w-full border rounded-xl px-4 py-3">
</div>
<div class="grid md:grid-cols-2 gap-4">
<div>
<label class="block mb-2 font-medium text-slate-700">
Latitude
</label>
<input type="text" name="latitude" id="latitude" readonly required
class="w-full border rounded-xl px-4 py-3 bg-slate-100">
</div>
<div>
<label class="block mb-2 font-medium text-slate-700">
Longitude
</label>
<input type="text" name="longitude" id="longitude" readonly required
class="w-full border rounded-xl px-4 py-3 bg-slate-100">
</div>
</div>
<div>
<label class="block mb-3 font-medium text-slate-700">
Pilih Lokasi Pada Peta
</label>
<p class="text-sm text-slate-500 mb-3">
Klik pada peta untuk menentukan lokasi warga.
</p>
<div id="map" style="height:450px;" class="rounded-2xl border">
</div>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script>
var map = L.map('map').setView(
[-0.0263, 109.3425],
11
);
L.tileLayer(
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19
}
).addTo(map);
var marker;
map.on('click', function(e) {
var lat = e.latlng.lat.toFixed(6);
var lng = e.latlng.lng.toFixed(6);
document.getElementById('latitude').value = lat;
document.getElementById('longitude').value = lng;
if (marker) {
map.removeLayer(marker);
}
marker = L.marker([lat, lng])
.addTo(map)
.bindPopup(
"Lat: " + lat +
"<br>Lng: " + lng
)
.openPopup();
});
setTimeout(function() {
map.invalidateSize();
}, 200);
</script>
</div>
<button type="submit"
class="w-full md:w-auto bg-blue-600 hover:bg-blue-700 text-white px-8 py-3 rounded-xl font-semibold shadow">
Kirim Laporan
</button>
</form>
</div>
</div>
</body>
</html>
+106
View File
@@ -0,0 +1,106 @@
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #f8fafc;
font-family: 'Segoe UI', sans-serif;
}
.content {
padding: 30px;
}
/* CARD */
.card {
background: white;
border-radius: 16px;
padding: 25px;
box-shadow:
0 4px 20px rgba(0, 0, 0, .08);
transition: .3s;
}
.card:hover {
transform: translateY(-5px);
}
/* TABLE */
table {
width: 100%;
border-collapse: collapse;
background: white;
border-radius: 15px;
overflow: hidden;
box-shadow:
0 4px 20px rgba(0, 0, 0, .08);
}
th {
background: #2563eb;
color: white;
}
th,
td {
padding: 14px;
border-bottom: 1px solid #eee;
}
/* BUTTON */
.btn {
padding: 10px 16px;
border-radius: 10px;
text-decoration: none;
color: white;
display: inline-block;
}
.approve {
background: #16a34a;
}
.reject {
background: #dc2626;
}
.delete {
background: #64748b;
}
.warning {
background: #f59e0b;
}
/* INPUT */
input,
select,
textarea {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 10px;
margin-top: 8px;
}
/* BOX */
.box {
background: white;
padding: 25px;
border-radius: 20px;
box-shadow:
0 4px 20px rgba(0, 0, 0, .08);
}
</style>
+105
View File
@@ -0,0 +1,105 @@
<?php
session_start();
include '../config/koneksi.php';
$pelapor_id = $_SESSION['id'];
$nama_warga = mysqli_real_escape_string(
$conn,
$_POST['nama_warga']
);
$alamat = mysqli_real_escape_string(
$conn,
$_POST['alamat']
);
$kondisi = mysqli_real_escape_string(
$conn,
$_POST['kondisi']
);
$latitude = floatval($_POST['latitude']);
$longitude = floatval($_POST['longitude']);
/* FOTO */
$foto =
time().'_'.
basename($_FILES['foto']['name']);
$tmp = $_FILES['foto']['tmp_name'];
$ext = strtolower(
pathinfo(
$foto,
PATHINFO_EXTENSION
)
);
$allowed = [
'jpg',
'jpeg',
'png',
'webp'
];
if(!in_array($ext,$allowed)){
echo "
<script>
alert('Format foto harus JPG, PNG, atau WEBP');
history.back();
</script>
";
exit;
}
if(!move_uploaded_file(
$tmp,
"../assets/uploads/".$foto
)){
die("Upload foto gagal");
}
/* INSERT */
mysqli_query($conn,
"INSERT INTO laporan
(
pelapor_id,
nama_warga,
alamat,
latitude,
longitude,
kondisi,
foto,
status
)
VALUES
(
'$pelapor_id',
'$nama_warga',
'$alamat',
'$latitude',
'$longitude',
'$kondisi',
'$foto',
'pending'
)"
);
echo "
<script>
alert('Laporan berhasil dikirim');
window.location='dashboard.php';
</script>
";
?>
+224
View File
@@ -0,0 +1,224 @@
<?php
session_start();
if(!isset($_SESSION['role'])){
header("Location: ../index.php");
exit;
}
if($_SESSION['role'] != 'warga'){
header("Location: ../index.php");
exit;
}
include '../config/koneksi.php';
$id = $_SESSION['id'];
$data = mysqli_query($conn,
"SELECT * FROM laporan
WHERE pelapor_id='$id'
ORDER BY id DESC"
);
?>
<!DOCTYPE html>
<html>
<head>
<title>Status Laporan</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
body {
font-family: Arial;
background: #f4f4f4;
padding: 20px;
}
table {
width: 100%;
background: white;
border-collapse: collapse;
}
th,
td {
padding: 12px;
border: 1px solid #ddd;
}
th {
background: #3498db;
color: white;
}
</style>
</head>
<body class="bg-slate-100 min-h-screen">
<div class="max-w-7xl mx-auto p-6">
<a href="dashboard.php"
class="inline-flex items-center gap-2 bg-slate-800 hover:bg-slate-900 text-white px-5 py-3 rounded-xl shadow transition">
← Kembali ke Dashboard
</a>
<div class="bg-white rounded-3xl shadow-lg p-6 md:p-8 mt-6">
<div class="mb-6">
<h1 class="text-3xl font-bold text-slate-800">
Status Laporan Saya
</h1>
<p class="text-slate-500 mt-2">
Pantau perkembangan laporan yang telah Anda kirim.
</p>
</div>
<div class="overflow-x-auto">
<table class="min-w-full">
<thead>
<tr class="bg-blue-600 text-white">
<th class="px-4 py-3 text-left">No</th>
<th class="px-4 py-3 text-left">Nama Warga</th>
<th class="px-4 py-3 text-left">Foto</th>
<th class="px-4 py-3 text-left">Tanggal</th>
<th class="px-4 py-3 text-left">Status</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
if(mysqli_num_rows($data) == 0){
?>
<tr>
<td colspan="5" class="text-center py-8 text-slate-500">
Belum ada laporan
</td>
</tr>
<?php
} else {
while($row = mysqli_fetch_assoc($data)){
?>
<tr class="border-b hover:bg-slate-50">
<td class="px-4 py-4">
<?= $no++ ?>
</td>
<td class="px-4 py-4 font-medium">
<?= htmlspecialchars($row['nama_warga']) ?>
</td>
<td class="px-4 py-4">
<?php if($row['foto']!=''){ ?>
<img src="../assets/uploads/<?= htmlspecialchars($row['foto']) ?>"
class="w-20 h-20 object-cover rounded-xl shadow">
<?php } else { ?>
<span class="text-slate-400">
Tidak ada foto
</span>
<?php } ?>
</td>
<td class="px-4 py-4 text-slate-600">
<?= date('d-m-Y H:i', strtotime($row['created_at'])) ?>
</td>
<td class="px-4 py-4">
<?php
if($row['status']=='pending'){
echo "<span class='bg-amber-500 text-white px-3 py-1 rounded-full text-sm'>Pending</span>";
}
elseif($row['status']=='disetujui'){
echo "<span class='bg-green-600 text-white px-3 py-1 rounded-full text-sm'>Disetujui</span>";
}
elseif($row['status']=='ditolak'){
echo "<span class='bg-red-600 text-white px-3 py-1 rounded-full text-sm'>Ditolak</span>";
}
elseif($row['status']=='diproses'){
echo "<span class='bg-blue-600 text-white px-3 py-1 rounded-full text-sm'>Diproses</span>";
}
elseif($row['status']=='selesai'){
echo "<span class='bg-purple-600 text-white px-3 py-1 rounded-full text-sm'>Selesai</span>";
}
?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>