@extends('layouts.users.main') @section('content')
{{-- Breadcrumb Component --}}

{{ __('Used machine details') }}

{{-- Staff ve el Ticket Status (+ Stage / Approved At) en el bloque de abajo. Aquí solo mostramos el indicador de 4 estados para el cliente. --}} @if ($ticket && ! $isStaff) @php $customerStatus = \App\Enums\CustomerSaleStatusEnum::fromTicket($ticket); @endphp @endif @if ($isStaff) @endif
{{ __('ID') }} {{ $machine->sale_ticket_id ?? 'N/A' }}
{{ __('Name') }} {{ $machine->brand . $machine->model }}
{{ __('Brand') }} {{ $machine->brand }}
{{ __('Model') }} {{ $machine->model }}
{{ __('Year') }} {{ $machine->year }}
{{ __('Type of machine') }} {{ machine_enum_label($machine->type_of_machine) }}
{{ __('Status') }} {{ $customerStatus->label() }}
{{ __('Sales user') }} @if ($machine->saleTicket?->user) @can('view_user_info') {{ $machine->saleTicket->user->name }} ({{ $machine->saleTicket->user->email }}) @else {{ $machine->saleTicket->user->name }} ({{ $machine->saleTicket->user->email }}) @endcan @else {{ __('No user assigned') }} @endif
{{ __('Stage') }} {{ $ticket->stage->label() }}
{{ __('Ticket status') }} {{ $ticket->status->label() }}
{{ __('Approved at') }} @if ($ticket->isApproved()) {{ \Carbon\Carbon::parse($ticket->approved_at)->format('d/m/Y H:i') }} @else {{ __('Not approved') }} @endif
{{-- Machine Details Table Dinámica --}}
@php $ordered = collect($sectionOrder) ->filter(fn($key) => isset($machineData[$key])) ->mapWithKeys(fn($key) => [$key => $machineData[$key]]); $remaining = collect($machineData)->except($sectionOrder); $sections = $ordered->merge($remaining); @endphp @foreach ($sections as $sectionKey => $sectionData) @if (is_array($sectionData) && !empty($sectionData)) @if ($sectionKey === 'generalInfo') @foreach ($extraGeneralFields as $extraKey => $extraValue) @endforeach @endif @foreach ($sectionData as $key => $value) @if ($isStaff || is_bool($value) || is_array($value) || !is_placeholder_value($value)) @endif @endforeach @endif @endforeach @if (!empty($machine->additional_information)) @endif
{{-- Str::headline() da Title Case ("General Info") y esas keys no existen: las cabeceras viven en lang/*/used_machine.php. El fallback cubre las secciones que no están mapeadas ahí (techDetail, priceInfo...). --}} @php $sectionLabelKey = 'used_machine.sections.' . $sectionKey; @endphp {{ \Illuminate\Support\Facades\Lang::has($sectionLabelKey) ? __($sectionLabelKey) : __(Str::headline($sectionKey)) }}
{{-- Sentence case, no headline(): la key es "Type of machine", no "Type Of Machine". --}} {{ __(Str::ucfirst(str_replace('_', ' ', $extraKey))) }} {{-- type_of_machine guarda el enum en minúscula ("weaving"); marca, modelo y año son texto libre y el helper los deja intactos. --}} {{ machine_enum_label($extraValue ?? '-') }}
{{ __(str_replace('_', ' ', $key)) }} @if ($key === 'currency_id') {{ \App\Models\Currency::getLabelById($value) ?? $value }} @elseif(is_bool($value)) {{ $value ? __('Yes') : __('No') }} @elseif(is_array($value)) {{ implode(', ', array_map(fn($item) => __($item), $value)) }} @else {{ __($value) }} @endif
{{ __('Additional information') }}
{!! nl2br(e($machine->additional_information)) !!}
{{-- Owner: mismo diseño de tabla que el resto del detalle y DENTRO de #printable-content para que salga en la impresión. --}} @can('view_machine_owner') @if ($machine->owners->isNotEmpty())
@foreach ($machine->owners as $owner) @if ($owner->additional_information) @endif @endforeach
{{ __('Owner') }}
{{ __('Name') }} {{ $owner->name }}
{{ __('Country') }} {{ $owner->country ?? '-' }}
{{ __('Phone') }} {{ $owner->phone ?? '-' }}
{{ __('Email') }} {{ $owner->mail ?? '-' }}
{{ __('Additional information') }} {!! nl2br(e($owner->additional_information)) !!}
@endif @endcan
@if ($machine->media && $machine->media->isNotEmpty())
@if ($images->isNotEmpty())

{{ __('Images') }}

@foreach ($images as $media)
@endforeach
@endif @if ($video)

{{ __('Video') }}

@endif
@endif @if ($machine->promo_flyer_path)

{{ __('Promotional flyer') }}

@endif
@endsection @push('styles') @endpush @push('scripts') @endpush