@extends('layout.layout') @section('content')

Purchase Order: {{ $purchase->purchase_number }}

Back to List
{{-- SECTION 1: HEADER DETAILS --}}

Order Name

{{ $purchase->name }}

Required By

{{ $purchase->required_by ? \Carbon\Carbon::parse($purchase->required_by)->format('M d, Y') : '--' }}

Status

{{ ucfirst($purchase->status) }}

Created On

{{-- Added created_at display --}}
{{ $purchase->created_at ? \Carbon\Carbon::parse($purchase->created_at)->format('M d, Y') : '--' }}
{{-- SECTION 2: FINANCE & STAFF --}}

Subtotal

${{ number_format($purchase->sub_total, 2) }}

Shipping Cost

${{ number_format($purchase->shipping_cost, 2) }}

Total Order Value

${{ number_format($purchase->total, 2) }}

{{-- STAFF DETAILS - NOW IN A CARD --}}
Assigned Staff
@forelse ($purchase->requestedStaffs as $staff) {{ $staff->first_name }} {{$staff->last_name}} @empty

No staff members have been assigned to this purchase order.

@endforelse
{{-- SECTION 3: VENDOR DETAILS - NOW IN A CARD --}}
Vendor Information
@php $vendors = json_decode($purchase->vendor_details, true) ?? []; @endphp
@if (count($vendors) > 0) @foreach ($vendors as $vendor) @endforeach
# Vendor Name Contact
{{ $loop->iteration }} {{ $vendor['name'] ?? '--' }} {{ $vendor['phone'] ?? '--' }}
@else @endif
{{-- SECTION 4: ITEMS --}}
Purchased Items
@foreach ($purchase->details as $detail) @endforeach
# Product Category Serial Part No Price Qty Amount Tax %
{{ $loop->iteration }} {{ $detail->product_name }} {{ $detail->category_name }} {{ $detail->serial_number }} {{ $detail->part_no }} ${{ number_format($detail->price, 2) }} {{ $detail->quantity }} ${{ number_format($detail->amount, 2) }} {{ $detail->tax_rate }}%
{{-- SUMMARY / FOOTER --}}
Subtotal: ${{ number_format($purchase->sub_total, 2) }}
Shipping: ${{ number_format($purchase->shipping_cost, 2) }}

GRAND TOTAL: ${{ number_format($purchase->total, 2) }}
{{-- SECTION 5: ATTACHMENTS --}}
Attachments
@forelse ($purchase->attachments as $attachment) @php $path = $attachment->file_path; $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); $isImage = in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'webp']); @endphp
{{-- Show image preview --}} @if ($isImage) Attachment @else {{-- Show file icon --}} @endif

{{ basename($path) }}

View / Download
@empty
No attachments available for this purchase.
@endforelse
@endsection