@extends('layouts.app') @section('title', 'Reports') @section('content')

{{ $report['title'] ?? 'Report' }}

{{ $dateFrom ?? '' }} → {{ $dateTo ?? '' }}
@php $rows = $report['rows'] ?? collect(); @endphp @if($rows->isEmpty()) @elseif(($type ?? '') === 'spend_by_supplier') @foreach($rows as $row) @endforeach
Supplier PO Count Total Spend
{{ $row->supplier->name ?? '—' }} {{ $row->po_count }} {{ number_format($row->total, 2) }}
@elseif(($type ?? '') === 'spend_by_category') @foreach($rows as $row) @endforeach
Category Total Spend
{{ $row->category ?: 'Uncategorized' }} {{ number_format($row->total, 2) }}
@elseif(($type ?? '') === 'purchase_orders') @foreach($rows as $po) @endforeach
PO Number Supplier Date Amount Status
{{ $po->po_number }} {{ $po->supplier->name ?? '—' }} {{ optional($po->order_date)->format('Y-m-d') }} {{ number_format($po->total_amount, 2) }} {{ $po->currency }}
@elseif(($type ?? '') === 'invoices') @foreach($rows as $inv) @endforeach
Invoice # Supplier Date Amount Status
{{ $inv->invoice_number }} {{ $inv->supplier->name ?? '—' }} {{ optional($inv->invoice_date)->format('Y-m-d') }} {{ number_format($inv->total_amount, 2) }} {{ $inv->currency }}
@else @foreach($rows as $waste) @endforeach
Item Qty Wasted Est. Value Reason Disposed At
{{ $waste->item->name_en ?? '—' }} {{ $waste->quantity_wasted }} {{ number_format($waste->estimated_value ?? 0, 2) }} {{ $waste->reason ?? '—' }} {{ optional($waste->disposed_at)->format('Y-m-d') }}
@endif
@endsection