From 6e445bfbe6b6093cf11029774b315f66efee5e0c Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 21 Feb 2025 13:08:54 -0600 Subject: [PATCH] =?UTF-8?q?Auditor=C3=ADa=20Excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action/action_auditoria.php | 10 ++++--- export/supervisor_excel.php | 57 +++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/action/action_auditoria.php b/action/action_auditoria.php index 3d0fc5a..11fb9cf 100644 --- a/action/action_auditoria.php +++ b/action/action_auditoria.php @@ -71,6 +71,7 @@ try { 'periodo_id' )); + $DaysWeek = implode(',', array_values(array_unique(array_map( fn(DateTime $date) => (int) $date->format('w'), iterator_to_array(new DatePeriod( @@ -80,7 +81,7 @@ try { )) )))); - $HorariosID = implode(',', array_column($db->query( + $_SESSION['horarios'] = $HorariosID = implode(',', array_column($db->query( "SELECT horario_id FROM horario WHERE horario_dia IN ($DaysWeek) AND periodo_id IN ($PeriodosHorarios) @@ -105,8 +106,8 @@ try { SELECT $RelevantColumns, CASE - WHEN registro.registro_retardo THEN 'warning'::text - ELSE 'primary'::text + WHEN registro.registro_retardo THEN 'warning' + ELSE 'primary' END AS color FROM horario NATURAL JOIN fechas @@ -115,7 +116,8 @@ try { NATURAL JOIN salon LEFT JOIN REGISTRO USING (profesor_id, registro_fecha_ideal, horario_id) LEFT JOIN usuario ON usuario.usuario_id = REGISTRO.supervisor_id - JOIN estado_supervisor ON estado_supervisor.estado_supervisor_id = COALESCE(REGISTRO.estado_supervisor_id, 0)", + JOIN estado_supervisor ON estado_supervisor.estado_supervisor_id = COALESCE(REGISTRO.estado_supervisor_id, 0) + ORDER BY fechas.registro_fecha_ideal, horario_hora", $fechas ); diff --git a/export/supervisor_excel.php b/export/supervisor_excel.php index def4d3c..ffdeb32 100644 --- a/export/supervisor_excel.php +++ b/export/supervisor_excel.php @@ -21,13 +21,52 @@ $profesor_clave = isset($params['profesor']) : null; $data = $db->query( - "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", + "WITH fechas AS ( + SELECT fechas_clase( + _horario_id => h.horario_id, + _todos => false, + _fecha_inicio => :fecha_inicio, + _fecha_fin => :fecha_fin + ) AS registro_fecha_ideal, h.horario_id + FROM horario h WHERE horario_id IN ({$_SESSION['horarios']}) + ) + SELECT + fechas.registro_fecha_ideal, + profesor_clave, + profesor_nombre, + profesor_correo, + facultad_nombre, + materia_nombre, + carrera_nombre, + horario_grupo, + horario_hora, + horario_fin, + salon, + salon_array, + registro_fecha, + registro_retardo, + usuario_nombre, + registro_fecha_supervisor, + registro.estado_supervisor_id, + comentario, + justificacion + FROM horario + NATURAL JOIN fechas + NATURAL JOIN horario_profesor + NATURAL JOIN profesor + NATURAL JOIN salon_view_mat + + NATURAL JOIN facultad + NATURAL JOIN materia + NATURAL JOIN carrera + + LEFT JOIN REGISTRO USING (profesor_id, registro_fecha_ideal, horario_id) + LEFT JOIN usuario ON usuario.usuario_id = REGISTRO.supervisor_id + WHERE profesor_clave = COALESCE(:profesor_clave, profesor_clave) + AND horario.facultad_id = COALESCE(:facultad_id, horario.facultad_id) + ORDER BY fechas.registro_fecha_ideal, horario_hora", [ - 'facultad_id' => $user->facultad['facultad_id'], + 'facultad_id' => $user->facultad['facultad_id'] ?? $params['facultad_id'], 'profesor_clave' => $profesor_clave, 'fecha_inicio' => $_SESSION['fecha_inicio'], 'fecha_fin' => $_SESSION['fecha_fin'], @@ -70,9 +109,9 @@ $data_excel = array( "CLAVE" => 'profesor_clave', "PROFESOR" => 'profesor_nombre', "CORREO" => 'profesor_correo', - "FACULTAD" => 'facultad', - "MATERIA" => 'materia', - "CARRERA / PROGRAMA" => 'carrera', + "FACULTAD" => 'facultad_nombre', + "MATERIA" => 'materia_nombre', + "CARRERA / PROGRAMA" => 'carrera_nombre', "GRUPO" => 'horario_grupo', "HORARIO" => 'horario_hora_completa', "SALÓN" => 'salon',