@php $fmt = function($v) { return ($v != 0) ? \App\Helpers\TimeHelper::decimalToHours($v) : '—'; }; $fmtRecup = function($line, $v) use ($fmt) { return $line->is_conversion ? '—' : $fmt($v); }; @endphp

📊 Synthèse de la Période @if($isDelegation) | {{ $displayUser->firstname }} {{ $displayUser->name }} @endif

@if($isDelegation)

⚠️ Mode Délégation Actif

@endif
@include('partials.unprinted_alert') {{-- SÉLECTEUR DE MOIS --}}

📅 Période sélectionnée

{{-- DÉTAILS PAR FILIÈRE --}} @foreach($linesByFiliere as $fId => $group) @php $filiere = $group['filiere']; $lines = $group['lines']; $serviceGroup = $group['service']; if ($serviceGroup) { $nStartNuit = \Carbon\Carbon::parse($serviceGroup->heure_nuit_debut)->format('H\h'); $nEndNuit = \Carbon\Carbon::parse($serviceGroup->heure_nuit_fin)->format('H\h'); $mentionNuitLabel = "Heures de nuit
$nStartNuit-$nEndNuit"; } else { $nStartNuit = '--'; $nEndNuit = '--'; $mentionNuitLabel = "Heures de nuit"; } // RÉCUPÉRATION DES JOURS FÉRIÉS DU MOIS POUR CETTE FILIÈRE $joursFeries = $filiere->joursFeries() ->whereBetween('date_ferie', [ $activeMois->copy()->startOfMonth(), $activeMois->copy()->endOfMonth() ]) ->pluck('date_ferie') ->map(fn($d) => $d->format('Y-m-d')) ->toArray(); @endphp

📂 SERVICE : {{ $serviceGroup ? $serviceGroup->libelle_service : 'SERVICE INCONNU' }}

🖨️ IMPRIMER LA SYNTHÈSE @if(!$isDelegation) @php $sigAgent = \App\Models\Signature::where('id_user', $displayUser->id) ->where('id_service', $serviceGroup->id_service) ->where('mois', $activeMois->startOfMonth()) ->where('role_signature', 'AGENT') ->first(); $sigChef = \App\Models\Signature::where('id_user', $displayUser->id) ->where('id_service', $serviceGroup->id_service) ->where('mois', $activeMois->startOfMonth()) ->where('role_signature', 'CHEF') ->first(); $isPastHRDate = \App\Models\Parametre::isPastHRDate($activeMois); @endphp @if(!$sigChef && !$isPastHRDate) @if(!$sigAgent) {{-- Bouton de soumission électronique (signature agent) --}}
@csrf
@else {{-- Déjà soumis, attente chef --}} ✔ Soumis — En attente chef @endif @elseif($sigChef) ✅ Validé électroniquement @endif @endif
{{-- TABLEAU HS DÉTAILLÉ (READ ONLY) --}} @if($lines->count() > 0)

Détail des Heures Supplémentaires

@php $nbColRecup = ($filiere->activer_dimanche_ferie ? 4 : 5); if (!$filiere->dimanche_ferie_recuperable) { $nbColRecup -= ($filiere->activer_dimanche_ferie ? 1 : 2); } @endphp {{-- Récup --}} @if($filiere->dimanche_ferie_recuperable) @if($filiere->activer_dimanche_ferie) @else @endif @endif {{-- Paye --}} @if($filiere->appliquer_seuil_paie) @endif @if($filiere->activer_dimanche_ferie) @else @endif @foreach($lines as $line) @php $isFerie = in_array($line->date_realisation->format('Y-m-d'), $joursFeries); $isWeekend = $line->date_realisation->isWeekend(); $colorClass = ''; if ($isFerie) $colorClass = 'text-red-600'; elseif ($isWeekend) $colorClass = 'text-amber-500'; @endphp {{-- Récup --}} @if($filiere->dimanche_ferie_recuperable) @if($filiere->activer_dimanche_ferie) @else @endif @endif {{-- Paye --}} @if($filiere->appliquer_seuil_paie) @endif @if($filiere->activer_dimanche_ferie) @else @endif @endforeach @php $normalLines = $lines->whereNull('id_source_conversion'); @endphp {{-- Récup Bruts --}} @if($filiere->dimanche_ferie_recuperable) @if($filiere->activer_dimanche_ferie) @else @endif @endif {{-- Paye Bruts --}} @if($filiere->appliquer_seuil_paie) @endif @if($filiere->activer_dimanche_ferie) @else @endif {{-- Ligne : TAUX DE MAJORATION --}} {{-- Récup --}} @if($filiere->dimanche_ferie_recuperable) @if($filiere->activer_dimanche_ferie) @else @endif @endif {{-- Paye --}} {{-- Ligne des TOTAUX MAJORÉS --}} {{-- Récup Majorés --}} @if($filiere->dimanche_ferie_recuperable) @if($filiere->activer_dimanche_ferie) @else @endif @endif {{-- Paye Majorés (N/A) --}}
Date Début Fin Travail effectué Total BrutRécupération Paiement Motif
{{ $filiere->n_premieres_heures }} premières
heures
Au-delà des {{ $filiere->n_premieres_heures }}
premières heures
{!! $mentionNuitLabel !!}Dimanches et
jours fériés
Au-delà des
18ers dimanches
1er MaiHeures
de
jour
Au-delà des {{ $filiere->n_premieres_heures }}
premières heures
{!! $mentionNuitLabel !!}Dimanches et
jours fériés
Au-delà des
18ers dimanches
1er Mai
{{ ucfirst(str_replace('.', '', $line->date_realisation->translatedFormat('D d M'))) }} {{ \Carbon\Carbon::parse($line->heure_debut)->format('H:i') }} {{ \Carbon\Carbon::parse($line->heure_fin)->format('H:i') }} {{ $line->travail_effectue }} {{ $line->total_raw_fmt }}{{ $fmtRecup($line, abs($line->raw_n_premieres)) }} {{ $fmtRecup($line, abs($line->raw_suivantes)) }} {{ $fmtRecup($line, abs($line->raw_nuit)) }}{{ $fmtRecup($line, abs($line->raw_dimanche_ferie)) }}{{ $fmtRecup($line, abs($line->raw_dim_suiv)) }} {{ $fmtRecup($line, abs($line->raw_1er_mai)) }}{{ $fmt(abs($line->paye_n_premieres)) }}{{ $fmt(abs($line->paye_suivantes)) }}{{ $fmt(abs($line->paye_nuit)) }}{{ $fmt(abs($line->paye_dimanche_ferie)) }}{{ $fmt(abs($line->paye_dim_suiv)) }} {{ $fmt(abs($line->paye_1er_mai)) }}{{ $line->motif->libelle_motif }}
TOTAUX BRUTS {{ $fmt(abs($normalLines->sum('total_raw'))) }} {{ $fmt(abs($normalLines->sum('raw_n_premieres'))) }} {{ $fmt(abs($normalLines->sum('raw_suivantes'))) }} {{ $fmt(abs($normalLines->sum('raw_nuit'))) }}{{ $fmt(abs($normalLines->sum('raw_dimanche_ferie'))) }}{{ $fmt(abs($normalLines->sum('raw_dim_suiv'))) }} {{ $fmt(abs($normalLines->sum('raw_1er_mai'))) }}{{ $fmt(abs($lines->sum('paye_n_premieres'))) }}{{ $fmt(abs($lines->sum('paye_suivantes'))) }}{{ $fmt(abs($lines->sum('paye_nuit'))) }}{{ $fmt(abs($lines->sum('paye_dimanche_ferie'))) }}{{ $fmt(abs($lines->sum('paye_dim_suiv'))) }} {{ $fmt(abs($lines->sum('paye_1er_mai'))) }}
Taux majoration x{{ $filiere->coeff_premieres_heures ?? '?' }} x{{ $filiere->coeff_heures_suivantes ?? '?' }} x{{ $filiere->coeff_nuit ?? '?' }}x{{ $filiere->coeff_dimanche_ferie ?? '?' }}x{{ $filiere->coeff_dimanches_suivants ?? '?' }} x{{ $filiere->coeff_dimanche_ferie ?? '?' }}
Totaux Majorés @php $sumMaj = $normalLines->sum('maj_n_premieres') + $normalLines->sum('maj_suivantes'); $sumMaj += $normalLines->sum('maj_nuit'); if ($filiere->activer_dimanche_ferie) { $sumMaj += $normalLines->sum('maj_dimanche_ferie'); } else { $sumMaj += $normalLines->sum('maj_dim_suiv') + $normalLines->sum('maj_1er_mai'); } @endphp {{ $sumMaj > 0 ? \App\Helpers\TimeHelper::decimalToHours($sumMaj) : '-' }} {{ $fmt(abs($normalLines->sum('maj_n_premieres'))) }} {{ $fmt(abs($normalLines->sum('maj_suivantes'))) }} {{ $fmt(abs($normalLines->sum('maj_nuit'))) }} {{ $fmt(abs($normalLines->sum('maj_dimanche_ferie'))) }} {{ $fmt(abs($normalLines->sum('maj_dim_suiv'))) }} {{ $fmt(abs($normalLines->sum('maj_1er_mai'))) }} -
{{-- Heures transposées --}} @php $conversions = $lines->where('is_conversion', true); $totalTransposed = $conversions->sum('valeur_majoree'); @endphp @if($conversions->isNotEmpty())
🔄 Heures transposées Heures majorées converties en paiement, retirées du solde de récupération.
{{ \App\Helpers\TimeHelper::decimalToHours($totalTransposed) }}
@endif @endif {{-- TABLEAU ASTREINTES DÉTAILLÉ --}} @if($group['astreintes']->count() > 0)

Détail des Astreintes

@php $hasRecupFiliere = $group['astreintes']->sum('heures_recup') > 0; $hasPayeFiliere = $group['astreintes']->filter(fn($a) => trim($a->type_demande) !== 'recup')->count() > 0; @endphp @if($hasRecupFiliere) @endif @if($hasPayeFiliere) @endif @foreach($group['astreintes'] as $ast) @php $isFerieAst = in_array($ast->date_debut->format('Y-m-d'), $joursFeries) || in_array($ast->date_fin->format('Y-m-d'), $joursFeries); $isWeekendAst = $ast->date_debut->isWeekend() || $ast->date_fin->isWeekend(); $textClass = 'text-gray-600'; $bgClass = 'hover:bg-gray-50'; if ($isFerieAst) { $textClass = 'text-red-600 font-bold'; $bgClass = 'bg-red-50/50 hover:bg-red-50'; } elseif ($isWeekendAst) { $textClass = 'text-amber-600 font-bold'; $bgClass = 'bg-amber-50/50 hover:bg-amber-50'; } @endphp @if($hasRecupFiliere) @endif @if($hasPayeFiliere) @endif @endforeach @php $sumRecupFiliere = $group['astreintes']->sum('heures_recup'); $totalPayeFiliere = $group['astreintes']->filter(fn($a) => trim($a->type_demande) !== 'recup')->count(); @endphp @if($hasRecupFiliere || $hasPayeFiliere) @if($hasRecupFiliere) @endif @if($hasPayeFiliere) @endif @endif
Période Type d'astreinteAcquisition Récup.Acquisition PayeMotif
Du {{ ucfirst(str_replace('.', '', $ast->date_debut->translatedFormat('D d M'))) }} au {{ ucfirst(str_replace('.', '', $ast->date_fin->translatedFormat('D d M'))) }}
@if(!($ast->categorie->ne_pas_afficher_dans_libelle ?? false)) {{ $ast->categorie->libelle_categorie ?? '' }} - @endif {{ $ast->typeAstreinte->libelle_astreinte }} @if($ast->majore) (Majorée) @endif
{{ $ast->heures_recup > 0 ? $ast->heures_recup_fmt : '' }} {{ trim($ast->type_demande) !== 'recup' ? '1' : '-' }} {{ $ast->motif->libelle_motif ?? '-' }}
Total Astreintes {{ $filiere->nom_filiere }} {{ $fmt($sumRecupFiliere) }} {{ $totalPayeFiliere }}
@endif
@endforeach {{-- TABLEAU DE SYNTHÈSE GLOBALE --}}

📈 Bilan de Récupération : {{ $activeMois->translatedFormat('F Y') }}

Calculé selon les règles RH
{{-- Col 1 : État Initial --}}
Situation au début du mois
Solde reporté {{ $fmt($soldeDebut) }}

Reliquat des heures restant à récupérer avant ce mois.

{{-- Col 2 : Flux du mois --}}
Mouvements cumulés du mois
@php $totalHS = 0; $totalAst = 0; $totalTransposedGlobal = 0; @endphp @foreach($linesByFiliere as $fId => $group) @php $hsMaj = $group['lines']->whereNull('id_source_conversion')->sum(function($l) { return $l->maj_n_premieres + $l->maj_suivantes + $l->maj_nuit + $l->maj_dimanche_ferie + $l->maj_dim_suiv + $l->maj_1er_mai; }); $astMaj = $group['astreintes']->sum('heures_recup'); $totalHS += $hsMaj; $totalAst += $astMaj; @endphp @endforeach
Acquisitions Heures Supp. + {{ $fmt($totalHS) }}
Acquisitions Astreintes + {{ $fmt($totalAst) }}
@if($totalTransposedGlobal > 0)
🔄 Heures transposées en paiement
{{ $fmt($totalTransposedGlobal) }}
@endif
➖ Récupérations prises ce mois (Absences)
- {{ $fmt($totalConsommationMonth) }}
{{-- Footer : Solde Final --}}
{{-- Détail de la perte --}}
Reporté en {{ $nomMoisSuivant }}
{{ $fmt($soldeSuivant) }}
Validité des acquisitions : {{ \Carbon\Carbon::parse(\App\Models\Parametre::calculateDefaultExpiration($activeMois))->format('d/m/Y') }}
{{-- Totaux du mois --}}
Total Acquisitions Récup. + {{ $fmt($totalMajMonth + $totalAstreintesMonth) }}
@php $nbAstreintesPaye = $astreintesMonth->filter(fn($a) => trim($a->type_demande) !== 'recup')->count(); @endphp @if($nbAstreintesPaye > 0)
Nb. Astreintes à Payer {{ $nbAstreintesPaye }}
@endif @if(isset($conversionsMonth) && $conversionsMonth > 0)
Total Conversion {{ $fmt($conversionsMonth) }}
@endif
Total Consommations - {{ $fmt($totalConsommationMonth) }}
{{-- Validation Modal --}}