Historial turnero: desglose de tomas de muestra y modal para documentos firmados
Muestra el detalle de cada toma (tipo, quien la recibió, tiempo) cuando un turno tuvo varias, para explicar tiempos de servicio prolongados. Los documentos firmados ahora se abren en un modal en vez de nueva pestaña, preservando los filtros de búsqueda activos. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
397dc208a0
commit
0b8418ec76
@@ -139,11 +139,12 @@ $stmtTurnos = $pdo->prepare($sqlTurnos);
|
||||
$stmtTurnos->execute($bindsPage);
|
||||
$turnos = $stmtTurnos->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// ── Enriquecer con exámenes, consentimientos y comentarios (batch) ─
|
||||
// ── Enriquecer con exámenes, consentimientos, comentarios y tomas (batch) ─
|
||||
$turnoIds = array_column($turnos, 'id');
|
||||
$examenes = [];
|
||||
$consentimientos = [];
|
||||
$comentarios = [];
|
||||
$tomas = [];
|
||||
|
||||
if ($turnoIds) {
|
||||
$ph = implode(',', array_fill(0, count($turnoIds), '?'));
|
||||
@@ -193,6 +194,26 @@ if ($turnoIds) {
|
||||
$comentarios[$tid][] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// Tomas de muestra — batch (una solicitud por turno, varias tomas por solicitud)
|
||||
$stmtTom = $pdo->prepare(
|
||||
"SELECT ts.turno_id, tm.tipo_muestra, tm.estado, tm.creado_at, tm.recibida_at,
|
||||
ar.full_name AS recibida_por_nombre
|
||||
FROM turnero_muestras tm
|
||||
JOIN turnero_solicitudes ts ON ts.id = tm.solicitud_id
|
||||
LEFT JOIN admin_users ar ON ar.id = tm.recibida_por
|
||||
WHERE ts.turno_id IN ($ph)
|
||||
ORDER BY tm.creado_at ASC"
|
||||
);
|
||||
$stmtTom->execute($turnoIds);
|
||||
foreach ($stmtTom->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$tid = (int)$row['turno_id'];
|
||||
unset($row['turno_id']);
|
||||
$row['tiempo_min'] = ($row['creado_at'] && $row['recibida_at'])
|
||||
? round((strtotime($row['recibida_at']) - strtotime($row['creado_at'])) / 60, 1)
|
||||
: null;
|
||||
$tomas[$tid][] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($turnos as &$turno) {
|
||||
@@ -200,6 +221,7 @@ foreach ($turnos as &$turno) {
|
||||
$turno['examenes'] = $examenes[$tid] ?? [];
|
||||
$turno['consentimientos'] = $consentimientos[$tid] ?? [];
|
||||
$turno['comentarios'] = $comentarios[$tid] ?? [];
|
||||
$turno['tomas'] = $tomas[$tid] ?? [];
|
||||
}
|
||||
|
||||
// ── Resumen por estado (del rango filtrado) ───────────────────
|
||||
|
||||
Reference in New Issue
Block a user