Individual JSON's
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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]));
|
||||||
|
|
||||||
@@ -149,7 +172,7 @@ function getFormattedValue($key, $registro)
|
|||||||
'nombre' => $registro[$key] ?? "Sin registro",
|
'nombre' => $registro[$key] ?? "Sin registro",
|
||||||
'horario_hora_completa' => "{$registro['horario_hora']} - {$registro['horario_fin']}",
|
'horario_hora_completa' => "{$registro['horario_hora']} - {$registro['horario_fin']}",
|
||||||
'usuario_nombre' => $registro[$key] ?? "Sin registro",
|
'usuario_nombre' => $registro[$key] ?? "Sin registro",
|
||||||
'salon_array' => json_encode($registro[$key], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
|
'salon_array' => json_encode($registro[$key], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
|
||||||
'justificacion',
|
'justificacion',
|
||||||
'comentario' => $registro[$key] ?? "Sin registro",
|
'comentario' => $registro[$key] ?? "Sin registro",
|
||||||
default => $registro[$key]
|
default => $registro[$key]
|
||||||
@@ -172,7 +195,7 @@ foreach ($data as $index => $registro) {
|
|||||||
array_walk($values, function ($row, $column_index) use ($sheet, $index, $registro) {
|
array_walk($values, function ($row, $column_index) use ($sheet, $index, $registro) {
|
||||||
$value = getFormattedValue($row, $registro);
|
$value = getFormattedValue($row, $registro);
|
||||||
$cellLocation = chr(65 + $column_index) . (ROW + $index + 1);
|
$cellLocation = chr(65 + $column_index) . (ROW + $index + 1);
|
||||||
|
|
||||||
$sheet->setCellValue($cellLocation, $value);
|
$sheet->setCellValue($cellLocation, $value);
|
||||||
|
|
||||||
if ($value == "Sin registro") {
|
if ($value == "Sin registro") {
|
||||||
|
|||||||
Reference in New Issue
Block a user