Individual JSON's

This commit is contained in:
Your Name
2025-01-20 15:44:19 -06:00
parent 05e1f7983b
commit 37f4cc42c1
2 changed files with 35 additions and 11 deletions

View File

@@ -38,11 +38,12 @@ try {
SELECT * FROM PUBLIC.AUDITORIA_MAT SELECT * FROM PUBLIC.AUDITORIA_MAT
WHERE FACULTAD_ID = COALESCE(:facultad_id, FACULTAD_ID) WHERE FACULTAD_ID = COALESCE(:facultad_id, FACULTAD_ID)
AND REGISTRO_FECHA_IDEAL + HORARIO_HORA between :fecha_inicio AND :fecha_fin AND REGISTRO_FECHA_IDEAL + HORARIO_HORA between :fecha_inicio AND :fecha_fin
), DELETION AS (
DELETE FROM last_auditoria
WHERE usuario_id = :usuario_id
), INSERTION AS ( ), INSERTION AS (
INSERT INTO last_auditoria VALUES (:usuario_id , COALESCE(( INSERT INTO last_auditoria
SELECT jsonb_agg(AUDITORIA_DATA) FROM AUDITORIA_DATA SELECT :usuario_id, to_jsonb(AUDITORIA_DATA) FROM AUDITORIA_DATA
), '[]'::JSONB))
ON CONFLICT (usuario_id) DO UPDATE SET auditoria = EXCLUDED.auditoria
) )
SELECT SELECT
registro_id, registro_id,

View File

@@ -16,11 +16,34 @@ $user = unserialize($_SESSION['user']);
/* $json = file_get_contents('php://input'); /* $json = file_get_contents('php://input');
$data = json_decode($json, true); */ $data = json_decode($json, true); */
$query = $db $data = $db->query(
->where('usuario_id', $user->user['id']) "SELECT
->getOne('last_auditoria', 'auditoria')['auditoria']; auditoria->>'registro_fecha_ideal' as registro_fecha_ideal,
auditoria->>'profesor_clave' as profesor_clave,
$data = json_decode($query, true); auditoria->>'profesor_nombre' as profesor_nombre,
auditoria->>'profesor_correo' as profesor_correo,
auditoria->>'facultad' as facultad,
auditoria->>'materia' as materia,
auditoria->>'carrera' as carrera,
auditoria->>'horario_grupo' as horario_grupo,
auditoria->>'horario_hora_completa' as horario_hora_completa,
auditoria->>'salon' as salon,
auditoria->>'salon_array' 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->>'registro_retardo' as registro_retardo
FROM last_auditoria
WHERE auditoria->>'registro_fecha_ideal' IS NOT NULL
AND USUARIO_ID = ?",
[$user->user['id']]
);
empty($data) and die(json_encode(['error' => 'No se recibieron datos', 'data' => $data])); empty($data) and die(json_encode(['error' => 'No se recibieron datos', 'data' => $data]));