<?php $__env->startSection('title', 'Visitors'); ?>
<?php $__env->startSection('page_title', 'Visitor Management'); ?>
<?php $__env->startSection('breadcrumbs'); ?>
    <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Home</a></li><li class="breadcrumb-item active">Visitors</li>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('page_actions'); ?>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('visitors.create')): ?><a href="<?php echo e(route('visitors.create')); ?>" class="btn btn-primary"><i class="bi bi-person-plus me-1"></i>New Visitor</a><?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="row g-3 mb-3">
        <div class="col-sm-4"><div class="card stat-card"><div class="card-body d-flex align-items-center gap-3">
            <div class="icon bg-soft-primary"><i class="bi bi-people"></i></div>
            <div><div class="value"><?php echo e($visitors->count()); ?></div><div class="label">Visitors Today</div></div>
        </div></div></div>
        <div class="col-sm-4"><div class="card stat-card"><div class="card-body d-flex align-items-center gap-3">
            <div class="icon bg-soft-success"><i class="bi bi-door-open"></i></div>
            <div><div class="value"><?php echo e($insideCount); ?></div><div class="label">Currently Inside</div></div>
        </div></div></div>
    </div>

    <div class="card mb-3"><div class="card-body py-2">
        <form method="GET" class="row g-2 align-items-end">
            <div class="col-md-3"><label class="form-label small">Date</label><input type="date" name="date" value="<?php echo e($date); ?>" class="form-control form-control-sm"></div>
            <div class="col-md-3"><label class="form-label small">Status</label>
                <select name="status" class="form-select form-select-sm">
                    <option value="">All</option>
                    <option value="checked_in" <?php if($status==='checked_in'): echo 'selected'; endif; ?>>Inside</option>
                    <option value="checked_out" <?php if($status==='checked_out'): echo 'selected'; endif; ?>>Left</option>
                </select></div>
            <div class="col-md-3"><button class="btn btn-sm btn-primary"><i class="bi bi-search me-1"></i>Filter</button></div>
        </form>
    </div></div>

    <div class="card"><div class="card-body">
        <table class="table table-hover align-middle">
            <thead><tr><th>Pass</th><th>Visitor</th><th>Phone</th><th>To Meet</th><th>Purpose</th><th>In</th><th>Out</th><th class="text-center">Status</th><th class="text-end">Actions</th></tr></thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $visitors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td class="small fw-semibold"><?php echo e($v->pass_number); ?></td>
                        <td><?php echo e($v->name); ?><?php if($v->party_size > 1): ?><span class="text-muted small"> +<?php echo e($v->party_size - 1); ?></span><?php endif; ?><div class="small text-muted"><?php echo e($v->cnic); ?></div></td>
                        <td class="small"><?php echo e($v->phone ?: '—'); ?></td>
                        <td class="small"><?php echo e($v->whom_to_meet ?: '—'); ?></td>
                        <td class="small"><?php echo e($v->purpose ?: '—'); ?></td>
                        <td class="small"><?php echo e(optional($v->check_in)->format('H:i')); ?></td>
                        <td class="small"><?php echo e(optional($v->check_out)->format('H:i') ?? '—'); ?></td>
                        <td class="text-center"><span class="badge bg-soft-<?php echo e($v->status_color); ?>"><?php echo e($v->status === 'checked_in' ? 'Inside' : 'Left'); ?></span></td>
                        <td class="text-end">
                            <a href="<?php echo e(route('visitors.pass', $v)); ?>" target="_blank" class="btn btn-sm btn-light border" title="Pass"><i class="bi bi-printer"></i></a>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('visitors.update')): ?><?php if($v->status === 'checked_in'): ?>
                                <form method="POST" action="<?php echo e(route('visitors.checkout', $v)); ?>" class="d-inline"><?php echo csrf_field(); ?><button class="btn btn-sm btn-outline-secondary" title="Check out"><i class="bi bi-box-arrow-right"></i></button></form>
                            <?php endif; ?> <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('visitors.delete')): ?><form method="POST" action="<?php echo e(route('visitors.destroy', $v)); ?>" class="d-inline" data-confirm="Delete record?"><?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?><button class="btn btn-sm btn-light border text-danger"><i class="bi bi-trash"></i></button></form><?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="9" class="text-center text-muted py-4">No visitors for this date.</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/u385418287/domains/itartificer.com/public_html/sms-erp/resources/views/visitors/index.blade.php ENDPATH**/ ?>