<div class="d-flex justify-content-between align-items-center mb-4">
    <h4 class="mb-0"><i class="fas fa-clipboard-list me-2"></i><?= lang('cards.access_log') ?></h4>
</div>
<div class="row g-3 mb-4">
    <div class="col-md-4"><div class="card border-success h-100"><div class="card-body"><h6 class="text-muted">Today's Entries</h6><h3><?= number_format($todayEntries) ?></h3></div></div></div>
    <div class="col-md-4"><div class="card border-danger h-100"><div class="card-body"><h6 class="text-muted">Denied Today</h6><h3><?= number_format($todayDenied) ?></h3></div></div></div>
</div>
<div class="card mb-3"><div class="card-body">
    <form class="row g-3" data-filter-table="log-table">
        <div class="col-md-3"><select name="filter_point" class="form-select"><option value="">All Points</option>
            <?php foreach($accessPoints as $ap): ?><option value="<?= $ap['id'] ?>"><?= e($ap['name_en']) ?></option><?php endforeach; ?>
        </select></div>
        <div class="col-md-2"><select name="filter_direction" class="form-select"><option value="">All</option><option value="entry">Entry</option><option value="exit">Exit</option></select></div>
        <div class="col-md-2"><input type="date" name="filter_date_from" class="form-control" placeholder="From"></div>
        <div class="col-md-2"><input type="date" name="filter_date_to" class="form-control" placeholder="To"></div>
        <div class="col-md-2"><button type="button" class="btn btn-secondary" onclick="DataTableHelper.reload('log-table')"><?= lang('common.filter') ?></button></div>
    </form>
</div></div>
<div class="card"><div class="card-body">
    <table id="log-table" class="table table-striped w-100" data-url="/access-log/datatable"
           data-columns='[{"data":"id","title":"#","width":"50px"},{"data":"access_time","title":"Time"},{"data":"direction","title":"Dir","render":"renderDir"},{"data":"member_name","title":"Member"},{"data":"membership_number","title":"Mem #"},{"data":"point_name","title":"Point"},{"data":"access_method","title":"Method"},{"data":"granted","title":"Granted","render":"renderGranted"},{"data":"card_number","title":"Card #"}]'>
    </table>
</div></div>
<?php $__view->push('scripts') ?>
<script>
function renderDir(d){return d==='entry'?'<span class="badge bg-success">IN</span>':'<span class="badge bg-info">OUT</span>';}
function renderGranted(d){return d==1?'<i class="fas fa-check text-success"></i>':'<i class="fas fa-times text-danger"></i>';}
document.addEventListener('DOMContentLoaded',function(){DataTableHelper.init('log-table');});
</script>
<?php $__view->endPush() ?>