{{-- Card de planning de nettoyage --}}
@php $clientObj = $schedule->client ?? null; $clientName = $clientObj->client_name ?? (\App\Helpers\TranslationHelper::getUserTranslations()['translations']['cleaning']['unknown_client'] ?? 'Client inconnu'); $logoUrl = $clientObj->logo_url ?? null; $logoRaw = $clientObj->client_logo ?? null; if (!$logoUrl && $logoRaw) { $isAbsolute = \Illuminate\Support\Str::startsWith($logoRaw, ['http://','https://','//']); $logoUrl = $isAbsolute ? $logoRaw : asset(ltrim($logoRaw, '/')); } $clientType = $clientObj->client_type ?? null; @endphp

{{ $clientName }}

@if($clientType) {{ ucfirst($clientType) }} @else {{ \App\Helpers\TranslationHelper::getUserTranslations()['translations']['cleaning']['unknown_client_type'] ?? 'Type inconnu' }} @endif
@php $billing = $schedule->billing ?? null; @endphp @if($billing && ($billing->type ?? null) === 'package' && !is_null($billing->monthly_package_amount ?? null)) Forfait {{ number_format($billing->monthly_package_amount, 0, ',', ' ') }}€/mois @elseif($billing && ($billing->type ?? null) === 'hourly' && !is_null($billing->hourly_rate ?? null)) À l'heure {{ number_format($billing->hourly_rate, 0, ',', ' ') }}€/h @endif
@php $addr = $schedule->address ?? null; $street = trim($addr->street ?? ''); $postal = trim($addr->postal_code ?? ''); $city = trim($addr->city ?? ''); $floor = trim((string)($addr->floor ?? '')); // Suffixe d'étage: 1 -> 1er, autres nombres -> Nème; valeurs non numériques inchangées (ex: RDC) $floorDisplay = $floor; if ($floor !== '' && is_numeric($floor)) { $n = (int) $floor; $floorDisplay = $n === 1 ? ($n.'er') : ($n.'ème'); } $side = trim((string)($addr->side ?? '')); $mainParts = []; if ($street !== '') { $mainParts[] = $street; } $cityLine = trim(($postal !== '' ? $postal.' ' : '').$city); if ($cityLine !== '') { $mainParts[] = $cityLine; } $baseAddress = count($mainParts) > 0 ? implode(', ', $mainParts) : (\App\Helpers\TranslationHelper::getUserTranslations()['translations']['cleaning']['unknown_address'] ?? 'Adresse inconnue'); $detailParts = []; if ($floor !== '') { $detailParts[] = $floorDisplay; } if ($side !== '') { $detailParts[] = $side; } $details = count($detailParts) > 0 ? (' - ' . implode(' ', $detailParts)) : ''; $mainAddress = $baseAddress . $details; @endphp
{{ $mainAddress }}
{{-- Mini planning aligné avec menage-show --}} @php // Préparer un agrégat simple des flags par jour (fr -> en) $frToEn = [ 'lundi' => 'monday', 'mardi' => 'tuesday', 'mercredi' => 'wednesday', 'jeudi' => 'thursday', 'vendredi' => 'friday', 'samedi' => 'saturday', 'dimanche' => 'sunday' ]; $dayNamesEn = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday']; $aggregatedFlags = array_fill_keys($dayNamesEn, ['morning'=>false,'evening'=>false]); $aggregatedPresence = array_fill_keys($dayNamesEn, false); $aggregatedDays = array_fill_keys($dayNamesEn, []); $daysConfigRaw = is_string($schedule->days_config ?? null) ? (json_decode($schedule->days_config, true) ?: []) : ($schedule->days_config ?? []); if (is_array($daysConfigRaw)) { foreach($daysConfigRaw as $k=>$v){ $key = $frToEn[strtolower($k)] ?? strtolower($k); if (in_array($key, $dayNamesEn, true)){ $aggregatedPresence[$key] = true; // Agréger les tâches si présentes $tasks = $v['tasks'] ?? []; if (is_array($tasks)) { $aggregatedDays[$key] = array_values(array_unique(array_merge($aggregatedDays[$key], $tasks))); } if (isset($v['morning'])) { $aggregatedFlags[$key]['morning'] = $aggregatedFlags[$key]['morning'] || (bool)$v['morning']; } if (isset($v['evening'])) { $aggregatedFlags[$key]['evening'] = $aggregatedFlags[$key]['evening'] || (bool)$v['evening']; } } } } $dayShort = ['monday'=>'Lu','tuesday'=>'Ma','wednesday'=>'Me','thursday'=>'Je','friday'=>'Ve','saturday'=>'Sa','sunday'=>'Di']; @endphp
@foreach($dayNamesEn as $dkey) @php $isMorning = (bool)($aggregatedFlags[$dkey]['morning'] ?? false); $isEvening = (bool)($aggregatedFlags[$dkey]['evening'] ?? false); $tasks = $aggregatedDays[$dkey] ?? []; $hasTasks = is_array($tasks) && count($tasks) > 0; // Considérer une "journée active" uniquement s'il y a des badges (matin/soir) OU des tâches. // La simple présence ne suffit pas: on affiche "repos" dans ce cas. $hasDay = ($isMorning || $isEvening || $hasTasks); $hasDish = $hasTasks && collect($tasks)->contains(function($t){ $t = strtolower($t); return str_contains($t,'vaisselle') || str_contains($t,'dish') || str_contains($t,'couvert'); }); @endphp
{{ $dayShort[$dkey] }}
@if($hasDay)
@if($isMorning || $isEvening) @php $morningLabel = (\App\Helpers\TranslationHelper::getUserTranslations()['translations']['cleaning']['morning_tooltip'] ?? 'Matin'); $eveningLabel = (\App\Helpers\TranslationHelper::getUserTranslations()['translations']['cleaning']['evening_tooltip'] ?? 'Soir'); $title = $isMorning && $isEvening ? ($morningLabel.' et '.$eveningLabel) : ($isMorning ? $morningLabel : $eveningLabel); @endphp
@if($isMorning)
@endif @if($isEvening)
@endif
@endif
@if($hasDish)
@endif
@else
@endif
@endforeach
{{-- Équipe assignée (alignée avec menage-show) --}}
@php $team = isset($schedule->all_workers) ? $schedule->all_workers : collect(); $teamCount = method_exists($team, 'count') ? $team->count() : (is_array($team) ? count($team) : 0); $perPerson = null; $billing = $schedule->billing ?? null; if ($billing && (($billing->type ?? null) === 'package')) { $amount = $billing->monthly_package_amount ?? null; // montant avant marge if (is_numeric($amount) && $teamCount > 0) { $perPerson = ((float)$amount) / $teamCount; } } @endphp @if($teamCount > 0) @foreach($schedule->all_workers as $worker)
{{ $worker->prenom }}
@if(!is_null($perPerson)) |
{{ number_format($perPerson, 0, ',', ' ') }}€/mois
@endif
@endforeach @else
{{ \App\Helpers\TranslationHelper::getUserTranslations()['translations']['cleaning']['not_assigned'] ?? 'Non assigné' }}
@endif