474 lines
22 KiB
PHP
474 lines
22 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'] ?? '';
|
||
$agenciaId = $_SESSION['agencia_id'] ?? null;
|
||
$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_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,
|
||
'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);
|
||
|
||
// 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_usuarios' => ($tipoUsuario === 'super_admin') ? 'Registro de usuarios' : null,
|
||
'registro_agencias' => ($tipoUsuario === 'super_admin') ? 'Registro de agencias' : null,
|
||
'acceso_usuarios_agencias' => ($tipoUsuario === 'admin_agencia' || $tipoUsuario === 'agente_aduanal') ? 'Registros 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 el icono según el permiso
|
||
function obtenerIconoPermiso($permiso) {
|
||
$iconos = [
|
||
'registro_accesos' => '🌐',
|
||
'registro_usuarios' => '👥',
|
||
'registro_agencias' => '🏪',
|
||
'acceso_usuarios_agencia' => '👥',
|
||
'registro_vinculaciones' => '🔗',
|
||
'mi_actividad' => '👤',
|
||
'vinculaciones_usuario' => '🔗'
|
||
];
|
||
|
||
return $iconos[$permiso] ?? '📋';
|
||
}
|
||
|
||
// Función para obtener la URL según el permiso
|
||
function obtenerUrlPermiso($permiso) {
|
||
$urls = [
|
||
'registro_accesos' => '/IMPORTADORES/bitacoras/sistema',
|
||
'registro_usuarios' => '/IMPORTADORES/bitacoras/usuarios',
|
||
'registro_agencias' => '/IMPORTADORES/bitacoras/agencias',
|
||
'acceso_usuarios_agencia' => '/IMPORTADORES/bitacoras/sistemaAgencia',
|
||
'registro_vinculaciones' => '/IMPORTADORES/bitacoras/vinculaciones',
|
||
'mis_vinculaciones' => '/IMPORTADORES/bitacoras/misVinculaciones',
|
||
'mi_actividad' => '/IMPORTADORES/bitacoras/miAcceso',
|
||
'vinculaciones_usuario' => '/IMPORTADORES/bitacoras/vinculacionesUsuario'
|
||
];
|
||
|
||
return $urls[$permiso] ?? '/IMPORTADORES/bitacoras/index';
|
||
}
|
||
?>
|
||
|
||
<style>
|
||
.nav .nav-link { font-weight: normal; color: white; transition: all 0.3s ease; }
|
||
.nav .nav-link:hover,
|
||
.nav .nav-link.active { background-color: #495057; color: #fff; }
|
||
/* Estilo inverso solo para pantallas pequeñas (sidebar tipo offcanvas) */
|
||
@media (max-width: 767.98px) {
|
||
.nav .nav-link { font-weight: normal; color: #343a40; background-color: transparent; }
|
||
.nav .nav-link:hover,
|
||
.nav .nav-link.active { background-color: #e9ecef; color: #212529; }
|
||
.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="btn btn-outline-light d-md-none me-2" 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" style="margin: 0 0 0 25px;">
|
||
← Panel Principal
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<!-- SIDEBAR FIJA (escritorio) -->
|
||
<div class="d-none d-md-block bg-dark text-white position-fixed h-100 pt-5" style="width: 250px;">
|
||
<nav class="nav flex-column">
|
||
|
||
<!-- Definimos variables de ubicación -->
|
||
<?php
|
||
// Detecta si estamos en alguna parte de configuración
|
||
$esConfiguracion = str_contains($_SERVER['REQUEST_URI'], '/configuracion');
|
||
// Detecta si estamos en alguna parte de bitácoras
|
||
$esVistaBitacoras = str_contains($_SERVER['REQUEST_URI'], '/bitacoras');
|
||
// Detecta si estamos en alguna parta de seguridad
|
||
$esVistaSeguridad = str_contains($_SERVER['REQUEST_URI'], '/seguridad');
|
||
// Detecta si estamos en alguna parte de preferencias
|
||
$esVistaPreferencias = str_contains($_SERVER['REQUEST_URI'], '/preferencias');
|
||
// Detecta si estamos en alguna parte de automatizaciones
|
||
$esVistaAutomatizaciones = str_contains($_SERVER['REQUEST_URI'], '/automatizaciones');
|
||
?>
|
||
|
||
<!-- INFORMACIÓN GENERAL -->
|
||
<?php if ($permisosUsuario['informacion_general']): ?>
|
||
<a href="/IMPORTADORES/configuracion/index"
|
||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/configuracion/dashboard_configuracion') ? 'active' : '' ?>">
|
||
ℹ️ Información General
|
||
</a>
|
||
<?php endif; ?>
|
||
|
||
<!-- AUTOMATIZACIONES -->
|
||
<?php if ($permisosUsuario['automatizaciones']): ?>
|
||
<?php if ($esVistaAutomatizaciones): ?>
|
||
<?php $enDashboardAutomatizaciones = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/automatizaciones/index'; ?>
|
||
<a href="/IMPORTADORES/automatizaciones/index"
|
||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/automatizaciones/index') ? 'active' : '' ?>">
|
||
⚙️ Automatizaciones
|
||
</a>
|
||
<?php elseif ($esConfiguracion || $esVistaSeguridad || $esVistaPreferencias || $esVistaBitacoras): ?>
|
||
<a href="/IMPORTADORES/automatizaciones/index"
|
||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/automatizaciones/index') ? 'active' : '' ?>">
|
||
⚙️ Automatizaciones
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<!-- PREFERENCIAS -->
|
||
<?php if ($permisosUsuario['preferencias']): ?>
|
||
<?php if ($esVistaPreferencias): ?>
|
||
<?php $enDashboardPreferencias = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/preferencias/index'; ?>
|
||
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaPreferencias ? 'active' : '' ?>"
|
||
href="<?= $enDashboardPreferencias ? '#submenuPreferencias' : '/IMPORTADORES/preferencias/index' ?>"
|
||
<?= $enDashboardPreferencias ? 'data-bd-toggle="collapse"' : '' ?>
|
||
role="button" aria-expanded="true" aria-controls="submenuPreferencias"
|
||
onclick="<? $enDashboardPreferencias ? '' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/preferencias/index\';' ?>">
|
||
✅ Preferencias
|
||
<span class="badge bg-secondary">1</span>
|
||
</a>
|
||
<div class="collapse show" id="submenuPreferencias">
|
||
<nav class="nav flex-column ms-3">
|
||
<a href="/IMPORTADORES/preferencias/notificaciones"
|
||
class="nav-link px-3 py-1 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/preferencias/notificaciones' ? 'active' : '' ?>">
|
||
• Gestión de Notificaciones
|
||
</a>
|
||
</nav>
|
||
</div>
|
||
<?php elseif ($esConfiguracion || $esVistaAutomatizaciones || $esVistaSeguridad || $esVistaBitacoras): ?>
|
||
<a href="/IMPORTADORES/preferencias/index"
|
||
class="nav-link px-3 py-2 d-flex justify-content-between align-items-center">
|
||
✅ Preferencias
|
||
<span class="badge bg-secondary">1</span>
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<!-- SEGURIDAD -->
|
||
<?php if ($permisosUsuario['seguridad']): ?>
|
||
<?php if ($esVistaSeguridad): ?>
|
||
<?php $enDashboardSeguridad = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/seguridad/index'; ?>
|
||
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaSeguridad ? 'active' : '' ?>"
|
||
href="<?= $enDashboardSeguridad ? '#submenuSeguridad' : '/IMPORTADORES/seguridad/index' ?>"
|
||
<?= $enDashboardSeguridad ? 'data-bs-toggle="collapse"' : '' ?>
|
||
role="button" aria-expanded="true" aria-controls="submenuSeguridad"
|
||
onclick="<?= $enDashboardSeguridad ? '' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/seguridad/index\';' ?>">
|
||
👮 Seguridad
|
||
<span class="badge bg-secondary">1</span>
|
||
</a>
|
||
<div class="collapse show" id="submenuSeguridad">
|
||
<nav class="nav flex-column ms-3">
|
||
<a href="/IMPORTADORES/seguridad/opciones"
|
||
class="nav-link px-3 py-1 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/seguridad/opciones' ? 'active' : '' ?>">
|
||
• Opciones de Seguridad
|
||
</a>
|
||
</nav>
|
||
</div>
|
||
<?php elseif ($esConfiguracion || $esVistaAutomatizaciones || $esVistaPreferencias || $esVistaBitacoras): ?>
|
||
<a href="/IMPORTADORES/seguridad/index"
|
||
class="nav-link px-3 py-2 d-flex justify-content-between align-items-center">
|
||
👮 Seguridad
|
||
<span class="badge bg-secondary">1</span>
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<!-- BITÁCORAS CON PERMISOS ESPECÍFICOS -->
|
||
<?php if (tieneAccesoBitacoras($permisosBitacoras)): ?>
|
||
<?php $enDashboardBitacoras = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/index'; ?>
|
||
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaBitacoras ? 'active' : '' ?>"
|
||
href="<?= $enDashboardBitacoras ? '#submenuBitacoras' : '/IMPORTADORES/bitacoras/index' ?>"
|
||
<?= $enDashboardBitacoras ? 'data-bs-toggle="collapse"' : '' ?>
|
||
role="button" aria-expanded="true" aria-controls="submenuBitacoras"
|
||
onclick="<?= $enDashboardBitacoras ? '' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/bitacoras/index\';' ?>">
|
||
📖 Bitácoras
|
||
<span class="badge bg-secondary"><?= $cantidadBitacoras ?></span>
|
||
</a>
|
||
|
||
<div class="collapse <?= $esVistaBitacoras ? 'show' : '' ?>" id="submenuBitacoras">
|
||
<nav class="nav flex-column ms-3">
|
||
<?php foreach ($permisosBitacoras as $permiso => $tienePermiso): ?>
|
||
<?php if ($tienePermiso): ?>
|
||
<?php
|
||
$url = obtenerUrlPermiso($permiso);
|
||
$texto = obtenerTextoPermiso($permiso, $tipoUsuario);
|
||
$icono = obtenerIconoPermiso($permiso);
|
||
$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>
|
||
<?= $icono ?> <?= htmlspecialchars($texto) ?>
|
||
<?php if ($scope): ?>
|
||
<span class="permission-scope"><?= $scope ?></span>
|
||
<?php endif; ?>
|
||
</span>
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php endforeach; ?>
|
||
</nav>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
</nav>
|
||
</div>
|
||
|
||
<!-- OFFCANVAS PARA MÓVILES -->
|
||
<div class="offcanvas offcanvas-start d-md-none" tabindex="-1" id="sidebarMenu" style="top: 56px;">
|
||
<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">
|
||
|
||
<!-- INFORMACIÓN GENERAL -->
|
||
<?php if ($permisosUsuario['informacion_general']): ?>
|
||
<a href="/IMPORTADORES/configuracion/index"
|
||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/configuracion/dashboard_configuracion') ? 'active' : '' ?>">
|
||
ℹ️ Información General
|
||
</a>
|
||
<?php endif; ?>
|
||
|
||
<!-- AUTOMATIZACIONES -->
|
||
<?php if ($permisosUsuario['automatizaciones']): ?>
|
||
<?php if ($esVistaAutomatizaciones): ?>
|
||
<?php $enDashboardAutomatizaciones = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/automatizaciones/index'; ?>
|
||
<a href="/IMPORTADORES/automatizaciones/index"
|
||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/automatizaciones/index') ? 'active' : '' ?>">
|
||
⚙️ Automatizaciones
|
||
</a>
|
||
<?php elseif ($esConfiguracion || $esVistaSeguridad || $esVistaPreferencias || $esVistaBitacoras): ?>
|
||
<a href="/IMPORTADORES/automatizaciones/index"
|
||
class="nav-link px-3 py-2 <?= str_contains($_SERVER['REQUEST_URI'], '/automatizaciones/index') ? 'active' : '' ?>">
|
||
⚙️ Automatizaciones
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<!-- PREFERENCIAS -->
|
||
<?php if ($permisosUsuario['preferencias']): ?>
|
||
<?php if ($esVistaPreferencias): ?>
|
||
<?php $enDashboardPreferencias = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/preferencias/index'; ?>
|
||
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaPreferencias ? 'active' : '' ?>"
|
||
href="<?= $enDashboardPreferencias ? '#submenuPreferencias' : '/IMPORTADORES/preferencias/index' ?>"
|
||
<?= $enDashboardPreferencias ? 'data-bd-toggle="collapse"' : '' ?>
|
||
role="button" aria-expanded="true" aria-controls="submenuPreferencias"
|
||
onclick="<? $enDashboardPreferencias ? '' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/preferencias/index\';' ?>">
|
||
✅ Preferencias
|
||
<span class="badge bg-secondary">1</span>
|
||
</a>
|
||
<div class="collapse show" id="submenuPreferencias">
|
||
<nav class="nav flex-column ms-3">
|
||
<a href="/IMPORTADORES/preferencias/notificaciones"
|
||
class="nav-link px-3 py-1 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/preferencias/notificaciones' ? 'active' : '' ?>">
|
||
• Gestión de Notificaciones
|
||
</a>
|
||
</nav>
|
||
</div>
|
||
<?php elseif ($esConfiguracion || $esVistaAutomatizaciones || $esVistaSeguridad || $esVistaBitacoras): ?>
|
||
<a href="/IMPORTADORES/preferencias/index"
|
||
class="nav-link px-3 py-2 d-flex justify-content-between align-items-center">
|
||
✅ Preferencias
|
||
<span class="badge bg-secondary">1</span>
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<!-- SEGURIDAD -->
|
||
<?php if ($permisosUsuario['seguridad']): ?>
|
||
<?php if ($esVistaSeguridad): ?>
|
||
<?php $enDashboardSeguridad = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/seguridad/index'; ?>
|
||
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaSeguridad ? 'active' : '' ?>"
|
||
href="<?= $enDashboardSeguridad ? '#submenuSeguridad' : '/IMPORTADORES/seguridad/index' ?>"
|
||
<?= $enDashboardSeguridad ? 'data-bs-toggle="collapse"' : '' ?>
|
||
role="button" aria-expanded="true" aria-controls="submenuSeguridad"
|
||
onclick="<?= $enDashboardSeguridad ? '' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/seguridad/index\';' ?>">
|
||
👮 Seguridad
|
||
<span class="badge bg-secondary">1</span>
|
||
</a>
|
||
<div class="collapse show" id="submenuSeguridad">
|
||
<nav class="nav flex-column ms-3">
|
||
<a href="/IMPORTADORES/seguridad/opciones"
|
||
class="nav-link px-3 py-1 <?= $_SERVER['REQUEST_URI'] === '/IMPORTADORES/seguridad/opciones' ? 'active' : '' ?>">
|
||
• Opciones de Seguridad
|
||
</a>
|
||
</nav>
|
||
</div>
|
||
<?php elseif ($esConfiguracion || $esVistaAutomatizaciones || $esVistaPreferencias || $esVistaBitacoras): ?>
|
||
<a href="/IMPORTADORES/seguridad/index"
|
||
class="nav-link px-3 py-2 d-flex justify-content-between align-items-center">
|
||
👮 Seguridad
|
||
<span class="badge bg-secondary">1</span>
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<!-- BITÁCORAS CON PERMISOS ESPECÍFICOS -->
|
||
<?php if (tieneAccesoBitacoras($permisosBitacoras)): ?>
|
||
<?php $enDashboardBitacoras = $_SERVER['REQUEST_URI'] === '/IMPORTADORES/bitacoras/index'; ?>
|
||
<a class="nav-link px-3 py-2 d-flex justify-content-between align-items-center <?= $esVistaBitacoras ? 'active' : '' ?>"
|
||
href="<?= $enDashboardBitacoras ? '#submenuBitacoras' : '/IMPORTADORES/bitacoras/index' ?>"
|
||
<?= $enDashboardBitacoras ? 'data-bs-toggle="collapse"' : '' ?>
|
||
role="button" aria-expanded="true" aria-controls="submenuBitacoras"
|
||
onclick="<?= $enDashboardBitacoras ? '' : 'event.preventDefault(); window.location.href = \'/IMPORTADORES/bitacoras/index\';' ?>">
|
||
📖 Bitácoras
|
||
<span class="badge bg-secondary"><?= $cantidadBitacoras ?></span>
|
||
</a>
|
||
|
||
<div class="collapse <?= $esVistaBitacoras ? 'show' : '' ?>" id="submenuBitacoras">
|
||
<nav class="nav flex-column ms-3">
|
||
<?php foreach ($permisosBitacoras as $permiso => $tienePermiso): ?>
|
||
<?php if ($tienePermiso): ?>
|
||
<?php
|
||
$url = obtenerUrlPermiso($permiso);
|
||
$texto = obtenerTextoPermiso($permiso, $tipoUsuario);
|
||
$icono = obtenerIconoPermiso($permiso);
|
||
$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>
|
||
<?= $icono ?> <?= htmlspecialchars($texto) ?>
|
||
<?php if ($scope): ?>
|
||
<span class="permission-scope"><?= $scope ?></span>
|
||
<?php endif; ?>
|
||
</span>
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php endforeach; ?>
|
||
</nav>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
</div>
|
||
</div>
|