From 13f1e3b26d040c1a7251376c4a8c732c886a3bbf Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 24 Feb 2025 09:02:51 -0600 Subject: [PATCH] =?UTF-8?q?Sin=20auditor=C3=ADa=20Mat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action/action_auditoria.php | 34 ++++++++++++++++------------- action/action_auditoria_detalle.php | 8 ++----- action/justificar.php | 3 --- auditoria.php | 14 +++++++----- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/action/action_auditoria.php b/action/action_auditoria.php index 11fb9cf..c57f234 100644 --- a/action/action_auditoria.php +++ b/action/action_auditoria.php @@ -19,7 +19,6 @@ $user = unserialize($_SESSION['user']); // check method try { if ($_SERVER['REQUEST_METHOD'] === 'GET') { - // pg_send_query($db->getConnection(), "REFRESH MATERIALIZED VIEW CONCURRENTLY PUBLIC.AUDITORIA_MAT"); $baseDate = $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null; $params = [ @@ -33,9 +32,9 @@ try { // Define relevant columns $relevant_columns = [ 'registro_id', - 'registro_fecha_ideal', - 'horario_id', - 'profesor_id', + 'fechas.registro_fecha_ideal', + 'fechas.horario_id', + 'profesor.profesor_id', 'salon', 'profesor_clave', 'profesor_nombre', @@ -56,20 +55,21 @@ try { $RelevantColumns = implode(', ', $relevant_columns); $_SESSION['fecha_inicio'] = $_GET['fecha'] ?? $_GET['fecha_inicio'] ?? date('Y-m-d'); - $_SESSION['fecha_fin'] = date('Y-m-d H:i:s', strtotime(($baseDate ?? 'now') . ' +24 hours')); + $_SESSION['fecha_fin'] = date('Y-m-d H:i:s', strtotime($baseDate ?? 'now')); $fechas = [ 'fecha_inicio' => $_SESSION['fecha_inicio'], 'fecha_fin' => $_SESSION['fecha_fin'], ]; + $PeriodosHorarios = implode(',', array_column( $db->query( 'SELECT periodo_id FROM periodo WHERE (:fecha_inicio, :fecha_fin) OVERLAPS (periodo_fecha_inicio, periodo_fecha_fin)', $fechas ), 'periodo_id' - )); + )) ?: 0; $DaysWeek = implode(',', array_values(array_unique(array_map( @@ -79,7 +79,7 @@ try { new DateInterval('P1D'), (new DateTime($_SESSION['fecha_fin']))->modify('+1 day') )) - )))); + )))) ?: 0; $_SESSION['horarios'] = $HorariosID = implode(',', array_column($db->query( "SELECT horario_id FROM horario @@ -90,7 +90,7 @@ try { array_merge($fechas, [ ':facultad_id' => $user->facultad['facultad_id'], ]) - ), 'horario_id')); + ), 'horario_id')) ?: 0; $Horarios = $db->query( @@ -100,8 +100,10 @@ try { _todos => false, _fecha_inicio => :fecha_inicio, _fecha_fin => :fecha_fin - ) AS registro_fecha_ideal, h.horario_id - FROM horario h WHERE horario_id IN ($HorariosID) + ) AS registro_fecha_ideal, h.horario_id, profesor_id + FROM horario h + JOIN horario_profesor USING (horario_id) + WHERE horario_id IN ($HorariosID) ) SELECT $RelevantColumns, @@ -110,11 +112,13 @@ try { ELSE 'primary' END AS color FROM horario - NATURAL JOIN fechas - NATURAL JOIN horario_profesor - NATURAL JOIN profesor - NATURAL JOIN salon - LEFT JOIN REGISTRO USING (profesor_id, registro_fecha_ideal, horario_id) + JOIN fechas USING (horario_id) + JOIN profesor USING (profesor_id) + JOIN salon USING (salon_id) + LEFT JOIN REGISTRO ON + REGISTRO.profesor_id = PROFESOR.profesor_id AND + REGISTRO.horario_id = FECHAS.horario_id AND + FECHAS.registro_fecha_ideal = REGISTRO.registro_fecha_ideal 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) ORDER BY fechas.registro_fecha_ideal, horario_hora", diff --git a/action/action_auditoria_detalle.php b/action/action_auditoria_detalle.php index 6b7cd0d..80de4ac 100644 --- a/action/action_auditoria_detalle.php +++ b/action/action_auditoria_detalle.php @@ -33,6 +33,7 @@ try { facultad_nombre as facultad, carrera_nombre as carrera, registro_fecha, + registro_fecha_supervisor, estado_color, estado_supervisor.estado_supervisor_id, estado_supervisor.nombre, @@ -40,7 +41,7 @@ try { usuario_nombre, horario_grupo, registro_retardo, - justificada, + registro_justificada, justificacion, comentario, CASE @@ -65,11 +66,6 @@ try { AND profesor.profesor_id = :profesor_id", $_GET ); - /* ->where('registro_fecha_ideal', $_GET['registro_fecha_ideal']) - ->where('horario_id', $_GET['horario_id']) - ->where('profesor_id', $_GET['profesor_id']) - ->getOne('auditoria_mat'); */ - // Print the JSON file echo json_encode($data); } else { http_response_code(405); diff --git a/action/justificar.php b/action/justificar.php index 0d77dc4..fbbcf31 100644 --- a/action/justificar.php +++ b/action/justificar.php @@ -39,9 +39,6 @@ try { ] ); - $db->query("REFRESH MATERIALIZED VIEW CONCURRENTLY PUBLIC.AUDITORIA_MAT"); - - $data_justificador = $db->querySingle( "SELECT justificador.usuario_nombre as justificador_nombre, justificador.usuario_clave as justificador_clave, diff --git a/auditoria.php b/auditoria.php index 25b04e2..faeaa66 100644 --- a/auditoria.php +++ b/auditoria.php @@ -395,7 +395,7 @@