@include('partials.head') @php $isVendedor = auth('vendedor')->check(); $currentUser = auth()->user() ?? auth('vendedor')->user(); @endphp @if ($isVendedor)
{{ __('Productos disponibles') }} {{ \App\Models\Producto::sum('stock_disponible') }} {{ __('Registro de cliente') }} {{ __('Crear pedido') }} {{ __('Pedidos') }}
@else @php $fromDb = \App\Models\Producto::sum('stock_pendiente'); $prodNeeded = \Illuminate\Support\Facades\DB::table('pedido_items') ->join('productos', 'pedido_items.producto_id', '=', 'productos.id') ->join('pedidos', 'pedido_items.pedido_id', '=', 'pedidos.id') ->where('pedidos.estado', 'pendiente') ->selectRaw('productos.id, productos.stock_disponible, SUM(pedido_items.cantidad) as cantidad_total') ->groupBy('productos.id', 'productos.stock_disponible') ->get(); $fromPedidos = 0; foreach ($prodNeeded as $p) { if ($p->stock_disponible < $p->cantidad_total) { $fromPedidos += $p->cantidad_total - $p->stock_disponible; } } $prodPendienteCount = $fromDb + $fromPedidos; @endphp {{ __('Dashboard') }} {{ __('Productos') }} {{ \App\Models\Producto::sum('stock_disponible') }} @if($prodPendienteCount > 0) | {{ $prodPendienteCount }} pend. @endif {{ __('Productos Pendientes') }} {{ $prodPendienteCount }} @livewire('sidebar-stock') {{ __('Gestión de Pedidos') }} {{ __('Lista de Precios') }} {{ __('Vendedores') }} {{ __('Analíticas') }} {{ __('Reportes') }} {{ __('Estadísticas de Vendedores') }} {{ __('Metas Cumplidas') }} @php $metasCount = \App\Models\MetaCumplida::count(); @endphp @if($metasCount > 0) {{ $metasCount }} @endif {{ __('Por Vendedor') }} {{ __('Por Cliente') }} {{ __('Estadísticas de Clientes') }} {{ __('Panel Vendedores') }} {{ __('Panel Clientes') }} {{ __('Clientes') }} {{ __('Ventas') }} {{ __('Notas de Entrega') }} @php $notasCount = \App\Models\Venta::whereNotNull('nota_entrega') ->where('nota_entrega', '!=', '') ->count(); @endphp @if($notasCount > 0) {{ $notasCount }} @endif {{ __('Chat con Vendedores') }} @php $mensajesNoLeidos = \App\Models\ChatMessage::whereNull('leido') ->orWhere('leido', false) ->whereNull('user_id') ->whereNull('admin_id') ->count(); @endphp @if($mensajesNoLeidos > 0) {{ $mensajesNoLeidos }} @endif @endif {{ __('Repository') }} {{ __('Documentation') }}
{{ $currentUser?->initials() }}
{{ $currentUser?->name }} {{ $currentUser?->email }}
{{ __('Settings') }}
@csrf {{ __('Log Out') }}
{{ $slot }} @fluxScripts @if(request()->is('chat-admin*')) @endif @stack('scripts')