@extends('layouts.app') @section('title', 'Pipeline โ€” ' . $pr->request_number) @section('content') {{-- Breadcrumb --}}
Purchase Pipeline
@php $stageIdx = $stages->stageIndex($pr->stage); $allStages = \App\Services\PurchaseStageService::STAGES; $total = count($allStages); $pct = $total > 1 ? round(($stageIdx / ($total - 1)) * 100) : 100; $isDone = $pr->stage === 'complete'; $pendingInv = $pr->rfqInvitations->where('status', 'pending'); $sentInv = $pr->rfqInvitations->where('status', '!=', 'pending'); $selectedIds = $pr->rfqInvitations->pluck('supplier_id')->toArray(); @endphp {{-- Header card --}}

{{ $pr->request_number }}

{{ $stages->stageLabel($pr->stage) }}
@if($pr->project_name) ๐Ÿ“ {{ $pr->project_name }} @endif @if($pr->department) ๐Ÿข {{ $pr->department }} @endif @if($pr->requested_by_name ?? $pr->requestedBy) ๐Ÿ‘ค {{ $pr->requested_by_name ?? $pr->requestedBy->name }} @endif @if($pr->date) ๐Ÿ“… {{ \Carbon\Carbon::parse($pr->date)->format('d M Y') }} @endif
View Full Request โ†’
{{-- Two-column layout --}}
{{-- Timeline --}}

Pipeline Stages

@foreach($allStages as $i => $stage) @php $done = $i < $stageIdx; $current = $i === $stageIdx; $isLast = $i === $total - 1; @endphp
{{-- Dot + line --}}
@if($done) @endif
@if(!$isLast)
@endif
{{-- Stage content --}}
{{ $stages->stageLabel($stage) }}
@if($done || $current)
@if($stage === 'draft') Created by {{ $pr->requested_by_name ?? $pr->requestedBy?->name ?? 'โ€”' }} @if($pr->created_at) ยท {{ $pr->created_at->format('d M Y') }} @endif @elseif($stage === 'gm_approval') @if($pr->signature) Signed by {{ $pr->signature->signedBy?->name ?? 'โ€”' }} ยท {{ $pr->signature->signed_at?->format('d M Y') }} @elseif($current) Awaiting GM signature @endif @elseif($stage === 'rfq') @if($pr->rfqInvitations->count()) {{ $pr->rfqInvitations->count() }} supplier(s) selected @if($pendingInv->count()) ยท {{ $pendingInv->count() }} unsent @endif @elseif($current) Select suppliers to receive quote requests @endif @elseif($stage === 'quoting') {{ $pr->supplierQuotes->count() }} quote(s) received ยท {{ $sentInv->count() }} invited @elseif($stage === 'comparison') {{ $pr->supplierQuotes->count() }} quote(s) ready to compare @elseif($stage === 'lpo' && $pr->awardedQuote) Awarded to {{ $pr->awardedQuote->supplier->name }} @endif
@endif
{{-- Action buttons per stage --}} @if($current) @if($stage === 'draft') @elseif($stage === 'gm_approval')
@elseif($stage === 'rfq')
@if($pendingInv->count() > 0)
@csrf
@endif
@elseif($stage === 'quoting') View Quotes ({{ $pr->supplierQuotes->count() }}) โ†’ @elseif($stage === 'comparison') Compare & Award โ†’ @elseif($stage === 'lpo') Issue LPO โ†’ @elseif($stage === 'receiving') Record GRN โ†’ @elseif($stage === 'payment') Issue Payment โ†’ @endif @endif
@endforeach
{{-- Info sidebar --}}
{{-- Request details --}}

Request Details

@if($pr->location)
Location
{{ $pr->location }}
@endif @if($pr->required_date_text)
Required By
{{ $pr->required_date_text }}
@endif @if($pr->verified_by_name)
Verified By
{{ $pr->verified_by_name }}
@endif
Status
{{ ucfirst($pr->status ?? 'โ€”') }}
{{-- Selected suppliers (rfq stage+) --}} @if($pr->rfqInvitations->isNotEmpty())

Suppliers ({{ $pr->rfqInvitations->count() }})

@foreach($pr->rfqInvitations as $inv) @php $statusMap = [ 'pending' => ['bg'=>'#f1f5f9','fg'=>'#64748b','label'=>'Pending'], 'sent' => ['bg'=>'#dbeafe','fg'=>'#1d4ed8','label'=>'Sent'], 'opened' => ['bg'=>'#e0e7ff','fg'=>'#3730a3','label'=>'Opened'], 'submitted' => ['bg'=>'#dcfce7','fg'=>'#15803d','label'=>'Submitted'], 'declined' => ['bg'=>'#fee2e2','fg'=>'#991b1b','label'=>'Declined'], ]; $sc = $statusMap[$inv->status] ?? $statusMap['pending']; @endphp
{{ $inv->supplier->name }}
@if($inv->channel !== 'email')
{{ ucfirst($inv->channel) }}
@endif
@if($inv->status === 'pending' && in_array($pr->stage, ['rfq','quoting'])) {{-- WhatsApp link for pending --}} @if($inv->supplier->phone) WA @endif @endif {{ $sc['label'] }}
@endforeach
@endif {{-- Quotes summary --}} @if($pr->supplierQuotes->isNotEmpty())

Quotes ({{ $pr->supplierQuotes->count() }})

@foreach($pr->supplierQuotes->sortBy('total_amount') as $quote)
{{ $quote->supplier->name }}
{{ number_format($quote->total_amount, 2) }} @if($quote->is_awarded) Awarded @endif
@endforeach
View All Quotes โ†’
@endif
{{-- ============================================================ GM SIGNATURE MODAL (always in DOM so the button always works) ============================================================ --}} @endsection