fix(formulario): múltiples correcciones modo embebido/turnero
- ver_formulario_enviado.php: usar opciones??options??items como fallback de claves del schema - ver_formulario_enviado.php: marcar _esquemaTieneFirmaPaciente en cualquier campo firma (no solo sin SVG), evita mostrar firma paciente cuando schema solo tiene firma_profesional - ver_formulario_enviado.php: modo embebido (?embed=1) con layout compacto para iframe - lugar.php: pasar &embed=1 al iframe src Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7b734195e0
commit
27135e4d2f
@@ -871,7 +871,7 @@ async function cargarFormEmbebido(turnoId) {
|
||||
const res = await fetch(`${API}get_consent_token.php?turno_id=${turnoId}&lugar_id=${lugarId}`);
|
||||
const json = await res.json();
|
||||
if (json.ok && json.token) {
|
||||
iframe.src = `${BASE_WA}ver_formulario_enviado.php?token=${encodeURIComponent(json.token)}`;
|
||||
iframe.src = `${BASE_WA}ver_formulario_enviado.php?token=${encodeURIComponent(json.token)}&embed=1`;
|
||||
} else {
|
||||
load.innerHTML = '<span class="text-danger small"><i class="fas fa-exclamation-triangle me-1"></i>' + (json.error || 'No hay formulario configurado') + '</span>';
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ $datosCliente = json_decode($envio['datos_cliente'] ?? '{}', true) ?? [];
|
||||
$datosPrefilled = json_decode($envio['datos_prefilled'] ?? '{}', true) ?? [];
|
||||
$todos = array_merge($datosPrefilled, $datosCliente);
|
||||
$modoEditar = $modoTurnero && $envio['estado'] !== 'firmado';
|
||||
$embebido = isset($_GET['embed']) && $_GET['embed'] === '1';
|
||||
|
||||
// Mapa id → label
|
||||
$labelMap = [];
|
||||
@@ -298,6 +299,31 @@ function esc2(mixed $v): string {
|
||||
.hash-seal-header { background: #000 !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
|
||||
}
|
||||
|
||||
<?php if ($embebido): ?>
|
||||
/* ── Modo embebido (iframe) ── */
|
||||
body { background: #fff; font-size: 12px; }
|
||||
.action-bar { display: none !important; }
|
||||
.doc-wrap { margin: 0; border-radius: 0; box-shadow: none; max-width: 100%; }
|
||||
.doc-header { padding: 10px 14px 8px; }
|
||||
.doc-header-text h3 { font-size: 14px; }
|
||||
.doc-header-text h4 { font-size: 12px; }
|
||||
.doc-body { padding: 12px 14px; }
|
||||
.doc-footer { display: none; }
|
||||
.section-title { font-size: 10px; margin: 14px 0 8px; }
|
||||
.campo-label { font-size: 11px; }
|
||||
.campo-valor { font-size: 12px; }
|
||||
.campo-edit { margin-bottom: 8px; }
|
||||
.campo-edit label { font-size: 11px; margin-bottom: 2px; }
|
||||
.campo-edit .form-control,
|
||||
.campo-edit .form-select { font-size: 12px; padding: 3px 7px; }
|
||||
.campo-edit .form-check-label { font-size: 12px; }
|
||||
.campo-row { padding: 3px 0; }
|
||||
.turnero-cv { height: 110px !important; }
|
||||
.btn { font-size: 12px; padding: 3px 10px; }
|
||||
.hash-seal { display: none; }
|
||||
.alert { font-size: 12px; padding: 6px 10px; }
|
||||
<?php endif; ?>
|
||||
|
||||
/* ── Canvas firma profesional ───────────────────── */
|
||||
.firma-pro-widget { max-width: 520px; margin-top: 8px; }
|
||||
.fpw-canvas { border: 2px solid #198754; border-radius: 8px; background: #f8fff9;
|
||||
@@ -470,6 +496,11 @@ function esc2(mixed $v): string {
|
||||
if (!$cid) continue;
|
||||
$isPro = ($tipo === 'firma_profesional');
|
||||
|
||||
// Marcar siempre que el esquema tiene campo firma paciente
|
||||
if (!$isPro) {
|
||||
$_esquemaTieneFirmaPaciente = true;
|
||||
}
|
||||
|
||||
// La firma profesional global solo se muestra en el PRIMER campo firma_profesional.
|
||||
// Campos posteriores (ej. desistimiento) solo muestran su propia firma por campo.
|
||||
$fSvg = $isPro
|
||||
@@ -481,12 +512,10 @@ function esc2(mixed $v): string {
|
||||
$fLabel = htmlspecialchars($campo['label'] ?? ($isPro ? 'Firma profesional' : 'Firma paciente'));
|
||||
|
||||
// Campo paciente sin firma:
|
||||
// - En turnero pendiente: todos los campos firma muestran canvas (consentimiento + desistimiento).
|
||||
// - En turnero pendiente: todos los campos firma muestran canvas.
|
||||
// - En vista normal: omitir campos sin firma.
|
||||
if (!$fSvg && !$fFoto && !$isPro) {
|
||||
if ($modoTurnero && $modoEditar) {
|
||||
$_esquemaTieneFirmaPaciente = true;
|
||||
} else {
|
||||
if (!($modoTurnero && $modoEditar)) {
|
||||
continue; // no-turnero: omitir campos sin firma
|
||||
}
|
||||
}
|
||||
@@ -598,7 +627,7 @@ function esc2(mixed $v): string {
|
||||
</div>
|
||||
<?php continue; endif;
|
||||
if ($tipo === 'radio'):
|
||||
$opts = $campo['opciones'] ?? [];
|
||||
$opts = $campo['opciones'] ?? $campo['options'] ?? [];
|
||||
?>
|
||||
<div class="campo-edit">
|
||||
<label><?= $label ?></label>
|
||||
@@ -613,7 +642,7 @@ function esc2(mixed $v): string {
|
||||
</div>
|
||||
<?php continue; endif;
|
||||
if ($tipo === 'checkbox' || $tipo === 'lista_marcable'):
|
||||
$opts = $campo['opciones'] ?? [];
|
||||
$opts = $campo['opciones'] ?? $campo['options'] ?? $campo['items'] ?? [];
|
||||
$checkedArr = is_array($prefill) ? $prefill
|
||||
: (is_string($prefill) && $prefill !== '' ? (json_decode($prefill, true) ?: [$prefill]) : []);
|
||||
?>
|
||||
@@ -630,7 +659,7 @@ function esc2(mixed $v): string {
|
||||
</div>
|
||||
<?php continue; endif;
|
||||
if ($tipo === 'select'):
|
||||
$opts = $campo['opciones'] ?? [];
|
||||
$opts = $campo['opciones'] ?? $campo['options'] ?? [];
|
||||
?>
|
||||
<div class="campo-edit">
|
||||
<label><?= $label ?></label>
|
||||
|
||||
Reference in New Issue
Block a user