up
This commit is contained in:
@@ -58,7 +58,7 @@ try {
|
||||
|
||||
try {
|
||||
$formulariosCons = $pdo->query(
|
||||
"SELECT id, nombre, COALESCE(is_principal,0) AS is_principal FROM lab_formularios WHERE is_active=1 ORDER BY nombre ASC"
|
||||
"SELECT id, nombre FROM lab_formularios WHERE is_active=1 ORDER BY nombre ASC"
|
||||
)->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (\Throwable $e) { $_loadErrors[] = 'lab_formularios: ' . $e->getMessage(); }
|
||||
|
||||
@@ -491,37 +491,16 @@ $tab = $_GET['tab'] ?? 'lugares';
|
||||
<?php if (!empty($formulariosCons)): ?>
|
||||
<div class="mt-4">
|
||||
<p class="section-title"><i class="fas fa-file-signature me-1"></i>Vista inversa: por consentimiento</p>
|
||||
|
||||
<div class="alert alert-info py-2 px-3 small mb-3" style="font-size:.8rem">
|
||||
<i class="fas fa-star me-1 text-warning"></i>
|
||||
Marque un consentimiento como <strong>principal</strong> (el que se firma en recepción para pasar a toma de muestras).
|
||||
Se auto-creará cuando el paciente tome turno en el kiosko y se enviará por WhatsApp automáticamente.
|
||||
</div>
|
||||
|
||||
<?php $principalEncontrado = false; ?>
|
||||
<?php foreach ($formulariosCons as $fc):
|
||||
$exsVinculados = [];
|
||||
foreach ($examTipos as $et) {
|
||||
$fids = $et['form_ids'] ? array_map('intval', explode(',', $et['form_ids'])) : [];
|
||||
if (in_array((int)$fc['id'], $fids)) $exsVinculados[] = $et;
|
||||
}
|
||||
$esPrincipal = !empty($fc['is_principal']);
|
||||
if ($esPrincipal) $principalEncontrado = true;
|
||||
?>
|
||||
<div class="mb-2 d-flex align-items-center gap-2" style="padding:4px 0">
|
||||
<?php if ($esPrincipal): ?>
|
||||
<span class="badge bg-warning text-dark" style="font-size:.65rem;cursor:pointer"
|
||||
onclick="quitarPrincipalConsent(<?= (int)$fc['id'] ?>)" title="Quitar como principal">
|
||||
<i class="fas fa-star"></i> Principal
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-light text-muted" style="font-size:.65rem;cursor:pointer"
|
||||
onclick="marcarPrincipalConsent(<?= (int)$fc['id'] ?>)" title="Marcar como consentimiento principal">
|
||||
<i class="far fa-star"></i>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<div class="mb-2">
|
||||
<span class="fw-semibold small"><?= htmlspecialchars($fc['nombre']) ?></span>
|
||||
<span class="text-muted small ms-1">
|
||||
<span class="text-muted small ms-2">
|
||||
<?= empty($exsVinculados)
|
||||
? '<em>Sin exámenes vinculados</em>'
|
||||
: implode(', ', array_map(fn($e)=>'<code>'.$e['codigo'].'</code>', $exsVinculados))
|
||||
@@ -529,11 +508,6 @@ $tab = $_GET['tab'] ?? 'lugares';
|
||||
</span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!$principalEncontrado): ?>
|
||||
<div class="text-muted small">
|
||||
<em>Ningún consentimiento marcado como principal.</em>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -1149,32 +1123,6 @@ async function borrarTvVideo() {
|
||||
} catch(e) { toast('Error de conexión', 'error'); }
|
||||
}
|
||||
|
||||
// ── Consentimiento principal ──────────────────────────────────
|
||||
async function marcarPrincipalConsent(formularioId) {
|
||||
try {
|
||||
const res = await fetch(API + 'set_principal_consent.php', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ formulario_id: formularioId })
|
||||
});
|
||||
const json = await res.json();
|
||||
if (!json.ok) { toast(json.error || 'Error', 'error'); return; }
|
||||
toast('Consentimiento principal actualizado');
|
||||
setTimeout(() => location.reload(), 400);
|
||||
} catch (e) { toast('Error de conexión', 'error'); }
|
||||
}
|
||||
async function quitarPrincipalConsent() {
|
||||
try {
|
||||
const res = await fetch(API + 'set_principal_consent.php', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ formulario_id: null })
|
||||
});
|
||||
const json = await res.json();
|
||||
if (!json.ok) { toast(json.error || 'Error', 'error'); return; }
|
||||
toast('Consentimiento principal desmarcado');
|
||||
setTimeout(() => location.reload(), 400);
|
||||
} catch (e) { toast('Error de conexión', 'error'); }
|
||||
}
|
||||
|
||||
async function guardarWhatsApp() {
|
||||
const template = document.getElementById('wa-template')?.value.trim();
|
||||
const lang = document.getElementById('wa-lang')?.value.trim();
|
||||
|
||||
@@ -108,7 +108,7 @@ $_hasVideo = (bool)$_tvVideo;
|
||||
position: relative;
|
||||
}
|
||||
.pg-body.has-video {
|
||||
grid-template-columns: 240px 1fr 240px;
|
||||
grid-template-columns: 380px 1fr 380px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -594,21 +594,8 @@ function abrirFicha(turno) {
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
// Cargar consentimientos anticipados (principal y otros ya creados)
|
||||
cargarConsentimientosTurno(turno.id);
|
||||
}
|
||||
|
||||
async function cargarConsentimientosTurno(turnoId) {
|
||||
try {
|
||||
const res = await fetch(`${API}get_consentimientos.php?turno_id=${turnoId}`);
|
||||
const json = await res.json();
|
||||
if (json.ok && json.consentimientos?.length) {
|
||||
consentimientos = json.consentimientos;
|
||||
renderConsentimientos(consentimientos);
|
||||
document.getElementById('sec-consentimientos').style.display = '';
|
||||
document.getElementById('btn-reenviar-consent').classList.remove('d-none');
|
||||
}
|
||||
} catch (_) {}
|
||||
// Buscar consentimientos si ya tiene solicitud
|
||||
verificarSolicitudExistente(turno.id);
|
||||
}
|
||||
|
||||
async function verificarSolicitudExistente(turnoId) {
|
||||
|
||||
Reference in New Issue
Block a user