Browse Source

Añadir todos los periodos

Alejandro Rosales 1 năm trước cách đây
mục cha
commit
8f68e927b1
3 tập tin đã thay đổi với 11 bổ sung8 xóa
  1. 2 2
      action/action_auditoria.php
  2. 6 4
      auditoria.php
  3. 3 2
      js/auditoría.js

+ 2 - 2
action/action_auditoria.php

@@ -22,7 +22,7 @@ try {
         $baseDate = $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null;
 
         $params = [
-            ':periodo_id' => $user->periodo_id,
+            ':periodo_id' => $_GET['periodo_id'] == 1 ? $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'),
@@ -52,7 +52,7 @@ try {
                 JOIN PERIODO USING (periodo_id)
                 JOIN nivel on periodo.nivel_id = nivel.nivel_id 
                 JOIN SALON USING (salon_id)
-                WHERE (PERIODO.periodo_id, horario.facultad_id) =  (:periodo_id, COALESCE(:facultad_id, horario.facultad_id))
+                WHERE (PERIODO.periodo_id, horario.facultad_id) =  (COALESCE(:periodo_id, PERIODO.periodo_id), COALESCE(:facultad_id, horario.facultad_id))
             ),
             fechas AS (
                 SELECT fechas_clase(h.horario_id, true) as registro_fecha_ideal, h.horario_id  

+ 6 - 4
auditoria.php

@@ -88,11 +88,13 @@
                     </div>
                 </div>
                 <div class="form-group row">
-                    <!-- Botón para descargar todo -->
+                    <!-- Checkbox para descargar todo -->
                     <div class="col-12 text-center">
-                        <button type="button" class="btn btn-outline-primary" @click="store.registros.descargar">
-                            Todos los perídos activos
-                        </button>
+                        <div class="custom-control custom-checkbox">
+                            <input type="checkbox" class="custom-control-input" id="descargarTodo"
+                                v-model="store.filters.todos_los_periodos">
+                            <label class="custom-control-label" for="descargarTodo">Descargar todos los registros</label>
+                        </div>
                     </div>
                 </div>
             <? } ?>

+ 3 - 2
js/auditoría.js

@@ -99,8 +99,8 @@ const store = reactive({
         },
         printEstados() {
             if (store.filters.estados.length > 0)
-                document.querySelector('#estados').innerHTML = store.filters.estados.map((estado) => `<span class="mx-2 badge badge-${store.estados.getEstado(estado).estado_color}">
-                    <i class="${store.estados.getEstado(estado).estado_icon}"></i> ${store.estados.getEstado(estado).nombre}
+                document.querySelector('#estados').innerHTML = store.filters.estados.map((estado) => `<span class="mx-2 badge badge-${store.estados.getEstado(estado).estado_color}">
+                    <i class="${store.estados.getEstado(estado).estado_icon}"></i> ${store.estados.getEstado(estado).nombre}
                 </span>`).join('');
             else
                 document.querySelector('#estados').innerHTML = `Todos los registros`;
@@ -208,6 +208,7 @@ const store = reactive({
                 params['fecha_inicio'] = fecha_inicio;
             if (fecha_fin)
                 params['fecha_fin'] = fecha_fin;
+            params['periodo_id'] = store.filters.todos_los_periodos ? 1 : 0;
             const paramsUrl = new URLSearchParams(params).toString();
             try {
                 const res = await fetch(`action/action_auditoria.php?${paramsUrl}`, {