{{-- New-Unity ERP | sales/orders/show.blade.php | v2.1 | 26/06/2026 --}} {{-- v2.1 — Dirección/contacto editables, botón PDF, textos en inglés. --}} @extends('layouts.vertical') @section('content')
{{-- Header --}}

{{ $order->folDisplay() }}

{{-- PDF Button --}} PDF @if($order->status === 'confirmed' || $order->status === 'in_process')
@csrf
@endif @if(in_array($order->status, ['confirmed', 'in_process'])) @php // Verificar stock disponible para todos los items $hasStock = true; foreach($order->products as $item) { $available = \App\Modules\Warehouse\Models\WarehouseInventory ::where('product_id', $item->product_id) ->sum('quantity_available'); if ($available < $item->quantity) { $hasStock = false; break; } } // Verificar que no exista delivery activa $activeDelivery = \App\Modules\Deliveries\Models\Delivery ::where('sales_order_id', $order->id) ->whereNotIn('status', ['cancelled', 'invoiced']) ->first(); @endphp @if($activeDelivery) {{ __('orders.view_delivery') }} {{ $activeDelivery->delivery_number }} @elseif($hasStock)
@csrf
@else @endif @endif {{ __('orders.back') }}
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Customer Info --}}
{{ __('orders.customer_information') }}
{{ $order->statusLabel() }} @if($order->canEdit()) @endif
{{ __('orders.customer') }} {{ $order->customer_name }}
RFC {{ $order->customer_rfc ?? '—' }}
{{ __('orders.customer_number') }} {{ $order->customer_number ?? '—' }}
{{ __('orders.delivery_address') }} {{ $order->customer_address ?? '—' }}
{{ __('orders.so_number') }} {{ $order->folDisplay() }}
{{ __('orders.quote_ref') }} @if($order->quote_id) COT-{{ str_pad($order->quote?->fol, 4, '0', STR_PAD_LEFT) }} @else @endif
{{ __('orders.date') }} {{ $order->created_at->format('d-m-Y') }}
{{ __('orders.delivery_date') }} {{ $order->delivery_date?->format('d-m-Y') ?? '—' }}
{{ __('orders.contact') }} {{ $order->customer_contact_name ?? '—' }}
{{ __('orders.created_by') }} {{ $order->user?->name ?? '—' }}
{{-- Products --}}
{{ __('orders.products') }}
@forelse($order->products as $i => $product) @empty @endforelse
# {{ __('orders.sku') }} {{ __('orders.description') }} {{ __('orders.unit') }} {{ __('orders.ordered') }} {{ __('orders.delivered') }} {{ __('orders.pending') }} {{ __('orders.unit_price') }} {{ __('orders.amount') }}
{{ $i + 1 }} {{ $product->sku ?? '—' }} {{ $product->product_name }} {{ $product->unity ?? '—' }} {{ $product->quantity }} {{ $product->quantity_delivered }} @php $pending = $product->pendingQty(); @endphp {{ $pending }} ${{ number_format($product->sales_price, 2) }} ${{ number_format($product->amount, 2) }}
{{ __('orders.no_products') }}
@if($order->notes)
{{ __('orders.notes') }}

{{ $order->notes }}

@endif
{{-- Totals --}}
{{ __('orders.currency') }}{{ $order->currency }}
{{ __('orders.subtotal') }}${{ number_format($order->subtotal, 2) }}
{{ __('orders.discount') }} ({{ $order->discount_perc }}%)${{ number_format($order->discount, 2) }}
{{ __('orders.vat') }} ({{ $order->tax_perc }}%)${{ number_format($order->tax, 2) }}
{{ __('orders.total') }}${{ number_format($order->total, 2) }}
{{-- Status Log --}}
{{ __('orders.status_history') }}
@forelse($order->statusLogs as $log)
{{ $log->statusToLabel() }}

{{ $log->comment }}

{{ $log->user?->name ?? __('orders.system') }} — {{ $log->created_at->format('d-m-Y H:i') }} @if($log->status_from) · {{ __('orders.from_status') }} {{ $log->statusFromLabel() }} @endif
@empty

{{ __('orders.no_status_changes') }}

@endforelse
{{-- Actions --}}
@php $transitions = $order->availableTransitions(); @endphp @if(count($transitions) > 0) @foreach($transitions as $key => $label) @endforeach @endif @if($order->canDelete())
@csrf @method('DELETE')
@endif
{{-- Modal Edit Delivery Info --}} @if($order->canEdit()) @endif {{-- Modal Change Status --}} @endsection @section('scripts') @parent @endsection