@extends('dashboard.admin.layouts.master')
@php
$money = fn ($amount) => number_format((float) $amount, 2);
$b = $stats['bookings'];
$statusColors = \App\Models\Clinic\Booking::STATUS_COLORS;
$statusChart = [
'labels' => array_map(fn ($s) => trans('clinic.bookings.statuses.' . $s), array_keys($statusColors)),
'data' => array_map(fn ($s) => $b['by_status'][$s] ?? 0, array_keys($statusColors)),
'colors' => array_values($statusColors),
];
$typeChart = [
'labels' => array_map(fn ($t) => trans('clinic.bookings.' . $t), ['visit', 'online', 'followup']),
'data' => array_map(fn ($t) => $b['by_type'][$t] ?? 0, ['visit', 'online', 'followup']),
];
@endphp
@section('toolbar')
@include('dashboard.admin.clinic.reports.partials.header', ['title' => trans('clinic.reports_center.statistics')])
@endsection
@section('content')
@include('dashboard.admin.clinic.reports.partials.filters', ['fields' => ['branch', 'clinic', 'doctor']])
{{-- Headline numbers --}}
@foreach ([
['bi-calendar-check', 'primary', $b['total'], trans('clinic.reports_center.stat_bookings')],
['bi-check2-circle', 'success', ($b['by_status']['completed'] ?? 0) . ' · ' . $b['completion_rate'] . '%', trans('clinic.reports_center.stat_completed')],
['bi-x-circle', 'danger', ($b['by_status']['cancelled'] ?? 0) . ' · ' . $b['cancel_rate'] . '%', trans('clinic.reports_center.stat_cancelled')],
['bi-cash-coin', 'info', $money($stats['money']['revenue']), trans('clinic.reports_center.total_revenue')],
['bi-camera-video', 'warning', $stats['online']['total'], trans('clinic.reports_center.stat_online')],
['bi-star-fill', 'warning', ($stats['ratings']['doctor_avg'] ?? '—') . ' / 5', trans('clinic.reports_center.stat_rating', ['count' => $stats['ratings']['count']])],
] as [$icon, $color, $value, $label])
{{ $value }}
{{ $label }}
@endforeach
{{-- Bookings over time + status + type --}}
{{-- Money, online consultations, inquiries, activity --}}
@foreach ([
['bi-wallet2', trans('clinic.reports_center.payments'), [
[trans('clinic.reports_center.total_revenue'), $money($stats['money']['revenue'])],
[trans('clinic.reports_center.online_paid'), $money($stats['money']['online_paid'])],
[trans('clinic.reports_center.unpaid_amount'), $money($stats['money']['unpaid_amount'])],
[trans('clinic.reports_center.doctors_shares'), $money($stats['money']['doctor_share'])],
[trans('clinic.reports_center.profit'), $money($stats['money']['center_share'])],
]],
['bi-camera-video', trans('clinic.reports_center.online_consultations'), [
[trans('clinic.reports_center.stat_bookings'), $stats['online']['total']],
[trans('clinic.bookings.statuses.completed'), $stats['online']['completed']],
[trans('clinic.bookings.statuses.cancelled'), $stats['online']['cancelled']],
]],
['bi-chat-dots', trans('clinic.reports_center.inquiries'), [
[trans('clinic.reports_center.contact_messages'), $stats['inquiries']['contacts']],
[trans('clinic.reports_center.contact_answered'), $stats['inquiries']['contacts_answered']],
[trans('clinic.reports_center.chat_from_patients'), $stats['inquiries']['chat_from_patients']],
[trans('clinic.reports_center.chat_replies'), $stats['inquiries']['chat_replies']],
]],
['bi-activity', trans('clinic.reports_center.activity'), [
[trans('clinic.reports_center.new_patients'), $stats['activity']['new_patients']],
[trans('sidebar.offer_subscriptions'), $stats['activity']['offer_subscriptions']],
[trans('sidebar.medicine_orders'), $stats['activity']['medicine_orders']],
[trans('clinic.reports_center.reviews_with_comments'), $stats['ratings']['comments']],
[trans('clinic.reports_center.clinic_rating'), ($stats['ratings']['clinic_avg'] ?? '—') . ' / 5'],
]],
] as [$icon, $title, $lines])
{{ $title }}
@foreach ($lines as [$label, $value])
{{ $label }}{{ $value }}
@endforeach
@endforeach
{{-- Clinic and doctor performance --}}
| {{ trans('clinic.reports_center.clinic') }} | {{ trans('clinic.reports_center.stat_bookings') }} |
{{ trans('clinic.bookings.statuses.completed') }} | {{ trans('clinic.bookings.statuses.cancelled') }} | {{ trans('clinic.reports_center.total_revenue') }} |
@forelse ($stats['clinics'] as $row)
{{ $row['model']?->name ?? '—' }} {{ $row['model']?->branch?->name }} |
{{ $row['bookings'] }} | {{ $row['completed'] }} | {{ $row['cancelled'] }} | {{ $money($row['revenue']) }} |
@empty
| {{ trans('clinic.reports_center.no_data') }} |
@endforelse
| {{ trans('clinic.doctors.title') }} | {{ trans('clinic.reports_center.stat_bookings') }} |
{{ trans('clinic.bookings.statuses.completed') }} | {{ trans('clinic.doctors.tab_ratings') }} | {{ trans('clinic.reports_center.total_revenue') }} |
@forelse ($stats['doctors'] as $row)
|
@if ($row['model'])
{{ $row['model']->name }}
@else — @endif
|
{{ $row['bookings'] }} | {{ $row['completed'] }} |
@if ($row['model']?->averageRating()) {{ number_format($row['model']->averageRating(), 1) }}@else — @endif |
{{ $money($row['revenue']) }} |
@empty
| {{ trans('clinic.reports_center.no_data') }} |
@endforelse
{{-- Latest ratings and comments --}}
@forelse ($stats['ratings']['latest'] as $review)
{{ $review->booking?->patient?->name }} → {{ $review->booking?->doctor?->name }}
@if ($review->doctor_comment)
{{ $review->doctor_comment }}
@endif
@if ($review->clinic_comment)
{{ $review->clinic_comment }}
@endif
@include('dashboard.admin.Site.feedback.partials.stars', ['rating' => (int) $review->doctor_rating])
@empty
{{ trans('clinic.doctors.no_reviews') }}
@endforelse
@endsection
@section('js')
@endsection