fix(turnero): corregir 6 hallazgos de auditoría en tomas previas
- cancelar_toma_pendiente: añade JOIN por paciente_id para prevenir IDOR - cancelar_toma_pendiente: requiere turno_id para validar propiedad - get_tomas_pendientes: porta filtros condicionales y _tomas_config de guardar_toma.php para mostrar conteo de firmas correcto - lugar.php: refresca sección tomas previas al completar via turneroFirmado - lugar.php: muestra error en catch de cargarTomasPrevias en vez de silenciar - lugar.php: limpia _tomaAlertados al cancelar toma previa - lugar.php: pasa turno_id en POST de cancelar para ownership check Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
814bd2ce5c
commit
49a622e05f
@@ -42,14 +42,46 @@ foreach ($rows as $r) {
|
||||
$esquema = json_decode($r['esquema'] ?? '[]', true) ?: [];
|
||||
$datos = json_decode($r['datos_respuestas'] ?? '[]', true) ?: [];
|
||||
|
||||
// Contar firmas totales y hechas
|
||||
$totalFirmas = 0;
|
||||
$firmasHechas = 0;
|
||||
// Contar firmas activas — mismo filtro que guardar_toma.php
|
||||
// (condicionales de separador + _tomas_config)
|
||||
$firmasCampos = [];
|
||||
$separadorLabel = null;
|
||||
$curCondField = null;
|
||||
$curCondVals = [];
|
||||
foreach ($esquema as $c) {
|
||||
if (($c['tipo'] ?? '') === 'firma_profesional') {
|
||||
$totalFirmas++;
|
||||
if (!empty($datos[$c['id']]) && strlen($datos[$c['id']]) > 10) $firmasHechas++;
|
||||
$tipo = $c['tipo'] ?? '';
|
||||
if ($tipo === 'separador') {
|
||||
$separadorLabel = $c['label'] ?? '';
|
||||
$cond = $c['condicion'] ?? null;
|
||||
if ($cond) {
|
||||
$curCondField = $cond['campo_id'] ?? null;
|
||||
$curCondVals = $cond['valores'] ?? ($cond['valor'] ? [$cond['valor']] : []);
|
||||
} else {
|
||||
$curCondField = null;
|
||||
$curCondVals = [];
|
||||
}
|
||||
}
|
||||
if ($tipo === 'firma_profesional') {
|
||||
if ($curCondField !== null && !empty($curCondVals)) {
|
||||
$ctrlVal = $datos[$curCondField] ?? null;
|
||||
$ctrlArr = is_array($ctrlVal) ? $ctrlVal : ($ctrlVal !== null ? [$ctrlVal] : []);
|
||||
if (empty(array_intersect($curCondVals, $ctrlArr))) continue;
|
||||
}
|
||||
$firmasCampos[] = $c['id'];
|
||||
}
|
||||
}
|
||||
$tcFirmas = $datos['_tomas_config'] ?? null;
|
||||
if (is_array($tcFirmas)) {
|
||||
$allowed = [];
|
||||
foreach ($tcFirmas as $ids) {
|
||||
if (is_array($ids)) foreach ($ids as $id) $allowed[$id] = true;
|
||||
}
|
||||
$firmasCampos = array_values(array_filter($firmasCampos, fn($id) => isset($allowed[$id])));
|
||||
}
|
||||
$totalFirmas = count($firmasCampos);
|
||||
$firmasHechas = 0;
|
||||
foreach ($firmasCampos as $fid) {
|
||||
if (!empty($datos[$fid]) && strlen($datos[$fid]) > 10) $firmasHechas++;
|
||||
}
|
||||
|
||||
$tomas[] = [
|
||||
|
||||
Reference in New Issue
Block a user