File manager - Edit - /home/webapp69.cm.in.th/u69319090028/Shop/views/admin/audit_log/index.php
Back
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-2 mb-3"> <div> <h4 class="fw-bold mb-1 text-dark">บันทึกการกระทำของผู้ดูแลระบบ (Admin Audit Trail)</h4> <p class="text-muted small mb-0">ระบบบันทึกประวัติการกระทำ การระงับสิทธิ์ การซ่อนสินค้า และการแก้ไขระบบที่ไม่สามารถลบหรือแก้ไขได้</p> </div> <div> <a href="<?= url('/admin/admins') ?>" class="btn btn-outline-secondary btn-sm py-1 px-3"> <i class="bi bi-person-badge me-1"></i>จัดการ Admin </a> </div> </div> <!-- ── Filter Bar ──────────────────────────────────────── --> <div class="admin-filter-bar mb-3"> <form method="GET" class="row g-2 align-items-end"> <div class="col-md-3"> <label class="form-label small fw-semibold text-muted mb-1">การกระทำ (Action)</label> <input type="text" name="action" value="<?= e($filters['action'] ?? '') ?>" class="form-control form-control-sm" placeholder="e.g. user.suspend, product.hide"> </div> <div class="col-6 col-md-2"> <label class="form-label small fw-semibold text-muted mb-1">เป้าหมาย (Target Type)</label> <select name="target_type" class="form-select form-select-sm"> <option value="">ทุกประเภท</option> <option value="user" <?= ($filters['target_type'] ?? '') === 'user' ? 'selected' : '' ?>>User</option> <option value="store" <?= ($filters['target_type'] ?? '') === 'store' ? 'selected' : '' ?>>Store</option> <option value="product" <?= ($filters['target_type'] ?? '') === 'product' ? 'selected' : '' ?>>Product</option> <option value="category" <?= ($filters['target_type'] ?? '') === 'category' ? 'selected' : '' ?>>Category</option> <option value="order" <?= ($filters['target_type'] ?? '') === 'order' ? 'selected' : '' ?>>Order</option> <option value="report" <?= ($filters['target_type'] ?? '') === 'report' ? 'selected' : '' ?>>Report</option> <option value="setting" <?= ($filters['target_type'] ?? '') === 'setting' ? 'selected' : '' ?>>Setting</option> <option value="admin" <?= ($filters['target_type'] ?? '') === 'admin' ? 'selected' : '' ?>>Admin</option> </select> </div> <div class="col-6 col-md-2"> <label class="form-label small fw-semibold text-muted mb-1">Target ID</label> <input type="number" name="target_id" value="<?= e($filters['target_id'] ?? '') ?>" class="form-control form-control-sm" placeholder="ID..."> </div> <div class="col-6 col-md-3 d-flex gap-2"> <button type="submit" class="btn btn-primary btn-sm w-100"><i class="bi bi-funnel me-1"></i>ค้นหา</button> <?php if (!empty($filters['action']) || !empty($filters['target_type']) || !empty($filters['target_id'])): ?> <a href="<?= url('/admin/audit-log') ?>" class="btn btn-outline-secondary btn-sm" title="ล้างการกรอง"><i class="bi bi-x-lg"></i></a> <?php endif; ?> </div> </form> </div> <!-- ── Audit Log Table ─────────────────────────────────── --> <div class="admin-table-container"> <div class="admin-table-header"> <div class="d-flex align-items-center gap-2"> <i class="bi bi-journal-text text-primary"></i> <span class="fw-bold text-dark" style="font-size: 0.9rem;">บันทึกเหตุการณ์ Audit Trail</span> <span class="badge bg-light text-muted border ms-1"><?= number_format($total ?? 0) ?> รายการ</span> </div> </div> <div class="table-responsive"> <table class="admin-table"> <thead> <tr> <th width="70">ID</th> <th>Admin ผู้กระทำ</th> <th>การกระทำ (Action)</th> <th>เป้าหมาย (Target)</th> <th>รายละเอียด / ข้อมูลบริบท (Details)</th> <th>IP Address</th> <th>วันและเวลา</th> </tr> </thead> <tbody> <?php if (empty($logs)): ?> <tr> <td colspan="7" class="text-center text-muted py-4">ไม่พบบันทึก Audit Log ในระบบ</td> </tr> <?php else: foreach ($logs as $l): $details = []; if (!empty($l['details'])) { $decoded = json_decode($l['details'], true); $details = is_array($decoded) ? $decoded : ['raw' => $l['details']]; } ?> <tr> <td class="font-monospace small text-muted">#<?= (int)$l['id'] ?></td> <td> <div class="fw-semibold text-dark small"><?= e($l['admin_first_name'] ?? '') ?></div> <div class="text-muted small font-monospace">@<?= e($l['admin_username'] ?? 'System') ?></div> </td> <td> <span class="badge bg-light border text-dark font-monospace" style="font-size: 0.72rem;"> <?= e($l['action']) ?> </span> </td> <td> <?php if (!empty($l['target_type'])): ?> <span class="small text-muted font-monospace"> <?= e($l['target_type']) ?> #<?= (int)$l['target_id'] ?> </span> <?php else: ?> <span class="text-muted small">—</span> <?php endif; ?> </td> <td style="max-width: 320px;"> <?php if (!empty($details)): ?> <details class="small"> <summary class="text-primary cursor-pointer" style="font-size: 0.75rem;"> <?= count($details) ?> ข้อมูลที่บันทึก (ดู JSON) </summary> <pre class="bg-light border rounded-2 p-2 mt-1 mb-0 font-monospace text-muted" style="font-size: 0.7rem; max-height: 120px; overflow: auto;"><?= e(json_encode($details, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)) ?></pre> </details> <?php else: ?> <span class="text-muted small">—</span> <?php endif; ?> </td> <td class="font-monospace small text-muted"><?= e($l['ip_address'] ?? '127.0.0.1') ?></td> <td class="text-muted small"><?= date('d/m/Y H:i:s', strtotime($l['created_at'])) ?></td> </tr> <?php endforeach; endif; ?> </tbody> </table> </div> <?php if (($total_pages ?? 1) > 1): ?> <div class="p-3 border-top d-flex justify-content-center"> <nav><ul class="pagination pagination-sm mb-0"> <?php for ($i = 1; $i <= $total_pages; $i++): ?> <li class="page-item <?= $i === $page ? 'active' : '' ?>"><a class="page-link" href="?<?= http_build_query(array_merge($filters, ['page' => $i])) ?>"><?= $i ?></a></li> <?php endfor; ?> </ul></nav> </div> <?php endif; ?> </div>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings