<div class="d-flex justify-content-between align-items-center mb-4">
    <h4 class="mb-0"><i class="fas fa-print me-2"></i><?= lang('cards.print_queue') ?></h4>
    <form method="POST" action="/card-print/create-batch" data-ajax="true" class="d-inline">
        <?= csrf_field() ?>
        <button type="submit" class="btn btn-primary"><i class="fas fa-plus me-1"></i>Create Print Batch (<?= $readyRequests ?> ready)</button>
    </form>
</div>
<div class="card"><div class="card-body">
    <table id="print-table" class="table table-striped w-100" data-url="/card-print/datatable"
           data-columns='[
               {"data":"id","title":"#","width":"50px"},
               {"data":"batch_number","title":"Batch #"},
               {"data":"batch_date","title":"Date"},
               {"data":"total_cards","title":"Total"},
               {"data":"printed_cards","title":"Printed"},
               {"data":"status","title":"Status","render":"renderStatusBadge"},
               {"data":"id","title":"Actions","orderable":false,"searchable":false,"render":"renderPrintActions"}
           ]'>
    </table>
</div></div>

<?php $__view->push('scripts') ?>
<script>
function renderPrintActions(data, type, row) {
    if (row.status === 'pending') {
        return '<form method="POST" action="/card-print/'+data+'/complete" data-ajax="true" class="d-inline">' +
            '<input type="hidden" name="_token" value="<?= csrf_token() ?>">' +
            '<button type="submit" class="btn btn-sm btn-success"><i class="fas fa-check me-1"></i>Complete</button></form>';
    }
    return '<span class="text-muted">-</span>';
}
document.addEventListener('DOMContentLoaded', function() { DataTableHelper.init('print-table'); });
</script>
<?php $__view->endPush() ?>