@php $monthSafe = $monthParam ?? date('Y-m'); // Parse year and month separately to avoid octal issues [$year, $month] = explode('-', $monthSafe); $year = (int)$year; $month = (int)$month; try { $curMonth = \Carbon\Carbon::create($year, $month, 1); } catch (Exception $e) { $curMonth = \Carbon\Carbon::now(); } // Create separate instances for prev/next to avoid Carbon mutation $prevMonth = \Carbon\Carbon::create($year, $month, 1)->subMonth()->format('Y-m'); $nextMonth = \Carbon\Carbon::create($year, $month, 1)->addMonth()->format('Y-m'); try { $label = $curMonth->locale('fr_FR')->translatedFormat('F Y'); } catch (Exception $e) { $label = $curMonth->format('F Y'); } $translations = \App\Helpers\TranslationHelper::getUserTranslations(); $tDecl = $translations['translations']['declaration'] ?? []; $tCommon = $translations['translations']['common'] ?? []; $statusLabels = [ 'empty' => $tDecl['monthly_status_empty'] ?? 'Aucune déclaration', 'validated' => $tDecl['monthly_status_validated'] ?? 'Validé', 'pending' => $tDecl['monthly_status_pending'] ?? 'Non validé', ]; $statusKey = $monthlyStatusKey ?? 'empty'; $statusLabel = $statusLabels[$statusKey] ?? ($monthlyStatusLabel ?? $statusLabels['empty']); @endphp

{{ $tDecl['title'] ?? 'Déclarations' }}

@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
@if($isParticulier)
@php $nameParts = explode(' ', trim($clientName)); if (count($nameParts) >= 2) { $initials = strtoupper(substr($nameParts[0], 0, 1) . substr($nameParts[1], 0, 1)); } else { $initials = strtoupper(substr($clientName, 0, 2)); } @endphp {{ $initials }}
@else @endif @if($createdDate)
{{ $createdDate }}
@endif
{{ $clientName }}
@if($typeClass)
{{ ucfirst($pd->client_type) }}
@endif
@if(!empty($pd->short_address))
{{ $pd->short_address }}
@endif
{{ $declarantsCount }} @if($declarantsNames) {{ $declarantsNames }} @endif
Mode
{{ $modeLabel }}
{{ $serviceLabel }}
Forfait mensuel
{{ number_format($pd->monthly_package_amount, 2, ',', ' ') }} €
Part personnelle
{{ number_format($pd->declared_amount, 2, ',', ' ') }} €
@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
@if($isParticulier)
@php $nameParts = explode(' ', trim($clientName)); if (count($nameParts) >= 2) { $initials = strtoupper(substr($nameParts[0], 0, 1) . substr($nameParts[1], 0, 1)); } else { $initials = strtoupper(substr($clientName, 0, 2)); } @endphp {{ $initials }}
@else @endif @if($createdDate)
{{ $createdDate }}
@endif
{{ $clientName }}
@if($typeClass)
{{ ucfirst($hd->client_type) }}
@endif
@if(!empty($hd->short_address))
{{ $hd->short_address }}
@endif @if($start && $end)
{{ $start }} – {{ $end }}{!! $pauseText !!}
@endif @if(!empty($hoursText))
Total d'heures: {{ $hoursText }}
@endif
{{ $serviceLabel }}
Montant
{{ number_format($hd->total_amount, 2, ',', ' ') }} €
@if(!is_null($hd->hourly_rate))
{{ number_format($hd->hourly_rate, 2, ',', ' ') }} €/h
@endif
@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
@if($isParticulier)
@php $nameParts = explode(' ', trim($clientName)); if (count($nameParts) >= 2) { $initials = strtoupper(substr($nameParts[0], 0, 1) . substr($nameParts[1], 0, 1)); } else { $initials = strtoupper(substr($clientName, 0, 2)); } @endphp {{ $initials }}
@else @endif @if($createdDate)
{{ $createdDate }}
@endif
{{ $clientName }}
@if($typeClass)
{{ ucfirst($ed->client_type) }}
@endif
@if(!empty($ed->short_address))
{{ $ed->short_address }}
@endif
{{ $declarantsCount }} @if($declarantsNames) {{ $declarantsNames }} @endif
Date événement
{{ $eventDateFormatted }}
{{ $serviceLabel }}
Montant total
{{ number_format($declaredAmount, 2, ',', ' ') }} €
Part personnelle
{{ number_format($displayAmount, 2, ',', ' ') }} €
@endforeach
@else

{{ $tDecl['event_empty_month'] ?? 'Aucune déclaration événementielle pour ce mois' }}

@endif