@vite(['resources/scss/app.scss', 'resources/js/app.js']) @livewireStyles @stack('styles')
@php $user = auth_user(); $rawDocumentTitle = trim((string) $__env->yieldContent('title')); $pageTitleOverride = trim((string) $__env->yieldContent('page_title')); $pageSubtitleOverride = trim((string) $__env->yieldContent('page_subtitle')); $pageIconOverride = trim((string) $__env->yieldContent('page_icon')); $requestPath = '/'.ltrim(request()->path(), '/'); if ($requestPath === '//') { $requestPath = '/'; } $tenantEmpresaNombre = $tenantSwitcher['current_empresa_nombre'] ?? 'N/A'; $tenantSucursalNombre = $tenantSwitcher['current_sucursal_nombre'] ?? 'N/A'; $showCompanySwitcher = (bool) ($tenantSwitcher['can_switch'] ?? false); $isSuperadminPanel = has_permission('superadmin.acceso'); $validSuperadminSections = [ 'resumen', 'wompi', 'correo', 'whatsapp_meta', 'whatsapp_meta_templates', 'whatsapp_manychat', 'notificaciones', 'ai', 'reporte_openia', 'checkout', 'cobranza', 'planes', 'empresas', 'suscripciones', 'sla', 'soporte', 'pagos', ]; $currentSuperadminSection = strtolower(trim((string) request()->query('seccion', 'resumen'))); if (! in_array($currentSuperadminSection, $validSuperadminSections, true)) { $currentSuperadminSection = 'resumen'; } $profileHomeRoute = route('perfil.index'); if ($isSuperadminPanel) { $superadminHref = static function (string $section): string { if ($section === 'resumen') { return route('superadmin.index'); } return route('superadmin.index', ['seccion' => $section]); }; $navGroups = [ [ 'title' => 'General', 'icon' => 'bx bxs-home', 'items' => [ ['label' => 'Resumen', 'href' => $superadminHref('resumen'), 'section' => 'resumen', 'icon' => 'bx bxs-dashboard', 'visible' => true], ], ], [ 'title' => 'Comercial', 'icon' => 'bx bxs-briefcase-alt-2', 'items' => [ ['label' => 'Planes', 'href' => $superadminHref('planes'), 'section' => 'planes', 'icon' => 'bx bxs-package', 'visible' => true], ['label' => 'Empresas', 'href' => $superadminHref('empresas'), 'section' => 'empresas', 'icon' => 'bx bxs-buildings', 'visible' => true], ['label' => 'Suscripciones', 'href' => $superadminHref('suscripciones'), 'section' => 'suscripciones', 'icon' => 'bx bx-time-five', 'visible' => true], ['label' => 'Pagos', 'href' => $superadminHref('pagos'), 'section' => 'pagos', 'icon' => 'bx bxs-wallet-alt', 'visible' => true], ['label' => 'Checkout fallidos', 'href' => $superadminHref('checkout'), 'section' => 'checkout', 'icon' => 'bx bx-cart-download', 'visible' => true], ['label' => 'Cobranza', 'href' => $superadminHref('cobranza'), 'section' => 'cobranza', 'icon' => 'bx bx-credit-card-front', 'visible' => true], ], ], [ 'title' => 'Api e Integraciones', 'icon' => 'bx bx-link-alt', 'items' => [ ['label' => 'Wompi', 'href' => $superadminHref('wompi'), 'section' => 'wompi', 'icon' => 'bx bx-credit-card', 'visible' => true], ['label' => 'Correo', 'href' => $superadminHref('correo'), 'section' => 'correo', 'icon' => 'bx bx-envelope', 'visible' => true], ['label' => 'WhatsApp Meta', 'href' => $superadminHref('whatsapp_meta'), 'section' => 'whatsapp_meta', 'icon' => 'bx bxl-whatsapp', 'visible' => true], ['label' => 'Templates Meta', 'href' => $superadminHref('whatsapp_meta_templates'), 'section' => 'whatsapp_meta_templates', 'icon' => 'bx bx-message-square-dots', 'visible' => true], ['label' => 'ManyChat', 'href' => $superadminHref('whatsapp_manychat'), 'section' => 'whatsapp_manychat', 'icon' => 'bx bx-chat', 'visible' => true], ['label' => 'Notificaciones', 'href' => $superadminHref('notificaciones'), 'section' => 'notificaciones', 'icon' => 'bx bx-bell', 'visible' => true], ], ], [ 'title' => 'Reporte', 'icon' => 'bx bxs-report', 'items' => [ ['label' => 'SLA', 'href' => $superadminHref('sla'), 'section' => 'sla', 'icon' => 'bx bx-timer', 'visible' => true], ['label' => 'Reporte IA', 'href' => $superadminHref('reporte_openia'), 'section' => 'reporte_openia', 'icon' => 'bx bx-line-chart', 'visible' => true], ], ], [ 'title' => 'Soporte', 'icon' => 'bx bx-support', 'items' => [ ['label' => 'Tickets', 'href' => $superadminHref('soporte'), 'section' => 'soporte', 'icon' => 'bx bx-support', 'visible' => true], ['label' => 'Ayuda IA', 'href' => $superadminHref('ai'), 'section' => 'ai', 'icon' => 'bx bx-bot', 'visible' => true], ], ], ]; } else { $navGroups = [ [ 'title' => 'Operacion', 'icon' => 'bx bxs-grid-alt', 'items' => [ ['label' => 'Dashboard', 'href' => route('dashboard'), 'match' => '/dashboard', 'icon' => 'bx bxs-grid-alt', 'visible' => has_permission('dashboard.ver')], ['label' => 'POS', 'href' => route('pos.index'), 'match' => '/pos', 'icon' => 'bx bxs-cart-add', 'visible' => has_permission('pos.vender')], ['label' => 'Ventas', 'href' => route('ventas.index'), 'match' => '/ventas', 'icon' => 'bx bxs-receipt', 'visible' => has_permission('ventas.ver')], ['label' => 'Caja', 'href' => route('caja.index'), 'match' => '/caja', 'icon' => 'bx bxs-wallet', 'visible' => has_permission('caja.ver')], ['label' => 'C. Cobrar', 'href' => route('cuentas-cobrar.index'), 'match' => '/cuentas-cobrar', 'icon' => 'bx bx-wallet-alt', 'visible' => has_permission('cuentas_cobrar.ver')], ], ], [ 'title' => 'Inventario', 'icon' => 'bx bxs-package', 'items' => [ ['label' => 'Inventario', 'href' => route('inventario.index'), 'match' => '/inventario', 'icon' => 'bx bxs-package', 'visible' => has_permission('inventario.ver')], ['label' => 'Productos', 'href' => route('productos.index'), 'match' => '/productos', 'icon' => 'bx bxs-box', 'visible' => has_permission('productos.ver')], ['label' => 'Categorias', 'href' => route('categorias.index'), 'match' => '/categorias', 'icon' => 'bx bxs-category', 'visible' => has_permission('categorias.ver')], ['label' => 'Compras', 'href' => route('compras.index'), 'match' => '/compras', 'icon' => 'bx bxs-cart-download', 'visible' => has_permission('compras.ver')], ['label' => 'Envíos', 'href' => route('envios.index'), 'match' => '/envios', 'icon' => 'bx bxs-truck', 'visible' => has_permission('envios.ver')], ['label' => 'Proveedores', 'href' => route('proveedores.index'), 'match' => '/proveedores', 'icon' => 'bx bxs-store-alt', 'visible' => has_permission('proveedores.ver')], ], ], [ 'title' => 'Comercial', 'icon' => 'bx bxs-briefcase-alt-2', 'items' => [ ['label' => 'Clientes', 'href' => route('clientes.index'), 'match' => '/clientes', 'icon' => 'bx bxs-user-detail', 'visible' => has_permission('clientes.ver')], ['label' => 'Reportes', 'href' => route('reportes.index'), 'match' => '/reportes', 'icon' => 'bx bxs-bar-chart-alt-2', 'visible' => has_permission('reportes.ver')], ], ], [ 'title' => 'Soporte', 'icon' => 'bx bx-support', 'items' => [ ['label' => 'Ticket', 'href' => route('soporte.index'), 'match' => '/soporte', 'icon' => 'bx bx-support', 'visible' => has_permission('dashboard.ver')], ['label' => 'Ayuda IA', 'href' => route('ayuda-ia.index'), 'match' => '/ayuda-ia', 'icon' => 'bx bx-bot', 'visible' => has_permission('dashboard.ver')], ], ], [ 'title' => 'Administracion', 'icon' => 'bx bxs-cog', 'items' => [ ['label' => 'Superadmin', 'href' => route('superadmin.index'), 'match' => '/superadmin', 'icon' => 'bx bxs-crown', 'visible' => has_permission('superadmin.acceso')], ['label' => 'Empresas', 'href' => route('empresas.index'), 'match' => '/empresas', 'icon' => 'bx bxs-buildings', 'visible' => has_permission('superadmin.acceso')], ['label' => 'Sucursales', 'href' => route('sucursales.index'), 'match' => '/sucursales', 'icon' => 'bx bxs-store', 'visible' => has_permission('sucursales.ver')], ['label' => 'Usuarios', 'href' => route('usuarios.index'), 'match' => '/usuarios', 'icon' => 'bx bxs-group', 'visible' => has_permission('usuarios.ver')], ['label' => 'Configuracion', 'href' => route('configuracion.index'), 'match' => '/configuracion', 'icon' => 'bx bxs-cog', 'visible' => has_permission('configuracion.ver')], ], ], ]; } $preparedGroups = []; foreach ($navGroups as $group) { $items = []; $groupHasActive = false; foreach ((array) ($group['items'] ?? []) as $item) { if (array_key_exists('visible', $item) && ! $item['visible']) { continue; } $match = (string) ($item['match'] ?? ''); $section = strtolower(trim((string) ($item['section'] ?? ''))); if ($section !== '') { $active = $requestPath === '/superadmin' && $currentSuperadminSection === $section; } else { $active = $match !== '' && ($requestPath === $match || str_starts_with($requestPath, $match.'/')); } $item['_active'] = $active; if ($active) { $groupHasActive = true; } $items[] = $item; } if ($items === []) { continue; } $preparedGroups[] = [ 'title' => (string) ($group['title'] ?? 'Modulo'), 'icon' => (string) ($group['icon'] ?? 'bx bxs-layer'), 'items' => $items, 'has_active' => $groupHasActive, ]; } $defaultOpenGroupIndex = 0; foreach ($preparedGroups as $idx => $group) { if ((bool) ($group['has_active'] ?? false)) { $defaultOpenGroupIndex = $idx; break; } } $activeNavItem = null; foreach ($preparedGroups as $group) { foreach ((array) ($group['items'] ?? []) as $item) { if ((bool) ($item['_active'] ?? false)) { $activeNavItem = $item; break 2; } } } $defaultPageTitle = $rawDocumentTitle !== '' ? trim((string) preg_replace('/\s*\|.*$/', '', $rawDocumentTitle)) : 'Dashboard'; $currentPageTitle = $pageTitleOverride !== '' ? $pageTitleOverride : $defaultPageTitle; $currentPageSubtitle = $pageSubtitleOverride !== '' ? $pageSubtitleOverride : 'Gestion operativa en tiempo real'; $defaultPageIcon = trim((string) ($activeNavItem['icon'] ?? 'bx bxs-grid-alt')); $currentPageIcon = $pageIconOverride !== '' ? $pageIconOverride : $defaultPageIcon; $profileName = trim((string) ($user->nombre ?? 'Usuario')); $profileRole = trim((string) ($user->rol?->nombre ?? 'Cuenta')); $profileInitial = strtoupper((string) mb_substr($profileName !== '' ? $profileName : 'U', 0, 1)); $notificationScope = $isSuperadminPanel ? 'superadmin' : 'tenant'; $notificationInventoryUrl = route('inventario.index'); $notificationSupportUrl = $isSuperadminPanel ? route('superadmin.index', ['seccion' => 'soporte']) : route('soporte.index'); $notificationPayload = [ 'count' => 0, 'count_stock' => 0, 'count_tickets' => 0, 'items' => [], ]; try { $notificationPayload = app(\App\Services\Notifications\NotificationCenterService::class) ->payload($notificationScope, 10); } catch (\Throwable) { // Evita romper la UI si ocurre un error temporal de lectura de notificaciones. } @endphp @if ($user)