@php $hours = fn ($h) => $h === null ? null : rtrim(rtrim(number_format((float) $h, 1), '0'), '.'); $ownerHours = $thresholds[0]; $directorHours = $thresholds[1]; $metrics = [ ['label' => __('Enquiries'), 'value' => number_format($totals['received']), 'icon' => 'inbox-arrow-down', 'accent' => '#6366f1', 'sub' => __(':n answered', ['n' => number_format($totals['responded'])])], ['label' => __('Median response'), 'value' => $totals['median'] === null ? __('Not available') : __(':h working h', ['h' => $hours($totals['median'])]), 'icon' => 'clock', 'accent' => '#0ea5e9', 'sub' => __('Arrival to first contact')], ['label' => trans_choice('Within :n working hour|Within :n working hours', $ownerHours, ['n' => $ownerHours]), 'value' => $totals['within_pct'] === null ? __('Not available') : $totals['within_pct'].'%', 'icon' => 'check-circle', 'accent' => '#10b981', 'sub' => __(':n of :of answered', ['n' => number_format($totals['within']), 'of' => number_format($totals['responded'])])], ['label' => __('Waiting now'), 'value' => number_format($totals['waiting']), 'icon' => 'bell-alert', 'accent' => '#f59e0b', 'sub' => __('Open, no contact yet')], ['label' => __('Closed unanswered'), 'value' => number_format($totals['closed']), 'icon' => 'x-circle', 'accent' => '#e11d48', 'sub' => __('Won, lost or deferred with no contact logged')], ]; $statusMeta = [ 'responded' => ['label' => __('Answered'), 'color' => 'emerald'], 'waiting' => ['label' => __('Waiting'), 'color' => 'amber'], 'closed' => ['label' => __('Closed, no contact'), 'color' => 'slate'], ]; $channel = \App\Models\Interaction::CRM_TYPES; @endphp
@if ($canSeeSettings) {{ __('Enquiry rota') }} @endif

{{ __('Enquiries that arrived :from to :to', ['from' => $from->format('j M Y'), 'to' => $to->format('j M Y')]) }}

{{ __('Owner alerted after :o, a director after :d working hours without contact.', ['o' => $ownerHours, 'd' => $directorHours]) }}

@foreach ($metrics as $m)

{{ $m['label'] }}

{{ $m['value'] }}

{{ $m['sub'] }}
@endforeach
@foreach ($tabs as $key => $meta) @endforeach
@if ($tab === 'enquiries')

{{ __('Each enquiry') }}

{{ __('Newest first. Time shown is working hours to first contact, or waited so far.') }}

@forelse ($rows as $row) @empty @endforelse
{{ __('Arrived') }} {{ __('Enquiry') }} {{ __('Owner and how assigned') }} {{ __('First contact') }} {{ __('Working hours') }} {{ __('Status') }}
{{ $row['received_at']->copy()->setTimezone($tz)->format('j M Y, H:i') }} {{ $row['title'] }}

{{ $row['organisation'] }} · {{ $row['source_label'] }}

{{ $row['owner'] }}

{{ $row['assigned_via_label'] }}

@if ($row['first_response_at']) {{ $row['first_response_at']->copy()->setTimezone($tz)->format('j M, H:i') }}

{{ __($channel[$row['first_response_type']] ?? '') }}{{ $row['first_response_by'] ? ' · '.$row['first_response_by'] : '' }}

@else {{ __('None yet') }} @endif
{{ $hours($row['hours']) }} @if ($row['status'] !== 'responded')

{{ __('so far') }}

@endif
{{ $statusMeta[$row['status']]['label'] }} @if ($row['director_alerted'])

{{ __('Director alerted') }}

@elseif ($row['owner_alerted'])

{{ __('Owner alerted') }}

@endif
@if ($rows->hasPages())
{{ $rows->links() }}
@endif
@else @php $groups = $tab === 'people' ? $byPerson : $bySource; @endphp

{{ $tab === 'people' ? __('By person') : __('By source') }}

{{ $tab === 'people' ? __('By the enquiry\'s owner. Fastest median first.') : __('By where the enquiry came from. Fastest median first.') }} {{ __('The median is the middle response time, so one slow enquiry does not hide the rest.') }}

@forelse ($groups as $group) @empty @endforelse
{{ $tab === 'people' ? __('Person') : __('Source') }} {{ __('Enquiries') }} {{ __('Answered') }} {{ __('Median working hours') }} {{ trans_choice('Within :n h|Within :n h', $ownerHours, ['n' => $ownerHours]) }} {{ __('Waiting') }} {{ __('Director alerts') }}
{{ $group['label'] }} {{ number_format($group['received']) }} {{ number_format($group['responded']) }} {{ $group['median'] === null ? __('Not available') : $hours($group['median']) }} {{ $group['within_pct'] === null ? __('Not available') : $group['within_pct'].'%' }} {{ number_format($group['waiting']) }} {{ number_format($group['director_alerts']) }}
@endif

{{ __('How it is measured') }}

  • {{ __('Arrived: when the request came in through the public request form.') }}
  • {{ __('First contact: the earliest call, email, WhatsApp, SMS, LinkedIn message, meeting or presentation we logged on the enquiry, its organisation or one of its contacts after it arrived. Notes and messages from the client do not count. Whoever made it, the client was answered.') }}
  • {{ __('Working hours: only the company\'s opening hours on its working days count, from HR settings. An enquiry at 16:30 on Friday answered at 08:30 on Monday took one working hour.') }}
  • {{ __('Closed unanswered: won, lost or deferred before any contact was logged. It has no response time.') }}