| ID | Client | Dates de contrat | Adresse | Personnel | Contrat ménage | Actions | Statut |
|---|---|---|---|---|---|---|---|
| {{ $clientData['row_contract_id'] ?? ($primaryContractId ?? '—') }} |
@php $clientId = $clientData['client']->client_id ?? ($clientData['client']->id ?? null); @endphp
@if($clientId)
@if($clientData['client']->logo_url ?? false)
@else
{{ $clientData['client']->client_display_name ?? 'Client' }}
{{ $clientData['client']->client_code ?? '' }}
@if($clientData['client']->logo_url ?? false)
@endif
{{ $clientData['client']->client_display_name ?? 'Client' }}
{{ $clientData['client']->client_code ?? '' }}
|
@php
// Utiliser les mêmes dates que celles définies plus haut pour les attributs data-*
$startDate = $contractStartDate;
$endDate = $contractEndDate;
// Debug pour les particuliers
if (($clientData['client']->client_type ?? '') === 'particulier') {
\Log::info('Debug dates particulier', [
'client_name' => $clientData['client']->client_display_name ?? '',
'primary_contract_id' => $primaryContractId,
'cleaning_contracts_count' => count($clientData['cleaning_contracts'] ?? []),
'dishwashing_contracts_count' => count($clientData['dishwashing_contracts'] ?? []),
'bin_contracts_count' => count($clientData['bin_contracts'] ?? []),
'ironing_contracts_count' => count($clientData['ironing_contracts'] ?? []),
'start_date' => $startDate,
'end_date' => $endDate,
'all_contracts' => [
'cleaning' => $clientData['cleaning_contracts'] ?? [],
'dishwashing' => $clientData['dishwashing_contracts'] ?? [],
'bin' => $clientData['bin_contracts'] ?? [],
'ironing' => $clientData['ironing_contracts'] ?? []
]
]);
}
@endphp
@if($startDate)
Début :
{{ \Carbon\Carbon::parse($startDate)->format('d/m/Y') }}
@else
@if(($clientData['client']->client_type ?? '') === 'particulier')
DEBUG: Pas de start_date - C:{{ count($clientData['cleaning_contracts'] ?? []) }} D:{{ count($clientData['dishwashing_contracts'] ?? []) }} B:{{ count($clientData['bin_contracts'] ?? []) }} I:{{ count($clientData['ironing_contracts'] ?? []) }}
@endif
@endif
@if($endDate)
Fin :
{{ \Carbon\Carbon::parse($endDate)->format('d/m/Y') }}
@else
Durée :
Indéterminée
@endif
|
@php
$addr = $clientData['address'] ?? null;
$street = trim($addr->street ?? '');
$postal = trim($addr->postal_code ?? '');
$city = trim($addr->city ?? '');
$floor = trim($addr->floor ?? '');
$side = trim($addr->side ?? '');
$mainParts = [];
if ($street !== '') { $mainParts[] = $street; }
$cityLine = trim(($postal !== '' ? $postal . ' ' : '') . $city);
if ($cityLine !== '') { $mainParts[] = $cityLine; }
$computedAddress = count($mainParts) > 0 ? implode(', ', $mainParts) : ($addr->formatted_address ?? 'Adresse non définie');
$mainAddress = trim($addr->short_address ?? '') !== '' ? $addr->short_address : $computedAddress;
@endphp
{{ $mainAddress }}
@if($floor !== '' || $side !== '')
@if($floor !== '')
{{ $floor }}
@endif
@if($side !== '')
{{ $side }}
@endif
@endif
|
@forelse($clientData['workers'] as $worker)
@php $workerId = $worker->id ?? null; @endphp
@if($workerId)
{{ $worker->prenom ?? 'Prénom' }}
{{ $worker->prenom ?? 'Prénom' }}
Non assigné
@endforelse
|
@php
// Déterminer si ce contrat est en facturation horaire (pour masquer le planning)
$cleaningContracts = $clientData['cleaning_contracts'] ?? [];
$dishwashingContracts = $clientData['dishwashing_contracts'] ?? [];
$binContracts = $clientData['bin_contracts'] ?? [];
$ironingContracts = $clientData['ironing_contracts'] ?? [];
$rowIsHourly = strtolower($clientData['billing_type'] ?? '') === 'hourly';
if (!$rowIsHourly && is_array($cleaningContracts)) {
foreach ($cleaningContracts as $c) { if (strtolower($c['billing_type'] ?? '') === 'hourly') { $rowIsHourly = true; break; } }
}
if (!$rowIsHourly && is_array($dishwashingContracts)) {
foreach ($dishwashingContracts as $c) { if (strtolower($c['billing_type'] ?? '') === 'hourly') { $rowIsHourly = true; break; } }
}
if (!$rowIsHourly && is_array($binContracts)) {
foreach ($binContracts as $c) { if (strtolower($c['billing_type'] ?? '') === 'hourly') { $rowIsHourly = true; break; } }
}
if (!$rowIsHourly && is_array($ironingContracts)) {
foreach ($ironingContracts as $c) { if (strtolower($c['billing_type'] ?? '') === 'hourly') { $rowIsHourly = true; break; } }
}
@endphp
@if($rowIsHourly)
{{-- Mode horaire: une seule prestation par contrat -> rendre UN seul bloc contrat mini --}}
@php
$hourlyBlock = null; $label = ''; $amount = null; $iconClass = 'fa-clock'; $legendIconClass = '';
// Priorité: Ménage > Poubelle > Repassage > Vaisselle
if (is_array($cleaningContracts)) {
foreach ($cleaningContracts as $c) { if (strtolower($c['billing_type'] ?? '')==='hourly') { $label = "À l'heure — Ménage"; $iconClass='fa-broom'; $legendIconClass='cleaning-icon'; $hourlyBlock = $c; break; } }
}
if (!$hourlyBlock && is_array($binContracts)) {
foreach ($binContracts as $c) { if (strtolower($c['billing_type'] ?? '')==='hourly') { $label = "À l'heure — Poubelle"; $iconClass='fa-trash'; $legendIconClass='trash-icon'; $hourlyBlock = $c; break; } }
}
if (!$hourlyBlock && is_array($ironingContracts)) {
foreach ($ironingContracts as $c) { if (strtolower($c['billing_type'] ?? '')==='hourly') { $label = "À l'heure — Repassage"; $iconClass='fa-shirt'; $legendIconClass='ironing-icon'; $hourlyBlock = $c; break; } }
}
if (!$hourlyBlock && is_array($dishwashingContracts)) {
foreach ($dishwashingContracts as $c) { if (strtolower($c['billing_type'] ?? '')==='hourly') { $label = "À l'heure — Vaisselle"; $iconClass='fa-utensils'; $legendIconClass='dishwashing-icon'; $hourlyBlock = $c; break; } }
}
if ($hourlyBlock) {
$hasTotal = isset($hourlyBlock['total_amount']) && $hourlyBlock['total_amount'] !== null && $hourlyBlock['total_amount'] !== '';
if ($hasTotal) {
$amount = number_format((float) $hourlyBlock['total_amount'], 2, ',', ' ');
} else {
// Try compute from block values; else fallback to top-level clientData
$rate = isset($hourlyBlock['hourly_rate']) ? (float)$hourlyBlock['hourly_rate'] : (isset($clientData['hourly_rate']) ? (float)$clientData['hourly_rate'] : null);
$marg = isset($hourlyBlock['margin_percent']) ? (float)$hourlyBlock['margin_percent'] : (isset($clientData['margin_percent']) ? (float)$clientData['margin_percent'] : null);
if ($rate !== null && $marg !== null && $marg < 100) {
$den = 1 - ($marg / 100.0);
$tot = $den > 0 ? ($rate / $den) : null;
$amount = $tot !== null ? number_format((float)$tot, 2, ',', ' ') : ($rate !== null ? number_format($rate, 2, ',', ' ') : null);
} else {
$amount = $rate !== null ? number_format($rate, 2, ',', ' ') : null;
}
}
}
@endphp
@if($hourlyBlock)
{{ $label }}
@if($amount !== null)
{{ $amount }}€/h
@else
Non défini
@endif
{{ $legacyLabel }}
@if($legacyAmount !== null)
{{ $legacyAmount }}€/h
@else
Non défini
@endif
@php
// Utiliser les vraies données du contrat depuis la base de données
$daysConfig = $clientData['days_config'] ?? [];
// Les clés viennent des schedules: monday..sunday
$dayShortNames = [
'monday' => 'Lu',
'tuesday' => 'Ma',
'wednesday' => 'Me',
'thursday' => 'Je',
'friday' => 'Ve',
'saturday' => 'Sa',
'sunday' => 'Di'
];
$dayNames = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
@endphp
@endif
@foreach($dayNames as $dayKey)
@php
$dayData = $daysConfig[$dayKey] ?? null;
$hasTasks = $dayData && isset($dayData['tasks']) && count($dayData['tasks']) > 0;
@endphp
{{-- Compteur des tâches --}}
@php
// Calculer les totaux directement à partir du planning affiché (par jour avec tâche)
$totalCleaning = 0;
$totalDishwashing = 0;
$totalBin = 0;
$totalIron = 0;
$daysConfig = $clientData['days_config'] ?? [];
$dayNames = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
foreach ($dayNames as $dayKey) {
$dayData = $daysConfig[$dayKey] ?? null;
if ($dayData && isset($dayData['tasks']) && count($dayData['tasks']) > 0) {
$tasks = $dayData['tasks'];
$hasCleaning = false; $hasDish = false; $hasBin = false; $hasIron = false;
foreach ($tasks as $t) {
$s = strtolower((string)$t);
if (!$hasCleaning && (str_contains($s,'nettoyage')||str_contains($s,'ménage')||str_contains($s,'cleaning')||str_contains($s,'menage'))) { $hasCleaning = true; }
if (!$hasDish && (str_contains($s,'vaisselle')||str_contains($s,'dish')||str_contains($s,'couvert'))) { $hasDish = true; }
if (!$hasBin && (str_contains($s,'poubelle')||str_contains($s,'trash')||str_contains($s,'garbage')||str_contains($s,'bin'))) { $hasBin = true; }
if (!$hasIron && (str_contains($s,'repassage')||str_contains($s,'ironing'))) { $hasIron = true; }
}
if ($hasCleaning) { $totalCleaning++; }
if ($hasDish) { $totalDishwashing++; }
if ($hasBin) { $totalBin++; }
if ($hasIron) { $totalIron++; }
}
}
@endphp
@php
// Récupérer les contrats par type (séparés)
$cleaningContracts = $clientData['cleaning_contracts'] ?? [];
$dishwashingContracts = $clientData['dishwashing_contracts'] ?? [];
$binContracts = $clientData['bin_contracts'] ?? [];
$ironingContracts = $clientData['ironing_contracts'] ?? [];
// Pour compatibilité avec l'ancien système
$billingType = $clientData['billing_type'] ?? null;
$monthlyAmount = $clientData['monthly_package_amount'] ?? null;
$hourlyRate = $clientData['hourly_rate'] ?? null;
$contractServiceType = $clientData['contract_service_type'] ?? null;
@endphp
{{ $dayShortNames[$dayKey] }}
@if($hasTasks)
@php
$tasks = $dayData['tasks'] ?? [];
$hasCleaning = false; $hasDish = false; $hasBin = false; $hasIron = false;
foreach ($tasks as $t) {
$s = strtolower((string)$t);
if (!$hasCleaning && (str_contains($s,'nettoyage')||str_contains($s,'ménage')||str_contains($s,'cleaning')||str_contains($s,'menage'))) { $hasCleaning = true; }
if (!$hasDish && (str_contains($s,'vaisselle')||str_contains($s,'dish')||str_contains($s,'couvert'))) { $hasDish = true; }
if (!$hasBin && (str_contains($s,'poubelle')||str_contains($s,'trash')||str_contains($s,'garbage')||str_contains($s,'bin'))) { $hasBin = true; }
if (!$hasIron && (str_contains($s,'repassage')||str_contains($s,'ironing'))) { $hasIron = true; }
}
@endphp
{{-- Groupe ménage (balai) --}}
@if($hasCleaning)
@else
@if(($dayData['morning'] ?? false) || ($dayData['evening'] ?? false))
@endif
{{-- Icônes de tâches séparées --}}
@if($hasDish)
@endif
@if($hasBin)
@if($dayData['morning'] ?? false)
@endif
@if(($dayData['morning'] ?? false) || ($dayData['evening'] ?? false))
@endif
@if($hasIron)
@endif
@if($dayData['morning'] ?? false)
@endif
@if($totalCleaning > 0)
{{ $totalCleaning }} fois/semaine
{{-- Informations du contrat sous ménage --}}
@if(!empty($cleaningContracts))
@foreach($cleaningContracts as $contract)
{{ $contract['billing_type'] === 'package' ? 'Forfait' : 'À l\'heure' }} — Ménage
@php
$hasTotal = isset($contract['total_amount']) && $contract['total_amount'] !== null && $contract['total_amount'] !== '';
@endphp
@if($hasTotal)
{{ number_format((float) $contract['total_amount'], 2, ',', ' ') }}{{ $contract['billing_type'] === 'package' ? '€/mois' : '€/h' }}
@elseif($contract['billing_type'] === 'package' && !empty($contract['monthly_package_amount']))
{{ number_format((float) $contract['monthly_package_amount'], 2, ',', ' ') }}€/mois
@elseif($contract['billing_type'] === 'hourly' && !empty($contract['hourly_rate']))
{{ number_format((float) $contract['hourly_rate'], 2, ',', ' ') }}€/h
@else
Non défini
@endif
{{ $totalBin }} fois/semaine
{{-- Informations du contrat sous poubelle (contrat séparé) --}}
@if(!empty($binContracts))
@foreach($binContracts as $contract)
{{ ($contract['billing_type'] ?? '') === 'package' ? 'Forfait' : 'À l\'heure' }} — Poubelle
@php $hasTotal = isset($contract['total_amount']) && $contract['total_amount'] !== null && $contract['total_amount'] !== ''; @endphp
@if($hasTotal)
{{ number_format((float) $contract['total_amount'], 2, ',', ' ') }}{{ ($contract['billing_type'] ?? '') === 'package' ? '€/mois' : '€/h' }}
@elseif(($contract['billing_type'] ?? '') === 'package' && !empty($contract['monthly_package_amount']))
{{ number_format((float) $contract['monthly_package_amount'], 2, ',', ' ') }}€/mois
@elseif(($contract['billing_type'] ?? '') === 'hourly' && !empty($contract['hourly_rate']))
{{ number_format((float) $contract['hourly_rate'], 2, ',', ' ') }}€/h
@else
Non défini
@endif
{{ $totalIron }} fois/semaine
{{-- Informations du contrat sous repassage (contrat séparé) --}}
@if(!empty($ironingContracts))
@foreach($ironingContracts as $contract)
{{ ($contract['billing_type'] ?? '') === 'package' ? 'Forfait' : 'À l\'heure' }} — Repassage
@php $hasTotal = isset($contract['total_amount']) && $contract['total_amount'] !== null && $contract['total_amount'] !== ''; @endphp
@if($hasTotal)
{{ number_format((float) $contract['total_amount'], 2, ',', ' ') }}{{ ($contract['billing_type'] ?? '') === 'package' ? '€/mois' : '€/h' }}
@elseif(($contract['billing_type'] ?? '') === 'package' && !empty($contract['monthly_package_amount']))
{{ number_format((float) $contract['monthly_package_amount'], 2, ',', ' ') }}€/mois
@elseif(($contract['billing_type'] ?? '') === 'hourly' && !empty($contract['hourly_rate']))
{{ number_format((float) $contract['hourly_rate'], 2, ',', ' ') }}€/h
@else
Non défini
@endif
{{ $totalDishwashing }} fois/semaine
{{-- Informations du contrat sous vaisselle --}}
@if(!empty($dishwashingContracts))
@foreach($dishwashingContracts as $contract)
{{ $contract['billing_type'] === 'package' ? 'Forfait' : 'À l\'heure' }} — Vaisselle
@php
$hasTotal = isset($contract['total_amount']) && $contract['total_amount'] !== null && $contract['total_amount'] !== '';
@endphp
@if($hasTotal)
{{ number_format((float) $contract['total_amount'], 2, ',', ' ') }}{{ $contract['billing_type'] === 'package' ? '€/mois' : '€/h' }}
@elseif($contract['billing_type'] === 'package' && !empty($contract['monthly_package_amount']))
{{ number_format((float) $contract['monthly_package_amount'], 2, ',', ' ') }}€/mois
@elseif($contract['billing_type'] === 'hourly' && !empty($contract['hourly_rate']))
{{ number_format((float) $contract['hourly_rate'], 2, ',', ' ') }}€/h
@else
Non défini
@endif
@if($hasCleaningContracts)
@endif
0 fois/semaine
@foreach($cleaningContracts as $contract)
{{ ($contract['billing_type'] ?? '') === 'package' ? 'Forfait' : 'À l\'heure' }} — Ménage
@php $hasTotal = isset($contract['total_amount']) && $contract['total_amount'] !== null && $contract['total_amount'] !== ''; @endphp
@if($hasTotal)
{{ number_format((float) $contract['total_amount'], 2, ',', ' ') }}{{ ($contract['billing_type'] ?? '') === 'package' ? '€/mois' : '€/h' }}
@elseif(($contract['billing_type'] ?? '') === 'package' && !empty($contract['monthly_package_amount']))
{{ number_format((float) $contract['monthly_package_amount'], 2, ',', ' ') }}€/mois
@elseif(($contract['billing_type'] ?? '') === 'hourly' && !empty($contract['hourly_rate']))
{{ number_format((float) $contract['hourly_rate'], 2, ',', ' ') }}€/h
@else
Non défini
@endif
0 fois/semaine
@foreach($dishwashingContracts as $contract)
{{ ($contract['billing_type'] ?? '') === 'package' ? 'Forfait' : 'À l\'heure' }}
@php $hasTotal = isset($contract['total_amount']) && $contract['total_amount'] !== null && $contract['total_amount'] !== ''; @endphp
@if($hasTotal)
{{ number_format((float) $contract['total_amount'], 2, ',', ' ') }}{{ ($contract['billing_type'] ?? '') === 'package' ? '€/mois' : '€/h' }}
@elseif(($contract['billing_type'] ?? '') === 'package' && !empty($contract['monthly_package_amount']))
{{ number_format((float) $contract['monthly_package_amount'], 2, ',', ' ') }}€/mois
@elseif(($contract['billing_type'] ?? '') === 'hourly' && !empty($contract['hourly_rate']))
{{ number_format((float) $contract['hourly_rate'], 2, ',', ' ') }}€/h
@else
Non défini
@endif
|
@php
// Determine a primary contract id for edit/delete actions (with server fallback)
$primaryContractId = $clientData['row_contract_id'] ?? null;
if (!empty($cleaningContracts)) {
$primaryContractId = $primaryContractId ?: ($cleaningContracts[0]['id'] ?? null);
}
if (!$primaryContractId && !empty($dishwashingContracts)) {
$primaryContractId = $dishwashingContracts[0]['id'] ?? null;
}
if (!$primaryContractId && !empty($clientData['primary_contract_id'] ?? null)) {
$primaryContractId = $clientData['primary_contract_id'];
}
@endphp
|
@php
$today = \Carbon\Carbon::now();
$startDate = $contractStartDate ? \Carbon\Carbon::parse($contractStartDate) : null;
$endDate = $contractEndDate ? \Carbon\Carbon::parse($contractEndDate) : null;
$status = 'unknown';
$statusLabel = 'Inconnu';
$statusClass = 'secondary';
$statusIcon = 'fas fa-question-circle';
if ($startDate) {
if ($startDate > $today) {
// Contrat futur
$status = 'future';
$statusLabel = 'Futur';
$statusClass = 'info';
$statusIcon = 'fas fa-clock';
} elseif ($endDate && $endDate < $today) {
// Contrat terminé
$status = 'terminated';
$statusLabel = 'Terminé';
$statusClass = 'danger';
$statusIcon = 'fas fa-stop-circle';
} else {
// Contrat en cours
$status = 'active';
$statusLabel = 'En cours';
$statusClass = 'success';
$statusIcon = 'fas fa-play-circle';
}
}
@endphp
{{ $statusLabel }}
|
Aucun client assignéAucun client n'a encore été assigné pour le ménage. |
|||||||