This commit is contained in:
Your Name
2025-02-17 14:55:02 -06:00
parent 96eba3f917
commit c980c5aecd
5 changed files with 63 additions and 83 deletions

View File

@@ -21,43 +21,16 @@ $profesor_clave = isset($params['profesor'])
: null;
$data = $db->query(
"SELECT DISTINCT
auditoria->>'registro_fecha_ideal' as registro_fecha_ideal,
auditoria->>'profesor_clave' as profesor_clave,
auditoria->>'profesor_nombre' as profesor_nombre,
NULLIF(auditoria->>'profesor_correo', '') as profesor_correo,
auditoria->>'facultad' as facultad,
auditoria->>'materia' as materia,
auditoria->>'carrera' as carrera,
NULLIF(auditoria->>'horario_grupo', '') as horario_grupo,
auditoria->>'horario_hora_completa' as horario_hora_completa,
auditoria->>'salon' as salon,
(
SELECT string_agg(value, ' / ' ORDER BY value)
FROM jsonb_array_elements_text(auditoria->'salon_array') AS value
) as salon_array,
auditoria->>'asistencia' as asistencia,
auditoria->>'registro_fecha' as registro_fecha,
auditoria->>'usuario_nombre' as usuario_nombre,
auditoria->>'nombre' as nombre,
auditoria->>'registro_fecha_supervisor' as registro_fecha_supervisor,
auditoria->>'comentario' as comentario,
auditoria->>'justificacion' as justificacion,
auditoria->>'horario_hora' as horario_hora,
auditoria->>'horario_fin' as horario_fin,
(auditoria->>'estado_supervisor_id')::integer as estado_id,
(auditoria->>'registro_retardo')::BOOLEAN as registro_retardo
FROM last_auditoria
-- JOIN BLOQUE_HORARIO ON ((auditoria->>'horario_hora')::TIME, (auditoria->>'horario_fin')::TIME) OVERLAPS (HORA_INICIO, HORA_FIN)
WHERE USUARIO_ID = :usuario_id
AND auditoria->>'facultad_id' = COALESCE(:facultad_id, auditoria->>'facultad_id')
AND auditoria->>'profesor_clave' = COALESCE(:profesor_clave, auditoria->>'profesor_clave')
/*AND BLOQUE_HORARIO.ID = COALESCE(:bloque_horario_id, BLOQUE_HORARIO.ID)*/",
"SELECT * FROM auditoria_mat
WHERE facultad_id = COALESCE(:facultad_id, facultad_id)
AND profesor_clave = COALESCE(:profesor_clave, profesor_clave)
AND REGISTRO_FECHA_IDEAL + HORARIO_HORA between :fecha_inicio AND :fecha_fin
ORDER BY REGISTRO_FECHA_IDEAL, HORARIO_HORA",
[
'usuario_id' => $user->user['id'],
'facultad_id' => $params['facultad_id'],
'profesor_clave' => $profesor_clave,
/* 'bloque_horario_id' => $params['bloque_horario'] */
'fecha_inicio' => $_SESSION['fecha_inicio'],
'fecha_fin' => $_SESSION['fecha_fin'],
]
);
@@ -65,7 +38,7 @@ $estados = empty($params['estados']) ? null : $params['estados'];
$data = array_filter(
$data,
fn($fila) => in_array($fila['estado_id'], $estados ?? [$fila['estado_id']])
fn($registro) => in_array($registro['estado_supervisor_id'], $estados ?? [$registro['estado_supervisor_id']])
);
$data = array_values($data);
@@ -192,12 +165,12 @@ function getFormattedValue($key, $registro)
{
return match ($key) {
'asistencia' => $registro['registro_fecha'] === null
? "Sin registro"
: ($registro['registro_retardo'] ? "Retardo " : "Asistencia "),
? "Sin registro"
: ($registro['registro_retardo'] ? "Retardo " : "Asistencia "),
'registro_fecha',
'registro_fecha_supervisor' => $registro[$key] === null
? 'Sin registro'
: date('H:i', strtotime($registro[$key])),
? 'Sin registro'
: date('H:i', strtotime($registro[$key])),
'nombre' => $registro[$key] ?? "Sin registro",
'horario_hora_completa' => "{$registro['horario_hora']} - {$registro['horario_fin']}",
'usuario_nombre' => $registro[$key] ?? "Sin registro",