%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
/**
* Admin: daftar permohonan informasi dengan filter status & pencarian.
*/
require_once dirname(__DIR__) . '/config/config.php';
require_once dirname(__DIR__) . '/includes/auth.php';
require_once dirname(__DIR__) . '/includes/queries.php';
require_central();
$status = get_param('status');
$keyword = get_param('q');
$page = max(1, (int) get_param('page', '1'));
$perPage = 12;
$offset = ($page - 1) * $perPage;
$validStatus = ['verifikasi', 'diproses', 'selesai', 'ditolak'];
$where = [];
$params = [];
if (in_array($status, $validStatus, true)) {
$where[] = 'p.status = :status';
$params[':status'] = $status;
}
if ($keyword !== '') {
$where[] = '(p.nama LIKE :kw1 OR p.no_resi LIKE :kw2 OR p.email LIKE :kw3)';
$like = '%' . $keyword . '%';
$params[':kw1'] = $like;
$params[':kw2'] = $like;
$params[':kw3'] = $like;
}
$whereSql = $where ? 'WHERE ' . implode(' AND ', $where) : '';
$countStmt = db()->prepare("SELECT COUNT(*) FROM permohonan p $whereSql");
$countStmt->execute($params);
$total = (int) $countStmt->fetchColumn();
$totalPages = max(1, (int) ceil($total / $perPage));
$sql = "SELECT p.*, k.nama AS kategori_nama
FROM permohonan p
LEFT JOIN kategori_informasi k ON k.id = p.kategori_id
$whereSql
ORDER BY p.created_at DESC
LIMIT :limit OFFSET :offset";
$stmt = db()->prepare($sql);
foreach ($params as $k => $v) {
$stmt->bindValue($k, $v);
}
$stmt->bindValue(':limit', $perPage, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
$rows = $stmt->fetchAll();
$buildUrl = static function (array $ov = []) use ($status, $keyword): string {
$p = array_filter([
'status' => $ov['status'] ?? $status,
'q' => $ov['q'] ?? $keyword,
'page' => $ov['page'] ?? null,
], static fn ($v) => $v !== null && $v !== '');
return url('admin/permohonan.php' . ($p ? '?' . http_build_query($p) : ''));
};
$pageTitle = 'Permohonan Masuk — CMS PPID';
$activeMenu = 'permohonan';
require __DIR__ . '/partials/head.php';
?>
<div class="flex flex-col md:flex-row md:items-center justify-between mb-6 gap-4">
<div>
<h2 class="text-2xl font-bold text-slate-900">Permohonan Masuk</h2>
<p class="text-sm text-slate-500 mt-1">Kelola & proses permohonan informasi publik. Total <strong><?= $total ?></strong> permohonan.</p>
</div>
<form method="get" class="flex items-center bg-white px-4 py-2 rounded-lg border border-slate-200 focus-within:border-mateng-blue transition-colors w-full md:w-72">
<i class="fas fa-search text-slate-400 mr-2"></i>
<?php if ($status): ?><input type="hidden" name="status" value="<?= e($status) ?>"><?php endif; ?>
<input type="text" name="q" value="<?= e($keyword) ?>" placeholder="Cari nama / resi / email..." class="bg-transparent outline-none text-sm w-full text-slate-700">
</form>
</div>
<!-- Filter status -->
<div class="flex flex-wrap gap-2 mb-6">
<?php
$tabs = ['' => 'Semua', 'verifikasi' => 'Verifikasi', 'diproses' => 'Diproses', 'selesai' => 'Selesai', 'ditolak' => 'Ditolak'];
foreach ($tabs as $key => $label): ?>
<a href="<?= e($buildUrl(['status' => $key, 'page' => null])) ?>" class="px-4 py-2 rounded-lg text-sm font-medium border transition-colors <?= $status === $key ? 'bg-mateng-green text-white border-mateng-green' : 'bg-white text-slate-600 border-slate-200 hover:border-mateng-green' ?>">
<?= e($label) ?>
</a>
<?php endforeach; ?>
</div>
<div class="bg-white border border-slate-100 rounded-xl shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-slate-50 text-slate-500 text-xs uppercase tracking-wider">
<th class="px-6 py-4 font-semibold">No. Resi</th>
<th class="px-6 py-4 font-semibold">Nama Pemohon</th>
<th class="px-6 py-4 font-semibold">Rincian / Kategori</th>
<th class="px-6 py-4 font-semibold">Tanggal</th>
<th class="px-6 py-4 font-semibold">Status</th>
<th class="px-6 py-4 font-semibold text-center">Aksi</th>
</tr>
</thead>
<tbody class="text-sm divide-y divide-slate-100 text-slate-700">
<?php if (empty($rows)): ?>
<tr><td colspan="6" class="px-6 py-12 text-center text-slate-400"><i class="fas fa-inbox text-3xl mb-2 block"></i>Tidak ada permohonan ditemukan.</td></tr>
<?php else: foreach ($rows as $p): ?>
<tr class="hover:bg-slate-50/50 transition-colors">
<td class="px-6 py-4 font-medium text-slate-900 whitespace-nowrap"><?= e($p['no_resi']) ?></td>
<td class="px-6 py-4">
<div class="font-medium text-slate-800"><?= e($p['nama']) ?></div>
<div class="text-xs text-slate-400"><?= e($p['email']) ?></div>
</td>
<td class="px-6 py-4 max-w-xs">
<?php if ($p['kategori_nama']): ?><span class="text-xs font-semibold text-mateng-blue"><?= e($p['kategori_nama']) ?></span><br><?php endif; ?>
<span class="text-slate-500"><?= e(excerpt($p['rincian_informasi'], 50)) ?></span>
</td>
<td class="px-6 py-4 whitespace-nowrap"><?= e(tanggal_id($p['created_at'])) ?></td>
<td class="px-6 py-4"><?= badge_status($p['status']) ?></td>
<td class="px-6 py-4 text-center">
<a href="<?= e(url('admin/permohonan-detail.php?id=' . $p['id'])) ?>" class="inline-flex p-2 text-mateng-blue hover:bg-blue-50 rounded-lg transition-colors" title="Proses">
<i class="fas fa-eye"></i>
</a>
</td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>
</div>
</div>
<?php if ($totalPages > 1): ?>
<div class="flex justify-center items-center gap-2 mt-6">
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
<a href="<?= e($buildUrl(['page' => $i])) ?>" class="px-4 py-2 rounded-lg border text-sm font-medium <?= $i === $page ? 'bg-mateng-green text-white border-mateng-green' : 'bg-white text-slate-600 border-slate-200 hover:border-mateng-green' ?>"><?= $i ?></a>
<?php endfor; ?>
</div>
<?php endif; ?>
<?php require __DIR__ . '/partials/foot.php'; ?>