<?php $__env->startSection('title','Van Sales'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-head"><div><h1>Van sales dashboard</h1><p>Each van is a warehouse and uses the same inventory and billing engine.</p></div><a href="<?php echo e(route('van.create')); ?>" class="btn btn-primary btn-dense"><i class="bi bi-plus-lg me-1"></i>Open van day</a></div>
<div class="row g-2 mb-2"><div class="col-6 col-md-3"><div class="card-erp stat-card"><div class="label">Open sessions</div><div class="value"><?php echo e($sessions->where('status','open')->count()); ?></div></div></div><div class="col-6 col-md-3"><div class="card-erp stat-card"><div class="label">Visible sales</div><div class="value">SAR <?php echo e(number_format((float)$sessions->sum(fn($s)=>$s->sales->where('status','finalized')->sum('grand_total')),2)); ?></div></div></div></div>
<div class="card-erp"><div class="table-responsive"><table class="table table-dense"><thead><tr><th>Session</th><th>Date</th><th>Van</th><th>Salesman</th><th>Route</th><th class="text-end">Sales</th><th class="text-end">Balance stock</th><th>Status</th><th></th></tr></thead><tbody><?php $__empty_1 = true; $__currentLoopData = $sessions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr><td class="fw-bold text-accent"><?php echo e($s->session_no); ?></td><td><?php echo e($s->session_date->format('d M Y')); ?></td><td><?php echo e($s->warehouse?->code); ?></td><td><?php echo e($s->salesman?->name); ?></td><td><?php echo e($s->route?:'—'); ?></td><td class="text-end"><?php echo e(number_format((float)$s->sales->where('status','finalized')->sum('grand_total'),2)); ?></td><td class="text-end"><?php echo e(number_format((float)$s->warehouse?->stocks?->sum('qty'),2)); ?></td><td><span class="badge status-<?php echo e($s->status); ?>"><?php echo e(strtoupper($s->status)); ?></span></td><td><a class="btn btn-light border btn-dense" href="<?php echo e(route('van.show',$s)); ?>">Open</a></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="9" class="text-center text-muted py-5">No van sessions. Open a van day to begin.</td></tr><?php endif; ?></tbody></table></div><?php if($sessions->hasPages()): ?><div class="card-erp-body border-top"><?php echo e($sessions->links()); ?></div><?php endif; ?></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\saudi\resources\views\van\index.blade.php ENDPATH**/ ?>