@extends('layouts.app') @section('titulo', 'Detalle de Entrega ' . $delivery->codigo) @section('subtitulo', 'Información completa del pedido, ruta y estado de entrega') @section('content')
{{-- Barra superior de acciones --}}
← Volver
{{ $delivery->codigo }} {!! $delivery->badge_estado !!}
{{-- Hoja de Despacho A5 --}} Hoja de Despacho (A5) {{-- WhatsApp al Cliente --}} @if($delivery->url_whatsapp_cliente) Notificar por WhatsApp @endif {{-- Editar --}} @if(!auth()->user()->esRepartidor()) Editar @endif
{{-- Panel de Control de Estados --}}
Estado actual de la entrega

Cambia el estado conforme avance el proceso de despacho:

@if($delivery->estado != 'pendiente')
@csrf
@endif @if($delivery->estado != 'en_camino')
@csrf
@endif @if($delivery->estado != 'entregado')
@csrf
@endif @if($delivery->estado != 'fallido' && $delivery->estado != 'cancelado')
@csrf
@endif
{{-- Grid Principal --}}
{{-- Columna Izquierda (2 cols) --}}
{{-- Datos de Entrega y Dirección --}}

Destinatario y Lugar de Entrega

Destinatario

{{ $delivery->destinatario_nombre }}

Teléfono / WhatsApp
{{ $delivery->destinatario_telefono ?? 'No registrado' }} @if($delivery->destinatario_telefono) 📞 @endif
Dirección de Envío

{{ $delivery->direccion_envio }}

@if($delivery->distrito)

Distrito: {{ $delivery->distrito }}

@endif @if($delivery->referencia_ubicacion)

Referencia: {{ $delivery->referencia_ubicacion }}

@endif
¿Abrir ubicación en GPS? 📍 Abrir Google Maps
@if($delivery->observaciones)
Indicaciones Especiales: {{ $delivery->observaciones }}
@endif
{{-- Si tiene Venta Asociada: Lista de Productos --}} @if($delivery->venta)

Artículos del Pedido (Comprobante: {{ $delivery->venta->referencia }})

Ver Comprobante (PDF) @if(!auth()->user()->esRepartidor()) Ver Venta @endif
@foreach($delivery->venta->detalles ?? [] as $det) @endforeach @if($delivery->costo_envio > 0) @endif
Producto Cant. P. Unit Subtotal
{{ $det->producto ? $det->producto->nombre : 'Artículo' }} {{ $det->cantidad }} {{ formato_moneda($det->precio_unitario) }} {{ formato_moneda($det->subtotal) }}
Subtotal Productos: @if(($delivery->condicion_cobro ?? 'solo_flete') !== 'contraentrega') (Pagado en Tienda) @else (Por cobrar) @endif {{ formato_moneda($delivery->venta->total) }}
+ Flete Delivery: @if(($delivery->condicion_cobro ?? 'solo_flete') === 'ya_pagado') (Pagado) @endif {{ formato_moneda($delivery->costo_envio) }}
Total a Cobrar por Repartidor: {{ $delivery->label_condicion_cobro }} {{ formato_moneda($delivery->total_a_cobrar) }}
@endif
{{-- Columna Derecha (1 col) --}}
{{-- Programación y Costos --}}

Programación y Cobro

Fecha Programada

{{ $delivery->fecha_entrega_programada ? $delivery->fecha_entrega_programada->format('d/m/Y') : 'Hoy' }}

Horario Preferido

{{ $delivery->horario_preferido ?: 'Cualquier momento' }}

Costo de Envío / Flete

{{ formato_moneda($delivery->costo_envio) }}

Condición de Cobro
{{ $delivery->label_condicion_cobro }}

Monto a cobrar en entrega: {{ formato_moneda($delivery->total_a_cobrar) }}

{{-- Repartidor Asignado --}}

Repartidor Asignado

@if($delivery->repartidor_nombre)

{{ $delivery->repartidor_nombre }}

@if($delivery->repartidor_telefono)

Tel: {{ $delivery->repartidor_telefono }}

@endif
@else

Sin repartidor asignado aún.

+ Asignar Repartidor @endif
{{-- Trazabilidad --}}

Trazabilidad

Registrado: {{ $delivery->created_at->format('d/m/Y H:i') }}
@if($delivery->fecha_salida)
Salida a ruta: {{ $delivery->fecha_salida->format('d/m/Y H:i') }}
@endif @if($delivery->fecha_entrega_real)
Entregado: {{ $delivery->fecha_entrega_real->format('d/m/Y H:i') }}
@endif
@endsection