- Auth: agrega isBacteriologo() - App: guard que bloquea dashboard e historial para bacteriólogo y redirige según IP (turnero_dispositivos); IP registrada → ese lugar, IP libre → primer lugar de muestras - module.php: sidebar bacteriólogo sin Dashboard/Historial; IP registrada muestra solo ese lugar, IP libre muestra TV + todos los lugares muestras Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
123 lines
5.2 KiB
PHP
123 lines
5.2 KiB
PHP
<?php
|
|
/**
|
|
* Descriptor del módulo Turnero — Oleada 1
|
|
* Los links visibles se filtran según el rol del usuario.
|
|
*/
|
|
|
|
$_trRole = $_SESSION['admin_user']['role'] ?? 'admin';
|
|
$_trAdminRoles = ['superadmin', 'admin', 'supervisor'];
|
|
$_trIsAdmin = in_array($_trRole, $_trAdminRoles, true);
|
|
$_trIsRecep = $_trRole === 'recepcionista';
|
|
$_trIsBacte = $_trRole === 'bacteriologo';
|
|
|
|
try {
|
|
$_trPdo = Database::getInstance()->getConnection();
|
|
|
|
$_trDesks = $_trPdo->query(
|
|
"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' => 'Chat Turnero', 'icon' => 'fab fa-whatsapp', 'route' => '/erp.php?m=turnero&v=chat'];
|
|
$_trLinks[] = ['name' => 'Verificar Paciente', 'icon' => 'fas fa-id-card', 'route' => '/erp.php?m=turnero&v=verificar_paciente'];
|
|
$_trLinks[] = ['name' => 'Pantalla TV', 'icon' => 'fas fa-tv', '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'];
|
|
}
|
|
|
|
// ── Bacteriólogo: sin dashboard ni historial; vista según IP ──
|
|
} elseif ($_trIsBacte) {
|
|
$_trIpLugar = null;
|
|
try {
|
|
$_trIpRow = $_trPdo->prepare(
|
|
"SELECT lugar_id FROM turnero_dispositivos WHERE ip = ? AND activo = 1 LIMIT 1"
|
|
);
|
|
$_trIpRow->execute([$_SERVER['REMOTE_ADDR'] ?? '']);
|
|
$_trIpLugar = $_trIpRow->fetchColumn() ?: null;
|
|
} catch (\Throwable $_) {}
|
|
|
|
if ($_trIpLugar) {
|
|
// IP registrada: solo ese lugar en el sidebar
|
|
foreach ($_trMuestras as $_m) {
|
|
if ((int)$_m['id'] === (int)$_trIpLugar) {
|
|
$_trLinks[] = [
|
|
'name' => $_m['nombre'],
|
|
'icon' => 'fas fa-flask',
|
|
'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'],
|
|
];
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
// IP no registrada: TV + todos los lugares muestras
|
|
$_trLinks[] = ['name' => 'Pantalla TV', 'icon' => 'fas fa-tv', 'route' => '/erp.php?m=turnero&v=display_global'];
|
|
foreach ($_trMuestras as $_m) {
|
|
$_trLinks[] = [
|
|
'name' => $_m['nombre'],
|
|
'icon' => 'fas fa-flask',
|
|
'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'],
|
|
];
|
|
}
|
|
}
|
|
|
|
// ── 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' => 'Chat Turnero', 'icon' => 'fab fa-whatsapp', 'route' => '/erp.php?m=turnero&v=chat'];
|
|
$_trLinks[] = ['name' => 'Verificar Paciente', 'icon' => 'fas fa-id-card', 'route' => '/erp.php?m=turnero&v=verificar_paciente'];
|
|
$_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',
|
|
'name' => 'Turnero',
|
|
'icon' => 'fas fa-ticket-alt',
|
|
'category' => 'turnero',
|
|
'route' => '/erp.php?m=turnero&v=dashboard',
|
|
'is_active' => true,
|
|
'sort_order' => 40,
|
|
'oleada' => 1,
|
|
'description' => 'Sistema de turnos presenciales en recepción con prioridades, consentimientos y pantallas TV',
|
|
'links' => $_trLinks,
|
|
];
|