up
This commit is contained in:
@@ -314,6 +314,25 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Sección: Comentarios y Notas ── -->
|
||||
<div class="ficha-sec" id="sec-comentarios">
|
||||
<div class="d-flex align-items-center justify-content-between mb-2">
|
||||
<h6 class="mb-0"><i class="fas fa-comments me-1" style="color:#8b5cf6"></i>Comentarios del seguimiento</h6>
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;margin-bottom:10px">
|
||||
<textarea id="inp-comentario" class="form-control form-control-sm"
|
||||
rows="2" placeholder="Añade un comentario sobre este turno…"
|
||||
maxlength="500" style="resize:vertical"></textarea>
|
||||
<button class="btn btn-sm btn-primary" onclick="guardarComentario()"
|
||||
style="height:fit-content;align-self:flex-end">
|
||||
<i class="fas fa-paper-plane"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div id="lista-comentarios" class="text-muted small py-2">
|
||||
<i class="fas fa-spinner fa-spin me-1"></i>Cargando comentarios…
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ── Barra de acciones ── -->
|
||||
<div class="ficha-acciones">
|
||||
<button class="btn btn-primary" id="btn-iniciar" onclick="iniciarAtencion()">
|
||||
@@ -587,6 +606,9 @@ async function cargarFichaSolicitud(turnoId) {
|
||||
// Consentimientos
|
||||
renderConsentimientos(consts);
|
||||
|
||||
// Comentarios
|
||||
cargarComentarios(turnoId);
|
||||
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
@@ -857,6 +879,48 @@ function mostrarToast(msg, type = 'info', duration = 2500) {
|
||||
function mostrarError(msg) { mostrarToast(msg, 'error', 4000); }
|
||||
function mostrarLlamando(cod) { mostrarToast('Llamando turno ' + cod + '…', 'info', 2000); }
|
||||
|
||||
// ── Comentarios y notas ───────────────────────────────────────
|
||||
async function cargarComentarios(turnoId) {
|
||||
if (!turnoId) return;
|
||||
const cont = document.getElementById('lista-comentarios');
|
||||
cont.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i>Cargando…';
|
||||
try {
|
||||
const res = await fetch(`${API}comentarios.php?turno_id=${turnoId}`);
|
||||
const json = await res.json();
|
||||
if (!json.ok || !json.comentarios) { cont.innerHTML = '<small class="text-muted">Sin comentarios</small>'; return; }
|
||||
if (json.comentarios.length === 0) { cont.innerHTML = '<small class="text-muted">Sin comentarios aún</small>'; return; }
|
||||
cont.innerHTML = json.comentarios.map(c => `
|
||||
<div style="background:#f8fafc;border-left:3px solid #8b5cf6;padding:8px 10px;margin-bottom:8px;border-radius:4px">
|
||||
<div style="font-size:.7rem;color:#94a3b8;margin-bottom:2px">${escHtml(c.usuario_nombre)} • ${new Date(c.creado_at).toLocaleString()}</div>
|
||||
<div style="font-size:.82rem;color:#334155">${escHtml(c.comentario)}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
} catch(_) {
|
||||
cont.innerHTML = '<small class="text-danger">Error al cargar comentarios</small>';
|
||||
}
|
||||
}
|
||||
|
||||
async function guardarComentario() {
|
||||
if (!turnoActivo) return;
|
||||
const inp = document.getElementById('inp-comentario');
|
||||
const txt = (inp.value || '').trim();
|
||||
if (!txt) { mostrarError('El comentario no puede estar vacío'); return; }
|
||||
try {
|
||||
const res = await fetch(API + 'comentarios.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ turno_id: turnoActivo.id, comentario: txt, tipo: 'muestras' }),
|
||||
});
|
||||
const json = await res.json();
|
||||
if (!json.ok) { mostrarError(json.error || 'Error al guardar'); return; }
|
||||
inp.value = '';
|
||||
await cargarComentarios(turnoActivo.id);
|
||||
mostrarToast('Comentario guardado', 'success', 2000);
|
||||
} catch(err) {
|
||||
mostrarError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Ocupación exclusiva del puesto ──────────────────────────── */
|
||||
(function(_ID, _NOMBRE, _VIEW, _PARAM) {
|
||||
if (!_ID) return;
|
||||
|
||||
Reference in New Issue
Block a user