@php use Illuminate\Support\Facades\Storage; // Conditionne l'affichage général, max 10 !! $nbIntervenantsToDisplay = $panneau->nbIntervenantsPrint ?? 5; $chantierInterdit = (bool) ($panneau->chantierInterditPrint ?? true); $chantierSafety = (bool) ($panneau->chantierSafetyPrint ?? false); $colBlocIntervenants = 6; $photoChantierMaxHeight = 465; $qrSize = 310; $artboardSize = 1500; //Si > 5 on passe à deux colonnes on va réduire l'image et qr code ! if($nbIntervenantsToDisplay > 5) { $colBlocIntervenants = 7; $photoChantierMaxHeight = 415; $qrSize = 280; } $hasLabels = $panneau->labels->where('actif', true)->isNotEmpty(); /* |-------------------------------------------------------------------------- | Calcul intelligent de la taille photo chantier |-------------------------------------------------------------------------- */ $photoChantierMaxHeight = 465; // valeur par défaut $photoRealWidth = null; $photoRealHeight = null; $photoRatio = null; $photoIsLowRes = false; if (!empty($panneau->photo)) { $relativePath = $panneau->photo; $absolutePath = storage_path('app/public/' . $relativePath); if (file_exists($absolutePath)) { try { $imageSize = @getimagesize($absolutePath); if ($imageSize !== false) { $photoRealWidth = $imageSize[0] ?? null; $photoRealHeight = $imageSize[1] ?? null; if (!empty($photoRealWidth) && !empty($photoRealHeight)) { $photoRatio = $photoRealWidth / $photoRealHeight; // Petite résolution = on évite les agrandissements trop moches $photoIsLowRes = ($photoRealWidth < 1200 || $photoRealHeight < 800); /* |-------------------------------------------------------------------------- | Règles de hauteur selon le format réel |-------------------------------------------------------------------------- | ratio > 2.2 : très panoramique | ratio > 1.6 : paysage | ratio > 1.15 : paysage léger | ratio >= 0.85 : quasi carré | ratio >= 0.60 : portrait | sinon : portrait très haut */ if ($photoRatio > 2.2) { // très panoramique $photoChantierMaxHeight = 360; } elseif ($photoRatio > 1.6) { // paysage large $photoChantierMaxHeight = 420; } elseif ($photoRatio > 1.15) { // paysage standard $photoChantierMaxHeight = 480; } elseif ($photoRatio >= 0.85) { // quasi carré $photoChantierMaxHeight = 540; } elseif ($photoRatio >= 0.60) { // portrait $photoChantierMaxHeight = 600; } else { // portrait très haut $photoChantierMaxHeight = 640; } // Si faible résolution, on limite la taille pour éviter le rendu "géant / flou" if ($photoIsLowRes) { $photoChantierMaxHeight = min($photoChantierMaxHeight, 360); } // Si beaucoup d'intervenants, on compresse un peu la hauteur if ($nbIntervenantsToDisplay > 5) { $photoChantierMaxHeight -= 40; } // Si labels + pictos, on réduit légèrement pour garder de l'air $securityCount = 0; if ($chantierInterdit) { $securityCount++; } if ($chantierSafety) { $securityCount++; } // Sécurité mini / maxi $photoChantierMaxHeight = max(260, min($photoChantierMaxHeight, 560)); } } } catch (\Throwable $e) { // On garde la valeur par défaut si lecture impossible $photoChantierMaxHeight = ($nbIntervenantsToDisplay > 5) ? 415 : 465; } // Sécurité si pas de photo ou dimensions introuvables if (empty($photoRealWidth) || empty($photoRealHeight)) { $photoChantierMaxHeight = ($nbIntervenantsToDisplay > 5) ? 415 : 465; } } } @endphp
@php $logoOuvrage1 = null; $logoOuvrage2 = null; $logoOuvrageEntete = 'les_deux'; foreach($panneau->intervenants->sortBy('numeroOrdre') as $intervenant) { if($intervenant->numeroOrdre == 1 && Str::contains(strtolower($intervenant->type), 'ouvrage')) { $logoOuvrage1 = $intervenant->logo; $logoOuvrage2 = $intervenant->logo2; $logoOuvrageEntete = $intervenant->logoEntete ?? 'les_deux'; break; } } @endphp @php $titre = $panneau->nom ?? null; $logo = $panneau->logo ?? null; @endphp
@if($logoOuvrage1 && in_array($logoOuvrageEntete, ['gauche', 'les_deux']))
Logo Maître d'Ouvrage
@endif
@if($titre || $logo) @if($logo)
Titre
@else @php $titleWords = count(preg_split('/\s+/', trim($titre))); $titleFz = $titleWords >= 8 ? 'fz-38' : ($titleWords >= 7 ? 'fz-42' : 'fz-52'); @endphp

{{$titre}}

@endif @endif
@if($logoOuvrage2 && in_array($logoOuvrageEntete, ['droite', 'les_deux']))
Logo Maître d'Ouvrage
@endif
@if($panneau->sousTitre)

{{ $panneau->sousTitre }}

@endif
Image du chantier
@if(app()->environment('local'))
{{ $photoRealWidth }} x {{ $photoRealHeight }} | ratio: {{ $photoRatio ? number_format($photoRatio, 2) : 'N/A' }} | lowRes: {{ $photoIsLowRes ? 'oui' : 'non' }} | maxHeight: {{ $photoChantierMaxHeight }}px
@endif
@php $typesAffiches = ['ouvrage', 'oeuvre', 'archi', 'SPS', 'controle']; $intervenantCount = 0; $logoIntervenantWidth = 110; $logoIntervenantHeight = 80; if ($nbIntervenantsToDisplay > 0) { $intervenantsToDisplay = $panneau->intervenants ->sortBy('numeroOrdre') ->take(min($nbIntervenantsToDisplay, 9)) ->values(); } else { $intervenantsToDisplay = $panneau->intervenants ->sortBy('numeroOrdre') ->filter(function ($intervenant) use ($typesAffiches) { return collect($typesAffiches)->contains(function ($type) use ($intervenant) { return Str::contains(strtolower($intervenant->type), strtolower($type)); }); }) ->take(9) ->values(); } $countIntervenants = $intervenantsToDisplay->count(); $isTwoColumns = $countIntervenants > 5; $firstIntervenant = $intervenantsToDisplay->first(); $otherIntervenants = $intervenantsToDisplay->slice(1)->values(); if ($isTwoColumns) { $logoIntervenantWidth = 90; $logoIntervenantHeight = 65; $leftColumn = $otherIntervenants->chunk((int) ceil($otherIntervenants->count() / 2))->get(0) ?? collect(); $rightColumn = $otherIntervenants->chunk((int) ceil($otherIntervenants->count() / 2))->get(1) ?? collect(); } @endphp {{-- 1er intervenant toujours pleine largeur --}} @if($firstIntervenant) @php $intervenant = $firstIntervenant; $intervenantCount++; $borderLightFirstIntervenant = "border-light"; $logoLigne = $intervenant->logoLigne; if ($logoLigne !== null) { $showLogo2 = in_array($logoLigne, ['logo2', 'les_deux']); } else { $showLogo2 = $intervenant->numeroOrdre == 1 && Str::contains(strtolower($intervenant->type), 'ouvrage') && !empty($intervenant->logo2); } $showLogo1 = !in_array($logoLigne, ['logo2', 'aucun']); $logoIntervenantFirst = ""; if ($isTwoColumns) $logoIntervenantFirst = "intervenant-logo-print-first"; @endphp
{{ Str::upper(Str::ascii($intervenant->type)) }}
{{ $intervenant->libelleType }}
{{ preg_replace('/(\d{2})(?=\d)/', '$1 ', $intervenant->numeroTel) }}
@if(!empty($intervenant->siteWeb))
{{ $intervenant->siteWeb }}
@endif
@if($showLogo1 && !empty($intervenant->logo))
Logo {{ $intervenant->libelle }}
@endif @if($showLogo2 && !empty($intervenant->logo2))
Logo {{ $intervenant->libelle }}
@endif
@endif {{-- Si 1 à 5 intervenants : les autres restent en pleine largeur --}} @if(!$isTwoColumns) @foreach($otherIntervenants as $intervenant) @php $intervenantCount++; $logoLigne = $intervenant->logoLigne; if ($logoLigne !== null) { $showLogo2 = in_array($logoLigne, ['logo2', 'les_deux']); } else { $showLogo2 = $intervenant->numeroOrdre == 1 && Str::contains(strtolower($intervenant->type), 'ouvrage') && !empty($intervenant->logo2); } $showLogo1 = !in_array($logoLigne, ['logo2', 'aucun']); @endphp
{{ Str::upper(Str::ascii($intervenant->type)) }}
{{ $intervenant->libelleType }}
{{ preg_replace('/(\d{2})(?=\d)/', '$1 ', $intervenant->numeroTel) }}
@if(!empty($intervenant->siteWeb))
{{ $intervenant->siteWeb }}
@endif
@if($showLogo1 && !empty($intervenant->logo))
Logo {{ $intervenant->libelle }}
@endif @if($showLogo2 && !empty($intervenant->logo2))
Logo {{ $intervenant->libelle }}
@endif
@endforeach @endif {{-- Si > 5 intervenants : les autres passent en 2 colonnes --}} @if($isTwoColumns)
@foreach($leftColumn as $intervenant) @php $intervenantCount++; $logoLigne = $intervenant->logoLigne; if ($logoLigne !== null) { $showLogo2 = in_array($logoLigne, ['logo2', 'les_deux']); } else { $showLogo2 = $intervenant->numeroOrdre == 1 && Str::contains(strtolower($intervenant->type), 'ouvrage') && !empty($intervenant->logo2); } $showLogo1 = !in_array($logoLigne, ['logo2', 'aucun']); @endphp
{{ Str::upper(Str::ascii($intervenant->type)) }}
{{ $intervenant->libelleType }}
{{ preg_replace('/(\d{2})(?=\d)/', '$1 ', $intervenant->numeroTel) }}
@if(!empty($intervenant->siteWeb))
{{ $intervenant->siteWeb }}
@endif
@if($showLogo1 && !empty($intervenant->logo))
Logo {{ $intervenant->libelle }}
@endif @if($showLogo2 && !empty($intervenant->logo2))
Logo {{ $intervenant->libelle }}
@endif
@endforeach
@foreach($rightColumn as $intervenant) @php $intervenantCount++; $logoLigne = $intervenant->logoLigne; if ($logoLigne !== null) { $showLogo2 = in_array($logoLigne, ['logo2', 'les_deux']); } else { $showLogo2 = $intervenant->numeroOrdre == 1 && Str::contains(strtolower($intervenant->type), 'ouvrage') && !empty($intervenant->logo2); } $showLogo1 = !in_array($logoLigne, ['logo2', 'aucun']); @endphp
{{ Str::upper(Str::ascii($intervenant->type)) }}
{{ $intervenant->libelleType }}
{{ preg_replace('/(\d{2})(?=\d)/', '$1 ', $intervenant->numeroTel) }}
@if(!empty($intervenant->siteWeb))
{{ $intervenant->siteWeb }}
@endif
@if($showLogo1 && !empty($intervenant->logo))
Logo {{ $intervenant->libelle }}
@endif @if($showLogo2 && !empty($intervenant->logo2))
Logo {{ $intervenant->libelle }}
@endif
@endforeach
@endif

Pour accéder à l'ensemble des informations du chantier :
SCANNEZ-MOI !

@if($panneau->qrLink)
{!! \SimpleSoftwareIO\QrCode\Facades\QrCode::size($qrSize)->generate(route('qr.redirect', $panneau->qrLink->slug)) !!}
@endif @if(($chantierInterdit || $chantierSafety))
@if($chantierInterdit) Chantier Interdit au public @endif @if($chantierSafety) Dispositif Ras le vol @endif
@endif
@if(isset($panneau->permis))
{{ $panneau->permis->type }} N° {{ $panneau->permis->numero }}
@endif
@if($hasLabels)
@foreach($panneau->labels->where('actif', true) as $label)
Logo {{ $label->libelle }}
@endforeach
@endif
{{-- --}}