diff --git a/modules/turnero/api/get_historial.php b/modules/turnero/api/get_historial.php index 8e08e90..c122447 100644 --- a/modules/turnero/api/get_historial.php +++ b/modules/turnero/api/get_historial.php @@ -183,13 +183,15 @@ if ($turnoIds) { "SELECT tc.turno_id, tc.usuario_nombre, tc.comentario, tc.tipo, tc.creado_at FROM turnero_comentarios tc WHERE tc.turno_id IN ($ph) - ORDER BY tc.turno_id, tc.creado_at DESC" + ORDER BY tc.turno_id, tc.creado_at ASC" ); $stmtCom->execute($turnoIds); foreach ($stmtCom->fetchAll(PDO::FETCH_ASSOC) as $row) { $tid = (int)$row['turno_id']; if (!isset($comentarios[$tid])) $comentarios[$tid] = []; - if (count($comentarios[$tid]) < 3) { + // Se traen todos: cortar en 3 escondía notas —entre ellas el motivo de + // una ausencia— sin que nada indicara que faltaban. + if (count($comentarios[$tid]) < 20) { unset($row['turno_id']); $comentarios[$tid][] = $row; } diff --git a/modules/turnero/views/dashboard.php b/modules/turnero/views/dashboard.php index fe0785e..2e15bb5 100644 --- a/modules/turnero/views/dashboard.php +++ b/modules/turnero/views/dashboard.php @@ -83,6 +83,13 @@ Layout::open('Dashboard Turnero', 'fas fa-chart-bar'); .det-row td { padding:0 !important; border-top:none !important; } .det-inner { padding:12px 16px 14px; border-top:2px solid color-mix(in srgb, var(--brand,#1565c0) 20%, #e2e8f0); background:#f8fafc; } + /* ── Origen de cada nota ── */ + .com-tipo { font-size:.62rem; font-weight:700; letter-spacing:.04em; padding:1px 7px; + border-radius:10px; text-transform:uppercase; margin-right:6px; } + .com-tipo.recepcion { background:#dbeafe; color:#1d4ed8; } + .com-tipo.muestras { background:#dcfce7; color:#15803d; } + .com-tipo.general { background:#fef3c7; color:#92400e; } + /* ── Sesión badge ── */ .sesion-open { background:#dcfce7; color:#15803d; } .sesion-closed { background:#f1f5f9; color:#64748b; } @@ -657,8 +664,9 @@ function renderDashDetalle(t) { // Comentarios if (t.comentarios && t.comentarios.length) { grid += `
-
Comentarios
+
Notas y observaciones (${t.comentarios.length})
${t.comentarios.map(c=>`
+ ${({recepcion:'Recepción',muestras:'Toma de muestras',general:'General'})[c.tipo]||c.tipo} ${e(c.usuario_nombre)} ${fmt(c.creado_at)}
${e(c.comentario)}
diff --git a/modules/turnero/views/historial.php b/modules/turnero/views/historial.php index 9fc0084..a08f601 100644 --- a/modules/turnero/views/historial.php +++ b/modules/turnero/views/historial.php @@ -100,6 +100,13 @@ Layout::open('Historial de Turnos', 'fas fa-history'); .detail-extra .d-lbl { font-size:.67rem; text-transform:uppercase; letter-spacing:.07em; color:#94a3b8; margin-bottom:5px; } .detail-comment { padding:5px 0; border-bottom:1px solid #f1f5f9; font-size:.82rem; } .detail-comment:last-child { border-bottom:none; } + /* ── Origen de cada nota ── */ + .com-tipo { font-size:.62rem; font-weight:700; letter-spacing:.04em; padding:1px 7px; + border-radius:10px; text-transform:uppercase; margin-right:6px; } + .com-tipo.recepcion { background:#dbeafe; color:#1d4ed8; } + .com-tipo.muestras { background:#dcfce7; color:#15803d; } + .com-tipo.general { background:#fef3c7; color:#92400e; } + /* ── Documentos firmados ── */ .docs-section { margin-top:10px; padding-top:10px; border-top:1px solid #e2e8f0; } @@ -567,9 +574,10 @@ function renderDetalle(t) { let comHtml = ''; if (t.comentarios && t.comentarios.length) { comHtml = `
-
Comentarios
+
Notas y observaciones (${t.comentarios.length})
${t.comentarios.map(c => `
+ ${({recepcion:'Recepción',muestras:'Toma de muestras',general:'General'})[c.tipo]||c.tipo} ${esc(c.usuario_nombre)} ${c.creado_at ? new Date(c.creado_at.replace(' ','T')).toLocaleString('es-CO',{dateStyle:'short',timeStyle:'short'}) : ''}
${esc(c.comentario)}
diff --git a/modules/turnero/views/recepcion.php b/modules/turnero/views/recepcion.php index c73ce4a..6e07880 100644 --- a/modules/turnero/views/recepcion.php +++ b/modules/turnero/views/recepcion.php @@ -2307,12 +2307,32 @@ async function pasarALugar() { // ── Ausente ─────────────────────────────────────────────────── async function marcarAusente() { if (!turnoActivo) return; - if (!confirm(`¿Marcar turno ${turnoActivo.codigo} como AUSENTE?`)) return; + + // El motivo se guarda como comentario de recepción: así aparece en la + // bandeja, el historial y el dashboard sin duplicar el dato. + const motivo = prompt( + `Marcar el turno ${turnoActivo.codigo} como AUSENTE.\n\n` + + '¿Por qué? (no respondió al llamado, se retiró, reprogramó…)'); + if (motivo === null) return; // canceló + const motivoLimpio = motivo.trim(); + if (!motivoLimpio) { mostrarError('Indique el motivo para marcar como ausente.'); return; } + + const turnoId = turnoActivo.id; + + await fetch(API + 'comentarios.php', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + turno_id: turnoId, + comentario: 'Marcado ausente: ' + motivoLimpio, + tipo: 'recepcion', + }), + }).catch(() => {}); await fetch(API + 'cambiar_estado.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ turno_id: turnoActivo.id, nuevo_estado: 'ausente' }), + body: JSON.stringify({ turno_id: turnoId, nuevo_estado: 'ausente' }), }); turnoActivo = null;