432 lines
21 KiB
PHP
432 lines
21 KiB
PHP
<!-- views/partials/sidebar_configuracion.php -->
|
|
<?php
|
|
// Verificar que el usuario esté autenticado
|
|
if (!isset($_SESSION['usuario_id'])) {
|
|
header('Location: /IMPORTADORES/login');
|
|
exit;
|
|
}
|
|
|
|
// Obtener información del usuario
|
|
$tipoUsuario = $_SESSION['tipo_usuario'] ?? '';
|
|
$usuarioId = $_SESSION['usuario_id'] ?? null;
|
|
|
|
// Definir permisos por tipo de usuario
|
|
$permisos = [
|
|
'super_admin' => [
|
|
'informacion_general' => true,
|
|
'automatizaciones' => true,
|
|
'preferencias' => true,
|
|
'seguridad' => true,
|
|
'bitacoras' => [
|
|
'registro_accesos' => true,
|
|
'registro_cambios' => true,
|
|
'registro_usuarios' => true,
|
|
'registro_agencias' => true,
|
|
'mi_actividad' => true
|
|
],
|
|
],
|
|
'admin_agencia' => [
|
|
'informacion_general' => true,
|
|
'automatizaciones' => true,
|
|
'preferencias' => true,
|
|
'seguridad' => true,
|
|
'bitacoras' => [
|
|
'acceso_usuarios_agencia' => true,
|
|
'registro_vinculaciones' => true,
|
|
'mi_actividad' => true
|
|
],
|
|
],
|
|
'agente_aduanal' => [
|
|
'informacion_general' => true,
|
|
'automatizaciones' => true,
|
|
'preferencias' => true,
|
|
'seguridad' => true,
|
|
'bitacoras' => [
|
|
'acceso_usuarios_agencia' => true,
|
|
'registro_vinculaciones' => true,
|
|
'mi_actividad' => true
|
|
],
|
|
],
|
|
'importador' => [
|
|
'informacion_general' => true,
|
|
'automatizaciones' => true,
|
|
'preferencias' => true,
|
|
'seguridad' => true,
|
|
'bitacoras' => [
|
|
'vinculaciones_usuario' => true,
|
|
'mi_actividad' => true
|
|
],
|
|
],
|
|
];
|
|
|
|
// Obtener permisos del usuario actual
|
|
$permisosUsuario = $permisos[$tipoUsuario] ?? $permisos['importador'];
|
|
$permisosBitacoras = $permisosUsuario['bitacoras'] ?? [];
|
|
|
|
// Función para verificar si el usuario tiene acceso a bitácoras
|
|
function tieneAccesoBitacoras($permisosBitacoras) {
|
|
if (is_bool($permisosBitacoras)) {
|
|
return $permisosBitacoras;
|
|
}
|
|
return !empty($permisosBitacoras) && array_filter($permisosBitacoras);
|
|
}
|
|
|
|
// Contar bitácoras disponibles según permisos
|
|
function contarBitacorasDisponibles($permisosBitacoras) {
|
|
if (!is_array($permisosBitacoras)) {
|
|
return is_bool($permisosBitacoras) && $permisosBitacoras ? 1 : 0;
|
|
}
|
|
return count(array_filter($permisosBitacoras));
|
|
}
|
|
|
|
$cantidadBitacoras = contarBitacorasDisponibles($permisosBitacoras);
|
|
|
|
// Variables para detectar las vistas actuales
|
|
$currentPath = $_SERVER['REQUEST_URI'];
|
|
$esConfiguracion = $currentPath === '/IMPORTADORES/configuracion/index' || $currentPath === '/IMPORTADORES/configuracion';
|
|
$esVistaAutomatizaciones = strpos($currentPath, '/IMPORTADORES/automatizaciones/') === 0;
|
|
$esVistaPreferencias = strpos($currentPath, '/IMPORTADORES/preferencias/') === 0;
|
|
$esVistaSeguridad = strpos($currentPath, '/IMPORTADORES/seguridad/') === 0;
|
|
$esVistaBitacoras = strpos($currentPath, '/IMPORTADORES/bitacoras/') === 0 && $currentPath !== '/IMPORTADORES/configuracion';
|
|
$esVistaReset = strpos($currentPath, '/IMPORTADORES/reset/') === 0;
|
|
|
|
// Función para obtener el texto descriptivo según el permiso
|
|
function obtenerTextoPermiso($permiso, $tipoUsuario) {
|
|
$textos = [
|
|
'registro_accesos' => ($tipoUsuario === 'super_admin') ? 'Registro de accesos' : null,
|
|
'registro_cambios' => ($tipoUsuario === 'super_admin') ? 'Cambios de usuarios' : null,
|
|
'registro_usuarios' => ($tipoUsuario === 'super_admin') ? 'Registro de usuarios' : null,
|
|
'registro_agencias' => ($tipoUsuario === 'super_admin') ? 'Registro de agencias' : null,
|
|
'acceso_usuarios_agencia' => ($tipoUsuario === 'admin_agencia' || $tipoUsuario === 'agente_aduanal') ? 'Registro de accesos' : null,
|
|
'registro_vinculaciones' => ($tipoUsuario === 'admin_agencia' || $tipoUsuario === 'agente_aduanal') ? 'Vinculaciones (Agencia)' : null,
|
|
'mi_actividad' => in_array($tipoUsuario, ['super_admin', 'admin_agencia', 'agente_aduanal', 'importador']) ? 'Mi actividad' : null,
|
|
'vinculaciones_usuario' => ($tipoUsuario === 'importador') ? 'Mis vinculaciones' : null,
|
|
];
|
|
|
|
return $textos[$permiso] ?? ucfirst(str_replace('_', ' ', $permiso));
|
|
}
|
|
|
|
// Función para obtener la URL según el permiso
|
|
function obtenerUrlPermiso($permiso) {
|
|
$urls = [
|
|
'registro_accesos' => '/IMPORTADORES/bitacoras/sistema', // ✅
|
|
'registro_cambios' => '/IMPORTADORES/bitacoras/cambios', // ✅
|
|
'registro_usuarios' => '/IMPORTADORES/bitacoras/usuarios', //
|
|
'registro_agencias' => '/IMPORTADORES/bitacoras/agencias', // ✅
|
|
'acceso_usuarios_agencia' => '/IMPORTADORES/bitacoras/sistemaAgencia', // ✅
|
|
'registro_vinculaciones' => '/IMPORTADORES/bitacoras/vinculaciones', // ✅
|
|
'mi_actividad' => '/IMPORTADORES/bitacoras/miAcceso', // ✅
|
|
'vinculaciones_usuario' => '/IMPORTADORES/bitacoras/vinculacionesUsuario' // ✅
|
|
];
|
|
|
|
return $urls[$permiso] ?? '/IMPORTADORES/bitacoras/index';
|
|
}
|
|
?>
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
|
|
<style>
|
|
/* Estilos inspirados en Tailwind */
|
|
.sidebar-container { background-color: #f9fafb; border-right: 1px solid #e5e7eb; }
|
|
.sidebar-dark { background-color: #1f2937; border-right: 1px solid #374151; }
|
|
.sidebar-nav .nav-link { color: #374151; font-weight: 500; padding: 0.5rem 0.75rem; margin-bottom: 0.125rem;
|
|
border-radius: 0.5rem; transition: all 0.15s ease-in-out; display: flex; align-items: center; }
|
|
.sidebar-nav .nav-link:hover { background-color: #f3f4f6; color: #111827; }
|
|
.sidebar-nav .nav-link.active { background-color: #f3f4f6; color: #111827; }
|
|
.sidebar-nav .nav-link .icon { width: 1.25rem; height: 1.25rem; margin-right: 0.75rem; color: #6b7280; transition: color 0.15s ease-in-out; flex-shrink: 0; }
|
|
.sidebar-nav .nav-link:hover .icon,
|
|
.sidebar-nav .nav-link.active .icon { color: #374151; }
|
|
.sidebar-nav .badge { background-color: #f3f4f6; color: #374151; font-size: 0.75rem; font-weight: 500; padding: 0.25rem 0.5rem; border-radius: 9999px; margin-left: auto; }
|
|
.sidebar-nav .badge.badge-primary { background-color: #dbeafe; color: #1e40af; }
|
|
.submenu .nav-link { padding-left: 2.75rem; color: #6b7280; font-weight: 400; }
|
|
.submenu .nav-link:hover { background-color: #f3f4f6; color: #374151; }
|
|
.submenu .nav-link.active { background-color: #f3f4f6; color: #374151; }
|
|
.collapse-icon { width: 0.75rem; height: 0.75rem; margin-left: auto; transition: transform 0.15s ease-in-out; }
|
|
.nav-link[aria-expanded="true"] .collapse-icon { transform: rotate(180deg); }
|
|
/* Estilos para modo oscuro */
|
|
.sidebar-dark .sidebar-nav .nav-link { color: #d1d5db; }
|
|
.sidebar-dark .sidebar-nav .nav-link:hover { background-color: #374151; color: #ffffff; }
|
|
.sidebar-dark .sidebar-nav .nav-link.active { background-color: #374151; color: #ffffff; }
|
|
.sidebar-dark .sidebar-nav .nav-link .icon { color: #9ca3af; }
|
|
.sidebar-dark .sidebar-nav .nav-link:hover .icon,
|
|
.sidebar-dark .sidebar-nav .nav-link.active .icon { color: #ffffff; }
|
|
.sidebar-dark .sidebar-nav .badge { background-color: #374151; color: #d1d5db; }
|
|
.sidebar-dark .sidebar-nav .badge.badge-primary { background-color: #1e3a8a; color: #93c5fd; }
|
|
.sidebar-dark .submenu .nav-link { color: #9ca3af; }
|
|
.sidebar-dark .submenu .nav-link:hover { background-color: #374151; color: #d1d5db; }
|
|
.sidebar-dark .submenu .nav-link.active { background-color: #374151; color: #d1d5db; }
|
|
/* Navbar */
|
|
.navbar-brand { font-weight: 600; font-size: 1.125rem; }
|
|
.menu-toggle { border: 1px solid #6b7280; border-radius: 0.5rem; padding: 0.5rem; transition: all 0.15s ease-in-out; }
|
|
.menu-toggle:hover { background-color: #f3f4f6; }
|
|
/* Offcanvas para móviles */
|
|
.offcanvas { background-color: #ffffff; }
|
|
.offcanvas-header { border-bottom: 1px solid #e5e7eb; padding: 1rem 1.5rem; }
|
|
.offcanvas-title { font-weight: 600; font-size: 1.125rem; color: #111827; }
|
|
.offcanvas-body { padding: 1rem 1.5rem; }
|
|
/* Responsive adjustments */
|
|
@media (max-width: 767.98px) {
|
|
.sidebar-nav .nav-link { color: #374151; }
|
|
.sidebar-nav .nav-link:hover { background-color: #f3f4f6; color: #111827; }
|
|
.sidebar-nav .nav-link.active { background-color: #f3f4f6; color: #111827; }
|
|
.permission-scope { background-color: rgba(108, 117, 125, 0.2); }
|
|
.submenu-item:hover { background-color: rgba(233, 236, 239, 0.8) !important; }
|
|
}
|
|
.user-badge { font-size: 0.75rem; padding: 2px 6px; border-radius: 3px; }
|
|
.permission-indicator { font-size: 0.7rem; color: #28a745; margin-left: 5px; }
|
|
.permission-scope { font-size: 0.65rem; color: #6c757d; margin-left: 5px; padding: 1px 4px; background-color: rgba(108, 117, 125, 0.1); border-radius: 2px; }
|
|
.submenu-item { font-size: 0.9rem; padding-left: 1rem !important; }
|
|
.submenu-item:hover { background-color: rgba(73, 80, 87, 0.7) !important; }
|
|
</style>
|
|
|
|
<!-- NAVBAR -->
|
|
<nav class="navbar navbar-dark bg-dark fixed-top">
|
|
<div class="container-fluid">
|
|
<!-- Botón de menú para móviles -->
|
|
<button class="menu-toggle d-md-none me-3" type="button" data-bs-toggle="offcanvas" data-bs-target="#sidebarMenu">
|
|
☰
|
|
</button>
|
|
<span class="navbar-brand">
|
|
SIIH | Configuración
|
|
<span class="user-badge bg-info text-dark ms-2"><?= strtoupper(str_replace('_', ' ', $tipoUsuario)) ?></span>
|
|
</span>
|
|
<div class="d-flex ms-auto">
|
|
<?php
|
|
// Definir la URL de regreso según el tipo de usuario
|
|
$urlRegreso = match($tipoUsuario) {
|
|
'super_admin' => '/IMPORTADORES/administrador/dashboard',
|
|
'admin_agencia' => '/IMPORTADORES/agencias/dashboard',
|
|
'agente_aduanal' => '/IMPORTADORES/agentes/dashboard',
|
|
'importador' => '/IMPORTADORES/importadores/dashboard',
|
|
default => '/IMPORTADORES/importadores/dashboard'
|
|
};
|
|
?>
|
|
<a href="<?= $urlRegreso ?>" class="btn btn-outline-light btn-sm ms-2 W-auto btn-animated" style="margin: 0 0 0 25px;">
|
|
← Panel Principal
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- SIDEBAR FIJA (escritorio) -->
|
|
<div class="d-none d-md-block sidebar-container sidebar-dark position-fixed h-100" style="width: 250px; top: 0; padding-top: 4rem; z-index: 1000;">
|
|
<div class="px-3 py-4 h-100 overflow-y-auto">
|
|
<nav class="sidebar-nav">
|
|
<ul class="nav flex-column">
|
|
<!-- INFORMACIÓN GENERAL -->
|
|
<li class="nav-item">
|
|
<?php if ($permisosUsuario['informacion_general']): ?>
|
|
<a href="/IMPORTADORES/configuracion/index" class="nav-link">
|
|
<svg class="icon" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M18 10c0 4.418-3.582 8-8 8s-8-3.582-8-8 3.582-8 8-8 8 3.582 8 8zm-8-4a1 1 0 100 2 1 1 0 000-2zm-1 4a1 1 0 000 2h1v3a1 1 0 102 0v-4a1 1 0 00-1-1h-2z" clip-rule="evenodd" />
|
|
</svg>
|
|
<span>Información general</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
</li>
|
|
<!-- AUTOMATIZACIONES -->
|
|
<li class="nav-item">
|
|
<?php if ($permisosUsuario['automatizaciones']): ?>
|
|
<a href="/IMPORTADORES/automatizaciones/index" class="nav-link">
|
|
<svg class="icon" fill="currentColor" viewBox="0 0 20 20">
|
|
<path d="M13 7H7v6h6V7z" />
|
|
<path fill-rule="evenodd" d="M5 3a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2V9.586a1 1 0 00-.293-.707l-4.586-4.586A1 1 0 0012.414 4H5zm7 1.414L16.586 10H13a1 1 0 01-1-1V4.414z" clip-rule="evenodd"/>
|
|
</svg>
|
|
<span>Automatizaciones</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
</li>
|
|
<!-- PREFERENCIAS -->
|
|
<li class="nav-item">
|
|
<?php if ($permisosUsuario['preferencias']): ?>
|
|
<?php $enDashboardPreferencias = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/preferencias/index'; ?>
|
|
<a class="nav-link <?= $esVistaPreferencias ? 'active' : '' ?>"
|
|
href="<?= $enDashboardPreferencias ? '#submenuPreferencias' : '/IMPORTADORES/preferencias/index' ?>"
|
|
<?= $enDashboardPreferencias ? 'data-bs-toggle="collapse"' : '' ?>
|
|
role="button" aria-expanded="false" aria-controls="submenuPreferencias"
|
|
onclick="<?= $enDashboardPreferencias ? 'return true;' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/preferencias/index\';' ?>">
|
|
<svg class="icon" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M11.3 1.046a1 1 0 00-2.6 0L7.528 3H4a1 1 0 000 2h1v10H4a1 1 0 000 2h3.528l1.172 1.954a1 1 0 001.6 0L12.472 17H16a1 1 0 000-2h-1V5h1a1 1 0 100-2h-3.528L11.3 1.046zM9 6a1 1 0 011 1v6a1 1 0 11-2 0V7a1 1 0 011-1z" clip-rule="evenodd"/>
|
|
</svg>
|
|
<span>Preferencias</span>
|
|
<svg class="collapse-icon" fill="none" stroke="currentColor" viewBox="0 0 10 6">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
|
</svg>
|
|
</a>
|
|
<div class="collapse" id="submenuPreferencias">
|
|
<ul class="nav flex-column submenu">
|
|
<li class="nav-item">
|
|
<a href="/IMPORTADORES/preferencias/notificaciones" class="nav-link">
|
|
Gestión de Notificaciones
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a href="/IMPORTADORES/preferencias/catalogos" class="nav-link">
|
|
Visualización de Catálogos
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<?php endif; ?>
|
|
</li>
|
|
<!-- SEGURIDAD -->
|
|
<li class="nav-item">
|
|
<?php if ($permisosUsuario['seguridad']): ?>
|
|
<?php $enDashboardSeguridad = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/seguridad/index'; ?>
|
|
<a class="nav-link <?= $esVistaSeguridad ? 'active' : '' ?>"
|
|
href="<?= $enDashboardSeguridad ? '#submenuSeguridad' : '/IMPORTADORES/seguridad/index' ?>"
|
|
<?= $enDashboardSeguridad ? 'data-bs-toggle="collapse"' : '' ?>
|
|
role="button" aria-expanded="false" aria-controls="submenuSeguridad"
|
|
onclick="<?= $enDashboardSeguridad ? 'return true;' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/seguridad/index\';' ?>">
|
|
<svg class="icon" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M10 2a4 4 0 00-4 4v2H5a2 2 0 00-2 2v6a2 2 0 002 2h10a2 2 0 002-2v-6a2 2 0 00-2-2h-1V6a4 4 0 00-4-4zm2 6V6a2 2 0 10-4 0v2h4z" clip-rule="evenodd"/>
|
|
</svg>
|
|
<span>Seguridad</span>
|
|
<svg class="collapse-icon" fill="none" stroke="currentColor" viewBox="0 0 10 6">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
|
</svg>
|
|
</a>
|
|
<div class="collapse" id="submenuSeguridad">
|
|
<nav class="nav flex-column submenu">
|
|
<li class="nav-item">
|
|
<a href="/IMPORTADORES/seguridad/opciones" class="nav-link">
|
|
Opciones de Seguridad
|
|
</a>
|
|
</li>
|
|
</nav>
|
|
</div>
|
|
<?php endif; ?>
|
|
</li>
|
|
<!-- BITÁCORAS CON PERMISOS ESPECÍFICOS -->
|
|
<li class="nav-item">
|
|
<?php if (tieneAccesoBitacoras($permisosBitacoras)): ?>
|
|
<?php $enDashboardBitacoras = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/index'; ?>
|
|
<a class="nav-link <?= $esVistaBitacoras ? 'active' : '' ?>"
|
|
href="<?= $enDashboardBitacoras ? '#submenuBitacoras' : '/IMPORTADORES/bitacoras/index' ?>"
|
|
<?= $enDashboardBitacoras ? 'data-bs-toggle="collapse"' : '' ?>
|
|
role="button" aria-expanded="<?= $enDashboardBitacoras ? 'false' : 'false' ?>" aria-controls="submenuBitacoras"
|
|
onclick="<?= $enDashboardBitacoras ? 'return true;' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/bitacoras/index\';' ?>">
|
|
<svg class="icon" fill="currentColor" viewBox="0 0 20 20">
|
|
<path d="M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a1 1 0 001-1V4a1 1 0 00-1-1H4zm0 2h11v10H4V5z"/>
|
|
<path d="M6 7h5v1H6V7zm0 3h8v1H6v-1z"/>
|
|
</svg>
|
|
<span>Bitácoras</span>
|
|
<svg class="collapse-icon" fill="none" stroke="currentColor" viewBox="0 0 10 6">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
|
</svg>
|
|
</a>
|
|
<div class="collapse" id="submenuBitacoras">
|
|
<nav class="nav flex-column submenu">
|
|
<?php foreach ($permisosBitacoras as $permiso => $tienePermiso): ?>
|
|
<li class="nav-item">
|
|
<?php if ($tienePermiso): ?>
|
|
<?php
|
|
$url = obtenerUrlPermiso($permiso);
|
|
$texto = obtenerTextoPermiso($permiso, $tipoUsuario);
|
|
$esActivo = $_SERVER['REQUEST_URI'] === $url;
|
|
|
|
// Scope según dashboard
|
|
$scope = '';
|
|
if ($tipoUsuario === 'super_admin') {
|
|
$scope = 'Global';
|
|
} elseif ($tipoUsuario === 'admin_agencia' || $tipoUsuario === 'agente_aduanal') {
|
|
if (in_array($permiso, ['acceso_usuarios_agencia', 'registro_vinculaciones'])) {
|
|
$scope = 'Agencia';
|
|
} elseif (in_array($permiso, ['mis_vinculaciones', 'mi_actividad'])) {
|
|
$scope = 'Personal';
|
|
}
|
|
} elseif ($tipoUsuario === 'importador') {
|
|
$scope = 'Personal';
|
|
}
|
|
?>
|
|
<a href="<?= $url ?>"
|
|
class="nav-link submenu-item px-3 py-2 d-flex justify-content-between align-items-center <?= $esActivo ? 'active' : '' ?>">
|
|
<span>
|
|
<?= htmlspecialchars($texto) ?>
|
|
<?php if ($scope): ?>
|
|
<span class="permission-scope"><?= $scope ?></span>
|
|
<?php endif; ?>
|
|
</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</nav>
|
|
</div>
|
|
<?php endif; ?>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- OFFCANVAS PARA MÓVILES -->
|
|
<div class="offcanvas offcanvas-start d-md-none" tabindex="-1" id="sidebarMenu" style="top: 0; width: 250px;">
|
|
<div class="offcanvas-header">
|
|
<h5 class="offcanvas-title">Menú</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="offcanvas"></button>
|
|
</div>
|
|
<div class="offcanvas-body">
|
|
<nav class="sidebar-nav">
|
|
<ul class="nav flex-column">
|
|
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Detectar la ruta actual
|
|
const currentPath = window.location.pathname;
|
|
|
|
// Función para abrir collapse si la página actual está en esa sección
|
|
function inicializarCollapses() {
|
|
// Preferencias
|
|
if (currentPath.includes('/preferencias/')) {
|
|
const preferencesCollapse = document.getElementById('submenuPreferencias');
|
|
if (preferencesCollapse) {
|
|
preferencesCollapse.classList.add('show');
|
|
const trigger = document.querySelector('[aria-controls="submenuPreferencias"]');
|
|
if (trigger) trigger.setAttribute('aria-expanded', 'true');
|
|
}
|
|
}
|
|
|
|
// Seguridad
|
|
if (currentPath.includes('/seguridad/')) {
|
|
const securityCollapse = document.getElementById('submenuSeguridad');
|
|
if (securityCollapse) {
|
|
securityCollapse.classList.add('show');
|
|
const trigger = document.querySelector('[aria-controls="submenuSeguridad"]');
|
|
if (trigger) trigger.setAttribute('aria-expanded', 'true');
|
|
}
|
|
}
|
|
|
|
// Bitácoras
|
|
if (currentPath.includes('/bitacoras/')) {
|
|
const bitacorasCollapse = document.getElementById('submenuBitacoras');
|
|
if (bitacorasCollapse) {
|
|
bitacorasCollapse.classList.add('show');
|
|
const trigger = document.querySelector('[aria-controls="submenuBitacoras"]');
|
|
if (trigger) trigger.setAttribute('aria-expanded', 'true');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Marcar enlaces activos
|
|
function marcarEnlacesActivos() {
|
|
const navLinks = document.querySelectorAll('.nav-link');
|
|
navLinks.forEach(link => {
|
|
const href = link.getAttribute('href');
|
|
if (href && currentPath === href) {
|
|
link.classList.add('active');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Inicializar todo
|
|
inicializarCollapses();
|
|
marcarEnlacesActivos();
|
|
});
|
|
</script>
|