@extends('client.layouts.dashboard') @section('title', 'Dashboard') @section('styles') @endsection @section('content') @php $trendPercent = function ($current, $previous) { if ($previous == 0) return $current > 0 ? 100 : 0; return round((($current - $previous) / $previous) * 100, 1); }; $trendClass = function ($current, $previous) { if ($current > $previous) return 'up'; if ($current < $previous) return 'down'; return 'neutral'; }; $trendIcon = function ($current, $previous) { if ($current > $previous) return 'bi-arrow-up-short'; if ($current < $previous) return 'bi-arrow-down-short'; return 'bi-dash'; }; @endphp @if($crmStats['overdue_followups'] > 0) @endif {{-- ===== ROW 1: HERO STATS ===== --}}
Overview
{{ $stats['total_users'] }}
Total Users
{{ $stats['active_users'] }} active @if($stats['pending_users'] > 0) {{ $stats['pending_users'] }} pending @endif
{{ number_format($stats['sms_today']) }}
SMS Today
{{ number_format($stats['sms_this_week']) }} week {{ number_format($stats['total_sms']) }} total
{{ number_format($stats['whatsapp_today']) }}
WhatsApp Today
{{ number_format($stats['whatsapp_this_week']) }} week {{ number_format($stats['total_whatsapp']) }} total
{{ number_format($stats['calls_today']) }}
Calls Today
{{ $stats['incoming_calls'] }} in {{ $stats['outgoing_calls'] }} out {{ $stats['missed_calls'] }} missed
{{-- ===== ROW 2: WEEKLY TREND COMPARISON ===== --}}
Week-over-Week Trends
@php $trends = [ ['label'=>'SMS','icon'=>'bi-chat-dots','this'=>$weekComparison['sms_this_week'],'last'=>$weekComparison['sms_last_week'],'color'=>'#11998e'], ['label'=>'WhatsApp','icon'=>'bi-whatsapp','this'=>$weekComparison['whatsapp_this_week'],'last'=>$weekComparison['whatsapp_last_week'],'color'=>'#25D366'], ['label'=>'Calls','icon'=>'bi-telephone','this'=>$weekComparison['calls_this_week'],'last'=>$weekComparison['calls_last_week'],'color'=>'#4facfe'], ['label'=>'New Users','icon'=>'bi-person-plus','this'=>$weekComparison['users_this_week'],'last'=>$weekComparison['users_last_week'],'color'=>'#764ba2'], ]; @endphp @foreach($trends as $t)
{{ $t['label'] }}
{{ number_format($t['this']) }}
{{ abs($trendPercent($t['this'], $t['last'])) }}%
vs {{ number_format($t['last']) }} last week
@php $pct = ($t['last'] > 0) ? min(($t['this']/$t['last'])*100, 200) : ($t['this'] > 0 ? 100 : 0); @endphp
@endforeach
{{-- ===== ROW 2.5: CRM OVERVIEW & PIPELINE FUNNEL ===== --}}
CRM & Lead Pipeline
{{-- CRM Stats Widget --}}
CRM Overview
{{ number_format($crmStats['total_leads']) }}
Total Leads
{{ number_format($crmStats['leads_today']) }}
Leads Today
{{ number_format($crmStats['pending_followups']) }}
Pending Tasks
{{ $crmStats['conversion_rate'] }}%
Conversion Rate
{{-- Graphical Pipeline Funnel --}}
Lead Pipeline Funnel
@php $maxCount = collect($pipelineData)->max('count') ?: 1; @endphp
@foreach($pipelineData as $pipe)
{{ $pipe['label'] }} {{ $pipe['count'] }}
@php $width = ($pipe['count'] / $maxCount) * 100; @endphp
@endforeach
{{-- ===== ROW 3: SUBSCRIPTION + USAGE + QUICK KPIs ===== --}}
{{-- Subscription --}}
Subscription Status
{{ $subscriptionInfo['days_remaining'] }}
days
remaining
{{ ucfirst($subscriptionInfo['type']) }} @if($subscriptionInfo['is_active']) Active @else Inactive @endif
Expires: {{ $subscriptionInfo['ends_at'] ? $subscriptionInfo['ends_at']->format('M d, Y') : 'N/A' }}
{{-- Usage Limits --}}
Usage Limits
@php $userPct = $client->max_users > 0 ? round(($stats['total_users']/$client->max_users)*100) : 0; @endphp
Users {{ $stats['total_users'] }} / {{ $client->max_users }}
@php $adminPct = $client->max_client_admins > 0 ? round(($stats['client_admins']/$client->max_client_admins)*100) : 0; @endphp
Admins {{ $stats['client_admins'] }} / {{ $client->max_client_admins }}
{{ $stats['sms_enabled_users'] }}
SMS ON
{{ $stats['whatsapp_enabled_users'] }}
WA ON
{{ $stats['inactive_users'] }}
Inactive
{{-- Quick Actions --}}
Quick Actions
{{ $stats['avg_sms_per_user'] }}
Avg SMS/User
{{ $stats['avg_calls_per_user'] }}
Avg Calls/User
{{-- ===== ROW 4: CHARTS ===== --}}
Activity Analytics
Messaging Activity
Channel Mix
SMS {{ number_format($stats['total_sms']) }} WA {{ number_format($stats['total_whatsapp']) }}
{{-- ===== ROW 5: CALL CHART + HOURLY HEATMAP ===== --}}
Call Activity (7 Days)
Today's Hourly Activity
{{-- ===== ROW 6: USER PERFORMANCE TABLE ===== --}}
User Performance
User-wise Detailed Statistics
View All Users
@forelse($userPerformance as $i => $u) @empty @endforelse
# User SMS
Total / Today
WhatsApp
Total / Today
Calls
Total / Today
Total Activity Status
{{ $i+1 }}
{{ strtoupper(substr($u->name,0,1)) }}
{{ $u->name }}
{{ $u->phone }}
{{ $u->sms_count }} / {{ $u->sms_today }} {{ $u->whatsapp_count }} / {{ $u->whatsapp_today }} {{ $u->call_count }} / {{ $u->calls_today }} {{ $u->sms_count + $u->whatsapp_count + $u->call_count }} @if($u->is_active)Active@elseInactive@endif
No active users yet
{{-- ===== ROW 7: RECENT MESSAGES + RECENT USERS ===== --}}
Recent Messages
View All
@forelse($recentMessages as $msg) @empty @endforelse
UserPhoneChannelStatusTime
{{ $msg->user->name ?? 'Unknown' }} {{ $msg->phone_number }} @if($msg->contact_name)
{{ $msg->contact_name }}
@endif
@if($msg->channel === 'whatsapp') WA @else SMS @endif @if($msg->status === 'sent')Sent @elseif($msg->status === 'pending')Pending @elseFailed@endif {{ $msg->created_at ? $msg->created_at->diffForHumans() : 'N/A' }}
No messages yet
Recent Users
View All
@forelse($recentUsers as $user) @empty @endforelse
NameStatusJoined
{{ $user->name }}
{{ $user->phone }}
@if($user->approval_status === 'approved')Approved @elseif($user->approval_status === 'pending')Pending @elseRejected@endif {{ $user->created_at ? $user->created_at->diffForHumans() : 'N/A' }}
No users yet
{{-- ===== ROW 8: MONTHLY SUMMARY KPIs ===== --}}
Monthly Summary
@php $monthKpis = [ ['label'=>'SMS This Month','val'=>$stats['sms_this_month'],'icon'=>'bi-chat-dots-fill','bg'=>'linear-gradient(135deg,#11998e,#38ef7d)'], ['label'=>'WA This Month','val'=>$stats['whatsapp_this_month'],'icon'=>'bi-whatsapp','bg'=>'linear-gradient(135deg,#00b09b,#96c93d)'], ['label'=>'Calls This Month','val'=>$stats['calls_this_month'],'icon'=>'bi-telephone-fill','bg'=>'linear-gradient(135deg,#4facfe,#00f2fe)'], ['label'=>'Messages This Month','val'=>$stats['messages_this_month'],'icon'=>'bi-envelope-fill','bg'=>'linear-gradient(135deg,#a18cd1,#fbc2eb)'], ['label'=>'Active Templates','val'=>$stats['active_templates'].'/'.$stats['total_templates'],'icon'=>'bi-file-text-fill','bg'=>'linear-gradient(135deg,#f093fb,#f5576c)'], ['label'=>'SMS Failed','val'=>$stats['sms_failed'],'icon'=>'bi-x-circle-fill','bg'=>'linear-gradient(135deg,#ff6a88,#ff99ac)'], ['label'=>'WA Failed','val'=>$stats['whatsapp_failed'],'icon'=>'bi-x-circle-fill','bg'=>'linear-gradient(135deg,#ef4444,#f87171)'], ['label'=>'Client Admins','val'=>$stats['client_admins'],'icon'=>'bi-person-badge-fill','bg'=>'linear-gradient(135deg,#fccb90,#d57eeb)'], ]; @endphp @foreach($monthKpis as $k)
{{ is_numeric($k['val']) ? number_format($k['val']) : $k['val'] }}
{{ $k['label'] }}
@endforeach
@endsection @section('scripts') @endsection