Update display_global.php

This commit is contained in:
Lizandro Guarnizo
2026-06-11 21:49:26 -05:00
parent e7820c7c2d
commit 22b2c01af5
+256 -553
View File
@@ -1,5 +1,4 @@
<?php
// Leer configuración visual del laboratorio
$_dispCfg = [];
try {
$__pdo = Database::getInstance()->getConnection();
@@ -25,465 +24,308 @@ $_hasVideo = (bool)$_tvVideo;
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
height: 100%; width: 100%;
overflow: hidden;
background: #ffffff;
background: #0f172a;
font-family: 'Segoe UI', system-ui, sans-serif;
color: #0f172a;
color: #fff;
}
:root {
--brand: <?= $_labColor ?>;
--brand-dk: color-mix(in srgb, <?= $_labColor ?> 72%, #000);
--brand-lt: color-mix(in srgb, <?= $_labColor ?> 10%, #fff);
--brand: <?= $_labColor ?>;
--brand-glow: color-mix(in srgb, <?= $_labColor ?> 70%, transparent);
}
/* ─── Wrapper principal ─────────────────────────────────── */
.pg-wrap {
display: grid;
grid-template-rows: auto 1fr auto auto;
grid-template-rows: auto 1fr auto;
height: 100vh;
overflow: hidden;
}
/* ── Header ────────────────────────────────────────────── */
/* ── Header ── */
.pg-header {
display: flex; align-items: center; gap: 1rem;
padding: .65rem 1.8rem;
background: var(--brand);
padding: .5rem 1.5rem;
background: rgba(15,23,42,.95);
border-bottom: 1px solid rgba(255,255,255,.06);
flex-shrink: 0;
box-shadow: 0 3px 14px rgba(0,0,0,.2);
}
.hd-brand { display: flex; align-items: center; gap: .8rem; flex: 1; min-width: 0; }
.hd-brand { display: flex; align-items: center; gap: .7rem; flex: 1; min-width: 0; }
.hd-brand .logo {
height: 46px; max-width: 120px; object-fit: contain;
background: rgba(255,255,255,.16); border-radius: 8px; padding: 4px 7px;
height: 40px; max-width: 100px; object-fit: contain;
background: rgba(255,255,255,.1); border-radius: 6px; padding: 3px 5px;
}
.lab-nombre {
font-size: clamp(1rem, 2.4vw, 1.55rem);
font-weight: 800; color: #fff;
font-size: clamp(.9rem, 1.8vw, 1.2rem);
font-weight: 700; color: #fff;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lab-sub {
font-size: .62rem; color: rgba(255,255,255,.65);
font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px;
display: block; margin-top: 1px;
}
.hd-right { display: flex; align-items: center; gap: .7rem; flex-shrink: 0; }
.hd-right { display: flex; align-items: center; gap: .8rem; flex-shrink: 0; }
.reloj {
font-size: clamp(1.2rem, 3vw, 2rem);
font-weight: 800; color: #fff;
font-variant-numeric: tabular-nums; letter-spacing: 1px;
font-size: clamp(1rem, 2vw, 1.5rem);
font-weight: 700; color: rgba(255,255,255,.7);
font-variant-numeric: tabular-nums; letter-spacing: .5px;
}
.live-dot {
width: 9px; height: 9px; border-radius: 50%;
background: #4ade80; box-shadow: 0 0 9px #4ade80;
animation: pdot 2s ease-in-out infinite; flex-shrink: 0;
}
@keyframes pdot { 0%,100%{opacity:1} 50%{opacity:.35} }
.btn-son {
background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.28);
color: rgba(255,255,255,.9); border-radius: 8px; padding: 5px 12px;
font-size: .7rem; font-weight: 600; cursor: pointer; font-family: inherit;
transition: background .2s;
}
.btn-son.on { background: rgba(74,222,128,.22); border-color: rgba(74,222,128,.45); color: #86efac; }
.btn-fs {
background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
color: rgba(255,255,255,.82); border-radius: 8px; padding: 5px 10px;
font-size: .7rem; cursor: pointer; font-family: inherit;
width: 7px; height: 7px; border-radius: 50%;
background: #4ade80; box-shadow: 0 0 8px #4ade80;
animation: pdot 2s ease-in-out infinite;
}
@keyframes pdot { 0%,100%{opacity:1} 50%{opacity:.3} }
/* ─── Body layout ───────────────────────────────────────── */
/* ── Main body ── */
.pg-body {
display: grid;
grid-template-columns: 1fr;
overflow: hidden;
position: relative;
}
.pg-body.has-video { grid-template-columns: 1fr 38%; }
.pg-body.no-video { grid-template-columns: 1fr 1fr; }
/* ─── Turnos area (stacked when video) ──────────────────── */
.turnos-area {
display: grid;
overflow: hidden;
border-right: 3px solid #e8ecf0;
.pg-body.has-video {
grid-template-columns: 1fr;
}
.pg-body.has-video .turnos-area { grid-template-rows: 1fr 1fr; }
.pg-body.no-video .turnos-area { grid-template-rows: 1fr; }
/* ─── Section panel ─────────────────────────────────────── */
.section-panel {
/* ── Turno activo (centro) ── */
.turno-activo {
display: flex; flex-direction: column;
overflow: hidden;
background: #f8fafc;
}
.turnos-area .section-panel + .section-panel {
border-top: 3px solid #e8ecf0;
}
/* no-video: muestras column sits right of turnos-area */
.mue-panel {
display: flex; flex-direction: column;
overflow: hidden;
background: #f8fafc;
border-left: 3px solid #e8ecf0;
}
/* Section header */
.sec-hdr {
display: flex; align-items: center; gap: .5rem;
padding: .5rem 1.2rem;
font-size: .72rem; font-weight: 800;
text-transform: uppercase; letter-spacing: 2.5px;
color: #fff; flex-shrink: 0;
}
.sec-hdr.rec { background: var(--brand); }
.sec-hdr.mue { background: var(--brand-dk); }
/* ─── Slots container ───────────────────────────────────── */
.slots-row {
flex: 1; display: grid;
grid-auto-flow: column;
grid-auto-columns: 1fr;
gap: 10px; padding: 10px;
overflow: hidden;
}
/* ─── Single slot card ──────────────────────────────────── */
.slot {
background: #fff;
border-radius: 16px;
border: 2.5px solid #e2e8f0;
display: flex; flex-direction: column;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,.06);
transition: border-color .45s, box-shadow .45s;
}
.slot.lit {
border-color: var(--pc, var(--brand));
box-shadow: 0 6px 28px color-mix(in srgb, var(--pc, var(--brand)) 24%, transparent),
0 2px 8px rgba(0,0,0,.06);
}
/* Slot header bar */
.slot-hdr {
display: flex; align-items: center; gap: .45rem;
padding: .35rem .9rem;
font-size: .62rem; font-weight: 800;
text-transform: uppercase; letter-spacing: 2px;
background: var(--brand-lt); color: var(--brand);
border-bottom: 2px solid color-mix(in srgb, var(--brand) 18%, transparent);
flex-shrink: 0;
transition: background .45s, color .45s, border-color .45s;
}
.slot.lit .slot-hdr {
background: color-mix(in srgb, var(--pc, var(--brand)) 12%, #fff);
color: var(--pc, var(--brand));
border-color: color-mix(in srgb, var(--pc, var(--brand)) 30%, transparent);
}
/* Slot body */
.slot-body {
flex: 1; display: flex; flex-direction: column;
align-items: center; justify-content: center;
padding: .6rem .4rem;
position: relative; overflow: hidden;
}
/* Ring pop on new turno */
.ring-pop-el {
position: absolute; top: 50%; left: 50%;
width: 10px; height: 10px; border-radius: 50%;
transform: translate(-50%,-50%);
pointer-events: none; z-index: 0;
}
.ring-pop-el.do-pop { animation: r-pop .85s ease-out forwards; }
@keyframes r-pop {
0% { transform:translate(-50%,-50%) scale(1); background:var(--pc,var(--brand)); opacity:.2; }
100% { transform:translate(-50%,-50%) scale(50); background:var(--pc,var(--brand)); opacity:0; }
}
/* Labels */
.lbl-dest {
font-size: clamp(.5rem, .88vw, .68rem);
font-weight: 700; text-transform: uppercase; letter-spacing: 3px;
color: #94a3b8; margin-bottom: .05rem;
z-index: 1; position: relative;
transition: color .4s;
}
.slot-body.lit .lbl-dest { color: var(--pc, var(--brand)); opacity: .75; }
/* BIG turno code */
.big-code {
font-size: clamp(3rem, 9vw, 10rem);
font-weight: 900; line-height: 1; letter-spacing: -2px;
color: #dde3eb;
font-variant-numeric: tabular-nums;
z-index: 1; position: relative;
transition: color .4s;
}
.slot-body.lit .big-code { color: var(--pc, var(--brand)); }
/* Patient name */
.pac-name {
font-size: clamp(.7rem, 1.4vw, 1.15rem);
font-weight: 700; color: #334155;
margin-top: .25rem; text-align: center; min-height: 1.2em;
z-index: 1; position: relative;
}
/* Priority badge */
.prio-badge {
display: inline-flex; align-items: center; gap: .3rem;
padding: .22rem .7rem; border-radius: 99px;
font-size: clamp(.52rem, .75vw, .68rem); font-weight: 700;
margin-top: .25rem; border: 1.5px solid #e2e8f0;
color: #94a3b8; background: #f8fafc;
transition: all .4s;
z-index: 1; position: relative;
}
.slot-body.lit .prio-badge {
color: var(--pc, var(--brand));
border-color: color-mix(in srgb, var(--pc, var(--brand)) 40%, transparent);
background: color-mix(in srgb, var(--pc, var(--brand)) 8%, #fff);
}
/* ─── Video panel ───────────────────────────────────────── */
.video-panel {
display: flex; align-items: center; justify-content: center;
text-align: center;
padding: 1rem;
position: relative;
overflow: hidden;
background: #f1f5f9;
border-left: 3px solid #e8ecf0;
}
.video-panel video {
.turno-activo .label {
font-size: clamp(.7rem, 1.2vw, .9rem);
font-weight: 700; text-transform: uppercase; letter-spacing: 4px;
color: rgba(255,255,255,.35);
margin-bottom: .2rem;
}
.turno-activo .codigo {
font-size: clamp(5rem, 22vw, 16rem);
font-weight: 900; line-height: 1;
letter-spacing: -4px;
color: var(--brand);
text-shadow: 0 0 60px var(--brand-glow), 0 0 120px var(--brand-glow);
transition: color .3s;
font-variant-numeric: tabular-nums;
}
.turno-activo .lugar-label {
font-size: clamp(1rem, 2.5vw, 1.8rem);
font-weight: 600;
color: rgba(255,255,255,.55);
margin-top: .3rem;
}
.turno-activo .lugar-nombre {
font-size: clamp(1.4rem, 3.5vw, 2.6rem);
font-weight: 800;
color: #fff;
margin-top: .1rem;
}
.turno-activo .pac-nombre {
font-size: clamp(.8rem, 1.6vw, 1.1rem);
color: rgba(255,255,255,.4);
margin-top: .3rem;
}
.turno-activo .sin-turno {
font-size: clamp(1.2rem, 2.5vw, 1.8rem);
color: rgba(255,255,255,.15);
}
/* ── Video reel (esquina inferior derecha) ── */
.reel-wrap {
position: fixed;
bottom: 80px;
right: 24px;
width: 160px;
height: 284px;
border-radius: 16px;
overflow: hidden;
box-shadow: 0 8px 32px rgba(0,0,0,.5);
border: 2px solid rgba(255,255,255,.1);
z-index: 100;
background: #000;
display: none;
}
.reel-wrap.has-video { display: block; }
.reel-wrap video {
width: 100%; height: 100%;
object-fit: contain; /* video completo, sin recortar */
object-fit: cover;
display: block;
}
/* ─── Cola en espera ────────────────────────────────────── */
/* ── Waiting queue ── */
.pg-cola {
background: #fff;
border-top: 2.5px solid #e8ecf0;
padding: .45rem 1rem;
display: flex; align-items: center; gap: .55rem;
overflow-x: auto; flex-shrink: 0;
background: rgba(15,23,42,.9);
border-top: 1px solid rgba(255,255,255,.06);
padding: .35rem 1rem;
display: flex;
align-items: center;
gap: .5rem;
overflow-x: auto;
flex-shrink: 0;
scrollbar-width: none;
min-height: 38px;
min-height: 44px;
}
.pg-cola::-webkit-scrollbar { display: none; }
.cola-lbl {
font-size: .64rem; font-weight: 800;
text-transform: uppercase; letter-spacing: 2px;
color: var(--brand); white-space: nowrap; flex-shrink: 0;
font-size: .6rem; font-weight: 700;
text-transform: uppercase; letter-spacing: 1.5px;
color: rgba(255,255,255,.3); white-space: nowrap; flex-shrink: 0;
}
.cola-sep { width: 1px; height: 14px; background: #e2e8f0; flex-shrink: 0; }
.cola-sep { width: 1px; height: 18px; background: rgba(255,255,255,.08); flex-shrink: 0; }
.cola-chip {
display: inline-flex; align-items: center; gap: .3rem;
padding: .22rem .7rem; border-radius: 99px;
font-size: .78rem; font-weight: 700;
background: #fff; border: 1.5px solid;
display: inline-flex; align-items: center; gap: .25rem;
padding: .2rem .6rem; border-radius: 99px;
font-size: .72rem; font-weight: 700;
border: 1px solid rgba(255,255,255,.1);
background: rgba(255,255,255,.04);
color: rgba(255,255,255,.6);
white-space: nowrap; flex-shrink: 0;
}
.cola-chip .cdot { width: 6px; height: 6px; border-radius: 50%; }
.cola-empty { font-size: .72rem; color: #94a3b8; }
.cola-chip .cdot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.cola-empty { font-size: .65rem; color: rgba(255,255,255,.2); }
/* ─── Footer stats ──────────────────────────────────────── */
.pg-footer {
display: flex; justify-content: center; align-items: center;
gap: 2.5rem; flex-wrap: wrap;
padding: .5rem 2rem;
background: var(--brand);
flex-shrink: 0;
}
.stat-item { text-align: center; }
.stat-item .val {
font-size: clamp(.95rem, 2vw, 1.35rem);
font-weight: 800; color: #fff;
font-variant-numeric: tabular-nums;
}
.stat-item .lbl {
font-size: .58rem; color: rgba(255,255,255,.65);
text-transform: uppercase; letter-spacing: 1.5px;
}
.stat-sep { width: 1px; height: 24px; background: rgba(255,255,255,.22); }
/* ─── Announcement overlay ──────────────────────────────── */
/* ── Announcement overlay ── */
#ann-overlay {
position: fixed; inset: 0; z-index: 9999;
display: flex; align-items: center; justify-content: center;
opacity: 0; pointer-events: none; transition: opacity .3s ease;
opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
#ann-overlay.visible { opacity: 1; pointer-events: all; }
.ann-bg {
position: absolute; inset: 0;
background: rgba(4,8,20,.93);
backdrop-filter: blur(18px);
transition: background .4s;
background: rgba(4,8,20,.94);
backdrop-filter: blur(20px);
}
.ann-card {
position: relative; z-index: 1;
width: min(600px, 88vw);
background: rgba(255,255,255,.055);
border: 1px solid rgba(255,255,255,.12);
border-radius: 28px; padding: 2.8rem 3.5rem 2.4rem; text-align: center;
box-shadow: 0 30px 90px rgba(0,0,0,.7), 0 0 70px var(--ac, #1565c0)44;
transform: scale(.88) translateY(14px);
transition: transform .4s cubic-bezier(.34,1.5,.64,1);
text-align: center;
transform: scale(.85) translateY(20px);
transition: transform .45s cubic-bezier(.34,1.5,.64,1);
}
#ann-overlay.visible .ann-card { transform: scale(1) translateY(0); }
.ann-card::before {
content: ''; position: absolute; left: 0; top: 12%; bottom: 12%;
width: 4px; border-radius: 0 4px 4px 0;
background: var(--ac, var(--brand));
box-shadow: 0 0 28px var(--ac, var(--brand));
}
.ann-ring {
position: absolute; top: 50%; left: 50%;
width: 10px; height: 10px; border-radius: 50%;
transform: translate(-50%,-50%); pointer-events: none;
}
.ann-ring.pop { animation: ann-pop 1.1s ease-out forwards; }
@keyframes ann-pop {
0% { transform:translate(-50%,-50%) scale(1); background:var(--ac,var(--brand)); opacity:.4; }
100% { transform:translate(-50%,-50%) scale(55); background:var(--ac,var(--brand)); opacity:0; }
}
.ann-label {
font-size: clamp(.7rem, 1.5vw, .92rem); font-weight: 700;
text-transform: uppercase; letter-spacing: 3.5px;
color: rgba(255,255,255,.44); margin-bottom: .5rem;
font-size: clamp(.8rem, 1.5vw, 1rem); font-weight: 700;
text-transform: uppercase; letter-spacing: 4px;
color: rgba(255,255,255,.3); margin-bottom: .2rem;
}
.ann-code {
font-size: clamp(5rem, 17vw, 11rem); font-weight: 900;
line-height: 1; letter-spacing: -4px;
font-size: clamp(7rem, 22vw, 16rem); font-weight: 900;
line-height: 1; letter-spacing: -6px;
font-variant-numeric: tabular-nums;
color: var(--ac, var(--brand));
text-shadow: 0 0 90px var(--ac, var(--brand))55;
position: relative; z-index: 1;
text-shadow: 0 0 80px var(--ac, var(--brand))66;
}
.ann-destino {
font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 700;
color: #fff; margin-top: .2rem;
}
.ann-pac {
font-size: clamp(.88rem, 2.2vw, 1.3rem); font-weight: 700;
color: rgba(255,255,255,.72); margin-top: .55rem; min-height: 1.5em;
}
.ann-chip {
display: inline-flex; align-items: center; gap: .35rem;
padding: .34rem 1.1rem; border-radius: 99px;
font-size: clamp(.62rem, 1.05vw, .82rem); font-weight: 700;
margin-top: .7rem; border: 1px solid;
font-size: clamp(.8rem, 1.5vw, 1.1rem);
color: rgba(255,255,255,.45); margin-top: .3rem;
}
.ann-progress {
width: 100%; height: 3px;
background: rgba(255,255,255,.07);
border-radius: 99px; margin-top: 1.7rem; overflow: hidden;
width: 200px; height: 3px;
background: rgba(255,255,255,.06);
border-radius: 99px; margin: 1.5rem auto 0; overflow: hidden;
}
.ann-bar {
height: 100%; width: 100%; border-radius: 99px;
background: var(--ac, var(--brand));
box-shadow: 0 0 12px var(--ac, var(--brand));
box-shadow: 0 0 10px var(--ac, var(--brand));
}
/* ── Mini stat en footer ── */
.pg-footer {
position: fixed;
bottom: 0; left: 0; right: 0;
display: flex; justify-content: center; align-items: center;
gap: 1.5rem;
padding: .25rem 1rem;
background: rgba(15,23,42,.85);
flex-shrink: 0;
z-index: 50;
}
.stat-item { text-align: center; }
.stat-item .val {
font-size: clamp(.7rem, 1.2vw, .85rem);
font-weight: 700; color: rgba(255,255,255,.7);
font-variant-numeric: tabular-nums;
}
.stat-item .lbl {
font-size: .5rem; color: rgba(255,255,255,.25);
text-transform: uppercase; letter-spacing: 1px;
}
.stat-sep { width: 1px; height: 18px; background: rgba(255,255,255,.08); }
@media (min-width: 1200px) {
.reel-wrap { width: 200px; height: 356px; }
}
</style>
</head>
<body>
<!-- ══ Announcement overlay ═══════════════════════════════════════ -->
<div id="ann-overlay">
<div class="ann-bg" id="ann-bg"></div>
<div class="ann-bg"></div>
<div class="ann-card">
<div class="ann-ring" id="ann-ring"></div>
<div class="ann-label" id="ann-label">Pase a Recepción</div>
<div class="ann-code" id="ann-code">A01</div>
<div class="ann-pac" id="ann-pac"></div>
<div class="ann-chip" id="ann-chip"></div>
<div class="ann-label">Pase a</div>
<div class="ann-code" id="ann-code">A01</div>
<div class="ann-destino" id="ann-destino">Recepción 1</div>
<div class="ann-pac" id="ann-pac"></div>
<div class="ann-progress"><div class="ann-bar" id="ann-bar"></div></div>
</div>
</div>
<!-- ══ Main layout ════════════════════════════════════════════════ -->
<div class="pg-wrap">
<header class="pg-header">
<div class="hd-brand">
<?php if ($_labLogo): ?>
<img class="logo" src="<?= htmlspecialchars($_labLogo) ?>" alt="Logo">
<?php endif; ?>
<div>
<div class="lab-nombre"><?= $_labNombre ?></div>
<span class="lab-sub">Sistema de Turnos — Vista General</span>
</div>
<div class="lab-nombre"><?= $_labNombre ?></div>
</div>
<div class="hd-right">
<div class="live-dot" title="En línea"></div>
<button class="btn-son" id="btn-sonido" onclick="event.stopPropagation();activarSonido()">
<i class="fas fa-volume-mute"></i> Sonido
</button>
<button class="btn-fs" onclick="toggleFullscreen()" title="Pantalla completa">
<i class="fas fa-expand" id="fs-icon"></i>
</button>
<div class="live-dot"></div>
<div class="reloj" id="reloj">--:--:--</div>
</div>
</header>
<div class="pg-body <?= $_hasVideo ? 'has-video' : 'no-video' ?>">
<?php if ($_hasVideo): ?>
<!-- Layout con video: recepción+muestras apiladas (izq) | video (der) -->
<div class="turnos-area">
<div class="section-panel">
<div class="sec-hdr rec"><i class="fas fa-door-open"></i> Recepción</div>
<div class="slots-row" id="rec-grid"></div>
</div>
<div class="section-panel">
<div class="sec-hdr mue"><i class="fas fa-vials"></i> Toma de Muestras</div>
<div class="slots-row" id="lugares-grid"></div>
</div>
<div class="pg-body <?= $_hasVideo ? 'has-video' : '' ?>">
<div class="turno-activo" id="zona-activo">
<div class="label">Siguiente turno</div>
<div class="codigo" id="codigo-activo">—</div>
<div class="lugar-label" id="lugar-label">Llamado a</div>
<div class="lugar-nombre" id="lugar-nombre">—</div>
<div class="pac-nombre" id="pac-nombre"></div>
</div>
<div class="video-panel">
<video autoplay muted loop playsinline>
<source src="<?= htmlspecialchars($_tvVideo) ?>">
</video>
</div>
<?php else: ?>
<!-- Layout sin video: recepción (izq) | muestras (der) -->
<div class="turnos-area">
<div class="section-panel">
<div class="sec-hdr rec"><i class="fas fa-door-open"></i> Recepción</div>
<div class="slots-row" id="rec-grid"></div>
</div>
</div>
<div class="mue-panel">
<div class="sec-hdr mue"><i class="fas fa-vials"></i> Toma de Muestras</div>
<div class="slots-row" id="lugares-grid"></div>
</div>
<?php endif; ?>
</div>
<div class="pg-cola" id="pg-cola">
<span class="cola-lbl"><i class="fas fa-list-ol" style="margin-right:.3rem"></i>EN ESPERA</span>
<span class="cola-lbl">EN ESPERA</span>
<div class="cola-sep"></div>
<span class="cola-empty" id="cola-vacia">Cola vacía</span>
</div>
<footer class="pg-footer">
<div class="stat-item"><div class="val" id="st-espera">—</div><div class="lbl">En espera</div></div>
<div class="stat-sep"></div>
<div class="stat-item"><div class="val" id="st-atencion">—</div><div class="lbl">En atención</div></div>
<div class="stat-sep"></div>
<div class="stat-item"><div class="val" id="st-finalizados">—</div><div class="lbl">Atendidos</div></div>
<div class="stat-sep"></div>
<div class="stat-item"><div class="val" id="st-total">—</div><div class="lbl">Total día</div></div>
<div class="stat-sep"></div>
<div class="stat-item"><div class="val" id="st-tiempo">—</div><div class="lbl">T. promedio</div></div>
</footer>
</div>
<div class="reel-wrap <?= $_hasVideo ? 'has-video' : '' ?>" id="reel-wrap">
<video autoplay muted loop playsinline>
<source src="<?= htmlspecialchars($_tvVideo) ?>">
</video>
</div>
<footer class="pg-footer">
<div class="stat-item"><div class="val" id="st-espera">—</div><div class="lbl">Espera</div></div>
<div class="stat-sep"></div>
<div class="stat-item"><div class="val" id="st-atencion">—</div><div class="lbl">Atención</div></div>
<div class="stat-sep"></div>
<div class="stat-item"><div class="val" id="st-finalizados">—</div><div class="lbl">Atendidos</div></div>
<div class="stat-sep"></div>
<div class="stat-item"><div class="val" id="st-total">—</div><div class="lbl">Total día</div></div>
</footer>
<script>
const BASE_API = '<?= BASE_URL ?>modules/turnero/api/';
/* ── Reloj ──────────────────────────────────────────────────────── */
function tick() {
const d = new Date();
document.getElementById('reloj').textContent =
@@ -493,71 +335,7 @@ function tick() {
}
tick(); setInterval(tick, 1000);
/* ── Pantalla completa ──────────────────────────────────────────── */
function toggleFullscreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().catch(() => {});
} else {
document.exitFullscreen().catch(() => {});
}
}
document.addEventListener('fullscreenchange', () => {
const ico = document.getElementById('fs-icon');
if (ico) ico.className = document.fullscreenElement ? 'fas fa-compress' : 'fas fa-expand';
});
/* ── Audio ──────────────────────────────────────────────────────── */
let audioCtx = null, sonidoActivo = false;
function activarSonido() {
try {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const g = audioCtx.createGain(); g.gain.setValueAtTime(0.001, audioCtx.currentTime);
const o = audioCtx.createOscillator(); o.connect(g); g.connect(audioCtx.destination);
o.start(); o.stop(audioCtx.currentTime + 0.05);
} catch (_) {}
sonidoActivo = true;
const btn = document.getElementById('btn-sonido');
if (btn) {
btn.innerHTML = '<i class="fas fa-volume-up"></i> Sonido ON';
btn.classList.add('on');
setTimeout(playBeep, 100);
}
}
document.addEventListener('click', () => { if (!sonidoActivo) activarSonido(); }, { once: true });
document.addEventListener('touchstart', () => { if (!sonidoActivo) activarSonido(); }, { once: true });
function playBeep() {
if (!sonidoActivo || !audioCtx) return;
try {
const osc = audioCtx.createOscillator();
const g = audioCtx.createGain();
osc.type = 'sine';
osc.connect(g); g.connect(audioCtx.destination);
osc.frequency.setValueAtTime(880, audioCtx.currentTime);
osc.frequency.setValueAtTime(1100, audioCtx.currentTime + 0.1);
osc.frequency.setValueAtTime(880, audioCtx.currentTime + 0.2);
g.gain.setValueAtTime(0.35, audioCtx.currentTime);
g.gain.exponentialRampToValueAtTime(0.0001, audioCtx.currentTime + 0.65);
osc.start(audioCtx.currentTime);
osc.stop(audioCtx.currentTime + 0.65);
} catch (_) {}
}
function anunciarTurno(codigo, destino) {
playBeep();
if ('speechSynthesis' in window) {
setTimeout(() => {
window.speechSynthesis.cancel();
const letras = codigo.split('').join(' ');
const utt = new SpeechSynthesisUtterance(`Turno ${letras}, pase a ${destino}`);
utt.lang = 'es-CO'; utt.rate = 0.85; utt.pitch = 1.05; utt.volume = 1;
window.speechSynthesis.speak(utt);
}, 700);
}
}
/* ── Announcement queue ─────────────────────────────────────────── */
/* ── Announcement ── */
const annQueue = [];
let isAnnouncing = false;
@@ -571,162 +349,85 @@ function processQueue() {
isAnnouncing = true;
showAnnouncement(annQueue.shift());
}
function showAnnouncement({ codigo, destino, paciente, prio_codigo, prio_nombre, color }) {
const ov = document.getElementById('ann-overlay');
const bg = document.getElementById('ann-bg');
const ring = document.getElementById('ann-ring');
const code = document.getElementById('ann-code');
const lbl = document.getElementById('ann-label');
const pac = document.getElementById('ann-pac');
const chip = document.getElementById('ann-chip');
const bar = document.getElementById('ann-bar');
const c = color || '#1565c0';
code.textContent = codigo;
lbl.textContent = 'Pase a ' + destino;
pac.textContent = paciente || '';
chip.innerHTML = '<i class="fas fa-ticket-alt"></i> ' + esc(prio_codigo||'') + ' — ' + esc(prio_nombre||'');
function showAnnouncement({ codigo, destino, paciente, color }) {
const ov = document.getElementById('ann-overlay');
const cd = document.getElementById('ann-code');
const dst = document.getElementById('ann-destino');
const pac = document.getElementById('ann-pac');
const bar = document.getElementById('ann-bar');
const c = color || '<?= $_labColor ?>';
cd.textContent = codigo;
dst.textContent = destino;
pac.textContent = paciente || '';
ov.style.setProperty('--ac', c);
bg.style.background = 'radial-gradient(ellipse at 50% 45%, ' + c + '2a 0%, rgba(4,8,20,.94) 65%)';
chip.style.color = c;
chip.style.borderColor = c + '55';
chip.style.background = c + '18';
ov.classList.add('visible');
ring.classList.remove('pop');
void ring.offsetWidth;
ring.classList.add('pop');
bar.style.transition = 'none';
bar.style.width = '100%';
requestAnimationFrame(() => requestAnimationFrame(() => {
bar.style.transition = 'width 1.65s linear';
bar.style.transition = 'width 2s linear';
bar.style.width = '0%';
}));
anunciarTurno(codigo, destino);
setTimeout(() => {
ov.classList.remove('visible');
setTimeout(processQueue, 370);
}, 1950);
}, 2300);
}
/* ── State ──────────────────────────────────────────────────────── */
const lastRec = {};
const lastLugar = {};
/* ── State ── */
let lastTurnoKey = null;
/* ── Helpers ────────────────────────────────────────────────────── */
function esc(s) {
const d = document.createElement('div');
d.appendChild(document.createTextNode(String(s ?? '')));
return d.innerHTML;
}
function buildSlot(id, nombre, turno, tipo) {
const has = !!turno;
const c = has ? (turno.prioridad_color || '#1565c0') : null;
const slotCl = has ? 'slot lit' : 'slot';
const slotSt = c ? ' style="--pc:' + c + '"' : '';
const bodyCl = has ? 'slot-body lit' : 'slot-body';
const bodySt = c ? '--pc:' + c + ';' : '';
const hCls = tipo === 'rec' ? 'slot-hdr rec' : 'slot-hdr mue';
const icon = tipo === 'rec' ? 'fas fa-concierge-bell' : 'fas fa-flask';
const cod = has ? esc(turno.codigo) : '—';
const pac = has ? esc(turno.paciente_nombre || '') : '';
const chip = has
? "<i class='fas fa-ticket-alt'></i> " + esc(turno.prioridad_codigo) + ' — ' + esc(turno.prioridad_nombre)
: "<i class='fas fa-hourglass-half'></i> En espera";
const chipSt = has && c ? 'style="color:' + c + ';border-color:' + c + '44;background:' + c + '15"' : '';
return '<div class="' + slotCl + '" id="slot-' + tipo + '-' + id + '"' + slotSt + '>'
+ '<div class="' + hCls + '"><i class="' + icon + '"></i> ' + esc(nombre) + '</div>'
+ '<div class="' + bodyCl + '" id="body-' + tipo + '-' + id + '" style="' + bodySt + '">'
+ '<div class="ring-pop-el" id="ring-' + tipo + '-' + id + '"></div>'
+ '<div class="lbl-dest">' + esc(nombre) + '</div>'
+ '<div class="big-code" id="cod-' + tipo + '-' + id + '">' + cod + '</div>'
+ '<div class="pac-name" id="pac-' + tipo + '-' + id + '">' + pac + '</div>'
+ '<div class="prio-badge" id="chip-' + tipo + '-' + id + '" ' + chipSt + '>' + chip + '</div>'
+ '</div></div>';
}
function updateSlot(id, turno, tipo) {
const slotEl = document.getElementById('slot-' + tipo + '-' + id);
const body = document.getElementById('body-' + tipo + '-' + id);
const cod = document.getElementById('cod-' + tipo + '-' + id);
const pac = document.getElementById('pac-' + tipo + '-' + id);
const chip = document.getElementById('chip-' + tipo + '-' + id);
if (!body) return false;
const c = turno ? (turno.prioridad_color || '#1565c0') : null;
if (turno) {
body.className = 'slot-body lit';
body.style.setProperty('--pc', c);
if (slotEl) { slotEl.className = 'slot lit'; slotEl.style.setProperty('--pc', c); }
cod.textContent = turno.codigo;
pac.textContent = turno.paciente_nombre || '';
chip.innerHTML = "<i class='fas fa-ticket-alt'></i> " + esc(turno.prioridad_codigo) + ' — ' + esc(turno.prioridad_nombre);
chip.style.color = c; chip.style.borderColor = c + '44'; chip.style.background = c + '15';
} else {
body.className = 'slot-body';
body.style.removeProperty('--pc');
if (slotEl) { slotEl.className = 'slot'; slotEl.style.removeProperty('--pc'); }
cod.textContent = '—';
pac.textContent = '';
chip.innerHTML = "<i class='fas fa-hourglass-half'></i> En espera";
chip.style.color = chip.style.borderColor = chip.style.background = '';
}
return true;
}
/* ── Render snapshot ────────────────────────────────────────────── */
function renderSnapshot(snap) {
const recList = snap.activos_recepcion || [];
const mueList = snap.lugares || [];
const recGrid = document.getElementById('rec-grid');
const mueGrid = document.getElementById('lugares-grid');
const codEl = document.getElementById('codigo-activo');
const lugEl = document.getElementById('lugar-nombre');
const pacEl = document.getElementById('pac-nombre');
const lblEl = document.getElementById('lugar-label');
// Recepción
const curRecIds = [...recGrid.querySelectorAll('.slot')].map(el => +el.id.replace('slot-rec-',''));
const newRecIds = recList.map(d => d.desk_id);
if (curRecIds.length !== newRecIds.length || newRecIds.some(id => !curRecIds.includes(id))) {
recGrid.innerHTML = recList.map(d => buildSlot(d.desk_id, d.desk_nombre, d.turno, 'rec')).join('');
} else {
recList.forEach(d => updateSlot(d.desk_id, d.turno, 'rec'));
}
recList.forEach(d => {
const t = d.turno;
if (!t) { lastRec[d.desk_id] = null; return; }
const clave = t.codigo + '|' + (t.llamado_at || '');
if (clave !== lastRec[d.desk_id]) {
queueAnnouncement({ _key: 'rec-' + d.desk_id + '-' + clave, codigo: t.codigo, destino: d.desk_nombre, paciente: t.paciente_nombre, prio_codigo: t.prioridad_codigo, prio_nombre: t.prioridad_nombre, color: t.prioridad_color });
const ring = document.getElementById('ring-rec-' + d.desk_id);
if (ring) { ring.classList.remove('do-pop'); void ring.offsetWidth; ring.classList.add('do-pop'); }
lastRec[d.desk_id] = clave;
}
const turnos = [];
(snap.activos_recepcion || []).forEach(d => {
if (d.turno) turnos.push({ ...d.turno, destino: d.desk_nombre, tipo: 'rec' });
});
(snap.lugares || []).forEach(l => {
if (l.turno) turnos.push({ ...l.turno, destino: l.lugar_nombre, tipo: 'mue' });
});
// Muestras
const curMueIds = [...mueGrid.querySelectorAll('.slot')].map(el => +el.id.replace('slot-mue-',''));
const newMueIds = mueList.map(l => l.lugar_id);
if (curMueIds.length !== newMueIds.length || newMueIds.some(id => !curMueIds.includes(id))) {
mueGrid.innerHTML = mueList.map(l => buildSlot(l.lugar_id, l.lugar_nombre, l.turno, 'mue')).join('');
} else {
mueList.forEach(l => updateSlot(l.lugar_id, l.turno, 'mue'));
}
mueList.forEach(l => {
const t = l.turno;
if (!t) { lastLugar[l.lugar_id] = null; return; }
const clave = t.codigo + '|' + (t.llamado_at || '');
if (clave !== lastLugar[l.lugar_id]) {
queueAnnouncement({ _key: 'mue-' + l.lugar_id + '-' + clave, codigo: t.codigo, destino: l.lugar_nombre, paciente: t.paciente_nombre, prio_codigo: t.prioridad_codigo, prio_nombre: t.prioridad_nombre, color: t.prioridad_color });
const ring = document.getElementById('ring-mue-' + l.lugar_id);
if (ring) { ring.classList.remove('do-pop'); void ring.offsetWidth; ring.classList.add('do-pop'); }
lastLugar[l.lugar_id] = clave;
}
});
if (turnos.length > 0) {
const t = turnos[0];
codEl.textContent = t.codigo;
lugEl.textContent = t.destino;
pacEl.textContent = t.paciente_nombre || '';
lblEl.textContent = 'Llamado a';
// Cola
const cola = snap.cola || [];
const c = t.prioridad_color || '<?= $_labColor ?>';
codEl.style.color = c;
document.getElementById('zona-activo').style.setProperty('--brand', c);
const key = t.codigo + '|' + t.destino + '|' + (t.llamado_at || '');
if (key !== lastTurnoKey) {
queueAnnouncement({
_key: key,
codigo: t.codigo,
destino: t.destino,
paciente: t.paciente_nombre,
color: c
});
lastTurnoKey = key;
}
} else {
codEl.textContent = '—';
lugEl.textContent = '—';
pacEl.textContent = '';
lblEl.textContent = 'Llamado a';
codEl.style.color = '<?= $_labColor ?>';
lastTurnoKey = null;
}
// Queue
const cola = snap.cola || [];
const pgCola = document.getElementById('pg-cola');
pgCola.querySelectorAll('.cola-chip').forEach(c => c.remove());
const vaciaMg = document.getElementById('cola-vacia');
@@ -736,10 +437,9 @@ function renderSnapshot(snap) {
vaciaMg.style.display = 'none';
cola.forEach(t => {
const chip = document.createElement('span');
const c = t.prioridad_color || '#1565c0';
const c = t.prioridad_color || '<?= $_labColor ?>';
chip.className = 'cola-chip';
chip.style.color = c; chip.style.borderColor = c + '55'; chip.style.background = c + '12';
chip.innerHTML = '<span class="cdot" style="background:' + c + ';box-shadow:0 0 5px ' + c + '88"></span>' + esc(t.codigo);
chip.innerHTML = '<span class="cdot" style="background:' + c + ';box-shadow:0 0 4px ' + c + '88"></span>' + esc(t.codigo);
pgCola.appendChild(chip);
});
}
@@ -750,11 +450,14 @@ function renderSnapshot(snap) {
document.getElementById('st-atencion').textContent = s.en_atencion || 0;
document.getElementById('st-finalizados').textContent = s.finalizados || 0;
document.getElementById('st-total').textContent = s.total || 0;
document.getElementById('st-tiempo').textContent = s.tiempo_promedio_atencion
? s.tiempo_promedio_atencion.substring(0, 5) : '—';
}
/* ── Polling ─────────────────────────────────────────────────────── */
function esc(s) {
const d = document.createElement('div');
d.appendChild(document.createTextNode(String(s ?? '')));
return d.innerHTML;
}
async function cargarSnapshot() {
try {
const res = await fetch(BASE_API + 'get_display_global.php', { cache: 'no-store' });