feat(recepcion): panel muestras muestra último turno atendido por letra

API: agrega por_prioridad con último código llamado a muestras por letra.
Vista: badges con color de prioridad mostrando "A: A-023", "B: B-011", etc.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-30 19:51:10 -05:00
co-authored by Claude Sonnet 4.6
parent 498a144c18
commit 941b6740f0
2 changed files with 25 additions and 6 deletions
@@ -46,8 +46,26 @@ $s2 = $pdo->prepare(
$s2->execute([$sesionId]);
$enEsperaMuestra = (int)$s2->fetchColumn();
// Último turno atendido en muestras por prioridad (letra)
$sp = $pdo->prepare(
"SELECT p.codigo, p.color,
(SELECT t.codigo FROM turnero_turnos t
WHERE t.sesion_id = ? AND t.prioridad_id = p.id
AND t.lugar_destino_id IN (SELECT id FROM turnero_lugares WHERE tipo='muestras' AND activo=1)
AND t.inicio_lugar_at IS NOT NULL
ORDER BY t.numero DESC LIMIT 1) AS ultimo_codigo
FROM turnero_prioridades p
ORDER BY p.orden_peso ASC"
);
$sp->execute([$sesionId]);
$porPrioridad = array_values(array_filter(
$sp->fetchAll(PDO::FETCH_ASSOC),
fn($r) => $r['ultimo_codigo'] !== null
));
jsonOk([
'estaciones' => $estaciones,
'en_espera' => $enEspera,
'en_espera_muestra' => $enEsperaMuestra,
'por_prioridad' => $porPrioridad,
]);