@extends('layouts.admin')
@section('title', 'Dashboard | Vase')
@section('page_title', 'Dashboard Vase')
@section('page_actions')
@can('admin.dashboard.configurar')
Configurar tarjetas
@endcan
@endsection
@section('css')
@endsection
@section('content')
@php
$moneyMetrics = ['ventas_hoy_total', 'ticket_promedio_hoy'];
$metricLabel = function ($metric, $value) use ($moneyMetrics) {
if (in_array($metric, $moneyMetrics, true)) {
return '$' . number_format((float) $value, 0, ',', '.');
}
if (is_numeric($value)) {
return number_format((float) $value, 0, ',', '.');
}
return $value;
};
$estadoPedidoBadge = function ($estado) {
return match ($estado) {
'PENDIENTE_POS' => 'warning',
'ACEPTADO_POS' => 'primary',
'EN_PREPARACION' => 'info',
'LISTO' => 'success',
'ENTREGADO' => 'success',
'RECHAZADO_FALTA_INGREDIENTES' => 'danger',
'CANCELADO' => 'secondary',
default => 'light',
};
};
@endphp
@php
$pulse = $businessPulse ?? [];
$pulseScore = (int) ($pulse['score'] ?? 100);
$pulseComparison = $pulse['comparison'] ?? [];
$pulseTopProduct = $pulse['top_product'] ?? null;
$pulseCashScope = $pulseComparison['cash_scope'] ?? [];
$pulsePeakHour = $pulse['peak_hour'] ?? null;
$pulseWeek = $pulse['sales_week'] ?? ['days' => [], 'max' => 0, 'total' => 0];
$pulsePriorities = collect($pulse['priorities'] ?? []);
$pulsePercent = $pulseComparison['percent'] ?? null;
$pulseTrendClass = is_numeric($pulsePercent) ? ($pulsePercent >= 0 ? 'positive' : 'negative') : 'neutral';
$pulseTrendIcon = is_numeric($pulsePercent) ? ($pulsePercent >= 0 ? 'bi-arrow-up-right' : 'bi-arrow-down-right') : 'bi-dash';
$pulseScoreTone = $pulseScore >= 90 ? 'excellent' : ($pulseScore >= 75 ? 'healthy' : ($pulseScore >= 55 ? 'attention' : 'critical'));
@endphp
@foreach($widgets as $widget)
@php
$canSee = !$widget->permission_name || auth()->user()->hasRole('Super Admin') || auth()->user()->can($widget->permission_name);
$value = $metrics[$widget->metric_type] ?? 0;
$url = '#';
if (($widget->metric_type ?? null) === 'productos_bajo_stock') { $url = url('/inventario/actual?estado=stock_bajo'); }
elseif (!empty($widget->route_name) && \Illuminate\Support\Facades\Route::has($widget->route_name)) { $url = route($widget->route_name); }
elseif (!empty($widget->url)) { $url = $widget->url; }
@endphp
@if($canSee)
@endif
@endforeach
VASE PULSO
Copiloto operativo del negocio
VASE analiza ventas, stock, pedidos, cajas y DTE para mostrarte qué mirar primero.
Actualizado {{ optional($pulse['generated_at'] ?? null)->format('H:i') ?? now()->format('H:i') }}
Salud operativa
{{ $pulse['score_label'] ?? 'Saludable' }}
Índice calculado con incidencias reales de stock, pedidos pendientes, documentos SII y cajas abiertas por demasiado tiempo.
Ventas hoy vs. ayer a esta hora
@if(($pulseComparison['available'] ?? false) === true)
${{ number_format((float) ($pulseComparison['today_total'] ?? 0), 0, ',', '.') }}
@if(is_numeric($pulsePercent))
{{ $pulsePercent >= 0 ? '+' : '' }}{{ number_format((float) $pulsePercent, 0, ',', '.') }}%
Ayer a esta hora: ${{ number_format((float) ($pulseComparison['yesterday_total'] ?? 0), 0, ',', '.') }} · Todas las cajas, solo cobros de ventas pagadas.
@else
Sin base comparable
{{ (int) ($pulseComparison['today_count'] ?? 0) }} ventas pagadas hoy, de todas las cajas.
@endif
@if(($pulseCashScope['available'] ?? false) && ($pulseCashScope['open_count'] ?? 0) > 0)
{{ $pulseCashScope['open_count'] === 1 ? 'Caja abierta' : 'Cajas abiertas' }} · desde apertura
${{ number_format((float) ($pulseCashScope['open_total'] ?? 0), 0, ',', '.') }}
En esas cajas, cobrado hoy ${{ number_format((float) ($pulseCashScope['open_today'] ?? 0), 0, ',', '.') }}
Hoy, fuera de las cajas abiertas ${{ number_format((float) ($pulseCashScope['other_today'] ?? 0), 0, ',', '.') }}
@if(abs((float) ($pulseCashScope['previous_days_open'] ?? 0)) >= 0.01)
De días anteriores en cajas abiertas ${{ number_format((float) $pulseCashScope['previous_days_open'], 0, ',', '.') }}
@endif
El total diario cubre todas las cajas desde las 00:00. Caja acumula desde su apertura; por eso pueden diferir.
Ver detalle en Caja
@elseif(($pulseCashScope['available'] ?? false))
No hay caja abierta. El importe corresponde a cobros registrados hoy.
@endif
@else
Sin datos verificables
No se pudo consultar el origen de pagos. Revisa las tablas de ventas y cobros antes de comparar.
@endif
Producto estrella de hoy
@if($pulseTopProduct)
{{ $pulseTopProduct['name'] }}
{{ number_format((float) $pulseTopProduct['quantity'], 0, ',', '.') }} unidades
${{ number_format((float) $pulseTopProduct['total'], 0, ',', '.') }} vendidos en este producto.
@else
Esperando ventas
Aún sin producto líder
Aparecerá automáticamente con las ventas del día.
@endif
Hora más fuerte de hoy
@if($pulsePeakHour)
{{ $pulsePeakHour['label'] }}
{{ $pulsePeakHour['sales'] }} {{ $pulsePeakHour['sales'] === 1 ? 'venta' : 'ventas' }}
${{ number_format((float) $pulsePeakHour['total'], 0, ',', '.') }} generados en ese bloque.
@else
Aún sin hora punta
Se calcula solo
Usará las ventas de hoy para detectar el bloque más fuerte.
@endif
Prioridades detectadas
Lo que merece tu atención ahora
{{ $pulsePriorities->count() }}
@foreach($pulsePriorities as $priority)
@endforeach
Últimos 7 días
Ritmo de ventas
${{ number_format((float) ($pulseWeek['total'] ?? 0), 0, ',', '.') }}
@foreach(($pulseWeek['days'] ?? []) as $day)
@php
$maxWeek = max(1, (float) ($pulseWeek['max'] ?? 0));
$barHeight = (float) ($day['total'] ?? 0) > 0 ? max(9, round(((float) $day['total'] / $maxWeek) * 100)) : 4;
@endphp
@endforeach
@php
$opportunities = $businessOpportunities ?? [];
$opportunitySignals = collect($opportunities['signals'] ?? []);
$recommendedOpportunity = $opportunities['recommended'] ?? null;
$secondaryOpportunitySignals = $recommendedOpportunity ? $opportunitySignals->skip(1)->values() : $opportunitySignals;
$opportunitySignalCount = (int) ($opportunities['signal_count'] ?? 0);
$opportunityRiskCount = (int) ($opportunities['risk_count'] ?? 0);
$opportunityGoodCount = (int) ($opportunities['opportunity_count'] ?? 0);
$dormantValue = (float) ($opportunities['dormant_value'] ?? 0);
@endphp
VASE OPORTUNIDADES
Dónde actuar para proteger margen y vender mejor
Compara ventas, costos e inventario para convertir los datos del sistema en decisiones concretas.
Análisis automático
Radar del negocio
{{ $opportunitySignalCount }}
{{ $opportunitySignalCount === 1 ? 'señal detectada' : 'señales detectadas' }}
{{ $opportunities['headline'] ?? 'VASE seguirá analizando el comportamiento del negocio.' }}
Riesgos
{{ $opportunityRiskCount }}
Oportunidades
{{ $opportunityGoodCount }}
@if($dormantValue > 0)
Capital a revisar
${{ number_format($dormantValue, 0, ',', '.') }}
@endif
@if($recommendedOpportunity)
Acción sugerida ahora
{{ $recommendedOpportunity['title'] ?? 'Revisar operación' }}
{{ $recommendedOpportunity['detail'] ?? '' }}
@endif
@if($secondaryOpportunitySignals->isNotEmpty())
Más señales encontradas
Lo que VASE está viendo detrás de los números
Últimos datos disponibles
@foreach($secondaryOpportunitySignals as $signal)
{{ $signal['metric'] ?? '' }}
{{ $signal['eyebrow'] ?? 'Señal detectada' }}
{{ $signal['title'] ?? 'Revisar operación' }}
{{ $signal['detail'] ?? '' }}
@if(!empty($signal['url']))
{{ $signal['action'] ?? 'Revisar' }}
@endif
@endforeach
@endif
@php
$projection = $businessProjection ?? [];
$projectionForecast = (float) ($projection['forecast_total'] ?? 0);
$projectionCurrent = (float) ($projection['current_month_total'] ?? 0);
$projectionPrevious = (float) ($projection['previous_month_total'] ?? 0);
$projectionTodayForecast = (float) ($projection['today_forecast'] ?? 0);
$projectionComparable = (float) ($projection['previous_comparable_total'] ?? 0);
$projectionComparisonPercent = $projection['comparison_percent'] ?? null;
$projectionGoal = (float) ($projection['goal'] ?? 0);
$projectionGoalProgress = $projection['goal_progress'] ?? null;
$projectionGoalProgressBar = is_numeric($projectionGoalProgress) ? max(0, min(100, (float) $projectionGoalProgress)) : 0;
$projectionForecastGoal = $projection['forecast_goal_percent'] ?? null;
$projectionRequiredDaily = (float) ($projection['required_daily_pace'] ?? 0);
$projectionDaily = (float) ($projection['forecast_daily_pace'] ?? 0);
$projectionStockRisks = collect($projection['stock_risks'] ?? []);
$projectionStatus = $projection['status'] ?? 'neutral';
@endphp
VASE PROYECCIÓN
Hacia dónde va el negocio
Proyecta el cierre del mes, compara el ritmo actual con tu meta y anticipa insumos que pueden agotarse.
Proyección {{ optional($projection['generated_at'] ?? null)->format('H:i') ?? now()->format('H:i') }}
@if(session('dashboard_projection_message'))
{{ session('dashboard_projection_message') }}
@endif
@if(session('dashboard_projection_error'))
{{ session('dashboard_projection_error') }}
@endif
Cierre mensual estimado
${{ number_format($projectionForecast, 0, ',', '.') }}
{{ $projection['status_title'] ?? 'Calculando proyección' }}
{{ $projection['status_detail'] ?? 'VASE irá afinando esta estimación con cada venta registrada.' }}
Ritmo proyectado
${{ number_format($projectionDaily, 0, ',', '.') }}
promedio diario utilizado para estimar el cierre
Vendido este mes
${{ number_format($projectionCurrent, 0, ',', '.') }}
{{ number_format((int) ($projection['current_month_count'] ?? 0), 0, ',', '.') }} ventas registradas
Hoy podría cerrar en
${{ number_format($projectionTodayForecast, 0, ',', '.') }}
Estimación de cierre para el día actual
Ritmo vs. mes anterior
@if(is_numeric($projectionComparisonPercent))
{{ (float) $projectionComparisonPercent >= 0 ? '+' : '' }}{{ number_format((float) $projectionComparisonPercent, 0, ',', '.') }}%
Comparando el mismo tramo del mes
@else
—
Sin base comparable suficiente
@endif
Tiempo restante
{{ number_format((float) ($projection['remaining_days'] ?? 0), 0, ',', '.') }} días
Hasta el cierre del mes actual
Meta mensual
¿Vamos encaminados al objetivo?
{{ ($projection['goal_source'] ?? 'automatic') === 'manual' ? 'Meta definida' : 'Referencia automática' }}
@if($projectionGoal > 0)
Meta
${{ number_format($projectionGoal, 0, ',', '.') }}
Avance real
{{ is_numeric($projectionGoalProgress) ? number_format((float) $projectionGoalProgress, 0, ',', '.') . '%' : '—' }}
Cierre vs. meta
{{ is_numeric($projectionForecastGoal) ? number_format((float) $projectionForecastGoal, 0, ',', '.') . '%' : '—' }}
@if($projectionRequiredDaily > 0)
Para alcanzar la meta, desde ahora se necesitan aproximadamente ${{ number_format($projectionRequiredDaily, 0, ',', '.') }} diarios .
@elseif($projectionCurrent >= $projectionGoal)
La meta mensual ya fue alcanzada con las ventas registradas.
@else
La meta se irá comparando automáticamente con el avance del mes.
@endif
@else
Define una meta para activar el seguimiento VASE comparará el avance real y la proyección de cierre contra ese objetivo.
@endif
@can('admin.dashboard.configurar')
@endcan
Inventario futuro
Insumos que podrían agotarse
{{ $projectionStockRisks->count() }}
@if($projectionStockRisks->isNotEmpty())
@foreach($projectionStockRisks as $risk)
{{ $risk['name'] ?? 'Insumo' }}
Stock {{ number_format((float) ($risk['stock'] ?? 0), 0, ',', '.') }} {{ $risk['unit'] ?? '' }} · consumo aprox. {{ number_format((float) ($risk['daily_use'] ?? 0), 0, ',', '.') }}/día
{{ number_format((float) ($risk['days_left'] ?? 0), 0, ',', '.') }} días
@if((float) ($risk['replenish'] ?? 0) > 0)
Reponer ~{{ number_format((float) $risk['replenish'], 0, ',', '.') }} {{ $risk['unit'] ?? '' }}
@endif
@endforeach
Revisar inventario
@else
Sin agotamientos proyectados en los próximos 14 días
Se analizan productos con enlace directo al inventario y consumo reciente suficiente.
@endif
Productos / insumos bajo stock
Lo más urgente para reponer o revisar receta.
{{ $metrics['productos_bajo_stock'] ?? $lowStockRows->count() }}
Inventario
Producto/Insumo Bodega Stock
@forelse($lowStockRows as $row)
{{ $row->item_nombre ?? 'Sin nombre' }}
{{ $row->item_codigo ?? 'Sin código' }}
{{ $row->bodega_nombre ?? 'General' }}
{{ number_format((float) $row->stock_actual, 0, ',', '.') }} / {{ number_format((float) $row->stock_minimo, 0, ',', '.') }} {{ $row->unidad_medida ?? '' }}
@empty
Sin productos bajo stock por ahora. Lindísimo ✨
@endforelse
Pedidos externos recientes
Ecommerce web, PedidosYa, Uber Eats, Rappi y otros canales.
Pedido Cliente Canal Estado Total
@forelse($pedidosRecientes as $pedido)
{{ $pedido->codigo ?? ('#'.$pedido->id) }}
{{ optional(\Illuminate\Support\Carbon::parse($pedido->created_at))->format('d/m H:i') }}
{{ $pedido->cliente_nombre ?? 'Cliente web' }}
{{ $pedido->cliente_telefono ?? '' }}
{{ $pedido->origen ?? 'ECOMMERCE' }}
{{ str_replace('_', ' ', $pedido->estado ?? 'SIN ESTADO') }}
${{ number_format((float) ($pedido->total ?? 0), 0, ',', '.') }}
@empty
Todavía no hay pedidos externos.
@endforelse
Últimas ventas POS
Movimiento reciente del punto de venta.
Venta Fecha Estado Total
@forelse($ventasRecientes as $venta)
{{ $venta->folio ?? ('Venta #'.$venta->id) }}
{{ isset($venta->created_at) ? \Illuminate\Support\Carbon::parse($venta->created_at)->format('d/m/Y H:i') : '-' }}
{{ $venta->estado ?? 'SIN ESTADO' }}
${{ number_format((float) ($venta->total ?? 0), 0, ',', '.') }}
@empty
Todavía no hay ventas registradas.
@endforelse
Notificaciones internas
Alertas importantes del sistema.
@can('admin.notificaciones.ver')
{{ $ultimasNotificaciones->count() }}
Abrir
@endcan
@forelse($ultimasNotificaciones as $notificacion)
{{ $notificacion->title }}
{{ $notificacion->body }}
@if(!$notificacion->is_read)
Nueva @endif
@empty
Sin notificaciones por ahora.
@endforelse
@endsection