<?php $title='سجل الحركات'; include __DIR__ . '/../layout/header.php'; ?>
<div class="card">
  <form method="get" style="display:flex;gap:12px;flex-wrap:wrap;align-items:end">
    <input type="hidden" name="page" value="audit">
    <div><label class="label">الموديول</label><input class="input" name="module" value="<?= e($module) ?>" placeholder="مثال: invoices أو queue"></div>
    <button class="btn">تصفية</button>
  </form>
</div>
<div class="card">
  <table class="table">
    <thead><tr><th>#</th><th>المستخدم</th><th>الموديول</th><th>الإجراء</th><th>السجل</th><th>الوقت</th><th>البيانات</th></tr></thead>
    <tbody>
      <?php foreach($rows as $r): ?>
      <tr>
        <td><?= (int)$r['id'] ?></td>
        <td><?= e($r['user_name'] ?? '-') ?></td>
        <td><?= e($r['module_name']) ?></td>
        <td><?= e($r['action_name']) ?></td>
        <td><?= e((string)($r['record_id'] ?? '')) ?></td>
        <td><?= e($r['created_at']) ?></td>
        <td><details><summary>عرض</summary><pre style="white-space:pre-wrap"><?= e($r['payload_json'] ?? '') ?></pre></details></td>
      </tr>
      <?php endforeach; ?>
    </tbody>
  </table>
</div>
<?php include __DIR__ . '/../layout/footer.php'; ?>
