<?php $__env->startSection('title','Sales Invoices'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-head"><div><h1>Sales invoices</h1><p>Finalized documents are immutable; corrections use a sales return.</p></div><a href="<?php echo e(route('sales.create')); ?>" class="btn btn-primary btn-dense"><i class="bi bi-plus-lg me-1"></i>New invoice</a></div>
<div class="card-erp"><div class="card-erp-body"><form class="row g-2 align-items-end"><div class="col-md-4"><label class="form-label">Search invoice or customer</label><input class="form-control" name="q" value="<?php echo e(request('q')); ?>"></div><div class="col-md-2"><label class="form-label">Status</label><select class="form-select" name="status"><option value="">All statuses</option><?php $__currentLoopData = ['draft','finalized','cancelled']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option <?php if(request('status')===$s): echo 'selected'; endif; ?>><?php echo e($s); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div class="col-md-2"><label class="form-label">From</label><input type="date" class="form-control" name="date_from" value="<?php echo e(request('date_from')); ?>"></div><div class="col-md-2"><label class="form-label">To</label><input type="date" class="form-control" name="date_to" value="<?php echo e(request('date_to')); ?>"></div><div class="col-md-2"><button class="btn btn-dark btn-dense w-100">Apply filters</button></div></form></div><div class="table-responsive"><table class="table table-dense"><thead><tr><th>Invoice</th><th>Date</th><th>Customer</th><th>Warehouse</th><th>Payment</th><th class="text-end">Total</th><th class="text-end">Balance</th><th>Status</th><th></th></tr></thead><tbody><?php $__empty_1 = true; $__currentLoopData = $sales; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sale): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr><td><a class="fw-bold text-accent text-decoration-none" href="<?php echo e(route('sales.show',$sale)); ?>"><?php echo e($sale->invoice_no); ?></a><small class="d-block text-muted"><?php echo e(str_replace('_',' ',ucfirst($sale->invoice_type))); ?></small></td><td><?php echo e($sale->invoice_date->format('d M Y')); ?></td><td><strong><?php echo e($sale->customer?->name_en); ?></strong><small class="d-block text-muted" dir="rtl"><?php echo e($sale->customer?->name_ar); ?></small></td><td><?php echo e($sale->warehouse?->code); ?></td><td><?php echo e(ucfirst($sale->payment_type)); ?></td><td class="text-end fw-bold"><?php echo e(number_format((float)$sale->grand_total,2)); ?></td><td class="text-end"><?php echo e(number_format((float)$sale->balance_total,2)); ?></td><td><span class="badge status-<?php echo e($sale->status); ?>"><?php echo e(strtoupper($sale->status)); ?></span></td><td class="text-end"><a class="btn btn-light border btn-dense" href="<?php echo e(route('sales.show',$sale)); ?>">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 sales invoices match the selected filters.</td></tr><?php endif; ?></tbody></table></div><?php if($sales->hasPages()): ?><div class="card-erp-body border-top"><?php echo e($sales->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/sales/index.blade.php ENDPATH**/ ?>