{{-- Accordéon des plannings d'un utilisateur. Variables attendues : - $plannings : collection de App\Models\Planning (avec relation equipe) - $planningInfos : map [planning_id => infos API (duree/employes/contact/devis/interventions)] - $user : App\Models\User courant (pour exclure des techniciens) --}} @if ($plannings->count())
@foreach ($plannings as $p) @php $info = $planningInfos[$p->id] ?? []; $contact = $info['contact'] ?? null; $devisL = $info['devis'] ?? []; $interL = $info['interventions'] ?? []; $duree = $info['duree'] ?? null; // Techniciens du chantier, hors utilisateur courant ("avec qui") $techniciens = collect($info['employes'] ?? []) ->reject(fn ($e) => (int) ($e['id'] ?? 0) === (int) $user->id) ->values(); $raison = $contact ? ($contact['raison_sociale'] ?? (trim(($contact['prenom'] ?? '') . ' ' . ($contact['nom'] ?? '')) ?: null)) : null; $itemId = 'planning_' . $p->id; $isOpen = $loop->first; @endphp

{{-- Infos chantier --}}
Durée {{ $duree ?? '—' }}
Techniciens @forelse ($techniciens as $t) {{ trim(($t['prenom'] ?? '') . ' ' . ($t['nom'] ?? '')) ?: '—' }} @empty Aucun autre technicien @endforelse
{{-- Client --}}
Client
@if ($contact)
Raison sociale {{ $raison ?? '—' }}
E-mail @if (!empty($contact['email'])) {{ $contact['email'] }} @else — @endif
Téléphone {{ $contact['tel'] ?? '—' }}
@else

@endif {{-- Devis --}} @if (!empty($devisL))
Devis
@foreach ($devisL as $d) @php $adresseChantier = implode(', ', array_filter([ trim(($d['adresse_1'] ?? '') . ' ' . ($d['adresse_2'] ?? '')), trim(($d['code_postal'] ?? '') . ' ' . ($d['ville'] ?? '')), ])) ?: '—'; @endphp @endforeach
Référence Nature Adresse chantier
@if (!empty($d['id'])) {{ $d['id'] }} @else — @endif {{ $d['reference'] ?? '—' }} {{ $d['nature'] ?? '—' }} {{ $adresseChantier }}
@endif {{-- Interventions --}} @if (!empty($interL))
Interventions
@foreach ($interL as $i) @endforeach
Libellé Secteur
{{ $i['id'] ?? '—' }} {{ $i['libelle'] ?? '—' }} {{ $i['secteur'] ?? '—' }}
@endif
@endforeach
@else

Aucun planning.

@endif