@extends('client.layouts.dashboard') @section('title', 'Call Logs') @section('styles') @endsection @section('content')
Call Activity Report

View and analyze all call activity and auto-replies triggered

Export Call Data
{{ number_format($stats['total']) }}
Total Calls
{{ number_format($stats['incoming']) }}
Incoming
{{ number_format($stats['outgoing']) }}
Outgoing
{{ number_format($stats['missed']) }}
Missed
@php $totalCalls = $stats['total'] ?: 1; @endphp
Call Type Distribution
In {{ round(($stats['incoming']/$totalCalls)*100) }}% Out {{ round(($stats['outgoing']/$totalCalls)*100) }}% Miss {{ round(($stats['missed']/$totalCalls)*100) }}%
{{ round(($stats['missed']/$totalCalls)*100,1) }}%
Missed Rate
{{ $stats['incoming'] + $stats['outgoing'] }}
Connected
{{ number_format($stats['total']) }}
Total
boolean('has_note') ? 'checked' : '' }}>
{{-- Status Breakdown Card --}} @php $clUserIds = \App\Models\User::where('client_id', $callLogs->first()?->user?->client_id ?? 0)->pluck('id'); // Use the filtered query to get status stats $clStatusStatsQ = \App\Models\CallLog::whereIn('user_id', \App\Models\User::whereHas('client', fn($q) => $q->whereHas('clientAdmins', fn($q2) => $q2->where('id', auth()->guard('client_admin')->id())))->pluck('id')) ->whereNotNull('status_key')->where('status_key', '!=', ''); if(request('date_from')) $clStatusStatsQ->whereDate('call_time', '>=', request('date_from')); if(request('date_to')) $clStatusStatsQ->whereDate('call_time', '<=', request('date_to')); if(request('user_id')) $clStatusStatsQ->where('user_id', request('user_id')); if(request('search')) $clStatusStatsQ->where('phone_number','like','%'.request('search').'%'); $clStatusStats = $clStatusStatsQ->select('status_key', \Illuminate\Support\Facades\DB::raw('count(*) as count'))->groupBy('status_key')->pluck('count','status_key')->toArray(); $clWithNotes = \App\Models\CallLog::whereIn('user_id', \App\Models\User::whereHas('client', fn($q) => $q->whereHas('clientAdmins', fn($q2) => $q2->where('id', auth()->guard('client_admin')->id())))->pluck('id')) ->whereNotNull('status_note')->where('status_note','!=',''); if(request('date_from')) $clWithNotes->whereDate('call_time','>=',request('date_from')); if(request('date_to')) $clWithNotes->whereDate('call_time','<=',request('date_to')); $clWithNotesCount = $clWithNotes->count(); $clStatusColorMap = [ 'callback' => ['bg' => '#dbeafe', 'color' => '#1d4ed8', 'icon' => 'bi-telephone-forward'], 'follow_up' => ['bg' => '#fef3c7', 'color' => '#b45309', 'icon' => 'bi-arrow-repeat'], 'interested' => ['bg' => '#dcfce7', 'color' => '#15803d', 'icon' => 'bi-hand-thumbs-up'], 'not_interested' => ['bg' => '#fee2e2', 'color' => '#b91c1c', 'icon' => 'bi-hand-thumbs-down'], 'converted' => ['bg' => '#d1fae5', 'color' => '#065f46', 'icon' => 'bi-trophy'], 'closed' => ['bg' => '#e5e7eb', 'color' => '#374151', 'icon' => 'bi-check-circle'], ]; $clDefaultColor = ['bg' => '#f3f4f6', 'color' => '#6b7280', 'icon' => 'bi-tag']; @endphp @if(!empty($clStatusStats) || $clWithNotesCount > 0)
Call Status Breakdown
{{ array_sum($clStatusStats) }} tagged calls
@foreach($clStatusStats as $sk => $cnt) @php $c = $clStatusColorMap[strtolower($sk)] ?? $clDefaultColor; $lbl = ($statusOptions[$sk] ?? ucfirst(str_replace('_',' ',$sk))); @endphp @endforeach
@endif
Call Log Records
Showing {{ $callLogs->firstItem() ?? 0 }}-{{ $callLogs->lastItem() ?? 0 }} of {{ $callLogs->total() }}
@forelse($callLogs as $log) @empty @endforelse
UserPhone NumberTypeStatusNoteDurationAuto-ReplyTime
{{ strtoupper(substr($log->user->name ?? 'U', 0, 1)) }}
{{ $log->user->name ?? 'Unknown' }}
{{ $log->phone_number }} @php $channelLogs = ($log->smsLogs ?? collect())->sortByDesc(fn($i) => optional($i->sent_at)->timestamp ?? optional($i->created_at)->timestamp ?? 0); $smsChannelLog = $channelLogs->first(fn($i) => ($i->channel ?? 'sms') === 'sms'); $whatsAppChannelLog = $channelLogs->first(fn($i) => ($i->channel ?? '') === 'whatsapp'); $displayContactName = $log->contact_name ?: optional($smsChannelLog)->contact_name ?: optional($whatsAppChannelLog)->contact_name; @endphp @if($displayContactName)
{{ $displayContactName }}@endif
@php $nct = strtolower((string)$log->call_type); if(in_array($nct,['incoming','answered_externally','wifi'],true)) $nct='incoming'; elseif($nct==='outgoing') $nct='outgoing'; else $nct='missed'; @endphp @if($nct==='incoming')Incoming @elseif($nct==='outgoing')Outgoing @elseMissed@endif @if($log->status_label){{ $log->status_label }} @else@endif
{{ $log->status_note ?: '—' }}
@if($log->call_duration){{ gmdate('H:i:s', $log->call_duration) }} @else-@endif @if($log->sms_sent)
@if($smsChannelLog)SMS@endif @if($whatsAppChannelLog)WA@endif @if(!$smsChannelLog && !$whatsAppChannelLog)Sent@endif
@elseNo@endif
{{ optional($log->call_time)->format('M d, Y') ?? $log->created_at->format('M d, Y') }}
{{ optional($log->call_time)->format('h:i A') ?? $log->created_at->format('h:i A') }}

No call logs found

@if($callLogs->hasPages()) @endif
@endsection