Final
This commit is contained in:
@@ -19,59 +19,59 @@ $user = unserialize($_SESSION['user']);
|
|||||||
// check method
|
// check method
|
||||||
try {
|
try {
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||||
/* $db->query(<<<SQL
|
|
||||||
REFRESH MATERIALIZED VIEW CONCURRENTLY PUBLIC.AUDITORIA_MAT
|
|
||||||
SQL
|
|
||||||
); */
|
|
||||||
// pg_send_query($db->getConnection(), "REFRESH MATERIALIZED VIEW CONCURRENTLY PUBLIC.AUDITORIA_MAT");
|
// pg_send_query($db->getConnection(), "REFRESH MATERIALIZED VIEW CONCURRENTLY PUBLIC.AUDITORIA_MAT");
|
||||||
$baseDate = $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null;
|
$baseDate = $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null;
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
// ':periodo_id' => $_GET['periodo_id'] > 0 ? $user->periodo_id : null,
|
// ':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'),
|
|
||||||
'usuario_id' => $user->user['id'],
|
'usuario_id' => $user->user['id'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$db->where('usuario_id', $user->user['id'])->delete('last_auditoria');
|
||||||
|
|
||||||
|
// Define relevant columns
|
||||||
|
$relevant_columns = [
|
||||||
|
'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',
|
||||||
|
'estado_supervisor_id',
|
||||||
|
'facultad_id',
|
||||||
|
'usuario_nombre',
|
||||||
|
'registro_fecha_supervisor',
|
||||||
|
'comentario',
|
||||||
|
'registro_justificada',
|
||||||
|
'justificacion',
|
||||||
|
'reposicion_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
$relevant_columns_string = 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'));
|
||||||
|
|
||||||
$data = $db->query(
|
$data = $db->query(
|
||||||
"WITH AUDITORIA_DATA AS (
|
"SELECT $relevant_columns_string 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 (
|
ORDER BY registro_fecha_ideal, horario_hora",
|
||||||
DELETE FROM last_auditoria
|
[
|
||||||
WHERE usuario_id = :usuario_id
|
':facultad_id' => $user->facultad['facultad_id'],
|
||||||
), INSERTION AS (
|
':fecha_inicio' => $_SESSION['fecha_inicio'],
|
||||||
INSERT INTO last_auditoria
|
':fecha_fin' => $_SESSION['fecha_fin'],
|
||||||
SELECT :usuario_id, to_jsonb(AUDITORIA_DATA), registro_fecha_ideal, horario_id, profesor_id FROM AUDITORIA_DATA
|
]
|
||||||
WHERE REGISTRO_FECHA_IDEAL IS NOT NULL
|
|
||||||
)
|
|
||||||
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,
|
|
||||||
estado_supervisor_id,
|
|
||||||
facultad_id,
|
|
||||||
usuario_nombre,
|
|
||||||
registro_fecha_supervisor,
|
|
||||||
comentario,
|
|
||||||
registro_justificada,
|
|
||||||
justificacion,
|
|
||||||
reposicion_id
|
|
||||||
FROM AUDITORIA_DATA ORDER BY registro_fecha_ideal, horario_hora",
|
|
||||||
$params
|
|
||||||
);
|
);
|
||||||
// Print the JSON file
|
|
||||||
echo json_encode($data);
|
echo json_encode($data);
|
||||||
} else {
|
} else {
|
||||||
http_response_code(405);
|
http_response_code(405);
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ try {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$db->query("REFRESH MATERIALIZED VIEW CONCURRENTLY PUBLIC.AUDITORIA_MAT");
|
||||||
|
|
||||||
|
|
||||||
$data_justificador = $db->querySingle(
|
$data_justificador = $db->querySingle(
|
||||||
"SELECT justificador.usuario_nombre as justificador_nombre,
|
"SELECT justificador.usuario_nombre as justificador_nombre,
|
||||||
|
|||||||
@@ -469,8 +469,13 @@
|
|||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
<div class="pp-card" style="grid-row: span 3">
|
<div class="pp-card" style="grid-row: span 3">
|
||||||
|
<div class="bg-primary text-white"
|
||||||
|
v-if="clase_vista.registro_justificada">
|
||||||
|
<span>Justificada</span>
|
||||||
|
<i class="ing-finalistas"></i>
|
||||||
|
</div>
|
||||||
<div class="bg-warning text-white"
|
<div class="bg-warning text-white"
|
||||||
v-if="clase_vista.registro_fecha && clase_vista.registro_retardo">
|
v-else-if="clase_vista.registro_fecha && clase_vista.registro_retardo">
|
||||||
<span>Con retardo</span>
|
<span>Con retardo</span>
|
||||||
<i class="ing-retardo"></i>
|
<i class="ing-retardo"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,43 +21,16 @@ $profesor_clave = isset($params['profesor'])
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
$data = $db->query(
|
$data = $db->query(
|
||||||
"SELECT DISTINCT
|
"SELECT * FROM auditoria_mat
|
||||||
auditoria->>'registro_fecha_ideal' as registro_fecha_ideal,
|
WHERE facultad_id = COALESCE(:facultad_id, facultad_id)
|
||||||
auditoria->>'profesor_clave' as profesor_clave,
|
AND profesor_clave = COALESCE(:profesor_clave, profesor_clave)
|
||||||
auditoria->>'profesor_nombre' as profesor_nombre,
|
AND REGISTRO_FECHA_IDEAL + HORARIO_HORA between :fecha_inicio AND :fecha_fin
|
||||||
NULLIF(auditoria->>'profesor_correo', '') as profesor_correo,
|
ORDER BY REGISTRO_FECHA_IDEAL, HORARIO_HORA",
|
||||||
auditoria->>'facultad' as facultad,
|
|
||||||
auditoria->>'materia' as materia,
|
|
||||||
auditoria->>'carrera' as carrera,
|
|
||||||
NULLIF(auditoria->>'horario_grupo', '') as horario_grupo,
|
|
||||||
auditoria->>'horario_hora_completa' as horario_hora_completa,
|
|
||||||
auditoria->>'salon' as salon,
|
|
||||||
(
|
|
||||||
SELECT string_agg(value, ' / ' ORDER BY value)
|
|
||||||
FROM jsonb_array_elements_text(auditoria->'salon_array') AS value
|
|
||||||
) 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->>'estado_supervisor_id')::integer as estado_id,
|
|
||||||
(auditoria->>'registro_retardo')::BOOLEAN as registro_retardo
|
|
||||||
FROM last_auditoria
|
|
||||||
-- JOIN BLOQUE_HORARIO ON ((auditoria->>'horario_hora')::TIME, (auditoria->>'horario_fin')::TIME) OVERLAPS (HORA_INICIO, HORA_FIN)
|
|
||||||
WHERE USUARIO_ID = :usuario_id
|
|
||||||
AND auditoria->>'facultad_id' = COALESCE(:facultad_id, auditoria->>'facultad_id')
|
|
||||||
AND auditoria->>'profesor_clave' = COALESCE(:profesor_clave, auditoria->>'profesor_clave')
|
|
||||||
/*AND BLOQUE_HORARIO.ID = COALESCE(:bloque_horario_id, BLOQUE_HORARIO.ID)*/",
|
|
||||||
[
|
[
|
||||||
'usuario_id' => $user->user['id'],
|
|
||||||
'facultad_id' => $params['facultad_id'],
|
'facultad_id' => $params['facultad_id'],
|
||||||
'profesor_clave' => $profesor_clave,
|
'profesor_clave' => $profesor_clave,
|
||||||
/* 'bloque_horario_id' => $params['bloque_horario'] */
|
'fecha_inicio' => $_SESSION['fecha_inicio'],
|
||||||
|
'fecha_fin' => $_SESSION['fecha_fin'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -65,7 +38,7 @@ $estados = empty($params['estados']) ? null : $params['estados'];
|
|||||||
|
|
||||||
$data = array_filter(
|
$data = array_filter(
|
||||||
$data,
|
$data,
|
||||||
fn($fila) => in_array($fila['estado_id'], $estados ?? [$fila['estado_id']])
|
fn($registro) => in_array($registro['estado_supervisor_id'], $estados ?? [$registro['estado_supervisor_id']])
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = array_values($data);
|
$data = array_values($data);
|
||||||
@@ -192,12 +165,12 @@ function getFormattedValue($key, $registro)
|
|||||||
{
|
{
|
||||||
return match ($key) {
|
return match ($key) {
|
||||||
'asistencia' => $registro['registro_fecha'] === null
|
'asistencia' => $registro['registro_fecha'] === null
|
||||||
? "Sin registro"
|
? "Sin registro"
|
||||||
: ($registro['registro_retardo'] ? "Retardo " : "Asistencia "),
|
: ($registro['registro_retardo'] ? "Retardo " : "Asistencia "),
|
||||||
'registro_fecha',
|
'registro_fecha',
|
||||||
'registro_fecha_supervisor' => $registro[$key] === null
|
'registro_fecha_supervisor' => $registro[$key] === null
|
||||||
? 'Sin registro'
|
? 'Sin registro'
|
||||||
: date('H:i', strtotime($registro[$key])),
|
: date('H:i', strtotime($registro[$key])),
|
||||||
'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",
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ const store = reactive({
|
|||||||
'facultad_id': store.filters.facultad_id,
|
'facultad_id': store.filters.facultad_id,
|
||||||
'estados': store.filters.estados,
|
'estados': store.filters.estados,
|
||||||
'profesor': store.filters.profesor,
|
'profesor': store.filters.profesor,
|
||||||
'bloque_horario': store.filters.bloque_horario,
|
'bloque_horario': store.bloques_horario?.data.find((bloque) => bloque.id === store.filters['bloque_horario']),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const blob = await res.blob();
|
const blob = await res.blob();
|
||||||
|
|||||||
Reference in New Issue
Block a user