<?php
require 'db.php';
require 'functions.php';
requireRole(['admin']);

$pagetitle = 'Audit Log';
$activemenu = 'auditlog';
require 'header.php';
?>

<div class="dfp-card">
  <h3>Activity Log</h3>
  <table id="tblAudit" class="dfp-table" style="width:100%;">
    <thead>
      <tr><th>Date/Time</th><th>Entity</th><th>Entity ID</th><th>Action</th><th>By Role</th><th>Remarks</th></tr>
      <tr class="filterrow">
        <th></th>
        <th><input class="dfp-colfilter"></th>
        <th><input class="dfp-colfilter"></th>
        <th><input class="dfp-colfilter"></th>
        <th><input class="dfp-colfilter"></th>
        <th><input class="dfp-colfilter"></th>
      </tr>
    </thead>
    <tbody></tbody>
  </table>
</div>

<?php require 'footer.php'; ?>
<script>
$(function () {
  var tbl = $('#tblAudit').DataTable({
    order: [[0, 'desc']],
    ajax: { url: 'ajax_admin_auditlog.php', data: { action: 'list' }, dataSrc: 'data' },
    columns: [
      { data: 'createdat' }, { data: 'entitytype' }, { data: 'entityid' },
      { data: 'action' }, { data: 'actionbyrole' }, { data: 'remarks', render: function (d) { return d ? d : '-'; } }
    ]
  });
  dfpEnableColumnFilters('#tblAudit');
});
</script>
<?php require 'footer2.php'; ?>
