@extends('layouts.app') @section('title', 'Batch Recall') @section('content') @php $qty = fn ($v) => rtrim(rtrim(number_format((float) $v, 2), '0'), '.'); $today = today(); $filtered = $search !== '' || $from || $to || $expiry || $stock; $chips = [ ['Expired, still on the shelf', ['expiry' => 'expired', 'stock' => 'in'], 'danger'], ['Expiring within 90 days', ['expiry' => 'soon', 'stock' => 'in'], 'warning'], ['Received this month', ['received_from' => $today->copy()->startOfMonth()->toDateString(), 'received_to' => $today->toDateString()], 'primary'], ['In stock', ['stock' => 'in'], 'success'], ]; $isChip = fn (array $params) => collect($params)->every(fn ($v, $k) => request($k) == $v) && collect(['q', 'received_from', 'received_to', 'expiry', 'stock'])->diff(array_keys($params))->every(fn ($k) => !request()->filled($k)); @endphp

Batch recall

Every batch received. Click a batch to see what is left on the shelf and which customers it was sold to.

@if($filtered) @endif
@foreach($chips as [$label, $params, $tone]) {{ $label }} @endforeach
@foreach([ ['Batches', number_format($summary['batches']), 'bi-upc-scan', 'secondary'], ['Units in stock', $qty($summary['in_stock']), 'bi-box-seam', 'primary'], ['Expired, on the shelf', number_format($summary['expired_on_shelf']), 'bi-calendar-x', $summary['expired_on_shelf'] ? 'danger' : 'success'], ['Expiring within 90 days', number_format($summary['expiring_soon']), 'bi-hourglass-split', $summary['expiring_soon'] ? 'warning' : 'success'], ] as [$label, $value, $icon, $tone])
{{ $label }}
{{ $value }}
@endforeach
@if($list->isEmpty())
{{ $filtered ? 'No batches match.' : 'No batches received yet.' }}
@else
@foreach($list as $batch) @php $url = $batch->batch_no ? route('reports.batches', ['batch_no' => $batch->batch_no]) : route('reports.batches', ['batch' => $batch->id]); $days = $batch->expiry_date ? (int) $today->diffInDays($batch->expiry_date, false) : null; $tone = $days === null ? 'secondary' : ($days < 0 ? 'danger' : ($days <= 90 ? 'warning' : 'success')); @endphp @endforeach
BatchProductReceivedExpiry ReceivedSoldIn stock
{{ $batch->batch_no ?? 'No number' }}
{{ $batch->product?->name ?? 'Deleted product' }}
{{ $batch->product?->sku }}{{ $batch->product?->category ? ' ยท ' . $batch->product->category->name : '' }}
{{ $batch->received_at?->format('d M Y') ?? '-' }} @if($batch->expiry_date) {{ $batch->expiry_date->format('d M Y') }}
{{ $days < 0 ? 'expired ' . abs($days) . ' days ago' : ($days === 0 ? 'expires today' : 'in ' . $days . ' days') }}
@else None @endif
{{ $qty($batch->received_quantity) }} {{ $qty($sold[$batch->id] ?? 0) }} {{ $qty($batch->quantity) }} Recall view
@if($list->hasPages())
{{ $list->links() }}
@endif @endif
@endsection