initial commit pemetaan kemiskinan
This commit is contained in:
+422
@@ -0,0 +1,422 @@
|
||||
<?php
|
||||
session_start();
|
||||
if(!isset($_SESSION['id'])){
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
include "config/koneksi.php";
|
||||
|
||||
$role = $_SESSION['role'];
|
||||
$view = $_GET['view'] ?? 'status';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Sistem Bantuan WebGIS</title>
|
||||
|
||||
<style>
|
||||
|
||||
body{
|
||||
font-family:Segoe UI;
|
||||
background:#eef2f7;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
.header{
|
||||
background:linear-gradient(135deg,#0f766e,#14b8a6);
|
||||
color:white;
|
||||
padding:15px 20px;
|
||||
}
|
||||
|
||||
.container{
|
||||
max-width:1100px;
|
||||
margin:auto;
|
||||
padding:20px;
|
||||
}
|
||||
|
||||
.nav{
|
||||
display:flex;
|
||||
gap:10px;
|
||||
flex-wrap:wrap;
|
||||
margin:15px 0;
|
||||
}
|
||||
|
||||
.nav a{
|
||||
background:#0f766e;
|
||||
color:white;
|
||||
padding:8px 12px;
|
||||
border-radius:8px;
|
||||
text-decoration:none;
|
||||
font-size:13px;
|
||||
}
|
||||
|
||||
.card{
|
||||
background:white;
|
||||
padding:15px;
|
||||
margin-bottom:12px;
|
||||
border-radius:12px;
|
||||
box-shadow:0 8px 20px rgba(0,0,0,0.05);
|
||||
border-left:5px solid #0ea5e9;
|
||||
}
|
||||
|
||||
.badge{
|
||||
padding:4px 10px;
|
||||
border-radius:20px;
|
||||
font-size:12px;
|
||||
display:inline-block;
|
||||
margin-top:5px;
|
||||
}
|
||||
|
||||
.pending{background:#fef3c7;}
|
||||
.disetujui{background:#dbeafe;}
|
||||
.diserahkan{background:#dcfce7;}
|
||||
|
||||
button{
|
||||
padding:7px 10px;
|
||||
border:none;
|
||||
border-radius:8px;
|
||||
cursor:pointer;
|
||||
font-size:13px;
|
||||
margin-top:8px;
|
||||
}
|
||||
|
||||
.green{background:#22c55e;color:white;}
|
||||
.blue{background:#0ea5e9;color:white;}
|
||||
.red{background:#ef4444;color:white;}
|
||||
|
||||
/* FORM */
|
||||
.form-box{
|
||||
display:none;
|
||||
background:white;
|
||||
padding:15px;
|
||||
border-radius:12px;
|
||||
box-shadow:0 10px 25px rgba(0,0,0,0.1);
|
||||
margin-bottom:15px;
|
||||
}
|
||||
|
||||
input,select,textarea{
|
||||
width:100%;
|
||||
padding:8px;
|
||||
margin-top:6px;
|
||||
margin-bottom:10px;
|
||||
border:1px solid #ddd;
|
||||
border-radius:8px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="header">
|
||||
<h2>🎁 Sistem Bantuan WebGIS</h2>
|
||||
<p>Role: <b><?= strtoupper($role) ?></b></p>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<!-- NAV -->
|
||||
<div class="nav">
|
||||
|
||||
<?php if($role=="admin"){ ?>
|
||||
<a href="bantuan.php?view=validasi">📊 Validasi</a>
|
||||
<a href="bantuan.php?view=monitoring">📈 Monitoring</a>
|
||||
<a href="bantuan.php?view=riwayat">📦 Riwayat</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($role=="pengurus"){ ?>
|
||||
<a href="bantuan.php?view=distribusi">🎁 Distribusi</a>
|
||||
<a href="bantuan.php?view=radius">📍 Radius</a>
|
||||
<a href="bantuan.php?view=riwayat">📦 Riwayat</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($role=="pengguna"){ ?>
|
||||
<a href="bantuan.php?view=status">📦 Status Saya</a>
|
||||
<a href="bantuan.php?view=riwayat">📦 Riwayat</a>
|
||||
<?php } ?>
|
||||
|
||||
<a href="index.php">🏠 Dashboard</a>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- FORM DISTRIBUSI -->
|
||||
<div class="form-box" id="formBantuan">
|
||||
|
||||
<h3>🎁 Distribusi Bantuan</h3>
|
||||
|
||||
<form method="POST" action="api/bantuan_create.php">
|
||||
|
||||
<input type="hidden" name="keluarga_id" id="keluarga_id">
|
||||
|
||||
<label>Jenis</label>
|
||||
<select name="jenis">
|
||||
<option value="uang">Uang</option>
|
||||
<option value="barang">Barang</option>
|
||||
</select>
|
||||
|
||||
<label>Jumlah</label>
|
||||
<input type="text" name="jumlah">
|
||||
|
||||
<label>Keterangan</label>
|
||||
<textarea name="keterangan"></textarea>
|
||||
|
||||
<button class="green" type="submit">Simpan</button>
|
||||
<button class="red" type="button" onclick="closeForm()">Tutup</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ================= DISTRIBUSI ================= -->
|
||||
<?php if($role=="pengurus" && $view=="distribusi"){ ?>
|
||||
|
||||
<h3>🎁 Distribusi Bantuan</h3>
|
||||
|
||||
<?php
|
||||
$q = mysqli_query($conn,"SELECT * FROM keluarga_miskin WHERE status_bantuan='belum'");
|
||||
while($d = mysqli_fetch_assoc($q)){
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<b><?= $d['nama'] ?></b><br>
|
||||
NIK: <?= $d['nik'] ?><br>
|
||||
Prioritas: <?= $d['prioritas'] ?><br>
|
||||
|
||||
<button class="green" onclick="openForm(<?= $d['id'] ?>)">
|
||||
Beri Bantuan
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<!-- ================= VALIDASI ================= -->
|
||||
<?php if($role=="admin" && $view=="validasi"){ ?>
|
||||
|
||||
<h3>📊 Validasi Bantuan</h3>
|
||||
|
||||
<?php
|
||||
$q = mysqli_query($conn,"
|
||||
SELECT b.*, k.nama, k.nik
|
||||
FROM bantuan b
|
||||
JOIN keluarga_miskin k ON b.keluarga_id=k.id
|
||||
ORDER BY b.id DESC
|
||||
");
|
||||
|
||||
while($d = mysqli_fetch_assoc($q)){
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<b><?= $d['nama'] ?></b><br>
|
||||
<?= $d['nik'] ?><br>
|
||||
<?= $d['jenis'] ?> - <?= $d['jumlah'] ?><br>
|
||||
|
||||
<span class="badge <?= $d['status'] ?>">
|
||||
<?= strtoupper($d['status']) ?>
|
||||
</span>
|
||||
|
||||
<br>
|
||||
|
||||
<a href="api/bantuan_update_status.php?id=<?= $d['id'] ?>&status=disetujui">
|
||||
<button class="green">Setujui</button>
|
||||
</a>
|
||||
|
||||
<a href="api/bantuan_update_status.php?id=<?= $d['id'] ?>&status=diserahkan">
|
||||
<button class="blue">Serahkan</button>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<!-- ================= MONITORING ================= -->
|
||||
<?php if($role=="admin" && $view=="monitoring"){ ?>
|
||||
|
||||
<h3>📈 Monitoring Lengkap</h3>
|
||||
|
||||
<h4>🏛 Rumah Ibadah</h4>
|
||||
<?php
|
||||
$q = mysqli_query($conn,"SELECT * FROM rumah_ibadah");
|
||||
while($d = mysqli_fetch_assoc($q)){
|
||||
echo "<div class='card'>".$d['nama']." - ".$d['radius']."m</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<h4>👨👩👧 Keluarga</h4>
|
||||
<?php
|
||||
$q = mysqli_query($conn,"SELECT * FROM keluarga_miskin");
|
||||
while($d = mysqli_fetch_assoc($q)){
|
||||
echo "<div class='card'>".$d['nama']." - ".$d['status_bantuan']."</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<h4>🎁 Bantuan</h4>
|
||||
<?php
|
||||
$q = mysqli_query($conn,"SELECT * FROM bantuan");
|
||||
while($d = mysqli_fetch_assoc($q)){
|
||||
echo "<div class='card'>".$d['jenis']." - ".$d['status']."</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<!-- ================= STATUS USER ================= -->
|
||||
<?php if($role=="pengguna" && $view=="status"){ ?>
|
||||
|
||||
<h3>📦 Status Bantuan Saya</h3>
|
||||
|
||||
<?php
|
||||
$q = mysqli_query($conn,"
|
||||
SELECT b.*, k.nama
|
||||
FROM bantuan b
|
||||
JOIN keluarga_miskin k ON b.keluarga_id=k.id
|
||||
");
|
||||
|
||||
while($d = mysqli_fetch_assoc($q)){
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<b><?= $d['nama'] ?></b><br>
|
||||
<?= $d['jenis'] ?> - <?= $d['jumlah'] ?><br>
|
||||
<span class="badge <?= $d['status'] ?>">
|
||||
<?= $d['status'] ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<!-- ================= RIWAYAT ================= -->
|
||||
<?php if($view=="riwayat"){ ?>
|
||||
|
||||
<h3>📦 Riwayat Bantuan</h3>
|
||||
|
||||
<?php
|
||||
$q = mysqli_query($conn,"
|
||||
SELECT b.*, k.nama
|
||||
FROM bantuan b
|
||||
JOIN keluarga_miskin k ON b.keluarga_id=k.id
|
||||
WHERE b.status='diserahkan'
|
||||
");
|
||||
|
||||
while($d = mysqli_fetch_assoc($q)){
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<b><?= $d['nama'] ?></b><br>
|
||||
<?= $d['jenis'] ?> - <?= $d['jumlah'] ?><br>
|
||||
Status: <?= $d['status'] ?>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<!-- ================= RADIUS MONITORING (DETAIL LIST) ================= -->
|
||||
<?php if($role=="pengurus" && $view=="radius"){ ?>
|
||||
|
||||
<h3 style="margin-bottom:10px;">📍 Monitoring Radius Rumah Ibadah</h3>
|
||||
|
||||
<?php
|
||||
$ib = mysqli_query($conn,"SELECT * FROM rumah_ibadah");
|
||||
|
||||
while($i = mysqli_fetch_assoc($ib)){
|
||||
|
||||
$kel_dalam = [];
|
||||
$kel_luar = [];
|
||||
|
||||
$kls = mysqli_query($conn,"SELECT * FROM keluarga_miskin");
|
||||
|
||||
while($k = mysqli_fetch_assoc($kls)){
|
||||
|
||||
$jarak = 6371000 * acos(
|
||||
cos(deg2rad($i['lat'])) *
|
||||
cos(deg2rad($k['lat'])) *
|
||||
cos(deg2rad($k['lng']) - deg2rad($i['lng'])) +
|
||||
sin(deg2rad($i['lat'])) *
|
||||
sin(deg2rad($k['lat']))
|
||||
);
|
||||
|
||||
if($jarak <= $i['radius']){
|
||||
$kel_dalam[] = $k;
|
||||
} else {
|
||||
$kel_luar[] = $k;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- CARD RUMAH IBADAH -->
|
||||
<div class="card">
|
||||
|
||||
<div style="font-size:16px;font-weight:bold;color:#0f766e;">
|
||||
🏛 <?= $i['nama'] ?>
|
||||
</div>
|
||||
|
||||
<div style="font-size:13px;margin-top:5px;">
|
||||
Radius: <b><?= $i['radius'] ?> meter</b><br>
|
||||
Alamat: <?= $i['alamat'] ?>
|
||||
</div>
|
||||
|
||||
<hr style="margin:10px 0;">
|
||||
|
||||
<!-- DALAM RADIUS -->
|
||||
<div style="margin-bottom:10px;">
|
||||
<span style="background:#dcfce7;color:#166534;padding:4px 10px;border-radius:20px;font-size:12px;">
|
||||
🟢 DALAM RADIUS (<?= count($kel_dalam) ?>)
|
||||
</span>
|
||||
|
||||
<div style="margin-top:8px;">
|
||||
<?php foreach($kel_dalam as $k){ ?>
|
||||
<div style="padding:6px;border:1px solid #dcfce7;border-radius:8px;margin-top:5px;background:#f0fdf4;">
|
||||
👤 <?= $k['nama'] ?> - <?= $k['nik'] ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- LUAR RADIUS -->
|
||||
<div>
|
||||
<span style="background:#fee2e2;color:#991b1b;padding:4px 10px;border-radius:20px;font-size:12px;">
|
||||
🔴 LUAR RADIUS (<?= count($kel_luar) ?>)
|
||||
</span>
|
||||
|
||||
<div style="margin-top:8px;">
|
||||
<?php foreach($kel_luar as $k){ ?>
|
||||
<div style="padding:6px;border:1px solid #fee2e2;border-radius:8px;margin-top:5px;background:#fff1f2;">
|
||||
👤 <?= $k['nama'] ?> - <?= $k['nik'] ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
function openForm(id){
|
||||
document.getElementById("formBantuan").style.display="block";
|
||||
document.getElementById("keluarga_id").value=id;
|
||||
}
|
||||
|
||||
function closeForm(){
|
||||
document.getElementById("formBantuan").style.display="none";
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user