@if(($packageDeclarations ?? collect())->count() > 0)
@foreach($packageDeclarations as $pd)
@php
$logoUrl = $pd->client_logo_url ?? (isset($pd->client_logo) ? asset(ltrim($pd->client_logo,'/')) : asset('images/logos/default-client.png'));
$typeClass = !empty($pd->client_type) ? strtolower($pd->client_type) : null;
$isParticulier = $typeClass === 'particulier';
$clientName = $pd->client_name ?? 'Client';
// Date de création
$createdAt = isset($pd->created_at) ? \Carbon\Carbon::parse($pd->created_at) : null;
$createdDate = $createdAt ? $createdAt->format('d/m/Y') : '';
$createdTime = $createdAt ? $createdAt->format('H:i') : '';
// Mode
$mode = strtolower($pd->period_mode ?? 'full');
$modeMap = [
'full' => ['label' => 'Mois complet', 'icon' => 'fa-calendar-check'],
'custom' => ['label' => 'Dates personnalisées', 'icon' => 'fa-calendar-alt'],
'free' => ['label' => 'Montant libre', 'icon' => 'fa-euro-sign'],
];
$modeConfig = $modeMap[$mode] ?? $modeMap['full'];
$modeLabel = $modeConfig['label'];
$modeIcon = $modeConfig['icon'];
// Status
$isValidated = (int)($pd->status ?? 0) === 1;
$statusClass = $isValidated ? 'validated' : 'pending';
// Declarants
$declarantsCount = (int)($pd->declarants_count ?? 1);
if ($declarantsCount < 1) { $declarantsCount = 1; }
$declarantsNames = $pd->declarants_names ?? '';
// Service type
$serviceType = $pd->service_type ?? 'cleaning';
$serviceConfig = \App\Helpers\ServiceIconHelper::getConfig($serviceType);
$serviceIcon = $serviceConfig['icon'];
$serviceClass = $serviceConfig['class'];
$serviceLabel = $serviceConfig['fallback']; // Traduction française
@endphp
@endforeach
@else
{{ $tDecl['package_empty_month'] ?? 'Aucune déclaration forfaitaire pour ce mois' }}
@endif
@if(($hourlyDeclarations ?? collect())->count() > 0)
@foreach($hourlyDeclarations as $hd)
@php
$typeClass = !empty($hd->client_type) ? strtolower($hd->client_type) : null;
$isParticulier = $typeClass === 'particulier';
$clientName = $hd->client_name ?? 'Client';
$logoUrl = $hd->client_logo_url ?? (isset($hd->client_logo) ? asset(ltrim($hd->client_logo,'/')) : asset('images/logos/default-client.png'));
// Date de la prestation (work_date)
$workDate = isset($hd->work_date) ? \Carbon\Carbon::parse($hd->work_date) : null;
$createdDate = $workDate ? $workDate->format('d/m/Y') : '';
$createdTime = $workDate ? $workDate->format('H:i') : '';
// Service type
$serviceType = $hd->service_type ?? 'cleaning';
$serviceConfig = \App\Helpers\ServiceIconHelper::getConfig($serviceType);
$serviceIcon = $serviceConfig['icon'];
$serviceClass = $serviceConfig['class'];
$serviceLabel = $serviceConfig['fallback']; // Traduction française
// Time
$start = isset($hd->start_time) ? substr($hd->start_time, 0, 5) : null;
$end = isset($hd->end_time) ? substr($hd->end_time, 0, 5) : null;
$totalMinutes = $hd->minutes_worked ?? 0;
$hours = floor($totalMinutes / 60);
$minutes = $totalMinutes % 60;
$hoursText = sprintf('%02dh%02d', $hours, $minutes);
// Break
$breakMin = isset($hd->break_minutes) ? (int)$hd->break_minutes : 0;
$pauseText = '';
if ($breakMin > 0) {
$bh = floor($breakMin / 60);
$bm = $breakMin % 60;
$pauseText = ' (' . ($bh > 0 ? ($bh . 'h' . str_pad((string)$bm, 2, '0', STR_PAD_LEFT)) : ($bm . ' min')) . ')';
}
// Status
$isValidated = (int)($hd->status ?? 0) === 1;
$statusClass = $isValidated ? 'validated' : 'pending';
@endphp
@endforeach
@else
{{ $tDecl['hourly_empty_month'] ?? "Aucune déclaration horaire pour ce mois" }}
@endif
@if(($eventDeclarations ?? collect())->count() > 0)
@foreach($eventDeclarations as $ed)
@php
$typeClass = !empty($ed->client_type) ? strtolower($ed->client_type) : null;
$isParticulier = $typeClass === 'particulier';
$clientName = $ed->client_name ?? 'Client';
$logoUrl = $ed->client_logo_url ?? (isset($ed->client_logo) ? asset(ltrim($ed->client_logo,'/')) : asset('images/logos/default-client.png'));
// Date de création
$createdAt = isset($ed->created_at) ? \Carbon\Carbon::parse($ed->created_at) : null;
$createdDate = $createdAt ? $createdAt->format('d/m/Y') : '';
$createdTime = $createdAt ? $createdAt->format('H:i') : '';
// Event date
$eventDate = isset($ed->event_date) ? \Carbon\Carbon::parse($ed->event_date) : null;
$eventDateFormatted = $eventDate ? $eventDate->format('d/m/Y') : '—';
// Participants
$declarantsCount = (int)($ed->declarants_count ?? ($ed->total_participants ?? 1));
if ($declarantsCount < 1) { $declarantsCount = 1; }
$declarantsNames = $ed->declarants_names ?? ($ed->participants_names ?? '');
// Service type from event_service_id
$eventServiceId = $ed->event_service_id ?? null;
$serviceType = $ed->service_type ?? 'event';
$serviceConfig = \App\Helpers\ServiceIconHelper::getConfig($serviceType);
$serviceIcon = $serviceConfig['icon'];
$serviceClass = $serviceConfig['class'];
$serviceLabel = $serviceConfig['fallback']; // Traduction française
// Amounts
$declaredAmount = (float)($ed->declared_amount ?? 0);
$shareAmount = (float)($ed->share_amount ?? 0);
$displayAmount = $shareAmount > 0 ? $shareAmount : $declaredAmount;
// Status
$isValidated = (int)($ed->status ?? 0) === 1;
$statusClass = $isValidated ? 'validated' : 'pending';
@endphp
@endforeach
@else
{{ $tDecl['event_empty_month'] ?? 'Aucune déclaration événementielle pour ce mois' }}
@endif