@extends('layouts.omd.omd') @section('title', 'RFQ Request') @section('content')
{{-- Header --}}
← All RFQs

{{ $rfq->rfq_number }}

@php $badge = match ($rfq->status) { 'open' => 'primary', 'awarded' => 'success', 'closed' => 'secondary', default => 'secondary', }; @endphp {{ ucfirst($rfq->status) }}
{{-- Alerts --}} @if(session('success'))
{{ session('success') }}
@endif
{{-- LEFT COLUMN --}}
{{-- RFQ Details --}}
RFQ Details
RFQ Number {{ $rfq->rfq_number }}
Category {{ ucfirst($rfq->category) }}
Site Location {{ $rfq->site_location }}
Delivery Date {{ optional($rfq->delivery_date)->format('d M Y') }}
Created {{ $rfq->created_at->format('d M Y') }}
Description {{ $rfq->description }}
{{-- Items --}}
Items Required
@forelse($rfq->items as $item) @empty @endforelse
Product Qty Unit
{{ $item->product_name }} @if($item->grade || $item->size)
{{ $item->grade }} {{ $item->size ? ' · ' . $item->size : '' }}
@endif
{{ $item->quantity }} {{ $item->unit }}
No items found
{{-- Vendor Status --}}
Vendors Notified
@foreach($rfq->vendors as $rv) @php $vbadge = match ($rv->status) { 'quoted' => 'success', 'rejected' => 'danger', 'draft' => 'warning', default => 'secondary', }; @endphp @endforeach
{{ $rv->vendor->name ?? 'Vendor' }} {{ ucfirst($rv->status) }} {{ $rv->quoted_at ? $rv->quoted_at->format('d M, h:i A') : '—' }}
{{-- RIGHT COLUMN --}}
@php $quotedVendors = $rfq->vendors->where('status', 'quoted'); $vendorTotals = []; foreach ($quotedVendors as $vendorRow) { $total = 0; foreach ($rfq->items as $item) { $quoteItem = $vendorRow->quoteItems ->firstWhere('rfq_item_id', $item->id); $total += (($quoteItem->quote ?? 0) * $item->quantity); } $vendorTotals[$vendorRow->id] = $total; } $lowestTotal = !empty($vendorTotals) ? min($vendorTotals) : 0; @endphp {{-- Quote Comparison --}}
Quote Comparison @if($quotedVendors->isEmpty()) Awaiting vendor quotes @endif
@if($quotedVendors->isNotEmpty())
@foreach($quotedVendors as $rv) @endforeach @foreach($rfq->items as $item) @php $rowPrices = $quotedVendors->map(function ($rv) use ($item) { return optional( $rv->quoteItems ->firstWhere('rfq_item_id', $item->id) )->quote; })->filter(); $minPrice = $rowPrices->min(); @endphp @foreach($quotedVendors as $rv) @php $qi = $rv->quoteItems ->firstWhere('rfq_item_id', $item->id); $price = $qi?->quote; $isMin = $price !== null && $price == $minPrice; @endphp @endforeach @endforeach {{-- FINAL TOTAL --}} @foreach($quotedVendors as $rv) @php $total = $vendorTotals[$rv->id] ?? 0; $isLowest = $total > 0 && $total == $lowestTotal; @endphp @endforeach
Item Qty {{ $rv->vendor->name }}
{{ $item->product_name }}
@if($item->grade || $item->size) {{ $item->grade }} {{ $item->size ? ' · ' . $item->size : '' }} @endif
{{ $item->quantity }} {{ $item->unit }} @if($price !== null) ₹ {{ number_format($price, 2) }} @else — @endif @if($qi?->comment)
{{ $qi->comment }}
@endif
Final Quote Amount ₹ {{ number_format($total, 2) }} @if($isLowest)
Lowest Quote
@endif
@else
No quotes received yet.
@endif
{{-- Generate PO --}} @if($rfq->status === 'open' && $quotedVendors->isNotEmpty())
Purchase Order
@csrf
@endif {{-- Awarded --}} @if($rfq->status === 'awarded') @php $order = $rfq->orders->first(); @endphp
PO Issued
{{ $order?->po_number ?? 'N/A' }} · ₹ {{ number_format($total ?? 0, 2) }}
@if($order) View PO @endif
@endif
@endsection