From 573b7e4a8f1fe6621e0eb1c0a9fdd0310392f904 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 23 Jun 2026 19:45:24 -0500 Subject: [PATCH] fix: sidebar marca activo solo el item actual, no todos los de erp.php --- shared/components/sidebar.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/shared/components/sidebar.php b/shared/components/sidebar.php index e6c33e5..dbdb239 100644 --- a/shared/components/sidebar.php +++ b/shared/components/sidebar.php @@ -34,17 +34,23 @@ $_current_script = basename($_SERVER['PHP_SELF']); */ $_isActive = function (string $route) use ($_current_script): string { if ($route === '') return ''; - // Para rutas como /lab_domicilios.php: comparar con basename - $routeBase = basename(parse_url($route, PHP_URL_PATH) ?? ''); - if ($routeBase === $_current_script) { + $parsed = parse_url($route); + $routeBase = basename($parsed['path'] ?? ''); + + // Rutas ERP con query params: comparar script Y cada param de la ruta + if (!empty($parsed['query'])) { + $uriParsed = parse_url($_SERVER['REQUEST_URI'] ?? ''); + if ($routeBase !== basename($uriParsed['path'] ?? '')) return ''; + parse_str($parsed['query'], $routeParams); + parse_str($uriParsed['query'] ?? '', $uriParams); + foreach ($routeParams as $k => $v) { + if (($uriParams[$k] ?? null) !== $v) return ''; + } return ' active'; } - // Para rutas con parámetros ERP (?m=&v=): comparar con REQUEST_URI - $uri = $_SERVER['REQUEST_URI'] ?? ''; - if ($route !== '/' && str_contains($uri, ltrim($route, '/'))) { - return ' active'; - } - return ''; + + // Rutas directas como /lab_domicilios.php + return $routeBase === $_current_script ? ' active' : ''; }; // Título del sidebar: prioridad al nombre definido por el módulo, luego el genérico