turnero: auto-redirigir a desk/lugar asignado sin mostrar selector
- authenticateUser incluye turnero_lugar_id en la sesión - login.php redirige con desk_id/lugar_id si el usuario tiene lugar fijo (sin necesitar IP) - recepcion.php redirige con desk_id si la sesión tiene turnero_lugar_id, evitando el modal de selección Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
f4da864db7
commit
003d16b6a2
@@ -544,6 +544,7 @@ function authenticateUser($username, $password) {
|
||||
'role_id' => $admin['role_id'] ?? null,
|
||||
'home_page' => $homePage,
|
||||
'enfermera_id' => $admin['enfermera_id'] ?? null,
|
||||
'turnero_lugar_id' => $admin['turnero_lugar_id'] ?? null,
|
||||
'modules' => $modules,
|
||||
'module_permissions' => $modulePermissions,
|
||||
];
|
||||
|
||||
@@ -70,6 +70,22 @@ if ($_POST && !$loginBlocked) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// Usuario con lugar fijo asignado (sin IP registrada)
|
||||
$_userLugarId = (int)($adminUser['turnero_lugar_id'] ?? 0);
|
||||
if ($_userLugarId && in_array('turnero', $modules, true)) {
|
||||
// Determinar si ese lugar es recepción o toma de muestras
|
||||
try {
|
||||
$_lugarTipo = Database::getInstance()->getConnection()
|
||||
->prepare("SELECT tipo FROM turnero_lugares WHERE id = ? LIMIT 1");
|
||||
$_lugarTipo->execute([$_userLugarId]);
|
||||
$_tipo = $_lugarTipo->fetchColumn() ?: 'muestras';
|
||||
} catch (\Throwable $_) { $_tipo = 'muestras'; }
|
||||
$url = $_tipo === 'recepcion'
|
||||
? BASE_URL . 'erp.php?m=turnero&v=recepcion&desk_id=' . $_userLugarId
|
||||
: BASE_URL . 'erp.php?m=turnero&v=lugar&lugar_id=' . $_userLugarId;
|
||||
header('Location: ' . $url); exit;
|
||||
}
|
||||
|
||||
if ($roleSlug === 'enfermero') {
|
||||
header('Location: enfermero_portal.php');
|
||||
} elseif (in_array('turnero', $modules, true)) {
|
||||
|
||||
@@ -10,6 +10,7 @@ if (!isUserLoggedIn()) {
|
||||
}
|
||||
|
||||
// Tablet asignada → forzar su escritorio, bloquear cualquier otro
|
||||
$_recepForzado = 0;
|
||||
if (!empty($_SESSION['turnero_dispositivo'])) {
|
||||
$_d = $_SESSION['turnero_dispositivo'];
|
||||
$_forzado = (int)$_d['lugar_id'];
|
||||
@@ -19,6 +20,17 @@ if (!empty($_SESSION['turnero_dispositivo'])) {
|
||||
if ((int)($_GET['desk_id'] ?? 0) !== $_forzado) {
|
||||
header('Location: ' . BASE_URL . 'erp.php?m=turnero&v=recepcion&desk_id=' . $_forzado); exit;
|
||||
}
|
||||
$_recepForzado = $_forzado;
|
||||
}
|
||||
// Restricción a nivel de usuario (turnero_lugar_id en admin_users)
|
||||
if (!$_recepForzado) {
|
||||
$_userDesk = (int)($_SESSION['admin_user']['turnero_lugar_id'] ?? 0);
|
||||
if ($_userDesk) {
|
||||
if ((int)($_GET['desk_id'] ?? 0) !== $_userDesk) {
|
||||
header('Location: ' . BASE_URL . 'erp.php?m=turnero&v=recepcion&desk_id=' . $_userDesk); exit;
|
||||
}
|
||||
$_recepForzado = $_userDesk;
|
||||
}
|
||||
}
|
||||
|
||||
// Cargar catálogos para la ficha
|
||||
|
||||
Reference in New Issue
Block a user