<?php $__env->startSection('title', 'Staff'); ?>
<?php $__env->startSection('content'); ?>
<div class="card mb-4">
    <div class="card-header pb-0 d-flex justify-content-between align-items-center">
        <h6 class="mb-0">Staff Directory <span class="text-sm text-muted">(<?php echo e($staff->total()); ?>)</span></h6>
        <?php if(auth()->user()->isAdmin() || auth()->user()->isSupervisor()): ?>
            <a href="<?php echo e(route('staff.create')); ?>" class="btn btn-sm btn-primary mb-0"><i class="bi bi-plus-lg me-1"></i>New Staff</a>
        <?php endif; ?>
    </div>
    <div class="card-body">
        <form method="GET" class="row g-2 mb-3">
            <div class="col-md-4"><input name="q" value="<?php echo e($filters['q']); ?>" class="form-control form-control-sm" placeholder="Search name / passport / running no…"></div>
            <div class="col-md-2"><select name="status" class="form-select form-select-sm">
                <option value="">All status</option>
                <?php $__currentLoopData = ['active','resign','inactive']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($s); ?>" <?php if($filters['status']===$s): echo 'selected'; endif; ?>><?php echo e(ucfirst($s)); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select></div>
            <div class="col-md-2"><select name="site_id" class="form-select form-select-sm searchable">
                <option value="">All sites</option>
                <?php $__currentLoopData = $sites; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $site): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($site->id); ?>" <?php if($filters['siteId']==$site->id): echo 'selected'; endif; ?>><?php echo e($site->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select></div>
            <div class="col-md-2"><select name="nationality_id" class="form-select form-select-sm searchable">
                <option value="">All nationalities</option>
                <?php $__currentLoopData = $nationalities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $n): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($n->id); ?>" <?php if($filters['natId']==$n->id): echo 'selected'; endif; ?>><?php echo e($n->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select></div>
            <div class="col-md-2 d-flex gap-1">
                <button class="btn btn-sm btn-primary mb-0 flex-fill">Filter</button>
                <a href="<?php echo e(route('staff.index')); ?>" class="btn btn-sm btn-outline-secondary mb-0">Reset</a>
            </div>
        </form>

        <div class="table-responsive">
        <table class="table align-items-center mb-0">
            <thead><tr class="text-uppercase text-xxs text-secondary font-weight-bolder">
                <th class="ps-2">Name</th><th>Passport</th><th>Nationality</th><th>Site</th>
                <th>Permit</th><th>Passport Exp.</th><th>Status</th><th></th>
            </tr></thead>
            <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $staff; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td class="ps-2"><a href="<?php echo e(route('staff.show', $s)); ?>" class="font-weight-bold text-sm"><?php echo e($s->name); ?></a>
                        <div class="text-xs text-muted">#<?php echo e($s->running_no); ?> <?php echo e($s->worker_code); ?></div></td>
                    <td class="text-sm"><?php echo e($s->passport_no ?? '—'); ?></td>
                    <td class="text-sm"><?php echo e($s->nationality?->name ?? '—'); ?></td>
                    <td class="text-sm"><?php echo e($s->site?->name ?? '—'); ?></td>
                    <td class="text-sm"><?php echo e(optional($s->permit_expiry)->format('d/m/y') ?? '—'); ?></td>
                    <td class="text-sm"><?php echo e(optional($s->passport_expiry)->format('d/m/y') ?? '—'); ?></td>
                    <td><span class="badge bg-<?php echo e($s->statusColor()); ?>"><?php echo e(ucfirst($s->status)); ?></span></td>
                    <td class="text-end pe-2"><a href="<?php echo e(route('staff.show', $s)); ?>" class="text-secondary"><i class="bi bi-eye"></i></a></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="8" class="text-center text-muted py-4">No staff found.</td></tr>
            <?php endif; ?>
            </tbody>
        </table>
        </div>
        <div class="mt-3"><?php echo e($staff->links()); ?></div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/kalaiarasen/projects/myindependent-worker-management/resources/views/staff/index.blade.php ENDPATH**/ ?>