diff --git a/action/action_auditoria.php b/action/action_auditoria.php index e1b74c5..c4f2571 100644 --- a/action/action_auditoria.php +++ b/action/action_auditoria.php @@ -17,6 +17,14 @@ $user = unserialize($_SESSION['user']); // check method try { if ($_SERVER['REQUEST_METHOD'] === 'GET') { + $baseDate = $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null; + + $params = [ + ':periodo_id' => $user->periodo_id, + ':facultad_id' => $user->facultad['facultad_id'], + ':fecha_inicio' => $_GET['fecha'] ?? $_GET['fecha_inicio'] ?? date('Y-m-d'), + ':fecha_fin' => $baseDate ? date('Y-m-d H:i:s', strtotime($baseDate . ' +24 hours')) : date('Y-m-d H:i:s'), + ]; $data = $db->query( "WITH horarios AS ( SELECT *, @@ -64,17 +72,14 @@ try { LEFT JOIN USUARIO JUSTIFICADOR ON JUSTIFICADOR.usuario_id = REGISTRO.justificador_id LEFT JOIN ROL on ROL.rol_id = justificador.rol_id left join facultad on facultad.facultad_id = justificador.facultad_id - WHERE fechas.registro_fecha_ideal BETWEEN COALESCE(:fecha_inicio, LEAST(CURRENT_DATE, PERIODO_FECHA_FIN)) AND COALESCE(:fecha_fin, LEAST(CURRENT_DATE, PERIODO_FECHA_FIN)) + WHERE (fechas.registro_fecha_ideal + HORARIO_HORA) BETWEEN + GREATEST(HORARIO_FECHA_INICIO, PERIODO_FECHA_INICIO, :fecha_inicio) AND LEAST(:fecha_fin, PERIODO_FECHA_FIN, HORARIO_FECHA_FIN) ORDER BY fechas.registro_fecha_ideal DESC, horarios.horario_id, profesor_nombre", - [ - ':periodo_id' => $user->periodo_id, - ':facultad_id' => $user->facultad['facultad_id'], - ':fecha_inicio' => $_GET['fecha'] ?? $_GET['fecha_inicio'] ?? null, - ':fecha_fin' => $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null, - - ] + $params ); - echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); + + // $user->print_to_log(json_encode($params)); + echo json_encode(array_merge($data), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); } else { http_response_code(405); echo json_encode(['error' => 'method not allowed']); diff --git a/action/rutas_salón_horario.php b/action/rutas_salón_horario.php index 96b00fb..fd56b40 100644 --- a/action/rutas_salón_horario.php +++ b/action/rutas_salón_horario.php @@ -31,20 +31,22 @@ try { $data = array_map( fn($ruta) => array_merge( [ - 'horarios' => $db - ->join('periodo', 'periodo.periodo_id = horario_view.periodo_id') - ->join('bloque_horario', '(bloque_horario.hora_inicio, bloque_horario.hora_fin) OVERLAPS (horario_view.horario_hora, horario_view.horario_hora + horario_view.duracion)') - ->join('salon_view', 'salon_view.salon_id = horario_view.salon_id') - ->join('horario_profesor', 'horario_profesor.horario_id = horario_view.horario_id') - ->join('profesor', 'profesor.profesor_id = horario_profesor.profesor_id') - ->join('registro', '(registro.profesor_id, registro.horario_id, registro.registro_fecha_ideal) = (profesor.profesor_id, horario_view.horario_id, CURRENT_DATE)', 'LEFT') - ->where('CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin') - ->where('horario_dia = EXTRACT(DOW FROM CURRENT_DATE)') - ->where('bloque_horario.id', $_GET['bloque_horario_id']) - ->where('id_espacio_padre', $ruta['id_espacio_sgu']) - ->get('horario_view', null, '*, horario_view.horario_id, profesor.profesor_id'), + 'horarios' => array_merge( + $db + ->join('periodo', 'periodo.periodo_id = horario_view.periodo_id') + ->join('bloque_horario', '(bloque_horario.hora_inicio, bloque_horario.hora_fin) OVERLAPS (horario_view.horario_hora, horario_view.horario_hora + horario_view.duracion)') + ->join('salon_view', 'salon_view.salon_id = horario_view.salon_id') + ->join('horario_profesor', 'horario_profesor.horario_id = horario_view.horario_id') + ->join('profesor', 'profesor.profesor_id = horario_profesor.profesor_id') + ->join('registro', '(registro.profesor_id, registro.horario_id, registro.registro_fecha_ideal) = (profesor.profesor_id, horario_view.horario_id, CURRENT_DATE)', 'LEFT') + ->where('CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin') + ->where('horario_dia = EXTRACT(DOW FROM CURRENT_DATE)') + ->where('bloque_horario.id', $_GET['bloque_horario_id']) + ->where('id_espacio_padre', $ruta['id_espacio_sgu']) + ->get('horario_view', null, '*, horario_view.horario_id, profesor.profesor_id'), + ), ], - $ruta + $ruta, ), $data ); diff --git a/auditoria.php b/auditoria.php index c36ed2a..e8a7cbe 100644 --- a/auditoria.php +++ b/auditoria.php @@ -595,7 +595,8 @@