action_profesor_faltas.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. $ruta = "../";
  3. require_once "../include/bd_pdo.php";
  4. // die(print_r($_POST, true));
  5. extract($_POST);
  6. // if hora fin is null, then subtract half an hour from hora inicio and set hora fin to hora inicio + half an hour
  7. $hora_fin = empty($hora_fin) ? $hora_inicio : $hora_fin;
  8. $hora_inicio = date('H:i:s', strtotime($hora_inicio < '07:00' ? '07:00' : $hora_inicio) - 1800);
  9. $hora_fin = date('H:i:s', strtotime($hora_fin > '22:00' ? '22:00' : $hora_fin) + 1800);
  10. die(json_encode(
  11. array_map(fn ($row) => array_merge(
  12. $db->where('id', $row['profesor_id'])->getOne('fs_profesor'),
  13. $db->where('id', $row['materia_id'])->getOne('fs_materia'),
  14. $row
  15. ),
  16. queryAll(
  17. "SELECT REPORTE.*
  18. FROM fs_asistencia_profesorreporte(null, :periodo, null, :fecha, :fecha) AS REPORTE
  19. JOIN PROFESOR P ON P.PROFESOR_ID = REPORTE.PROFESOR_ID
  20. WHERE HORA_CHECADO IS NULL
  21. AND HORA BETWEEN :inicio AND :fin
  22. AND P.PROFESOR_CLAVE ILIKE COALESCE(:clave, P.PROFESOR_CLAVE) and UNACCENT(P.PROFESOR_NOMBRE) ILIKE UNACCENT(COALESCE(:nombre, P.PROFESOR_NOMBRE))
  23. AND FECHA = :fecha
  24. ORDER BY HORA, MATERIA",
  25. [
  26. 'periodo' => $periodo,
  27. 'fecha' => $fecha,
  28. 'inicio' => $hora_inicio,
  29. 'fin' => $hora_fin,
  30. 'clave' => empty($clave) ? null : "%$clave%",
  31. 'nombre' => empty($nombre) ? null : "%$nombre%"
  32. ]
  33. ))));
  34. #ECHO "$hora_inicio - $hora_fin";