68 lines
2.9 KiB
PHP
68 lines
2.9 KiB
PHP
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h3 mb-0 text-gray-800">ระบบติดตาม (Audit Log)</h1>
|
|
<a href="<?= BASE_URL ?>/settings" class="btn btn-outline-secondary shadow-sm"><i class="fa-solid fa-arrow-left me-1"></i> กลับไปตั้งค่า</a>
|
|
</div>
|
|
|
|
<div class="card shadow border-0 rounded-4 mb-4">
|
|
<div class="card-header bg-white py-3">
|
|
<h6 class="m-0 font-weight-bold text-primary"><i class="fa-solid fa-list-check me-2"></i>ประวัติการใช้งานล่าสุด</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-sm table-striped table-hover align-middle" id="auditTable">
|
|
<thead class="table-dark">
|
|
<tr>
|
|
<th>วัน-เวลา</th>
|
|
<th>User ID</th>
|
|
<th>Action</th>
|
|
<th>Entity Type</th>
|
|
<th>Entity ID</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($logs)): ?>
|
|
<tr>
|
|
<td colspan="5" class="text-center py-3">ไม่มีข้อมูลการกระทำ</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($logs as $log): ?>
|
|
<tr>
|
|
<td><?= date('d/m/Y H:i:s', strtotime($log['created_at'])) ?></td>
|
|
<td><?= $log['user_id'] ?></td>
|
|
<td>
|
|
<?php
|
|
$color = 'secondary';
|
|
if($log['action'] == 'CREATE') $color = 'success';
|
|
if($log['action'] == 'APPROVED') $color = 'primary';
|
|
if($log['action'] == 'REJECTED') $color = 'danger';
|
|
?>
|
|
<span class="badge bg-<?= $color ?>"><?= $log['action'] ?></span>
|
|
</td>
|
|
<td><code><?= $log['entity_type'] ?></code></td>
|
|
<td><?= $log['entity_id'] ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$extraScripts = '
|
|
<script>
|
|
$(document).ready(function() {
|
|
if($("#auditTable tbody tr td").length > 1) {
|
|
$("#auditTable").DataTable({
|
|
"language": {
|
|
"url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/th.json"
|
|
},
|
|
"order": [[ 0, "desc" ]]
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
';
|
|
?>
|