@extends('layouts.app') @section('title', __('messages.dashboard')) @section('styles') @endsection @section('content') @php $dateTimeFormat = trim(($displayDateFormat ?? 'd/m/Y') . ' H:i'); @endphp

{{ __('messages.dashboard') }}

{{ $showSimpleDashboard ? __('messages.dashboard_simple_subtitle') : __('messages.dashboard_ticket_subtitle') }}

{{ __('messages.last_seen') }}: @if ($lastSeenAt) {{ $lastSeenAt->format($dateTimeFormat) }} @else - @endif
{{-- ── Accès Rapide ─────────────────────────────────────── --}} {{-- ─────────────────────────────────────────────────────── --}} @php $topTab = $topTab ?? 'helpdesk'; @endphp @if ($canUseAdvancedDashboard && $canViewGlobal) @endif
@if ($canViewGlobal)
@endif
@if ($showSimpleDashboard)

{{ __('messages.total_tickets') }}

{{ number_format((int) $stats['total_tickets']) }}

{{ __('messages.general_statistics') }}

{{ __('messages.tickets_assigned_to_me') }}

{{ number_format((int) $stats['assigned_to_me']) }}

{{ __('messages.my_tickets') }}

{{ __('messages.active_tickets') }}

{{ number_format((int) $stats['active_tickets']) }}

{{ __('messages.open_tickets') }}

{{ __('messages.closed_tickets') }}

{{ number_format((int) $stats['closed_tickets']) }}

{{ __('messages.status_breakdown') }}

{{ __('messages.ticket_volume_over_time') }} {{ __('messages.range') }}: {{ $filters['start_date'] }} - {{ $filters['end_date'] }}
{{ __('messages.recent_tickets') }}
@forelse ($recentTickets as $ticket) @php $statusColor = (string) ($ticket->statusRecord->color ?? '#1d4ed8'); if (!str_starts_with($statusColor, '#')) { $statusColor = '#' . ltrim($statusColor, '#'); } $statusTextColor = (string) ($ticket->statusRecord->text_color ?? '#ffffff'); if (!str_starts_with($statusTextColor, '#')) { $statusTextColor = '#' . ltrim($statusTextColor, '#'); } @endphp
#{{ $ticket->ID }} - {{ \App\Models\Ticket::decodeLegacyText($ticket->getRawOriginal('title') ?? $ticket->title ?? '') }} {{ \App\Models\Ticket::decodeLegacyText($ticket->statusRecord->name ?? $ticket->status) }}
{{ \App\Models\Ticket::decodeLegacyText($ticket->user->name ?? '-') }} {{ \Carbon\Carbon::createFromTimestamp((int) $ticket->timestamp)->format($dateTimeFormat) }}
@empty
{{ __('messages.no_recent_tickets') }}
@endforelse
{{ __('messages.status_distribution') }}

{{ number_format((int) $statusChart['total']) }}

{{ __('messages.total_tickets') }}
{{ __('messages.status_breakdown') }}
@php $totalStatsCount = $statusChart['total'] ?: 1; @endphp @foreach ($statusCards as $item) @php $percentage = ($item['count'] / $totalStatsCount) * 100; @endphp
{{ $item['name'] }} {{ number_format((int) $item['count']) }} ({{ number_format($percentage, 1) }}%)
@endforeach
@else
@if ($canViewGlobal)

{{ __('messages.total_tickets') }}

{{ number_format((int) $stats['total_tickets']) }}

{{ __('messages.tickets_assigned_to_me') }}

{{ number_format((int) $stats['assigned_to_me']) }}

{{ __('messages.tickets_created_today') }}

{{ number_format((int) $stats['created_today']) }}

{{ __('messages.users_online') }}

{{ number_format((int) $stats['online_users']) }}

{{ number_format((int) $stats['active_tickets']) }} {{ __('messages.active_tickets') }}

{{ __('messages.ticket_volume_over_time') }} {{ __('messages.range') }}: {{ $filters['start_date'] }} - {{ $filters['end_date'] }}
{{ __('messages.recent_tickets') }}
@forelse ($recentTickets as $ticket) @php $statusColor = (string) ($ticket->statusRecord->color ?? '#1d4ed8'); if (!str_starts_with($statusColor, '#')) { $statusColor = '#' . ltrim($statusColor, '#'); } $statusTextColor = (string) ($ticket->statusRecord->text_color ?? '#ffffff'); if (!str_starts_with($statusTextColor, '#')) { $statusTextColor = '#' . ltrim($statusTextColor, '#'); } @endphp
#{{ $ticket->ID }} - {{ \App\Models\Ticket::decodeLegacyText($ticket->getRawOriginal('title') ?? $ticket->title ?? '') }} {{ \App\Models\Ticket::decodeLegacyText($ticket->statusRecord->name ?? $ticket->status) }}
{{ \App\Models\Ticket::decodeLegacyText($ticket->user->name ?? '-') }} {{ \Carbon\Carbon::createFromTimestamp((int) $ticket->timestamp)->format($dateTimeFormat) }}
@empty
{{ __('messages.no_recent_tickets') }}
@endforelse
@endif

{{ __('messages.total_tickets') }}

{{ number_format((int) $stats['total_tickets']) }}

{{ __('messages.tickets_assigned_to_me') }}

{{ number_format((int) $stats['assigned_to_me']) }}

{{ __('messages.tickets_created_today') }}

{{ number_format((int) $stats['created_today']) }}

{{ __('messages.users_online') }}

{{ number_format((int) $stats['online_users']) }}

{{ number_format((int) $stats['active_tickets']) }} {{ __('messages.active_tickets') }}

{{ __('messages.ticket_volume_over_time') }} {{ __('messages.range') }}: {{ $filters['start_date'] }} - {{ $filters['end_date'] }}
{{ __('messages.recent_tickets') }}
@forelse ($recentTickets as $ticket) @php $statusColor = (string) ($ticket->statusRecord->color ?? '#1d4ed8'); if (!str_starts_with($statusColor, '#')) { $statusColor = '#' . ltrim($statusColor, '#'); } $statusTextColor = (string) ($ticket->statusRecord->text_color ?? '#ffffff'); if (!str_starts_with($statusTextColor, '#')) { $statusTextColor = '#' . ltrim($statusTextColor, '#'); } @endphp
#{{ $ticket->ID }} - {{ \App\Models\Ticket::decodeLegacyText($ticket->getRawOriginal('title') ?? $ticket->title ?? '') }} {{ \App\Models\Ticket::decodeLegacyText($ticket->statusRecord->name ?? $ticket->status) }}
{{ \App\Models\Ticket::decodeLegacyText($ticket->user->name ?? '-') }} {{ \Carbon\Carbon::createFromTimestamp((int) $ticket->timestamp)->format($dateTimeFormat) }}
@empty
{{ __('messages.no_recent_tickets') }}
@endforelse
{{ __('messages.status_distribution') }}

{{ number_format((int) $statusChart['total']) }}

{{ __('messages.total_tickets') }}
{{ __('messages.status_breakdown') }}
@php $totalStatsCount = $statusChart['total'] ?: 1; @endphp @foreach ($statusCards as $item) @php $percentage = ($item['count'] / $totalStatsCount) * 100; @endphp
{{ $item['name'] }} {{ number_format((int) $item['count']) }} ({{ number_format($percentage, 1) }}%)
@endforeach
@if ($canViewGlobal)
@if ($agentPerformance->isEmpty())
{{ __('messages.no_agent_data') }}
@else
📈 {{ __('Résumé de Performance') }} {{ __('Voir Rapport Complet') }}
@foreach ($agentPerformance as $agent) @endforeach
{{ __('Agent') }} {{ __('Tickets Assignés') }} {{ __('Action') }}
{{ strtoupper(substr($agent->agent_name, 0, 1)) }}
{{ $agent->agent_name }}
{{ $agent->total }}
⏱️ {{ __('Délais Moyens') }}

{{ __('Résolution Moyenne') }}

{{ $avgResolutionTime > 0 ? round($avgResolutionTime / 86400, 1) : 0 }} jours


* Calculé sur la base des tickets clôturés dans la période.

📊 {{ __('Volume par Agent') }}
@endif
🏢 {{ __('Aperçu par Affiliés') }} {{ __('Détails Affiliés') }}
@foreach ($agencyStats as $a) @endforeach
Affilié Tickets
{{ $a->agency_name }} {{ $a->total }}

Analysez la répartition catégorielle et géographique complète.

Ouvrir le Rapport Complet
{{-- ═══════════════════════════════════════════════════════════ --}} {{-- TAB: RÉSERVATIONS (Packages + Visa sub-tabs) --}} {{-- ═══════════════════════════════════════════════════════════ --}}
@php $resSubTab = request('res_tab', 'overview'); @endphp {{-- Quick Actions --}} {{-- ── Sub-tabs: Overview | Packages | Visa ── --}}
{{-- ═══ SUB-TAB: Vue d'ensemble ═══ --}}
{{-- KPI Cards --}}

Total Réservations

{{ number_format($travelCount + $visaCount) }}

{{ $travelCount }} voyage + {{ $visaCount }} visa

Revenu Total

{{ number_format($totalRevenue, 0, ',', ' ') }}

DA

Commissions

{{ number_format($totalCommission, 0, ',', ' ') }}

DA

Reste à Toucher

{{ number_format($totalRemaining, 0, ',', ' ') }}

DA

{{-- Second row: paid + breakdown --}}
{{ number_format($totalPaid, 0, ',', ' ') }} DA
Total Payé
{{ number_format($travelRevenue, 0, ',', ' ') }} DA
Voyage
{{ number_format($visaRevenue, 0, ',', ' ') }} DA
Visa
{{ number_format($totalCommission, 0, ',', ' ') }} DA
Commissions Agence
{{-- Charts + Top Clients --}}
Revenu Mensuel (12 mois) Voyage vs Visa
Top Clients
@forelse ($topClients as $i => $tc)
{{ strtoupper(substr($tc['name'], 0, 1)) }}
{{ $tc['name'] }}
CA cumulé
{{ number_format($tc['total'], 0, ',', ' ') }} DA
@empty

Aucune donnée

@endforelse
{{-- Status + Recent --}}
Statuts Voyage
@forelse ($travelStatusCounts as $label => $count) @php $pct = $travelCount > 0 ? round(($count / $travelCount) * 100) : 0; $color = match(strtolower($label)) { 'confirmed' => '#10b981', 'pending' => '#f59e0b', 'cancelled' => '#ef4444', 'in progress' => '#3b82f6', default => '#6b7280' }; @endphp
{{ $label }} {{ $count }} ({{ $pct }}%)
@empty
Aucune réservation voyage
@endforelse
Statuts Visa
@forelse ($visaStatusCounts as $label => $count) @php $pct = $visaCount > 0 ? round(($count / $visaCount) * 100) : 0; $color = match(strtolower($label)) { 'approved' => '#10b981', 'pending' => '#f59e0b', 'processing' => '#3b82f6', 'rejected' => '#ef4444', 'cancelled' => '#6b7280', default => '#6b7280' }; @endphp
{{ $label }} {{ $count }} ({{ $pct }}%)
@empty
Aucune réservation visa
@endforelse
Réservations Récentes
@forelse ($recentReservations as $rr)
{{ $rr['reference'] }} {{ $rr['status'] }}
{{ $rr['client'] }}
{{ number_format($rr['amount'], 0, ',', ' ') }} DA {{ $rr['created_at']->diffForHumans() }}
@empty

Aucune réservation

@endforelse
{{-- ═══ SUB-TAB: Packages ═══ --}}
{{-- KPI Cards --}}

Réservations

{{ number_format($travelCount) }}

Voyage

Revenu

{{ number_format($travelRevenue, 0, ',', ' ') }}

DA

Commissions

{{ number_format($travelCommission, 0, ',', ' ') }}

DA

Payé

{{ number_format($travelPaid, 0, ',', ' ') }}

DA

{{-- Chart + Status + Recent --}}
Statuts
@forelse ($travelStatusCounts as $label => $count) @php $pct = $travelCount > 0 ? round(($count / $travelCount) * 100) : 0; $color = match(strtolower($label)) { 'confirmed' => '#10b981', 'pending' => '#f59e0b', 'cancelled' => '#ef4444', 'in progress' => '#3b82f6', default => '#6b7280' }; @endphp
{{ $label }} {{ $count }} ({{ $pct }}%)
@empty
Aucune réservation
@endforelse
Top Clients
@forelse ($travelTopClients as $i => $tc)
{{ strtoupper(substr($tc['name'], 0, 1)) }}
{{ $tc['name'] }}
CA cumulé
{{ number_format($tc['total'], 0, ',', ' ') }} DA
@empty

Aucune donnée

@endforelse
Récentes
@forelse ($recentTravel as $rr)
{{ $rr['client'] }}
{{ number_format($rr['amount'], 0, ',', ' ') }} DA {{ $rr['created_at']->diffForHumans() }}
@empty

Aucune

@endforelse
{{-- ═══ SUB-TAB: Visa ═══ --}}
{{-- KPI Cards --}}

Réservations

{{ number_format($visaCount) }}

Visa

Revenu

{{ number_format($visaRevenue, 0, ',', ' ') }}

DA

Commissions

{{ number_format($visaCommission, 0, ',', ' ') }}

DA

Payé

{{ number_format($visaPaid, 0, ',', ' ') }}

DA

{{-- Chart + Status + Recent --}}
Statuts
@forelse ($visaStatusCounts as $label => $count) @php $pct = $visaCount > 0 ? round(($count / $visaCount) * 100) : 0; $color = match(strtolower($label)) { 'approved' => '#10b981', 'pending' => '#f59e0b', 'processing' => '#3b82f6', 'rejected' => '#ef4444', 'cancelled' => '#6b7280', default => '#6b7280' }; @endphp
{{ $label }} {{ $count }} ({{ $pct }}%)
@empty
Aucune réservation
@endforelse
Top Clients
@forelse ($visaTopClients as $i => $tc)
{{ strtoupper(substr($tc['name'], 0, 1)) }}
{{ $tc['name'] }}
CA cumulé
{{ number_format($tc['total'], 0, ',', ' ') }} DA
@empty

Aucune donnée

@endforelse
Récentes
@forelse ($recentVisa as $rr)
{{ $rr['client'] }}
{{ number_format($rr['amount'], 0, ',', ' ') }} DA {{ $rr['created_at']->diffForHumans() }}
@empty

Aucune

@endforelse
{{-- /tab-content --}}
@endif
@endif @endsection @section('scripts') @endsection