All
This commit is contained in:
@@ -14,7 +14,8 @@ $ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
$facultad_id = $user->facultad['facultad_id'];
|
||||
$carreras = $db->query(
|
||||
"SELECT * FROM carrera
|
||||
"SELECT carrera_id, carrera_nombre, clave_carrera
|
||||
FROM carrera
|
||||
WHERE
|
||||
(facultad_id = :facultad_id OR :facultad_id IS NULL)
|
||||
ORDER BY carrera_nombre DESC",
|
||||
@@ -23,4 +24,4 @@ $carreras = $db->query(
|
||||
|
||||
// $user->print_to_log("Crea carrera", old: $_POST);
|
||||
|
||||
die(json_encode($carreras));
|
||||
die(json_encode($carreras));
|
||||
@@ -26,9 +26,14 @@ try {
|
||||
exit;
|
||||
}
|
||||
});
|
||||
// step 1: get subrutas
|
||||
$data = $db->get('facultad');
|
||||
|
||||
$data = $db->query(<<<SQL
|
||||
SELECT facultad_nombre, facultad_id, clave_dependencia
|
||||
FROM facultad
|
||||
WHERE facultad_id = :facultad_id OR :facultad_id IS NULL
|
||||
SQL
|
||||
,
|
||||
[':facultad_id' => $user->facultad['facultad_id']]
|
||||
);
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
http_response_code(405);
|
||||
|
||||
@@ -1,21 +1,41 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
$user = Login::get_user();
|
||||
if (Login::is_logged())
|
||||
$user = Login::get_user();
|
||||
else {
|
||||
header('HTTP/1.1 401 Unauthorized');
|
||||
echo json_encode(['error' => 'No se ha iniciado sesión']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php");
|
||||
extract($_POST);
|
||||
$params = ['per' => $_POST['periodo'], 'fac' => $_POST['facultad'], 'car' => $_POST['carrera']];
|
||||
|
||||
$user->print_to_log("Acceso a grupos", old: $params);
|
||||
$grupos = queryAll("SELECT DISTINCT LENGTH(GRUPO), GRUPO FROM fs_horario_basic WHERE PERIODO_ID = COALESCE(:per, PERIODO_ID) AND FACULTAD_ID = COALESCE(:fac, FACULTAD_ID) AND CARRERA_ID = COALESCE(:car, CARRERA_ID) ORDER BY LENGTH(GRUPO), GRUPO", $params);
|
||||
if (!isset($_GET['carrera_id'])) {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'error' => 'No se ha especificado una carrera'
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
|
||||
$grupos = array_map(fn ($grupo) => $grupo['grupo'], $grupos);
|
||||
$grupos = $db->query(<<<SQL
|
||||
SELECT distinct substring(horario_grupo, 7, 3)::int - 1 as horario_grupo FROM horario_view WHERE
|
||||
PERIODO_ID = :periodo_id AND
|
||||
(FACULTAD_ID = :facultad_id OR :facultad_id IS NULL) AND
|
||||
CARRERA_ID = :carrera_id
|
||||
GROUP BY horario_grupo
|
||||
ORDER BY horario_grupo ASC
|
||||
SQL,
|
||||
[
|
||||
':periodo_id' => $user->periodo_id,
|
||||
':facultad_id' => $user->facultad['facultad_id'],
|
||||
':carrera_id' => $_GET['carrera_id']
|
||||
]
|
||||
);
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'grupos' => $grupos
|
||||
]);
|
||||
echo json_encode(array_map(fn($grupo) => $grupo['horario_grupo'], $grupos));
|
||||
@@ -17,20 +17,34 @@ $user = unserialize($_SESSION['user']);
|
||||
// check method
|
||||
try {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (!isset($_GET['profesor_id'])) {
|
||||
if (!(isset($_GET['profesor_id']) || isset($_GET['grupo']))) {
|
||||
throw new Exception('missing parameters');
|
||||
}
|
||||
$data = $db->query(
|
||||
"SELECT *, (EXTRACT(EPOCH FROM (horario_fin - horario_hora) ) / EXTRACT(EPOCH FROM interval '15 minute'))::INT AS bloques
|
||||
if (isset($_GET['profesor_id'])) {
|
||||
$data = $db->query(
|
||||
"SELECT *, (EXTRACT(EPOCH FROM (horario_fin - horario_hora) ) / EXTRACT(EPOCH FROM interval '15 minute'))::INT AS bloques
|
||||
FROM horario_view
|
||||
JOIN horario_profesor ON horario_profesor.horario_id = horario_view.horario_id
|
||||
WHERE horario_profesor.profesor_id = :profesor_id
|
||||
AND (facultad_id = :facultad_id OR :facultad_id IS NULL)",
|
||||
[
|
||||
'profesor_id' => $_GET['profesor_id'],
|
||||
'facultad_id' => $user->facultad['facultad_id'],
|
||||
]
|
||||
);
|
||||
[
|
||||
'profesor_id' => $_GET['profesor_id'],
|
||||
'facultad_id' => $user->facultad['facultad_id'],
|
||||
]
|
||||
);
|
||||
} else if (isset($_GET['grupo'])) {
|
||||
$data = $db->query(
|
||||
"SELECT *, (EXTRACT(EPOCH FROM (horario_fin - horario_hora) ) / EXTRACT(EPOCH FROM interval '15 minute'))::INT AS bloques
|
||||
FROM horario_view
|
||||
WHERE substring(horario_grupo, 7, 3) = (CAST(:grupo AS INT) + 1)::varchar
|
||||
AND (facultad_id = :facultad_id OR :facultad_id IS NULL) AND carrera_id = :carrera_id",
|
||||
[
|
||||
'grupo' => $_GET['grupo'],
|
||||
'facultad_id' => $user->facultad['facultad_id'],
|
||||
'carrera_id' => $_GET['carrera_id'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$last_query = [
|
||||
'query' => $db->getLastQuery(),
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
extract($_POST);
|
||||
# print_r($_POST); exit;
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(header('Location: index.php'));
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
if (($access = $user->access('asistencia')) == 'n')
|
||||
die(json_encode(['error' => true]));
|
||||
|
||||
$user->print_to_log('Consultar materias');
|
||||
$materias = queryAll(
|
||||
"SELECT id, nombre FROM FS_MATERIA WHERE carrera = COALESCE(:carrera, carrera) ORDER BY nombre",
|
||||
[':carrera' => empty($carrera) ? null : $carrera]
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
$facultad_id = $user->facultad['facultad_id'];
|
||||
$materias = $db->query(<<<SQL
|
||||
SELECT materia_id, materia_nombre, clave_materia, materia.carrera_id
|
||||
FROM materia
|
||||
JOIN carrera USING (carrera_id)
|
||||
JOIN facultad USING (facultad_id)
|
||||
WHERE
|
||||
(facultad_id = :facultad_id OR :facultad_id IS NULL)
|
||||
ORDER BY carrera_nombre DESC
|
||||
SQL,
|
||||
array('facultad_id' => $facultad_id)
|
||||
);
|
||||
?>
|
||||
|
||||
<?= json_encode([
|
||||
'status' => 'success',
|
||||
'materias' => $materias,
|
||||
]); ?>
|
||||
// $user->print_to_log("Crea carrera", old: $_POST);
|
||||
|
||||
die(json_encode($materias));
|
||||
36
action/carrera.php
Normal file
36
action/carrera.php
Normal 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()
|
||||
]);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ try {
|
||||
->join('puesto_usuario', 'puesto_usuario.usuario_id = usuario.usuario_id', 'LEFT')
|
||||
->getOne('usuario', ['usuario.usuario_id', 'usuario_nombre', 'usuario_clave']),
|
||||
),
|
||||
$db->orderBy('puesto_id', 'desc')
|
||||
$db->orderBy('puesto.nombre', 'desc')
|
||||
->where('facultad_id', $facultad_id)
|
||||
->get(tableName: 'puesto', numRows: count($carreras), columns: 'puesto_id, nombre'),
|
||||
);
|
||||
@@ -61,7 +61,7 @@ try {
|
||||
$raw_input = file_get_contents('php://input');
|
||||
$input_data = json_decode($raw_input, true);
|
||||
|
||||
if (!$input_data || !isset($input_data['puesto_id'], $input_data['materias'], $input_data['usuario_id'])) {
|
||||
if (!$input_data || !isset($input_data['puesto_id'], $input_data['materias'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Datos inválidos']);
|
||||
exit();
|
||||
@@ -77,10 +77,11 @@ try {
|
||||
]);
|
||||
}
|
||||
|
||||
$db->insert('puesto_usuario', [
|
||||
'puesto_id' => $input_data['puesto_id'],
|
||||
'usuario_id' => $input_data['usuario_id'],
|
||||
]);
|
||||
if (isset($input_data['usuario_id']))
|
||||
$db->insert('puesto_usuario', [
|
||||
'puesto_id' => $input_data['puesto_id'],
|
||||
'usuario_id' => $input_data['usuario_id'],
|
||||
]);
|
||||
|
||||
echo json_encode(['msg' => 'Puesto actualizado exitosamente']);
|
||||
break;
|
||||
@@ -95,7 +96,7 @@ try {
|
||||
exit();
|
||||
}
|
||||
|
||||
$db->where('puesto_id', $input_data['puesto_id'])->delete('puestos');
|
||||
$db->where('puesto_id', $input_data['puesto_id'])->delete('puesto');
|
||||
echo json_encode(['msg' => 'Puesto eliminado exitosamente']);
|
||||
break;
|
||||
|
||||
|
||||
@@ -7,12 +7,14 @@ $ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
$user = Login::get_user();
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
$pag = "../reposiciones_autorizar.php";
|
||||
|
||||
|
||||
|
||||
if(!isset($_POST["id"]) || !isset($_POST["edo"]) ){
|
||||
header("Location: ".$pag."?error=0");
|
||||
exit();
|
||||
@@ -21,30 +23,31 @@ if(!isset($_POST["id"]) || !isset($_POST["edo"]) ){
|
||||
$id_repo = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$edo = filter_input(INPUT_POST, "edo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
$salon = trim(filter_input(INPUT_POST, "salon", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
|
||||
$salon = filter_input(INPUT_POST, "salon", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
$motivo = "";
|
||||
if(isset($_POST["motivo"]) && $_POST["motivo"] != "")
|
||||
$motivo = trim($_POST["motivo"]);
|
||||
|
||||
if($edo == 4){//cancelación
|
||||
$motivo = "";
|
||||
if(isset($_POST["motivo"]) && $_POST["motivo"] != "")
|
||||
$motivo = trim($_POST["motivo"]);
|
||||
$db->querySingle('SELECT fu_reposicion_cancela(:id, :motivo)',
|
||||
[':id' => $id_repo, ':motivo' => $motivo]
|
||||
);
|
||||
}else{
|
||||
if(!empty($salon)){
|
||||
$db->querySingle('SELECT fu_reposicion(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)',
|
||||
$db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':sal' => $salon, ':edo' => $edo]
|
||||
);
|
||||
}else{
|
||||
$db->querySingle('SELECT fu_reposicion(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)',
|
||||
$db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':edo' => $edo]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtener datos del usuario que creó la reposición y mandar correo
|
||||
/*$stmt = $pdo->prepare('Select * from fs_reposicion(:id, :periodo, NULL, NULL, NULL, NULL, NULL, 0, 1)');
|
||||
/*$stmt = $pdo->prepare('Select * from
|
||||
:id, :periodo, NULL, NULL, NULL, NULL, NULL, 0, 1)');
|
||||
$stmt->bindParam(":id", $id_repo);
|
||||
$stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
|
||||
if(!$stmt->execute()){
|
||||
|
||||
@@ -7,17 +7,20 @@ $ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
$user = Login::get_user();
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
//--- Objeto para validar usuario. El id de usuario lo lee desde sesión
|
||||
if(!isset($_POST["id"], $_POST["prof"])){
|
||||
if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información necesaria.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$prof = $user["id"];
|
||||
$creador = $user->user["id"];
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fd_reposicion(:id, :prof)', [":id"=> $id, ":prof"=>$prof]);
|
||||
$db->query('SELECT * from fd_reposicion_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]);
|
||||
$return["ok"] = "La reposición se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
|
||||
@@ -55,7 +55,17 @@ $user = unserialize($_SESSION['user']);
|
||||
$return["materia"] = $rs["materia_id"];
|
||||
$return["materia_desc"] = $rs["materia_nombre"];
|
||||
$return["salon"] = $rs["salon_id"];
|
||||
$return["salon_desc"] = $rs["salon"]=="" ? "-Pendiente-": $rs["salon"];
|
||||
if($rs["salon_id"]==""){
|
||||
$return["salon_desc"] = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$return["salon_desc"] = join(" / ",$salon_json);
|
||||
}
|
||||
|
||||
//$return["salon_desc"] = $rs["salon"]=="" ? "-Pendiente-": $rs["salon"];
|
||||
$return["ciclo"] = $rs["ciclo"];
|
||||
$return["bloque"] = $rs["bloque"];
|
||||
$return["profesor"] = $rs["profesor_id"];
|
||||
@@ -69,6 +79,7 @@ $user = unserialize($_SESSION['user']);
|
||||
$return["dia"] = date('w', strtotime($rs["fecha_clase"]));
|
||||
$return["motivo_cancelacion"] = $rs["motivo_cancelacion"];
|
||||
$return["estado"] = $rs["estado_reposicion_id"];
|
||||
$return["facultad"] = $rs["facultad_nombre"];
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
|
||||
@@ -60,7 +60,6 @@ try {
|
||||
'reposicion_hora',
|
||||
'salon_reposicion.salon as reposicion_salon',
|
||||
];
|
||||
|
||||
$data = array_map(
|
||||
fn($ruta) => array_merge(
|
||||
[
|
||||
@@ -77,6 +76,8 @@ try {
|
||||
->where('horario_dia = EXTRACT(DOW FROM CURRENT_DATE)')
|
||||
->where('bloque_horario.id', $_GET['bloque_horario_id'])
|
||||
->where('salon_view.id_espacio_padre', $ruta['id_espacio_sgu'])
|
||||
->orderBy('horario_hora')
|
||||
->orderBy('salon_view.salon')
|
||||
->get(
|
||||
'horario_view',
|
||||
columns: $columns
|
||||
|
||||
28
action/usuarios.php
Normal file
28
action/usuarios.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
$facultad_id = $user->facultad['facultad_id'];
|
||||
$materias = $db->query(<<<SQL
|
||||
SELECT usuario_id, usuario_nombre, usuario_clave
|
||||
FROM usuario
|
||||
WHERE
|
||||
(facultad_id = :facultad_id OR :facultad_id IS NULL)
|
||||
ORDER BY usuario_nombre ASC
|
||||
SQL,
|
||||
array('facultad_id' => $facultad_id)
|
||||
);
|
||||
|
||||
// $user->print_to_log("Crea carrera", old: $_POST);
|
||||
|
||||
die(json_encode($materias));
|
||||
Reference in New Issue
Block a user