Datos mínimos

This commit is contained in:
Your Name
2025-01-20 09:28:19 -06:00
parent dbcbf57118
commit 70ba06120d
2 changed files with 43 additions and 17 deletions

View File

@@ -8,8 +8,8 @@ ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$ruta = "../";
require_once $ruta . "class/c_login.php";
$ruta = "..";
require_once "$ruta/class/c_login.php";
if (!isset($_SESSION['user'])) {
http_response_code(401);
die(json_encode(['error' => 'unauthorized']));
@@ -30,17 +30,44 @@ try {
// ':periodo_id' => $_GET['periodo_id'] > 0 ? $user->periodo_id : null,
':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'),
':fecha_fin' => $baseDate ? date('Y-m-d H:i:s', strtotime("$baseDate +24 hours")) : date('Y-m-d H:i:s'),
'usuario_id' => $user->user['id'],
];
$data = $db->query(
"SELECT * FROM PUBLIC.AUDITORIA_MAT
WHERE FACULTAD_ID = COALESCE(:facultad_id, FACULTAD_ID)
AND REGISTRO_FECHA_IDEAL + HORARIO_HORA between :fecha_inicio AND :fecha_fin
ORDER BY registro_fecha_ideal asc, horario_hora asc",
"WITH AUDITORIA_DATA AS (
SELECT * FROM PUBLIC.AUDITORIA_MAT
WHERE FACULTAD_ID = COALESCE(:facultad_id, FACULTAD_ID)
AND REGISTRO_FECHA_IDEAL + HORARIO_HORA between :fecha_inicio AND :fecha_fin
), INSERTION AS (
INSERT INTO last_auditoria VALUES (:usuario_id , COALESCE((
SELECT jsonb_agg(AUDITORIA_DATA) FROM AUDITORIA_DATA
), '[]'::JSONB))
ON CONFLICT (usuario_id) DO UPDATE SET auditoria = EXCLUDED.auditoria
)
SELECT
registro_id,
registro_fecha_ideal,
horario_id,
profesor_id,
salon,
profesor_clave,
profesor_nombre,
horario_hora,
horario_fin,
registro_fecha,
color,
estado_color,
estado_icon,
usuario_nombre,
registro_fecha_supervisor,
comentario,
registro_justificada,
reposicion_id
FROM AUDITORIA_DATA",
$params
);
echo json_encode(array_merge($data), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
// Print the JSON file
echo json_encode($data);
} else {
http_response_code(405);
echo json_encode(['error' => 'method not allowed']);