asd
This commit is contained in:
commit
3e4a056b14
67 files changed
+13926
No files matched your search
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
defined('SERUBI_ADMIN') || exit;
|
||||
$perPage = 30;
|
||||
$page = max(1, (int)($_GET['p'] ?? 1));
|
||||
$total = (int)db()->query('SELECT COUNT(*) FROM audit_log')->fetchColumn();
|
||||
$pages = max(1, (int)ceil($total / $perPage));
|
||||
$page = min($page, $pages);
|
||||
$st = db()->prepare('SELECT * FROM audit_log ORDER BY id DESC LIMIT ? OFFSET ?');
|
||||
$st->bindValue(1, $perPage, PDO::PARAM_INT);
|
||||
$st->bindValue(2, ($page - 1) * $perPage, PDO::PARAM_INT);
|
||||
$st->execute();
|
||||
$logs = $st->fetchAll();
|
||||
|
||||
$fmtVal = function ($v, string $unit): string {
|
||||
return $unit === 'pct' ? fmt_pct((float)$v) . '%' : ($unit === 'idr' ? 'Rp' . fmt_idr((float)$v) : (string)$v);
|
||||
};
|
||||
/** One line per tier: "≤ Rp100.000.000: 0,75%". */
|
||||
$fmtTiers = function (array $tiers): string {
|
||||
return implode(' · ', array_map(fn($t) => ($t['max'] === null ? 'di atas' : '≤ Rp' . fmt_idr((float)$t['max'])) . ': ' . fmt_pct((float)$t['rate']) . '%', $tiers));
|
||||
};
|
||||
?>
|
||||
<section class="panel">
|
||||
<?php if (!$logs): ?>
|
||||
<p class="empty">Belum ada aktivitas. Setiap perubahan parameter, login, dan pengelolaan admin akan tercatat di sini.</p>
|
||||
<?php else: ?>
|
||||
<ol class="log-list">
|
||||
<?php foreach ($logs as $log): $ch = $log['changes'] ? json_decode($log['changes'], true) : null; ?>
|
||||
<li class="log">
|
||||
<div class="log-head">
|
||||
<span class="log-what"><?= e($log['summary']) ?></span>
|
||||
<span class="log-meta"><?= e(fmt_datetime($log['created_at'])) ?> · <?= $log['username'] ? '@' . e($log['username']) : 'sistem' ?></span>
|
||||
</div>
|
||||
<?php if ($ch && $log['action'] === 'param.settings'): ?>
|
||||
<ul class="log-diff">
|
||||
<?php foreach ($ch as $d): ?>
|
||||
<li><?= e($d['label']) ?>: <del><?= e($fmtVal($d['old'], $d['unit'])) ?></del> → <ins><?= e($fmtVal($d['new'], $d['unit'])) ?></ins></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php elseif ($ch && $log['action'] === 'param.produk'): ?>
|
||||
<ul class="log-diff">
|
||||
<?php foreach ($ch as $prod => $d): ?>
|
||||
<li><b><?= e(SERUBI_PRODUCTS[$prod] ?? $prod) ?></b><br><del><?= e($fmtTiers($d['old'])) ?></del><br><ins><?= e($fmtTiers($d['new'])) ?></ins></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php elseif ($ch && $log['action'] === 'param.deposito'): ?>
|
||||
<ul class="log-diff">
|
||||
<?php foreach ($ch['new'] as $tenor => $tiers): if (json_encode($tiers) === json_encode($ch['old'][$tenor] ?? null)) continue; ?>
|
||||
<li><b><?= (int)$tenor ?> bulan</b><br><del><?= e($fmtTiers($ch['old'][$tenor] ?? [])) ?></del><br><ins><?= e($fmtTiers($tiers)) ?></ins></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php elseif ($ch && $log['action'] === 'param.cashback'): ?>
|
||||
<ul class="log-diff">
|
||||
<?php foreach (['old' => 'del', 'new' => 'ins'] as $k => $tag): ?>
|
||||
<li><<?= $tag ?>>Tenor <?= e(implode(', ', $ch[$k]['tenors'])) ?> bln · <?= e(implode(' · ', array_map(fn($t) => '≥ Rp' . fmt_idr((float)$t['min']) . ': ' . fmt_pct((float)$t['nasabah']) . '%', $ch[$k]['tiers']))) ?></<?= $tag ?>></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php if ($pages > 1): ?>
|
||||
<nav class="pager" aria-label="Halaman riwayat">
|
||||
<?php if ($page > 1): ?><a class="btn btn-ghost btn-sm" href="?tab=riwayat&p=<?= $page - 1 ?>">Lebih baru</a><?php endif; ?>
|
||||
<span>Halaman <?= $page ?> dari <?= $pages ?></span>
|
||||
<?php if ($page < $pages): ?><a class="btn btn-ghost btn-sm" href="?tab=riwayat&p=<?= $page + 1 ?>">Lebih lama</a><?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
Reference in new issue
Block a user