Files
UAS_WEBGIS_IhyaUlumuddinHar…/project_final/admin/log.php
T
2026-06-13 11:24:58 +07:00

60 lines
2.7 KiB
PHP

<?php
require_once __DIR__ . '/../config/db.php';
require_once __DIR__ . '/../config/auth_check.php';
requireAnyRole(['operator']);
$pdo = Database::getConnection();
$rows = $pdo->query(
"SELECT id, username, aksi, tabel_target, record_id, keterangan, ip_address, created_at
FROM activity_log ORDER BY id DESC LIMIT 300"
)->fetchAll();
$pageTitle = 'Log Aktivitas';
$activeNav = 'log';
require_once __DIR__ . '/partials/header.php';
function aksiBadge(string $a): string {
return match ($a) {
'login' => '<span class="badge badge-info">login</span>',
'logout' => '<span class="badge" style="background:#F3F4F6;color:#6B7280;">logout</span>',
'create' => '<span class="badge badge-success">create</span>',
'update' => '<span class="badge badge-warning">update</span>',
'delete' => '<span class="badge badge-danger">delete</span>',
default => '<span class="badge">' . htmlspecialchars($a) . '</span>',
};
}
?>
<div class="page-header">
<div class="breadcrumb"><span>Operator</span><span class="sep">/</span><span>Log Aktivitas</span></div>
<h1>📋 Log Aktivitas Sistem</h1>
<p>Audit trail aktivitas pengguna terautentikasi (KF-04). Menampilkan 300 entri terbaru.</p>
</div>
<div class="page-toolbar">
<div class="search-box">
<i class="fas fa-search search-icon"></i>
<input type="text" id="searchInput" placeholder="Cari log..." oninput="filterTable('searchInput','logTable')">
</div>
</div>
<div class="table-wrap">
<table class="data-table" id="logTable">
<thead><tr>
<th>Waktu</th><th>User</th><th>Aksi</th><th>Tabel</th><th>Record</th><th>Keterangan</th><th>IP</th>
</tr></thead>
<tbody>
<?php foreach ($rows as $r): ?>
<tr>
<td style="font-size:0.8rem;color:var(--text-muted);white-space:nowrap;"><?= date('d M Y H:i:s', strtotime($r['created_at'])) ?></td>
<td><strong><?= htmlspecialchars($r['username'] ?: '-') ?></strong></td>
<td><?= aksiBadge($r['aksi']) ?></td>
<td style="font-size:0.82rem;"><?= htmlspecialchars($r['tabel_target'] ?: '-') ?></td>
<td style="font-size:0.82rem;color:var(--text-muted);"><?= $r['record_id'] !== null ? (int)$r['record_id'] : '-' ?></td>
<td style="font-size:0.85rem;"><?= htmlspecialchars($r['keterangan'] ?: '-') ?></td>
<td style="font-size:0.78rem;color:var(--text-muted);"><?= htmlspecialchars($r['ip_address'] ?: '-') ?></td>
</tr>
<?php endforeach; ?>
<?php if (!$rows): ?><tr><td colspan="7" style="text-align:center;padding:40px;color:var(--text-muted);">Belum ada aktivitas tercatat.</td></tr><?php endif; ?>
</tbody>
</table>
</div>
<?php require_once __DIR__ . '/partials/footer.php'; ?>