%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
/**
* Halaman PPID Pembantu — informasi publik per Unit Perangkat Daerah (UPD).
*
* Query string:
* ?upd=slug Filter berdasarkan UPD (kosong = Semua UPD).
* ?q=kata Kata kunci pencarian.
* ?page=n Paginasi.
*/
require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/includes/queries.php';
$updSlug = get_param('upd');
$keyword = get_param('q');
$page = max(1, (int) get_param('page', '1'));
$perPage = 9;
$offset = ($page - 1) * $perPage;
$updList = get_upd_list();
$jumlahUpd = count_dokumen_per_upd();
$activeUpd = $updSlug ? get_upd_by_slug($updSlug) : null;
$kategoriSlug = get_param('kategori');
$kategoriList = get_kategori('kip');
$activeKat = $kategoriSlug ? get_kategori_by_slug($kategoriSlug) : null;
// Hanya dokumen yang terikat UPD (PPID Pembantu).
$where = ["d.status = 'publish'", 'd.upd_id IS NOT NULL'];
$params = [];
if ($activeUpd) {
$where[] = 'd.upd_id = :upd';
$params[':upd'] = $activeUpd['id'];
}
if ($activeKat) {
$where[] = 'd.kategori_id = :kat';
$params[':kat'] = $activeKat['id'];
}
if ($keyword !== '') {
$where[] = '(d.judul LIKE :kw1 OR d.deskripsi LIKE :kw2 OR d.unit_kerja LIKE :kw3)';
$like = '%' . $keyword . '%';
$params[':kw1'] = $like; $params[':kw2'] = $like; $params[':kw3'] = $like;
}
$whereSql = implode(' AND ', $where);
$countStmt = db()->prepare("SELECT COUNT(*) FROM dokumen_informasi d WHERE $whereSql");
$countStmt->execute($params);
$total = (int) $countStmt->fetchColumn();
$totalPages = max(1, (int) ceil($total / $perPage));
$sql = "SELECT d.*, k.nama AS kategori_nama, k.warna, k.icon,
u.nama AS upd_nama, u.singkatan AS upd_singkatan, u.slug AS upd_slug
FROM dokumen_informasi d
JOIN kategori_informasi k ON k.id = d.kategori_id
JOIN upd u ON u.id = d.upd_id
WHERE $whereSql
ORDER BY d.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();
$dokumen = $stmt->fetchAll();
$buildUrl = static function (array $o = []) use ($updSlug, $keyword, $kategoriSlug): string {
$p = array_filter([
'upd' => $o['upd'] ?? $updSlug,
'kategori' => $o['kategori'] ?? $kategoriSlug,
'q' => $o['q'] ?? $keyword,
'page' => $o['page'] ?? null,
], static fn ($v) => $v !== null && $v !== '');
return url('ppid-pembantu.php' . ($p ? '?' . http_build_query($p) : ''));
};
$pageTitle = 'PPID Pembantu' . ($activeUpd ? ' — ' . $activeUpd['nama'] : '') . ' — ' . APP_NAME_SHORT;
$activeNav = 'layanan';
require __DIR__ . '/partials/head.php';
require __DIR__ . '/partials/navbar.php';
?>
<section class="relative overflow-hidden bg-gradient-to-br from-mateng-blue to-mateng-green text-white py-14">
<?php require __DIR__ . '/partials/sekda-header.php'; ?>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<nav class="text-sm text-sky-100 mb-3">
<a href="<?= e(url('index.php')) ?>" class="hover:underline">Beranda</a><span class="mx-2">/</span>
<a href="<?= e(url('direktori-pembantu.php')) ?>" class="hover:underline">PPID Pembantu</a>
<?php if ($activeUpd): ?><span class="mx-2">/</span><span><?= e($activeUpd['singkatan'] ?: $activeUpd['nama']) ?></span><?php endif; ?>
</nav>
<h1 class="text-3xl md:text-4xl font-extrabold mb-2"><?= $activeUpd ? e($activeUpd['nama']) : 'PPID Pembantu' ?></h1>
<p class="text-sky-50 max-w-2xl"><?= $activeUpd ? e($activeUpd['deskripsi'] ?: 'Informasi publik yang dikuasai ' . $activeUpd['nama'] . '.') : 'Telusuri informasi publik berdasarkan Unit Perangkat Daerah (UPD) di lingkungan Pemerintah Kabupaten Mamuju Tengah.' ?></p>
</div>
</section>
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 w-full">
<?php if ($activeUpd): ?>
<!-- Panel kontak UPD terpilih -->
<div class="bg-white border border-slate-100 rounded-2xl shadow-sm p-6 mb-8 flex flex-col lg:flex-row lg:items-center gap-5">
<div class="w-14 h-14 rounded-2xl bg-gradient-to-br from-mateng-blue to-mateng-green text-white flex items-center justify-center font-extrabold text-lg shadow-md shrink-0"><?= e(strtoupper(mb_substr($activeUpd['singkatan'] ?: $activeUpd['nama'], 0, 2))) ?></div>
<div class="flex-grow">
<h2 class="font-bold text-slate-900"><?= e($activeUpd['nama']) ?></h2>
<div class="flex flex-wrap gap-x-5 gap-y-1.5 mt-2 text-sm text-slate-500">
<?php if (!empty($activeUpd['penanggung_jawab'])): ?><span><i class="fas fa-user-tie text-slate-400 mr-1.5"></i><?= e($activeUpd['penanggung_jawab']) ?></span><?php endif; ?>
<?php if (!empty($activeUpd['telepon'])): ?><span><i class="fas fa-phone text-slate-400 mr-1.5"></i><?= e($activeUpd['telepon']) ?></span><?php endif; ?>
<?php if (!empty($activeUpd['email'])): ?><a href="mailto:<?= e($activeUpd['email']) ?>" class="hover:text-mateng-blue"><i class="fas fa-envelope text-slate-400 mr-1.5"></i><?= e($activeUpd['email']) ?></a><?php endif; ?>
</div>
<?php if (!empty($activeUpd['alamat'])): ?><p class="text-sm text-slate-400 mt-1.5"><i class="fas fa-location-dot mr-1.5"></i><?= e($activeUpd['alamat']) ?></p><?php endif; ?>
</div>
<a href="<?= e(url('direktori-pembantu.php')) ?>" class="shrink-0 inline-flex items-center gap-2 text-sm font-semibold text-mateng-blue hover:underline"><i class="fas fa-arrow-left"></i> Direktori PPID Pembantu</a>
</div>
<?php endif; ?>
<!-- Kategori informasi + pencarian (sejajar) -->
<div class="flex flex-col lg:flex-row lg:items-center gap-4 mb-5">
<div class="flex flex-wrap gap-2">
<a href="<?= e($buildUrl(['kategori' => '', 'page' => null])) ?>" class="px-4 py-2 rounded-lg text-sm font-medium border transition-colors <?= !$activeKat ? 'bg-mateng-blue text-white border-mateng-blue' : 'bg-white text-slate-600 border-slate-200 hover:border-mateng-blue' ?>">Semua</a>
<?php foreach ($kategoriList as $kat): ?>
<a href="<?= e($buildUrl(['kategori' => $kat['slug'], 'page' => null])) ?>" class="px-4 py-2 rounded-lg text-sm font-medium border transition-colors <?= ($activeKat && $activeKat['id'] == $kat['id']) ? 'bg-mateng-blue text-white border-mateng-blue' : 'bg-white text-slate-600 border-slate-200 hover:border-mateng-blue' ?>"><?= e($kat['nama']) ?></a>
<?php endforeach; ?>
</div>
<form method="get" class="lg:ml-auto flex items-center bg-white border border-slate-200 rounded-lg px-3 py-2 focus-within:border-mateng-blue transition-colors w-full lg:w-80 shrink-0">
<?php if ($kategoriSlug): ?><input type="hidden" name="kategori" value="<?= e($kategoriSlug) ?>"><?php endif; ?>
<?php if ($activeUpd): ?><input type="hidden" name="upd" value="<?= e($updSlug) ?>"><?php endif; ?>
<i class="fas fa-search text-slate-400 mr-2"></i>
<input type="text" name="q" value="<?= e($keyword) ?>" placeholder="Cari dokumen..." class="bg-transparent outline-none text-sm w-full text-slate-700">
</form>
</div>
<?php if (!$activeUpd): ?>
<!-- Saring Unit Perangkat Daerah (hanya saat menelusuri semua unit) -->
<div class="mb-2">
<div class="flex items-center gap-2 mb-3 text-sm font-semibold text-slate-600"><i class="fas fa-filter text-mateng-blue"></i> Saring Unit Perangkat Daerah</div>
<form method="get" class="flex flex-col md:flex-row md:items-center gap-3">
<?php if ($kategoriSlug): ?><input type="hidden" name="kategori" value="<?= e($kategoriSlug) ?>"><?php endif; ?>
<?php if ($keyword !== ''): ?><input type="hidden" name="q" value="<?= e($keyword) ?>"><?php endif; ?>
<div class="relative w-full md:w-96">
<i class="fas fa-sitemap absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400"></i>
<select name="upd" onchange="this.form.submit()" class="w-full appearance-none bg-white border border-slate-200 rounded-lg pl-10 pr-10 py-2.5 text-sm font-medium text-slate-700 outline-none focus:border-mateng-blue focus:ring-4 focus:ring-mateng-blue/10 cursor-pointer">
<option value="">Semua UPD — seluruh unit</option>
<?php foreach ($updList as $u):
$cnt = $jumlahUpd[(int) $u['id']] ?? 0; ?>
<option value="<?= e($u['slug']) ?>" <?= $updSlug === $u['slug'] ? 'selected' : '' ?>><?= e($u['nama']) ?><?= $u['singkatan'] ? ' (' . e($u['singkatan']) . ')' : '' ?> — <?= $cnt ?> dok</option>
<?php endforeach; ?>
</select>
<i class="fas fa-chevron-down absolute right-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs pointer-events-none"></i>
</div>
<?php if ($keyword !== '' || $kategoriSlug): ?>
<a href="<?= e(url('ppid-pembantu.php')) ?>" class="text-sm text-slate-500 hover:text-mateng-blue inline-flex items-center gap-1.5 shrink-0"><i class="fas fa-rotate-left"></i> Reset</a>
<?php endif; ?>
</form>
</div>
<?php endif; ?>
<?php if (empty($dokumen)): ?>
<div class="text-center py-20 bg-white rounded-2xl border border-slate-100">
<i class="fas fa-sitemap text-5xl text-slate-300 mb-4"></i>
<p class="text-slate-500 font-medium">Belum ada dokumen pada Unit Perangkat Daerah ini.</p>
</div>
<?php else:
$resultText = '<strong>' . (int) $total . '</strong> dokumen'
. ($activeUpd ? ' dari ' . e($activeUpd['singkatan'] ?: $activeUpd['nama']) : ' dari seluruh UPD')
. ($activeKat ? ' · ' . e($activeKat['nama']) : '')
. ($keyword !== '' ? ' untuk "<strong>' . e($keyword) . '</strong>"' : '');
$accent = 'blue';
require __DIR__ . '/partials/dokumen-koleksi.php';
?>
<?php if ($totalPages > 1): ?>
<div class="flex justify-center items-center gap-2 mt-10">
<?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-blue text-white border-mateng-blue' : 'bg-white text-slate-600 border-slate-200 hover:border-mateng-blue' ?>"><?= $i ?></a>
<?php endfor; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</main>
<?php require __DIR__ . '/partials/footer.php'; ?>