@php // Use period_month (YYYY-MM-01) to derive the period displayed and filtering attributes $monthDate = isset($declaration->period_month) ? \Carbon\Carbon::parse($declaration->period_month) : null; $monthKey = $monthDate ? strtolower($monthDate->format('F')) : null; $t = \App\Helpers\TranslationHelper::getUserTranslations(); $monthText = $monthDate ? ($t['translations']['months'][$monthKey] ?? $monthDate->translatedFormat('F')) : '—'; if (function_exists('mb_strtolower') && $monthText) { $monthText = mb_strtolower($monthText, 'UTF-8'); } $periodLabel = $monthDate ? ($monthText . ' ' . $monthDate->format('Y')) : '—'; // For the visible badge: show the actual declaration creation day, with month/year from the period $createdDate = isset($declaration->created_at) ? \Carbon\Carbon::parse($declaration->created_at) : null; $createdDayText = $createdDate ? $createdDate->format('d') : ''; $periodMonthAbbr = ''; $periodYearText = ''; if ($monthDate) { $fullMonth = $t['translations']['months'][$monthKey] ?? $monthDate->translatedFormat('F'); if (function_exists('mb_substr')) { $periodMonthAbbr = mb_strtolower(mb_substr($fullMonth, 0, 3, 'UTF-8'), 'UTF-8') . '.'; } else { $periodMonthAbbr = strtolower(substr($fullMonth, 0, 3)) . '.'; } $periodYearText = $monthDate->format('Y'); } $modeMap = [ 'full' => ($t['translations']['declaration']['period_full'] ?? 'mois complet'), 'custom' => ($t['translations']['declaration']['period_custom'] ?? 'dates personnalisées'), 'free' => ($t['translations']['declaration']['period_free'] ?? 'montant libre'), ]; $modeLabel = $modeMap[$declaration->period_mode ?? 'full'] ?? ($t['translations']['declaration']['period_full'] ?? 'mois complet'); // Icon for mode $modeIconMap = [ 'full' => 'fa-calendar-check', 'custom' => 'fa-calendar-alt', 'free' => 'fa-euro-sign', ]; $modeIcon = $modeIconMap[$declaration->period_mode ?? 'full'] ?? 'fa-calendar-alt'; // Task type shown as badge in title row (using English service_type) $taskType = strtolower($declaration->task_type ?? 'cleaning'); if ($taskType === 'dishwashing') { $taskClass = 'vaisselle'; $taskIcon = 'fa-utensils'; $taskText = $t['translations']['cleaning']['legend_dishwashing'] ?? 'vaisselle'; } elseif ($taskType === 'bin') { $taskClass = 'poubelle'; $taskIcon = 'fa-trash-alt'; $taskText = $t['translations']['cleaning']['legend_bin'] ?? ($t['translations']['cleaning']['bin_task'] ?? 'poubelle'); } else { // cleaning or default $taskClass = 'menage'; $taskIcon = 'fa-broom'; $taskText = $t['translations']['cleaning']['legend_cleaning'] ?? 'ménage'; } // Define client name with safe fallbacks to prevent undefined variable $clientName = $declaration->client_name ?? $declaration->client ?? $declaration->client_company_name ?? $declaration->household_name ?? ($t['translations']['interventions']['client'] ?? 'Client'); $isValidated = (int)($declaration->status ?? 0) === 1; $statusClass = $isValidated ? 'validated' : 'pending'; // Build localized period pieces already handled above (created day + period month/year) @endphp
@php $clientType = strtolower($declaration->client_type ?? ''); $isParticulier = $clientType === 'particulier'; @endphp @if($isParticulier)
@php $nameParts = explode(' ', trim($clientName)); $initials = ''; 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($monthDate)
{{ $periodMonthAbbr }}
{{ $periodYearText }}
@endif
{{ $clientName }}
@if(!empty($declaration->client_type)) @php $typeClass = strtolower($declaration->client_type); $typeKey = 'client_type_' . $typeClass; $typeLabel = $t['translations']['declaration'][$typeKey] ?? $declaration->client_type; @endphp
{{ $typeLabel }}
@endif
@if(!empty($declaration->short_address))
{{ $declaration->short_address }}
@endif
@php // Backend now provides total declarations rows (all modes) as declarants_count. $declarantsCount = (int)($declaration->declarants_count ?? $declaration->participants_count ?? $declaration->workers_count ?? 1); if ($declarantsCount < 1) { $declarantsCount = 1; } $displayAmount = isset($declaration->user_share) ? (float)$declaration->user_share : (float)$declaration->declared_amount; @endphp {{ $t['translations']['declaration']['declarants_title'] ?? 'Déclarants' }} {{ $declarantsCount }}
{{ $t['translations']['declaration']['package_total_amount'] ?? ($t['translations']['declaration']['amount_title'] ?? 'Somme du service') }}
{{ number_format((float)$declaration->monthly_package_amount, 2, ',', ' ') }} €
{{ $t['translations']['declaration']['plage_mode'] ?? 'Plage & Mode' }}
{{ $modeLabel }}
{{ $taskText }}
{{ $t['translations']['declaration']['your_share_label'] ?? ($t['translations']['declaration']['declared_label'] ?? 'Déclaré') }}
{{ number_format($displayAmount, 2, ',', ' ') }} €