diff --git a/.vscode/sftp.json b/.vscode/sftp.json new file mode 100644 index 0000000..9fd1666 --- /dev/null +++ b/.vscode/sftp.json @@ -0,0 +1,12 @@ +{ + "name": "PAAD", + "host": "paad.lci.ulsa.mx", + "protocol": "sftp", + "port": 22, + "username": "miniroot", + "remotePath": "/saa_dsk/www", + "uploadOnSave": false, + "useTempFile": false, + "openSsh": false, + "password": "T4nP0d3r0s1s1m0##" +} diff --git a/action/action_auditoria.php b/action/action_auditoria.php index 3aae895..00572af 100644 --- a/action/action_auditoria.php +++ b/action/action_auditoria.php @@ -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,48 @@ 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 + ), DELETION AS ( + DELETE FROM last_auditoria + WHERE usuario_id = :usuario_id + ), INSERTION AS ( + INSERT INTO last_auditoria + SELECT :usuario_id, to_jsonb(AUDITORIA_DATA) 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, + 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']); diff --git a/action/action_auditoria_detalle.php b/action/action_auditoria_detalle.php new file mode 100644 index 0000000..824237b --- /dev/null +++ b/action/action_auditoria_detalle.php @@ -0,0 +1,48 @@ + 'unauthorized'])); +} +$user = unserialize($_SESSION['user']); + +// check method +try { + if ($_SERVER['REQUEST_METHOD'] === 'GET') { + + $data = $db + ->where('registro_fecha_ideal', $_GET['registro_fecha_ideal']) + ->where('horario_id', $_GET['horario_id']) + ->where('profesor_id', $_GET['profesor_id']) + ->getOne('auditoria_mat'); + // Print the JSON file + echo json_encode(array_merge($data, ['query' => $db->getLastQuery(), 'get' => $_GET])); + } else { + http_response_code(405); + echo json_encode(['error' => 'method not allowed']); + exit; + } +} catch (PDOException $th) { + http_response_code(500); + echo json_encode([ + 'error' => $th->getMessage(), + // 'query' => $db->getLastQuery(), + ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR); + exit; +} catch (Exception $th) { + http_response_code(500); + echo json_encode([ + 'error' => $th->getMessage(), + ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); + exit; +} \ No newline at end of file diff --git a/auditoria.php b/auditoria.php index 5da539d..aec8de1 100644 --- a/auditoria.php +++ b/auditoria.php @@ -13,6 +13,7 @@ display: none; } + @@ -261,25 +262,30 @@ :class="{ 'table-warning': registro.reposicion_id }"> {{ registro.registro_fecha_ideal }} - {{ registro.salon }} - - {{ registro.profesor_clave }} - {{ registro.profesor_nombre }} - + {{ + `${registro.salon?.slice(0,15)}${registro.salon?.length > 15 ? '...' : ''}` }} + +
+ + {{ registro.profesor_clave }} + {{ registro.profesor_nombre }} + + + + +
- {{ registro.horario_hora?.slice(0,5) }} - - {{registro.horario_fin?.slice(0,5) }} - + + {{ `${registro.horario_hora?.slice(0,5)} - ${registro.horario_fin?.slice(0,5)}` }} +
- Registro {{ registro.registro_fecha?.slice(11,19) }} + Registro {{ `${registro.registro_fecha?.slice(11,19)}` }}
@@ -299,21 +305,22 @@ - {{ registro.usuario_nombre - }} + + {{ registro.usuario_nombre }} +
Hora - {{ registro.registro_fecha_supervisor?.slice(11,19) }} + {{ `${registro.registro_fecha_supervisor?.slice(11,19)}` }}
Observaciones: - {{registro.comentario?.slice(0,25)}}{{registro.comentario.length - > 10 ? '...' : ''}} + {{`${registro.comentario?.slice(0,25)} + ${registro.comentario.length + > 25 ? '...' : ''}`}}
@@ -389,165 +396,99 @@