diff --git a/api/lab/save_tomas_config.php b/api/lab/save_tomas_config.php index 06fb5cc..8383d86 100644 --- a/api/lab/save_tomas_config.php +++ b/api/lab/save_tomas_config.php @@ -85,10 +85,10 @@ if ($action === 'add_exam') { $sepLabel = "$examName · {$h12}:{$mm} {$ampm}"; } - $sepId = $prefix . 's' . $idx . $uid; - $horaId = $prefix . 'h' . $idx . $uid; - $resId = $prefix . 'r' . $idx . $uid; - $firmaId = $prefix . 'f' . $idx . $uid; + $sepId = $prefix . 's' . $idx . $uid; + $horaId = $prefix . 'h' . $idx . $uid; + $obsId = $prefix . 'o' . $idx . $uid; + $firmaId = $prefix . 'f' . $idx . $uid; $esquema[] = [ 'id' => $sepId, @@ -96,28 +96,9 @@ if ($action === 'add_exam') { 'label' => $sepLabel, 'condicion'=> ['campo_id' => $condCampoId, 'valores' => [$examName]], ]; - $esquema[] = [ - 'id' => $horaId, - 'tipo' => 'hora', - 'label' => 'Hora de toma', - ]; - $esquema[] = [ - 'id' => $resId, - 'tipo' => 'numero', - 'label' => 'Resultado', - ]; - $esquema[] = [ - 'id' => $prefix . 'o' . $idx . $uid, - 'tipo' => 'texto', - 'label' => 'Observaciones', - 'placeholder' => '', - 'required' => false, - ]; - $esquema[] = [ - 'id' => $firmaId, - 'tipo' => 'firma_profesional', - 'label' => 'Firma del profesional', - ]; + $esquema[] = ['id' => $horaId, 'tipo' => 'hora', 'label' => 'Hora de toma']; + $esquema[] = ['id' => $obsId, 'tipo' => 'texto', 'label' => 'Observaciones', 'placeholder' => '', 'required' => false]; + $esquema[] = ['id' => $firmaId, 'tipo' => 'firma_profesional', 'label' => 'Firma del profesional']; } $db->getConnection()->prepare( diff --git a/ver_formulario_enviado.php b/ver_formulario_enviado.php index aec04d1..0ab22b0 100644 --- a/ver_formulario_enviado.php +++ b/ver_formulario_enviado.php @@ -305,7 +305,12 @@ if ($modoTurnero && $embebido && $_soloFirmaPro) { if (is_array($__rawCfg)) { $_tomasConfig = $__rawCfg; foreach ($_mpGroups as $__gk => &$__gsecs) { - if (!isset($_tomasConfig[$__gk])) continue; + if (!isset($_tomasConfig[$__gk])) { + // Grupo no configurado: ocultar sus secciones y vaciarlo del mapa + foreach ($__gsecs as $__s) { $_mpSkippedSepIds[$__s['sep_id']] = true; } + $__gsecs = []; + continue; + } $__allowed = array_flip($_tomasConfig[$__gk]); foreach ($__gsecs as $__s) { if (!isset($__allowed[$__s['firma']])) { @@ -369,6 +374,7 @@ function esc2(mixed $v): string { function _addExamWizardHtml(string $cid): string { return ' +
'; + } + html += '
'; + }); + wrap.innerHTML = html; +} + // Escuchar selección de tipo de examen document.addEventListener('change', function(e) { var el = e.target; if (el.name.replace(/\[\]$/, '') !== '_c8j2g16') return; var examName = _mpGetExamName(); _mpApplyExamVisibility(examName); - // Panel de configuración solo en modo turnero y si aún no está configurado - if (!_mpModoTurnero || _mpTomasConfig !== null || !examName) return; - var groups = _mpGetGroupsForExam(examName); - if (!Object.keys(groups).length) return; - _mpShowCfgPanel(examName, groups); + if (_mpModoTurnero) _mpRenderBadges(); }); -// Al cargar: aplicar visibilidad (sin examen = ocultar todo) +// Click en botón "Configurar tiempos" del badge +document.addEventListener('click', function(e) { + var btn = e.target.closest('.mp-exam-badge-btn'); + if (!btn) return; + var examName = btn.getAttribute('data-exam'); + var groups = _mpGetGroupsForExam(examName); + if (Object.keys(groups).length) _mpShowCfgPanel(examName, groups); +}); + +// Al cargar: aplicar visibilidad y renderizar badges document.addEventListener('DOMContentLoaded', function() { var examName = _mpGetExamName(); // Restaurar selección de examen tras el reload del panel de config @@ -1379,9 +1438,7 @@ document.addEventListener('DOMContentLoaded', function() { } catch(e) {} } _mpApplyExamVisibility(examName); - if (!_mpModoTurnero || _mpTomasConfig !== null || !examName) return; - var groups = _mpGetGroupsForExam(examName); - if (Object.keys(groups).length) _mpShowCfgPanel(examName, groups); + if (_mpModoTurnero) _mpRenderBadges(); }); // Botón "Usar todas"