@php $pageConfigs = ['navbarType' => 'static', 'contentLayout' => 'wide']; $configData = Helper::appClasses(); $statusMap = [ 'pending' => ['Pendiente', 'warning', 10], 'confirmed' => ['Confirmado', 'info', 30], 'at_restaurant' => ['Confirmado', 'info', 45], 'en_route' => ['En camino', 'primary', 80], 'delivered' => ['Entregado', 'success', 100], 'cancelled' => ['Cancelado', 'danger', 0], ]; $confirmedTotal = ($statusCounts['confirmed'] ?? 0) + ($statusCounts['at_restaurant'] ?? 0); $todayOrders = collect($allDeliveries ?? $deliveries ?? [])->count(); $activeOrders = ($statusCounts['pending'] ?? 0) + $confirmedTotal + ($statusCounts['en_route'] ?? 0); $completionRate = $todayOrders > 0 ? (int) round((($statusCounts['delivered'] ?? 0) / $todayOrders) * 100) : 0; @endphp @extends('layouts/layoutMaster') @section('title', 'Operativa') @section('bodyClass', 'restaurant-fleet-page') @section('page-style') @vite('resources/assets/vendor/scss/pages/app-logistics-fleet.scss') @endsection @section('content') @if (session('duplicate_delivery_warning')) @php $duplicateWarning = session('duplicate_delivery_warning'); @endphp
Ya solicitaste un repartidor {{ $duplicateWarning['created_ago'] ?? 'hace menos de 2 minutos' }} @if (!empty($duplicateWarning['delivery_id'])) (orden #{{ $duplicateWarning['delivery_id'] }}) @endif . Ver la última orden o vuelve a enviar para confirmar.
@endif
@csrf
Operativa de hoy
{{ now()->format('d/m/Y') }}
{{ $completionRate }}% completado
Total
{{ $todayOrders }}
Activas
{{ $activeOrders }}
Entregadas
{{ $statusCounts['delivered'] ?? 0 }}
@forelse ($deliveries as $delivery) @php [$statusLabel, $statusColor, $progress] = $statusMap[$delivery->status] ?? ['Pendiente', 'warning', 20]; $courierName = $delivery->courier?->name ?? 'Sin asignar'; $courierStatusLabel = match ($delivery->status) { 'pending' => 'Buscando repartidor', 'confirmed' => 'Repartidor confirmado', 'at_restaurant' => 'Repartidor confirmado', 'en_route' => 'En camino', 'delivered' => 'Entregado', 'cancelled' => 'Cancelado', default => 'En espera', }; $courierStatusColor = match ($delivery->status) { 'pending' => 'warning', 'confirmed' => 'info', 'at_restaurant' => 'info', 'en_route' => 'primary', 'delivered' => 'success', 'cancelled' => 'danger', default => 'secondary', }; $courierStatusNote = match (true) { $delivery->courier_id && $delivery->status === 'at_restaurant' => 'Rider en el restaurante', $delivery->courier_id && $delivery->status === 'confirmed' => 'Rider en camino al restaurante', default => null, }; $desktopCustomer = $delivery->customer_name ?: 'Cliente sin nombre'; $desktopAddress = $delivery->delivery_address ?: 'Dirección sin definir'; @endphp
@empty
No hay entregas todavía.
Crea una orden para verla aquí.
@endforelse
@foreach ($deliveries as $delivery) @php [$statusLabel, $statusColor, $progress] = $statusMap[$delivery->status] ?? ['Pendiente', 'warning', 20]; $courierName = $delivery->courier?->name ?? 'Sin asignar'; @endphp
Entrega #{{ $delivery->id }}
{{ $statusLabel }}
Cliente {{ $delivery->customer_name }}
Teléfono {{ $delivery->customer_phone ?? '-' }}
Dirección {{ $delivery->delivery_address }}
@if ($delivery->delivery_address_extra)
Adicional {{ $delivery->delivery_address_extra }}
@endif
Repartidor {{ $courierName }}
Estado

{{ $statusLabel }}

@if ($delivery->status === 'at_restaurant')
Rider en el restaurante
@endif
  • pedido creado
    {{ $delivery->restaurant?->name ?? 'Restaurante' }}
    {{ $delivery->created_at->format('d/m/Y H:i') }}
  • repartidor
    {{ $courierName }}
    {{ $delivery->status === 'pending' ? 'En espera' : 'Asignado' }}
  • entrega
    {{ $delivery->delivery_address }}
    {{ $delivery->status === 'delivered' ? 'Entregado' : 'En curso' }}
@if ($delivery->status === 'pending')
@csrf
@endif
@endforeach
@php $homePending = $statusCounts['pending'] ?? 0; $homeConfirmed = $confirmedTotal ?? 0; $homeEnRoute = $statusCounts['en_route'] ?? 0; $homeDelivered = $statusCounts['delivered'] ?? 0; @endphp
Solicitar repartidor
Rider urgente

Solicitar rider

{{ $restaurant?->zone?->name ?? 'Zona activa' }}
@php $last = $latestDelivery ?? (($allDeliveries ?? collect())->first()); $lastLabel = $last ? ($statusMap[$last->status][0] ?? 'Pendiente') : 'Sin estado'; $lastBadge = $last ? ($statusMap[$last->status][1] ?? 'secondary') : 'secondary'; $hasCourier = $last && $last->courier; $courierLine = $hasCourier ? ($last->courier->name ?? 'Repartidor asignado') : 'Sin repartidor'; $courierStatus = match ($last?->status) { 'pending' => 'Aún no viene en camino (buscando rider)', 'confirmed' => 'Rider asignado, pendiente de recogida', 'at_restaurant' => 'Rider en restaurante (recogiendo pedido)', 'en_route' => 'Rider en camino al cliente', 'delivered' => 'Pedido entregado', 'cancelled' => 'Pedido cancelado', default => $hasCourier ? 'Rider asignado' : 'Sin asignar', }; $lastProgress = match ($last?->status) { 'pending' => 18, 'confirmed' => 46, 'at_restaurant' => 62, 'en_route' => 84, 'delivered' => 100, 'cancelled' => 100, default => 12, }; $lastProgressText = match ($last?->status) { 'pending' => 'Buscando rider disponible', 'confirmed' => 'Rider asignado', 'at_restaurant' => 'Rider en restaurante', 'en_route' => 'Rider en camino al cliente', 'delivered' => 'Entrega completada', 'cancelled' => 'Pedido cancelado', default => 'Sin estado', }; @endphp
Último pedido
Seguimiento rápido y acceso en un toque.
{{ $lastLabel }} {{ $last ? "#{$last->id}" : '--' }} {{ $last ? optional($last->created_at)->format('H:i') : '--:--' }} Urgente
{{ $lastProgressText }}
Cliente
{{ $last?->customer_name ?? 'Por definir' }}
{{ $last?->customer_phone ?: 'Sin teléfono' }}
{{ $last?->delivery_address ?? 'Por definir' }}
Rider
{{ $courierLine }}
{{ $courierStatus }}
Toca para centrar esta orden
Aún no has solicitado ningún servicio hoy.
Órdenes
@forelse ($allDeliveries ?? collect() as $delivery) @php $mobileStatus = $statusMap[$delivery->status] ?? ['Pendiente', 'secondary', 20]; $mobileStatusLabel = $mobileStatus[0]; $mobileStatusColor = $mobileStatus[1]; $mobileCustomer = $delivery->customer_name ?: 'Cliente sin nombre'; $mobileAddress = $delivery->delivery_address ?: 'Dirección sin definir'; @endphp
#{{ $delivery->id }}
{{ $mobileCustomer }}
{{ $mobileStatusLabel }}
{{ $mobileAddress }}
{{ optional($delivery->created_at)->format('d/m/Y H:i') }} {{ $delivery->is_urgent ? 'Urgente' : 'Normal' }}
@empty
No hay pedidos hoy.
@endforelse
{{ strtoupper(substr($restaurant?->name ?? 'R', 0, 1)) }}
{{ $restaurant?->name ?? 'Restaurante' }}
{{ $restaurant?->address ?? 'Sin dirección' }}
{{ $restaurant?->zone?->name ?? 'Zona no asignada' }}
Pendientes
{{ $statusCounts['pending'] ?? 0 }}
Confirmados
{{ $confirmedTotal }}
En camino
{{ $statusCounts['en_route'] ?? 0 }}
Entregados
{{ $statusCounts['delivered'] ?? 0 }}
Contacto
{{ $restaurant?->contact_name ?? 'Sin contacto' }}
Teléfono
{{ $restaurant?->phone ?? 'Sin teléfono' }}
Email
{{ $restaurant?->email ?? 'Sin email' }}
@csrf
Nueva entrega
Completa los datos para enviar un rider.
@csrf
Se cobrará €{{ number_format($restaurant?->delivery_fee ?? 0, 2) }} por entrega.
Pedir repartidor urgente
Solicitud rápida para recoger en restaurante.
Un repartidor llegará al restaurante con urgencia. El repartidor completará los datos del cliente al llegar.
@csrf
Se cobrará €{{ number_format($restaurant?->delivery_fee ?? 0, 2) }} por entrega.
@endsection @section('page-script') @endsection