This commit is contained in:
@@ -1,52 +1,52 @@
|
||||
<?
|
||||
#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 $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->query(
|
||||
'SELECT * FROM AVISO',
|
||||
[
|
||||
':facultad_id' => $user->facultad['facultad_id'],
|
||||
':fecha_inicio' => $_GET['fecha'] ?? $_GET['fecha_inicio'] ?? null,
|
||||
':fecha_fin' => $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null,
|
||||
]
|
||||
);
|
||||
|
||||
$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 | 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;
|
||||
<?
|
||||
#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 $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->query(
|
||||
'SELECT * FROM AVISO',
|
||||
[
|
||||
':facultad_id' => $user->facultad['facultad_id'],
|
||||
':fecha_inicio' => $_GET['fecha'] ?? $_GET['fecha_inicio'] ?? null,
|
||||
':fecha_fin' => $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null,
|
||||
]
|
||||
);
|
||||
|
||||
$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 | 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;
|
||||
}
|
||||
@@ -1,19 +1,30 @@
|
||||
|
||||
<?php
|
||||
$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";
|
||||
$sql = "SELECT fi_carrera(:nombre, :idfacultad, :idnivel, true, :estado)";
|
||||
$params = [':nombre' => mb_strtoupper($_POST['nombre']), ':idfacultad' => $_POST['facultad'], ':idnivel' => $_POST['nivel'], ':estado' => $_POST['estado']];
|
||||
|
||||
print_r($_POST);
|
||||
echo json_encode(query($sql, $params, true));
|
||||
$user->print_to_log("Crea carrera", new: $params);
|
||||
$nombre_carrera = mb_strtoupper($_POST['carreraCrear']);
|
||||
$facultad_id = $_POST['facultadCrear'];
|
||||
$nivel_id = $_POST['nivelCrear'];
|
||||
$clave_carrera = $_POST['nombreCarreraCrear'];
|
||||
|
||||
|
||||
$sql = "INSERT INTO public.carrera(carrera_nombre, facultad_id, nivel_id, clave_carrera, carrera_activa, carrera_comun)
|
||||
VALUES (:nombre_carrera, :facultad_id, :nivel_id, :clave_carrera, true, false)";
|
||||
|
||||
$params = [
|
||||
':nombre_carrera' => $nombre_carrera,
|
||||
':facultad_id' => $facultad_id,
|
||||
':nivel_id' => $nivel_id,
|
||||
':clave_carrera' => $clave_carrera
|
||||
];
|
||||
|
||||
$resultado = query($sql, $params, true);
|
||||
header("Location: ../carreras.php?facultad=" . $_POST['facultad']);
|
||||
exit();
|
||||
|
||||
@@ -2,15 +2,22 @@
|
||||
$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";
|
||||
$ruta = "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "SELECT * FROM fs_carreras(:idfacultad, :idcarrera, null)";
|
||||
$params = [':idfacultad' => $_POST['idfacultad'], ':idcarrera' => $_POST['idcarrera']];
|
||||
$user->print_to_log("Crea carrera", old: $params);
|
||||
echo json_encode(query($sql, $params, true));
|
||||
|
||||
|
||||
$idmateria = $_POST['idmateria'];
|
||||
|
||||
$sql = "SELECT ca.clave_carrera,ca.carrera_id, ca.carrera_nombre, f.facultad_id, n.nivel_id, n.nivel_nombre
|
||||
FROM carrera ca
|
||||
JOIN facultad f ON f.facultad_id = ca.facultad_id
|
||||
JOIN nivel n ON n.nivel_id = ca.nivel_id
|
||||
WHERE ca.carrera_id = :idmateria";
|
||||
|
||||
$params = [':idmateria' => $idmateria];
|
||||
$result = query($sql, $params, true);
|
||||
echo json_encode($result);
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
|
||||
<?php
|
||||
$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";
|
||||
$old = query("SELECT * FROM FS_CARRERA WHERE ID = :id", [':id' => $_POST['id']]);
|
||||
$sql = "SELECT fu_updatecarrera(:idcarrera, :nombre, :activa, :idnivel)";
|
||||
print_r($_POST);
|
||||
$params = [':idcarrera' => $_POST['id'], ':nombre' => mb_strtoupper($_POST['nombre']), ':activa' => $_POST['estado'], ':idnivel' => $_POST['nivel']];
|
||||
|
||||
$nombre_carrera = mb_strtoupper($_POST['carreraEditar']);
|
||||
$facultad_id = $_POST['facultadEditar'];
|
||||
$nivel_id = $_POST['nivelEditar'];
|
||||
$clave_carrera = $_POST['nombreCarreraEditar'];
|
||||
$carrera_id = $_POST['id'];
|
||||
|
||||
|
||||
$sql = "UPDATE public.carrera SET carrera_nombre=:nombre_carrera, facultad_id = :facultad_id, nivel_id = :nivel_id, clave_carrera = :clave_carrera WHERE carrera_id = :id";
|
||||
|
||||
$params = [
|
||||
':nombre_carrera' => $nombre_carrera,
|
||||
':facultad_id' => $facultad_id,
|
||||
':nivel_id' => $nivel_id,
|
||||
':clave_carrera' => $clave_carrera,
|
||||
':id' => $carrera_id
|
||||
];
|
||||
|
||||
query($sql, $params, true);
|
||||
$user->print_to_log("Actualiza carrera.", old: $old, new: $params);
|
||||
header("Location: ../carreras.php?facultad=" . $_POST['facultad']);
|
||||
exit();
|
||||
exit();
|
||||
|
||||
@@ -17,7 +17,7 @@ SELECT json_agg(json_build_object(
|
||||
'id', id,
|
||||
'hora_inicio', hora_inicio,
|
||||
'hora_fin', hora_fin,
|
||||
'selected', current_time between hora_inicio and hora_fin
|
||||
'selected', false --current_time between hora_inicio and hora_fin
|
||||
)) AS bloque_horario
|
||||
FROM bloques
|
||||
",
|
||||
|
||||
@@ -36,7 +36,7 @@ if (is_array($user)) {
|
||||
} else {
|
||||
$_SESSION['user'] = serialize($user);
|
||||
|
||||
header("Location: " . ($_SESSION['ruta'] ?? "../main.php"));
|
||||
header("Location: " . (isset($_SESSION['ruta']) ? $_SESSION['ruta'] : "../main.php"));
|
||||
}
|
||||
|
||||
exit;
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $db;
|
||||
|
||||
try {
|
||||
$db->querySingle("UPDATE usuario SET estado_baja = TRUE WHERE usuario_id = ?", [$_GET['id']]);
|
||||
header("Location: ../usuarios.php", true, 307);
|
||||
} catch (PDOException $e) {
|
||||
header("Location: ../usuarios.php?error=2");
|
||||
exit;
|
||||
}
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $db;
|
||||
|
||||
try {
|
||||
$db->querySingle("UPDATE usuario SET estado_baja = TRUE WHERE usuario_id = ?", [$_GET['id']]);
|
||||
header("Location: ../usuarios.php", true, 307);
|
||||
} catch (PDOException $e) {
|
||||
header("Location: ../usuarios.php?error=2");
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* Borra reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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"])){
|
||||
$return["error"] = "Error! No se recibió la información necesaria.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$creador = $user->user["id"];
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fd_asignacion_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]);
|
||||
$return["ok"] = "La solicitud se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al borrar la solicitud de salón.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Borra reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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"])){
|
||||
$return["error"] = "Error! No se recibió la información necesaria.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$creador = $user->user["id"];
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fd_asignacion_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]);
|
||||
$return["ok"] = "La solicitud se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al borrar la solicitud de salón.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
|
||||
@@ -1,186 +1,186 @@
|
||||
<?php
|
||||
/*
|
||||
* Inserta reposición
|
||||
*/
|
||||
$pag = "../asignacion_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
require_once "../class/mailer.php";
|
||||
|
||||
define("COORDINADOR", 9);
|
||||
define("ENVIO_CORREOS", true);
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
//$user->access();
|
||||
|
||||
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
$salon = filter_input(INPUT_POST, "salon", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", 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
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
$aula_rs = $db->querySingle("select tipoaula_nombre, tipoaula_supervisor from tipoaula where tipoaula_id = :id", [":id"=>$aula]);
|
||||
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
//-- Obtiene datos de horario regular de clase
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
|
||||
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
//Datos de dependencia de usuario
|
||||
$fac_rs = $db->querySingle("SELECT facultad_nombre, clave_dependencia from facultad where facultad_id = :id_fac",[':id_fac' => $user->facultad["facultad_id"]] );
|
||||
|
||||
$salon_desc = "Pendiente";
|
||||
if(!empty($salon)){
|
||||
$salon_rs = $db->querySingle('SELECT s.salon_id, s.salon_array FROM salon_view s where s.salon_id = :id_salon',
|
||||
[':id_salon' => $salon]
|
||||
);
|
||||
if($salon_rs["salon_id"] == "" || $salon_rs["salon_id"] == NULL){
|
||||
$salon_desc = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($salon_rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$salon_desc = join(" / ",$salon_json);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT coor.usuario_correo as coordinador_correo
|
||||
from reposicion_solicitud rs
|
||||
inner join profesor p on rs.profesor_id =p.profesor_id
|
||||
inner join usuario u on u.usuario_id = rs.usuario_id
|
||||
inner join horario_view hv on hv.horario_id = rs.horario_id
|
||||
inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord
|
||||
where hv.facultad_id = :id_fac',
|
||||
[':rol_coord' => COORDINADOR, ':id_fac' => $user->facultad["facultad_id"]]
|
||||
);
|
||||
$coord_correos=[];
|
||||
foreach($correos_rs as $correo){
|
||||
if( count($coord_correos)==0 && $correo["coordinador_correo"]!=""){
|
||||
if(!isset($coord_correos["correo"]) || !in_array($correo["coordinador_correo"], $coord_correos["correo"])){
|
||||
array_push($coord_correos, $correo["coordinador_correo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_correo as coordinador_correo
|
||||
FROM horario_supervisor hs
|
||||
inner join usuario sup on sup.usuario_id =hs.usuario_id
|
||||
where :id_fac = ANY(hs.facultad_id_array)
|
||||
and sup.usuario_correo is not null and sup.usuario_correo != ''",
|
||||
[':id_fac' => $user->facultad["facultad_id"]] );
|
||||
|
||||
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia_new, $hora, $materia, "-", $fecha_new, $fecha_fin_new, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
*/
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo en la fecha nueva
|
||||
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo]
|
||||
)["traslape_profesor_reposicion"];
|
||||
if($traslape){
|
||||
//print_r($_POST);
|
||||
//echo "SELECT * from traslape_profesor_reposicion($prof,'".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."' , '$hora', $duracion)";
|
||||
|
||||
header("Location:".$pag."?error=9");
|
||||
exit();
|
||||
}
|
||||
|
||||
try{
|
||||
$edo = 1;
|
||||
if(!$user->jefe_carrera)
|
||||
$edo = 2;
|
||||
|
||||
//echo "SELECT * from fi_asignacion_solicitud( $fecha_new, $hora, $prof, $edo, $comentario, $alumnos, $aula, $duracion_tiempo, ".$user->user["id"].")"; exit();
|
||||
$db->query('SELECT * from fi_asignacion_solicitud(:f_nueva, :hora_nueva, :prof, :edo, :desc, :alumnos, :aula, :duracion, :usr)',
|
||||
[':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':prof' => $prof, ':edo'=>$edo, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"]
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
echo $e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$asunto = "";
|
||||
$texto = "";
|
||||
$to = "";
|
||||
switch($edo){
|
||||
case 1://Correo a coordinador
|
||||
if( count($coord_correos) > 0 ){
|
||||
$to = join(",", $coord_correos);
|
||||
}
|
||||
$asunto = "Solicitud de salon nueva";
|
||||
$texto = "<p>Se creó una solicitud de asignación de salón nueva.</p>";
|
||||
$texto .= "<p><b>Se solicita un espacio de tipo ".mb_strtoupper($aula_rs["tipoaula_nombre"])."</b> para el día <b>".$fecha." a las ".$hora." hrs. </b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
break;
|
||||
case 2://Correo a supervisor
|
||||
$asunto = "Solicitud de salon nueva - ".$fac_rs["clave_dependencia"]." ".$fac_rs["facultad_nombre"];
|
||||
//crear plantilla
|
||||
$texto = "<p>Se creó una solicitud de asignación de salón nueva para: <b>".$fac_rs["clave_dependencia"]." ".$fac_rs["facultad_nombre"]."</b>.</p>";
|
||||
$texto .= "<p>Para el día <b>".$fecha." a las ".$hora." hrs. </b>";
|
||||
if(!$aula_rs["tipoaula_supervisor"]){
|
||||
$texto .= " en el salón: <b>".$salon_desc."</b></p>";
|
||||
}else{
|
||||
$texto .= " en un salón de tipo: <b>".mb_strtoupper($aula_rs["tipoaula_nombre"])."</b></p>";
|
||||
}
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
$to = join(",", $correosSup_rs);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_falta.">".$fecha_new."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
|
||||
|
||||
|
||||
if($to!= "" && ENVIO_CORREOS){
|
||||
//crear plantilla
|
||||
$texto = '<body >
|
||||
<img src="https://paad.lci.ulsa.mx/imagenes/logo_lasalle.png" alt="La Salle" style="margin-bottom:60px">
|
||||
'.$texto.'
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: ".$pag."?ok=0");
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Inserta reposición
|
||||
*/
|
||||
$pag = "../asignacion_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
require_once "../class/mailer.php";
|
||||
|
||||
define("COORDINADOR", 9);
|
||||
define("ENVIO_CORREOS", true);
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
//$user->access();
|
||||
|
||||
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
$salon = filter_input(INPUT_POST, "salon", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", 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
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
$aula_rs = $db->querySingle("select tipoaula_nombre, tipoaula_supervisor from tipoaula where tipoaula_id = :id", [":id"=>$aula]);
|
||||
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
//-- Obtiene datos de horario regular de clase
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
|
||||
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
//Datos de dependencia de usuario
|
||||
$fac_rs = $db->querySingle("SELECT facultad_nombre, clave_dependencia from facultad where facultad_id = :id_fac",[':id_fac' => $user->facultad["facultad_id"]] );
|
||||
|
||||
$salon_desc = "Pendiente";
|
||||
if(!empty($salon)){
|
||||
$salon_rs = $db->querySingle('SELECT s.salon_id, s.salon_array FROM salon_view s where s.salon_id = :id_salon',
|
||||
[':id_salon' => $salon]
|
||||
);
|
||||
if($salon_rs["salon_id"] == "" || $salon_rs["salon_id"] == NULL){
|
||||
$salon_desc = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($salon_rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$salon_desc = join(" / ",$salon_json);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT coor.usuario_correo as coordinador_correo
|
||||
from reposicion_solicitud rs
|
||||
inner join profesor p on rs.profesor_id =p.profesor_id
|
||||
inner join usuario u on u.usuario_id = rs.usuario_id
|
||||
inner join horario_view hv on hv.horario_id = rs.horario_id
|
||||
inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord
|
||||
where hv.facultad_id = :id_fac',
|
||||
[':rol_coord' => COORDINADOR, ':id_fac' => $user->facultad["facultad_id"]]
|
||||
);
|
||||
$coord_correos=[];
|
||||
foreach($correos_rs as $correo){
|
||||
if( count($coord_correos)==0 && $correo["coordinador_correo"]!=""){
|
||||
if(!isset($coord_correos["correo"]) || !in_array($correo["coordinador_correo"], $coord_correos["correo"])){
|
||||
array_push($coord_correos, $correo["coordinador_correo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_correo as coordinador_correo
|
||||
FROM horario_supervisor hs
|
||||
inner join usuario sup on sup.usuario_id =hs.usuario_id
|
||||
where :id_fac = ANY(hs.facultad_id_array)
|
||||
and sup.usuario_correo is not null and sup.usuario_correo != ''",
|
||||
[':id_fac' => $user->facultad["facultad_id"]] );
|
||||
|
||||
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia_new, $hora, $materia, "-", $fecha_new, $fecha_fin_new, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
*/
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo en la fecha nueva
|
||||
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo]
|
||||
)["traslape_profesor_reposicion"];
|
||||
if($traslape){
|
||||
//print_r($_POST);
|
||||
//echo "SELECT * from traslape_profesor_reposicion($prof,'".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."' , '$hora', $duracion)";
|
||||
|
||||
header("Location:".$pag."?error=9");
|
||||
exit();
|
||||
}
|
||||
|
||||
try{
|
||||
$edo = 1;
|
||||
if(!$user->jefe_carrera)
|
||||
$edo = 2;
|
||||
|
||||
//echo "SELECT * from fi_asignacion_solicitud( $fecha_new, $hora, $prof, $edo, $comentario, $alumnos, $aula, $duracion_tiempo, ".$user->user["id"].")"; exit();
|
||||
$db->query('SELECT * from fi_asignacion_solicitud(:f_nueva, :hora_nueva, :prof, :edo, :desc, :alumnos, :aula, :duracion, :usr)',
|
||||
[':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':prof' => $prof, ':edo'=>$edo, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"]
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
echo $e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$asunto = "";
|
||||
$texto = "";
|
||||
$to = "";
|
||||
switch($edo){
|
||||
case 1://Correo a coordinador
|
||||
if( count($coord_correos) > 0 ){
|
||||
$to = join(",", $coord_correos);
|
||||
}
|
||||
$asunto = "Solicitud de salon nueva";
|
||||
$texto = "<p>Se creó una solicitud de asignación de salón nueva.</p>";
|
||||
$texto .= "<p><b>Se solicita un espacio de tipo ".mb_strtoupper($aula_rs["tipoaula_nombre"])."</b> para el día <b>".$fecha." a las ".$hora." hrs. </b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
break;
|
||||
case 2://Correo a supervisor
|
||||
$asunto = "Solicitud de salon nueva - ".$fac_rs["clave_dependencia"]." ".$fac_rs["facultad_nombre"];
|
||||
//crear plantilla
|
||||
$texto = "<p>Se creó una solicitud de asignación de salón nueva para: <b>".$fac_rs["clave_dependencia"]." ".$fac_rs["facultad_nombre"]."</b>.</p>";
|
||||
$texto .= "<p>Para el día <b>".$fecha." a las ".$hora." hrs. </b>";
|
||||
if(!$aula_rs["tipoaula_supervisor"]){
|
||||
$texto .= " en el salón: <b>".$salon_desc."</b></p>";
|
||||
}else{
|
||||
$texto .= " en un salón de tipo: <b>".mb_strtoupper($aula_rs["tipoaula_nombre"])."</b></p>";
|
||||
}
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
$to = join(",", $correosSup_rs);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_falta.">".$fecha_new."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
|
||||
|
||||
|
||||
if($to!= "" && ENVIO_CORREOS){
|
||||
//crear plantilla
|
||||
$texto = '<body >
|
||||
<img src="https://paad.lci.ulsa.mx/imagenes/logo_lasalle.png" alt="La Salle" style="margin-bottom:60px">
|
||||
'.$texto.'
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: ".$pag."?ok=0");
|
||||
?>
|
||||
|
||||
@@ -1,81 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Obtiene datos de reposición
|
||||
*/
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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(!$objSesion->tieneAcceso()){
|
||||
$return["error"] = "Error! No tienes permisos para realizar esta acción.";
|
||||
}else*/ if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información de la reposición.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
|
||||
try{
|
||||
if($user->rol["rol_id"] == 7){//es supervisor
|
||||
$rs = $db->querySingle('SELECT * from fs_asignacion_solicitud(:id, NULL, NULL, :sup, NULL)',
|
||||
[':id' => $id, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
}else{//coordinador
|
||||
$rs = $db->querySingle('SELECT * from fs_asignacion_solicitud(:id, NULL, NULL, NULL, null)',
|
||||
[':id' => $id]
|
||||
);
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al leer los datos de la reposición.";
|
||||
echo json_encode($return);
|
||||
exit();
|
||||
}
|
||||
|
||||
$return["fecha_nueva"] = date('d/m/Y', strtotime($rs["fecha_nueva"]));
|
||||
$hora_nueva = explode(":",$rs["hora_nueva"]);
|
||||
$return["hora_ini"] = $hora_nueva[0];
|
||||
$return["min_ini"] = $hora_nueva[1];
|
||||
$hora_nueva_fin = explode(":",$rs["hora_nueva_fin"]);
|
||||
$return["hora_fin"] = $hora_nueva_fin[0];
|
||||
$return["min_fin"] = $hora_nueva_fin[1];
|
||||
$return["duracion"] = $rs["duracion_total"];
|
||||
|
||||
// $return["carrera"] = $rs["PlanEstudio_desc"];
|
||||
// $return["materia"] = $rs["materia_id"];
|
||||
// $return["materia_desc"] = $rs["materia_nombre"];
|
||||
$return["salon"] = $rs["salon_id"];
|
||||
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["profesor"] = $rs["profesor_id"];
|
||||
$return["profesor_nombre"] = $rs["profesor_nombre"];
|
||||
$return["comentario"] = $rs["descripcion"];
|
||||
$return["alumnos"] = $rs["alumnos"];
|
||||
$return["aula"] = $rs["tipoaula_id"];
|
||||
$return["aula_desc"] = $rs["tipoaula_nombre"];
|
||||
$return["aula_supervisor"] = $rs["tipoaula_supervisor"];
|
||||
$return["dia"] = date('w', strtotime($rs["fecha_nueva"]));
|
||||
$return["motivo_cancelacion"] = $rs["motivo_cancelacion"];
|
||||
$return["estado"] = $rs["estado_reposicion_id"];
|
||||
$return["facultad"] = $rs["facultad_nombre"];
|
||||
$return["supervisor_nombre"] = $rs["supervisor_nombre"];
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Obtiene datos de reposición
|
||||
*/
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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(!$objSesion->tieneAcceso()){
|
||||
$return["error"] = "Error! No tienes permisos para realizar esta acción.";
|
||||
}else*/ if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información de la reposición.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
|
||||
try{
|
||||
if($user->rol["rol_id"] == 7){//es supervisor
|
||||
$rs = $db->querySingle('SELECT * from fs_asignacion_solicitud(:id, NULL, NULL, :sup, NULL)',
|
||||
[':id' => $id, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
}else{//coordinador
|
||||
$rs = $db->querySingle('SELECT * from fs_asignacion_solicitud(:id, NULL, NULL, NULL, null)',
|
||||
[':id' => $id]
|
||||
);
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al leer los datos de la reposición.";
|
||||
echo json_encode($return);
|
||||
exit();
|
||||
}
|
||||
|
||||
$return["fecha_nueva"] = date('d/m/Y', strtotime($rs["fecha_nueva"]));
|
||||
$hora_nueva = explode(":",$rs["hora_nueva"]);
|
||||
$return["hora_ini"] = $hora_nueva[0];
|
||||
$return["min_ini"] = $hora_nueva[1];
|
||||
$hora_nueva_fin = explode(":",$rs["hora_nueva_fin"]);
|
||||
$return["hora_fin"] = $hora_nueva_fin[0];
|
||||
$return["min_fin"] = $hora_nueva_fin[1];
|
||||
$return["duracion"] = $rs["duracion_total"];
|
||||
|
||||
// $return["carrera"] = $rs["PlanEstudio_desc"];
|
||||
// $return["materia"] = $rs["materia_id"];
|
||||
// $return["materia_desc"] = $rs["materia_nombre"];
|
||||
$return["salon"] = $rs["salon_id"];
|
||||
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["profesor"] = $rs["profesor_id"];
|
||||
$return["profesor_nombre"] = $rs["profesor_nombre"];
|
||||
$return["comentario"] = $rs["descripcion"];
|
||||
$return["alumnos"] = $rs["alumnos"];
|
||||
$return["aula"] = $rs["tipoaula_id"];
|
||||
$return["aula_desc"] = $rs["tipoaula_nombre"];
|
||||
$return["aula_supervisor"] = $rs["tipoaula_supervisor"];
|
||||
$return["dia"] = date('w', strtotime($rs["fecha_nueva"]));
|
||||
$return["motivo_cancelacion"] = $rs["motivo_cancelacion"];
|
||||
$return["estado"] = $rs["estado_reposicion_id"];
|
||||
$return["facultad"] = $rs["facultad_nombre"];
|
||||
$return["supervisor_nombre"] = $rs["supervisor_nombre"];
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
|
||||
@@ -1,135 +1,135 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Actualiza reposición
|
||||
*/
|
||||
$pag = "../asignacion_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
define("COORDINADOR", 9);
|
||||
define("ENVIO_CORREOS", true);
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
|
||||
/*if(!isset($_POST["id"]) || !isset($_POST["fecha_falta"]) || !isset($_POST["fecha_inicial"]) || !isset($_POST["hora_ini"]) || !isset($_POST["min_ini"]) || !isset($_POST["materia"]) || !isset($_POST["grupo"])){
|
||||
header("Location: ".$pag."?error=0");
|
||||
exit();
|
||||
}*/
|
||||
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", 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
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
|
||||
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
//echo $fecha_new."<br>";
|
||||
//echo $fecha_fin_new."<br>";
|
||||
$fac_rs = $db->querySingle("SELECT facultad_nombre, clave_dependencia from facultad where facultad_id = :id_fac",[':id_fac' => $user->facultad["facultad_id"]] );
|
||||
|
||||
$salon_desc = "Pendiente";
|
||||
if(!empty($salon)){
|
||||
$salon_rs = $db->querySingle('SELECT s.salon_id, s.salon_array FROM salon_view s where s.salon_id = :id_salon',
|
||||
[':id_salon' => $salon]
|
||||
);
|
||||
if($salon_rs["salon_id"] == "" || $salon_rs["salon_id"] == NULL){
|
||||
$salon_desc = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($salon_rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$salon_desc = join(" / ",$salon_json);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT coor.usuario_correo as coordinador_correo
|
||||
from reposicion_solicitud rs
|
||||
inner join profesor p on rs.profesor_id =p.profesor_id
|
||||
inner join usuario u on u.usuario_id = rs.usuario_id
|
||||
inner join horario_view hv on hv.horario_id = rs.horario_id
|
||||
inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord
|
||||
where hv.facultad_id = :id_fac',
|
||||
[':rol_coord' => COORDINADOR, ':id_fac' => $user->facultad["facultad_id"]]
|
||||
);
|
||||
$coord_correos=[];
|
||||
foreach($correos_rs as $correo){
|
||||
if( count($coord_correos)==0 && $correo["coordinador_correo"]!=""){
|
||||
if(!isset($coord_correos["correo"]) || !in_array($correo["coordinador_correo"], $coord_correos["correo"])){
|
||||
array_push($coord_correos, $correo["coordinador_correo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_correo as coordinador_correo
|
||||
FROM horario_supervisor hs
|
||||
inner join usuario sup on sup.usuario_id =hs.usuario_id
|
||||
where :id_fac = ANY(hs.facultad_id_array)
|
||||
and sup.usuario_correo is not null and sup.usuario_correo != ''",
|
||||
[':id_fac' => $user->facultad["facultad_id"]] );
|
||||
|
||||
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur, :id)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo, ':id'=>$id]
|
||||
)["traslape_profesor_reposicion"];
|
||||
echo "SELECT * from traslape_profesor_reposicion($prof, '".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."', $hora, $duracion_tiempo, $id)";
|
||||
if($traslape){
|
||||
//header("Location:".$pag."?error=9");
|
||||
echo "traslape";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Actualiza reposición ID[".$id."] Fechas[".$fecha_ini."][".$fecha_fin."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fu_asignacion_solicitud(:id, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)',
|
||||
[':id'=> $id, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
//header("Location: ".$pag."?error=2");
|
||||
print_r($e->getMessage());
|
||||
echo "SELECT * from fu_asignacion_solicitud(:id, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)'";
|
||||
print_r(
|
||||
[':id'=> $id, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
header("Location: ".$pag);
|
||||
exit();
|
||||
?>
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Actualiza reposición
|
||||
*/
|
||||
$pag = "../asignacion_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
define("COORDINADOR", 9);
|
||||
define("ENVIO_CORREOS", true);
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
|
||||
/*if(!isset($_POST["id"]) || !isset($_POST["fecha_falta"]) || !isset($_POST["fecha_inicial"]) || !isset($_POST["hora_ini"]) || !isset($_POST["min_ini"]) || !isset($_POST["materia"]) || !isset($_POST["grupo"])){
|
||||
header("Location: ".$pag."?error=0");
|
||||
exit();
|
||||
}*/
|
||||
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", 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
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
|
||||
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
//echo $fecha_new."<br>";
|
||||
//echo $fecha_fin_new."<br>";
|
||||
$fac_rs = $db->querySingle("SELECT facultad_nombre, clave_dependencia from facultad where facultad_id = :id_fac",[':id_fac' => $user->facultad["facultad_id"]] );
|
||||
|
||||
$salon_desc = "Pendiente";
|
||||
if(!empty($salon)){
|
||||
$salon_rs = $db->querySingle('SELECT s.salon_id, s.salon_array FROM salon_view s where s.salon_id = :id_salon',
|
||||
[':id_salon' => $salon]
|
||||
);
|
||||
if($salon_rs["salon_id"] == "" || $salon_rs["salon_id"] == NULL){
|
||||
$salon_desc = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($salon_rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$salon_desc = join(" / ",$salon_json);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT coor.usuario_correo as coordinador_correo
|
||||
from reposicion_solicitud rs
|
||||
inner join profesor p on rs.profesor_id =p.profesor_id
|
||||
inner join usuario u on u.usuario_id = rs.usuario_id
|
||||
inner join horario_view hv on hv.horario_id = rs.horario_id
|
||||
inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord
|
||||
where hv.facultad_id = :id_fac',
|
||||
[':rol_coord' => COORDINADOR, ':id_fac' => $user->facultad["facultad_id"]]
|
||||
);
|
||||
$coord_correos=[];
|
||||
foreach($correos_rs as $correo){
|
||||
if( count($coord_correos)==0 && $correo["coordinador_correo"]!=""){
|
||||
if(!isset($coord_correos["correo"]) || !in_array($correo["coordinador_correo"], $coord_correos["correo"])){
|
||||
array_push($coord_correos, $correo["coordinador_correo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_correo as coordinador_correo
|
||||
FROM horario_supervisor hs
|
||||
inner join usuario sup on sup.usuario_id =hs.usuario_id
|
||||
where :id_fac = ANY(hs.facultad_id_array)
|
||||
and sup.usuario_correo is not null and sup.usuario_correo != ''",
|
||||
[':id_fac' => $user->facultad["facultad_id"]] );
|
||||
|
||||
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur, :id)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo, ':id'=>$id]
|
||||
)["traslape_profesor_reposicion"];
|
||||
echo "SELECT * from traslape_profesor_reposicion($prof, '".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."', $hora, $duracion_tiempo, $id)";
|
||||
if($traslape){
|
||||
//header("Location:".$pag."?error=9");
|
||||
echo "traslape";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Actualiza reposición ID[".$id."] Fechas[".$fecha_ini."][".$fecha_fin."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fu_asignacion_solicitud(:id, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)',
|
||||
[':id'=> $id, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
//header("Location: ".$pag."?error=2");
|
||||
print_r($e->getMessage());
|
||||
echo "SELECT * from fu_asignacion_solicitud(:id, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)'";
|
||||
print_r(
|
||||
[':id'=> $id, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
header("Location: ".$pag);
|
||||
exit();
|
||||
?>
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
if(empty($_POST["id"]) || empty($_POST["hor"])){
|
||||
$return["error"] = "Error! No se recibió la información del usuario.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "hor", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
$rs = $db->query('SELECT * from fs_asistenciaprofesor_horario(:id, :hor)', [':id' => $id, ':hor' => $hor]);
|
||||
$asistArr = array();
|
||||
|
||||
foreach($rs as $row){
|
||||
$asistArr[] = $row["registro_fecha_ideal"];
|
||||
}
|
||||
$return["asistenciaArr"] = $asistArr;
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
if(empty($_POST["id"]) || empty($_POST["hor"])){
|
||||
$return["error"] = "Error! No se recibió la información del usuario.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "hor", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
$rs = $db->query('SELECT * from fs_asistenciaprofesor_horario(:id, :hor)', [':id' => $id, ':hor' => $hor]);
|
||||
$asistArr = array();
|
||||
|
||||
foreach($rs as $row){
|
||||
$asistArr[] = $row["registro_fecha_ideal"];
|
||||
}
|
||||
$return["asistenciaArr"] = $asistArr;
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
|
||||
@@ -1,293 +1,293 @@
|
||||
<?
|
||||
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(array('error' => 'No se ha iniciado sesión'));
|
||||
exit();
|
||||
}
|
||||
$user = Login::get_user();
|
||||
try {
|
||||
|
||||
switch ($_SERVER['REQUEST_METHOD']) {
|
||||
case 'GET':
|
||||
$facultad_id = $user->facultad['facultad_id'];
|
||||
$avisos = $db->query(
|
||||
"SELECT * FROM aviso
|
||||
WHERE
|
||||
(CURRENT_DATE BETWEEN aviso_fecha_inicial AND aviso_fecha_final) AND
|
||||
(facultad_id = :facultad_id OR :facultad_id IS NULL) AND
|
||||
aviso_estado
|
||||
ORDER BY aviso_id DESC",
|
||||
array('facultad_id' => $facultad_id)
|
||||
);
|
||||
|
||||
/*
|
||||
if (empty($avisos)) {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
echo json_encode(array('error' => 'No hay avisos disponibles'));
|
||||
exit();
|
||||
}
|
||||
*/
|
||||
|
||||
$avisos = array_map(fn($aviso) => array(
|
||||
...$aviso,
|
||||
'carreras' => $db->query(
|
||||
"SELECT carrera_id, carrera_nombre FROM aviso_carrera
|
||||
JOIN carrera USING (carrera_id)
|
||||
WHERE aviso_id = :aviso_id",
|
||||
array('aviso_id' => $aviso['aviso_id'])
|
||||
),
|
||||
'profesores' => $db->query(
|
||||
"SELECT profesor_id, profesor_clave, profesor_nombre FROM aviso_profesor
|
||||
JOIN profesor USING (profesor_id)
|
||||
WHERE aviso_id = :aviso_id",
|
||||
array('aviso_id' => $aviso['aviso_id'])
|
||||
),
|
||||
), $avisos);
|
||||
echo json_encode($avisos);
|
||||
break;
|
||||
case 'POST':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
if (empty($raw_input)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'No se recibieron parámetros'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$input_data = json_decode($raw_input);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'Invalid JSON format'));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$schema = <<<JSON
|
||||
{
|
||||
"\$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"required": ["aviso_fecha_inicial", "aviso_fecha_final", "aviso_titulo", "aviso_texto"],
|
||||
"properties": {
|
||||
"aviso_fecha_inicial": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"aviso_fecha_final": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"aviso_texto": {
|
||||
"type": "string"
|
||||
},
|
||||
"aviso_titulo": {
|
||||
"type": "string"
|
||||
},
|
||||
"carreras": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"minItems": 0,
|
||||
"uniqueItems": true
|
||||
},
|
||||
"profesores": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"minItems": 0,
|
||||
"uniqueItems": true
|
||||
}
|
||||
},
|
||||
"anyOf": [
|
||||
{"required": ["carreras"]},
|
||||
{"required": ["profesores"]}
|
||||
]
|
||||
}
|
||||
JSON;
|
||||
// VALIDATE JSON SCHEMA
|
||||
$validate = new JsonSchema\Validator();
|
||||
$validate->validate($input_data, json_decode($schema));
|
||||
|
||||
if (!$validate->isValid()) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(
|
||||
array(
|
||||
'error' => 'El formato de la solicitud es incorrecto',
|
||||
'success' => false,
|
||||
'errors' => $validate->getErrors()
|
||||
)
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
$aviso_id = $db->insert(
|
||||
'aviso',
|
||||
array(
|
||||
'aviso_fecha_inicial' => $input_data->aviso_fecha_inicial,
|
||||
'aviso_fecha_final' => $input_data->aviso_fecha_final,
|
||||
'aviso_texto' => $input_data->aviso_texto,
|
||||
'facultad_id' => $user->facultad['facultad_id'],
|
||||
),
|
||||
'aviso_id'
|
||||
);
|
||||
|
||||
if (isset($input_data->carreras)) {
|
||||
array_walk($input_data->carreras, fn($carrera_id) => $db->insert('aviso_carrera', array('aviso_id' => $aviso_id, 'carrera_id' => $carrera_id)));
|
||||
}
|
||||
if (isset($input_data->profesores)) {
|
||||
array_walk($input_data->profesores, fn($profesor_id) => $db->insert('aviso_profesor', array('aviso_id' => $aviso_id, 'profesor_id' => $profesor_id)));
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
array(
|
||||
'aviso_id' => $aviso_id,
|
||||
'msg' => 'Aviso creado exitosamente',
|
||||
'success' => true
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'PUT':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
if (empty($raw_input)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'No se recibieron parámetros'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$input_data = json_decode($raw_input);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'Invalid JSON format'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$schema = <<<JSON
|
||||
{
|
||||
"\$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"required": ["aviso_id", "aviso_fecha_final"],
|
||||
"properties": {
|
||||
"aviso_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"aviso_fecha_final": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON;
|
||||
|
||||
// VALIDATE JSON SCHEMA
|
||||
$validate = new JsonSchema\Validator();
|
||||
$validate->validate($input_data, json_decode($schema));
|
||||
|
||||
if (!$validate->isValid()) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(
|
||||
array(
|
||||
'error' => 'El formato de la solicitud es incorrecto',
|
||||
'errors' => $validate->getErrors(),
|
||||
'success' => false,
|
||||
)
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
$db->where('aviso_id', $input_data->aviso_id)
|
||||
->update(
|
||||
'aviso',
|
||||
array(
|
||||
'aviso_fecha_final' => $input_data->aviso_fecha_final,
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($input_data->carreras)) {
|
||||
$db->where('aviso_id', $input_data->aviso_id)->delete('aviso_carrera');
|
||||
array_walk($input_data->carreras, fn($carrera_id) => $db->insert('aviso_carrera', array('aviso_id' => $input_data->aviso_id, 'carrera_id' => $carrera_id)));
|
||||
}
|
||||
|
||||
if (isset($input_data->profesores)) {
|
||||
$db->where('aviso_id', $input_data->aviso_id)->delete('aviso_profesor');
|
||||
array_walk($input_data->profesores, fn($profesor_id) => $db->insert('aviso_profesor', array('aviso_id' => $input_data->aviso_id, 'profesor_id' => $profesor_id)));
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
array(
|
||||
'msg' => 'Aviso actualizado exitosamente',
|
||||
'success' => true
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'DELETE':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
if (empty($raw_input)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'No se recibieron parámetros'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$input_data = json_decode($raw_input);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'Invalid JSON format'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$schema = <<<JSON
|
||||
{
|
||||
"\$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"required": ["aviso_id"],
|
||||
"properties": {
|
||||
"aviso_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON;
|
||||
|
||||
// VALIDATE JSON SCHEMA
|
||||
$validate = new JsonSchema\Validator();
|
||||
$validate->validate($input_data, json_decode($schema));
|
||||
|
||||
if (!$validate->isValid()) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(
|
||||
array(
|
||||
'error' => 'El formato de la solicitud es incorrecto',
|
||||
'errors' => $validate->getErrors(),
|
||||
'success' => false,
|
||||
)
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
$result = $db->where('aviso_id', $input_data->aviso_id)->update('aviso', array('aviso_estado' => false));
|
||||
echo json_encode(
|
||||
array(
|
||||
'msg' => 'Aviso eliminado exitosamente',
|
||||
'success' => true,
|
||||
'result' => $result
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(
|
||||
array(
|
||||
'error' => $e->getMessage(),
|
||||
'query' => $db->getLastQuery(),
|
||||
'exception' => $e->getTraceAsString()
|
||||
)
|
||||
);
|
||||
<?
|
||||
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(array('error' => 'No se ha iniciado sesión'));
|
||||
exit();
|
||||
}
|
||||
$user = Login::get_user();
|
||||
try {
|
||||
|
||||
switch ($_SERVER['REQUEST_METHOD']) {
|
||||
case 'GET':
|
||||
$facultad_id = $user->facultad['facultad_id'];
|
||||
$avisos = $db->query(
|
||||
"SELECT * FROM aviso
|
||||
WHERE
|
||||
(CURRENT_DATE BETWEEN aviso_fecha_inicial AND aviso_fecha_final) AND
|
||||
(facultad_id = :facultad_id OR :facultad_id IS NULL) AND
|
||||
aviso_estado
|
||||
ORDER BY aviso_id DESC",
|
||||
array('facultad_id' => $facultad_id)
|
||||
);
|
||||
|
||||
/*
|
||||
if (empty($avisos)) {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
echo json_encode(array('error' => 'No hay avisos disponibles'));
|
||||
exit();
|
||||
}
|
||||
*/
|
||||
|
||||
$avisos = array_map(fn($aviso) => array(
|
||||
...$aviso,
|
||||
'carreras' => $db->query(
|
||||
"SELECT carrera_id, carrera_nombre FROM aviso_carrera
|
||||
JOIN carrera USING (carrera_id)
|
||||
WHERE aviso_id = :aviso_id",
|
||||
array('aviso_id' => $aviso['aviso_id'])
|
||||
),
|
||||
'profesores' => $db->query(
|
||||
"SELECT profesor_id, profesor_clave, profesor_nombre FROM aviso_profesor
|
||||
JOIN profesor USING (profesor_id)
|
||||
WHERE aviso_id = :aviso_id",
|
||||
array('aviso_id' => $aviso['aviso_id'])
|
||||
),
|
||||
), $avisos);
|
||||
echo json_encode($avisos);
|
||||
break;
|
||||
case 'POST':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
if (empty($raw_input)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'No se recibieron parámetros'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$input_data = json_decode($raw_input);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'Invalid JSON format'));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$schema = <<<JSON
|
||||
{
|
||||
"\$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"required": ["aviso_fecha_inicial", "aviso_fecha_final", "aviso_titulo", "aviso_texto"],
|
||||
"properties": {
|
||||
"aviso_fecha_inicial": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"aviso_fecha_final": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
"aviso_texto": {
|
||||
"type": "string"
|
||||
},
|
||||
"aviso_titulo": {
|
||||
"type": "string"
|
||||
},
|
||||
"carreras": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"minItems": 0,
|
||||
"uniqueItems": true
|
||||
},
|
||||
"profesores": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"minItems": 0,
|
||||
"uniqueItems": true
|
||||
}
|
||||
},
|
||||
"anyOf": [
|
||||
{"required": ["carreras"]},
|
||||
{"required": ["profesores"]}
|
||||
]
|
||||
}
|
||||
JSON;
|
||||
// VALIDATE JSON SCHEMA
|
||||
$validate = new JsonSchema\Validator();
|
||||
$validate->validate($input_data, json_decode($schema));
|
||||
|
||||
if (!$validate->isValid()) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(
|
||||
array(
|
||||
'error' => 'El formato de la solicitud es incorrecto',
|
||||
'success' => false,
|
||||
'errors' => $validate->getErrors()
|
||||
)
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
$aviso_id = $db->insert(
|
||||
'aviso',
|
||||
array(
|
||||
'aviso_fecha_inicial' => $input_data->aviso_fecha_inicial,
|
||||
'aviso_fecha_final' => $input_data->aviso_fecha_final,
|
||||
'aviso_texto' => $input_data->aviso_texto,
|
||||
'facultad_id' => $user->facultad['facultad_id'],
|
||||
),
|
||||
'aviso_id'
|
||||
);
|
||||
|
||||
if (isset($input_data->carreras)) {
|
||||
array_walk($input_data->carreras, fn($carrera_id) => $db->insert('aviso_carrera', array('aviso_id' => $aviso_id, 'carrera_id' => $carrera_id)));
|
||||
}
|
||||
if (isset($input_data->profesores)) {
|
||||
array_walk($input_data->profesores, fn($profesor_id) => $db->insert('aviso_profesor', array('aviso_id' => $aviso_id, 'profesor_id' => $profesor_id)));
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
array(
|
||||
'aviso_id' => $aviso_id,
|
||||
'msg' => 'Aviso creado exitosamente',
|
||||
'success' => true
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 'PUT':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
if (empty($raw_input)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'No se recibieron parámetros'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$input_data = json_decode($raw_input);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'Invalid JSON format'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$schema = <<<JSON
|
||||
{
|
||||
"\$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"required": ["aviso_id", "aviso_fecha_final"],
|
||||
"properties": {
|
||||
"aviso_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"aviso_fecha_final": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON;
|
||||
|
||||
// VALIDATE JSON SCHEMA
|
||||
$validate = new JsonSchema\Validator();
|
||||
$validate->validate($input_data, json_decode($schema));
|
||||
|
||||
if (!$validate->isValid()) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(
|
||||
array(
|
||||
'error' => 'El formato de la solicitud es incorrecto',
|
||||
'errors' => $validate->getErrors(),
|
||||
'success' => false,
|
||||
)
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
$db->where('aviso_id', $input_data->aviso_id)
|
||||
->update(
|
||||
'aviso',
|
||||
array(
|
||||
'aviso_fecha_final' => $input_data->aviso_fecha_final,
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($input_data->carreras)) {
|
||||
$db->where('aviso_id', $input_data->aviso_id)->delete('aviso_carrera');
|
||||
array_walk($input_data->carreras, fn($carrera_id) => $db->insert('aviso_carrera', array('aviso_id' => $input_data->aviso_id, 'carrera_id' => $carrera_id)));
|
||||
}
|
||||
|
||||
if (isset($input_data->profesores)) {
|
||||
$db->where('aviso_id', $input_data->aviso_id)->delete('aviso_profesor');
|
||||
array_walk($input_data->profesores, fn($profesor_id) => $db->insert('aviso_profesor', array('aviso_id' => $input_data->aviso_id, 'profesor_id' => $profesor_id)));
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
array(
|
||||
'msg' => 'Aviso actualizado exitosamente',
|
||||
'success' => true
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'DELETE':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
if (empty($raw_input)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'No se recibieron parámetros'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$input_data = json_decode($raw_input);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(array('error' => 'Invalid JSON format'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$schema = <<<JSON
|
||||
{
|
||||
"\$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"required": ["aviso_id"],
|
||||
"properties": {
|
||||
"aviso_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
JSON;
|
||||
|
||||
// VALIDATE JSON SCHEMA
|
||||
$validate = new JsonSchema\Validator();
|
||||
$validate->validate($input_data, json_decode($schema));
|
||||
|
||||
if (!$validate->isValid()) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(
|
||||
array(
|
||||
'error' => 'El formato de la solicitud es incorrecto',
|
||||
'errors' => $validate->getErrors(),
|
||||
'success' => false,
|
||||
)
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
$result = $db->where('aviso_id', $input_data->aviso_id)->update('aviso', array('aviso_estado' => false));
|
||||
echo json_encode(
|
||||
array(
|
||||
'msg' => 'Aviso eliminado exitosamente',
|
||||
'success' => true,
|
||||
'result' => $result
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(
|
||||
array(
|
||||
'error' => $e->getMessage(),
|
||||
'query' => $db->getLastQuery(),
|
||||
'exception' => $e->getTraceAsString()
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1,66 +1,66 @@
|
||||
<?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'];
|
||||
$periodo_nivel_id = $db->where('periodo_id', $user->periodo_id)->getOne('periodo', 'nivel_id')['nivel_id'];
|
||||
$carreras = $db->query(<<<SQL
|
||||
SELECT carrera_id, carrera_nombre, clave_carrera,
|
||||
facultad_id, facultad_nombre,
|
||||
nivel_id, nivel_nombre
|
||||
FROM carrera
|
||||
join nivel using (nivel_id)
|
||||
join facultad using (facultad_id)
|
||||
WHERE facultad_id = :facultad_id OR :facultad_id IS NULL AND
|
||||
nivel.nivel_id = :periodo_nivel_id
|
||||
ORDER BY facultad_nombre, carrera_nombre
|
||||
SQL, [
|
||||
'facultad_id' => $facultad_id,
|
||||
'periodo_nivel_id' => $periodo_nivel_id
|
||||
]);
|
||||
echo json_encode($carreras);
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
// Update carrera {nivel_id}
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw, true);
|
||||
|
||||
if (!isset($data['carrera_id'], $data['nivel_id'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id de la carrera o el nivel']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$carrera_id = $data['carrera_id'];
|
||||
$nivel_id = $data['nivel_id'];
|
||||
$db->where('carrera_id', $carrera_id)->update('carrera', ['nivel_id' => $nivel_id]);
|
||||
|
||||
$carrera_nombre = $db->where('carrera_id', $carrera_id)->getOne('carrera', 'carrera_nombre')['carrera_nombre'];
|
||||
$nivel_nombre = $db->where('nivel_id', $nivel_id)->getOne('nivel', 'nivel_nombre')['nivel_nombre'];
|
||||
|
||||
echo json_encode(['success' => "$carrera_nombre actualizada a $nivel_nombre"]);
|
||||
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()
|
||||
]);
|
||||
<?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'];
|
||||
$periodo_nivel_id = $db->where('periodo_id', $user->periodo_id)->getOne('periodo', 'nivel_id')['nivel_id'];
|
||||
$carreras = $db->query(<<<SQL
|
||||
SELECT carrera_id, carrera_nombre, clave_carrera,
|
||||
facultad_id, facultad_nombre,
|
||||
nivel_id, nivel_nombre
|
||||
FROM carrera
|
||||
join nivel using (nivel_id)
|
||||
join facultad using (facultad_id)
|
||||
WHERE facultad_id = :facultad_id OR :facultad_id IS NULL AND
|
||||
nivel.nivel_id = :periodo_nivel_id
|
||||
ORDER BY facultad_nombre, carrera_nombre
|
||||
SQL, [
|
||||
'facultad_id' => $facultad_id,
|
||||
'periodo_nivel_id' => $periodo_nivel_id
|
||||
]);
|
||||
echo json_encode($carreras);
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
// Update carrera {nivel_id}
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw, true);
|
||||
|
||||
if (!isset($data['carrera_id'], $data['nivel_id'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id de la carrera o el nivel']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$carrera_id = $data['carrera_id'];
|
||||
$nivel_id = $data['nivel_id'];
|
||||
$db->where('carrera_id', $carrera_id)->update('carrera', ['nivel_id' => $nivel_id]);
|
||||
|
||||
$carrera_nombre = $db->where('carrera_id', $carrera_id)->getOne('carrera', 'carrera_nombre')['carrera_nombre'];
|
||||
$nivel_nombre = $db->where('nivel_id', $nivel_id)->getOne('nivel', 'nivel_nombre')['nivel_nombre'];
|
||||
|
||||
echo json_encode(['success' => "$carrera_nombre actualizada a $nivel_nombre"]);
|
||||
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()
|
||||
]);
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
<?php
|
||||
require_once '../class/mailer.php';
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if(!isset($_GET["correo"])){
|
||||
echo "Debes especificar la dirección a la que se enviará el correo <strong>?correo=</strong>";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$to = $_GET["correo"];
|
||||
$texto = "<h1>Esto es una prueba automatizada</h1><p>El correo se envió atutomáticamente, no debes hacer nada más.</p>";
|
||||
$asunto="Prueba";
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
echo "Enviado!".date("H:i:s");
|
||||
|
||||
?>
|
||||
<?php
|
||||
require_once '../class/mailer.php';
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if(!isset($_GET["correo"])){
|
||||
echo "Debes especificar la dirección a la que se enviará el correo <strong>?correo=</strong>";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$to = $_GET["correo"];
|
||||
$texto = "<h1>Esto es una prueba automatizada</h1><p>El correo se envió atutomáticamente, no debes hacer nada más.</p>";
|
||||
$asunto="Prueba";
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
echo "Enviado!".date("H:i:s");
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
<?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':
|
||||
$profesor_id = $db
|
||||
->where('profesor_clave', $_GET['profesor'])
|
||||
->getOne('profesor', 'profesor_id');
|
||||
// Fetch all puestos
|
||||
$horarios = $db->query(<<<SQL
|
||||
SELECT * FROM horario
|
||||
|
||||
NATURAL JOIN horario_profesor
|
||||
NATURAL JOIN facultad
|
||||
NATURAL LEFT JOIN materia
|
||||
NATURAL LEFT JOIN carrera
|
||||
|
||||
WHERE periodo_id = ? AND profesor_id = ?
|
||||
SQL,
|
||||
[$user->periodo_id, $profesor_id['profesor_id']]
|
||||
);
|
||||
|
||||
echo json_encode($horarios);
|
||||
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()
|
||||
]);
|
||||
<?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':
|
||||
$profesor_id = $db
|
||||
->where('profesor_clave', $_GET['profesor'])
|
||||
->getOne('profesor', 'profesor_id');
|
||||
// Fetch all puestos
|
||||
$horarios = $db->query(<<<SQL
|
||||
SELECT * FROM horario
|
||||
|
||||
NATURAL JOIN horario_profesor
|
||||
NATURAL JOIN facultad
|
||||
NATURAL LEFT JOIN materia
|
||||
NATURAL LEFT JOIN carrera
|
||||
|
||||
WHERE periodo_id = ? AND profesor_id = ?
|
||||
SQL,
|
||||
[$user->periodo_id, $profesor_id['profesor_id']]
|
||||
);
|
||||
|
||||
echo json_encode($horarios);
|
||||
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()
|
||||
]);
|
||||
}
|
||||
@@ -1,76 +1,76 @@
|
||||
<?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 'POST':
|
||||
// check parameters
|
||||
|
||||
$raw = file_get_contents('php://input');
|
||||
$post_data = json_decode($raw, true);
|
||||
|
||||
$data = $db->querySingle(
|
||||
'WITH HORARIOS AS (
|
||||
SELECT *
|
||||
FROM horario
|
||||
JOIN horario_profesor USING (horario_id)
|
||||
WHERE horario.periodo_id = :periodo_id
|
||||
)
|
||||
INSERT INTO registro (profesor_id, horario_id, registro_fecha_ideal, registro_justificada, justificador_id, registro_fecha_justificacion, justificacion)
|
||||
VALUES (:profesor_id, :horario_id, :registro_fecha_ideal, :registro_justificada, :justificador_id, NOW(), :justificacion)
|
||||
ON CONFLICT (profesor_id, horario_id, registro_fecha_ideal)
|
||||
DO UPDATE SET registro_justificada = :registro_justificada, justificador_id = :justificador_id, registro_fecha_justificacion = NOW(), justificacion = :justificacion
|
||||
RETURNING *',
|
||||
array(
|
||||
'periodo_id' => $user->periodo_id,
|
||||
'profesor_id' => $post_data['profesor_id'],
|
||||
'horario_id' => $post_data['horario_id'],
|
||||
'registro_fecha_ideal' => $post_data['registro_fecha_ideal'],
|
||||
'registro_justificada' => $post_data['registro_justificada'],
|
||||
'justificador_id' => $user->user['id'],
|
||||
'justificacion' => empty($post_data['justificacion']) ? null : $post_data['justificacion'],
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$data_justificador = $db->querySingle(
|
||||
"SELECT justificador.usuario_nombre as justificador_nombre,
|
||||
justificador.usuario_clave as justificador_clave,
|
||||
facultad.facultad_nombre as justificador_facultad, rol.rol_titulo as justificador_rol
|
||||
|
||||
FROM USUARIO JUSTIFICADOR
|
||||
JOIN ROL on ROL.rol_id = justificador.rol_id
|
||||
LEFT JOIN facultad on facultad.facultad_id = justificador.facultad_id
|
||||
where justificador.usuario_id = :justificador_id",
|
||||
array(
|
||||
'justificador_id' => $user->user['id'],
|
||||
)
|
||||
);
|
||||
// exit('exit');
|
||||
|
||||
echo json_encode(array_merge($data, $data_justificador), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
break;
|
||||
|
||||
default:
|
||||
header('HTTP/1.1 405 Method Not Allowed');
|
||||
echo json_encode(['error' => 'Método no permitido']);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode([
|
||||
'error' => $e->getMessage(),
|
||||
'query' => $db->getLastQuery(),
|
||||
'exception' => $e->getTraceAsString()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'error' => $e->getMessage(),
|
||||
'exception' => $e->getTraceAsString()
|
||||
]);
|
||||
<?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 'POST':
|
||||
// check parameters
|
||||
|
||||
$raw = file_get_contents('php://input');
|
||||
$post_data = json_decode($raw, true);
|
||||
|
||||
$data = $db->querySingle(
|
||||
'WITH HORARIOS AS (
|
||||
SELECT *
|
||||
FROM horario
|
||||
JOIN horario_profesor USING (horario_id)
|
||||
WHERE horario.periodo_id = :periodo_id
|
||||
)
|
||||
INSERT INTO registro (profesor_id, horario_id, registro_fecha_ideal, registro_justificada, justificador_id, registro_fecha_justificacion, justificacion)
|
||||
VALUES (:profesor_id, :horario_id, :registro_fecha_ideal, :registro_justificada, :justificador_id, NOW(), :justificacion)
|
||||
ON CONFLICT (profesor_id, horario_id, registro_fecha_ideal)
|
||||
DO UPDATE SET registro_justificada = :registro_justificada, justificador_id = :justificador_id, registro_fecha_justificacion = NOW(), justificacion = :justificacion
|
||||
RETURNING *',
|
||||
array(
|
||||
'periodo_id' => $user->periodo_id,
|
||||
'profesor_id' => $post_data['profesor_id'],
|
||||
'horario_id' => $post_data['horario_id'],
|
||||
'registro_fecha_ideal' => $post_data['registro_fecha_ideal'],
|
||||
'registro_justificada' => $post_data['registro_justificada'],
|
||||
'justificador_id' => $user->user['id'],
|
||||
'justificacion' => empty($post_data['justificacion']) ? null : $post_data['justificacion'],
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$data_justificador = $db->querySingle(
|
||||
"SELECT justificador.usuario_nombre as justificador_nombre,
|
||||
justificador.usuario_clave as justificador_clave,
|
||||
facultad.facultad_nombre as justificador_facultad, rol.rol_titulo as justificador_rol
|
||||
|
||||
FROM USUARIO JUSTIFICADOR
|
||||
JOIN ROL on ROL.rol_id = justificador.rol_id
|
||||
LEFT JOIN facultad on facultad.facultad_id = justificador.facultad_id
|
||||
where justificador.usuario_id = :justificador_id",
|
||||
array(
|
||||
'justificador_id' => $user->user['id'],
|
||||
)
|
||||
);
|
||||
// exit('exit');
|
||||
|
||||
echo json_encode(array_merge($data, $data_justificador), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
break;
|
||||
|
||||
default:
|
||||
header('HTTP/1.1 405 Method Not Allowed');
|
||||
echo json_encode(['error' => 'Método no permitido']);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode([
|
||||
'error' => $e->getMessage(),
|
||||
'query' => $db->getLastQuery(),
|
||||
'exception' => $e->getTraceAsString()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'error' => $e->getMessage(),
|
||||
'exception' => $e->getTraceAsString()
|
||||
]);
|
||||
}
|
||||
@@ -1,31 +1,31 @@
|
||||
<?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
|
||||
$nivel = $db->get('nivel');
|
||||
echo json_encode($nivel);
|
||||
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()
|
||||
]);
|
||||
<?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
|
||||
$nivel = $db->get('nivel');
|
||||
echo json_encode($nivel);
|
||||
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()
|
||||
]);
|
||||
}
|
||||
@@ -1,44 +1,44 @@
|
||||
<?
|
||||
#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 $ruta . "class/c_login.php";
|
||||
|
||||
if (!isset($_SESSION['user'])) {
|
||||
http_response_code(401);
|
||||
die(json_encode(['error' => 'unauthorized']));
|
||||
}
|
||||
$user = unserialize($_SESSION['user']);
|
||||
// check method
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||||
http_response_code(405);
|
||||
die(json_encode(['error' => 'method not allowed']));
|
||||
}
|
||||
|
||||
const JSON_OPTIONS = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR;
|
||||
try {
|
||||
$data = $db->querySingle("SELECT *, LEAST(periodo_fecha_fin, CURRENT_DATE) as fecha_final FROM periodo WHERE periodo_id = ?", array($user->periodo_id));
|
||||
$last_query = [
|
||||
'query' => $db->getLastQuery(),
|
||||
];
|
||||
|
||||
echo json_encode($data, JSON_OPTIONS);
|
||||
} catch (PDOException $th) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => $th->getMessage(),
|
||||
'query' => $db->getLastQuery(),
|
||||
], JSON_OPTIONS);
|
||||
exit;
|
||||
} catch (Exception $th) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => $th->getMessage(),
|
||||
], JSON_OPTIONS);
|
||||
exit;
|
||||
<?
|
||||
#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 $ruta . "class/c_login.php";
|
||||
|
||||
if (!isset($_SESSION['user'])) {
|
||||
http_response_code(401);
|
||||
die(json_encode(['error' => 'unauthorized']));
|
||||
}
|
||||
$user = unserialize($_SESSION['user']);
|
||||
// check method
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||||
http_response_code(405);
|
||||
die(json_encode(['error' => 'method not allowed']));
|
||||
}
|
||||
|
||||
const JSON_OPTIONS = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR;
|
||||
try {
|
||||
$data = $db->querySingle("SELECT *, LEAST(periodo_fecha_fin, CURRENT_DATE) as fecha_final FROM periodo WHERE periodo_id = ?", array($user->periodo_id));
|
||||
$last_query = [
|
||||
'query' => $db->getLastQuery(),
|
||||
];
|
||||
|
||||
echo json_encode($data, JSON_OPTIONS);
|
||||
} catch (PDOException $th) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => $th->getMessage(),
|
||||
'query' => $db->getLastQuery(),
|
||||
], JSON_OPTIONS);
|
||||
exit;
|
||||
} catch (Exception $th) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => $th->getMessage(),
|
||||
], JSON_OPTIONS);
|
||||
exit;
|
||||
}
|
||||
@@ -1,204 +1,204 @@
|
||||
<?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
|
||||
$periodo_id = $user->periodo_id;
|
||||
if (is_null($user->facultad['facultad_id'])) {
|
||||
$periodos = $db
|
||||
//->where('CURRENT_DATE BETWEEN periodo_fecha_inicio AND periodo_fecha_fin')
|
||||
->join('nivel', 'nivel.nivel_id = periodo.nivel_id')
|
||||
->orderBy('periodo_id')
|
||||
->get('periodo', null, 'periodo.*, nivel_nombre as nivel');
|
||||
} else {
|
||||
$periodos = $db->query(
|
||||
"SELECT DISTINCT periodo.*, nivel_nombre as nivel FROM periodo
|
||||
JOIN horario_view USING (periodo_id)
|
||||
JOIN nivel ON nivel.nivel_id = periodo.nivel_id
|
||||
WHERE /*CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin
|
||||
AND */facultad_id = :facultad_id
|
||||
ORDER BY periodo_id
|
||||
",
|
||||
['facultad_id' => $user->facultad['facultad_id']]
|
||||
);
|
||||
}
|
||||
echo json_encode($periodos);
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
// Update nivel_id of a periodo
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw, true);
|
||||
|
||||
if (!isset($data['action'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta la acción a realizar']);
|
||||
exit();
|
||||
}
|
||||
|
||||
switch ($data['action']) {
|
||||
case 'changeNivel':
|
||||
if (!isset($data['periodo_id'], $data['nivel_id'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id del periodo o el nivel']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
$nivel_id = $data['nivel_id'];
|
||||
$db->where('periodo_id', $periodo_id)->update('periodo', ['nivel_id' => $nivel_id]);
|
||||
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
$nivel_nombre = $db->where('nivel_id', $nivel_id)->getOne('nivel', 'nivel_nombre')['nivel_nombre'];
|
||||
|
||||
echo json_encode([
|
||||
'success' =>
|
||||
"El nivel del periodo $periodo_nombre ha sido cambiado a $nivel_nombre"
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'changeFechaInicio':
|
||||
if (!isset($data['periodo_id'], $data['periodo_fecha_inicio'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id del periodo o la fecha de inicio']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
$periodo_fecha_inicio = $data['periodo_fecha_inicio'];
|
||||
$db->where('periodo_id', $periodo_id)->update('periodo', ['periodo_fecha_inicio' => $periodo_fecha_inicio]);
|
||||
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
|
||||
echo json_encode([
|
||||
'success' =>
|
||||
"La fecha de inicio del periodo $periodo_nombre ha sido cambiada a $periodo_fecha_inicio"
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'changeFechaFin':
|
||||
if (!isset($data['periodo_id'], $data['periodo_fecha_fin'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id del periodo o la fecha de fin']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
$periodo_fecha_fin = $data['periodo_fecha_fin'];
|
||||
$db->where('periodo_id', $periodo_id)->update('periodo', ['periodo_fecha_fin' => $periodo_fecha_fin]);
|
||||
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
|
||||
echo json_encode([
|
||||
'success' =>
|
||||
"La fecha de fin del periodo $periodo_nombre ha sido cambiada a $periodo_fecha_fin"
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'updatePeriodo':
|
||||
if (!isset($data['periodo_id'], $data['periodo_nombre'], $data['id_periodo_sgu'], $data['periodo_clave'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Faltan datos para actualizar el periodo']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
|
||||
$db->where('periodo_id', $periodo_id)->update('periodo', array_filter($data, fn($key) => in_array($key, [
|
||||
'periodo_nombre',
|
||||
'id_periodo_sgu',
|
||||
'periodo_clave',
|
||||
]), ARRAY_FILTER_USE_KEY));
|
||||
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
|
||||
echo json_encode([
|
||||
'success' =>
|
||||
"El periodo $periodo_nombre ha sido actualizado"
|
||||
]);
|
||||
break;
|
||||
|
||||
default:
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Acción no válida']);
|
||||
exit();
|
||||
}
|
||||
|
||||
break;
|
||||
case 'POST':
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw, true);
|
||||
|
||||
if (!isset($data['periodo_nombre'], $data['nivel_id'], $data['periodo_fecha_inicio'], $data['periodo_fecha_fin'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Faltan datos para crear el periodo']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$newPeriodo = $db->insert(
|
||||
'periodo',
|
||||
array_filter($data, fn($key) => in_array($key, [
|
||||
'periodo_nombre',
|
||||
'nivel_id',
|
||||
'periodo_fecha_inicio',
|
||||
'periodo_fecha_fin',
|
||||
'periodo_clave',
|
||||
'id_periodo_sgu',
|
||||
]), ARRAY_FILTER_USE_KEY)
|
||||
);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => 'El periodo ha sido creado',
|
||||
'periodo' => $newPeriodo
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'DELETE':
|
||||
// Delete a periodo
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw, true);
|
||||
|
||||
if (!isset($data['periodo_id'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id del periodo']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
|
||||
$db->where('periodo_id', $periodo_id)->delete('periodo');
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => "El periodo $periodo_nombre ha sido eliminado"
|
||||
]);
|
||||
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()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'error' => $e->getMessage(),
|
||||
'exception' => $e->getTraceAsString()
|
||||
]);
|
||||
<?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
|
||||
$periodo_id = $user->periodo_id;
|
||||
if (is_null($user->facultad['facultad_id'])) {
|
||||
$periodos = $db
|
||||
//->where('CURRENT_DATE BETWEEN periodo_fecha_inicio AND periodo_fecha_fin')
|
||||
->join('nivel', 'nivel.nivel_id = periodo.nivel_id')
|
||||
->orderBy('periodo_id')
|
||||
->get('periodo', null, 'periodo.*, nivel_nombre as nivel');
|
||||
} else {
|
||||
$periodos = $db->query(
|
||||
"SELECT DISTINCT periodo.*, nivel_nombre as nivel FROM periodo
|
||||
JOIN horario_view USING (periodo_id)
|
||||
JOIN nivel ON nivel.nivel_id = periodo.nivel_id
|
||||
WHERE /*CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin
|
||||
AND */facultad_id = :facultad_id
|
||||
ORDER BY periodo_id
|
||||
",
|
||||
['facultad_id' => $user->facultad['facultad_id']]
|
||||
);
|
||||
}
|
||||
echo json_encode($periodos);
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
// Update nivel_id of a periodo
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw, true);
|
||||
|
||||
if (!isset($data['action'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta la acción a realizar']);
|
||||
exit();
|
||||
}
|
||||
|
||||
switch ($data['action']) {
|
||||
case 'changeNivel':
|
||||
if (!isset($data['periodo_id'], $data['nivel_id'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id del periodo o el nivel']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
$nivel_id = $data['nivel_id'];
|
||||
$db->where('periodo_id', $periodo_id)->update('periodo', ['nivel_id' => $nivel_id]);
|
||||
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
$nivel_nombre = $db->where('nivel_id', $nivel_id)->getOne('nivel', 'nivel_nombre')['nivel_nombre'];
|
||||
|
||||
echo json_encode([
|
||||
'success' =>
|
||||
"El nivel del periodo $periodo_nombre ha sido cambiado a $nivel_nombre"
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'changeFechaInicio':
|
||||
if (!isset($data['periodo_id'], $data['periodo_fecha_inicio'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id del periodo o la fecha de inicio']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
$periodo_fecha_inicio = $data['periodo_fecha_inicio'];
|
||||
$db->where('periodo_id', $periodo_id)->update('periodo', ['periodo_fecha_inicio' => $periodo_fecha_inicio]);
|
||||
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
|
||||
echo json_encode([
|
||||
'success' =>
|
||||
"La fecha de inicio del periodo $periodo_nombre ha sido cambiada a $periodo_fecha_inicio"
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'changeFechaFin':
|
||||
if (!isset($data['periodo_id'], $data['periodo_fecha_fin'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id del periodo o la fecha de fin']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
$periodo_fecha_fin = $data['periodo_fecha_fin'];
|
||||
$db->where('periodo_id', $periodo_id)->update('periodo', ['periodo_fecha_fin' => $periodo_fecha_fin]);
|
||||
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
|
||||
echo json_encode([
|
||||
'success' =>
|
||||
"La fecha de fin del periodo $periodo_nombre ha sido cambiada a $periodo_fecha_fin"
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'updatePeriodo':
|
||||
if (!isset($data['periodo_id'], $data['periodo_nombre'], $data['id_periodo_sgu'], $data['periodo_clave'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Faltan datos para actualizar el periodo']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
|
||||
$db->where('periodo_id', $periodo_id)->update('periodo', array_filter($data, fn($key) => in_array($key, [
|
||||
'periodo_nombre',
|
||||
'id_periodo_sgu',
|
||||
'periodo_clave',
|
||||
]), ARRAY_FILTER_USE_KEY));
|
||||
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
|
||||
echo json_encode([
|
||||
'success' =>
|
||||
"El periodo $periodo_nombre ha sido actualizado"
|
||||
]);
|
||||
break;
|
||||
|
||||
default:
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Acción no válida']);
|
||||
exit();
|
||||
}
|
||||
|
||||
break;
|
||||
case 'POST':
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw, true);
|
||||
|
||||
if (!isset($data['periodo_nombre'], $data['nivel_id'], $data['periodo_fecha_inicio'], $data['periodo_fecha_fin'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Faltan datos para crear el periodo']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$newPeriodo = $db->insert(
|
||||
'periodo',
|
||||
array_filter($data, fn($key) => in_array($key, [
|
||||
'periodo_nombre',
|
||||
'nivel_id',
|
||||
'periodo_fecha_inicio',
|
||||
'periodo_fecha_fin',
|
||||
'periodo_clave',
|
||||
'id_periodo_sgu',
|
||||
]), ARRAY_FILTER_USE_KEY)
|
||||
);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => 'El periodo ha sido creado',
|
||||
'periodo' => $newPeriodo
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'DELETE':
|
||||
// Delete a periodo
|
||||
$raw = file_get_contents('php://input');
|
||||
$data = json_decode($raw, true);
|
||||
|
||||
if (!isset($data['periodo_id'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Falta el id del periodo']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$periodo_id = $data['periodo_id'];
|
||||
$periodo_nombre = $db->where('periodo_id', $periodo_id)->getOne('periodo', 'periodo_nombre')['periodo_nombre'];
|
||||
|
||||
$db->where('periodo_id', $periodo_id)->delete('periodo');
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => "El periodo $periodo_nombre ha sido eliminado"
|
||||
]);
|
||||
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()
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'error' => $e->getMessage(),
|
||||
'exception' => $e->getTraceAsString()
|
||||
]);
|
||||
}
|
||||
@@ -1,135 +1,135 @@
|
||||
<?
|
||||
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':
|
||||
$facultad = $_GET['facultad'] ?? $user->facultad['facultad_id'] ?? null;
|
||||
$porcentaje = $_GET['porcentaje'] ?? null;
|
||||
$faltas = $_GET['faltas'] ?? null;
|
||||
|
||||
if (!isset($facultad) || !is_numeric($facultad)) {
|
||||
$error = 'No se ha seleccionado una facultad';
|
||||
} else if ((!isset($faltas) || !is_numeric($faltas)) && (!isset($porcentaje) || !is_numeric($porcentaje))) {
|
||||
$error = 'Debe especificar las faltas o el porcentaje';
|
||||
} else if (isset($faltas) && (!is_numeric($faltas) || $faltas <= 0)) {
|
||||
$error = 'Las faltas deben ser un número mayor a 0';
|
||||
} else if (isset($porcentaje) && (!is_numeric($porcentaje) || $porcentaje <= 0)) {
|
||||
$error = 'El porcentaje debe ser un número mayor a 0';
|
||||
} else if (isset($faltas) && isset($porcentaje)) {
|
||||
$error = 'No se puede especificar las faltas y el porcentaje al mismo tiempo';
|
||||
} else if (!isset($facultad) || !is_numeric($facultad)) {
|
||||
$error = 'Debe especificar una facultad';
|
||||
}
|
||||
|
||||
if (isset($error)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => $error]);
|
||||
exit();
|
||||
}
|
||||
// Initialize the data array
|
||||
$data = array();
|
||||
|
||||
// Check if 'profesor' or 'supervisor' is set and prepare the specific part of the SQL query accordingly.
|
||||
if (isset($_GET['profesor']) || isset($_GET['supervisor'])) {
|
||||
|
||||
$condition = isset($_GET['profesor'])
|
||||
? "r.registro_fecha IS NULL AND NOT COALESCE(r.registro_justificada, FALSE)"
|
||||
: "estado_supervisor_id = 2";
|
||||
|
||||
$filter = isset($faltas)
|
||||
? "afcp.faltas >= :faltas"
|
||||
: "afcp.porcentaje >= :porcentaje";
|
||||
|
||||
// Prepare the SQL query with placeholders for parameters
|
||||
$data = array_column($db->query(
|
||||
"WITH fechas AS (
|
||||
SELECT
|
||||
h.horario_id,
|
||||
fechas_clase(h.horario_id, true) AS registro_fecha_ideal,
|
||||
hp.profesor_id
|
||||
FROM horario h
|
||||
JOIN horario_profesor hp USING (horario_id)
|
||||
WHERE (h.PERIODO_ID, h.FACULTAD_ID) = (:periodo_id, :facultad_id) AND hp.profesor_id <> 0
|
||||
),
|
||||
asistencia_faltas AS (
|
||||
SELECT
|
||||
f.profesor_id,
|
||||
COUNT(1) AS total,
|
||||
COUNT(1) FILTER (WHERE $condition AND f.registro_fecha_ideal <= current_date) AS faltas
|
||||
FROM fechas f
|
||||
LEFT JOIN registro r USING (registro_fecha_ideal, horario_id, profesor_id)
|
||||
GROUP BY f.profesor_id
|
||||
),
|
||||
asistencia_faltas_con_porcentaje AS (
|
||||
SELECT
|
||||
af.profesor_id,
|
||||
af.faltas,
|
||||
af.total,
|
||||
CASE
|
||||
WHEN af.total > 0 THEN ROUND((af.faltas::NUMERIC / af.total) * 100, 2)
|
||||
ELSE NULL
|
||||
END AS porcentaje
|
||||
FROM asistencia_faltas af
|
||||
WHERE af.faltas > 0
|
||||
)
|
||||
SELECT
|
||||
json_build_object(
|
||||
'profesor', json_build_object(
|
||||
'profesor_nombre', p.profesor_nombre,
|
||||
'profesor_clave', p.profesor_clave,
|
||||
'profesor_correo', p.profesor_correo
|
||||
),
|
||||
'profesor_id', afcp.profesor_id,
|
||||
'faltas', afcp.faltas,
|
||||
'total', afcp.total,
|
||||
'porcentaje', afcp.porcentaje
|
||||
) AS result_json
|
||||
FROM asistencia_faltas_con_porcentaje afcp
|
||||
JOIN profesor p USING (profesor_id)
|
||||
WHERE $filter
|
||||
ORDER BY afcp.porcentaje DESC;
|
||||
",
|
||||
[
|
||||
'periodo_id' => $user->periodo_id,
|
||||
'facultad_id' => $facultad,
|
||||
] + (isset($faltas)
|
||||
? ['faltas' => $faltas]
|
||||
: ['porcentaje' => $porcentaje])
|
||||
), 'result_json');
|
||||
} else {
|
||||
// Send a 400 Bad Request header and an error message in JSON format
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Especifique si las faltas son de profesor o supervisor']);
|
||||
exit();
|
||||
}
|
||||
if (empty($data)) {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
echo json_encode(['error' => 'No se encontraron faltas']);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array_map(fn($item) => json_decode($item), $data)
|
||||
);
|
||||
}
|
||||
|
||||
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(),
|
||||
]);
|
||||
}
|
||||
<?
|
||||
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':
|
||||
$facultad = $_GET['facultad'] ?? $user->facultad['facultad_id'] ?? null;
|
||||
$porcentaje = $_GET['porcentaje'] ?? null;
|
||||
$faltas = $_GET['faltas'] ?? null;
|
||||
|
||||
if (!isset($facultad) || !is_numeric($facultad)) {
|
||||
$error = 'No se ha seleccionado una facultad';
|
||||
} else if ((!isset($faltas) || !is_numeric($faltas)) && (!isset($porcentaje) || !is_numeric($porcentaje))) {
|
||||
$error = 'Debe especificar las faltas o el porcentaje';
|
||||
} else if (isset($faltas) && (!is_numeric($faltas) || $faltas <= 0)) {
|
||||
$error = 'Las faltas deben ser un número mayor a 0';
|
||||
} else if (isset($porcentaje) && (!is_numeric($porcentaje) || $porcentaje <= 0)) {
|
||||
$error = 'El porcentaje debe ser un número mayor a 0';
|
||||
} else if (isset($faltas) && isset($porcentaje)) {
|
||||
$error = 'No se puede especificar las faltas y el porcentaje al mismo tiempo';
|
||||
} else if (!isset($facultad) || !is_numeric($facultad)) {
|
||||
$error = 'Debe especificar una facultad';
|
||||
}
|
||||
|
||||
if (isset($error)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => $error]);
|
||||
exit();
|
||||
}
|
||||
// Initialize the data array
|
||||
$data = array();
|
||||
|
||||
// Check if 'profesor' or 'supervisor' is set and prepare the specific part of the SQL query accordingly.
|
||||
if (isset($_GET['profesor']) || isset($_GET['supervisor'])) {
|
||||
|
||||
$condition = isset($_GET['profesor'])
|
||||
? "r.registro_fecha IS NULL AND NOT COALESCE(r.registro_justificada, FALSE)"
|
||||
: "estado_supervisor_id = 2";
|
||||
|
||||
$filter = isset($faltas)
|
||||
? "afcp.faltas >= :faltas"
|
||||
: "afcp.porcentaje >= :porcentaje";
|
||||
|
||||
// Prepare the SQL query with placeholders for parameters
|
||||
$data = array_column($db->query(
|
||||
"WITH fechas AS (
|
||||
SELECT
|
||||
h.horario_id,
|
||||
fechas_clase(h.horario_id, true) AS registro_fecha_ideal,
|
||||
hp.profesor_id
|
||||
FROM horario h
|
||||
JOIN horario_profesor hp USING (horario_id)
|
||||
WHERE (h.PERIODO_ID, h.FACULTAD_ID) = (:periodo_id, :facultad_id) AND hp.profesor_id <> 0
|
||||
),
|
||||
asistencia_faltas AS (
|
||||
SELECT
|
||||
f.profesor_id,
|
||||
COUNT(1) AS total,
|
||||
COUNT(1) FILTER (WHERE $condition AND f.registro_fecha_ideal <= current_date) AS faltas
|
||||
FROM fechas f
|
||||
LEFT JOIN registro r USING (registro_fecha_ideal, horario_id, profesor_id)
|
||||
GROUP BY f.profesor_id
|
||||
),
|
||||
asistencia_faltas_con_porcentaje AS (
|
||||
SELECT
|
||||
af.profesor_id,
|
||||
af.faltas,
|
||||
af.total,
|
||||
CASE
|
||||
WHEN af.total > 0 THEN ROUND((af.faltas::NUMERIC / af.total) * 100, 2)
|
||||
ELSE NULL
|
||||
END AS porcentaje
|
||||
FROM asistencia_faltas af
|
||||
WHERE af.faltas > 0
|
||||
)
|
||||
SELECT
|
||||
json_build_object(
|
||||
'profesor', json_build_object(
|
||||
'profesor_nombre', p.profesor_nombre,
|
||||
'profesor_clave', p.profesor_clave,
|
||||
'profesor_correo', p.profesor_correo
|
||||
),
|
||||
'profesor_id', afcp.profesor_id,
|
||||
'faltas', afcp.faltas,
|
||||
'total', afcp.total,
|
||||
'porcentaje', afcp.porcentaje
|
||||
) AS result_json
|
||||
FROM asistencia_faltas_con_porcentaje afcp
|
||||
JOIN profesor p USING (profesor_id)
|
||||
WHERE $filter
|
||||
ORDER BY afcp.porcentaje DESC;
|
||||
",
|
||||
[
|
||||
'periodo_id' => $user->periodo_id,
|
||||
'facultad_id' => $facultad,
|
||||
] + (isset($faltas)
|
||||
? ['faltas' => $faltas]
|
||||
: ['porcentaje' => $porcentaje])
|
||||
), 'result_json');
|
||||
} else {
|
||||
// Send a 400 Bad Request header and an error message in JSON format
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Especifique si las faltas son de profesor o supervisor']);
|
||||
exit();
|
||||
}
|
||||
if (empty($data)) {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
echo json_encode(['error' => 'No se encontraron faltas']);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array_map(fn($item) => json_decode($item), $data)
|
||||
);
|
||||
}
|
||||
|
||||
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(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,113 +1,113 @@
|
||||
<?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'] ?? -1;
|
||||
$puestos = array_map(
|
||||
fn($p) => array(
|
||||
...$p,
|
||||
'materias' => $db->where('puesto_id', $p['puesto_id'])
|
||||
->join('puesto_materia', 'puesto_materia.materia_id = materia.materia_id', 'LEFT')
|
||||
->get(tableName: 'materia', columns: ['materia.materia_id', 'materia_nombre', 'clave_materia',]),
|
||||
'encargado' => $db->where('puesto_id', $p['puesto_id'])
|
||||
->join('puesto_usuario', 'puesto_usuario.usuario_id = usuario.usuario_id', 'LEFT')
|
||||
->getOne('usuario', ['usuario.usuario_id', 'usuario_nombre', 'usuario_clave']),
|
||||
),
|
||||
$db->orderBy('puesto.nombre', 'desc')
|
||||
->where('facultad_id', $facultad_id)
|
||||
->get(tableName: 'puesto', columns: 'puesto_id, nombre'),
|
||||
);
|
||||
echo json_encode($puestos);
|
||||
break;
|
||||
|
||||
case 'POST':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
$input_data = json_decode($raw_input, true);
|
||||
|
||||
if (!$input_data || !isset($input_data['puesto_nombre'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Datos inválidos']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$puesto = $db->insert('puesto', [
|
||||
'nombre' => $input_data['puesto_nombre'],
|
||||
'facultad_id' => $user->facultad['facultad_id'],
|
||||
], ['puesto_id', 'nombre', 'facultad_id']);
|
||||
|
||||
echo json_encode(
|
||||
array(
|
||||
...$puesto,
|
||||
'materias' => [],
|
||||
'encargado' => null,
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
$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'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Datos inválidos']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$db->where('puesto_id', $input_data['puesto_id'])->delete('puesto_materia');
|
||||
$db->where('puesto_id', $input_data['puesto_id'])->delete('puesto_usuario');
|
||||
|
||||
foreach ($input_data['materias'] as $materia_id) {
|
||||
$db->insert('puesto_materia', [
|
||||
'puesto_id' => $input_data['puesto_id'],
|
||||
'materia_id' => $materia_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;
|
||||
|
||||
case 'DELETE':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
$input_data = json_decode($raw_input, true);
|
||||
|
||||
if (!$input_data || !isset($input_data['puesto_id'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Datos inválidos']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$db->where('puesto_id', $input_data['puesto_id'])->delete('puesto');
|
||||
echo json_encode(['msg' => 'Puesto eliminado exitosamente']);
|
||||
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()
|
||||
]);
|
||||
<?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'] ?? -1;
|
||||
$puestos = array_map(
|
||||
fn($p) => array(
|
||||
...$p,
|
||||
'materias' => $db->where('puesto_id', $p['puesto_id'])
|
||||
->join('puesto_materia', 'puesto_materia.materia_id = materia.materia_id', 'LEFT')
|
||||
->get(tableName: 'materia', columns: ['materia.materia_id', 'materia_nombre', 'clave_materia',]),
|
||||
'encargado' => $db->where('puesto_id', $p['puesto_id'])
|
||||
->join('puesto_usuario', 'puesto_usuario.usuario_id = usuario.usuario_id', 'LEFT')
|
||||
->getOne('usuario', ['usuario.usuario_id', 'usuario_nombre', 'usuario_clave']),
|
||||
),
|
||||
$db->orderBy('puesto.nombre', 'desc')
|
||||
->where('facultad_id', $facultad_id)
|
||||
->get(tableName: 'puesto', columns: 'puesto_id, nombre'),
|
||||
);
|
||||
echo json_encode($puestos);
|
||||
break;
|
||||
|
||||
case 'POST':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
$input_data = json_decode($raw_input, true);
|
||||
|
||||
if (!$input_data || !isset($input_data['puesto_nombre'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Datos inválidos']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$puesto = $db->insert('puesto', [
|
||||
'nombre' => $input_data['puesto_nombre'],
|
||||
'facultad_id' => $user->facultad['facultad_id'],
|
||||
], ['puesto_id', 'nombre', 'facultad_id']);
|
||||
|
||||
echo json_encode(
|
||||
array(
|
||||
...$puesto,
|
||||
'materias' => [],
|
||||
'encargado' => null,
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
$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'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Datos inválidos']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$db->where('puesto_id', $input_data['puesto_id'])->delete('puesto_materia');
|
||||
$db->where('puesto_id', $input_data['puesto_id'])->delete('puesto_usuario');
|
||||
|
||||
foreach ($input_data['materias'] as $materia_id) {
|
||||
$db->insert('puesto_materia', [
|
||||
'puesto_id' => $input_data['puesto_id'],
|
||||
'materia_id' => $materia_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;
|
||||
|
||||
case 'DELETE':
|
||||
$raw_input = file_get_contents('php://input');
|
||||
$input_data = json_decode($raw_input, true);
|
||||
|
||||
if (!$input_data || !isset($input_data['puesto_id'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Datos inválidos']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$db->where('puesto_id', $input_data['puesto_id'])->delete('puesto');
|
||||
echo json_encode(['msg' => 'Puesto eliminado exitosamente']);
|
||||
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()
|
||||
]);
|
||||
}
|
||||
@@ -1,288 +1,288 @@
|
||||
<?php
|
||||
/*
|
||||
Cambia de estado la reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
require_once "../class/mailer.php";
|
||||
|
||||
define("COORDINADOR", 9);
|
||||
define("SUPERVISOR", 7);
|
||||
define("ENVIO_CORREOS", true);
|
||||
|
||||
// check if the session is started
|
||||
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();
|
||||
}
|
||||
|
||||
$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
|
||||
$tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
$salon = filter_input(INPUT_POST, "salon", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
//--------------
|
||||
|
||||
//Obtiene datos de salón asignado
|
||||
$salon_desc = "Pendiente";
|
||||
if(!empty($salon)){
|
||||
$salon_rs = $db->querySingle('SELECT s.salon_id, s.salon_array FROM salon_view s where s.salon_id = :id_salon',
|
||||
[':id_salon' => $salon]
|
||||
);
|
||||
if($salon_rs["salon_id"] == "" || $salon_rs["salon_id"] == NULL){
|
||||
$salon_desc = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($salon_rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$salon_desc = join(" / ",$salon_json);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($tipo ==1 || $tipo == 2){
|
||||
//--------------
|
||||
//Obtiene datos reposición
|
||||
$reposicion_rs = $db->querySingle('SELECT h.materia, r.fecha_nueva, r.hora_nueva, r.fecha_clase, r.descripcion, h.horario_hora, h.facultad_id, h.facultad, f.clave_dependencia, r.motivo_cancelacion, ta.tipoaula_supervisor , ta.tipoaula_nombre
|
||||
from reposicion_solicitud r
|
||||
inner join horario_view h on h.horario_id = r.horario_id
|
||||
inner join facultad f on f.facultad_id = h.facultad_id
|
||||
inner join tipoaula ta on ta.tipoaula_id = r.tipoaula_id
|
||||
where r.reposicion_solicitud_id = :id_repo',
|
||||
[':id_repo' => $id_repo]
|
||||
);
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT p.profesor_nombre, p.profesor_correo, u.usuario_nombre as jefe_nombre, u.usuario_correo as jefe_correo,
|
||||
coor.usuario_nombre as coordinador_nombre, coor.usuario_correo as coordinador_correo
|
||||
from reposicion_solicitud rs
|
||||
inner join profesor p on rs.profesor_id =p.profesor_id
|
||||
inner join usuario u on u.usuario_id = rs.usuario_id
|
||||
inner join horario_view hv on hv.horario_id = rs.horario_id
|
||||
inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord
|
||||
where rs.reposicion_solicitud_id = :id_repo',
|
||||
[':rol_coord' => COORDINADOR, ':id_repo' => $id_repo]
|
||||
);
|
||||
//print_r($correos_rs); exit();
|
||||
}else{
|
||||
//Obtiene datos asignación
|
||||
$reposicion_rs = $db->querySingle('SELECT r.fecha_nueva, r.hora_nueva, r.descripcion, f.facultad_id, f.facultad_nombre as facultad, f.clave_dependencia, r.motivo_cancelacion, ta.tipoaula_supervisor , ta.tipoaula_nombre, p.profesor_nombre
|
||||
from asignacion_solicitud r
|
||||
inner join usuario u on u.usuario_id = r.usuario_id
|
||||
inner join facultad f on f.facultad_id = u.facultad_id
|
||||
inner join tipoaula ta on ta.tipoaula_id = r.tipoaula_id
|
||||
inner join profesor p on p.profesor_id = r.profesor_id
|
||||
where r.asignacion_solicitud_id = :id_repo',
|
||||
[':id_repo' => $id_repo]
|
||||
);
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT p.profesor_nombre, p.profesor_correo, NULL as jefe_nombre, NULL as jefe_correo,
|
||||
coor.usuario_nombre as coordinador_nombre, coor.usuario_correo as coordinador_correo
|
||||
from asignacion_solicitud rs
|
||||
inner join profesor p on rs.profesor_id =p.profesor_id
|
||||
inner join usuario u on u.usuario_id = rs.usuario_id
|
||||
inner join usuario coor on u.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord
|
||||
where rs.asignacion_solicitud_id = :id_repo',
|
||||
[':rol_coord' => COORDINADOR, ':id_repo' => $id_repo]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$prof_correos=array();
|
||||
$jefe_correos=[];
|
||||
$coord_correos=[];
|
||||
|
||||
foreach($correos_rs as $correo){
|
||||
if( count($prof_correos)==0 && $correo["profesor_correo"]!=""){
|
||||
if( !isset($prof_correos["correo"]) || !in_array($correo["profesor_correo"], $prof_correos["correo"]) ){
|
||||
array_push($prof_correos, $correo["profesor_correo"]);
|
||||
}
|
||||
}
|
||||
if( count($jefe_correos)==0 && $correo["jefe_correo"]!=""){
|
||||
if(!isset($jefe_correos["correo"]) || !in_array($correo["jefe_correo"], $jefe_correos["correo"])){
|
||||
array_push($jefe_correos, $correo["jefe_correo"]);
|
||||
}
|
||||
}
|
||||
if( count($coord_correos)==0 && $correo["coordinador_correo"]!=""){
|
||||
if(!isset($coord_correos["correo"]) || !in_array($correo["coordinador_correo"], $coord_correos["correo"])){
|
||||
array_push($coord_correos, $correo["coordinador_correo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$correosSup_rs = $db->query("SELECT DISTINCT sup.usuario_correo as supervisor_correo
|
||||
FROM horario_supervisor hs
|
||||
inner join usuario sup on sup.usuario_id =hs.usuario_id
|
||||
where :facultad = ANY(hs.facultad_id_array)",
|
||||
[':facultad'=>$reposicion_rs["facultad_id"]] );
|
||||
|
||||
$sup_correos=[];
|
||||
foreach($correosSup_rs as $correo){
|
||||
array_push($sup_correos, $correo["supervisor_correo"]);
|
||||
}
|
||||
|
||||
|
||||
if($tipo ==1 || $tipo == 2){
|
||||
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_solicitud(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':sal' => $salon, ':edo' => $edo]
|
||||
);
|
||||
}else{
|
||||
$db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':edo' => $edo]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fecha_clase = date('d/m/Y', strtotime($reposicion_rs["fecha_clase"]));
|
||||
$fecha_nueva = date('d/m/Y', strtotime($reposicion_rs["fecha_nueva"]));
|
||||
$hora_tmp = explode(":",$reposicion_rs["horario_hora"]);
|
||||
$hora_clase = $hora_tmp[0].":".$hora_tmp[1];
|
||||
$hora_tmp = explode(":",$reposicion_rs["hora_nueva"]);
|
||||
$hora_nueva = $hora_tmp[0].":".$hora_tmp[1];
|
||||
|
||||
$asunto = "";
|
||||
$texto = "";
|
||||
$to = "";
|
||||
switch($edo){
|
||||
case 2://Correo a supervisor
|
||||
$asunto = "Reposición nueva - ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"];
|
||||
//crear plantilla
|
||||
$texto = "<p>Se creó una reposición nueva para: <b>".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"]."</b>.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($reposicion_rs["materia"])."</b> del día <b>".$fecha_clase." a las ".$hora_clase." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora_nueva." hrs.</b>";
|
||||
if(!$reposicion_rs["tipoaula_supervisor"]){
|
||||
$texto .= " en el salón: <b>".$salon_desc."</b></p>";
|
||||
}else{
|
||||
$texto .= " en un salón de tipo: <b>".$reposicion_rs["tipoaula_nombre"]."</b></p>";
|
||||
}
|
||||
$texto .= "<p style='font-style:italic; padding-left:25px'>".$reposicion_rs["descripcion"]."</p>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
$to = join(",", $sup_correos);
|
||||
$ok = 0;
|
||||
break;
|
||||
case 3://Correo a coordinador, profesor y jefe
|
||||
$asunto = "Reposición autorizada - ".$reposicion_rs["materia"];
|
||||
$texto = "<p>La resposición de la clase de <b>".$reposicion_rs["materia"]."</b> del día <b>".$fecha_clase." a las ".$hora_clase." hrs. </b> está autorizada para realizarse el día <b>".$fecha_nueva." a las ".$hora_nueva." hrs. en: $salon_desc</b></p>";
|
||||
$to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos);
|
||||
$ok = 0;
|
||||
$db->querySingle('SELECT fu_reposicion_solicitud_supervisor(:id, :sup)',
|
||||
[':id' => $id_repo, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
break;
|
||||
case 4://Correo a coordinador, profesor y jefe
|
||||
$asunto = "Reposición declinada - ".$reposicion_rs["materia"];
|
||||
$texto = "<p>La resposición de la clase de <b>".$reposicion_rs["materia"]." planeada para el día ".$fecha_nueva." a las ".$hora_nueva." hrs.</b> ha sido declinada por el siguiente motivo:</p>";
|
||||
$texto .= "<p style='font-style:italic; padding-left:25px'>".$motivo."</p>";
|
||||
$to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos);
|
||||
$ok = 1;
|
||||
$db->querySingle('SELECT fu_reposicion_solicitud_supervisor(:id, :sup)',
|
||||
[':id' => $id_repo, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
if($edo == 4){//cancelación
|
||||
$motivo = "";
|
||||
if(isset($_POST["motivo"]) && $_POST["motivo"] != "")
|
||||
$motivo = trim($_POST["motivo"]);
|
||||
$db->querySingle('SELECT fu_asignacion_cancela(:id, :motivo)',
|
||||
[':id' => $id_repo, ':motivo' => $motivo]
|
||||
);
|
||||
}else{
|
||||
if(!empty($salon)){
|
||||
$db->querySingle('SELECT fu_asignacion_solicitud(:id, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':sal' => $salon, ':edo' => $edo]
|
||||
);
|
||||
}else{
|
||||
$db->querySingle('SELECT fu_asignacion_solicitud(:id, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':edo' => $edo]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fecha_nueva = date('d/m/Y', strtotime($reposicion_rs["fecha_nueva"]));
|
||||
$hora_tmp = explode(":",$reposicion_rs["hora_nueva"]);
|
||||
$hora_nueva = $hora_tmp[0].":".$hora_tmp[1];
|
||||
|
||||
$asunto = "";
|
||||
$texto = "";
|
||||
$to = "";
|
||||
switch($edo){
|
||||
case 2://Correo a supervisor
|
||||
$asunto = "Asignación nueva - ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"];
|
||||
//crear plantilla
|
||||
$texto = "<p>Se creó una solicitud de asignación nueva para: <b>".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"]."</b>.</p>";
|
||||
$texto .= "<p>Se solicita el día <b>".$fecha_nueva." a las ".$hora_nueva." hrs.</b> para el profesor: <b>".$reposicion_rs["profesor_nombre"]."</b>.";
|
||||
if(!$reposicion_rs["tipoaula_supervisor"]){
|
||||
$texto .= " en el salón: <b>".$salon_desc."</b></p>";
|
||||
}else{
|
||||
$texto .= " en un salón de tipo: <b>".$reposicion_rs["tipoaula_nombre"]."</b></p>";
|
||||
}
|
||||
$texto .= "<p style='font-style:italic; padding-left:25px'>".$reposicion_rs["descripcion"]."</p>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
$to = join(",", $sup_correos);
|
||||
$ok = 0;
|
||||
break;
|
||||
case 3://Correo a coordinador, profesor y jefe
|
||||
$asunto = "Asignación autorizada - ".$reposicion_rs["profesor_nombre"];
|
||||
$texto = "<p>La asignación de espacio para el profesor <b>".$reposicion_rs["profesor_nombre"]."</b> está autorizada para realizarse el día <b>".$fecha_nueva." a las ".$hora_nueva." hrs. en: $salon_desc</b></p>";
|
||||
$to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos);
|
||||
$ok = 0;
|
||||
$db->querySingle('SELECT fu_asignacion_solicitud_supervisor(:id, :sup)',
|
||||
[':id' => $id_repo, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
break;
|
||||
case 4://Correo a coordinador, profesor y jefe
|
||||
$asunto = "Asignación declinada - ".$reposicion_rs["profesor_nombre"];
|
||||
$texto = "<p>La asignación de espacio para el profesor <b>".$reposicion_rs["profesor_nombre"]."</b> planeada para el día ".$fecha_nueva." a las ".$hora_nueva." hrs.</b> ha sido declinada por el siguiente motivo:</p>";
|
||||
$texto .= "<p style='font-style:italic; padding-left:25px'>".$motivo."</p>";
|
||||
$to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos);
|
||||
$ok = 1;
|
||||
$db->querySingle('SELECT fu_asignacion_solicitud_supervisor(:id, :sup)',
|
||||
[':id' => $id_repo, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($to!= "" && ENVIO_CORREOS){
|
||||
$texto = '<body >
|
||||
<img src="https://paad.lci.ulsa.mx/imagenes/logo_lasalle.png" alt="La Salle" style="margin-bottom:60px">
|
||||
'.$texto.'
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
|
||||
*/
|
||||
header("Location: ".$pag."?ok=".$ok);
|
||||
exit();
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
Cambia de estado la reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
require_once "../class/mailer.php";
|
||||
|
||||
define("COORDINADOR", 9);
|
||||
define("SUPERVISOR", 7);
|
||||
define("ENVIO_CORREOS", true);
|
||||
|
||||
// check if the session is started
|
||||
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();
|
||||
}
|
||||
|
||||
$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
|
||||
$tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
$salon = filter_input(INPUT_POST, "salon", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
//--------------
|
||||
|
||||
//Obtiene datos de salón asignado
|
||||
$salon_desc = "Pendiente";
|
||||
if(!empty($salon)){
|
||||
$salon_rs = $db->querySingle('SELECT s.salon_id, s.salon_array FROM salon_view s where s.salon_id = :id_salon',
|
||||
[':id_salon' => $salon]
|
||||
);
|
||||
if($salon_rs["salon_id"] == "" || $salon_rs["salon_id"] == NULL){
|
||||
$salon_desc = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($salon_rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$salon_desc = join(" / ",$salon_json);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($tipo ==1 || $tipo == 2){
|
||||
//--------------
|
||||
//Obtiene datos reposición
|
||||
$reposicion_rs = $db->querySingle('SELECT h.materia, r.fecha_nueva, r.hora_nueva, r.fecha_clase, r.descripcion, h.horario_hora, h.facultad_id, h.facultad, f.clave_dependencia, r.motivo_cancelacion, ta.tipoaula_supervisor , ta.tipoaula_nombre
|
||||
from reposicion_solicitud r
|
||||
inner join horario_view h on h.horario_id = r.horario_id
|
||||
inner join facultad f on f.facultad_id = h.facultad_id
|
||||
inner join tipoaula ta on ta.tipoaula_id = r.tipoaula_id
|
||||
where r.reposicion_solicitud_id = :id_repo',
|
||||
[':id_repo' => $id_repo]
|
||||
);
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT p.profesor_nombre, p.profesor_correo, u.usuario_nombre as jefe_nombre, u.usuario_correo as jefe_correo,
|
||||
coor.usuario_nombre as coordinador_nombre, coor.usuario_correo as coordinador_correo
|
||||
from reposicion_solicitud rs
|
||||
inner join profesor p on rs.profesor_id =p.profesor_id
|
||||
inner join usuario u on u.usuario_id = rs.usuario_id
|
||||
inner join horario_view hv on hv.horario_id = rs.horario_id
|
||||
inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord
|
||||
where rs.reposicion_solicitud_id = :id_repo',
|
||||
[':rol_coord' => COORDINADOR, ':id_repo' => $id_repo]
|
||||
);
|
||||
//print_r($correos_rs); exit();
|
||||
}else{
|
||||
//Obtiene datos asignación
|
||||
$reposicion_rs = $db->querySingle('SELECT r.fecha_nueva, r.hora_nueva, r.descripcion, f.facultad_id, f.facultad_nombre as facultad, f.clave_dependencia, r.motivo_cancelacion, ta.tipoaula_supervisor , ta.tipoaula_nombre, p.profesor_nombre
|
||||
from asignacion_solicitud r
|
||||
inner join usuario u on u.usuario_id = r.usuario_id
|
||||
inner join facultad f on f.facultad_id = u.facultad_id
|
||||
inner join tipoaula ta on ta.tipoaula_id = r.tipoaula_id
|
||||
inner join profesor p on p.profesor_id = r.profesor_id
|
||||
where r.asignacion_solicitud_id = :id_repo',
|
||||
[':id_repo' => $id_repo]
|
||||
);
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT p.profesor_nombre, p.profesor_correo, NULL as jefe_nombre, NULL as jefe_correo,
|
||||
coor.usuario_nombre as coordinador_nombre, coor.usuario_correo as coordinador_correo
|
||||
from asignacion_solicitud rs
|
||||
inner join profesor p on rs.profesor_id =p.profesor_id
|
||||
inner join usuario u on u.usuario_id = rs.usuario_id
|
||||
inner join usuario coor on u.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord
|
||||
where rs.asignacion_solicitud_id = :id_repo',
|
||||
[':rol_coord' => COORDINADOR, ':id_repo' => $id_repo]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$prof_correos=array();
|
||||
$jefe_correos=[];
|
||||
$coord_correos=[];
|
||||
|
||||
foreach($correos_rs as $correo){
|
||||
if( count($prof_correos)==0 && $correo["profesor_correo"]!=""){
|
||||
if( !isset($prof_correos["correo"]) || !in_array($correo["profesor_correo"], $prof_correos["correo"]) ){
|
||||
array_push($prof_correos, $correo["profesor_correo"]);
|
||||
}
|
||||
}
|
||||
if( count($jefe_correos)==0 && $correo["jefe_correo"]!=""){
|
||||
if(!isset($jefe_correos["correo"]) || !in_array($correo["jefe_correo"], $jefe_correos["correo"])){
|
||||
array_push($jefe_correos, $correo["jefe_correo"]);
|
||||
}
|
||||
}
|
||||
if( count($coord_correos)==0 && $correo["coordinador_correo"]!=""){
|
||||
if(!isset($coord_correos["correo"]) || !in_array($correo["coordinador_correo"], $coord_correos["correo"])){
|
||||
array_push($coord_correos, $correo["coordinador_correo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$correosSup_rs = $db->query("SELECT DISTINCT sup.usuario_correo as supervisor_correo
|
||||
FROM horario_supervisor hs
|
||||
inner join usuario sup on sup.usuario_id =hs.usuario_id
|
||||
where :facultad = ANY(hs.facultad_id_array)",
|
||||
[':facultad'=>$reposicion_rs["facultad_id"]] );
|
||||
|
||||
$sup_correos=[];
|
||||
foreach($correosSup_rs as $correo){
|
||||
array_push($sup_correos, $correo["supervisor_correo"]);
|
||||
}
|
||||
|
||||
|
||||
if($tipo ==1 || $tipo == 2){
|
||||
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_solicitud(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':sal' => $salon, ':edo' => $edo]
|
||||
);
|
||||
}else{
|
||||
$db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':edo' => $edo]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fecha_clase = date('d/m/Y', strtotime($reposicion_rs["fecha_clase"]));
|
||||
$fecha_nueva = date('d/m/Y', strtotime($reposicion_rs["fecha_nueva"]));
|
||||
$hora_tmp = explode(":",$reposicion_rs["horario_hora"]);
|
||||
$hora_clase = $hora_tmp[0].":".$hora_tmp[1];
|
||||
$hora_tmp = explode(":",$reposicion_rs["hora_nueva"]);
|
||||
$hora_nueva = $hora_tmp[0].":".$hora_tmp[1];
|
||||
|
||||
$asunto = "";
|
||||
$texto = "";
|
||||
$to = "";
|
||||
switch($edo){
|
||||
case 2://Correo a supervisor
|
||||
$asunto = "Reposición nueva - ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"];
|
||||
//crear plantilla
|
||||
$texto = "<p>Se creó una reposición nueva para: <b>".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"]."</b>.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($reposicion_rs["materia"])."</b> del día <b>".$fecha_clase." a las ".$hora_clase." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora_nueva." hrs.</b>";
|
||||
if(!$reposicion_rs["tipoaula_supervisor"]){
|
||||
$texto .= " en el salón: <b>".$salon_desc."</b></p>";
|
||||
}else{
|
||||
$texto .= " en un salón de tipo: <b>".$reposicion_rs["tipoaula_nombre"]."</b></p>";
|
||||
}
|
||||
$texto .= "<p style='font-style:italic; padding-left:25px'>".$reposicion_rs["descripcion"]."</p>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
$to = join(",", $sup_correos);
|
||||
$ok = 0;
|
||||
break;
|
||||
case 3://Correo a coordinador, profesor y jefe
|
||||
$asunto = "Reposición autorizada - ".$reposicion_rs["materia"];
|
||||
$texto = "<p>La resposición de la clase de <b>".$reposicion_rs["materia"]."</b> del día <b>".$fecha_clase." a las ".$hora_clase." hrs. </b> está autorizada para realizarse el día <b>".$fecha_nueva." a las ".$hora_nueva." hrs. en: $salon_desc</b></p>";
|
||||
$to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos);
|
||||
$ok = 0;
|
||||
$db->querySingle('SELECT fu_reposicion_solicitud_supervisor(:id, :sup)',
|
||||
[':id' => $id_repo, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
break;
|
||||
case 4://Correo a coordinador, profesor y jefe
|
||||
$asunto = "Reposición declinada - ".$reposicion_rs["materia"];
|
||||
$texto = "<p>La resposición de la clase de <b>".$reposicion_rs["materia"]." planeada para el día ".$fecha_nueva." a las ".$hora_nueva." hrs.</b> ha sido declinada por el siguiente motivo:</p>";
|
||||
$texto .= "<p style='font-style:italic; padding-left:25px'>".$motivo."</p>";
|
||||
$to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos);
|
||||
$ok = 1;
|
||||
$db->querySingle('SELECT fu_reposicion_solicitud_supervisor(:id, :sup)',
|
||||
[':id' => $id_repo, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
if($edo == 4){//cancelación
|
||||
$motivo = "";
|
||||
if(isset($_POST["motivo"]) && $_POST["motivo"] != "")
|
||||
$motivo = trim($_POST["motivo"]);
|
||||
$db->querySingle('SELECT fu_asignacion_cancela(:id, :motivo)',
|
||||
[':id' => $id_repo, ':motivo' => $motivo]
|
||||
);
|
||||
}else{
|
||||
if(!empty($salon)){
|
||||
$db->querySingle('SELECT fu_asignacion_solicitud(:id, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':sal' => $salon, ':edo' => $edo]
|
||||
);
|
||||
}else{
|
||||
$db->querySingle('SELECT fu_asignacion_solicitud(:id, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':edo' => $edo]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fecha_nueva = date('d/m/Y', strtotime($reposicion_rs["fecha_nueva"]));
|
||||
$hora_tmp = explode(":",$reposicion_rs["hora_nueva"]);
|
||||
$hora_nueva = $hora_tmp[0].":".$hora_tmp[1];
|
||||
|
||||
$asunto = "";
|
||||
$texto = "";
|
||||
$to = "";
|
||||
switch($edo){
|
||||
case 2://Correo a supervisor
|
||||
$asunto = "Asignación nueva - ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"];
|
||||
//crear plantilla
|
||||
$texto = "<p>Se creó una solicitud de asignación nueva para: <b>".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"]."</b>.</p>";
|
||||
$texto .= "<p>Se solicita el día <b>".$fecha_nueva." a las ".$hora_nueva." hrs.</b> para el profesor: <b>".$reposicion_rs["profesor_nombre"]."</b>.";
|
||||
if(!$reposicion_rs["tipoaula_supervisor"]){
|
||||
$texto .= " en el salón: <b>".$salon_desc."</b></p>";
|
||||
}else{
|
||||
$texto .= " en un salón de tipo: <b>".$reposicion_rs["tipoaula_nombre"]."</b></p>";
|
||||
}
|
||||
$texto .= "<p style='font-style:italic; padding-left:25px'>".$reposicion_rs["descripcion"]."</p>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
$to = join(",", $sup_correos);
|
||||
$ok = 0;
|
||||
break;
|
||||
case 3://Correo a coordinador, profesor y jefe
|
||||
$asunto = "Asignación autorizada - ".$reposicion_rs["profesor_nombre"];
|
||||
$texto = "<p>La asignación de espacio para el profesor <b>".$reposicion_rs["profesor_nombre"]."</b> está autorizada para realizarse el día <b>".$fecha_nueva." a las ".$hora_nueva." hrs. en: $salon_desc</b></p>";
|
||||
$to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos);
|
||||
$ok = 0;
|
||||
$db->querySingle('SELECT fu_asignacion_solicitud_supervisor(:id, :sup)',
|
||||
[':id' => $id_repo, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
break;
|
||||
case 4://Correo a coordinador, profesor y jefe
|
||||
$asunto = "Asignación declinada - ".$reposicion_rs["profesor_nombre"];
|
||||
$texto = "<p>La asignación de espacio para el profesor <b>".$reposicion_rs["profesor_nombre"]."</b> planeada para el día ".$fecha_nueva." a las ".$hora_nueva." hrs.</b> ha sido declinada por el siguiente motivo:</p>";
|
||||
$texto .= "<p style='font-style:italic; padding-left:25px'>".$motivo."</p>";
|
||||
$to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos);
|
||||
$ok = 1;
|
||||
$db->querySingle('SELECT fu_asignacion_solicitud_supervisor(:id, :sup)',
|
||||
[':id' => $id_repo, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($to!= "" && ENVIO_CORREOS){
|
||||
$texto = '<body >
|
||||
<img src="https://paad.lci.ulsa.mx/imagenes/logo_lasalle.png" alt="La Salle" style="margin-bottom:60px">
|
||||
'.$texto.'
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
|
||||
*/
|
||||
header("Location: ".$pag."?ok=".$ok);
|
||||
exit();
|
||||
?>
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* Borra reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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"])){
|
||||
$return["error"] = "Error! No se recibió la información necesaria.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$creador = $user->user["id"];
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fd_reposicion_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]);
|
||||
$return["ok"] = "La reposición se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al borrar la reposición.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Borra reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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"])){
|
||||
$return["error"] = "Error! No se recibió la información necesaria.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$creador = $user->user["id"];
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fd_reposicion_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]);
|
||||
$return["ok"] = "La reposición se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al borrar la reposición.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
|
||||
@@ -1,208 +1,208 @@
|
||||
<?php
|
||||
/*
|
||||
* Inserta reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
require_once "../class/mailer.php";
|
||||
|
||||
define("COORDINADOR", 9);
|
||||
define("ENVIO_CORREOS", true);
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
//$user->access();
|
||||
|
||||
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
||||
$bloque = filter_input(INPUT_POST, "bloque", FILTER_SANITIZE_NUMBER_INT);//
|
||||
$ciclo = filter_input(INPUT_POST, "ciclo", FILTER_SANITIZE_NUMBER_INT);//
|
||||
$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//Reposicion
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//Reposicion
|
||||
$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//Cambio salón
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto hora reposicion
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "horario", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
$salon = NULL;
|
||||
|
||||
if(!$user->jefe_carrera){//coordinador
|
||||
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
$salon = filter_input(INPUT_POST, "dlSalon", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
}
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user->user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
//-- Obtiene datos de horario regular de clase
|
||||
$horario_rs = $db->querySingle('SELECT * from horario_view where horario_id = :hor',
|
||||
[':hor' => $hor]
|
||||
);
|
||||
|
||||
$materia = $horario_rs["materia_id"];
|
||||
$dia = $horario_rs["horario_dia"];
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
|
||||
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
$fecha_falta = DateTime::createFromFormat('d/m/Y', $fecha_falta)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_falta));
|
||||
}else{
|
||||
$fecha_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_cambio));
|
||||
}
|
||||
|
||||
|
||||
//Valida que tenga clase en la fecha de falta
|
||||
if(intval($dia) != intval($dia_falta)){
|
||||
header("Location:".$pag."?error=11");
|
||||
/*print_r($_POST);
|
||||
echo 'SELECT * from horario_view where horario_id = '.$hor;
|
||||
echo intval($dia)." != ".intval($dia_falta);*/
|
||||
exit();
|
||||
}
|
||||
|
||||
//Obtiene materia
|
||||
$materia_rs = $db->querySingle('SELECT materia_nombre from materia where materia_id = :mat',[':mat' => $materia]);
|
||||
|
||||
//Obtiene correo
|
||||
$correos_rs = $db->querySingle('SELECT coor.usuario_correo, coor.usuario_nombre from usuario coor where rol_id = :rol_coord and facultad_id = (
|
||||
select coalesce(facultad_id,0) from usuario u where u.usuario_id = :id_usr) and coor.usuario_correo != \'\'',[':rol_coord' => COORDINADOR, ':id_usr' => $user->user["id"]]
|
||||
);
|
||||
if( count($correos_rs) > 0 ){
|
||||
$to = $correos_rs["usuario_correo"];
|
||||
}
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia_new, $hora, $materia, "-", $fecha_new, $fecha_fin_new, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
*/
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo en la fecha nueva
|
||||
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo]
|
||||
)["traslape_profesor_reposicion"];
|
||||
if($traslape){
|
||||
//print_r($_POST);
|
||||
//echo "SELECT * from traslape_profesor_reposicion($prof,'".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."' , '$hora', $duracion)";
|
||||
|
||||
header("Location:".$pag."?error=9");
|
||||
exit();
|
||||
}
|
||||
|
||||
try{
|
||||
if($user->jefe_carrera){//jefe
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo
|
||||
]
|
||||
);
|
||||
|
||||
}else{//coordinador
|
||||
echo 'SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo, '.$salon.')';
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo, :salon)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo, ':salon'=>$salon
|
||||
]
|
||||
);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
|
||||
echo "ERROR Reposición<br>".$e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$fecha_clase = date('d/m/Y', strtotime($fecha_falta));
|
||||
$fecha_nueva = date('d/m/Y', strtotime($fecha_new));
|
||||
$texto = "<p>Se creó una reposición nueva.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_clase." a las ".$horario_rs["horario_hora"]." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora." hrs.</b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_falta.">".$fecha_new."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
|
||||
|
||||
}else{//Cambio salón / hora
|
||||
|
||||
try{
|
||||
if($user->jefe_carrera){//jefe
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, false, :aula, :duracion, :usr, :bloque, :ciclo)',
|
||||
[':f_falta' => $fecha_cambio, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo
|
||||
]
|
||||
);
|
||||
}else{//coordinador
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, false, :aula, :duracion, :usr, :bloque, :ciclo, :salon)',
|
||||
[':f_falta' => $fecha_cambio, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo, ':salon'=>$salon
|
||||
]
|
||||
);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
echo "ERROR Cambio<br>".$e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$texto = "<p>Se creó un cambio de salón nuevo.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_falta." a las ".$hora." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora." hrs.</b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarlo.</p>";
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_cambio.">".$fecha_cambio_nueva."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
if($to!= "" && ENVIO_CORREOS){
|
||||
$asunto = "Reposición nueva - solicitud";
|
||||
//crear plantilla
|
||||
$texto = '<body >
|
||||
<img src="https://paad.lci.ulsa.mx/imagenes/logo_lasalle.png" alt="La Salle" style="margin-bottom:60px">
|
||||
'.$texto.'
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header("Location: ".$pag."?ok=0");
|
||||
exit();
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Inserta reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
require_once "../class/mailer.php";
|
||||
|
||||
define("COORDINADOR", 9);
|
||||
define("ENVIO_CORREOS", true);
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
//$user->access();
|
||||
|
||||
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
||||
$bloque = filter_input(INPUT_POST, "bloque", FILTER_SANITIZE_NUMBER_INT);//
|
||||
$ciclo = filter_input(INPUT_POST, "ciclo", FILTER_SANITIZE_NUMBER_INT);//
|
||||
$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//Reposicion
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//Reposicion
|
||||
$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//Cambio salón
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto hora reposicion
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "horario", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
$salon = NULL;
|
||||
|
||||
if(!$user->jefe_carrera){//coordinador
|
||||
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
$salon = filter_input(INPUT_POST, "dlSalon", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
}
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user->user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
//-- Obtiene datos de horario regular de clase
|
||||
$horario_rs = $db->querySingle('SELECT * from horario_view where horario_id = :hor',
|
||||
[':hor' => $hor]
|
||||
);
|
||||
|
||||
$materia = $horario_rs["materia_id"];
|
||||
$dia = $horario_rs["horario_dia"];
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
|
||||
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
$fecha_falta = DateTime::createFromFormat('d/m/Y', $fecha_falta)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_falta));
|
||||
}else{
|
||||
$fecha_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_cambio));
|
||||
}
|
||||
|
||||
|
||||
//Valida que tenga clase en la fecha de falta
|
||||
if(intval($dia) != intval($dia_falta)){
|
||||
header("Location:".$pag."?error=11");
|
||||
/*print_r($_POST);
|
||||
echo 'SELECT * from horario_view where horario_id = '.$hor;
|
||||
echo intval($dia)." != ".intval($dia_falta);*/
|
||||
exit();
|
||||
}
|
||||
|
||||
//Obtiene materia
|
||||
$materia_rs = $db->querySingle('SELECT materia_nombre from materia where materia_id = :mat',[':mat' => $materia]);
|
||||
|
||||
//Obtiene correo
|
||||
$correos_rs = $db->querySingle('SELECT coor.usuario_correo, coor.usuario_nombre from usuario coor where rol_id = :rol_coord and facultad_id = (
|
||||
select coalesce(facultad_id,0) from usuario u where u.usuario_id = :id_usr) and coor.usuario_correo != \'\'',[':rol_coord' => COORDINADOR, ':id_usr' => $user->user["id"]]
|
||||
);
|
||||
if( count($correos_rs) > 0 ){
|
||||
$to = $correos_rs["usuario_correo"];
|
||||
}
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia_new, $hora, $materia, "-", $fecha_new, $fecha_fin_new, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
*/
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo en la fecha nueva
|
||||
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo]
|
||||
)["traslape_profesor_reposicion"];
|
||||
if($traslape){
|
||||
//print_r($_POST);
|
||||
//echo "SELECT * from traslape_profesor_reposicion($prof,'".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."' , '$hora', $duracion)";
|
||||
|
||||
header("Location:".$pag."?error=9");
|
||||
exit();
|
||||
}
|
||||
|
||||
try{
|
||||
if($user->jefe_carrera){//jefe
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo
|
||||
]
|
||||
);
|
||||
|
||||
}else{//coordinador
|
||||
echo 'SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo, '.$salon.')';
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo, :salon)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo, ':salon'=>$salon
|
||||
]
|
||||
);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
|
||||
echo "ERROR Reposición<br>".$e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$fecha_clase = date('d/m/Y', strtotime($fecha_falta));
|
||||
$fecha_nueva = date('d/m/Y', strtotime($fecha_new));
|
||||
$texto = "<p>Se creó una reposición nueva.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_clase." a las ".$horario_rs["horario_hora"]." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora." hrs.</b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_falta.">".$fecha_new."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
|
||||
|
||||
}else{//Cambio salón / hora
|
||||
|
||||
try{
|
||||
if($user->jefe_carrera){//jefe
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, false, :aula, :duracion, :usr, :bloque, :ciclo)',
|
||||
[':f_falta' => $fecha_cambio, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo
|
||||
]
|
||||
);
|
||||
}else{//coordinador
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, false, :aula, :duracion, :usr, :bloque, :ciclo, :salon)',
|
||||
[':f_falta' => $fecha_cambio, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo, ':salon'=>$salon
|
||||
]
|
||||
);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
echo "ERROR Cambio<br>".$e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$texto = "<p>Se creó un cambio de salón nuevo.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_falta." a las ".$hora." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora." hrs.</b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarlo.</p>";
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_cambio.">".$fecha_cambio_nueva."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
if($to!= "" && ENVIO_CORREOS){
|
||||
$asunto = "Reposición nueva - solicitud";
|
||||
//crear plantilla
|
||||
$texto = '<body >
|
||||
<img src="https://paad.lci.ulsa.mx/imagenes/logo_lasalle.png" alt="La Salle" style="margin-bottom:60px">
|
||||
'.$texto.'
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header("Location: ".$pag."?ok=0");
|
||||
exit();
|
||||
?>
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Obtiene datos de reposición
|
||||
*/
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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(!$objSesion->tieneAcceso()){
|
||||
$return["error"] = "Error! No tienes permisos para realizar esta acción.";
|
||||
}else*/ if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información del profesor.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
try{
|
||||
if($user->jefe_carrera){
|
||||
$rs = $db->query('SELECT * FROM fs_materiasprofesor(:id, :jefe)', [':id' => $id, ':jefe'=>$user->user["id"]] );
|
||||
}else{
|
||||
$rs = $db->query('SELECT * FROM fs_materiasprofesor(:id, NULL)', [':id' => $id] );
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al leer los datos de las materias.";
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
$mat_arr = array();
|
||||
foreach($rs as $m){
|
||||
$mat_arr[] = array("horario_id"=>$m["horario_id"], "horario_dia"=>$m["horario_dia"],
|
||||
"horario_hora"=>substr($m["horario_hora"], 0, 2), "horario_min"=>substr($m["horario_hora"], 3, 2),
|
||||
"materia_nombre"=>$m["materia_nombre"].' - '.$m["horario_dia_nombre"]." ".substr($m["horario_hora"], 0, -3),
|
||||
"grupo"=>$m["horario_grupo"], "duracion" => $m["duracion"]
|
||||
);
|
||||
}
|
||||
|
||||
$return["materias"] = $mat_arr;
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Obtiene datos de reposición
|
||||
*/
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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(!$objSesion->tieneAcceso()){
|
||||
$return["error"] = "Error! No tienes permisos para realizar esta acción.";
|
||||
}else*/ if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información del profesor.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
try{
|
||||
if($user->jefe_carrera){
|
||||
$rs = $db->query('SELECT * FROM fs_materiasprofesor(:id, :jefe)', [':id' => $id, ':jefe'=>$user->user["id"]] );
|
||||
}else{
|
||||
$rs = $db->query('SELECT * FROM fs_materiasprofesor(:id, NULL)', [':id' => $id] );
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al leer los datos de las materias.";
|
||||
echo json_encode($return);
|
||||
}
|
||||
|
||||
$mat_arr = array();
|
||||
foreach($rs as $m){
|
||||
$mat_arr[] = array("horario_id"=>$m["horario_id"], "horario_dia"=>$m["horario_dia"],
|
||||
"horario_hora"=>substr($m["horario_hora"], 0, 2), "horario_min"=>substr($m["horario_hora"], 3, 2),
|
||||
"materia_nombre"=>$m["materia_nombre"].' - '.$m["horario_dia_nombre"]." ".substr($m["horario_hora"], 0, -3),
|
||||
"grupo"=>$m["horario_grupo"], "duracion" => $m["duracion"]
|
||||
);
|
||||
}
|
||||
|
||||
$return["materias"] = $mat_arr;
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
|
||||
88
action/reposicion_select_old.php
Normal file
88
action/reposicion_select_old.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Obtiene datos de reposición
|
||||
*/
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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(!$objSesion->tieneAcceso()){
|
||||
$return["error"] = "Error! No tienes permisos para realizar esta acción.";
|
||||
}else*/ if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información de la reposición.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
|
||||
try{
|
||||
if($user->rol["rol_id"] == 7){//es supervisor
|
||||
$rs = $db->querySingle('SELECT * from fs_reposicion_solicitud(:id, NULL, NULL, NULL, NULL, NULL, NULL, NULL, :sup)',
|
||||
[':id' => $id, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
}else{//coordinador
|
||||
$rs = $db->querySingle('SELECT * from fs_reposicion_solicitud(:id, :fac, NULL, NULL, NULL, NULL, NULL, NULL, null)',
|
||||
[':id' => $id, ":fac"=>$user->facultad["facultad_id"] ]
|
||||
);
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al leer los datos de la reposición.";
|
||||
echo json_encode($return);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$return["fecha_clase"] = date('d/m/Y', strtotime($rs["fecha_clase"]));
|
||||
$return["fecha_nueva"] = date('d/m/Y', strtotime($rs["fecha_nueva"]));
|
||||
$hora_nueva = explode(":",$rs["hora_nueva"]);
|
||||
$return["hora_ini"] = $hora_nueva[0];
|
||||
$return["min_ini"] = $hora_nueva[1];
|
||||
$hora_nueva_fin = explode(":",$rs["hora_nueva_fin"]);
|
||||
$return["hora_fin"] = $hora_nueva_fin[0];
|
||||
$return["min_fin"] = $hora_nueva_fin[1];
|
||||
$return["duracion"] = $rs["duracion_interval"];
|
||||
|
||||
// $return["carrera"] = $rs["PlanEstudio_desc"];
|
||||
$return["horario"] = $rs["horario_id"];
|
||||
$return["materia"] = $rs["materia_id"];
|
||||
$return["materia_desc"] = $rs["materia_nombre"];
|
||||
$return["salon"] = $rs["salon_id"];
|
||||
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"];
|
||||
$return["profesor_nombre"] = $rs["profesor_nombre"];
|
||||
$return["comentario"] = $rs["descripcion"];
|
||||
$return["alumnos"] = $rs["alumnos"];
|
||||
$return["tipo"] = $rs["es_reposicion"];
|
||||
$return["aula"] = $rs["tipoaula_id"];
|
||||
$return["aula_desc"] = $rs["tipoaula_nombre"];
|
||||
$return["aula_supervisor"] = $rs["tipoaula_supervisor"];
|
||||
$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"];
|
||||
$return["carrera"] = $rs["carrera_nombre"];
|
||||
$return["grupo"] = $rs["horario_grupo"];
|
||||
$return["supervisor_nombre"] = $rs["supervisor_nombre"];
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
@@ -1,125 +1,125 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Actualizar reposiciones
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
|
||||
/*if(!isset($_POST["id"]) || !isset($_POST["fecha_falta"]) || !isset($_POST["fecha_inicial"]) || !isset($_POST["hora_ini"]) || !isset($_POST["min_ini"]) || !isset($_POST["materia"]) || !isset($_POST["grupo"])){
|
||||
header("Location: ".$pag."?error=0");
|
||||
exit();
|
||||
}*/
|
||||
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
||||
$bloque = filter_input(INPUT_POST, "bloque", FILTER_SANITIZE_NUMBER_INT);//
|
||||
$ciclo = filter_input(INPUT_POST, "ciclo", FILTER_SANITIZE_NUMBER_INT);//
|
||||
$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "horario", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", 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
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
$horario_rs = $db->querySingle('SELECT * from horario_view where horario_id = :hor',
|
||||
[':hor' => $hor]
|
||||
);
|
||||
|
||||
$materia = $horario_rs["materia_id"];
|
||||
$dia = $horario_rs["horario_dia"];
|
||||
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
|
||||
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
//echo $fecha_new."<br>";
|
||||
//echo $fecha_fin_new."<br>";
|
||||
if($tipo == 1){//Reposición
|
||||
$fecha_falta = DateTime::createFromFormat('d/m/Y', $fecha_falta)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_falta));
|
||||
}else{
|
||||
$fecha_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_cambio));
|
||||
}
|
||||
|
||||
//Valida que tenga clase en la fecha de falta
|
||||
if(intval($dia) != intval($dia_falta)){
|
||||
//header("Location:".$pag."?error=11");
|
||||
echo intval($dia)." != ".intval($dia_falta);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia, $hora, $materia, "-", $fecha_ini, $fecha_fin, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo
|
||||
*/
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur, :id)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo, ':id'=>$id]
|
||||
)["traslape_profesor_reposicion"];
|
||||
echo "SELECT * from traslape_profesor_reposicion($prof, '".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."', $hora, $duracion_tiempo, $id)";
|
||||
if($traslape){
|
||||
//header("Location:".$pag."?error=9");
|
||||
echo "traslape";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Actualiza reposición ID[".$id."] Fechas[".$fecha_ini."][".$fecha_fin."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
}
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fu_reposicion_solicitud(:id, :f_falta, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)',
|
||||
[':id'=> $id, ':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
//header("Location: ".$pag."?error=2");
|
||||
print_r($e->getMessage());
|
||||
echo "SELECT * from fu_reposicion_solicitud(:id, :f_falta, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)'";
|
||||
print_r(
|
||||
[':id'=> $id, ':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
header("Location: ".$pag);
|
||||
exit();
|
||||
?>
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Actualiza reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
|
||||
/*if(!isset($_POST["id"]) || !isset($_POST["fecha_falta"]) || !isset($_POST["fecha_inicial"]) || !isset($_POST["hora_ini"]) || !isset($_POST["min_ini"]) || !isset($_POST["materia"]) || !isset($_POST["grupo"])){
|
||||
header("Location: ".$pag."?error=0");
|
||||
exit();
|
||||
}*/
|
||||
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
||||
$bloque = filter_input(INPUT_POST, "bloque", FILTER_SANITIZE_NUMBER_INT);//
|
||||
$ciclo = filter_input(INPUT_POST, "ciclo", FILTER_SANITIZE_NUMBER_INT);//
|
||||
$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "horario", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", 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
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
$horario_rs = $db->querySingle('SELECT * from horario_view where horario_id = :hor',
|
||||
[':hor' => $hor]
|
||||
);
|
||||
|
||||
$materia = $horario_rs["materia_id"];
|
||||
$dia = $horario_rs["horario_dia"];
|
||||
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora;
|
||||
$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo;
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
//echo $fecha_new."<br>";
|
||||
//echo $fecha_fin_new."<br>";
|
||||
if($tipo == 1){//Reposición
|
||||
$fecha_falta = DateTime::createFromFormat('d/m/Y', $fecha_falta)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_falta));
|
||||
}else{
|
||||
$fecha_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_cambio));
|
||||
}
|
||||
|
||||
//Valida que tenga clase en la fecha de falta
|
||||
if(intval($dia) != intval($dia_falta)){
|
||||
//header("Location:".$pag."?error=11");
|
||||
echo intval($dia)." != ".intval($dia_falta);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia, $hora, $materia, "-", $fecha_ini, $fecha_fin, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo
|
||||
*/
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur, :id)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo, ':id'=>$id]
|
||||
)["traslape_profesor_reposicion"];
|
||||
echo "SELECT * from traslape_profesor_reposicion($prof, '".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."', $hora, $duracion_tiempo, $id)";
|
||||
if($traslape){
|
||||
//header("Location:".$pag."?error=9");
|
||||
echo "traslape";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Actualiza reposición ID[".$id."] Fechas[".$fecha_ini."][".$fecha_fin."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
}
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fu_reposicion_solicitud(:id, :f_falta, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)',
|
||||
[':id'=> $id, ':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
//header("Location: ".$pag."?error=2");
|
||||
print_r($e->getMessage());
|
||||
echo "SELECT * from fu_reposicion_solicitud(:id, :f_falta, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)'";
|
||||
print_r(
|
||||
[':id'=> $id, ':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
header("Location: ".$pag);
|
||||
exit();
|
||||
?>
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* Borra reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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"])){
|
||||
$return["error"] = "Error! No se recibió la información necesaria.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$creador = $user->user["id"];
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fd_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]);
|
||||
$return["ok"] = "La solicitud se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al borrar la solicitud.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Borra reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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"])){
|
||||
$return["error"] = "Error! No se recibió la información necesaria.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$creador = $user->user["id"];
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fd_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]);
|
||||
$return["ok"] = "La solicitud se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al borrar la solicitud.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
|
||||
@@ -1,101 +1,101 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Obtiene datos de reposición
|
||||
*/
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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(!$objSesion->tieneAcceso()){
|
||||
$return["error"] = "Error! No tienes permisos para realizar esta acción.";
|
||||
}else*/ if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información de la reposición.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
try{
|
||||
if($user->rol["rol_id"] == 7){//es supervisor
|
||||
$rs = $db->querySingle('SELECT * from fs_solicitud(:id, NULL, NULL, NULL, NULL, NULL, NULL, :sup)',
|
||||
[':id' => $id, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
}else{//coordinador
|
||||
$rs = $db->querySingle('SELECT * from fs_solicitud(:id, :fac, NULL, NULL, NULL, NULL, NULL, null)',
|
||||
[':id' => $id, ":fac"=>$user->facultad["facultad_id"] ]
|
||||
);
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al leer los datos de la reposición.";
|
||||
echo json_encode($return);
|
||||
exit();
|
||||
}
|
||||
|
||||
$dias = array('Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado');
|
||||
|
||||
if($rs["solicitudtipo_id"]!=3){
|
||||
$hora_nueva = explode(":",$rs["horario_hora"]);
|
||||
}
|
||||
|
||||
if($rs["solicitudtipo_id"]!=4){
|
||||
$return["fecha_clase"] = isset($rs["fecha_clase"]) ? date('d/m/Y', strtotime($rs["fecha_clase"])):'';
|
||||
}else{
|
||||
$return["fecha_clase"] = $dias[$rs["horario_dia"]];
|
||||
}
|
||||
$return["hora_clase_ini"] = $rs["horario_hora"];
|
||||
$return["hora_clase_fin"] = $rs["horario_hora_fin"];
|
||||
|
||||
$return["fecha_nueva"] = isset($rs["fecha_nueva"]) ? date('d/m/Y', strtotime($rs["fecha_nueva"])):'';
|
||||
$return["hora_nueva"] = $rs["hora_nueva"];
|
||||
$hora_nueva = explode(":",$rs["hora_nueva"]);
|
||||
$return["hora_ini"] = $hora_nueva[0];
|
||||
$return["min_ini"] = $hora_nueva[1];
|
||||
$return["hora_nueva_fin"] = $rs["hora_nueva_fin"];
|
||||
$hora_nueva_fin = explode(":",$rs["hora_nueva_fin"]);
|
||||
$return["hora_fin"] = $hora_nueva_fin[0];
|
||||
$return["min_fin"] = $hora_nueva_fin[1];
|
||||
$return["duracion"] = $rs["duracion_interval"];
|
||||
|
||||
// $return["carrera"] = $rs["PlanEstudio_desc"];
|
||||
$return["horario"] = $rs["horario_id"];
|
||||
$return["materia"] = $rs["materia_id"];
|
||||
$return["materia_desc"] = $rs["materia_nombre"];
|
||||
$return["salon"] = $rs["salon_id"];
|
||||
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["ciclo"] = $rs["ciclo"];
|
||||
$return["bloque"] = $rs["bloque"];
|
||||
$return["profesor"] = $rs["profesor_id"];
|
||||
$return["profesor_nombre"] = $rs["profesor_nombre"];
|
||||
$return["comentario"] = $rs["descripcion"];
|
||||
$return["alumnos"] = $rs["alumnos"];
|
||||
$return["aula"] = $rs["tipoaula_id"];
|
||||
$return["aula_desc"] = $rs["tipoaula_nombre"];
|
||||
$return["aula_supervisor"] = $rs["tipoaula_supervisor"];
|
||||
$return["dia_nombre"] = isset($rs["fecha_clase"]) ? date('w', strtotime($rs["fecha_clase"])): '';
|
||||
$return["dia"] = isset($rs["fecha_clase"]) ? $dias[date('w', strtotime($rs["fecha_clase"]))]: '';
|
||||
$return["motivo_cancelacion"] = $rs["motivo_cancelacion"];
|
||||
$return["estado"] = $rs["estado_reposicion_id"];
|
||||
$return["facultad"] = $rs["facultad_nombre"];
|
||||
$return["carrera"] = $rs["carrera_comun"]? $rs["carrera_nombre"]:$rs["horario_carrera"];//si es común, se muestra la carrera de la materia, si no, la carrera del horario
|
||||
$return["grupo"] = $rs["horario_grupo"];
|
||||
$return["supervisor_nombre"] = $rs["supervisor_nombre"];
|
||||
$return["solicitudtipo_id"] = $rs["solicitudtipo_id"];
|
||||
$return["solicitudtipo"] = $rs["solicitudtipo_nombre"];
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Obtiene datos de reposición
|
||||
*/
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
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(!$objSesion->tieneAcceso()){
|
||||
$return["error"] = "Error! No tienes permisos para realizar esta acción.";
|
||||
}else*/ if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información de la reposición.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
try{
|
||||
if($user->rol["rol_id"] == 7){//es supervisor
|
||||
$rs = $db->querySingle('SELECT * from fs_solicitud(:id, NULL, NULL, NULL, NULL, NULL, NULL, :sup)',
|
||||
[':id' => $id, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
}else{//coordinador
|
||||
$rs = $db->querySingle('SELECT * from fs_solicitud(:id, :fac, NULL, NULL, NULL, NULL, NULL, null)',
|
||||
[':id' => $id, ":fac"=>$user->facultad["facultad_id"] ]
|
||||
);
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al leer los datos de la reposición.";
|
||||
echo json_encode($return);
|
||||
exit();
|
||||
}
|
||||
|
||||
$dias = array('Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado');
|
||||
|
||||
if($rs["solicitudtipo_id"]!=3){
|
||||
$hora_nueva = explode(":",$rs["horario_hora"]);
|
||||
}
|
||||
|
||||
if($rs["solicitudtipo_id"]!=4){
|
||||
$return["fecha_clase"] = isset($rs["fecha_clase"]) ? date('d/m/Y', strtotime($rs["fecha_clase"])):'';
|
||||
}else{
|
||||
$return["fecha_clase"] = $dias[$rs["horario_dia"]];
|
||||
}
|
||||
$return["hora_clase_ini"] = $rs["horario_hora"];
|
||||
$return["hora_clase_fin"] = $rs["horario_hora_fin"];
|
||||
|
||||
$return["fecha_nueva"] = isset($rs["fecha_nueva"]) ? date('d/m/Y', strtotime($rs["fecha_nueva"])):'';
|
||||
$return["hora_nueva"] = $rs["hora_nueva"];
|
||||
$hora_nueva = explode(":",$rs["hora_nueva"]);
|
||||
$return["hora_ini"] = $hora_nueva[0];
|
||||
$return["min_ini"] = $hora_nueva[1];
|
||||
$return["hora_nueva_fin"] = $rs["hora_nueva_fin"];
|
||||
$hora_nueva_fin = explode(":",$rs["hora_nueva_fin"]);
|
||||
$return["hora_fin"] = $hora_nueva_fin[0];
|
||||
$return["min_fin"] = $hora_nueva_fin[1];
|
||||
$return["duracion"] = $rs["duracion_interval"];
|
||||
|
||||
// $return["carrera"] = $rs["PlanEstudio_desc"];
|
||||
$return["horario"] = $rs["horario_id"];
|
||||
$return["materia"] = $rs["materia_id"];
|
||||
$return["materia_desc"] = $rs["materia_nombre"];
|
||||
$return["salon"] = $rs["salon_id"];
|
||||
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["ciclo"] = $rs["ciclo"];
|
||||
$return["bloque"] = $rs["bloque"];
|
||||
$return["profesor"] = $rs["profesor_id"];
|
||||
$return["profesor_nombre"] = $rs["profesor_nombre"];
|
||||
$return["comentario"] = $rs["descripcion"];
|
||||
$return["alumnos"] = $rs["alumnos"];
|
||||
$return["aula"] = $rs["tipoaula_id"];
|
||||
$return["aula_desc"] = $rs["tipoaula_nombre"];
|
||||
$return["aula_supervisor"] = $rs["tipoaula_supervisor"];
|
||||
$return["dia_nombre"] = isset($rs["fecha_clase"]) ? date('w', strtotime($rs["fecha_clase"])): '';
|
||||
$return["dia"] = isset($rs["fecha_clase"]) ? $dias[date('w', strtotime($rs["fecha_clase"]))]: '';
|
||||
$return["motivo_cancelacion"] = $rs["motivo_cancelacion"];
|
||||
$return["estado"] = $rs["estado_reposicion_id"];
|
||||
$return["facultad"] = $rs["facultad_nombre"];
|
||||
$return["carrera"] = $rs["carrera_comun"]? $rs["carrera_nombre"]:$rs["horario_carrera"];//si es común, se muestra la carrera de la materia, si no, la carrera del horario
|
||||
$return["grupo"] = $rs["horario_grupo"];
|
||||
$return["supervisor_nombre"] = $rs["supervisor_nombre"];
|
||||
$return["solicitudtipo_id"] = $rs["solicitudtipo_id"];
|
||||
$return["solicitudtipo"] = $rs["solicitudtipo_nombre"];
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
|
||||
@@ -1,28 +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);
|
||||
|
||||
<?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));
|
||||
490
carreras.php
490
carreras.php
@@ -1,124 +1,414 @@
|
||||
<?php
|
||||
require_once 'class/c_login.php';
|
||||
require_once 'include/bd_pdo.php';
|
||||
|
||||
$user = Login::get_user();
|
||||
|
||||
$user->access();
|
||||
if ($user->acceso == null) {
|
||||
// die($access);
|
||||
header('Location: main.php?error=1');
|
||||
} else {
|
||||
$user->print_to_log('Carreras');
|
||||
}
|
||||
$facultad = $user->facultad['facultad_id'] ?? -1;
|
||||
if ($user->admin) {
|
||||
$facultad = null;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Auditoría asistencial</title>
|
||||
<title>Carreras</title>
|
||||
<?php
|
||||
include 'import/html_css_files.php';
|
||||
?>
|
||||
<link rel="stylesheet" type="text/css" href="https://unpkg.com/trix@2.0.0/dist/trix.css">
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="js/jquery-ui.js"></script>
|
||||
<script src="js/bootstrap/bootstrap.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?
|
||||
$redirect = $_SERVER['PHP_SELF'];
|
||||
<?php
|
||||
include "import/html_header.php";
|
||||
global $user;
|
||||
|
||||
html_header(
|
||||
"Carreras",
|
||||
"Sistema de gestión de checador",
|
||||
"CARRERAS",
|
||||
"Gestión de Checador "
|
||||
);
|
||||
?>
|
||||
<main class="container-fluid px-4 my-4" id="app" v-cloak @vue:mounted="mounted" style="min-height: 70vh;">
|
||||
<section class="row mt-4">
|
||||
<div class="col-12 position-relative">
|
||||
<!-- Loop for messages -->
|
||||
<div class="toast show shadow-sm mb-3 bg-white"
|
||||
style="position: fixed; top: 15%; right: 1%; max-width: 300px;" role="alert" aria-live="assertive"
|
||||
aria-atomic="true"
|
||||
@vue:mounted="$('.toast').toast({delay: 5000}).toast('show').on('hidden.bs.toast', () => { message.text = '' })"
|
||||
v-if="message.text">
|
||||
<div class="toast-header">
|
||||
<strong class="mr-auto text-primary text-uppercase text-center w-100 px-4">
|
||||
{{ message.title }}
|
||||
</strong>
|
||||
<small class="text-muted">{{ message.timestamp }}</small>
|
||||
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close"
|
||||
@click="message.text = ''">
|
||||
<span aria-hidden="true">
|
||||
<i class="fas fa-times"></i>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
<div :class="message.type == 'success' ? 'text-success' : 'text-danger'"><i
|
||||
:class="message.type == 'success' ? 'fas fa-check-circle' : 'fas fa-times-circle'"></i>
|
||||
{{ message.text }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div class="container">
|
||||
<div class="row" v-for="facultad in carreras">
|
||||
<!-- Facultad Card -->
|
||||
<div class="card col-12 mb-4 shadow-lg">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h3 class="mb-1">{{ facultad.facultad_nombre }}</h3>
|
||||
</div>
|
||||
<div class="card-body bg-white">
|
||||
<div class="row justify-content-center">
|
||||
<!-- Loop for Carreras -->
|
||||
<div class="col-md-6 mb-3" v-for="carrera in facultad.carreras">
|
||||
<div class="card border-secondary mb-3 shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title text-primary text-uppercase text-center w-100 px-4 mb-3 text-truncate text-break border-bottom border-secondary pb-2"
|
||||
:title="carrera.carrera_nombre">
|
||||
{{ carrera.carrera_nombre }}
|
||||
</h5>
|
||||
$user->access();
|
||||
$max_count = 30;
|
||||
|
||||
<!-- Dropdown for Niveles -->
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button"
|
||||
data-toggle="dropdown" aria-expanded="false"
|
||||
@vue:mounted="$('.dropdown-toggle').dropdown()">
|
||||
{{ carrera.nivel_nombre }}
|
||||
</button>
|
||||
<div class="dropdown-menu shadow">
|
||||
<a class="dropdown-item" v-for="nivel in niveles" key="nivel.nivel_id"
|
||||
style="cursor: pointer; user-select: none;"
|
||||
@click="setNivel(carrera, nivel)"
|
||||
:class="nivel.nivel_id == carrera.nivel_id ? 'active' : ''"
|
||||
:disabled="nivel.nivel_id == carrera.nivel_id">
|
||||
{{ nivel.nivel_nombre }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- End of Carreras loop -->
|
||||
</div>
|
||||
</div>
|
||||
/*$sql = "SELECT * FROM (:nombre, :carrera, :facultad)";
|
||||
if (isset($_POST["desc"])) {
|
||||
$desc = $_POST["desc"];
|
||||
$filter_desc = htmlspecialchars($desc, ENT_QUOTES, 'UTF-8');
|
||||
} else {
|
||||
$desc = null;
|
||||
}
|
||||
|
||||
if (isset($_POST["carrera"])) {
|
||||
$pcarrera = $_POST["carrera"];
|
||||
$filter_carrera = htmlspecialchars($pcarrera, ENT_QUOTES, 'UTF-8');
|
||||
} else {
|
||||
$pcarrera = null;
|
||||
}
|
||||
|
||||
if ($pcarrera == "") {
|
||||
$sql .= "LIMIT 30";
|
||||
}
|
||||
$fs_materias = query(
|
||||
$sql,
|
||||
array(":nombre" => $desc, ":carrera" => $pcarrera, ":facultad" => $facultad),
|
||||
single: false
|
||||
);
|
||||
$fs_carreras = query(
|
||||
"SELECT * FROM fs_carreras(:facultad, null, null) ORDER BY unaccent(carrera_nombre)",
|
||||
array(":facultad" => $facultad),
|
||||
single: false
|
||||
);*/
|
||||
|
||||
$stmt = $pdo->prepare('SELECT ca.carrera_id, ca.clave_carrera, ca.carrera_nombre, f.facultad_nombre
|
||||
FROM carrera ca
|
||||
JOIN facultad f ON f.facultad_id = ca.facultad_id
|
||||
WHERE ca.carrera_id != 0
|
||||
ORDER BY f.facultad_nombre, ca.carrera_nombre');
|
||||
$stmt->execute();
|
||||
$carr = $stmt->fetchAll();
|
||||
|
||||
$stmt = $pdo->prepare('SELECT * FROM nivel');
|
||||
$stmt->execute();
|
||||
$nivel = $stmt->fetchAll();
|
||||
|
||||
|
||||
|
||||
$stmt = $pdo->prepare('SELECT * FROM facultad');
|
||||
$stmt->execute();
|
||||
$facultad = $stmt->fetchAll();
|
||||
|
||||
|
||||
//print_r($fs_materias);
|
||||
|
||||
?>
|
||||
<main class="content marco">
|
||||
<!-- Filtro -->
|
||||
|
||||
|
||||
<!-- Tabla -->
|
||||
<div class="row">
|
||||
<div class="col-12 table-responsive">
|
||||
<!--
|
||||
|
||||
<button type="button" class="btn btn-outline-primary" data-toggle="modal"
|
||||
data-target="#modal">
|
||||
<span class="ing-editar ing-fw"></span>
|
||||
</button>
|
||||
|
||||
-->
|
||||
<div class="col-12 text-end pb-3">
|
||||
<button type="button" class="btn btn-outline-primary" data-toggle="modal" data-target="#modalCrear">
|
||||
<span class="ing-mas ing-fw"></span>
|
||||
Crear
|
||||
</button>
|
||||
</div>
|
||||
<!-- End of Facultad Card -->
|
||||
|
||||
<table class="table table-sm table-striped table-white">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Clave Carrera</th>
|
||||
<th>Nombre Facultad</th>
|
||||
<th>Nombre Carrera</th>
|
||||
<th>Editar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ($carr) {
|
||||
foreach ($carr as $materia) {
|
||||
|
||||
?>
|
||||
<tr data-id="<?= $materia["carrera_id"]; ?>" id="<?= $materia["carrera_id"]; ?>">
|
||||
<td class="text-primary">
|
||||
<?= $materia["clave_carrera"]; ?>
|
||||
</td>
|
||||
<td class="text-primary">
|
||||
<?= $materia["facultad_nombre"]; ?>
|
||||
</td>
|
||||
<td class="text-primary">
|
||||
<!-- <small>(<?= $materia["clave_materia"]; ?>)</small> -->
|
||||
<?= $materia["carrera_nombre"]; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<button type="button" class="btn btn-outline-primary" data-toggle="modal"
|
||||
data-target="#modal">
|
||||
<span class="ing-editar ing-fw"></span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="message"></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<?
|
||||
include "import/html_footer.php"; ?>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"
|
||||
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
|
||||
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js"
|
||||
integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+"
|
||||
crossorigin="anonymous"></script>
|
||||
<!-- Footer -->
|
||||
<?php
|
||||
include "import/html_footer.php";
|
||||
?>
|
||||
|
||||
<!-- Modal Crear-->
|
||||
<div class="modal fade" id="modalCrear" tabindex="-1" role="dialog" aria-labelledby="modalCrear" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="col-12 modal-title text-center">
|
||||
<span id="modalLable">
|
||||
Crear Carrera
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="action\action_carreras_insert.php" method="post" id="formaModal"
|
||||
onsubmit="return valida_campos_crear()">
|
||||
<div class="form-box">
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="carreraCrear" class="col-4 col-form-label">Nombre Carrera*</label>
|
||||
<div class="col-8">
|
||||
<input id="carreraCrear" name="carreraCrear" type="text" class="form-control" maxlength="100">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="facultadCrear" class="col-4 col-form-label">Nombre Facultad*</label>
|
||||
<div class="col-8">
|
||||
<?php
|
||||
echo '<select class="form-control area" id="facultadCrear" name="facultadCrear" required style="color: black;">';
|
||||
foreach ($facultad as $op) {
|
||||
echo '<option value="' . $op['facultad_id'] . '">' . $op['facultad_nombre'] . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="nivelCrear" class="col-4 col-form-label">Nivel*</label>
|
||||
<div class="col-8">
|
||||
<?php
|
||||
echo '<select class="form-control area" id="nivelCrear" name="nivelCrear" required style="color: black;">';
|
||||
foreach ($nivel as $op) {
|
||||
echo '<option value="' . $op['nivel_id'] . '">' . $op['nivel_nombre'] . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="nombreCarreraCrear" class="col-4 col-form-label">Clave de la Carrera*</label>
|
||||
<div class="col-8">
|
||||
<input id="nombreCarreraCrear" name="nombreCarreraCrear" type="text" class="form-control"
|
||||
maxlength="100">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="offset-4 col-8">
|
||||
<button type="submit" class="btn btn-outline-primary" id="submitBtn" data-tipo="1">
|
||||
<span class="ing-aceptar ing-fw"></span> Guardar
|
||||
</button>
|
||||
<button type="reset" class="btn btn-outline-danger" data-dismiss="modal">
|
||||
<span class="ing-cancelar ing-fw"></span> Cancelar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Modal Crear-->
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="col-12 modal-title text-center">
|
||||
<span id="modalLable">
|
||||
Editar Carrera
|
||||
</span>
|
||||
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="./action/action_carreras_update.php" method="post" id="formaModal"
|
||||
onsubmit="return valida_campos_editar()">
|
||||
<input type="hidden" name="id" id="carrera_id">
|
||||
<div class="form-box">
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="carreraEditar" class="col-4 col-form-label">Nombre Carrera*</label>
|
||||
<div class="col-8">
|
||||
<input id="carreraEditar" name="carreraEditar" type="text" class="form-control" maxlength="100">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="facultad" class="col-4 col-form-label">Nombre Facultad*</label>
|
||||
<div class="col-8">
|
||||
<?php
|
||||
echo '<select class="form-control area" id="facultadEditar" name="facultadEditar" required style="color: black;">';
|
||||
foreach ($facultad as $op) {
|
||||
echo '<option value="' . $op['facultad_id'] . '">' . $op['facultad_nombre'] . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="nivel" class="col-4 col-form-label">Nivel*</label>
|
||||
<div class="col-8">
|
||||
<?php
|
||||
echo '<select class="form-control area" id="nivelEditar" name="nivelEditar" required style="color: black;">';
|
||||
foreach ($nivel as $op) {
|
||||
echo '<option value="' . $op['nivel_id'] . '">' . $op['nivel_nombre'] . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="nombreCarreraEditar" class="col-4 col-form-label">Clave de la Carrera*</label>
|
||||
<div class="col-8">
|
||||
<input id="nombreCarreraEditar" name="nombreCarreraEditar" type="text" class="form-control"
|
||||
maxlength="100">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="offset-4 col-8">
|
||||
<button type="submit" class="btn btn-outline-primary" id="submitBtn" data-tipo="1">
|
||||
<span class="ing-aceptar ing-fw"></span> Guardar
|
||||
</button>
|
||||
<button type="reset" class="btn btn-outline-danger" data-dismiss="modal">
|
||||
<span class="ing-cancelar ing-fw"></span> Cancelar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Modal -->
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="js/bootstrap/bootstrap.min.js"></script>
|
||||
<script src="js/datalist.js"></script>
|
||||
<script src="js/carreras.js?<?= rand(0, 2) ?>" type="module"></script>
|
||||
<script src="js/scrollables.js"></script>
|
||||
<?php
|
||||
require_once 'js/messages.php';
|
||||
?>
|
||||
<script>
|
||||
|
||||
function valida_campos_editar() {
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
var ok = true;
|
||||
|
||||
if ($("#carreraEditar").val().trim() === "") {
|
||||
$("#carreraEditar").addClass("is-invalid");
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if ($("#nombreCarreraEditar").val().trim() === "") {
|
||||
$("#nombreCarreraEditar").addClass("is-invalid");
|
||||
ok = false;
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function valida_campos_crear() {
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
var ok = true;
|
||||
|
||||
if ($("#carreraCrear").val().trim() === "") {
|
||||
$("#carreraCrear").addClass("is-invalid");
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if ($("#nombreCarreraCrear").val().trim() === "") {
|
||||
$("#nombreCarreraCrear").addClass("is-invalid");
|
||||
ok = false;
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(document).on("click", ".btn-reset", function (event) {
|
||||
var forma = $(this).parents("form");
|
||||
forma.find("input[type=text]").val("");
|
||||
setDatalistFirst("#filter_carrera");
|
||||
forma.submit();
|
||||
});
|
||||
|
||||
$('#modal').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var id = button.closest("tr").data("id");
|
||||
|
||||
//var id = $(event.relatedTarget).parents("tr").data("id");
|
||||
$.ajax({
|
||||
url: "action/action_carreras_select.php",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
idmateria: id
|
||||
},
|
||||
success: function (result) {
|
||||
$("#carreraEditar").val(result["carrera_nombre"]);
|
||||
$("#facultadEditar").val(result["facultad_id"]);
|
||||
$("#nivelEditar").val(result["nivel_id"]);
|
||||
$("#nombreCarreraEditar").val(result["clave_carrera"]);
|
||||
$("#carrera_id").val(result["carrera_id"]);
|
||||
|
||||
},
|
||||
error: function () {
|
||||
console.log("Error")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
49
periodos_sgu.php
Normal file
49
periodos_sgu.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/inicioSesion/seleccionar',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS =>'{"username":"SGU_APSA_AUD_ASIST","password":"B4qa594JFPr2ufHrZdHS8A=="}',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Transfer-Encoding: chunked'
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/periodos/v1/seleccionar',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POSTFIELDS =>'[]',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"token:".json_decode($response, true),
|
||||
'username: SGU_APSA_AUD_ASIST',
|
||||
'Transfer-Encoding: chunked'
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$periodos = implode("\n", array_map(
|
||||
fn($periodo) => <<<HTML
|
||||
<li class="list-group item" value="{$periodo->IdPeriodo}" data-clave="{$periodo->NombrePeriodo}">
|
||||
{$periodo->NombrePeriodo} - {$periodo->NombreNivel}
|
||||
</li>
|
||||
HTML, array_filter(
|
||||
json_decode($response),
|
||||
fn($periodo) => in_array($periodo->IdPeriodo, [])
|
||||
)));
|
||||
|
||||
curl_close($curl);
|
||||
echo <<<HTML
|
||||
<ul class="list-group" id="alumnos">
|
||||
{$periodos}
|
||||
</ul>
|
||||
HTML;
|
||||
Reference in New Issue
Block a user