@extends('layouts.app') @section('title', __('lang_v1.expired_batches')) @section('content')

{{ $mode === 'upcoming' ? __('lang_v1.batches_at_risk') : __('lang_v1.expired_batches') }} @lang('lang_v1.batch_level_drilldown')

{!! Form::open(['route' => 'expiry-analytics.batches', 'method' => 'get', 'class' => 'form-inline']) !!}
{!! Form::label('mode', __('lang_v1.showing') . ':') !!} {!! Form::select('mode', ['expired' => __('lang_v1.already_expired'), 'upcoming' => __('lang_v1.expiring_soon')], $mode, ['class' => 'form-control']) !!}
{!! Form::label('business_id', __('lang_v1.site') . ':') !!} {!! Form::select('business_id', ['' => __('lang_v1.all_sites')] + $businesses->all(), $filters['business_id'] ?? null, ['class' => 'form-control select2', 'style' => 'width:220px;']) !!}
{!! Form::label('state', __('business.state') . ':') !!} {!! Form::select('state', ['' => __('lang_v1.all_states')] + $states->mapWithKeys(fn($s) => [$s => $s])->all(), $filters['state'] ?? null, ['class' => 'form-control']) !!}
@lang('lang_v1.back_to_analytics') {!! Form::close() !!}
@if($batches->isEmpty())
@lang('lang_v1.no_batches_for_scope')
@endif @component('components.widget', ['class' => 'box-solid'])
@foreach($batches as $b) @endforeach
@lang('lang_v1.site') @lang('business.state') @lang('business.product') @lang('lang_v1.schedule') @lang('lang_v1.lot_number') @lang('product.exp_date') {{ $mode === 'upcoming' ? __('lang_v1.days_left') : __('lang_v1.days_expired') }} @lang('lang_v1.manufacturer') @lang('lang_v1.status') @lang('sale.quantity') @lang('lang_v1.unit_cost') @lang('lang_v1.value_at_cost')
{{ $b->business_name }} @if($b->is_supplier_warehouse)@lang('lang_v1.warehouse')@endif {{ $b->state ?: '--' }} {{ $b->product_name }} @if($b->variation_name && $b->variation_name !== 'DUMMY') ({{ $b->variation_name }}) @endif @if(in_array($b->drug_schedule, ['H','H1','X'])) {{ $b->drug_schedule }} @else {{ $b->drug_schedule ?: '--' }} @endif {{ $b->lot_number ?: '--' }} {{ \Carbon::parse($b->exp_date)->format('d-m-Y') }} @if($mode === 'upcoming') {{ (int) $b->days_to_expiry }} @elseif($b->days_expired === null) -- @else {{ (int) $b->days_expired }} @endif {{ $b->batch_manufacturer ?: ($b->product_manufacturer ?: '--') }} @if(($b->row_type ?? 'on_hand') === 'destroyed') {{-- Counted as waste by the expiry ratio, but no longer in stock — the certificate is the evidence. --}} @lang('lang_v1.destroyed')
{{ $b->disposal_ref }} @if(!empty($b->disposal_date)) — {{ \Carbon::parse($b->disposal_date)->format('d-m-Y') }} @endif @if(!empty($b->source_store_name))
@lang('lang_v1.from_store'): {{ $b->source_store_name }} @endif @else {{ $mode === 'upcoming' ? __('lang_v1.expiring_soon') : __('lang_v1.on_hand_expired') }} @endif
{{ @num_format($b->qty_remaining) }} @format_currency($b->unit_cost) @format_currency($b->value_at_cost)
@endcomponent
@endsection @section('javascript') @endsection