action_auditoria.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?
  2. #input $_GET['id_espacio_sgu']
  3. #output rutas: [ ...ruta, salones: [{...salon}] ]
  4. header('Content-Type: application/json charset=utf-8');
  5. $information = [
  6. 'GET' => [
  7. #'periodo_id',
  8. ],
  9. ];
  10. $ruta = "../";
  11. require_once "../class/c_login.php";
  12. // check method
  13. try {
  14. if ($_SERVER['REQUEST_METHOD'] === 'GET') {
  15. array_walk($information['GET'], function ($value) {
  16. if (!array_key_exists($value, $_GET)) {
  17. http_response_code(400);
  18. echo json_encode(['error' => "$value is required"]);
  19. exit;
  20. }
  21. });
  22. $data = $db->query("SELECT *, horario_view.facultad_id, horario_view.periodo_id FROM registro
  23. JOIN horario_view USING (horario_id)
  24. LEFT JOIN estado_supervisor USING (estado_supervisor_id)
  25. LEFT JOIN profesor USING (profesor_id)
  26. LEFT JOIN usuario ON usuario.usuario_id = registro.supervisor_id
  27. ORDER BY registro_fecha_ideal DESC, horario_hora ASC, registro_fecha_supervisor ASC");
  28. $last_query = [
  29. 'query' => $db->getLastQuery(),
  30. ];
  31. echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
  32. } else {
  33. http_response_code(405);
  34. echo json_encode(['error' => 'method not allowed']);
  35. exit;
  36. }
  37. } catch (PDOException $th) {
  38. http_response_code(500);
  39. echo json_encode([
  40. 'error' => $th->getMessage(),
  41. 'query' => $db->getLastQuery(),
  42. ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
  43. exit;
  44. } catch (Exception $th) {
  45. http_response_code(500);
  46. echo json_encode([
  47. 'error' => $th->getMessage(),
  48. ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
  49. exit;
  50. }