@php $org = auth()->user()->organization ?? \App\Models\System\Organization::find(auth()->user()->organization_id); @endphp @extends('documents.procurement._layout', [ 'documentTitle' => 'Production Summary', 'reference' => null, 'documentDate' => $reportDate, 'noAutoPrint' => true, ]) @section('header-meta')
Period: {{ $from->format('d M Y') }}{{ $until->format('d M Y') }}
Currency: {{ $currency }} (base)
@endsection @section('content') @php $byStatus = $orders->groupBy('status'); $totalPlanned = $orders->sum('planned_quantity'); $totalProduced = $orders->sum('produced_quantity'); $totalRejected = $orders->sum('rejected_quantity'); $totalCost = $orders->sum('total_production_cost_base'); @endphp {{-- KPI strip --}}
Orders
{{ $orders->count() }}
Planned Qty
{{ number_format($totalPlanned) }}
Produced Qty
{{ number_format($totalProduced) }}
Rejected
{{ number_format($totalRejected) }}
Total Cost ({{ $currency }})
{{ number_format($totalCost, 0) }}
@if($orders->isEmpty())

No production orders found for this period.

@else @foreach($orders as $order) @php $net = ($order->produced_quantity ?? 0) - ($order->rejected_quantity ?? 0); $cpu = $net > 0 && $order->total_production_cost_base ? (float) $order->total_production_cost_base / $net : null; @endphp @endforeach
Reference Product Location Status Planned Produced Rejected Total Cost ({{ $currency }}) Cost/Unit Prod. Date Completion
{{ $order->production_reference }} {{ $order->product?->name ?? '—' }} {{ $order->location?->name ?? '—' }} {{ ucwords(str_replace('_',' ',$order->status)) }} {{ number_format($order->planned_quantity) }} {{ $order->produced_quantity !== null ? number_format($order->produced_quantity) : '—' }} {{ ($order->rejected_quantity ?? 0) > 0 ? number_format($order->rejected_quantity) : '—' }} {{ number_format((float) ($order->total_production_cost_base ?? 0), 2) }} {{ $cpu !== null ? number_format($cpu, 2) : '—' }} {{ \Carbon\Carbon::parse($order->production_date)->format('d M Y') }} {{ $order->completion_date ? \Carbon\Carbon::parse($order->completion_date)->format('d M Y') : '—' }}
Totals {{ number_format($totalPlanned) }} {{ number_format($totalProduced) }} {{ number_format($totalRejected) }} {{ number_format($totalCost, 2) }}
@endif @endsection