@php $money = fn (?float $amount): string => trim($baseCode.' '.number_format((float) $amount, 2)); $tabMeta = [ 'due' => ['label' => __('To act on'), 'icon' => 'bell'], 'upcoming' => ['label' => __('Coming up'), 'icon' => 'calendar-days'], 'closed' => ['label' => __('Closed'), 'icon' => 'check-circle'], ]; $metrics = [ ['label' => __('To act on'), 'value' => number_format($counts['due']), 'icon' => 'bell', 'accent' => '#f59e0b', 'sub' => __('Prompt date reached')], ['label' => __('Expected in 90 days'), 'value' => number_format($comingUpCount), 'icon' => 'calendar-days', 'accent' => '#6366f1', 'sub' => $comingUpCount > 0 && $comingUpValue > 0 ? __(':amount typical, an estimate', ['amount' => $money($comingUpValue)]) : __('Typical value not estimated')], ['label' => __('Opened this year'), 'value' => number_format($convertedThisYear), 'icon' => 'arrow-path', 'accent' => '#10b981', 'sub' => __('As Repeat opportunities')], ['label' => __('Under a year of history'), 'value' => number_format($shortHistory), 'icon' => 'fa-solid fa-hourglass-half', 'accent' => '#94a3b8', 'sub' => __('Too soon for a yearly pattern')], ]; $confidenceColor = ['high' => 'emerald', 'medium' => 'sky', 'low' => 'slate']; $statusColor = ['open' => 'slate', 'prompted' => 'amber', 'snoozed' => 'violet', 'converted' => 'emerald', 'dismissed' => 'slate', 'missed' => 'rose']; $empty = [ 'due' => [__('Nothing to act on'), __(':weeks weeks before a client\'s next order is expected, it appears here and the owner gets a task.', ['weeks' => $leadWeeks])], 'upcoming' => [__('No patterns found yet'), __('A client who buys the same thing in about the same month in two different years, or at a steady interval, appears here. Nothing is predicted from a single purchase.')], 'closed' => [__('Nothing closed yet'), __('Predictions turned into opportunities, dismissed, ordered or missed are kept here.')], ]; @endphp
@foreach ($metrics as $m)

{{ $m['label'] }}

{{ $m['value'] }}

{{ $m['sub'] }}
@endforeach
@foreach ($tabMeta as $key => $meta) @endforeach
@if ($seesTeam)
@foreach (['mine' => __('My accounts'), 'team' => __('Whole team')] as $key => $label) @endforeach
@endif

{{ $tabMeta[$tab]['label'] }}

{{ __('Open the invoices under each prediction to see why it was made. Typical value is an estimate, never a sale.') }}

@forelse ($predictions as $prediction) @empty @endforelse
{{ __('Organisation') }} {{ __('What repeats, and the evidence') }} {{ __('Expected') }} {{ __('Typical value') }} {{ __('Status') }} {{ __('Actions') }}
{{ $prediction->customer?->name }}

{{ $prediction->customer?->relationshipOwner?->name ?? __('No owner') }}

{{ $prediction->category_label }}

{{ $prediction->pattern === 'interval' ? __('About every :days days', ['days' => $prediction->interval_days]) : __(\App\Models\Crm\ReorderPrediction::PATTERNS[$prediction->pattern] ?? $prediction->pattern) }} {{ __(':level confidence', ['level' => __(\App\Models\Crm\ReorderPrediction::CONFIDENCES[$prediction->confidence] ?? $prediction->confidence)]) }}

@include('livewire.crm.reorders.partials.evidence', ['prediction' => $prediction, 'reasons' => $reasons($prediction)])

{{ $prediction->expected_on->format('M Y') }}

{{ __('around :date', ['date' => $prediction->expected_on->format('j M')]) }}

@if (in_array($prediction->status, ['open', 'prompted'], true))

{{ $prediction->prompt_on->lte($today) ? __('Prompted from :date', ['date' => $prediction->prompt_on->format('j M')]) : __('Prompt on :date', ['date' => $prediction->prompt_on->format('j M')]) }}

@endif
@if ($prediction->typical_value_base !== null) {{ $money((float) $prediction->typical_value_base) }} @else {{ __('Not estimated') }} @endif @if ($wasOrdered($prediction)) {{ __('Ordered') }}

{{ \Illuminate\Support\Str::after($prediction->dismissed_reason, \App\Services\Crm\Reorders\ReorderService::ORDERED_PREFIX) }}

@else {{ __(\App\Models\Crm\ReorderPrediction::STATUSES[$prediction->status] ?? $prediction->status) }} @if ($prediction->status === 'snoozed' && $prediction->snoozed_until)

{{ __('until :date', ['date' => $prediction->snoozed_until->format('j M')]) }}

@elseif ($prediction->status === 'converted' && $prediction->opportunity) {{ $prediction->opportunity->title }} @elseif ($prediction->status === 'dismissed')

{{ $prediction->dismissed_reason }}@if ($prediction->actor) · {{ $prediction->actor->name }}@endif

@endif @endif
@if ($canAct($prediction))
@if ($canCreateOpportunity) @endif
@endif
{{ $predictions->links() }}
@if ($shortHistory > 0)

{{ trans_choice('{1} :count client has invoices going back less than a year. A yearly pattern cannot be seen yet, so none is guessed; importing their past invoices helps.|[2,*] :count clients have invoices going back less than a year. A yearly pattern cannot be seen yet, so none is guessed; importing their past invoices helps.', $shortHistory, ['count' => number_format($shortHistory)]) }}

@endif
@include('livewire.crm.reorders.partials.modals')