123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?
- #input $_GET['id_espacio_sgu']
- #output rutas: [ ...ruta, salones: [{...salon}] ]
- header('Content-Type: application/json charset=utf-8');
- $information = [
- 'GET' => [
- #'periodo_id',
- ],
- ];
- $ruta = "../";
- require_once "../class/c_login.php";
- // 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("SELECT *, horario_view.facultad_id, horario_view.periodo_id FROM registro
- JOIN horario_view USING (horario_id)
- LEFT JOIN estado_supervisor USING (estado_supervisor_id)
- LEFT JOIN profesor USING (profesor_id)
- LEFT JOIN usuario ON usuario.usuario_id = registro.supervisor_id
- ORDER BY registro_fecha_ideal DESC, horario_hora ASC, registro_fecha_supervisor ASC");
- $last_query = [
- 'query' => $db->getLastQuery(),
- ];
- echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
- } else {
- http_response_code(405);
- echo json_encode(['error' => 'method not allowed']);
- exit;
- }
- } catch (PDOException $th) {
- http_response_code(500);
- echo json_encode([
- 'error' => $th->getMessage(),
- 'query' => $db->getLastQuery(),
- ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
- exit;
- } catch (Exception $th) {
- http_response_code(500);
- echo json_encode([
- 'error' => $th->getMessage(),
- ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
- exit;
- }
|