<div class="d-flex justify-content-between align-items-center mb-4">
    <h4 class="mb-0"><i class="fas fa-ban me-2"></i><?= lang('cards.guest_blacklist') ?></h4>
    <?php if (auth_can('guests.create')): ?><a href="/guest-blacklist/create" class="btn btn-danger"><i class="fas fa-plus me-1"></i><?= lang('cards.add_to_blacklist') ?></a><?php endif; ?>
</div>
<div class="card"><div class="card-body">
    <table id="bl-table" class="table table-striped w-100" data-url="/guest-blacklist/datatable"
           data-columns='[{"data":"id","title":"#","width":"50px"},{"data":"guest_name","title":"Name"},{"data":"guest_national_id","title":"National ID"},{"data":"guest_phone","title":"Phone"},{"data":"reason","title":"Reason"},{"data":"blacklisted_date","title":"Date"},{"data":"status","title":"Status","render":"renderStatusBadge"},{"data":"id","title":"Actions","orderable":false,"searchable":false,"render":"renderBLActions"}]'>
    </table>
</div></div>
<?php $__view->push('scripts') ?>
<script>
function renderBLActions(d,t,r){
    if(r.status==='active') return '<button class="btn btn-sm btn-success" onclick="removeBL('+d+')"><i class="fas fa-undo me-1"></i>Remove</button>';
    return '<span class="text-muted">'+r.status+'</span>';
}
function removeBL(id){Swal.fire({title:'Remove from blacklist?',input:'textarea',inputPlaceholder:'Reason',showCancelButton:true,confirmButtonText:'Remove'}).then(r=>{
    if(r.isConfirmed){$.post('/guest-blacklist/'+id+'/remove',{_token:'<?= csrf_token() ?>',reason:r.value},function(d){if(d.success){FormHelper.showToast('success',d.message);DataTableHelper.reload('bl-table');}});}
});}
document.addEventListener('DOMContentLoaded',function(){DataTableHelper.init('bl-table');});
</script>
<?php $__view->endPush() ?>