From e1f3d21b8348889c9f67a94324e37981ece80914 Mon Sep 17 00:00:00 2001 From: Alejandro Rosales Date: Tue, 15 Aug 2023 15:58:14 +0000 Subject: [PATCH] =?UTF-8?q?Redistribuci=C3=B3n=20de=20periodo=20a=20period?= =?UTF-8?q?o=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action/action_auditoria.php | 38 +- action/action_periodousuario_update.php | 13 +- action/periodo_datos.php | 44 + alta_de_horario.php | 4 +- auditoría.php | 275 ++-- class/c_login.php | 6 +- consultar_horario.php | 1553 +---------------------- consultar_horario_old.php | 395 ++++++ excel_horario.php | 2 +- horario_profesor.php | 4 +- import/html_forms_asistencia.php | 4 +- import/html_forms_vista.php | 8 +- import/periodo.php | 8 +- js/auditoría.js | 16 +- js/consultar_horarios.js | 4 +- justificar_asistencias.php | 4 +- log/asistencias_2023_08.log | 56 + reporte_de_asistencias.php | 2 +- reposiciones.php | 8 +- ts/auditoría.ts | 43 +- vista_profesor.php | 6 +- 21 files changed, 762 insertions(+), 1731 deletions(-) create mode 100644 action/periodo_datos.php create mode 100644 consultar_horario_old.php diff --git a/action/action_auditoria.php b/action/action_auditoria.php index 2a31bcf..fdbe8dd 100644 --- a/action/action_auditoria.php +++ b/action/action_auditoria.php @@ -2,29 +2,24 @@ #input $_GET['id_espacio_sgu'] #output rutas: [ ...ruta, salones: [{...salon}] ] header('Content-Type: application/json charset=utf-8'); -$information = [ - 'GET' => [ - #'periodo_id', - ], -]; +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); + $ruta = "../"; -require_once "../class/c_login.php"; +require_once $ruta . "class/c_login.php"; +if (!isset($_SESSION['user'])) { + http_response_code(401); + die(json_encode(['error' => 'unauthorized'])); +} +$user = unserialize($_SESSION['user']); + // check method try { - - if ($_SERVER['REQUEST_METHOD'] === 'GET') { - array_walk($information['GET'], function ($value) { - if (!array_key_exists($value, $_GET)) { - http_response_code(400); - echo json_encode(['error' => "$value is required"]); - exit; - } - }); - $data = $db->query( "WITH horarios AS ( - SELECT * FROM horario_view WHERE (periodo_id, facultad_id) = (:periodo_id, :facultad_id) + SELECT * FROM horario_view WHERE (periodo_id, facultad_id) = (:periodo_id, COALESCE(:facultad_id, facultad_id)) ), fechas AS ( SELECT fechas_clase(h.horario_id) as registro_fecha_ideal, h.horario_id @@ -37,10 +32,11 @@ try { JOIN profesor using (profesor_id) LEFT JOIN registro USING (horario_id, registro_fecha_ideal, profesor_id) left join estado_supervisor using (estado_supervisor_id) - LEFT JOIN USUARIO ON USUARIO.usuario_id = REGISTRO.supervisor_id", + LEFT JOIN USUARIO ON USUARIO.usuario_id = REGISTRO.supervisor_id + ORDER BY fechas.registro_fecha_ideal DESC, horarios.horario_id, profesor_nombre", [ - ':periodo_id' => $_GET['periodo_id'], - ':facultad_id' => $_GET['facultad_id'], + ':periodo_id' => $user->periodo_id, + ':facultad_id' => $user->facultad['facultad_id'], ] ); @@ -53,9 +49,7 @@ try { http_response_code(405); echo json_encode(['error' => 'method not allowed']); exit; - } - } catch (PDOException $th) { http_response_code(500); echo json_encode([ diff --git a/action/action_periodousuario_update.php b/action/action_periodousuario_update.php index 279b774..f02e8c7 100644 --- a/action/action_periodousuario_update.php +++ b/action/action_periodousuario_update.php @@ -9,19 +9,10 @@ if (!isset($_SESSION['user'])) { $user = unserialize($_SESSION['user']); $params = array(':id' => $user->user['id'], ':per' => $_POST['id']); -$user->print_to_log('Actualizando periodo from ' . $user->periodo . ' to ' . $_POST['id']); +$user->print_to_log('Actualizando periodo from ' . $user->periodo_id . ' to ' . $_POST['id']); query("SELECT FU_UPDATEPERIODO(:id, :per)", $params); -$user->periodo = $params[':per']; - -# if the user is admin, also update the facultad in user object -if ($user->admin) { - $facultad = query("SELECT FACULTAD_ID id, FACULTAD f FROM FS_PERIODO WHERE ID = :id", [':id' => $user->periodo]); - $user->facultad = array( - 'facultad_id' => $facultad["id"], - 'facultad' => $facultad["f"], - ); -} +$user->periodo_id = $params[':per']; $_SESSION['user'] = serialize($user); header("Location: {$_POST["target"]}"); diff --git a/action/periodo_datos.php b/action/periodo_datos.php new file mode 100644 index 0000000..7da8339 --- /dev/null +++ b/action/periodo_datos.php @@ -0,0 +1,44 @@ + 'unauthorized'])); +} +$user = unserialize($_SESSION['user']); +// check method +if ($_SERVER['REQUEST_METHOD'] !== 'GET') { + http_response_code(405); + die(json_encode(['error' => 'method not allowed'])); +} + +const JSON_OPTIONS = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR; +try { + $data = $db->querySingle("SELECT *, LEAST(periodo_fecha_fin, CURRENT_DATE) as fecha_final FROM periodo WHERE periodo_id = ?", array($user->periodo_id)); + $last_query = [ + 'query' => $db->getLastQuery(), + ]; + + echo json_encode($data, JSON_OPTIONS); +} catch (PDOException $th) { + http_response_code(500); + echo json_encode([ + 'error' => $th->getMessage(), + 'query' => $db->getLastQuery(), + ], JSON_OPTIONS); + exit; +} catch (Exception $th) { + http_response_code(500); + echo json_encode([ + 'error' => $th->getMessage(), + ], JSON_OPTIONS); + exit; +} \ No newline at end of file diff --git a/alta_de_horario.php b/alta_de_horario.php index 82e9116..4c88fdc 100644 --- a/alta_de_horario.php +++ b/alta_de_horario.php @@ -41,7 +41,7 @@ $user->print_to_log('Consultar: Alta de horario');
where('id', $user->periodo)->getOne('fs_periodo'); + $periodo = $db->where('id', $user->periodo_id)->getOne('fs_periodo'); $carreras = $db ->where('nivel', $periodo['nivel_id']) ->where('facultad', $user->facultad['facultad_id']) @@ -236,7 +236,7 @@ require_once("js/messages.php") formData.append('carrera', carrera); formData.append('facultad', facultad); - formData.append('periodo', periodo ?>); + formData.append('periodo', periodo_id ?>); formData.append('data', JSON.stringify(datum)); diff --git a/auditoría.php b/auditoría.php index ea33f11..33771a1 100644 --- a/auditoría.php +++ b/auditoría.php @@ -13,6 +13,9 @@ display: none; } + + + @@ -25,18 +28,39 @@ "Sistema de gestión de checador", ); ?> + + periodo_id) { ?> + + + + + + +
- -
- -
-
+ + +
+
+ facultad['facultad_id']) { ?>
@@ -56,124 +80,147 @@
+ +
+
+ +
+
+ +
-
- -
-
- -
-
-
-
- -
+
+
+
+
-
-
- -
+
+
+
-
- -
-
-
- Seleccione un bloque horario -
+
+
+ +
+
+
+ Seleccione un bloque horario +
+ +
    +
  • + Todos los bloques horarios +
  • + +
  • + Mañana +
  • + +
  • + {{ bloque.hora_inicio.substr(0,5) }} - {{ bloque.hora_fin.substr(0,5) }} +
  • +
  • + Tarde +
  • +
  • + {{ bloque.hora_inicio.substr(0,5) }} - {{ bloque.hora_fin.substr(0,5) }} +
  • + +
+ +
+
+
+
+ +
+
+ + +
+ + +
+
+
+ +
+
+
+
Selecciona un estado de asistencia
  • - Todos los bloques horarios + @click="store.filters.estados = []; store.current.page = 1;"> + Todos los registros
  • +
  • + + {{estado.nombre}} +
  • -
  • - Mañana -
  • - -
  • - {{ bloque.hora_inicio.substr(0,5) }} - {{ bloque.hora_fin.substr(0,5) }} -
  • -
  • - Tarde -
  • -
  • - {{ bloque.hora_inicio.substr(0,5) }} - {{ bloque.hora_fin.substr(0,5) }} -
  • -
- +
-
-
-
- -
-
- - -
- - -
-
-
- -
-
-
-
Selecciona un estado de asistencia
- -
    -
  • - Todos los registros -
  • -
  • - {{estado.nombre}} -
  • -
- + +
+
+ + + + + Sin registro + +
+
-
@@ -471,14 +518,12 @@
- - - + - + \ No newline at end of file diff --git a/class/c_login.php b/class/c_login.php index b6205a7..9f54dbe 100644 --- a/class/c_login.php +++ b/class/c_login.php @@ -19,7 +19,7 @@ require_once($ruta ?? '') . "vendor/autoload.php"; class Login { public string $acceso; - public function __construct(public array $user, public array $facultad, public array $rol, public bool $admin, public ?int $periodo, public bool $supervisor, public bool $jefe_carrera, public bool $profesor) + public function __construct(public array $user, public array $facultad, public array $rol, public bool $admin, public ?int $periodo_id, public bool $supervisor, public bool $jefe_carrera, public bool $profesor) { } public function print_to_log(string $desc, array $old = null, array $new = null): void @@ -111,7 +111,7 @@ class Login $periodo = $fs_validaclaveulsa["periodo_id"]; return new Login($user, $facultad, $rol, $admin, $periodo, $supervisor, $jefe_carrera, false); - } else if ($db->where('profesor_clave', preg_replace('/^do0*/', '', $user), 'ilike')->has("profesor")) { + } else if ($db->where('profesor_clave', preg_replace('/^do0*/', '', $user), 'ilike')->has("profesor")) { $profesor = $db->where('profesor_clave', preg_replace('/^do0*/', '', $user), 'ilike')->getOne("profesor"); $user = array( 'id' => $profesor["profesor_clave"], @@ -128,7 +128,7 @@ class Login // CREATE A COOKIE FOR THE REST OF THE day for example: 23:00 then duration will be 1 hour setcookie("profesor", $user["id"], strtotime('today midnight') + 86400, "/"); - return new Login($user, $facultad, $rol, admin: false, periodo: null, supervisor: false, jefe_carrera: false, profesor: true); + return new Login($user, $facultad, $rol, admin: false, periodo_id: null, supervisor: false, jefe_carrera: false, profesor: true); } else return [ 'error' => true, diff --git a/consultar_horario.php b/consultar_horario.php index 46b97d0..4c0b0f7 100644 --- a/consultar_horario.php +++ b/consultar_horario.php @@ -18,12 +18,15 @@ $write = $user->admin || in_array($user->acceso, ['w']); Consultar horario | - <?= $user->facultad['facultad'] ?? 'General' ?> + <?= $user->facultad['facultad'] ?> + + + @@ -34,7 +37,7 @@ $write = $user->admin || in_array($user->acceso, ['w']); html_header("Consultar horario", "Sistema de gestión de checador"); ?> " ?> -
+
@@ -42,63 +45,7 @@ $write = $user->admin || in_array($user->acceso, ['w']);
- $user->facultad['facultad_id'], ":per" => $user->periodo], single: false); - // repliaction of the query in the database with database class - $nivel = $user->periodo ? $db->where('id', $user->periodo)->getOne('fs_periodo') : false; - $carreras = $nivel ? $db - ->orderBy('carrera') - ->where('facultad', $nivel['facultad_id']) - ->where('nivel', $nivel['nivel_id']) - ->get('fs_carrera', 100, 'id, carrera') : []; - - ?> -
- -
-
-
Seleccionar carrera
- -
    - -
  • - -
  • - -
- -
-
-
- - - -
- -
-
-
Seleccionar grupo
- -
    -
- -
-
-
- -
- - - -
@@ -126,1488 +73,24 @@ $write = $user->admin || in_array($user->acceso, ['w']); Sábado - + + + 7:00 + Hola + Hola + Hola + Hola + Hola + Hola + +
- - - - - + - - - + - - \ No newline at end of file diff --git a/consultar_horario_old.php b/consultar_horario_old.php new file mode 100644 index 0000000..dbd7bd5 --- /dev/null +++ b/consultar_horario_old.php @@ -0,0 +1,395 @@ +access(); +if (!$user->admin && in_array($user->acceso, ['n'])) + die(header('Location: main.php?error=1')); + +$user->print_to_log('Consultar horario'); + +$write = $user->admin || in_array($user->acceso, ['w']); +// var_dump($user); +?> + + + + + Consultar horario | + <?= $user->facultad['facultad'] ?? 'General' ?> + + + + + + + + + + + " ?> +
+
+ + + + +
+
+ $user->facultad['facultad_id'], ":per" => $user->periodo_id], single: false); + // repliaction of the query in the database with database class + $nivel = $user->periodo_id ? $db->where('id', $user->periodo_id)->getOne('fs_periodo') : false; + + $carreras = $nivel ? $db + ->orderBy('carrera') + ->where('facultad', $nivel['facultad_id']) + ->where('nivel', $nivel['nivel_id']) + ->get('fs_carrera', 100, 'id, carrera') : []; + + ?> +
+ +
+
+
Seleccionar carrera
+ +
    + +
  • + +
  • + +
+ +
+
+
+ + + +
+ +
+
+
Seleccionar grupo
+ +
    +
+ +
+
+
+ +
+ + + +
+
+
+ + + + + +
+ + + + + + + + + + + + + +
HoraLunesMartesMiércolesJuevesViernesSábado
+
+ + + + +
+ + + + + + \ No newline at end of file diff --git a/excel_horario.php b/excel_horario.php index 8a95869..b3c00e3 100644 --- a/excel_horario.php +++ b/excel_horario.php @@ -39,7 +39,7 @@ if (!$user->admin && in_array($user->acceso, ['r', 'n'])) {
$user->facultad['facultad_id'], ":per" => $user->periodo], single: false); + $carreras = query("SELECT * FROM FS_CARRERA WHERE FACULTAD = COALESCE(:fac, FACULTAD) AND PERIODO = COALESCE(:per, PERIODO) ORDER BY CARRERA", [":fac" => $user->facultad['facultad_id'], ":per" => $user->periodo_id], single: false); #die(print_r($carreras, true)); ?>
diff --git a/horario_profesor.php b/horario_profesor.php index 71d9564..aef2681 100644 --- a/horario_profesor.php +++ b/horario_profesor.php @@ -50,7 +50,7 @@ $write = $user->admin || in_array($user->acceso, ['w']);
- +
@@ -73,7 +73,7 @@ $write = $user->admin || in_array($user->acceso, ['w']); ?>
    - +
    diff --git a/import/html_forms_asistencia.php b/import/html_forms_asistencia.php index 06ebe3b..6c9623c 100644 --- a/import/html_forms_asistencia.php +++ b/import/html_forms_asistencia.php @@ -7,7 +7,7 @@ include_once "import/html_forms.php";
    where('id', $user->periodo)->getOne('fs_periodo'); + $periodo = $db->where('id', $user->periodo_id)->getOne('fs_periodo'); $carreras = $db ->where('nivel', $periodo['nivel_id']) ->where('facultad', $user->facultad['facultad_id']) @@ -81,7 +81,7 @@ include_once "import/html_forms.php"; changeMonth: true, }); $user->periodo]); + $periodo = query("SELECT * FROM FS_PERIODO WHERE ID = :periodo", [":periodo" => $user->periodo_id]); echo "// Período: {$periodo["inicio"]} - {$periodo["fin"]}\n"; echo "// Fecha inicial: " . ($fecha_inicial ?? 'n/a') . " - Fecha final: " . ($fecha_final ?? 'n/a') . "\n"; ?> diff --git a/import/html_forms_vista.php b/import/html_forms_vista.php index bd76f1b..ea3cc39 100644 --- a/import/html_forms_vista.php +++ b/import/html_forms_vista.php @@ -4,18 +4,18 @@ $target = '/checador_otros/admin_checador/reporte_de_asistencias.php'; $id = $_POST['id']; include_once "import/html_forms.php"; -$carreras = queryAll("SELECT DISTINCT carrera, id, facultad FROM FS_CARRERA WHERE ID IN (SELECT distinct CARRERA_ID FROM FS_HORARIO_BASIC WHERE :id IN (SELECT HORARIO_ID FROM HORARIO_PROFESOR WHERE PROFESOR_ID = :id) AND PERIODO_ID = :per)", [':id' => $id, ':per' => $user->periodo]); +$carreras = queryAll("SELECT DISTINCT carrera, id, facultad FROM FS_CARRERA WHERE ID IN (SELECT distinct CARRERA_ID FROM FS_HORARIO_BASIC WHERE :id IN (SELECT HORARIO_ID FROM HORARIO_PROFESOR WHERE PROFESOR_ID = :id) AND PERIODO_ID = :per)", [':id' => $id, ':per' => $user->periodo_id]); // materia por carrera #print_r($carreras); -$materias = queryAll("SELECT DISTINCT * FROM FS_MATERIA WHERE CARRERA = COALESCE(:car, CARRERA) AND ID IN (SELECT distinct materia_id FROM HORARIO WHERE :id IN (SELECT HORARIO_ID FROM HORARIO_PROFESOR WHERE PROFESOR_ID = :id) AND PERIODO_ID = :per) ORDER BY NOMBRE", [":car" => empty($carrera) ? null : $carrera, ':id' => $id, ':per' => $user->periodo]); +$materias = queryAll("SELECT DISTINCT * FROM FS_MATERIA WHERE CARRERA = COALESCE(:car, CARRERA) AND ID IN (SELECT distinct materia_id FROM HORARIO WHERE :id IN (SELECT HORARIO_ID FROM HORARIO_PROFESOR WHERE PROFESOR_ID = :id) AND PERIODO_ID = :per) ORDER BY NOMBRE", [":car" => empty($carrera) ? null : $carrera, ':id' => $id, ':per' => $user->periodo_id]); #exit(); -$periodo = query("SELECT inicio, fin FROM FS_PERIODO WHERE ID = :per", [':per' => $user->periodo]); +$periodo = query("SELECT inicio, fin FROM FS_PERIODO WHERE ID = :per", [':per' => $user->periodo_id]); ?> - +
    diff --git a/import/periodo.php b/import/periodo.php index c68341e..21ffbc9 100644 --- a/import/periodo.php +++ b/import/periodo.php @@ -1,4 +1,4 @@ - +
    @@ -37,7 +37,7 @@ array_walk($periodos_rs, function ($per) { global $user; ?> -
  • periodo == $per["periodo_id"]) { +
  • periodo_id == $per["periodo_id"]) { echo 'class="selected"'; } ?>> @@ -55,8 +55,8 @@
  • -