@extends('layouts.app') @section('title', 'Commandes Cuisine') @push('styles') @endpush @section('content') @php $activeTab = $activeTab ?? request('tab', 'kitchen'); $pendingCount = $orders['pending']->count(); $acceptedCount = $orders['accepted']->count(); $preparingCount = $orders['preparing']->count(); $readyCount = $orders['ready']->count(); $totalKitchen = $pendingCount + $acceptedCount + $preparingCount + $readyCount; $deliveryCount = ($deliveryOrders ?? collect())->count(); $deliverySyncKey = $deliverySyncKey ?? ''; $foodIsOpen = (bool) ($prestataire->food_is_open ?? true); $toggleOpenRoute = \Illuminate\Support\Facades\Route::has('prestataire.food-orders.toggle-open') ? route('prestataire.food-orders.toggle-open') : null; $scheduledOrders = $scheduledOrders ?? collect(); $scheduledCount = $scheduledOrders->count(); $statDetails = $statDetails ?? []; @endphp
{{-- ═══════ HEADER ═══════ --}}
🍳 Cuisine Live
En direct
--:--:--
Carte interneCarte LivreursLivreurs LivraisonsLivraison MenuMenu AccueilAccueil
{{-- ═══════ STATS BAR ═══════ --}}
{{ number_format($paymentStats['revenue_today'] ?? 0, 2) }}€
CA jourCA aujourd'hui
{{ $paymentStats['paid_count_today'] ?? 0 }}
PayeesCommandes payees
{{ number_format($paymentStats['pending_payments'] ?? 0, 2) }}€
Att. ({{ $paymentStats['pending_count'] ?? 0 }})En attente ({{ $paymentStats['pending_count'] ?? 0 }})
{{ number_format($paymentStats['revenue_month'] ?? 0, 2) }}€
CA moisCA ce mois
{{ $totalKitchen }}
CuisineEn cuisine
{{-- ═══════ MAIN TABS ═══════ --}}
@if($totalKitchen > 0){{ $totalKitchen }}@endif Cuisine
@if($deliveryCount > 0){{ $deliveryCount }}@endif Livr.Livraisons
@if($scheduledCount > 0){{ $scheduledCount }}@endif Agenda
HistoHistorique
{{-- ═══════════════════════════════════════════ TAB: CUISINE ═══════════════════════════════════════════ --}}
{{-- Sub tabs mobile --}}
Att.Attente {{ $pendingCount }}
OKAcceptées {{ $acceptedCount }}
Prep.Prepa {{ $preparingCount }}
PretesPrêtes {{ $readyCount }}
{{-- ── SWIPE PANELS (Mobile) ── --}}
{{-- PANEL 0: EN ATTENTE --}}
@forelse($orders['pending'] as $order) @include('prestataire.food-orders._order_card', ['order' => $order, 'panel' => 'pending']) @empty

Aucune commande en attente

Les nouvelles commandes apparaîtront ici

@endforelse
{{-- PANEL 1: ACCEPTÉES --}}
@forelse($orders['accepted'] as $order) @include('prestataire.food-orders._order_card', ['order' => $order, 'panel' => 'accepted']) @empty
📋

Aucune commande acceptée

@endforelse
{{-- PANEL 2: EN PRÉPARATION --}}
@forelse($orders['preparing'] as $order) @include('prestataire.food-orders._order_card', ['order' => $order, 'panel' => 'preparing']) @empty
👨‍🍳

Rien en préparation

@endforelse
{{-- PANEL 3: PRÊTES --}}
@forelse($orders['ready'] as $order) @include('prestataire.food-orders._order_card', ['order' => $order, 'panel' => 'ready']) @empty

Toutes les commandes sont servies !

@endforelse
{{-- ── DESKTOP KANBAN ── --}}
@foreach(['pending' => ['⏳ En attente', $pendingCount], 'accepted' => ['✓ Acceptées', $acceptedCount], 'preparing' => ['🔥 En cuisine', $preparingCount], 'ready' => ['✅ Prêtes', $readyCount]] as $key => [$label, $count])
{{ $label }} {{ $count }}
@forelse($orders[$key] as $order) @include('prestataire.food-orders._order_card', ['order' => $order, 'panel' => $key]) @empty
@switch($key) @case('pending') ☕ @break @case('accepted') 📋 @break @case('preparing') 👨‍🍳 @break @case('ready') ✨ @break @endswitch

@switch($key) @case('pending') Aucune commande en attente @break @case('accepted') Aucune commande acceptée @break @case('preparing') Aucune préparation en cours @break @case('ready') Aucune commande prête @break @endswitch

Les nouvelles commandes apparaîtront ici

@endforelse
@endforeach
{{-- ═══════════════════════════════════════════ TAB: LIVRAISONS ═══════════════════════════════════════════ --}}
@php $internalBoard = $internalBoard ?? ['fleet' => collect(), 'stats' => []]; $internalFleet = $internalBoard['fleet'] ?? collect(); $internalStats = $internalBoard['stats'] ?? []; $internalDriverOptions = collect($internalFleet) ->map(function ($driverRoute) { return [ 'id' => (int) ($driverRoute['driver_id'] ?? 0), 'name' => (string) ($driverRoute['driver_name'] ?? 'Livreur'), ]; }) ->filter(fn ($d) => $d['id'] > 0) ->unique('id') ->values(); @endphp @if(($internalStats['drivers_total'] ?? 0) > 0)
@foreach($internalFleet as $driverRoute)
🛵 {{ $driverRoute['driver_name'] ?? 'Livreur' }}
{{ ($driverRoute['active_orders_count'] ?? 0) > 0 ? 'En tournee' : 'Disponible' }}
{{ $driverRoute['active_orders_count'] ?? 0 }} commande(s) {{ $driverRoute['remaining_points_count'] ?? 0 }} point(s) restant(s) @if(($driverRoute['remaining_eta_minutes'] ?? 0) > 0) ETA ~ {{ $driverRoute['remaining_eta_minutes'] }} min @endif
@if(!empty($driverRoute['driver_phone'])) 📞 {{ $driverRoute['driver_phone'] }} @endif @if(($driverRoute['remaining_points_count'] ?? 0) > 0)
@foreach(($driverRoute['route_points'] ?? []) as $index => $point)
{{ $index + 1 }}
{{ $point['label'] ?? 'Point de route' }}
#{{ $point['order_number'] ?? '-' }} · {{ $point['address'] ?? 'Adresse non renseignee' }}
@endforeach
@else
Aucun point en attente pour ce livreur.
@endif
@endforeach
@endif
@forelse($deliveryOrders ?? [] as $order)
#{{ $order->order_number }} @switch($order->delivery_status ?? 'pending') @case('assigned') 🛵 Livreur assigné @break @case('picked_up') 📦 Récupérée @break @case('in_transit') 🚀 En route @break @case('delivered') ✅ Livrée @break @default ⏳ En attente livreur @endswitch
👤 {{ $order->client->name ?? 'Client' }} · {{ number_format($order->total, 2) }}€
📍 {{ $order->delivery_address ?? 'Adresse non renseignée' }}
{{-- Payment info --}} @php $delPolicy = method_exists($order, 'getPaymentPolicy') ? ((array) ($order->getPaymentPolicy() ?? [])) : []; $delPType = $delPolicy['type'] ?? 'cash'; $delPaid = ($order->payment_status === 'paid'); @endphp
@if($delPType === 'cash') 💵 Espèces · @if($delPaid) ✓ Encaissé @else {{ number_format($order->total, 2) }}€ à encaisser @endif @elseif($delPType === 'deposit') 🏦 Acompte {{ $delPolicy['percent'] }}% en ligne · @if($delPaid) ✓ Payé @else Reste {{ number_format($order->total - round($order->total * $delPolicy['percent']/100, 2), 2) }}€ en espèces @endif @elseif($delPType === 'full_prepay') 💳 Payé en ligne · @if($delPaid) ✓ {{ number_format($order->total, 2) }}€ @else ⏳ En attente @endif @endif
@if($order->driver)
🛵
{{ $order->driver->user->name ?? 'Livreur' }} @if($order->driver->user->phone ?? null) 📞 {{ $order->driver->user->phone }} @endif
@else
@if(($prestataire->delivery_mode ?? 'both') === 'internal') En attente d'affectation d'un livreur interne. @else Recherche d'un livreur en cours... @endif
@php $canAssignFromCuisine = in_array((string) ($order->status ?? ''), ['accepted', 'preparing', 'ready'], true) && in_array((string) ($order->delivery_status ?? 'pending'), ['pending', 'assigned', 'self_delivery', ''], true); @endphp @if($canAssignFromCuisine) @if($internalDriverOptions->isNotEmpty())
@csrf
@else
Aucun livreur interne. Ajoutez-en dans "Livreurs".
@endif @else
Affectation indisponible pour cet état de commande.
@endif @endif
@if($delPType === 'cash' && !$delPaid)
@csrf
@endif
@empty
🛵

Aucune livraison en cours

Les livraisons actives apparaîtront ici

@endforelse
{{-- ═══════════════════════════════════════════ TAB: AGENDA (commandes planifiées) ═══════════════════════════════════════════ --}}
@if($scheduledOrders->isEmpty())
📅

Aucune commande planifiée

Les commandes avec une date future apparaîtront dans l'agenda après acceptation

@else
@php $lastDay = ''; @endphp @foreach($scheduledOrders as $order) @php $day = $order->requested_at->translatedFormat('l d F Y'); @endphp @if($day !== $lastDay)
📅 {{ $day }}
@php $lastDay = $day; @endphp @endif
{{ $order->requested_at->format('H\hi') }}
#{{ $order->order_number }} · {{ $order->client->name ?? 'Client' }}
@foreach($order->items->take(3) as $item) {{ $item->quantity }}x {{ $item->product_name }}@if(!$loop->last), @endif @endforeach @if($order->items->count() > 3) +{{ $order->items->count() - 3 }} @endif
{{ number_format($order->total, 2) }}€
{{ $order->delivery_type === 'delivery' ? '🛵 Livr.' : '🏪 Emp.' }}
@endforeach
@endif
{{-- ═══════════════════════════════════════════ TAB: HISTORIQUE ═══════════════════════════════════════════ --}}
@forelse($historyOrders ?? [] as $order)
#{{ $order->order_number }} {{ $order->created_at->format('d/m/Y H:i') }} · {{ $order->client->name ?? 'Client' }} @if($order->delivery_type === 'delivery') · 🛵 @else · 🏪 @endif {{ number_format($order->total, 2) }}€ @switch($order->status) @case('delivered') ✅ Livrée @break @case('completed') ✓ Terminée @break @case('cancelled') ✕ Annulée @break @default {{ ucfirst($order->status) }} @endswitch
@empty
📜

Aucun historique trouvé

@endforelse
{{-- ═══════ CODE MODAL ═══════ --}}

🔐 Code de vérification

Demandez le code à 4 chiffres au client pour valider la remise

Code incorrect, réessayez

Detail

0 commande 0.00€
@endsection @push('scripts') @endpush