{{-- New-Unity ERP | Modules/Products/Resources/Views/products/datasheet.blade.php | v1.3 | 26/07/2026 --}} {{-- v1.3 β€” Tabla proveedores: πŸ₯‡ badge en mejor precio activo, ⚠️ en status de expirados. --}} {{-- v1.2 β€” SecciΓ³n Proveedores convertida en tabla completa (moneda, IVA, total, vigencia, editar). --}} {{-- BotΓ³n "+ Agregar Proveedor" en header de la card. --}} {{-- v1.1 β€” part-hash usa product_number en vez de $product->id. --}} {{-- v1.0 β€” Product Datasheet: hub central con 8 dimensiones en grid 3 columnas. --}} @extends('layouts.vertical') @section('content')
{{-- Header --}}
{{ __('products.back') }}
{{-- Product Header Card --}}

{{ $product->product_name }}

{{ __('products.sku') }}: {{ $product->sku }}  Β·  {{ __('products.part-hash') }}: {{ $product->product_number }}  Β·  {{ $product->category?->group?->es_name }} / {{ $product->category?->name }}  Β·  {{ $product->brand?->validbrand_id }}

@php $mtColors = ['TR'=>'info','RM'=>'warning','FG'=>'success','SV'=>'secondary']; $mtColor = $mtColors[$product->material_type] ?? 'secondary'; @endphp {{ $product->material_type }} @if($activeCost) {{ __('products.ds-cost-valid') }} @else {{ __('products.ds-cost-invalid') }} @endif
{{-- Grid 3 columnas --}}
{{-- ══════════════════════════════════════════════════ --}} {{-- FILA 1: Costo actual | Identidad | Alertas --}} {{-- ══════════════════════════════════════════════════ --}} {{-- Costo actual --}}
{{ __('products.ds-current-cost') }} @if($activeCost) {{ __('products.ds-edit') }} @else {{ __('products.ds-add') }} @endif
@if($activeCost)

${{ number_format($activeCost->cost, 2) }} {{ $activeCost->currency }}

{{ __('products.ds-list-cost-valid-until') }} {{ $activeCost->valid_to?->format('d/m/Y') ?? __('products.ds-no-date') }}


IVA ({{ $activeCost->iva_perc }}%) ${{ number_format($activeCost->iva_amount, 2) }}
IEPS ({{ $activeCost->ieps_perc }}%) @if($activeCost->ieps_perc > 0) ${{ number_format($activeCost->ieps_amount, 2) }} @else β€” @endif
{{ __('products.ds-total-cost') }} ${{ number_format($activeCost->total_cost, 2) }}
{{ __('products.ds-avg-cost') }} ${{ number_format($activeCost->avg_cost, 2) }}
{{ __('products.ds-supplier') }} {{ $activeCost->supplier?->commercial_name ?? __('products.ds-generic') }}
@else

{{ __('products.ds-no-cost-registered') }}

{{ __('products.ds-register-cost') }}
@endif
{{-- Identidad --}}
{{ __('products.ds-identity') }} @php $fields = [ __('products.sku') => $product->sku, __('products.part-hash') => $product->product_number, __('products.product-code') => $product->product_code, __('products.barcode-label') => $product->barcode, __('products.ds-material-type') => ($product->material_type ?? 'β€”') . ' β€” ' . match($product->material_type) { 'TR' => __('products.mt-commercial'), 'RM' => __('products.mt-raw-material'), 'FG' => __('products.mt-finished-good'), 'SV' => __('products.mt-service'), default => '' }, __('products.sat-code') => $product->tax_code, __('products.sat-unity') => $product->unity, __('products.brand') => $product->brand?->validbrand_id, __('products.family') => $product->family, __('products.model') => $product->model, ]; @endphp @foreach($fields as $label => $value) @if($value)
{{ $label }} {{ $value }}
@endif @endforeach
{{-- Alertas --}}
{{ __('products.ds-alerts') }} @if($activeCost) @php $daysLeft = $activeCost->daysRemaining(); @endphp @if($daysLeft > 30)
{{ __('products.ds-cost-valid-days', ['days' => $daysLeft]) }}
@elseif($daysLeft > 0)
{{ __('products.ds-cost-expires-days', ['days' => $daysLeft]) }}
@else
{{ __('products.ds-cost-expired') }}
@endif @else
{{ __('products.ds-no-cost-rfq') }}
@endif @if($supplierCount <= 1)
{{ __('products.ds-only-supplier', ['count' => $supplierCount]) }}
@else
{{ __('products.ds-suppliers-registered', ['count' => $supplierCount]) }}
@endif @if($activeRfqCount > 0)
{{ __('products.ds-active-rfqs', ['count' => $activeRfqCount]) }}
@else
{{ __('products.ds-no-active-rfq') }}
@endif @if($historyCount > 0)
{{ __('products.ds-history-records', ['count' => $historyCount]) }}
@endif
{{-- ══════════════════════════════════════════════════ --}} {{-- FILA 2: GrΓ‘fica de precios (span 3) --}} {{-- ══════════════════════════════════════════════════ --}}
{{ __('products.ds-price-trend') }} {{ __('products.ds-view-full-history') }}
@if($priceHistory->count() > 0) @else

{{ __('products.ds-no-price-history') }}

@endif
{{-- ══════════════════════════════════════════════════ --}} {{-- FILA 3: Proveedores (span 2) | EstadΓ­sticas --}} {{-- ══════════════════════════════════════════════════ --}} {{-- Proveedores --}}
{{ __('products.ds-suppliers-quotes') }}
@if($costsBySupplier->isNotEmpty()) @php $bestActiveId = $costsBySupplier->filter(fn($c) => $c->isActive())->sortBy('cost')->first()?->id; @endphp
@foreach($costsBySupplier as $cost) @endforeach
{{ __('products.ds-supplier') }} {{ __('products.ds-list-cost') }} Mon. IVA% {{ __('products.ds-total-cost') }} {{ __('products.ds-col-valid-to') }} Status
{{ $cost->supplier?->commercial_name ?? $cost->supplier?->name ?? __('products.ds-generic') }} @if($bestActiveId && $cost->id === $bestActiveId) πŸ₯‡ {{ __('products.ds-best-price') }} @endif ${{ number_format($cost->cost, 2) }} {{ $cost->currency }} {{ number_format($cost->iva_perc, 0) }}% ${{ number_format($cost->total_cost, 2) }} {{ $cost->valid_to?->format('d/m/Y') ?? 'β€”' }} @if($cost->isActive()) {{ __('products.ds-active') }} @else ⚠️ {{ __('products.ds-expired') }} @endif @can('costs.edit') @endcan
@else

{{ __('products.ds-no-suppliers') }}

{{ __('products.ds-create-rfq') }}
@endif
{{ $activeRfqCount }}
{{ __('products.ds-active-rfqs-label') }}
{{ $supplierCount }}
{{ __('products.ds-suppliers-label') }}
@if($bestCost) ${{ number_format($bestCost->cost, 2) }} @else β€” @endif
{{ __('products.ds-best-price') }}
{{ $historyCount }}
{{ __('products.ds-price-changes') }}
{{-- EstadΓ­sticas de precio --}}
{{ __('products.ds-price-stats') }}
@if($priceStats['current']) ${{ number_format($priceStats['current'], 2) }} @else β€” @endif
{{ __('products.ds-current-price') }}
@if($priceStats['avg']) ${{ number_format($priceStats['avg'], 2) }} @else β€” @endif
{{ __('products.ds-avg-12m') }}
@if($priceStats['min']) ${{ number_format($priceStats['min'], 2) }} @else β€” @endif
{{ __('products.ds-min-hist') }}
@if($priceStats['max']) ${{ number_format($priceStats['max'], 2) }} @else β€” @endif
{{ __('products.ds-max-hist') }}
{{ $priceStats['variation'] !== null ? number_format($priceStats['variation'], 2).'%' : 'β€”' }}
{{ __('products.ds-variation') }}
{{ $historyCount }}
{{ __('products.ds-total-changes') }}
{{-- ══════════════════════════════════════════════════ --}} {{-- FILA 4: Inventario | POs | Ventas (pendientes) --}} {{-- ══════════════════════════════════════════════════ --}}
{{ __('products.ds-inventory') }}

{{ __('products.ds-warehouse-pending') }}

{{ __('products.ds-purchase-orders') }}

{{ __('products.ds-po-pending') }}

{{ __('products.ds-sales-consumption') }}

{{ __('products.ds-sales-pending') }}

@endsection @section('scripts') @parent @endsection