@extends('layouts.app') @section('content') @php // Ensure variables are defined for backward compatibility $isMultiSlotSession = $isMultiSlotSession ?? false; $allBookings = $allBookings ?? collect([$booking]); $relatedBookings = $relatedBookings ?? collect(); $totalSessionPrice = $totalSessionPrice ?? $booking->total_price; // Function to clean session ID from notes for display function cleanNotesForDisplay($notes) { if (!$notes) return null; return trim(preg_replace('/\[SESSION:[^\]]+\]/', '', $notes)) ?: null; } // Status configuration $statusConfig = [ 'pending' => ['bg' => 'bg-gradient-to-r from-amber-400 to-orange-400', 'text' => 'text-white', 'icon' => 'fa-hourglass-half', 'label' => 'En attente', 'light' => 'bg-amber-50 border-amber-200 text-amber-800'], 'confirmed' => ['bg' => 'bg-gradient-to-r from-emerald-400 to-green-500', 'text' => 'text-white', 'icon' => 'fa-check-circle', 'label' => 'Confirmée', 'light' => 'bg-emerald-50 border-emerald-200 text-emerald-800'], 'completed' => ['bg' => 'bg-gradient-to-r from-blue-400 to-indigo-500', 'text' => 'text-white', 'icon' => 'fa-flag-checkered', 'label' => 'Terminée', 'light' => 'bg-blue-50 border-blue-200 text-blue-800'], 'cancelled' => ['bg' => 'bg-gradient-to-r from-red-400 to-rose-500', 'text' => 'text-white', 'icon' => 'fa-times-circle', 'label' => 'Annulée', 'light' => 'bg-red-50 border-red-200 text-red-800'], 'refused' => ['bg' => 'bg-gradient-to-r from-gray-400 to-slate-500', 'text' => 'text-white', 'icon' => 'fa-ban', 'label' => 'Refusée', 'light' => 'bg-gray-50 border-gray-200 text-gray-800'], ]; $currentStatus = $statusConfig[$booking->status] ?? $statusConfig['pending']; @endphp
@php $previousUrl = url()->previous(); $currentUrl = url()->current(); if ($previousUrl === $currentUrl || empty($previousUrl)) { $backUrl = auth()->user()->role === 'prestataire' ? route('prestataire.bookings.index') : route('client.bookings.index'); } else { $backUrl = $previousUrl; } @endphp Retour aux réservations
{{ $currentStatus['label'] }} @if($isMultiSlotSession) {{ $allBookings->count() }} créneaux @endif

@if($isMultiSlotSession) Session #{{ $booking->booking_number }} @else Réservation #{{ $booking->booking_number }} @endif

{{ $booking->service->name }}

Montant total
{{ number_format($isMultiSlotSession ? $totalSessionPrice : $booking->total_price, 2) }} €
@if($isMultiSlotSession) Du {{ $allBookings->first()->start_datetime->format('d/m') }} au {{ $allBookings->last()->end_datetime->format('d/m/Y') }} @else {{ $booking->start_datetime->locale('fr')->isoFormat('dddd D MMMM YYYY') }} @endif
@include('bookings.partials.flash-messages') @if($isMultiSlotSession) @endif

Détails de la réservation

Date
{{ $booking->start_datetime->locale('fr')->isoFormat('dddd D MMMM') }}
{{ $booking->start_datetime->format('Y') }}
Horaire
{{ $booking->start_datetime->format('H:i') }} - {{ $booking->end_datetime->format('H:i') }}
@if($booking->service->price_type === 'heure' && $booking->service->quantity) {{ $booking->service->quantity }} heure{{ $booking->service->quantity > 1 ? 's' : '' }} @elseif($booking->service->price_type === 'jour' && $booking->service->quantity) {{ $booking->service->quantity }} jour{{ $booking->service->quantity > 1 ? 's' : '' }} @else {{ $booking->getDurationFormatted() }} @endif
Prix
{{ number_format($booking->total_price, 2) }} €
@if($booking->service->price_type === 'heure') {{ number_format($booking->service->price, 2) }} €/h @elseif($booking->service->price_type === 'jour') {{ number_format($booking->service->price, 2) }} €/jour @else Forfait @endif
Créée le
{{ $booking->created_at->locale('fr')->isoFormat('D MMM YYYY') }}
à {{ $booking->created_at->format('H:i') }}

Service réservé

@if($booking->service->image) {{ $booking->service->name }} @else
@endif

{{ $booking->service->name }}

@if($booking->service->description)

{{ Str::limit($booking->service->description, 120) }}

@endif Voir le service
@if($booking->status === 'confirmed' && $booking->confirmed_at)
Réservation confirmée
Le {{ $booking->confirmed_at->locale('fr')->isoFormat('D MMMM YYYY à HH:mm') }}
@elseif($booking->status === 'completed' && $booking->completed_at)
Prestation terminée
Le {{ $booking->completed_at->locale('fr')->isoFormat('D MMMM YYYY à HH:mm') }}
@elseif($booking->status === 'cancelled' || $booking->status === 'refused')
{{ $booking->status === 'cancelled' ? 'Réservation annulée' : 'Réservation refusée' }}
@if($booking->cancelled_at)
Le {{ $booking->cancelled_at->locale('fr')->isoFormat('D MMMM YYYY à HH:mm') }}
@endif @if($booking->cancellation_reason)
Raison: {{ $booking->cancellation_reason }}
@endif
@endif @php $cleanClientNotes = cleanNotesForDisplay($booking->client_notes); $cleanPrestataireNotes = cleanNotesForDisplay($booking->prestataire_notes); @endphp @if($cleanClientNotes || $cleanPrestataireNotes)

Notes

@if($cleanClientNotes)
Note du client

{{ $cleanClientNotes }}

@endif @if($cleanPrestataireNotes)
Note du prestataire

{{ $cleanPrestataireNotes }}

@endif
@endif

Actions

{{ $currentStatus['label'] }}
@if(isset($isMultiSlotSession) && $isMultiSlotSession)
Session de {{ $allBookings->count() }} créneaux
@endif
@if(auth()->user()->role === 'prestataire') @if($booking->status === 'pending')
@csrf
@elseif($booking->status === 'confirmed')
@csrf
@endif @endif @if(auth()->user()->role === 'client' && in_array($booking->status, ['pending', 'confirmed'])) @if(\Illuminate\Support\Facades\Route::has('client.payments.form') && function_exists('booking_online_payment_enabled') && booking_online_payment_enabled()) @php $payReq = function_exists('normalize_payment_requirement_for_mode') ? normalize_payment_requirement_for_mode($booking->service->payment_requirement ?? 'none') : ($booking->service->payment_requirement ?? 'none'); $presta = $booking->prestataire ?? $booking->service?->prestataire; $hasStripe = $presta && !empty($presta->stripe_account_id); @endphp @if($payReq !== 'none' && $hasStripe) @if($booking->payment_status === 'pending') Payer maintenant @elseif($booking->payment_status === 'deposit_paid') Payer le solde @endif @endif @endif @endif
@if(auth()->user()->role === 'client')

Votre prestataire

@if($booking->prestataire->photo) {{ $booking->prestataire->user->name }} @elseif($booking->prestataire->user->avatar) {{ $booking->prestataire->user->name }} @else
{{ substr($booking->prestataire->user->name, 0, 1) }}
@endif @if($booking->prestataire->isVerified())
@endif

{{ $booking->prestataire->user->name }}

@if($booking->prestataire->isVerified()) Profil vérifié @endif @if($booking->prestataire->location)

{{ $booking->prestataire->location }}

@endif
@else

Votre client

@if($booking->client->user->avatar) {{ $booking->client->user->name }} @else
{{ substr($booking->client->user->name, 0, 1) }}
@endif

{{ $booking->client->user->name }}

Client
Envoyer un message
@endif @if($booking->status === 'completed' && auth()->user()->role === 'client') @endif
@include('bookings.partials.modals') @push('scripts') @endpush {{-- Rappel pour activer les notifications (contexte réservation) --}} @include('components.notification-context-alert', ['context' => 'booking']) @endsection