@php
$affectations = \App\Models\ReservationChambreTente::where('reservation_id', $reservationId)->get();
$total_aff_male = $affectations->sum('male_personnes');
$total_aff_female = $affectations->sum('female_personnes');
$allAssigned = ($total_aff_male >= $male) && ($total_aff_female >= $female);
@endphp
تاريخ الوصول: {{ $reservation->date_arrive }} —
تاريخ المغادرة: {{ $reservation->date_depart }}
عدد الذكور: {{ $male }}
عدد الاناث: {{ $female }}
المجموع: {{ $reservation->nbr_personnes }}
اختر غرفة مناسبة من القائمة التالية.
@forelse($chambres as $ch)
@php
$aff = \App\Models\ReservationChambreTente::where('chambre_tente_id',$ch->id_chambre_tente)->sum('total_personnes');
$reste = $ch->capacite - $aff;
// Récupérer les affectations actuelles de cette chambre pour CETTE réservation
$currentAffectation = \App\Models\ReservationChambreTente::where('chambre_tente_id', $ch->id_chambre_tente)
->where('reservation_id', $reservationId)
->first();
$hasCurrentAssignment = $currentAffectation ? true : false;
$currentMale = $currentAffectation ? $currentAffectation->male_personnes : 0;
$currentFemale = $currentAffectation ? $currentAffectation->female_personnes : 0;
// Déterminer le type de la chambre pour cette réservation
if ($hasCurrentAssignment) {
if ($currentMale > 0 && $currentFemale == 0) {
$assignmentType = 'male';
$assignmentLabel = 'رجال فقط';
$assignmentClass = 'sex-badge-male';
} elseif ($currentFemale > 0 && $currentMale == 0) {
$assignmentType = 'female';
$assignmentLabel = 'نساء فقط';
$assignmentClass = 'sex-badge-female';
} else {
$assignmentType = 'mixed';
$assignmentLabel = 'مختلط';
$assignmentClass = 'sex-badge-mixed';
}
}
// Récupérer toutes les affectations de cette chambre (toutes réservations)
$allAffectationsChambre = \App\Models\ReservationChambreTente::where('chambre_tente_id', $ch->id_chambre_tente)->get();
$totalMaleInRoom = $allAffectationsChambre->sum('male_personnes');
$totalFemaleInRoom = $allAffectationsChambre->sum('female_personnes');
$remainMale = $male - $total_aff_male;
$remainFemale = $female - $total_aff_female;
// Vérifier si la chambre peut être assignée (disponible et besoins restants)
$canAssignRoom = ($reste > 0) && !$allAssigned;
@endphp
الغرفة رقم: {{ $ch->num_chambre }}
الطاقة الإجمالية: {{ $ch->capacite }}
@if($totalMaleInRoom > 0 || $totalFemaleInRoom > 0)
المشغول حالياً:
@if($totalMaleInRoom > 0)
{{ $totalMaleInRoom }} رجال
@endif
@if($totalFemaleInRoom > 0)
{{ $totalFemaleInRoom }} نساء
@endif
@endif
@if($hasCurrentAssignment)
تعيينك الحالي:
@if($currentMale > 0)
{{ $currentMale }} رجال
@endif
@if($currentFemale > 0)
{{ $currentFemale }} نساء
@endif
@endif
الطاقة المتبقية: {{ $reste }}
@if($canAssignRoom)
@else
@endif
@empty
لا توجد غرف متاحة حاليا في هذا المركب.
@endforelse