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
|
<?php
|
||||||
/**
|
/**
|
||||||
* Descriptor del módulo Turnero — Oleada 1
|
* 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 ──────────────────────────────────────
|
$_trRole = $_SESSION['admin_user']['role'] ?? 'admin';
|
||||||
$_trLinks = [
|
$_trAdminRoles = ['superadmin', 'admin', 'supervisor'];
|
||||||
['name' => 'Dashboard', 'icon' => 'fas fa-tachometer-alt', 'route' => '/erp.php?m=turnero&v=dashboard'],
|
$_trIsAdmin = in_array($_trRole, $_trAdminRoles, true);
|
||||||
['name' => 'Historial', 'icon' => 'fas fa-history', 'route' => '/erp.php?m=turnero&v=historial'],
|
$_trIsRecep = $_trRole === 'recepcionista';
|
||||||
['name' => 'Configuración', 'icon' => 'fas fa-sliders-h', 'route' => '/erp.php?m=turnero&v=configuracion'],
|
$_trIsBacte = $_trRole === 'bacteriologo';
|
||||||
['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'],
|
|
||||||
];
|
|
||||||
|
|
||||||
// ── Links dinámicos: un enlace por escritorio de Recepción ────
|
|
||||||
try {
|
try {
|
||||||
$_trPdo = Database::getInstance()->getConnection();
|
$_trPdo = Database::getInstance()->getConnection();
|
||||||
|
|
||||||
$_trDesks = $_trPdo->query(
|
$_trDesks = $_trPdo->query(
|
||||||
"SELECT id, nombre FROM turnero_lugares
|
"SELECT id, nombre FROM turnero_lugares WHERE activo=1 AND tipo='recepcion' ORDER BY sort_order"
|
||||||
WHERE activo = 1 AND tipo = 'recepcion'
|
|
||||||
ORDER BY sort_order ASC"
|
|
||||||
)->fetchAll(PDO::FETCH_ASSOC);
|
)->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)) {
|
if (!empty($_trDesks)) {
|
||||||
foreach ($_trDesks as $_d) {
|
foreach ($_trDesks as $_d) {
|
||||||
$_trLinks[] = [
|
$_trLinks[] = [
|
||||||
@@ -31,22 +39,14 @@ try {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Sin escritorios configurados: enlace genérico
|
|
||||||
$_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => '/erp.php?m=turnero&v=recepcion'];
|
$_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) {
|
foreach ($_trMuestras as $_m) {
|
||||||
$_trLinks[] = [
|
$_trLinks[] = [
|
||||||
'name' => $_m['nombre'],
|
'name' => $_m['nombre'],
|
||||||
@@ -54,7 +54,33 @@ try {
|
|||||||
'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'],
|
'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 [
|
return [
|
||||||
'slug' => 'turnero',
|
'slug' => 'turnero',
|
||||||
|
|||||||
Reference in New Issue
Block a user