@php $statusMeta = [ 'draft' => ['label' => __('Draft'), 'color' => 'slate'], 'sent' => ['label' => __('Out for Quotation'), 'color' => 'indigo'], 'closed' => ['label' => __('Closed'), 'color' => 'amber'], 'awarded' => ['label' => __('Awarded'), 'color' => 'emerald'], 'cancelled' => ['label' => __('Cancelled'), 'color' => 'slate'], ]; $seatMeta = [ 'invited' => ['label' => __('Invited'), 'color' => 'slate', 'icon' => 'paper-airplane'], 'viewed' => ['label' => __('Viewed'), 'color' => 'sky', 'icon' => 'eye'], 'submitted' => ['label' => __('Quoted'), 'color' => 'indigo', 'icon' => 'check'], 'declined' => ['label' => __('No bid'), 'color' => 'amber', 'icon' => 'x-mark'], 'awarded' => ['label' => __('Awarded'), 'color' => 'emerald', 'icon' => 'check-circle'], 'not_selected' => ['label' => __('Not selected'), 'color' => 'slate', 'icon' => 'minus'], ]; $money = fn ($v) => $baseCode . ' ' . number_format((float) $v, 2); $qty = fn ($v) => rtrim(rtrim(number_format((float) $v, 2), '0'), '.'); $deadline = $rfq->response_deadline; $bids = $comparison['bids']; // The floor: what the basket would cost buying each line from whoever is // cheapest on it. The gap to the winning single-supplier bid is the price // of the convenience of one order. $cherry = $comparison['cherryPickTotal']; $best = $comparison['bestTotal']; @endphp
{{-- Back link --}} {{ __('All RFQs') }} {{-- Header --}} {{ __('Preview') }} @if ($canManage) @if ($rfq->status === 'draft') {{ __('Issue RFQ') }} @elseif ($rfq->status === 'sent') {{ __('Chase') }} {{ __('Invite supplier') }} @endif @endif {{-- Status strip --}}

{{ __('Status') }}

{{ $statusMeta[$rfq->status]['label'] ?? $rfq->status_label }}

{{ __('Responses close') }}

@if ($deadline)

{{ $deadline->format('j M Y, H:i') }}

{{ $rfq->is_expired ? __('Deadline passed, links are locked') : $deadline->diffForHumans() }}

@else

{{ __('Open-ended') }}

@endif @if ($canManage && in_array($rfq->status, ['sent', 'closed'], true)) @endif

{{ __('Bids in') }}

{{ count($bids) }}/{{ $seats->count() }}

{{ trans_choice('{0}no items|{1}:count item|[2,*] :count items', $rfq->lines->count(), ['count' => $rfq->lines->count()]) }}

@if ($best > 0)

{{ __('Best single bid') }}

{{ $money($best) }}

@if ($cherry > 0 && $best - $cherry > 0.005)

{{ __('Split across cheapest: :v', ['v' => $money($cherry)]) }}

@endif
@endif @if ($rfq->required_by)

{{ __('Required by') }}

{{ $rfq->required_by->format('j M Y') }}

@endif @if ($canManage && in_array($rfq->status, ['sent', 'closed'], true))
@if ($rfq->status === 'sent') @else @endif
@endif
{{-- ============================================================= --}} {{-- Open tender: the public bidding link --}} {{-- ============================================================= --}} @if ($rfq->is_public && $rfq->public_url)

{{ __('Open tender — anyone can bid') }}

{{ __('Share this link. Suppliers register themselves and are handed a private, sealed bidding form.') }}

{{ $rfq->public_url }}

{{ __('Copy link') }} {{ __('Copied') }}
{{ __('Preview') }}
@if ($canManage && $rfq->status !== 'awarded' && $rfq->status !== 'cancelled')
@endif
@elseif ($canManage && $rfq->status !== 'awarded' && $rfq->status !== 'cancelled')

{{ __('Invite-only tender') }}

{{ __('Only the suppliers below can bid. Open it up to advertise publicly and let any supplier register.') }}

{{ __('Open to public bidding') }}
@endif {{-- Award outcome --}} @if ($rfq->status === 'awarded')

{{ __('Awarded to :supplier', ['supplier' => $rfq->awardedSupplier?->name]) }}

{{ __('Awarded :when by :who', [ 'when' => optional($rfq->awarded_at)->format('j M Y'), 'who' => $rfq->awarder?->name ?? __('the system'), ]) }}

@if ($rfq->purchaseOrder) {{ __('Open :po', ['po' => $rfq->purchaseOrder->po_number]) }} @endif
@endif {{-- ============================================================= --}} {{-- Invited suppliers --}} {{-- ============================================================= --}}

{{ __('Invited suppliers') }}

{{ __('Each supplier holds a private link. Bidding is sealed, nobody sees anybody else’s prices.') }}

@if ($canManage && $rfq->status !== 'awarded' && $rfq->status !== 'cancelled') {{ __('Add supplier') }} @endif
@if ($seats->isEmpty())
@else
@foreach ($seats as $seat) @php $meta = $seatMeta[$seat->status] ?? $seatMeta['invited']; @endphp

@if ($seat->is_shortlisted) @endif {{ $seat->supplier?->name ?? __('Supplier') }}

{{ $seat->contact_email ?: ($seat->supplier?->email ?: __('No email on file')) }}

{{ $meta['label'] }} @if ($seat->source === 'public') {{ __('Open tender') }} @endif
{{-- Bid summary --}} @if ($seat->has_responded)
{{ $seat->currency_code }} {{ number_format((float) $seat->total, 2) }} @if ($seat->currency_code !== $baseCode) ≈ {{ $money($seat->total_base) }} @endif @if ($seat->lead_time_days !== null) {{ __(':n day lead time', ['n' => $seat->lead_time_days]) }} @endif
@elseif ($seat->status === 'declined')

{{ $seat->decline_reason ?: __('Declined to quote, no reason given.') }}

@else

@if ($seat->first_viewed_at) {{ __('Opened the link :when', ['when' => $seat->first_viewed_at->diffForHumans()]) }} @elseif ($seat->sent_at) {{ __('Emailed :when, not yet opened', ['when' => $seat->sent_at->diffForHumans()]) }} @else {{ __('Not yet sent') }} @endif

@endif {{-- Private link + actions --}}
@if ($canManage)
@if (in_array($rfq->status, ['sent'], true)) @endif @if ($rfq->is_awardable) @endif @endif @if ($seat->has_responded) @endif @if ($canManage && $seat->has_responded && $rfq->is_awardable) @endif @if ($canManage && $rfq->is_awardable && $seat->status === 'submitted') @endif @if ($canManage && ! $seat->has_responded && $seat->status !== 'declined' && $rfq->status !== 'awarded') @endif
@endforeach
@endif
{{-- ============================================================= --}} {{-- Comparison matrix --}} {{-- ============================================================= --}}

{{ __('Bid comparison') }}

{{ __('Unit prices converted to :code so bids in different currencies compare like for like. The cheapest price on each line is highlighted.', ['code' => $baseCode]) }}

@if ($shortlistCount > 0) {{-- Narrowing re-benchmarks the grid against the short list, so "cheapest" means cheapest of what is still in the running. --}}
@endif
@if (empty($bids))
@else
@foreach ($bids as $bid) @endforeach @foreach ($comparison['lines'] as $row) @php $line = $row['line']; @endphp @foreach ($bids as $bid) @php $cell = $row['cells'][$bid['invitation']->id] ?? null; @endphp @endforeach @endforeach @foreach ($bids as $bid) @endforeach @foreach ($bids as $bid) @endforeach @if ($canManage && $rfq->is_awardable) @foreach ($bids as $bid) @endforeach @endif
{{ __('Item') }} {{ __('Qty') }} @if ($bid['is_shortlisted']) @endif {{ $bid['invitation']->supplier?->name }} {{ $bid['invitation']->currency_code }} @if ($bid['invitation']->source === 'public') · {{ __('open') }} @endif

{{ $line->description }}

@if ($line->specification)

{{ $line->specification }}

@endif
{{ $qty($line->quantity) }} {{ $line->unit }} @if (! $cell || ! $cell['quoted']) — @elseif (! $cell['available']) {{ __('Can’t supply') }} @else $cell['is_best'], 'text-slate-900' => ! $cell['is_best'], ])> {{ number_format($cell['base_unit_price'], 2) }} @if (! $cell['is_best'] && $cell['premium_percent'] !== null && $cell['premium_percent'] > 0) +{{ number_format($cell['premium_percent'], 1) }}% @endif @if ($cell['alternate']) {{ __('alt: :d', ['d' => $cell['alternate']]) }} @endif @endif
{{ __('Total') }} ({{ $baseCode }}) $bid['is_cheapest'], 'text-slate-900' => ! $bid['is_cheapest'], ])>{{ number_format($bid['total_base'], 2) }} @if ($bid['delta_vs_best'] > 0.005) +{{ number_format($bid['delta_vs_best'], 2) }} @elseif ($bid['is_cheapest']) {{ __('Lowest') }} @endif
{{ __('Lead time') }} {{ $bid['invitation']->lead_time_days !== null ? __(':n days', ['n' => $bid['invitation']->lead_time_days]) : '—' }}
@if ($bid['invitation']->status === 'submitted') @endif
@if ($cherry > 0 && $best > 0 && $best - $cherry > 0.005)
{{ __('Buying each line from whoever is cheapest would cost :cherry, :delta less than the best single-supplier bid. Split the award only if the extra admin and delivery are worth it.', [ 'cherry' => $money($cherry), 'delta' => $money($best - $cherry), ]) }}
@endif @endif
{{-- Requirement recap --}} @if ($rfq->scope || $rfq->terms || $rfq->notes)
@if ($rfq->scope)

{{ __('Scope') }}

{{ $rfq->scope }}

@endif @if ($rfq->terms)

{{ __('Conditions shown to suppliers') }}

{{ $rfq->terms }}

@endif @if ($rfq->notes)

{{ __('Internal notes') }}

{{ $rfq->notes }}

@endif
@endif
{{-- ============================================================= --}} {{-- Invite more suppliers --}} {{-- ============================================================= --}} {{ __('Invite more suppliers') }} @if ($availableSuppliers->isEmpty())

{{ __('Every active supplier is already on this RFQ.') }}

@else

{{ __('They will each get their own private link. On a live RFQ the invitation is emailed straight away.') }}

@foreach ($availableSuppliers as $supplier) @endforeach
@endif
{{ __('Cancel') }} @if ($availableSuppliers->isNotEmpty()) {{ __('Invite') }} {{ __('Inviting...') }} @endif
{{-- ============================================================= --}} {{-- Quotation detail --}} {{-- ============================================================= --}} {{ $viewingBid ? __('Quotation from :supplier', ['supplier' => $viewingBid->supplier?->name]) : __('Quotation') }} @if ($viewingBid)
{{-- Terms --}}

{{ __('Total') }}

{{ $viewingBid->currency_code }} {{ number_format((float) $viewingBid->total, 2) }}

{{ __('Lead time') }}

{{ $viewingBid->lead_time_days !== null ? __(':n days', ['n' => $viewingBid->lead_time_days]) : '—' }}

{{ __('Valid until') }}

{{ optional($viewingBid->valid_until)->format('j M Y') ?: '—' }}

{{ __('Payment terms') }}

{{ $viewingBid->payment_terms ?: '—' }}

{{-- Priced lines --}}
@foreach ($rfq->lines as $line) @php $ql = $viewingBid->quoteLines->firstWhere('rfq_line_id', $line->id); @endphp @endforeach
{{ __('Item') }} {{ __('Qty') }} {{ __('Unit') }} {{ __('Total') }}
{{ $line->description }} @if ($ql?->alternate_description) {{ __('Offered: :d', ['d' => $ql->alternate_description]) }} @endif @if ($ql?->notes) {{ $ql->notes }} @endif {{ $qty($ql?->quantity ?? $line->quantity) }} @if ($ql && ! $ql->is_available) {{ __('Can’t supply') }} @else {{ number_format((float) ($ql?->unit_price ?? 0), 2) }} @endif {{ number_format((float) ($ql?->line_total ?? 0), 2) }}
{{ __('Subtotal') }} {{ number_format((float) $viewingBid->subtotal, 2) }}
{{ __('Tax') }} {{ number_format((float) $viewingBid->tax, 2) }}
{{ __('Total') }} {{ number_format((float) $viewingBid->total, 2) }}
@if ($viewingBid->supplier_notes)

{{ __('Supplier notes') }}

{{ $viewingBid->supplier_notes }}

@endif {{-- Evaluation: the buyer's own verdict on this bid --}} @if ($canManage && $rfq->is_awardable)

{{ __('Evaluation') }}

@if ($viewingBid->is_shortlisted && $viewingBid->shortlisted_at) {{ __('Shortlisted :when', ['when' => $viewingBid->shortlisted_at->diffForHumans()]) }} @else {{ __('Notes are internal and never shown to the supplier.') }} @endif

@elseif ($viewingBid->evaluation_note)

{{ __('Evaluation') }}

{{ $viewingBid->evaluation_note }}

@endif {{-- Provenance --}}
{{ __('Submitted :when', ['when' => optional($viewingBid->submitted_at)->format('j M Y, H:i') ?: '—']) }} {{ $viewingBid->source_label }} @if ($viewingBid->respondent_name) {{ __('By :who', ['who' => $viewingBid->respondent_name]) }} @endif @if ($viewingBid->respondent_email) {{ $viewingBid->respondent_email }} @endif @if ($viewingBid->attachment_path) {{ $viewingBid->attachment_name ?: __('Attached quotation') }} @endif
@endif
{{ __('Close') }} @if ($canManage && $viewingBid && $rfq->is_awardable && $viewingBid->status === 'submitted') {{ __('Award this quotation') }} @endif
{{-- ============================================================= --}} {{-- Key in an offline quotation --}} {{-- ============================================================= --}} {{ $capturingSeat ? __('Record quotation from :supplier', ['supplier' => $capturingSeat->supplier?->name]) : __('Record quotation') }} @if ($capturingSeat)

{{ __('For quotes that arrived by phone, WhatsApp or on paper. It is stored and compared exactly like a self-served bid, and stamped as keyed in by you.') }}

{{-- Priced lines --}}
@foreach ($rfq->lines as $line) @php $row = $captureLines[$line->id] ?? []; $lineTotal = ($row['is_available'] ?? true) ? round((float) ($row['quantity'] ?? 0) * (float) ($row['unit_price'] ?? 0), 2) : 0; @endphp

{{ $line->description }}

@if ($line->specification)

{{ $line->specification }}

@endif
@if ($row['is_available'] ?? true)

{{ $capture_currency }} {{ number_format($lineTotal, 2) }}

@endif
@endforeach
{{-- Terms + totals --}}
{{ __('Subtotal') }} {{ $capture_currency }} {{ number_format($captureTotals['subtotal'], 2) }}
{{ __('Tax') }} {{ $capture_currency }} {{ number_format($captureTotals['tax'], 2) }}
{{ __('Total') }} {{ $capture_currency }} {{ number_format($captureTotals['total'], 2) }}
@endif
{{ __('Cancel') }} {{ __('Save quotation') }} {{ __('Saving...') }}