feat(turnero): filtrar sidebar por rol — recep ve solo sus desks, bacteriologo ve sus estaciones
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ea0de4d487
commit
841acf9a85
+54
-28
@@ -1,27 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Descriptor del módulo Turnero — Oleada 1
|
||||
* Sistema de Turnero Inteligente con gestión de consentimientos informados.
|
||||
* Los links visibles se filtran según el rol del usuario.
|
||||
*/
|
||||
|
||||
// ── Links estáticos base ──────────────────────────────────────
|
||||
$_trLinks = [
|
||||
['name' => 'Dashboard', 'icon' => 'fas fa-tachometer-alt', 'route' => '/erp.php?m=turnero&v=dashboard'],
|
||||
['name' => 'Historial', 'icon' => 'fas fa-history', 'route' => '/erp.php?m=turnero&v=historial'],
|
||||
['name' => 'Configuración', 'icon' => 'fas fa-sliders-h', 'route' => '/erp.php?m=turnero&v=configuracion'],
|
||||
['name' => 'Kiosko', 'icon' => 'fas fa-desktop', 'route' => '/erp.php?m=turnero&v=kiosko'],
|
||||
['name' => 'Pantalla TV Global', 'icon' => 'fas fa-th-large', 'route' => '/erp.php?m=turnero&v=display_global'],
|
||||
];
|
||||
$_trRole = $_SESSION['admin_user']['role'] ?? 'admin';
|
||||
$_trAdminRoles = ['superadmin', 'admin', 'supervisor'];
|
||||
$_trIsAdmin = in_array($_trRole, $_trAdminRoles, true);
|
||||
$_trIsRecep = $_trRole === 'recepcionista';
|
||||
$_trIsBacte = $_trRole === 'bacteriologo';
|
||||
|
||||
// ── Links dinámicos: un enlace por escritorio de Recepción ────
|
||||
try {
|
||||
$_trPdo = Database::getInstance()->getConnection();
|
||||
$_trPdo = Database::getInstance()->getConnection();
|
||||
|
||||
$_trDesks = $_trPdo->query(
|
||||
"SELECT id, nombre FROM turnero_lugares
|
||||
WHERE activo = 1 AND tipo = 'recepcion'
|
||||
ORDER BY sort_order ASC"
|
||||
"SELECT id, nombre FROM turnero_lugares WHERE activo=1 AND tipo='recepcion' ORDER BY sort_order"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$_trMuestras = $_trPdo->query(
|
||||
"SELECT id, nombre FROM turnero_lugares WHERE activo=1 AND tipo='muestras' ORDER BY sort_order"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (\Throwable $_) {
|
||||
$_trDesks = [];
|
||||
$_trMuestras = [];
|
||||
}
|
||||
|
||||
$_trLinks = [];
|
||||
|
||||
// ── Recepcionista: solo sus escritorios + pantalla TV ─────────
|
||||
if ($_trIsRecep) {
|
||||
$_trLinks[] = ['name' => 'Pantalla TV', 'icon' => 'fas fa-tv', 'route' => '/erp.php?m=turnero&v=display_global'];
|
||||
if (!empty($_trDesks)) {
|
||||
foreach ($_trDesks as $_d) {
|
||||
$_trLinks[] = [
|
||||
@@ -31,22 +39,14 @@ try {
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// Sin escritorios configurados: enlace genérico
|
||||
$_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => '/erp.php?m=turnero&v=recepcion'];
|
||||
}
|
||||
} catch (\Throwable $_) {
|
||||
// BD no disponible todavía (instalación inicial)
|
||||
$_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => '/erp.php?m=turnero&v=recepcion'];
|
||||
}
|
||||
|
||||
// ── Links dinámicos: un enlace por estación de Muestras ──────
|
||||
try {
|
||||
$_trMuestras = $_trPdo->query(
|
||||
"SELECT id, nombre FROM turnero_lugares
|
||||
WHERE activo = 1 AND tipo = 'muestras'
|
||||
ORDER BY sort_order ASC"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// ── Bacteriólogo: dashboard, historial, TV + sus estaciones ──
|
||||
} elseif ($_trIsBacte) {
|
||||
$_trLinks[] = ['name' => 'Dashboard', 'icon' => 'fas fa-tachometer-alt', 'route' => '/erp.php?m=turnero&v=dashboard'];
|
||||
$_trLinks[] = ['name' => 'Historial', 'icon' => 'fas fa-history', 'route' => '/erp.php?m=turnero&v=historial'];
|
||||
$_trLinks[] = ['name' => 'Pantalla TV', 'icon' => 'fas fa-tv', 'route' => '/erp.php?m=turnero&v=display_global'];
|
||||
foreach ($_trMuestras as $_m) {
|
||||
$_trLinks[] = [
|
||||
'name' => $_m['nombre'],
|
||||
@@ -54,7 +54,33 @@ try {
|
||||
'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'],
|
||||
];
|
||||
}
|
||||
} catch (\Throwable $_) {}
|
||||
|
||||
// ── Admin / Supervisor / otros: acceso completo ───────────────
|
||||
} else {
|
||||
$_trLinks[] = ['name' => 'Dashboard', 'icon' => 'fas fa-tachometer-alt', 'route' => '/erp.php?m=turnero&v=dashboard'];
|
||||
$_trLinks[] = ['name' => 'Historial', 'icon' => 'fas fa-history', 'route' => '/erp.php?m=turnero&v=historial'];
|
||||
$_trLinks[] = ['name' => 'Configuración', 'icon' => 'fas fa-sliders-h', 'route' => '/erp.php?m=turnero&v=configuracion'];
|
||||
$_trLinks[] = ['name' => 'Kiosko', 'icon' => 'fas fa-desktop', 'route' => '/erp.php?m=turnero&v=kiosko'];
|
||||
$_trLinks[] = ['name' => 'Pantalla TV Global', 'icon' => 'fas fa-th-large', 'route' => '/erp.php?m=turnero&v=display_global'];
|
||||
if (!empty($_trDesks)) {
|
||||
foreach ($_trDesks as $_d) {
|
||||
$_trLinks[] = [
|
||||
'name' => $_d['nombre'],
|
||||
'icon' => 'fas fa-concierge-bell',
|
||||
'route' => '/erp.php?m=turnero&v=recepcion&desk_id=' . (int)$_d['id'],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => '/erp.php?m=turnero&v=recepcion'];
|
||||
}
|
||||
foreach ($_trMuestras as $_m) {
|
||||
$_trLinks[] = [
|
||||
'name' => $_m['nombre'],
|
||||
'icon' => 'fas fa-flask',
|
||||
'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'slug' => 'turnero',
|
||||
|
||||
Reference in New Issue
Block a user