Sfoglia il codice sorgente

Corrección de periodo

Alejandro Rosales 1 anno fa
parent
commit
857baa0163
2 ha cambiato i file con 5 aggiunte e 7 eliminazioni
  1. 1 1
      action/action_auditoria.php
  2. 4 6
      js/auditoría.js

+ 1 - 1
action/action_auditoria.php

@@ -22,7 +22,7 @@ try {
         $baseDate = $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null;
 
         $params = [
-            ':periodo_id' => $_GET['periodo_id'] == 1 ? $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'),

+ 4 - 6
js/auditoría.js

@@ -198,17 +198,15 @@ const store = reactive({
             // if (!store.filters.facultad_id || !store.filters.periodo_id) return
             this.loading = true;
             this.data = [];
-            const params = {
-                facultad_id: 19,
-                periodo_id: 2,
-            };
+            const params = {};
             if (fecha)
                 params['fecha'] = fecha;
             if (fecha_inicio)
                 params['fecha_inicio'] = fecha_inicio;
             if (fecha_fin)
                 params['fecha_fin'] = fecha_fin;
-            params['periodo_id'] = store.filters.todos_los_periodos ? 1 : 0;
+            params['periodo_id'] = store.filters.todos_los_periodos ? 0 : store.periodo.periodo_id;
+            console.log(store.periodo);
             const paramsUrl = new URLSearchParams(params).toString();
             try {
                 const res = await fetch(`action/action_auditoria.php?${paramsUrl}`, {
@@ -335,12 +333,12 @@ createApp({
     async mounted() {
         $('div.modal#cargando').modal('show');
         try {
+            store.periodo = await fetch('action/periodo_datos.php').then(res => res.json());
             // await store.registros.fetch()
             await store.facultades.fetch();
             await store.estados.fetch();
             await store.bloques_horario.fetch();
             await store.filters.switchFechas();
-            store.periodo = await fetch('action/periodo_datos.php').then(res => res.json());
             this.profesores = await (await fetch('action/action_profesor.php')).json();
             this.messages.push({ title: 'Datos cargados', text: 'Los datos se han cargado correctamente', type: 'success', timestamp: new Date() });
         }