@extends('backoffice.dashboard') @section('content') @php // Calculer le nombre de nuits $nights = 0; if ($reservation->date_arrive && $reservation->date_depart) { try { $nights = \Carbon\Carbon::parse($reservation->date_arrive) ->diffInDays(\Carbon\Carbon::parse($reservation->date_depart)); } catch (Exception $e) { $nights = 0; } } // Fonction pour gérer la pluralisation en arabe pour les nuits function getNightsTextArabic($nights) { if ($nights === 1) { return 'ليلة'; } else if ($nights === 2) { return 'ليلتين'; } else if ($nights >= 3 && $nights <= 10) { return 'ليالي'; } else { return 'ليلة'; } } // Fonction pour gérer la pluralisation en arabe pour les personnes function getPersonsTextArabic($persons) { if ($persons === 1) { return 'شخص'; } else if ($persons === 2) { return 'شخصين'; } else if ($persons >= 3 && $persons <= 10) { return 'أشخاص'; } else { return 'شخص'; } } // Générer la liste des dates du séjour $datesSejour = []; if ($reservation->date_arrive && $reservation->date_depart) { $start = \Carbon\Carbon::parse($reservation->date_arrive); $end = \Carbon\Carbon::parse($reservation->date_depart); for ($i = 0; $i < $nights; $i++) { $currentDate = clone $start; $currentDate->addDays($i); $datesSejour[] = $currentDate->format('Y-m-d'); } } // Récupérer les données de restauration par jour $restaurationsJours = collect(); if (isset($reservation->restaurationsJours) && $reservation->restaurationsJours->count() > 0) { $restaurationsJours = $reservation->restaurationsJours->groupBy(function($item) { return $item->date_service ? $item->date_service->format('Y-m-d') : null; }); } // Récupérer les données de café par jour $cafeJours = collect(); if (isset($reservation->cafes) && $reservation->cafes->count() > 0) { $cafeJours = $reservation->cafes->keyBy(function($item) { return $item->date_service ? $item->date_service->format('Y-m-d') : null; }); } // Décoder les affectations archivées $affectationsArchive = []; if ($reservation->affectations_archive) { $decoded = json_decode($reservation->affectations_archive, true); if (is_array($decoded)) { $affectationsArchive = $decoded; } } // Calculer les totaux des affectations $totalMaleArchive = 0; $totalFemaleArchive = 0; $totalPersonsArchive = 0; foreach ($affectationsArchive as $aff) { $totalMaleArchive += $aff['male_personnes'] ?? 0; $totalFemaleArchive += $aff['female_personnes'] ?? 0; $totalPersonsArchive += $aff['total_personnes'] ?? 0; } @endphp

تفاصيل الحجز المؤرشف

تمت الأرشفة

معلومات الأرشفة

{{ $reservation->archived_at ? \Carbon\Carbon::parse($reservation->archived_at)->format('Y-m-d H:i:s') : '-' }}
{{ $reservation->archivedBy?->nom_prenom ?? 'غير معروف' }}

المعلومات الشخصية

{{ $reservation->user->nom_prenom ?? $reservation->nom_prenom ?? '-' }}
{{ $reservation->user->email ?? $reservation->email ?? '-' }}
{{ $reservation->user->tel ?? $reservation->telephone ?? '-' }}
{{ $reservation->user->adresse ?? $reservation->adresse ?? '-' }}

تواريخ الإقامة

{{ $reservation->date_arrive ? \Carbon\Carbon::parse($reservation->date_arrive)->format('Y-m-d') : '-' }}
{{ $reservation->date_depart ? \Carbon\Carbon::parse($reservation->date_depart)->format('Y-m-d') : '-' }}
{{ $nights }} {{ getNightsTextArabic($nights) }}
{{ $reservation->nbr_personnes ?? 0 }} {{ getPersonsTextArabic($reservation->nbr_personnes ?? 0) }}

تفاصيل الأشخاص

{{ $reservation->nbr_h ?? 0 }}
{{ $reservation->nbr_f ?? 0 }}
{{ $reservation->nbr_personnes ?? 0 }}
@if($reservation->reservationPersons && $reservation->reservationPersons->count() > 0)
التفاصيل حسب النوع
@foreach($reservation->reservationPersons as $person) @php $totalPersonnes = ($person->nbr_hommes ?? 0) + ($person->nbr_femmes ?? 0); if (!isset($person->tarif) || $person->tarif == 0) { if ($person->typeTarif) { $person->tarif = $person->typeTarif->tarif_chambre ?? 0; } } if (!isset($person->subtotal) || $person->subtotal == 0) { $person->subtotal = ($person->tarif ?? 0) * $totalPersonnes; } @endphp @endforeach
نوع الوفد نوع الإقامة رجال نساء التعريفة للفرد المجموع الفرعي إجمالي الأشخاص
@if($person->typeTarif ?? false) @php $typeName = $person->typeTarif->type_ar ?? $person->typeTarif->type_fr ?? $person->typeTarif->type_en ?? ''; $type = $person->typeTarif->type ?? ''; @endphp {{ $typeName }} @if($type == 'groupe') (مجموعة) @else (فردي) @endif @else لا توجد قيمة @endif @if($person->accomodation_type == 'chambre') غرفة @elseif($person->accomodation_type == 'tente') خيمة @else غرفة @endif {{ $person->nbr_hommes ?? 0 }} {{ $person->nbr_femmes ?? 0 }} {{ number_format($person->tarif ?? 0, 3) }} د {{ number_format($person->subtotal ?? 0, 3) }} د {{ $totalPersonnes }}
@else
لم يتم إدخال تفاصيل الأشخاص بعد
@endif
@if(count($affectationsArchive) > 0)

الغرف المعينة (سابقة)

إجمالي الرجال {{ $totalMaleArchive }}
إجمالي النساء {{ $totalFemaleArchive }}
إجمالي الأشخاص {{ $totalPersonsArchive }}
@foreach($affectationsArchive as $index => $aff)
الغرفة رقم {{ $aff['chambre_num'] ?? 'غير معروف' }} تعيين {{ $index + 1 }}
عدد الرجال
{{ $aff['male_personnes'] ?? 0 }}
عدد النساء
{{ $aff['female_personnes'] ?? 0 }}
الإجمالي
{{ $aff['total_personnes'] ?? 0 }} {{ getPersonsTextArabic($aff['total_personnes'] ?? 0) }}
@endforeach
@endif

خدمات الطعام

يتم حساب خدمات الطعام لكل شخص ولكل يوم
@php $hasRestoData = isset($restaurationsParJour) && !empty($restaurationsParJour); @endphp @if($hasRestoData) @if(isset($restaurationsParJour['general']) && count($restaurationsParJour['general']) > 0)
الخدمات العامة (طوال الإقامة)
@foreach($restaurationsParJour['general'] as $restoData) @php $resto = $restoData['restauration']; $tarif = $restoData['tarif']; $totalResto = $tarif * ($reservation->nbr_personnes ?? 0) * $nights; $nomResto = $resto->nom_ar ?? $resto->nom_fr ?? $resto->nom_en ?? 'خدمة طعام'; $descResto = $resto->description_ar ?? $resto->description_fr ?? $resto->description_en ?? ''; @endphp
{{ $nomResto }}
{{ number_format($totalResto, 3) }} د
@if($descResto)
{{ $descResto }}
@endif
{{ number_format($tarif, 3) }} د × {{ $reservation->nbr_personnes ?? 0 }} {{ getPersonsTextArabic($reservation->nbr_personnes ?? 0) }} × {{ $nights }} {{ getNightsTextArabic($nights) }}
@endforeach @endif @if(count($datesSejour) > 0) @php // Compter combien de jours ont des restaurations $joursAvecRestos = 0; foreach($datesSejour as $date) { if(isset($restaurationsParJour[$date]) && !empty($restaurationsParJour[$date])) { $joursAvecRestos++; } } @endphp @if($joursAvecRestos > 0)
@foreach($datesSejour as $index => $date) @php $restosDuJour = isset($restaurationsParJour[$date]) ? $restaurationsParJour[$date] : []; $hasRestosJour = !empty($restosDuJour); @endphp @if($hasRestosJour)
اليوم {{ $index + 1 }} {{ \Carbon\Carbon::parse($date)->format('d/m') }} {{ count($restosDuJour) }}
@endif @endforeach
@foreach($datesSejour as $index => $date) @php $restosDuJour = isset($restaurationsParJour[$date]) ? $restaurationsParJour[$date] : []; $hasRestosJour = !empty($restosDuJour); $jourTotal = 0; if ($hasRestosJour) { foreach ($restosDuJour as $restoData) { $jourTotal += $restoData['tarif'] * ($reservation->nbr_personnes ?? 0); } } @endphp @if($hasRestosJour)
اليوم {{ $index + 1 }} {{ \Carbon\Carbon::parse($date)->format('d/m/Y') }}
{{ number_format($jourTotal, 3) }} د
@foreach($restosDuJour as $restoData) @php $resto = $restoData['restauration']; $tarif = $restoData['tarif']; $totalResto = $tarif * ($reservation->nbr_personnes ?? 0); $nomResto = $resto->nom_ar ?? $resto->nom_fr ?? $resto->nom_en ?? 'خدمة طعام'; $descResto = $resto->description_ar ?? $resto->description_fr ?? $resto->description_en ?? ''; @endphp
{{ $nomResto }}
{{ number_format($totalResto, 3) }} د
@if($descResto)
{{ $descResto }}
@endif
{{ number_format($tarif, 3) }} د × {{ $reservation->nbr_personnes ?? 0 }} {{ getPersonsTextArabic($reservation->nbr_personnes ?? 0) }}
@endforeach
@endif @endforeach @else
لا توجد خدمات طعام مخصصة لأيام محددة
@endif @endif @else
لم يتم اختيار أي خدمة طعام
@endif

استراحة القهوة

@if($reservation->auberge && $reservation->auberge->pause_cafe && $reservation->auberge->tarif_cafe > 0)
سعر استراحة القهوة: {{ number_format($reservation->auberge->tarif_cafe, 3) }} د للشخص الواحد
@php $hasCafeData = isset($reservation->cafes) && $reservation->cafes->count() > 0; @endphp @if($hasCafeData && $cafeJours->isNotEmpty()) @if(count($datesSejour) > 0) @php // Compter combien de jours ont du café $joursAvecCafe = 0; foreach($datesSejour as $date) { $cafeDuJour = $cafeJours->get($date); if($cafeDuJour && $cafeDuJour->quantite > 0) { $joursAvecCafe++; } } @endphp @if($joursAvecCafe > 0)
@foreach($datesSejour as $index => $date) @php $cafeDuJour = $cafeJours->get($date); $hasCafe = $cafeDuJour && $cafeDuJour->quantite > 0; @endphp @if($hasCafe)
اليوم {{ $index + 1 }} {{ \Carbon\Carbon::parse($date)->format('d/m') }} {{ $cafeDuJour->quantite }}
@endif @endforeach
@foreach($datesSejour as $index => $date) @php $cafeDuJour = $cafeJours->get($date); $hasCafe = $cafeDuJour && $cafeDuJour->quantite > 0; $jourTotalCafe = $hasCafe ? ($cafeDuJour->total ?? 0) : 0; @endphp @if($hasCafe)
اليوم {{ $index + 1 }} {{ \Carbon\Carbon::parse($date)->format('d/m/Y') }}
{{ number_format($jourTotalCafe, 3) }} د
استراحة قهوة
{{ number_format($cafeDuJour->total, 3) }} د
الكمية {{ $cafeDuJour->quantite }}
السعر للوحدة {{ number_format($cafeDuJour->tarif_unitaire, 3) }} د
عدد الأشخاص {{ $reservation->nbr_personnes ?? 0 }}
{{ $cafeDuJour->quantite }} × {{ number_format($cafeDuJour->tarif_unitaire, 3) }} د × {{ $reservation->nbr_personnes ?? 0 }} {{ getPersonsTextArabic($reservation->nbr_personnes ?? 0) }}
@endif @endforeach @else
لم يتم اختيار قهوة لأي يوم
@endif @else
لم يتم اختيار قهوة
@endif @else
لم يتم اختيار قهوة
@endif @else
خدمة استراحة القهوة غير متوفرة
@endif

الملاحظات

{{ $reservation->remarque ?: '—' }}
ملخص الحجز المؤرشف
المركز: @if($reservation->auberge) {{ $reservation->auberge->nom_ar ?? '-' }} @else لا توجد قيمة @endif
عدد الليالي: {{ $nights }} {{ getNightsTextArabic($nights) }}
عدد النزلاء: {{ $reservation->nbr_personnes ?? 0 }} {{ getPersonsTextArabic($reservation->nbr_personnes ?? 0) }}
@if(count($affectationsArchive) > 0)
الغرف المعينة: {{ count($affectationsArchive) }} غرف
@endif @php // Calcul du total des services de restauration par jour $restoTotal = 0; if (isset($restaurationsParJour) && !empty($restaurationsParJour)) { // Restaurations générales if (isset($restaurationsParJour['general'])) { foreach ($restaurationsParJour['general'] as $restoData) { $restoTotal += $restoData['tarif'] * ($reservation->nbr_personnes ?? 0) * $nights; } } // Restaurations par jour foreach ($restaurationsParJour as $date => $restos) { if ($date !== 'general' && $date !== 'unknown') { foreach ($restos as $restoData) { $restoTotal += $restoData['tarif'] * ($reservation->nbr_personnes ?? 0); } } } } elseif ($reservation->restaurations && $reservation->restaurations->count() > 0) { foreach ($reservation->restaurations as $resto) { $prixUnitaire = $resto->pivot->tarif ?? $resto->tarif ?? 0; $restoTotal += $prixUnitaire * ($reservation->nbr_personnes ?? 0) * $nights; } } // Calcul du total du café par jour $cafeTotal = 0; if ($cafeJours->isNotEmpty()) { foreach ($cafeJours as $cafe) { $cafeTotal += $cafe->total ?? 0; } } $servicesTotal = $restoTotal + $cafeTotal; @endphp
إجمالي الإطعام: {{ number_format($restoTotal, 3) }} د
إجمالي القهوة: {{ number_format($cafeTotal, 3) }} د
إجمالي الخدمات: {{ number_format($servicesTotal, 3) }} د
التعريفة لليلة: @php $tarifNuit = 0; if ($reservation->reservationPersons && $reservation->reservationPersons->count() > 0) { foreach ($reservation->reservationPersons as $person) { $tarifNuit += $person->subtotal ?? 0; } } if ($tarifNuit == 0 && $reservation->total_price > 0 && $nights > 0) { $tarifNuit = ($reservation->total_price - $servicesTotal) / $nights; } if ($tarifNuit < 0) $tarifNuit = 0; @endphp {{ number_format($tarifNuit, 3) }} د
إجمالي الإقامة: @php $totalHebergement = $tarifNuit * $nights; @endphp {{ number_format($totalHebergement, 3) }} د
السعر الإجمالي
@php $totalFinal = $reservation->total_price ?? ($totalHebergement + $servicesTotal); @endphp {{ number_format($totalFinal, 3) }} د
حالة الحجز: مؤرشف
@if($reservation->statut_id == 3 && !empty($reservation->commentaire_motif))
سبب الرفض:

{{ $reservation->commentaire_motif }}

@endif @if($reservation->statut_id == 1 && $reservation->date_acceptation)
تاريخ القبول: {{ $reservation->date_acceptation }}
@endif
العودة إلى قائمة الأرشيف
@endsection