@php
$kpis = $data['kpis'] ?? [];
$perDay = $data['per_day'] ?? [];
$topExt = $data['top_ext'] ?? [];
$departments = $data['departments'] ?? [];
$reportType = $data['type'] ?? 'management_summary';
$reportLabel = $schedule->reportTypeLabel();
$companyName = app(\App\Services\PbxDefaultsService::class)->companyName();
$freqLabel = ucfirst($schedule->frequencyLabel());
@endphp
@extends('emails.layouts.base', [
'subject' => "{$companyName} โ {$reportLabel}",
'title' => $reportLabel,
'subtitle' => "{$freqLabel} report ยท {$fromDate} โ {$toDate}",
'icon' => '๐',
'iconColor' => '#3b82f6',
])
@section('content')
{{-- KPI Hero Tiles --}}
@if(!empty($kpis))
|
Total Calls
{{ number_format($kpis['total'] ?? 0) }}
|
|
|
Answer Rate
{{ $kpis['answer_rate'] ?? 0 }}%
|
|
|
Avg Talk
{{ $kpis['avg_talk'] ?? '0:00' }}
|
|
|
Missed
{{ number_format($kpis['missed_outstanding'] ?? $kpis['noanswer'] ?? 0) }}
|
|
{{-- Secondary metrics --}}
|
Total Talk: {{ $kpis['talk_human'] ?? '0:00' }} ยท
Busiest Hour: {{ $kpis['busiest_hour'] ?? 'โ' }} ยท
Answered: {{ number_format($kpis['answered'] ?? 0) }}
|
@endif
{{-- Network Health --}}
@php $netHealth = $data['network_health'] ?? []; @endphp
@if(!empty($netHealth['available']))
| ๐ถ Network Quality |
{{ $netHealth['grade'] }}
|
|
Avg RTT: {{ $netHealth['avg_rtt'] }}ms ยท
Best: {{ $netHealth['min_rtt'] }}ms ยท
Worst: {{ $netHealth['max_rtt'] }}ms ยท
{{ $netHealth['endpoints'] }} endpoints monitored
|
|
@endif
{{-- Direction Split (Inbound / Outbound / Internal) --}}
@php $direction = $data['direction'] ?? []; @endphp
@if(!empty($direction) && $reportType !== 'missed_calls')
|
โ Inbound
{{ number_format($direction['inbound']['total'] ?? 0) }}
{{ number_format($direction['inbound']['answered'] ?? 0) }} answered
|
|
|
โ Outbound
{{ number_format($direction['outbound']['total'] ?? 0) }}
{{ number_format($direction['outbound']['answered'] ?? 0) }} connected
|
|
|
โ Internal
{{ number_format($direction['internal']['total'] ?? 0) }}
{{ number_format($direction['internal']['answered'] ?? 0) }} answered
|
|
@endif
{{-- Top Extensions (prominent, first data section) --}}
@if(!empty($topExt))
๐ Top Extensions
| Ext |
Total |
In |
Out |
Int |
Missed |
Talk |
@foreach($topExt as $ext)
{{ $ext['ext'] }}@if(!empty($ext['name'])) {{ $ext['name'] }}@endif |
{{ $ext['calls'] }} |
{{ $ext['inbound'] ?? 0 }} |
{{ $ext['outbound'] ?? 0 }} |
{{ $ext['internal'] ?? 0 }} |
{{ $ext['missed'] ?? 0 }} |
{{ $ext['talk'] }} |
@endforeach
@endif
{{-- Top Contacts (phonebook customers by volume) --}}
@php $topContacts = $data['top_contacts'] ?? []; @endphp
๐ค Top Contacts (Phonebook)
@if(!empty($topContacts))
| Contact |
Total |
In |
Out |
@foreach($topContacts as $contact)
{{ $contact['name'] }} {{ $contact['number'] }} |
{{ $contact['total'] }} |
{{ $contact['inbound'] }} |
{{ $contact['outbound'] }} |
@endforeach
@else
|
๐ Your phonebook is empty. Import your customer contacts to unlock caller-name display, missed-call resolution tracking, and this Top Contacts report.
Speak to your V-Connect administrator about importing your customer database.
|
@endif
{{-- Calls per day mini-chart (table-based bars for email client compatibility) --}}
@if(!empty($perDay))
Daily Call Volume
@php $maxCalls = max(array_column($perDay, 'total') ?: [1]); @endphp
@foreach(array_slice($perDay, -14) as $day)
@php
$totalPct = max(5, round($day['total'] / $maxCalls * 100));
$ansPct = $day['total'] > 0 ? round($day['answered'] / $day['total'] * 100) : 0;
@endphp
| {{ $day['date'] }} |
| |
@if($ansPct < 100) | @endif
|
{{ $day['total'] }} |
@endforeach
Answered
Unanswered
@endif
{{-- Department breakdown with traffic-light --}}
@if(!empty($departments))
Department Performance
| Department |
Calls |
Answer % |
Talk |
@foreach(array_slice($departments, 0, 8) as $dept)
@php
$rate = $dept['answer_rate'];
$rateColor = $rate >= 80 ? '#16a34a' : ($rate >= 60 ? '#d97706' : '#dc2626');
$rateBg = $rate >= 80 ? '#f0fdf4' : ($rate >= 60 ? '#fffbeb' : '#fef2f2');
@endphp
| {{ $dept['name'] }} |
{{ $dept['total'] }} |
{{ $rate }}%
|
{{ $dept['talk_human'] }} |
@endforeach
@else
|
๐ข Did you know? Group your users into departments to see team-level answer rates, talk time, and performance scoring right here.
Configure departments under Applications โ Departments in your V-Connect admin panel.
|
@endif
{{-- โโโ CALL ANALYTICS SPECIFIC: Hourly + Duration Bands โโโ --}}
@if($reportType === 'call_analytics')
@php $perHour = $data['per_hour'] ?? []; $durationBands = $data['duration_bands'] ?? []; @endphp
@if(!empty($perHour))
๐ Hourly Distribution
@php $maxHour = max(array_column($perHour, 'total') ?: [1]); @endphp
@foreach($perHour as $h)
@if($h['total'] > 0)
@php $hPct = max(5, round($h['total'] / $maxHour * 100)); @endphp
| {{ $h['hour'] }} |
|
{{ $h['total'] }} |
@endif
@endforeach
@endif
@if(!empty($durationBands))
โฑ Call Duration Distribution
| Duration |
Calls |
@foreach($durationBands as $band => $count)
| {{ $band }} |
{{ number_format($count) }} |
@endforeach
Longest call: {{ $kpis['longest_call'] ?? 'โ' }} ยท
Avg duration: {{ $kpis['avg_duration'] ?? 'โ' }}
@endif
@endif
{{-- โโโ MISSED CALLS SPECIFIC: KPIs + Top Missed โโโ --}}
@if($reportType === 'missed_calls')
@php $missedRows = $data['rows'] ?? []; @endphp
@if(!empty($kpis))
|
Total Missed
{{ number_format($kpis['total_attempts'] ?? 0) }}
|
|
|
Unique Callers
{{ number_format($kpis['unique_callers'] ?? 0) }}
|
|
|
Outstanding
{{ number_format($kpis['outstanding'] ?? 0) }}
|
|
|
Resolved
{{ number_format($kpis['resolved'] ?? 0) }}
|
|
|
Resolution %
{{ $kpis['resolution_rate'] ?? 0 }}%
|
|
@endif
@if(!empty($missedRows))
๐ฑ Top Missed Callers
| Caller |
Attempts |
Last Missed |
@foreach(array_slice($missedRows, 0, 10) as $row)
{{ $row['name'] ?: $row['number'] }}@if($row['name']) {{ $row['number'] }}@endif |
{{ $row['attempts'] }} |
{{ \Illuminate\Support\Carbon::parse($row['last'])->format('d M H:i') }} |
@endforeach
@endif
@endif
{{-- Report info footer --}}
{{ $companyName }} ยท {{ $freqLabel }} Report ยท {{ $fromDate }} โ {{ $toDate }}
Schedule: {{ $schedule->name }} ยท Attachment: {{ strtoupper($schedule->format) }}
|
@endsection