@php $hasMultipleApplications = isset($allApplications) && $allApplications->count() > 1; $canClientsWrite = auth()->user()->canAccessPartnerClientsWrite(); @endphp @if($hasMultipleApplications && isset($clientsByApplication)) {{-- Affichage avec plusieurs tableaux (une par application) --}} @foreach($allApplications as $app)
@php $appClients = $clientsByApplication[$app->id] ?? collect(); @endphp @if($appClients->isNotEmpty() || $app->id == $application->id)
{{ $app->name }} ({{ $appClients->count() }} client{{ $appClients->count() > 1 ? 's' : '' }})
@if($appClients->isEmpty())

Aucun client pour cette application

@else
@foreach($appClients as $client) @endforeach
@if(request('sort_by') == 'lastname') @else @endif Client @if(request('sort_by') == 'email') @else @endif Email @if(request('sort_by') == 'commercialisateur') @else @endif Commercialisateur Dossiers Ventes @if(request('sort_by') == 'created_at' || !request('sort_by')) @else @endif Ajouté le
@php $firstInitial = strtoupper(substr($client->firstname ?? '', 0, 1)); $lastInitial = strtoupper(substr($client->lastname ?? '', 0, 1)); $initials = $firstInitial . $lastInitial; @endphp @if($initials) {{ $initials }} @endif {{ ($client->firstname ?? '') . ' ' . ($client->lastname ?? '') ?: '-' }}
{{ $client->email }} @php $applicationUserIds = $app->users->pluck('id')->toArray(); $commercialisateur = $client->user ?: $client->options->first()?->user; if ($commercialisateur && !in_array($commercialisateur->id, $applicationUserIds)) { $commercialisateur = null; } if ($commercialisateur && !$commercialisateur->isRole(\App\Enums\Role::ROLE_COMMERCIALISATEUR->name)) { $commercialisateur = null; } @endphp @if($commercialisateur) {{ $commercialisateur->firstname }} {{ $commercialisateur->lastname }} @else Aucun commercialisateur @endif {{ $client->active_dossiers_count ?? 0 }} actifs {{ $client->ventes_count ?? 0 }} signées {{ $client->created_at->format('d/m/Y') }}
Voir @if($canClientsWrite) @endif
@endif @endif
@endforeach @else {{-- Affichage classique avec pagination (une seule application) --}} @if($clients->isEmpty())
Aucun client disponible
@else
Liste des clients ({{ $clients->total() }})
@foreach($clients as $client) @endforeach
@if(request('sort_by') == 'lastname') @else @endif Client @if(request('sort_by') == 'email') @else @endif Email @if(request('sort_by') == 'commercialisateur') @else @endif Commercialisateur Dossiers Ventes @if(request('sort_by') == 'created_at' || !request('sort_by')) @else @endif Ajouté le
@php $firstInitial = strtoupper(substr($client->firstname ?? '', 0, 1)); $lastInitial = strtoupper(substr($client->lastname ?? '', 0, 1)); $initials = $firstInitial . $lastInitial; @endphp @if($initials) {{ $initials }} @endif {{ ($client->firstname ?? '') . ' ' . ($client->lastname ?? '') ?: '-' }}
{{ $client->email }} @php $applicationUserIds = $application->users->pluck('id')->toArray(); $commercialisateur = $client->user ?: $client->options->first()?->user; if ($commercialisateur && !in_array($commercialisateur->id, $applicationUserIds)) { $commercialisateur = null; } if ($commercialisateur && !$commercialisateur->isRole(\App\Enums\Role::ROLE_COMMERCIALISATEUR->name)) { $commercialisateur = null; } @endphp @if($commercialisateur) {{ $commercialisateur->firstname }} {{ $commercialisateur->lastname }} @else Aucun commercialisateur @endif {{ $client->active_dossiers_count ?? 0 }} actifs {{ $client->ventes_count ?? 0 }} signées {{ $client->created_at->format('d/m/Y') }}
@if($canClientsWrite) @endif
{{ $clients->appends(request()->all())->links() }}
@endif @endif