@extends('layouts.app')
@section('title','Batch & Expiry')
@section('content')<div class="page-head"><div><h1>Batch & expiry report</h1><p>Expired and near-expiry stock by warehouse.</p></div></div><div class="d-flex flex-wrap gap-2 mb-2">@foreach(['all'=>'All','expired'=>'Expired','7days'=>'Next 7 days','30days'=>'Next 30 days','60days'=>'Next 60 days','90days'=>'Next 90 days'] as $k=>$l)<a href="{{ route('expiry-report.index',['filter'=>$k,'warehouse_id'=>request('warehouse_id')]) }}" class="btn btn-sm {{ $filter===$k?'btn-dark':'btn-light border' }}">{{ $l }}</a>@endforeach</div><div class="card-erp"><div class="card-erp-body"><form class="d-flex gap-2"><input type="hidden" name="filter" value="{{ $filter }}"><select name="warehouse_id" class="form-select"><option value="">All warehouses</option>@foreach($warehouses as $w)<option value="{{ $w->id }}" @selected(request('warehouse_id')==$w->id)>{{ $w->code }} · {{ $w->name_en }}</option>@endforeach</select><button class="btn btn-dark">Filter</button></form></div><div class="table-responsive"><table class="table table-dense"><thead><tr><th>Product</th><th>Warehouse</th><th>Batch</th><th>Expiry</th><th class="text-end">Days remaining</th><th class="text-end">Quantity</th><th>Status</th></tr></thead><tbody>@forelse($batches as $b)<tr><td>{{ $b->product?->name_en }}</td><td>{{ $b->warehouse?->code }}</td><td>{{ $b->batch_number }}</td><td>{{ $b->expiry_date->format('d M Y') }}</td><td class="text-end {{ $b->days_remaining<0?'text-danger':'' }}">{{ $b->days_remaining }}</td><td class="text-end">{{ number_format((float)$b->quantity,4) }}</td><td><span class="badge {{ $b->days_remaining<0?'bg-danger':'status-draft' }}">{{ strtoupper($b->expiry_status) }}</span></td></tr>@empty<tr><td colspan="7" class="text-center text-muted py-5">No batch expiry records for this filter.</td></tr>@endforelse</tbody></table></div></div>@endsection
