%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
require_once dirname(__DIR__) . '/config/config.php';
require_once dirname(__DIR__) . '/includes/auth.php';
require_once dirname(__DIR__) . '/includes/queries.php';
require_central();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
csrf_verify();
$id = (int) post_param('id');
$action = post_param('action');
if ($id > 0) {
if ($action === 'dibaca') {
db()->prepare('UPDATE survey_kepuasan SET is_dibaca = 1 WHERE id = ?')->execute([$id]);
set_flash('success', 'Survei ditandai sudah dibaca.');
} elseif ($action === 'baru') {
db()->prepare('UPDATE survey_kepuasan SET is_dibaca = 0 WHERE id = ?')->execute([$id]);
set_flash('success', 'Survei ditandai belum dibaca.');
} elseif ($action === 'publish') {
db()->prepare('UPDATE survey_kepuasan SET is_published = 1, is_dibaca = 1 WHERE id = ?')->execute([$id]);
set_flash('success', 'Testimoni survei dipublikasikan ke beranda.');
} elseif ($action === 'unpublish') {
db()->prepare('UPDATE survey_kepuasan SET is_published = 0 WHERE id = ?')->execute([$id]);
set_flash('success', 'Publikasi testimoni survei ditarik.');
} elseif ($action === 'hapus') {
db()->prepare('DELETE FROM survey_kepuasan WHERE id = ?')->execute([$id]);
set_flash('success', 'Survei berhasil dihapus.');
}
}
redirect('admin/survey.php' . (get_param('f') ? '?f=' . get_param('f') : ''));
}
// Filter.
$f = get_param('f');
$where = '';
$params = [];
if ($f === 'baru') {
$where = 'WHERE is_dibaca = 0';
} elseif ($f === 'dibaca') {
$where = 'WHERE is_dibaca = 1';
}
$stmt = db()->prepare("SELECT * FROM survey_kepuasan $where ORDER BY created_at DESC");
$stmt->execute($params);
$rows = $stmt->fetchAll();
// Ringkasan.
$agg = db()->query('SELECT COUNT(*) total, COALESCE(ROUND(AVG(rating),1),0) avg_rating, SUM(is_dibaca = 0) belum, SUM(is_published = 1) tampil FROM survey_kepuasan')->fetch();
$pageTitle = 'Survei Kepuasan — CMS PPID';
$activeMenu = 'survey';
require __DIR__ . '/partials/head.php';
?>
<div class="mb-6">
<h2 class="text-2xl font-bold text-slate-900">Survei Kepuasan Pengunjung</h2>
<p class="text-sm text-slate-500 mt-1">Masukan & rating kepuasan dari pengunjung situs (berbeda dari penilaian permohonan).</p>
</div>
<!-- Ringkasan -->
<div class="grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-5">
<p class="text-xs font-semibold text-slate-500 uppercase tracking-wide">Total Responden</p>
<p class="text-3xl font-extrabold text-slate-900 mt-1"><?= (int) $agg['total'] ?></p>
</div>
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-5">
<p class="text-xs font-semibold text-slate-500 uppercase tracking-wide">Rata-rata Rating</p>
<div class="flex items-center gap-2 mt-1">
<span class="text-3xl font-extrabold text-slate-900"><?= e((string) $agg['avg_rating']) ?></span>
<?= render_stars((float) $agg['avg_rating'], 'text-base') ?>
</div>
</div>
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-5">
<p class="text-xs font-semibold text-slate-500 uppercase tracking-wide">Belum Dibaca</p>
<p class="text-3xl font-extrabold text-mateng-gold mt-1"><?= (int) $agg['belum'] ?></p>
</div>
<div class="bg-white rounded-xl border border-slate-100 shadow-sm p-5">
<p class="text-xs font-semibold text-slate-500 uppercase tracking-wide">Tampil di Beranda</p>
<p class="text-3xl font-extrabold text-mateng-green mt-1"><?= (int) $agg['tampil'] ?></p>
</div>
</div>
<div class="flex flex-wrap gap-2 mb-6">
<?php foreach (['' => 'Semua', 'baru' => 'Belum Dibaca', 'dibaca' => 'Sudah Dibaca'] as $key => $label): ?>
<a href="<?= e(url('admin/survey.php' . ($key ? '?f=' . $key : ''))) ?>" class="px-4 py-2 rounded-lg text-sm font-medium border transition-colors <?= $f === $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>
<?php if (empty($rows)): ?>
<div class="text-center py-16 bg-white rounded-xl border border-slate-100">
<i class="fas fa-star-half-stroke text-4xl text-slate-300 mb-3"></i>
<p class="text-slate-500 font-medium">Belum ada survei pada kategori ini.</p>
</div>
<?php else: ?>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-5">
<?php foreach ($rows as $s): ?>
<div class="bg-white border <?= $s['is_dibaca'] ? 'border-slate-100' : 'border-mateng-green/40' ?> rounded-xl shadow-sm p-5 flex flex-col">
<div class="flex items-center justify-between gap-2 mb-3">
<?= render_stars((int) $s['rating'], 'text-lg') ?>
<span class="flex items-center gap-2">
<?php if ($s['is_published']): ?>
<span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-semibold bg-green-50 text-mateng-green border border-green-200"><i class="fas fa-circle-check"></i> Tampil</span>
<?php endif; ?>
<?php if (!$s['is_dibaca']): ?>
<span class="inline-flex items-center gap-1 text-xs font-semibold text-mateng-green"><i class="fas fa-circle text-[8px]"></i> Baru</span>
<?php else: ?>
<span class="text-xs text-slate-400"><i class="fas fa-check mr-1"></i>Dibaca</span>
<?php endif; ?>
</span>
</div>
<?php if ($s['testimoni']): ?>
<p class="text-slate-700 text-sm leading-relaxed mb-4 flex-grow whitespace-pre-line">"<?= e($s['testimoni']) ?>"</p>
<?php else: ?>
<p class="text-slate-400 text-sm italic mb-4 flex-grow">(tanpa testimoni)</p>
<?php endif; ?>
<div class="border-t border-slate-100 pt-3 space-y-1.5 text-xs text-slate-500">
<div class="flex flex-wrap items-center gap-x-3 gap-y-1">
<span class="font-semibold text-slate-700 text-sm"><?= e($s['nama']) ?></span>
<?php if ($s['usia']): ?><span><i class="fas fa-user-clock mr-1 text-slate-400"></i><?= (int) $s['usia'] ?> th</span><?php endif; ?>
<?php if ($s['gender']): ?><span><i class="fas fa-venus-mars mr-1 text-slate-400"></i><?= e($s['gender']) ?></span><?php endif; ?>
</div>
<?php if (!empty($s['kategori_pengunjung'])): ?>
<div class="flex flex-wrap items-center gap-1.5">
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-semibold border <?= $s['kategori_pengunjung'] === 'Kelompok Rentan' ? 'bg-amber-50 text-mateng-gold border-amber-200' : 'bg-slate-100 text-slate-600 border-slate-200' ?>">
<i class="fas fa-user-tag mr-1"></i><?= e($s['kategori_pengunjung']) ?>
</span>
<?php if (!empty($s['kelompok_rentan'])): ?>
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-semibold bg-blue-50 text-mateng-blue border border-blue-200"><i class="fas fa-hands-helping mr-1"></i><?= e($s['kelompok_rentan']) ?></span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($s['alamat']): ?><div><i class="fas fa-location-dot mr-1 text-slate-400"></i><?= e($s['alamat']) ?></div><?php endif; ?>
<div class="flex items-center justify-between">
<span>
<?php if ($s['no_wa']): ?>
<a href="https://wa.me/<?= e(preg_replace('/[^0-9]/', '', preg_replace('/^0/', '62', $s['no_wa']))) ?>" target="_blank" rel="noopener" class="text-mateng-green hover:underline"><i class="fab fa-whatsapp mr-1"></i><?= e($s['no_wa']) ?></a>
<?php endif; ?>
<span class="text-slate-400"><i class="far fa-clock mr-1 ml-1"></i><?= e(tanggal_id($s['created_at'], true)) ?></span>
</span>
<span class="flex items-center gap-1">
<?php if ($s['is_published']): ?>
<form method="post" class="inline">
<?= csrf_field() ?><input type="hidden" name="id" value="<?= (int) $s['id'] ?>"><input type="hidden" name="action" value="unpublish">
<button type="submit" class="p-2 text-slate-500 hover:bg-slate-100 hover:text-slate-700 rounded-lg transition-colors" title="Tarik dari beranda"><i class="fas fa-eye-slash"></i></button>
</form>
<?php else: ?>
<form method="post" class="inline">
<?= csrf_field() ?><input type="hidden" name="id" value="<?= (int) $s['id'] ?>"><input type="hidden" name="action" value="publish">
<button type="submit" class="p-2 text-mateng-green hover:bg-green-50 rounded-lg transition-colors" title="Publikasikan ke beranda"><i class="fas fa-bullhorn"></i></button>
</form>
<?php endif; ?>
<?php if (!$s['is_dibaca']): ?>
<form method="post" class="inline">
<?= csrf_field() ?><input type="hidden" name="id" value="<?= (int) $s['id'] ?>"><input type="hidden" name="action" value="dibaca">
<button type="submit" class="p-2 text-mateng-green hover:bg-green-50 rounded-lg transition-colors" title="Tandai dibaca"><i class="fas fa-check-double"></i></button>
</form>
<?php else: ?>
<form method="post" class="inline">
<?= csrf_field() ?><input type="hidden" name="id" value="<?= (int) $s['id'] ?>"><input type="hidden" name="action" value="baru">
<button type="submit" class="p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700 rounded-lg transition-colors" title="Tandai belum dibaca"><i class="fas fa-rotate-left"></i></button>
</form>
<?php endif; ?>
<form method="post" class="inline" onsubmit="return confirm('Hapus survei ini?');">
<?= csrf_field() ?><input type="hidden" name="id" value="<?= (int) $s['id'] ?>"><input type="hidden" name="action" value="hapus">
<button type="submit" class="p-2 text-red-500 hover:bg-red-50 rounded-lg transition-colors" title="Hapus"><i class="fas fa-trash"></i></button>
</form>
</span>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php require __DIR__ . '/partials/foot.php'; ?>