Panel

Resumen general

{{-- Aviso de periodo contable activo --}} @php // Soporte a nombres de columnas: fecha_inicio/fin o fecha_inicial/final $fi = $activePeriod->fecha_inicio ?? $activePeriod->fecha_inicial ?? null; $ff = $activePeriod->fecha_fin ?? $activePeriod->fecha_final ?? null; $fmt = function($d) { try { return \Carbon\Carbon::parse($d)->isoFormat('DD/MM/YYYY'); } catch(\Throwable $e) { return $d; } }; @endphp @if($activePeriod)
Periodo activo @if($fi || $ff) Rango: {{ $fi ? $fmt($fi) : '—' }}{{ $ff ? $fmt($ff) : '—' }} @endif @if(optional($activePeriod->local)->alias) · Local: {{ $activePeriod->local->alias }} @endif @if($activePeriod->descripcion) · {{ $activePeriod->descripcion }} @endif Gestionar periodos
@else
No hay periodo contable activo. Crear periodo
@endif {{-- Tarjetas de métricas --}}
Productos
{{ $stats['products'] ?? 0 }}
Total en catálogo
Categorías
{{ $stats['categories'] ?? 0 }}
Registradas
Gestores
{{ $stats['gestors'] ?? 0 }}
Con acceso
Inventario
{{ number_format($stats['stock'] ?? 0) }}
Unidades
{{-- (Opcional) tarjeta de ventas si existe orders --}} @if(($ventasTotales ?? 0) > 0)
Ventas acumuladas
${{ number_format($ventasTotales, 2) }}
@endif {{-- Últimos productos --}}
Últimos productos
Ver todos
@forelse(($latestProducts ?? []) as $p) @php // === mismo bloque de media que en el index === $toUrl = function($path) { $raw = trim($path ?? ''); if ($raw === '') return null; if (preg_match('~^https?://~i',$raw)) return $raw; if (str_starts_with($raw,'public/storage/')) return asset(substr($raw,7)); if (str_starts_with($raw,'storage/')) return asset($raw); if (\Storage::disk('public')->exists($raw)) return \Storage::url($raw); if (file_exists(public_path($raw))) return asset($raw); return null; }; $media = collect($p->media ?? []); $primary = $media->firstWhere('is_primary', true) ?? $media->first(); $others = $media->filter(fn($m)=> $primary ? $m->id !== $primary->id : true); $ordered = collect($primary ? [$primary] : [])->merge($others); $imgUrls = $ordered->map(fn($m)=> $toUrl($m->path))->filter()->values(); $placeholder = asset('img/placeholder_zapato_detalle.svg'); $mainUrl = $imgUrls->first() ?: $placeholder; $hasRealGallery = $imgUrls->count() > 1 || ($imgUrls->count() === 1 && !\Illuminate\Support\Str::contains($imgUrls->first(), 'placeholder_zapato_detalle.svg')); @endphp {{-- Nombre + SKU (badge debajo, oculto en sm-) --}} {{-- Costo --}} {{-- Precio base --}} @empty @endforelse
Imagen Nombre Costo Precio Base
@if($hasRealGallery) {{ $p->name }} @else {{ $p->name }} @endif
{{ $p->name }}
@if($p->sku) @endif
${{ (int) ($p->cost ?? 0) }} ${{ (int) ($p->base_price ?? 0) }} Editar
No hay productos recientes.
{{-- (Opcional) puedes luego renderizar $bajoStock, $topStock o $stockPorCategoria en tarjetas o gráficos --}}