<div class="d-flex justify-content-between align-items-center mb-4">
    <h4 class="mb-0"><i class="fas fa-shield-alt me-2"></i><?= lang('cards.access_rules') ?></h4>
    <a href="/access-rules/create" class="btn btn-primary"><i class="fas fa-plus me-1"></i><?= lang('common.create') ?></a>
</div>
<div class="card"><div class="card-body">
    <table id="rules-table" class="table table-striped w-100" data-url="/access-rules/datatable"
           data-columns='[{"data":"id","title":"#","width":"50px"},{"data":"rule_name","title":"Rule"},{"data":"point_name","title":"Access Point"},{"data":"type_name","title":"Membership Type"},{"data":"priority","title":"Priority"},{"data":"is_active","title":"Active","render":"renderBool"},{"data":"id","title":"Actions","orderable":false,"searchable":false,"render":"renderRuleActions"}]'>
    </table>
</div></div>
<?php $__view->push('scripts') ?>
<script>
function renderBool(d){return d==1?'<i class="fas fa-check text-success"></i>':'<i class="fas fa-times text-danger"></i>';}
function renderRuleActions(d){return '<a href="/access-rules/'+d+'/edit" class="btn btn-sm btn-warning me-1"><i class="fas fa-edit"></i></a><button class="btn btn-sm btn-danger" onclick="deleteRule('+d+')"><i class="fas fa-trash"></i></button>';}
function deleteRule(id){Swal.fire({title:'Delete this rule?',icon:'warning',showCancelButton:true,confirmButtonColor:'#e53e3e',confirmButtonText:'Delete'}).then(r=>{if(r.isConfirmed){$.post('/access-rules/'+id+'/delete',{_token:'<?= csrf_token() ?>'},function(d){if(d.success){FormHelper.showToast('success',d.message);DataTableHelper.reload('rules-table');}});}});}
document.addEventListener('DOMContentLoaded',function(){DataTableHelper.init('rules-table');});
</script>
<?php $__view->endPush() ?>