@extends('layouts.dashboard') @section('title',$stockRequest->request_number) @section('page-title','Stock Request Review') @section('content')
← Back to Stock Requests@if(session('success'))
{{session('success')}}
@endif @if($errors->any())
{{$errors->first()}}
@endif
{{$stockRequest->request_number}}

{{$stockRequest->salesman?->name}}

Created {{$stockRequest->created_at?->format('d M Y H:i')}}

{{str_replace('_',' ',ucwords($stockRequest->status,'_'))}}Request PDFPreparation PDFReceiving PDF
@php($linkedWarehouseOrder=\Illuminate\Support\Facades\DB::table('warehouse_order_headers')->where('stock_request_id',$stockRequest->id)->first()) @if($linkedWarehouseOrder)
Linked warehouse order: {{ $linkedWarehouseOrder->reference }} · {{ $linkedWarehouseOrder->status }}Open Warehouse Order →
@elseif(in_array($stockRequest->status,['approved','picking','awaiting_admin_release','ready_to_ship'],true))
Admin approved. Prepare the Focus-backed warehouse allocation and register STI/STR through Warehouse Orders.Prepare Warehouse Order →
@endif
@csrf
@foreach($stockRequest->items as $i)@endforeach
ProductSourceVanDemandRequestedApprovedPreparedShippedReceivedAccepted
{{$i->sku_snapshot}}
{{$i->name_snapshot}}
{{$i->catalog_source}}{{$i->van_qty_snapshot}}{{$i->demand_30d_qty??'—'}}{{$i->requested_qty}}id}.approved_qty",$i->approved_qty??$i->requested_qty)}}">id}.prepared_qty",$i->prepared_qty??0)}}">{{$i->shipped_qty??'—'}}{{$i->received_qty}}{{$i->accepted_qty}}
@if($stockRequest->status==='awaiting_admin_release') @php($hasPreparationVariance=$stockRequest->items->contains(fn($item)=>(float)$item->prepared_qty!==(float)$item->approved_qty))
{{$hasPreparationVariance?'Preparation requires review: one or more lines differ from approved quantities.':'Fully prepared: every line matches its approved quantity.'}}
@endif
@if($stockRequest->status==='ready_to_ship')

Dispatch & Delivery Note

All delivery metadata is optional and remains in the audit trail.

@endif
@php($actions=match($stockRequest->status){'pending_admin_approval'=>['approve'=>'Approve','needs_changes'=>'Needs Changes','reject'=>'Reject'],'approved','returned_to_warehouse'=>['start_preparation'=>'Start Preparation'],'picking'=>['finish_preparation'=>'Finish Preparation'],'awaiting_admin_release'=>['release'=>'Approve for Dispatch','return_to_warehouse'=>'Return to Warehouse'],'ready_to_ship'=>['dispatch'=>'Dispatch'],default=>[]}) @foreach($actions as $value=>$label)@endforeach
@if($stockRequest->dispatched_at)

Dispatch Details

Delivery Note
{{$stockRequest->delivery_note_number?:'—'}}
Driver
{{$stockRequest->dispatch_driver?:'—'}}
Vehicle
{{$stockRequest->dispatch_vehicle?:'—'}}
Dispatched
{{$stockRequest->dispatched_at?->format('d M Y H:i')}}
{{$stockRequest->dispatch_note}}
@endif
@foreach(['prepared_photo'=>'Prepared Shipment Photo','dispatch_receipt'=>'Shipping Receipt / Photo'] as $type=>$label)

{{$label}}

Optional · private protected evidence

@csrf
@forelse($stockRequest->attachments->where('type',$type) as $attachment){{$attachment->original_name}}{{$attachment->created_at?->format('d M Y H:i')}}@empty

No attachment uploaded.

@endforelse
@endforeach

Audit Timeline

@foreach($stockRequest->events as $e)
{{str_replace('_',' ',ucwords($e->action,'_'))}}
{{$e->actor?->name??'System'}} · {{$e->created_at?->format('d M Y H:i')}}
@if($e->note)

{{$e->note}}

@endif
@endforeach
@endsection