290 lines
13 KiB
PHP
290 lines
13 KiB
PHP
<?php
|
|
require_once 'koneksi.php';
|
|
cekLogin();
|
|
cekRole('pengurus','relawan','admin');
|
|
|
|
$page = 'konfirmasi';
|
|
$pageTitle = 'Konfirmasi Bantuan';
|
|
$pageSubtitle = 'Verifikasi Penerimaan di Lapangan';
|
|
|
|
// Filter tab
|
|
$tab = $_GET['tab'] ?? 'menunggu';
|
|
|
|
$where = "WHERE 1=1";
|
|
if ($tab === 'menunggu') $where .= " AND bt.status_konfirmasi = 'Menunggu'";
|
|
if ($tab === 'dikonfirmasi') $where .= " AND bt.status_konfirmasi = 'Dikonfirmasi'";
|
|
if ($tab === 'ditolak') $where .= " AND bt.status_konfirmasi = 'Ditolak'";
|
|
|
|
$data = $conn->query("
|
|
SELECT bt.*, rm.nama_kepala_keluarga, rm.kelurahan, rm.rt_rw,
|
|
rm.kondisi_rumah, rm.no_telp AS telp_warga,
|
|
u.nama_lengkap AS input_oleh
|
|
FROM bantuan_tersalur bt
|
|
LEFT JOIN rumah_miskin rm ON bt.warga_id = rm.id
|
|
LEFT JOIN users u ON bt.disalurkan_oleh = u.id
|
|
$where
|
|
ORDER BY bt.created_at DESC
|
|
");
|
|
$total = $data->num_rows;
|
|
|
|
// Count per tab
|
|
$cMenunggu = $conn->query("SELECT COUNT(*) AS c FROM bantuan_tersalur WHERE status_konfirmasi='Menunggu'") ->fetch_assoc()['c'];
|
|
$cDikonfirmasi = $conn->query("SELECT COUNT(*) AS c FROM bantuan_tersalur WHERE status_konfirmasi='Dikonfirmasi'") ->fetch_assoc()['c'];
|
|
$cDitolak = $conn->query("SELECT COUNT(*) AS c FROM bantuan_tersalur WHERE status_konfirmasi='Ditolak'") ->fetch_assoc()['c'];
|
|
|
|
include 'includes/sidebar.php';
|
|
?>
|
|
|
|
<style>
|
|
.custom-header-wrapper {
|
|
display: flex !important;
|
|
justify-content: space-between !important;
|
|
align-items: center !important;
|
|
margin-bottom: 25px !important;
|
|
background: #ffffff !important;
|
|
padding: 20px 24px !important;
|
|
border-radius: 12px !important;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
|
|
}
|
|
.custom-tabs {
|
|
display: flex;
|
|
gap: 8px;
|
|
margin-bottom: 20px;
|
|
border-bottom: 2px solid #e2e8f0;
|
|
padding-bottom: 1px;
|
|
}
|
|
.custom-tab-item {
|
|
padding: 10px 18px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: #64748b;
|
|
text-decoration: none;
|
|
border-bottom: 2px solid transparent;
|
|
transition: all 0.2s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
.custom-tab-item:hover {
|
|
color: #2563eb;
|
|
}
|
|
.custom-tab-item.active {
|
|
color: #2563eb;
|
|
border-bottom-color: #2563eb;
|
|
}
|
|
.custom-tab-badge {
|
|
font-size: 11px;
|
|
padding: 2px 6px;
|
|
border-radius: 20px;
|
|
font-weight: 700;
|
|
}
|
|
@media (max-width: 768px) {
|
|
.custom-header-wrapper {
|
|
flex-direction: column !important;
|
|
align-items: flex-start !important;
|
|
gap: 15px !important;
|
|
}
|
|
.custom-tabs {
|
|
flex-wrap: wrap;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<div class="custom-header-wrapper">
|
|
<div>
|
|
<h2 style="margin: 0; font-size: 24px; color: #1e293b; font-weight: 700; display: flex; align-items: center; gap: 10px;">
|
|
<span>📋</span> Konfirmasi Penerimaan Bantuan
|
|
</h2>
|
|
<p style="margin: 4px 0 0 0; color: #64748b; font-size: 14px;">
|
|
Halaman khusus Relawan & Pengurus untuk verifikasi logistik di lapangan
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="custom-tabs">
|
|
<a href="konfirmasi-bantuan.php?tab=menunggu" class="custom-tab-item <?= $tab==='menunggu'?'active':'' ?>">
|
|
⏳ Menunggu
|
|
<span class="custom-tab-badge" style="background:#fef3c7; color:#d97706;"><?= $cMenunggu ?></span>
|
|
</a>
|
|
<a href="konfirmasi-bantuan.php?tab=dikonfirmasi" class="custom-tab-item <?= $tab==='dikonfirmasi'?'active':'' ?>">
|
|
✅ Dikonfirmasi
|
|
<span class="custom-tab-badge" style="background:#dcfce7; color:#16a34a;"><?= $cDikonfirmasi ?></span>
|
|
</a>
|
|
<a href="konfirmasi-bantuan.php?tab=ditolak" class="custom-tab-item <?= $tab==='ditolak'?'active':'' ?>">
|
|
❌ Ditolak / Masalah
|
|
<span class="custom-tab-badge" style="background:#fee2e2; color:#dc2626;"><?= $cDitolak ?></span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3>Penyaluran Status: <span style="text-transform: capitalize; color: var(--primary)"><?= $tab ?></span></h3>
|
|
<span class="badge badge-gray"><?= $total ?> Transaksi</span>
|
|
</div>
|
|
<div class="tbl-wrap">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>Penerima (KPM) & Alamat</th>
|
|
<th>Detail Item Bantuan</th>
|
|
<th>Tanggal Input</th>
|
|
<th>Dibuat Oleh</th>
|
|
<?php if ($tab !== 'menunggu'): ?>
|
|
<th>Info Verifikasi</th>
|
|
<?php endif; ?>
|
|
<?php if ($tab === 'menunggu'): ?>
|
|
<th>Verifikasi Lapangan</th>
|
|
<?php endif; ?>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($total === 0): ?>
|
|
<tr>
|
|
<td colspan="7" style="text-align:center;padding:40px;color:var(--gray)">
|
|
<i class="fa fa-inbox" style="font-size:24px;display:block;margin-bottom:8px;color:#94a3b8"></i>
|
|
Tidak ada data bantuan dalam kategori ini
|
|
</td>
|
|
</tr>
|
|
<?php else: $no=1; while ($r = $data->fetch_assoc()): ?>
|
|
<tr>
|
|
<td style="color:#94a3b8;font-weight:600;font-size:12px"><?= $no++ ?></td>
|
|
<td>
|
|
<div style="font-weight:700;font-size:13px"><?= htmlspecialchars($r['nama_kepala_keluarga'] ?? 'Warga Dihapus') ?></div>
|
|
<div style="font-size:11px;color:var(--gray);margin-top:2px">
|
|
<?= htmlspecialchars($r['rt_rw'] ?? '') ?>, Kel. <?= htmlspecialchars($r['kelurahan'] ?? '') ?>
|
|
</div>
|
|
<?php if ($r['telp_warga']): ?>
|
|
<div style="font-size:11px;color:#2563eb;margin-top:2px"><i class="fa fa-phone"></i> <?= htmlspecialchars($r['telp_warga']) ?></div>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<span class="badge badge-blue" style="font-weight:600"><?= htmlspecialchars($r['jenis_bantuan']) ?></span>
|
|
<div style="font-weight:700;font-size:13px;margin-top:4px;color:#1e293b">Jml: <?= htmlspecialchars($r['jumlah'] ?? '-') ?></div>
|
|
<?php if ($r['keterangan']): ?>
|
|
<div style="font-size:11px;color:var(--gray);font-style:italic;margin-top:2px">Note: <?= htmlspecialchars($r['keterangan']) ?></div>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td style="font-size:12px;color:var(--gray)"><?= date('d M Y H:i', strtotime($r['created_at'])) ?></td>
|
|
<td style="font-size:12px;font-weight:500"><?= htmlspecialchars($r['input_oleh'] ?? 'Sistem') ?></td>
|
|
|
|
<?php if ($tab !== 'menunggu'): ?>
|
|
<td>
|
|
<div style="font-size:12px">
|
|
<strong>Status:</strong>
|
|
<span class="badge <?= $tab==='dikonfirmasi'?'badge-green':'badge-red' ?>">
|
|
<?= htmlspecialchars($r['status_konfirmasi']) ?>
|
|
</span>
|
|
</div>
|
|
<?php if ($r['catatan_konfirmasi']): ?>
|
|
<div style="font-size:11px;color:var(--gray);background:#f8fafc;padding:4px 6px;border-radius:4px;margin-top:4px;border:1px solid #e2e8f0">
|
|
<strong>Ket:</strong> <?= htmlspecialchars($r['catatan_konfirmasi']) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div style="font-size:10px;color:#94a3b8;margin-top:4px">
|
|
Waktu: <?= $r['waktu_konfirmasi'] ? date('d/m/Y H:i', strtotime($r['waktu_konfirmasi'])) : '-' ?>
|
|
</div>
|
|
</td>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($tab === 'menunggu'): ?>
|
|
<td>
|
|
<div style="display:flex;gap:6px">
|
|
<button class="btn btn-success btn-sm" onclick="konfirmasiTerima(<?= $r['id'] ?>, '<?= htmlspecialchars($r['nama_kepala_keluarga'], ENT_QUOTES) ?>')" style="display:flex;align-items:center;gap:4px">
|
|
<i class="fa fa-check"></i> Terima
|
|
</button>
|
|
<button class="btn btn-danger btn-sm" onclick="bukaModalTolak(<?= $r['id'] ?>, '<?= htmlspecialchars($r['nama_kepala_keluarga'], ENT_QUOTES) ?>')" style="display:flex;align-items:center;gap:4px">
|
|
<i class="fa fa-times"></i> Bermasalah
|
|
</button>
|
|
</div>
|
|
</td>
|
|
<?php endif; ?>
|
|
</tr>
|
|
<?php endwhile; endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal-overlay" id="modalTolak">
|
|
<div class="modal-box" style="max-width:400px">
|
|
<div class="modal-head">
|
|
<h3>Tolak / Laporkan Masalah</h3>
|
|
<button class="btn-close" onclick="closeModal('modalTolak')">✕</button>
|
|
</div>
|
|
<form method="POST" action="proses.php">
|
|
<input type="hidden" name="aksi" value="konfirmasi_bantuan">
|
|
<input type="hidden" name="id" id="mt_id">
|
|
<input type="hidden" name="status" value="Ditolak">
|
|
<div class="modal-body">
|
|
<div style="font-size:13px; font-weight:600; color:#dc2626; margin-bottom:12px;" id="mt_nama_label"></div>
|
|
<div class="form-group">
|
|
<label>Alasan Penolakan / Laporan Masalah *</label>
|
|
<textarea class="form-control" name="catatan_konfirmasi" rows="3" required
|
|
placeholder="cth: Penerima tidak ditemukan di alamat, bantuan belum sampai, barang rusak..."></textarea>
|
|
</div>
|
|
<div style="background:var(--red-lt);border-radius:var(--radius-sm);padding:9px 12px;font-size:12px;color:var(--red)">
|
|
Data ini akan dilaporkan kembali ke pihak manajemen/pemerintah untuk ditindaklanjuti.
|
|
</div>
|
|
</div>
|
|
<div class="modal-foot">
|
|
<button type="button" class="btn btn-ghost" onclick="closeModal('modalTolak')">Batal</button>
|
|
<button type="submit" class="btn btn-danger">Kirim Laporan</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function openModal(id) {
|
|
const modal = document.getElementById(id);
|
|
if(modal) modal.style.display = 'flex';
|
|
}
|
|
|
|
// Fungsi menutup form modal
|
|
function closeModal(id) {
|
|
const modal = document.getElementById(id);
|
|
if(modal) modal.style.display = 'none';
|
|
}
|
|
|
|
// 1. Fungsi Klik Tombol "Terima" (Langsung Setujui Distribusi lewat POST virtual form)
|
|
function konfirmasiTerima(id, namaWarga) {
|
|
if (confirm(`Apakah Anda sudah memverifikasi di lapangan bahwa bantuan untuk KK "${namaWarga}" telah DITERIMA dengan benar?`)) {
|
|
// Membuat elemen form virtual di dalam memori dokumen browser
|
|
const form = document.createElement('form');
|
|
form.method = 'POST';
|
|
form.action = 'proses.php';
|
|
|
|
form.innerHTML = `
|
|
<input type="hidden" name="aksi" value="konfirmasi_bantuan">
|
|
<input type="hidden" name="id" value="${id}">
|
|
<input type="hidden" name="status" value="Dikonfirmasi">
|
|
<input type="hidden" name="catatan_konfirmasi" value="Bantuan diterima dengan baik di lapangan.">
|
|
`;
|
|
document.body.appendChild(form);
|
|
form.submit();
|
|
}
|
|
}
|
|
|
|
// 2. Fungsi Klik Tombol "Bermasalah" (Membuka Modal Laporan Dampak)
|
|
function bukaModalTolak(id, namaWarga) {
|
|
document.getElementById('mt_id').value = id;
|
|
document.getElementById('mt_nama_label').innerHTML = `<i class="fa fa-user"></i> Masalah Distribusi: <strong>${namaWarga}</strong>`;
|
|
|
|
// Reset isi form teks area sebelumnya
|
|
document.querySelector('#modalTolak textarea[name="catatan_konfirmasi"]').value = "";
|
|
|
|
openModal('modalTolak');
|
|
}
|
|
|
|
// Menutup modal otomatis apabila pengguna mengklik area luar box modal yang gelap
|
|
window.onclick = function(event) {
|
|
if (event.target.classList.contains('modal-overlay')) {
|
|
closeModal(event.target.id);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<?php
|
|
include 'includes/footer.php';
|
|
?>
|