@php $tz = config('app.display_timezone'); $parts = \App\Services\Crm\Health\AccountHealth::PARTS; $statusLabel = \App\Services\Crm\Health\AccountHealth::STATUSES; $tone = [ 'risk' => ['chip' => 'bg-rose-50 text-rose-600', 'badge' => 'rose'], 'watch' => ['chip' => 'bg-amber-50 text-amber-600', 'badge' => 'amber'], 'good' => ['chip' => 'bg-emerald-50 text-emerald-600', 'badge' => 'emerald'], 'unknown' => ['chip' => 'bg-slate-100 text-slate-400', 'badge' => 'slate'], ]; $confidenceColor = ['high' => 'emerald', 'medium' => 'sky', 'low' => 'slate']; $statusColor = ['open' => 'slate', 'prompted' => 'amber', 'snoozed' => 'violet', 'converted' => 'emerald', 'dismissed' => 'slate', 'missed' => 'rose']; @endphp
{{-- Account health (19.11) --}}

{{ __('Account health') }} @if ($assessment && $assessment['label']) @endif

@if (! $assessment) {{ __('Health is worked out for clients we trade with. This organisation has not been invoiced yet.') }} @else {{ $assessment['rule'] }} @if ($organisation->health_checked_at) · {{ __('Saved by the check on :when', ['when' => $organisation->health_checked_at->timezone($tz)->format('j M Y H:i')]) }} @endif @endif

@if ($canCheck) {{ __('Check now') }} {{ __('Checking…') }} @endif
@if ($assessment)
@foreach ($assessment['parts'] as $key => $part)

{{ __($parts[$key]['label']) }}

{{ __($statusLabel[$part['status']]) }}

{{ $part['reason'] }}

@endforeach
@endif
{{-- Reorder predictions (19.4) --}}

{{ __('Reorder predictions') }}

{{ __('Learnt from this client\'s invoices. The owner is prompted :weeks weeks before an expected order.', ['weeks' => $leadWeeks]) }}

@if ($canCheck) {{ __('Read invoices again') }} {{ __('Reading…') }} @endif
@if ($historyDays !== null && $historyDays < 365)

{{ __('Their invoices go back :days days, less than a year, so a yearly pattern cannot be seen yet and none is guessed. Importing their past invoices helps.', ['days' => number_format($historyDays)]) }}

@endif
@forelse ($predictions as $prediction) @empty @endforelse
{{ __('What repeats, and the evidence') }} {{ __('Expected') }} {{ __('Typical value') }} {{ __('Status') }} {{ __('Actions') }}

{{ $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 ($prediction->typical_value_base !== null) {{ trim($baseCode.' '.number_format((float) $prediction->typical_value_base, 2)) }} @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

@elseif ($prediction->status === 'open' && $prediction->prompt_on->gt($today))

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

@endif @endif
@if ($canActOn($prediction))
@if ($canCreateOpportunity) @endif
@endif
@if ($predictions->hasPages())
{{ $predictions->onEachSide(1)->links() }}
@endif
@include('livewire.crm.reorders.partials.modals')