92 lines
3.3 KiB
PHP
92 lines
3.3 KiB
PHP
<?php
|
|
#input $_GET['id_espacio_sgu']
|
|
#output rutas: [ ...ruta, salones: [{...salon}] ]
|
|
header('Content-Type: application/json charset=utf-8');
|
|
ini_set('memory_limit', '2048M');
|
|
ini_set('post_max_size', '2048M');
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
|
|
$ruta = "..";
|
|
require_once "$ruta/class/c_login.php";
|
|
if (!isset($_SESSION['user'])) {
|
|
http_response_code(401);
|
|
die(json_encode(['error' => 'unauthorized']));
|
|
}
|
|
$user = unserialize($_SESSION['user']);
|
|
|
|
// check method
|
|
try {
|
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|
|
|
$data = $db->querySingle(
|
|
"SELECT
|
|
:registro_fecha_ideal as registro_fecha_ideal,
|
|
horario_hora,
|
|
horario_fin,
|
|
COALESCE(materia_asignacion.materia_asignacion_profesor, profesor.profesor_nombre) AS profesor_nombre,
|
|
profesor_correo,
|
|
profesor_clave,
|
|
horario.facultad_id,
|
|
COALESCE(materia_asignacion.materia_asignacion_materia, materia.materia_nombre) AS materia,
|
|
facultad_nombre as facultad,
|
|
COALESCE(materia_asignacion.materia_asignacion_carrera, carrera.carrera_nombre) AS carrera,
|
|
registro_fecha,
|
|
registro_fecha_supervisor,
|
|
estado_color,
|
|
estado_supervisor.estado_supervisor_id,
|
|
estado_supervisor.nombre,
|
|
estado_icon,
|
|
usuario_nombre,
|
|
horario_grupo,
|
|
registro_retardo,
|
|
registro_justificada,
|
|
justificacion,
|
|
comentario,
|
|
CASE
|
|
WHEN registro.registro_retardo THEN 'warning'
|
|
ELSE 'primary'
|
|
END AS color
|
|
FROM horario
|
|
NATURAL JOIN horario_profesor
|
|
NATURAL JOIN profesor
|
|
JOIN facultad ON facultad.facultad_id = COALESCE(horario.facultad_id, 0)
|
|
|
|
LEFT JOIN materia USING (MATERIA_ID)
|
|
LEFT JOIN carrera USING (carrera_id)
|
|
|
|
LEFT JOIN materia_asignacion USING (horario_id)
|
|
|
|
LEFT JOIN registro ON
|
|
REGISTRO.HORARIO_ID = HORARIO.HORARIO_ID AND
|
|
REGISTRO.PROFESOR_ID = HORARIO_PROFESOR.PROFESOR_ID AND
|
|
REGISTRO.REGISTRO_FECHA_IDEAL = :registro_fecha_ideal
|
|
|
|
LEFT JOIN estado_supervisor ON estado_supervisor.estado_supervisor_id = COALESCE(registro.estado_supervisor_id, 0)
|
|
LEFT JOIN usuario ON usuario_id = supervisor_id
|
|
|
|
WHERE horario.horario_id = :horario_id
|
|
AND profesor.profesor_id = :profesor_id",
|
|
$_GET
|
|
);
|
|
echo json_encode($data);
|
|
} 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 | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR);
|
|
exit;
|
|
} catch (Exception $th) {
|
|
http_response_code(500);
|
|
echo json_encode([
|
|
'error' => $th->getMessage(),
|
|
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
|
exit;
|
|
} |