diff --git a/index.php b/index.php index db3dd23..094062f 100644 --- a/index.php +++ b/index.php @@ -13,10 +13,17 @@ if (!isUserLoggedIn()) { exit('Acceso denegado. Iniciar sesión'); } -// Enfermeros no tienen acceso al panel principal +// Redirigir roles que no deben ver el panel WhatsApp if (isEnfermero()) { - header('Location: enfermero_portal.php'); - exit; + header('Location: enfermero_portal.php'); exit; +} +$_indexRole = $_SESSION['admin_user']['role'] ?? ''; +$_indexModules = $_SESSION['admin_user']['modules'] ?? []; +if ($_indexRole === 'recepcionista' || (in_array('turnero', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true))) { + header('Location: erp.php?m=turnero&v=recepcion'); exit; +} +if (in_array('lab_dashboard', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true)) { + header('Location: lab_dashboard.php'); exit; } // Verificar conexión a la base de datos diff --git a/login.php b/login.php index ffdfea8..2f0bd76 100644 --- a/login.php +++ b/login.php @@ -53,12 +53,16 @@ if ($_POST && !$loginBlocked) { } if ($roleSlug === 'enfermero') { header('Location: enfermero_portal.php'); - } elseif (count($modules) === 1 && $modules[0] === 'lab_formularios') { + } elseif (in_array('turnero', $modules, true)) { + header('Location: erp.php?m=turnero&v=recepcion'); + } elseif (in_array('lab_dashboard', $modules, true)) { + header('Location: lab_dashboard.php'); + } elseif (in_array('lab_formularios', $modules, true)) { header('Location: lab_formularios.php'); - } elseif (count($modules) === 2 - && in_array('lab_domicilios', $modules, true) - && in_array('lab_ordenes', $modules, true)) { - header('Location: lab_domicilios.php'); + } elseif (in_array('lab_ordenes', $modules, true)) { + header('Location: lab_ordenes.php'); + } elseif (in_array('whatsapp', $modules, true)) { + header('Location: index.php'); } else { header('Location: index.php'); }