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 = []; } // Sub-links de recepción $_trRecepChildren = []; foreach ($_trDesks as $_d) { $_trRecepChildren[] = [ 'name' => $_d['nombre'], 'icon' => 'fas fa-chair', 'route' => '/erp.php?m=turnero&v=recepcion&desk_id=' . (int)$_d['id'], ]; } if (empty($_trRecepChildren)) { $_trRecepChildren[] = ['name' => 'Recepción', 'icon' => 'fas fa-chair', 'route' => '/erp.php?m=turnero&v=recepcion']; } // Sub-links de muestras $_trMuestrasChildren = []; foreach ($_trMuestras as $_m) { $_trMuestrasChildren[] = [ 'name' => $_m['nombre'], 'icon' => 'fas fa-flask', 'route' => '/erp.php?m=turnero&v=lugar&lugar_id=' . (int)$_m['id'], ]; } $_trLinks = []; // ── Recepcionista ───────────────────────────────────────────── if ($_trIsRecep) { $_trLinks[] = ['name' => 'Pantalla TV', 'icon' => 'fas fa-tv', 'route' => '/erp.php?m=turnero&v=display_global']; if (count($_trRecepChildren) > 1) { $_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => null, 'children' => $_trRecepChildren]; } else { $_trLinks[] = array_merge($_trRecepChildren[0], ['icon' => 'fas fa-concierge-bell']); } // ── Bacteriólogo ────────────────────────────────────────────── } 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']; if (count($_trMuestrasChildren) > 1) { $_trLinks[] = ['name' => 'Estaciones', 'icon' => 'fas fa-flask', 'route' => null, 'children' => $_trMuestrasChildren]; } elseif (!empty($_trMuestrasChildren)) { $_trLinks[] = $_trMuestrasChildren[0]; } // ── Admin / Supervisor / otros ──────────────────────────────── } 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', 'icon' => 'fas fa-tv', 'route' => '/erp.php?m=turnero&v=display_global']; if (count($_trRecepChildren) > 1) { $_trLinks[] = ['name' => 'Recepción', 'icon' => 'fas fa-concierge-bell', 'route' => null, 'children' => $_trRecepChildren]; } elseif (!empty($_trRecepChildren)) { $_trLinks[] = array_merge($_trRecepChildren[0], ['icon' => 'fas fa-concierge-bell']); } if (count($_trMuestrasChildren) > 1) { $_trLinks[] = ['name' => 'Estaciones', 'icon' => 'fas fa-flask', 'route' => null, 'children' => $_trMuestrasChildren]; } elseif (!empty($_trMuestrasChildren)) { $_trLinks[] = $_trMuestrasChildren[0]; } } 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, ];