@php $tz = config('app.display_timezone'); $base = $figures['base_code']; $money = fn (?float $v, string $unknown) => $v === null ? $unknown : trim($base.' '.number_format($v, 2)); $cards = [ ['label' => __('Confirmed order'), 'value' => $money($figures['confirmed'], __('Not available')), 'icon' => 'check-circle', 'accent' => '#10b981', 'sub' => $figures['confirmed'] === null ? __('Set when the job is confirmed') : __('From :ref', ['ref' => $figures['confirmed_from']])], ['label' => __('Invoiced'), 'value' => $money($figures['invoiced'], __('Not invoiced')), 'icon' => 'document-text', 'accent' => '#6366f1', 'sub' => __('Net of voids and credit notes')], ['label' => __('Received'), 'value' => $money($figures['received'], __('Not available')), 'icon' => 'banknotes', 'accent' => '#0ea5e9', 'sub' => __('Net of refunds')], ['label' => __('Still owed'), 'value' => $money($figures['outstanding'], __('Not applicable')), 'icon' => 'clock', 'accent' => '#f59e0b', 'sub' => __('Invoiced less received')], ]; $tone = ['emerald' => 'border-emerald-200 bg-emerald-50/60', 'amber' => 'border-amber-200 bg-amber-50/60', 'rose' => 'border-rose-200 bg-rose-50/60', 'slate' => 'border-slate-200 bg-slate-50/60', 'sky' => 'border-slate-200 bg-slate-50/60'][$state['color']]; @endphp
{{-- Where it stands --}}
{{ $state['label'] }}

@switch($state['key']) @case('won') {{ __('Won on :date with job :job.', ['date' => $opportunity->outcome_at?->copy()->timezone($tz)->format('j M Y'), 'job' => $figures['job']?->job_number ?? __('(removed)')]) }} @break @case('awaiting_confirmation') {{ __('The client has accepted. It is won only when Administration confirms the job and links it here.') }} @break @case('open') {{ __('Won needs two things: the client\'s acceptance, and the job Administration has confirmed.') }} @break @default {{ __('This opportunity is closed.') }} @endswitch

@if ($canRecord && $state['key'] === 'open') {{ __('Record written acceptance') }} @endif @if ($canConfirm) {{ __('Confirm the job') }} @endif
{{-- The figures, read live --}}
@foreach ($cards as $m)

{{ $m['label'] }}

{{ $m['value'] }}

{{ $m['sub'] }}
@endforeach

{{ __('In :base at the rate frozen on each document. Read from the quotes, invoices, jobs and payments each time; nothing is copied into the CRM.', ['base' => $base ?: __('the base currency')]) }}

{{-- Evidence and job --}}

{{ __('Client acceptance') }}

@if ($opportunity->accepted_at || $opportunity->acceptance_evidence)

{{ $opportunity->accepted_at?->copy()->timezone($tz)->format('D j M Y, H:i') }}

{{ $opportunity->acceptance_evidence }}

@if ($figures['accepted_quote'])

{{ __('Accepted quote: :number, :amount', ['number' => $figures['accepted_quote']->quote_number, 'amount' => $figures['accepted_quote']->currency_code.' '.number_format((float) $figures['accepted_quote']->total, 2)]) }}

@endif @else

{{ __('Not yet. Online acceptance on the quote link is recorded by itself; a written or emailed acceptance is recorded here, with the document on the Files tab.') }}

@endif

{{ __('Confirmed job') }}

@if ($figures['job'])

@if ($canSeeJobs) {{ $figures['job']->job_number }} @else {{ $figures['job']->job_number }} @endif · {{ $figures['job']->title }}

{{ __('Status: :status', ['status' => ucfirst(str_replace('_', ' ', (string) $figures['job']->status))]) }}

@else

{{ __('Not linked. Administration links the job once it is confirmed.') }}

@endif
{{-- Invoices --}}

{{ __('Invoices') }}

{{ __('Raised from this opportunity\'s quotes or for its confirmed job. Each counted once; voided ones are listed but not counted.') }}

@forelse ($figures['invoices'] as $row) @php $inv = $row['invoice']; @endphp @empty @endforelse
{{ __('Invoice') }} {{ __('Status') }} {{ __('Total') }} {{ __('Counted (:base)', ['base' => $base]) }} {{ __('Received (:base)', ['base' => $base]) }}
@if ($canSeeInvoices) {{ $inv->invoice_number }} @else {{ $inv->invoice_number }} @endif

{{ $inv->created_at?->copy()->timezone($tz)->format('j M Y') }}

{{ ucfirst(strtolower((string) $inv->status)) }} {{ $inv->currency_code }} {{ number_format((float) $inv->total, 2) }} {{ $row['counted'] ? number_format($row['total'], 2) : __('Not counted') }} {{ $row['counted'] ? number_format($row['received'], 2) : __('Not counted') }}
{{ __('Record the client\'s written acceptance') }}

{{ __('A verbal yes is not acceptance. This records the evidence only; the opportunity is won when the job is confirmed.') }}

{{ __('Cancel') }} {{ __('Record acceptance') }}
{{ __('Confirm the job') }} @if ($jobs->isEmpty())

{{ __('No job for this organisation is free to link. Create the job from the invoice first.') }}

@endif

{{ __('Linking the job marks the opportunity won. The client\'s acceptance must be recorded first, and a job confirms only one opportunity.') }}

{{ __('Cancel') }} {{ __('Confirm and mark won') }}