Commit Bulk
This commit is contained in:
@@ -1,14 +1,57 @@
|
||||
<?php
|
||||
<?
|
||||
#input $_GET['id_espacio_sgu']
|
||||
#output rutas: [ ...ruta, salones: [{...salon}] ]
|
||||
header('Content-Type: application/json charset=utf-8');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php");
|
||||
require_once $ruta . "class/c_login.php";
|
||||
if (!isset($_SESSION['user'])) {
|
||||
http_response_code(401);
|
||||
die(json_encode(['error' => 'unauthorized']));
|
||||
}
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
extract($_GET);
|
||||
// check method
|
||||
try {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$data = $db->query(
|
||||
"SELECT DISTINCT profesor.*
|
||||
FROM profesor
|
||||
JOIN horario_profesor using (profesor_id)
|
||||
JOIN horario using (horario_id)
|
||||
JOIN materia using (materia_id)
|
||||
JOIN carrera using (carrera_id)
|
||||
WHERE carrera.facultad_id = :facultad_id OR :facultad_id IS NULL
|
||||
ORDER BY profesor.profesor_nombre",
|
||||
array(
|
||||
":facultad_id" => $user->facultad['facultad_id']
|
||||
)
|
||||
);
|
||||
|
||||
$profesores = $db
|
||||
->where("facultad_id", $facultad ?? 0)
|
||||
->get("fs_profesor");
|
||||
$last_query = [
|
||||
'query' => $db->getLastQuery(),
|
||||
];
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"profesores" => $profesores
|
||||
]);
|
||||
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 | 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;
|
||||
}
|
||||
Reference in New Issue
Block a user