@extends('dashboard.admin.layouts.master')
@php
use App\Models\Crm\Lead;
$t = $report['totals'];
$maxReason = max([1, ...array_values($report['lost_reasons'])]);
@endphp
@section('toolbar')
@include('dashboard.admin.clinic.reports.partials.header', ['title' => trans('crm.report.title')])
@endsection
@section('content')
@include('dashboard.admin.clinic.reports.partials.filters', ['fields' => [], 'csv' => true])
{{ trans('crm.report.cohort_note') }}
{{-- Headline numbers --}}
@foreach ([
['bi-people', 'primary', $t['total'], trans('crm.report.leads')],
['bi-telephone-outbound', 'info', $t['contacted'], trans('crm.report.contacted')],
['bi-calendar-check', 'success', $t['converted'] . ' · ' . $t['rate'] . '%', trans('crm.report.converted_rate')],
['bi-x-circle', 'secondary', $t['lost'], trans('crm.statuses.lost')],
['bi-hourglass-split', 'warning', $t['uncontacted'], trans('crm.report.uncontacted')],
['bi-stopwatch', 'danger', $report['avg_hours_to_contact'] !== null ? trans('crm.report.hours', ['count' => $report['avg_hours_to_contact']]) : '—', trans('crm.report.avg_first_contact')],
] as [$icon, $color, $value, $label])
{{ $value }}
{{ $label }}
@endforeach
{{-- Pipeline: where the period's leads are now --}}
@if ($t['total'] > 0)
@foreach ($report['by_status'] as $status => $count)
@if ($count > 0)
{{ $count }}
@endif
@endforeach
@endif
@foreach ($report['by_status'] as $status => $count)
{{ trans('crm.statuses.' . $status) }} {{ $count }}
@endforeach
{{-- By source --}}
@include('dashboard.admin.crm.reports.table', ['rows' => $report['by_source'], 'label' => fn ($row) => trans('crm.sources.' . $row['source'])])
{{-- Lost reasons --}}
@forelse ($report['lost_reasons'] as $reason => $count)
{{ trans('crm.lost_reasons.' . $reason) }}{{ $count }}
@empty
{{ trans('clinic.reports_center.no_data') }}
@endforelse
{{-- By assignee --}}
@include('dashboard.admin.crm.reports.table', ['rows' => $report['by_assignee'], 'label' => fn ($row) => $row['name'] ?? trans('crm.list.unassigned')])
@endsection