@extends('layouts.app') @section('title', 'Détails de la réservation #' . ($booking->id ?? 'N/A')) @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 ?? 0); // Function to clean session ID from notes for display function cleanNotesForDisplay($notes) { if (!$notes) return null; return trim(preg_replace('/\[SESSION:[^\]]+\]/', '', $notes)) ?: null; } @endphp

Détails de la réservation

#{{ $booking->booking_number ?? 'N/A' }} - {{ Str::limit($booking->service->name ?? 'Service supprimé', 60) }}
@if(($booking->status ?? '') === 'pending') En attente de confirmation @elseif(($booking->status ?? '') === 'confirmed') Confirmée @elseif(($booking->status ?? '') === 'completed') Terminée @elseif(($booking->status ?? '') === 'cancelled') Annulée @elseif(($booking->status ?? '') === 'refused') Refusée @else Statut inconnu @endif
@if(($booking->status ?? '') === 'pending' && $booking->service) @elseif(($booking->status ?? '') === 'confirmed' && $booking->service) @php $paymentReq = $booking->service->payment_requirement ?? 'none'; @endphp @if(in_array($paymentReq, ['none', 'deposit']) && ($booking->payment_status ?? '') !== 'paid') @endif @elseif(($booking->status ?? '') === 'completed' && ($booking->payment_status ?? '') !== 'paid') @php $paymentReqCompleted = $booking->service->payment_requirement ?? 'none'; @endphp @if(in_array($paymentReqCompleted, ['none', 'deposit'])) @endif @elseif(($booking->status ?? '') === 'completed') @php $prestataireId = auth()->user()->prestataire ? auth()->user()->prestataire->id : null; $hasReviewedClient = $prestataireId ? \App\Models\ClientReview::where('prestataire_id', $prestataireId) ->where('booking_id', $booking->id) ->exists() : false; $clientUserId = $booking->client && $booking->client->user ? $booking->client->user->id : null; @endphp @if(!$hasReviewedClient) Noter ce client @else Client noté @endif @if($clientUserId) Voir les avis du client @endif @endif
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif @if(($booking->status ?? '') === 'pending' && !$booking->service)

Impossible d'accepter ou refuser cette réservation car le service a été supprimé.

@elseif(($booking->status ?? '') === 'confirmed' && !$booking->service)

Impossible de marquer cette réservation comme terminée car le service a été supprimé.

@endif

Informations du client

@if($booking->client && $booking->client->user && $booking->client->user->profile_photo_url) {{ $booking->client->first_name ?? '' }} {{ $booking->client->last_name ?? '' }} @else
{{ substr($booking->client->first_name ?? '', 0, 1) }}{{ substr($booking->client->last_name ?? '', 0, 1) }}
@endif

{{ $booking->client->first_name ?? '' }} {{ $booking->client->last_name ?? '' }}

{{-- Note et avis du client --}} @if($booking->client && $booking->client->user) @php $clientUser = $booking->client->user; $clientRating = $clientUser->client_rating; $reviewsCount = $clientUser->client_reviews_count; $wouldWorkAgain = $clientUser->would_work_again_percentage; @endphp @if($reviewsCount > 0)
@for($i = 1; $i <= 5; $i++) @endfor {{ number_format($clientRating, 1) }}

{{ $reviewsCount }} avis

@if($wouldWorkAgain !== null)

{{ $wouldWorkAgain }}% retravailleraient avec ce client

@endif Voir tous les avis →
@else

Nouveau client - Pas encore d'avis

@endif @endif
Email
{{ ($booking->client && $booking->client->user) ? ($booking->client->user->email ?? $booking->client->email) : 'N/A' }}
@if($booking->client && $booking->client->phone)
Téléphone
{{ $booking->client->phone }}
@endif @if($booking->client && $booking->client->address)
Adresse
{{ $booking->client->address }}
@endif
Membre depuis
{{ $booking->client && $booking->client->created_at ? $booking->client->created_at->format('F Y') : 'N/A' }}

Détails du service

Service
{{ $booking->service->name ?? 'Service non disponible' }}
Catégorie
@if($booking->service && $booking->service->category) {{ $booking->service->category->first()->name ?? 'Non spécifiée' }} @else Non spécifiée @endif
Prix
{{ number_format($booking->total_price ?? 0, 2, ',', ' ') }} €
Durée
{{ $booking->getDurationFormatted() }}
@if($booking->service && $booking->service->description)
Description
{{ $booking->service->description }}
@endif

Détails de la réservation

Début
{{ $booking->start_datetime ? $booking->start_datetime->format('d/m/Y') : 'N/A' }}
{{ $booking->start_datetime ? $booking->start_datetime->format('H:i') : 'N/A' }}
Fin
{{ $booking->end_datetime ? $booking->end_datetime->format('d/m/Y') : 'N/A' }}
{{ $booking->end_datetime ? $booking->end_datetime->format('H:i') : 'N/A' }}
@if($isMultiSlotSession)
Session multiple
{{ $allBookings->count() }} créneaux - Total: {{ number_format($totalSessionPrice, 2, ',', ' ') }} €
@endif @if(cleanNotesForDisplay($booking->client_notes))
Notes du client
{{ cleanNotesForDisplay($booking->client_notes) }}
@endif @if(cleanNotesForDisplay($booking->prestataire_notes))
Vos notes
{{ cleanNotesForDisplay($booking->prestataire_notes) }}
@endif

Résumé

Numéro: #{{ $booking->booking_number ?? 'N/A' }}
Création: {{ $booking->created_at ? $booking->created_at->format('d/m/Y') : 'N/A' }}
Statut: @if(($booking->status ?? '') === 'pending') En attente @elseif(($booking->status ?? '') === 'confirmed') Confirmée @elseif(($booking->status ?? '') === 'completed') Terminée @elseif(($booking->status ?? '') === 'cancelled') Annulée @elseif(($booking->status ?? '') === 'refused') Refusée @else Statut inconnu @endif

Total: {{ number_format($booking->total_price ?? 0, 2, ',', ' ') }} €

Communication

@if($booking->client && $booking->client->user) Message @if($booking->client->user->phone) Appeler @endif @else
Contact non disponible
@endif
@endsection @push('scripts') @endpush {{-- Rappel pour activer les notifications (contexte réservation) --}} @include('components.notification-context-alert', ['context' => 'booking'])