This commit is contained in:
2023-10-03 18:22:51 +00:00
parent 6f4ee51b55
commit c927cb02bb
22 changed files with 800 additions and 335 deletions

36
action/carrera.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
require_once "{$_SERVER['DOCUMENT_ROOT']}/class/c_login.php";
header('Content-Type: application/json');
if (!Login::is_logged()) {
header('HTTP/1.1 401 Unauthorized');
echo json_encode(['error' => 'No se ha iniciado sesión']);
exit();
}
$user = Login::get_user();
try {
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
// Fetch all puestos
$facultad_id = $user->facultad['facultad_id'];
$carreras = $db->query(<<<SQL
SELECT carrera_id, carrera_nombre, clave_carrera, facultad_id
FROM carrera
WHERE facultad_id = :facultad_id OR :facultad_id IS NULL
SQL, ['facultad_id' => $facultad_id]);
echo json_encode($carreras);
break;
default:
header('HTTP/1.1 405 Method Not Allowed');
echo json_encode(['error' => 'Método no permitido']);
break;
}
} catch (PDOException $e) {
echo json_encode([
'error' => $e->getMessage(),
'query' => $db->getLastQuery(),
'exception' => $e->getTraceAsString()
]);
}