Add new files and make code improvements
This commit is contained in:
@@ -31,7 +31,7 @@ try {
|
||||
"WITH horarios AS (
|
||||
SELECT
|
||||
horario_id,
|
||||
facultad.facultad_id,
|
||||
horario.facultad_id,
|
||||
horario_fecha_inicio,
|
||||
horario_fecha_fin,
|
||||
horario_grupo,
|
||||
@@ -40,20 +40,19 @@ try {
|
||||
PERIODO.periodo_fecha_fin,
|
||||
salon,
|
||||
COALESCE(materia_nombre, materia_asignacion_materia) as materia,
|
||||
carrera_nombre as carrera,
|
||||
coalesce(carrera_nombre, materia_asignacion_carrera) as carrera,
|
||||
facultad_nombre as facultad,
|
||||
nivel_nombre as nivel,
|
||||
horario_fin
|
||||
FROM horario
|
||||
left JOIN materia USING (materia_id)
|
||||
LEFT JOIN carrera USING (carrera_id)
|
||||
left join carrera using (carrera_id)
|
||||
left join materia_asignacion using (horario_id)
|
||||
-- JOIN carrera USING (carrera_id) but if carrera_id is null then 0
|
||||
JOIN nivel USING (nivel_id)
|
||||
JOIN facultad ON facultad.facultad_id = COALESCE(carrera.facultad_id, 0)
|
||||
join facultad on facultad.facultad_id = horario.facultad_id
|
||||
JOIN PERIODO USING (periodo_id)
|
||||
JOIN nivel on periodo.nivel_id = nivel.nivel_id
|
||||
JOIN SALON USING (salon_id)
|
||||
WHERE (PERIODO.periodo_id, facultad.facultad_id) = (:periodo_id, COALESCE(:facultad_id, facultad.facultad_id))
|
||||
WHERE (PERIODO.periodo_id, horario.facultad_id) = (:periodo_id, COALESCE(:facultad_id, horario.facultad_id))
|
||||
),
|
||||
fechas AS (
|
||||
SELECT fechas_clase(h.horario_id, true) as registro_fecha_ideal, h.horario_id
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?
|
||||
#input $_GET['id_espacio_sgu']
|
||||
define("INFORMATION", [
|
||||
'GET' => [
|
||||
|
||||
@@ -23,7 +23,8 @@ if (!isset($_GET['carrera_id'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$grupos = $db->query(<<<SQL
|
||||
try {
|
||||
$grupos = $db->query(<<<SQL
|
||||
SELECT distinct substring(horario_grupo, 7, 3)::int - 1 as horario_grupo FROM horario_view WHERE
|
||||
PERIODO_ID = :periodo_id AND
|
||||
(FACULTAD_ID = :facultad_id OR :facultad_id IS NULL) AND
|
||||
@@ -34,8 +35,12 @@ $grupos = $db->query(<<<SQL
|
||||
[
|
||||
':periodo_id' => $user->periodo_id,
|
||||
':facultad_id' => $user->facultad['facultad_id'],
|
||||
':carrera_id' => $_GET['carrera_id']
|
||||
':carrera_id' => $_GET['carrera_id'] ?? 0
|
||||
]
|
||||
);
|
||||
);
|
||||
} catch (PDOException $ex) {
|
||||
echo json_encode([]);
|
||||
exit();
|
||||
}
|
||||
|
||||
echo json_encode(array_map(fn($grupo) => $grupo['horario_grupo'], $grupos));
|
||||
15
action/action_usuarios_delete.php
Normal file
15
action/action_usuarios_delete.php
Normal file
@@ -0,0 +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;
|
||||
}
|
||||
33
action/asignacion_delete.php
Normal file
33
action/asignacion_delete.php
Normal file
@@ -0,0 +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);
|
||||
?>
|
||||
@@ -23,6 +23,8 @@ $hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//l
|
||||
$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"];
|
||||
@@ -32,7 +34,7 @@ else
|
||||
//$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 from tipoaula where tipoaula_id = :id", [":id"=>$aula]);
|
||||
$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]);
|
||||
@@ -45,16 +47,52 @@ $fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$
|
||||
$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"]] );
|
||||
|
||||
|
||||
//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)',[':rol_coord' => COORDINADOR, ':id_usr' => $user->user["id"]]
|
||||
);
|
||||
if( count($correos_rs) > 0 ){
|
||||
$to = $correos_rs["usuario_correo"];
|
||||
$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
|
||||
@@ -77,10 +115,14 @@ if($traslape){
|
||||
}
|
||||
|
||||
try{
|
||||
//echo "SELECT * from fi_asignacion_solicitud( $fecha_new, $hora, $prof, 1, $comentario, $alumnos, $aula, $duracion_tiempo, ".$user->user["id"].")";
|
||||
$db->query('SELECT * from fi_asignacion_solicitud(:f_nueva, :hora_nueva, :prof, 1, :desc, :alumnos, :aula, :duracion, :usr)',
|
||||
$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, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"]
|
||||
':prof' => $prof, ':edo'=>$edo, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"]
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
@@ -88,9 +130,34 @@ try{
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$texto = "<p>Se creó una asignación nueva.</p>";
|
||||
$texto .= "<p><b>Se solicita un espacio de tipo ".mb_strtoupper($aula_rs["tipoaula_nombre"])."</b> del día <b>".$fecha_new." hrs. </b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
|
||||
$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();
|
||||
@@ -100,7 +167,6 @@ $log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSI
|
||||
|
||||
|
||||
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">
|
||||
|
||||
81
action/asignacion_select.php
Normal file
81
action/asignacion_select.php
Normal file
@@ -0,0 +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);
|
||||
?>
|
||||
135
action/asignacion_update.php
Normal file
135
action/asignacion_update.php
Normal file
@@ -0,0 +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();
|
||||
?>
|
||||
46
action/horario_profesor.php
Normal file
46
action/horario_profesor.php
Normal file
@@ -0,0 +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()
|
||||
]);
|
||||
}
|
||||
7
action/mail_javier.php
Normal file
7
action/mail_javier.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
require_once "../class/c_login.php";
|
||||
require_once "../class/mailer.php";
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
|
||||
Mailer::enviarCorreo("javier.garrido@lasalle.mx", "Prueba de correo", "Este es un correo de prueba", "", true);
|
||||
echo "Correo enviado";
|
||||
@@ -27,13 +27,33 @@ if(!isset($_POST["id"]) || !isset($_POST["edo"]) ){
|
||||
|
||||
$id_repo = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$edo = filter_input(INPUT_POST, "edo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$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 reposición
|
||||
$reposicion_rs = $db->querySingle('SELECT h.materia, r.fecha_nueva, r.hora_nueva, r.fecha_clase, h.horario_hora, h.facultad_id, h.facultad, f.clave_dependencia, r.motivo_cancelacion, ta.tipoaula_supervisor , ta.tipoaula_nombre
|
||||
//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
|
||||
@@ -42,22 +62,8 @@ $reposicion_rs = $db->querySingle('SELECT h.materia, r.fecha_nueva, r.hora_nueva
|
||||
[':id_repo' => $id_repo]
|
||||
);
|
||||
|
||||
//Obtiene datos de salón asignado
|
||||
$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 p.profesor_nombre, p.profesor_correo, u.usuario_nombre as jefe_nombre, u.usuario_correo as jefe_correo,
|
||||
//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
|
||||
@@ -67,7 +73,31 @@ $correos_rs = $db->query('SELECT p.profesor_nombre, p.profesor_correo, u.usuario
|
||||
where rs.reposicion_solicitud_id = :id_repo',
|
||||
[':rol_coord' => COORDINADOR, ':id_repo' => $id_repo]
|
||||
);
|
||||
//print_r($correos_rs); exit();
|
||||
//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=[];
|
||||
@@ -91,22 +121,27 @@ foreach($correos_rs as $correo){
|
||||
}
|
||||
}
|
||||
|
||||
$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_correo as 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)
|
||||
and hs.turno_inicio <= :hora and hs.turno_fin >= :hora",
|
||||
[':facultad'=>$reposicion_rs["facultad_id"], ':hora'=>$reposicion_rs["hora_nueva"]] );
|
||||
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($edo == 4){//cancelación
|
||||
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{
|
||||
}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]
|
||||
@@ -116,20 +151,19 @@ if($edo == 4){//cancelación
|
||||
[':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];
|
||||
|
||||
$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){
|
||||
$asunto = "";
|
||||
$texto = "";
|
||||
$to = "";
|
||||
switch($edo){
|
||||
case 2://Correo a supervisor
|
||||
$asunto = "Reposición nueva - ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"];
|
||||
//crear plantilla
|
||||
@@ -140,8 +174,9 @@ switch($edo){
|
||||
}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(",", $correosSup_rs);
|
||||
$to = join(",", $sup_correos);
|
||||
$ok = 0;
|
||||
break;
|
||||
case 3://Correo a coordinador, profesor y jefe
|
||||
@@ -149,6 +184,9 @@ switch($edo){
|
||||
$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"];
|
||||
@@ -156,9 +194,77 @@ switch($edo){
|
||||
$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">
|
||||
@@ -166,13 +272,12 @@ if($to!= "" && ENVIO_CORREOS){
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
/*if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
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);
|
||||
}*/
|
||||
Mailer::enviarCorreo("alejandro.rosales@lasalle.mx", $asunto, $texto, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -20,15 +20,16 @@ $user = unserialize($_SESSION['user']);
|
||||
$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 de reposicion
|
||||
$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$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"] != "")
|
||||
@@ -36,7 +37,7 @@ if(!$user->jefe_carrera){//coordinador
|
||||
}
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user["id"];
|
||||
$prof = $user->user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
@@ -56,11 +57,13 @@ $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));
|
||||
|
||||
|
||||
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{
|
||||
@@ -131,7 +134,7 @@ if($tipo == 1){//Reposición
|
||||
}
|
||||
}catch(Exception $e){
|
||||
|
||||
echo $e->getMessage();
|
||||
echo "ERROR Reposición<br>".$e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
@@ -151,23 +154,23 @@ if($tipo == 1){//Reposición
|
||||
|
||||
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_cambio, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
$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, true, :aula, :duracion, :usr, :bloque, :ciclo, :salon)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
$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){
|
||||
|
||||
header("Location: ".$pag."?error=1");
|
||||
echo "ERROR Cambio<br>".$e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$texto = "<p>Se creó un cambio de salón nuevo.</p>";
|
||||
@@ -191,13 +194,13 @@ if($to!= "" && ENVIO_CORREOS){
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
/*if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
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);
|
||||
}*/
|
||||
Mailer::enviarCorreo("alejandro.rosales@lasalle.mx", $asunto, $texto, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header("Location: ".$pag."?ok=0");
|
||||
|
||||
@@ -80,6 +80,9 @@ $user = unserialize($_SESSION['user']);
|
||||
$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);
|
||||
?>
|
||||
|
||||
@@ -5,7 +5,7 @@ require_once "../class/c_login.php";
|
||||
|
||||
$universidad_la_salle = $db
|
||||
->where('salon', 'UNIVERSIDAD LA SALLE', 'ILIKE')
|
||||
->getOne('salon_view');
|
||||
->getOne('salon_view_mat');
|
||||
|
||||
$rutas =
|
||||
array_map(
|
||||
@@ -14,14 +14,14 @@ $rutas =
|
||||
$db
|
||||
->where('id_espacio_padre', $ruta['id_espacio_sgu'])
|
||||
->orderBy('salon')
|
||||
->get('salon_view');
|
||||
->get('salon_view_mat');
|
||||
return $ruta;
|
||||
|
||||
},
|
||||
$db
|
||||
->where('id_espacio_padre', $universidad_la_salle['id_espacio_sgu'])
|
||||
->orderBy('salon')
|
||||
->get('salon_view')
|
||||
->get('salon_view_mat')
|
||||
);
|
||||
|
||||
// echo json_encode($universidad_la_salle, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); EXIT;
|
||||
|
||||
@@ -31,7 +31,7 @@ try {
|
||||
$data = $db
|
||||
->where('tiene_salones')
|
||||
->where("{$_GET['id_espacio_sgu']} = ANY(id_espacio_sgu_array)")
|
||||
->get('salon_view', columns: 'id_espacio_sgu, salon, salon_id, salon_array');
|
||||
->get('salon_view_mat', columns: 'id_espacio_sgu, salon, salon_id, salon_array');
|
||||
|
||||
$columns = [
|
||||
// horario
|
||||
@@ -61,43 +61,47 @@ try {
|
||||
'reposicion_hora_fin',
|
||||
'salon_reposicion.salon as reposicion_salon',
|
||||
];
|
||||
$fecha = ($_GET['fecha'] != 'null') ? ("'{$_GET['fecha']}'" ?: 'CURRENT_DATE') : 'CURRENT_DATE';
|
||||
$data = array_map(
|
||||
fn($ruta) => array_merge(
|
||||
[
|
||||
'horarios' => $db
|
||||
->join('periodo', 'periodo.periodo_id = horario_view.periodo_id')
|
||||
->join('bloque_horario', '(bloque_horario.hora_inicio, bloque_horario.hora_fin) OVERLAPS (horario_view.horario_hora, horario_view.horario_hora + horario_view.duracion)')
|
||||
->join('salon_view', 'salon_view.salon_id = horario_view.salon_id')
|
||||
->join('horario_profesor', 'horario_profesor.horario_id = horario_view.horario_id')
|
||||
->join('profesor', 'profesor.profesor_id = horario_profesor.profesor_id')
|
||||
->join('registro', '(registro.profesor_id, registro.horario_id, registro.registro_fecha_ideal) = (profesor.profesor_id, horario_view.horario_id, CURRENT_DATE)', 'LEFT')
|
||||
->join('reposicion', 'reposicion.reposicion_id = registro.reposicion_id', 'LEFT')
|
||||
->join('salon as salon_reposicion', 'salon_reposicion.salon_id = reposicion.salon_id', 'LEFT')
|
||||
->where('CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin')
|
||||
->where('horario_dia = EXTRACT(DOW FROM CURRENT_DATE)')
|
||||
->where('bloque_horario.id', $_GET['bloque_horario_id'])
|
||||
->where('salon_view.id_espacio_padre', $ruta['id_espacio_sgu'])
|
||||
->orderBy('horario_hora')
|
||||
->orderBy('salon_view.salon')
|
||||
->get(
|
||||
'horario_view',
|
||||
columns: $columns
|
||||
'horarios' => $db->query(
|
||||
"SELECT " . implode(', ', $columns) . <<<SQL
|
||||
FROM horario_view
|
||||
NATURAL JOIN periodo
|
||||
JOIN bloque_horario ON (bloque_horario.hora_inicio, bloque_horario.hora_fin) OVERLAPS (horario_view.horario_hora, horario_view.horario_hora + horario_view.duracion)
|
||||
NATURAL JOIN salon_view_mat
|
||||
NATURAL JOIN horario_profesor
|
||||
NATURAL JOIN profesor
|
||||
LEFT JOIN registro ON (registro.profesor_id, registro.horario_id, registro.registro_fecha_ideal) = (profesor.profesor_id, horario_view.horario_id, $fecha::DATE)
|
||||
NATURAL LEFT JOIN reposicion
|
||||
LEFT JOIN salon AS salon_reposicion ON salon_reposicion.salon_id = reposicion.salon_id
|
||||
WHERE $fecha::DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin
|
||||
AND horario_dia = EXTRACT(DOW FROM $fecha::DATE)
|
||||
AND bloque_horario.id = :bloque_horario_id
|
||||
AND salon_view_mat.id_espacio_padre = :id_espacio_sgu
|
||||
ORDER BY horario_hora, salon_view_mat.salon;
|
||||
SQL,
|
||||
[
|
||||
'bloque_horario_id' => $_GET['bloque_horario_id'],
|
||||
'id_espacio_sgu' => $ruta['id_espacio_sgu'],
|
||||
]
|
||||
),
|
||||
// 'query' => $db->getLastQuery(),
|
||||
'reposiciones' => $db->query(
|
||||
'SELECT ' . implode(', ', $columns) . <<<SQL
|
||||
, reposicion_hora + horario_view.duracion as reposicion_fin
|
||||
, reposicion_hora + horario_view.duracion as reposicion_fin, registro_fecha_ideal
|
||||
FROM horario_view
|
||||
JOIN periodo USING (periodo_id)
|
||||
JOIN registro USING (horario_id)
|
||||
JOIN reposicion USING (reposicion_id)
|
||||
NATURAL JOIN periodo
|
||||
NATURAL JOIN registro
|
||||
NATURAL JOIN reposicion
|
||||
JOIN bloque_horario ON (bloque_horario.hora_inicio, bloque_horario.hora_fin) OVERLAPS (reposicion_hora, reposicion_hora + horario_view.duracion)
|
||||
JOIN profesor USING (profesor_id)
|
||||
JOIN salon_view as salon_reposicion ON (salon_reposicion.salon_id = reposicion.salon_id)
|
||||
NATURAL JOIN profesor
|
||||
JOIN salon_view_mat as salon_reposicion ON (salon_reposicion.salon_id = reposicion.salon_id)
|
||||
WHERE
|
||||
CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio
|
||||
$fecha::DATE BETWEEN periodo.periodo_fecha_inicio
|
||||
AND periodo.periodo_fecha_fin
|
||||
AND reposicion_fecha = CURRENT_DATE
|
||||
AND reposicion_fecha = $fecha::DATE
|
||||
AND bloque_horario.id = :bloque_horario_id
|
||||
AND salon_reposicion.id_espacio_padre = :id_espacio_sgu
|
||||
ORDER BY reposicion_hora
|
||||
|
||||
@@ -3,21 +3,9 @@ $ruta = '../';
|
||||
require_once '../include/bd_pdo.php';
|
||||
global $pdo;
|
||||
|
||||
if ($_POST['nombre'] == "") {
|
||||
$nombre = null;
|
||||
} else {
|
||||
$nombre = $_POST['nombre'];
|
||||
}
|
||||
if ($_POST['clave'] == "") {
|
||||
$clave = null;
|
||||
} else {
|
||||
$clave = $_POST['clave'];
|
||||
}
|
||||
if ($_POST['facultad'] == "") {
|
||||
$facultad = null;
|
||||
} else {
|
||||
$facultad = $_POST['facultad'];
|
||||
}
|
||||
$nombre = $_POST['nombre'] ?: null;
|
||||
$clave = $_POST['clave'] ?: null;
|
||||
$facultad = $_POST['facultad'] ?: null;
|
||||
|
||||
echo json_encode($db->query("SELECT * FROM fs_profesores(:nombre, :clave, :facultad) ORDER BY profesor_nombre", [':nombre' => $nombre, ':clave' => $clave, ':facultad' => $facultad]));
|
||||
?>
|
||||
@@ -24,11 +24,15 @@ if ($user->acceso === null && !$user->admin){
|
||||
exit();
|
||||
}
|
||||
|
||||
//if (!$user->admin && in_array($user->acceso, ['n']))
|
||||
//die(header('Location: main.php?error=1'));
|
||||
//$user->print_to_log('Reposiciones');
|
||||
$jefatura = false;
|
||||
$coordinador = false;
|
||||
if($user->rol["rol_id"]==11){
|
||||
$jefatura = true;
|
||||
}
|
||||
if($user->rol["rol_id"]==9){
|
||||
$coordinador = true;
|
||||
}
|
||||
|
||||
//$write = $user->admin || in_array($user->acceso, ['w']);
|
||||
$write = true; //
|
||||
|
||||
$en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", [':periodo_id' => $user->periodo_id])['esta_en_periodo'];
|
||||
@@ -166,14 +170,14 @@ if(!is_null($user->periodo_id)){
|
||||
</form>
|
||||
|
||||
<?php
|
||||
$reposiciones_rs = $db->query('SELECT * FROM fs_reposiciones_solicitud(:f_ini, :f_fin, :usr ,NULL, NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]);
|
||||
$asignaciones_rs = $db->query('SELECT * FROM fs_asignaciones_solicitud(:f_ini, :f_fin, :usr ,NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<?php
|
||||
if(isset($reposiciones_rs) && count($reposiciones_rs)>0){ ?>
|
||||
<h3 class="mb-3">Reposiciones creadas</h3>
|
||||
if(isset($asignaciones_rs) && count($asignaciones_rs)>0){ ?>
|
||||
<h3 class="mb-3">Asignaciones creadas</h3>
|
||||
<div class="col-12 table-responsive px-0">
|
||||
<table class="table table-sm table-striped table-white">
|
||||
<thead class="thead-dark">
|
||||
@@ -188,16 +192,16 @@ if(!is_null($user->periodo_id)){
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach($reposiciones_rs as $reposicion){
|
||||
foreach($asignaciones_rs as $asignacion){
|
||||
?>
|
||||
<tr data-id="<?php echo $reposicion["reposicion_id"]; ?>" id="id<?php echo $reposicion["reposicion_id"]; ?>">
|
||||
<td class="align-middle text-center" style="color:<?php echo $reposicion["estado_color"];?>" title="<?php echo $reposicion["estado_nombre"];?>">
|
||||
<?php if($reposicion["estado_reposicion_id"]<3){ ?>
|
||||
<div class="wizard <?php if(intval($reposicion["estado_reposicion_id"])==2) echo "active";?> d-flex mx-auto">
|
||||
<tr data-id="<?php echo $asignacion["asignacion_solicitud_id"]; ?>" id="id<?php echo $asignacion["asignacion_solicitud_id"]; ?>">
|
||||
<td class="align-middle text-center" style="color:<?php echo $asignacion["estado_color"];?>" title="<?php echo $asignacion["estado_nombre"];?>">
|
||||
<?php if($asignacion["estado_reposicion_id"]<3){ ?>
|
||||
<div class="wizard <?php if(intval($asignacion["estado_reposicion_id"])==2) echo "active";?> d-flex mx-auto">
|
||||
<div class="w-50 h-100"></div>
|
||||
<div class=""></div>
|
||||
</div>
|
||||
<?php } else if($reposicion["estado_reposicion_id"]==3){?>
|
||||
<?php } else if($asignacion["estado_reposicion_id"]==3){?>
|
||||
<div class="text-success text-center pt-1">
|
||||
<span class="ing-autorizar ing-lg"></span>
|
||||
</div>
|
||||
@@ -207,19 +211,19 @@ if(!is_null($user->periodo_id)){
|
||||
</div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="align-middle"><?php echo $reposicion["profesor_nombre"]; ?></td>
|
||||
<td class="align-middle"><?php echo $asignacion["profesor_nombre"]; ?></td>
|
||||
<td class="align-middle text-center"><?php
|
||||
|
||||
echo date("d/m/Y", strtotime($reposicion["fecha_nueva"])) ."<br>".substr($reposicion["hora_nueva"],0,-3)." a ".substr($reposicion["hora_nueva_fin"],0,-3)." hrs.";
|
||||
echo date("d/m/Y", strtotime($asignacion["fecha_nueva"])) ."<br>".substr($asignacion["hora_nueva"],0,-3)." a ".substr($asignacion["hora_nueva_fin"],0,-3)." hrs.";
|
||||
?>
|
||||
</td>
|
||||
<td class="align-middle text-center"><?php
|
||||
echo $reposicion["duracion_total"];
|
||||
echo $asignacion["duracion_total"];
|
||||
?>
|
||||
</td>
|
||||
<td class="align-middle text-center"><?php
|
||||
if($reposicion["salon_id"] != ""){
|
||||
echo $reposicion["salon_id"];
|
||||
if($asignacion["salon_id"] != ""){
|
||||
echo $asignacion["salon_id"];
|
||||
}else
|
||||
echo "Pendiente";
|
||||
?>
|
||||
@@ -228,9 +232,9 @@ if(!is_null($user->periodo_id)){
|
||||
<?php if($write){ ?>
|
||||
<td class="align-middle text-center icono-acciones">
|
||||
<?php
|
||||
|
||||
//no se ha aprobado
|
||||
if(($reposicion["estado_reposicion_id"] == 1 && $user->jefe_carrera) || ($reposicion["estado_reposicion_id"] == 2 && !$user->jefe_carrera)){?>
|
||||
|
||||
if(($asignacion["estado_reposicion_id"] == 1 && $jefatura) || ($asignacion["estado_reposicion_id"] == 2 && $coordinador)){?>
|
||||
<a href="#" data-tipo="2" title="Editar" data-toggle="modal" data-target="#modal"><?php echo $ICO["editar"];?></a>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_confirm" title="Borrar"><?php echo $ICO["cancelar"];?></a>
|
||||
<?php } ?>
|
||||
@@ -349,9 +353,11 @@ if(!is_null($user->periodo_id)){
|
||||
<div class="datalist-input">Salón</div>
|
||||
<span class="ing-buscar icono"></span>
|
||||
<ul style="display:none">
|
||||
<li data-id="1">Salón</li>
|
||||
<li data-id="2">Sala de cómputo</li>
|
||||
<li data-id="3">Salón/Taller de la facultad</li>
|
||||
<?php
|
||||
$tipoaula_rs = $db->query('select * from tipoaula t order by t.tipoaula_id ');
|
||||
foreach($tipoaula_rs as $ta){ ?>
|
||||
<li data-id="<?php echo $ta["tipoaula_id"];?>"><?php echo $ta["tipoaula_nombre"];?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<input type="hidden" id="aula" name="aula" value="1">
|
||||
</div>
|
||||
@@ -367,12 +373,19 @@ if(!is_null($user->periodo_id)){
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mt-3">
|
||||
<div class="form-group row mt-3" id="submitGroup">
|
||||
<div class="offset-4 col-8">
|
||||
<button type="submit" class="btn btn-outline-primary materia-block" id="submitBtn" data-tipo="1"><?php echo $ICO["aceptar"];?> Guardar</button>
|
||||
<button type="reset" class="btn btn-outline-danger" data-dismiss="modal"><?php echo $ICO["cancelar"];?> Cancelar</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mt-3" id="loadingGroup" style="display:none">
|
||||
<div class="col-12 text-center">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -508,8 +521,6 @@ if(!is_null($user->periodo_id)){
|
||||
$("#fecha_falta").removeClass("is-invalid");
|
||||
$("#fecha_cambio").removeClass("is-invalid");
|
||||
|
||||
|
||||
if($("#tipo").val() == 1){//reposición
|
||||
if($("#fecha_falta").val() == ""){
|
||||
$("#fecha_falta").addClass("is-invalid");
|
||||
error = true;
|
||||
@@ -518,22 +529,18 @@ if(!is_null($user->periodo_id)){
|
||||
$("#fecha_inicial").addClass("is-invalid");
|
||||
error = true;
|
||||
}
|
||||
}else{
|
||||
if($("#fecha_cambio").val() == ""){
|
||||
$("#fecha_cambio").addClass("is-invalid");
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
if($("#horario").val().trim() == "" || $("#horario").val() === null){
|
||||
invalidDatalist("#horario", true);
|
||||
error = true;
|
||||
}
|
||||
|
||||
console.log(myBtn.data("tipo"));
|
||||
|
||||
if(myBtn.data("tipo") == 2 ){
|
||||
$('#formaModal').prop("action", "./action/asignacion_update.php");
|
||||
}else{
|
||||
$('#formaModal').prop("action", "./action/asignacion_insert.php");
|
||||
}
|
||||
if(!error){
|
||||
$("#loadingGroup").show();
|
||||
$("#submitGroup").hide();
|
||||
}
|
||||
return !error;
|
||||
}
|
||||
|
||||
@@ -653,6 +660,7 @@ if(!is_null($user->periodo_id)){
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var id = button.parents("tr").data("id");
|
||||
$("#id_borrar").val(id);
|
||||
|
||||
});
|
||||
|
||||
$(".btn-borrar").click(function(){
|
||||
@@ -682,9 +690,12 @@ if(!is_null($user->periodo_id)){
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var tipo = button.data('tipo'); // 1 alta, 2 edicion
|
||||
var modal = $(this);
|
||||
$("#loadingGroup").hide();
|
||||
$("#submitGroup").show();
|
||||
|
||||
$("#modal .is-invalid").removeClass("is-invalid");
|
||||
//$(this).find(".form-control:first-child").focus();
|
||||
$('#submitBtn').attr("disabled", false);
|
||||
|
||||
|
||||
$("#errorBox").collapse('hide');
|
||||
|
||||
927
cambio_crear.php
Normal file
927
cambio_crear.php
Normal file
@@ -0,0 +1,927 @@
|
||||
<?php
|
||||
|
||||
require_once 'class/c_login.php';
|
||||
if (!isset($_SESSION['user'])){
|
||||
die(header('Location: index.php'));
|
||||
}
|
||||
|
||||
//$user = unserialize($_SESSION['user']);
|
||||
$user = Login::get_user();
|
||||
|
||||
$user->access();
|
||||
//profesor, admin, rol, facultad
|
||||
if ($user->acceso === null && !$user->admin){
|
||||
die(header('Location: index.php'));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$write = true; //
|
||||
|
||||
$en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", [':periodo_id' => $user->periodo_id])['esta_en_periodo'];
|
||||
|
||||
|
||||
if($user->jefe_carrera){
|
||||
//$prof_rs = $db->query('SELECT DISTINCT * FROM fs_profesores(null, null, :fac) ORDER BY PROFESOR_NOMBRE', [':fac' => $user->facultad["facultad_id"]]);
|
||||
$prof_rs = $db->query('SELECT DISTINCT PROFESOR.* FROM PUESTO_USUARIO
|
||||
JOIN PUESTO_MATERIA USING (PUESTO_ID)
|
||||
JOIN HORARIO_VIEW USING (MATERIA_ID)
|
||||
JOIN HORARIO_PROFESOR USING (HORARIO_ID)
|
||||
JOIN PROFESOR USING (PROFESOR_ID)
|
||||
WHERE USUARIO_ID = :usr', [':usr' => $user->user["id"]]);
|
||||
}else{
|
||||
$prof_rs = $db->query('SELECT DISTINCT PROFESOR.* FROM PROFESOR
|
||||
JOIN horario_profesor USING (profesor_id)
|
||||
JOIN HORARIO_VIEW USING (horario_id)
|
||||
WHERE FACULTAD_ID = :fac ORDER BY profesor.profesor_nombre', [':fac' => $user->facultad["facultad_id"]]);
|
||||
}
|
||||
|
||||
//Duraciones
|
||||
$duracion_rs = $db->query("select * from duracion order by duracion_interval");
|
||||
|
||||
if(!is_null($user->periodo_id)){
|
||||
//Periodo
|
||||
$periodo_rs = $db->querySingle('SELECT periodo_fecha_inicio, periodo_fecha_fin FROM periodo WHERE periodo_id = :periodo_id', [':periodo_id' => $user->periodo_id]);
|
||||
$periodo_fin = $periodo_rs["periodo_fecha_fin"];
|
||||
if(strtotime($periodo_rs["periodo_fecha_inicio"])>strtotime(date("Y-m-d")) )
|
||||
$fecha_man = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"]));
|
||||
else{
|
||||
$dia_actual = intval(date("w"));
|
||||
$dias = 2;//días mínimos Lun a Jue
|
||||
if($dia_actual ==5 || $dia_actual ==4 )//Vie
|
||||
$dias=4;
|
||||
else if( $dia_actual ==6 )//Sab
|
||||
$dias=3;
|
||||
else if( $dia_actual ==0 )//Do
|
||||
$dias=2;
|
||||
|
||||
$fecha_man = date("d/m/Y", strtotime("+".$dias." day"));
|
||||
}
|
||||
/*
|
||||
// Materias
|
||||
$id_prof = $user->profesor;
|
||||
//$facultad_id = 28;
|
||||
$materias_rs = $db->query('SELECT * FROM fs_materiasprofesor(:id)', [':id' => $id_prof]);
|
||||
*/
|
||||
if(isset($_POST["fecha_inicial"]))
|
||||
$fecha_ini = $_POST["fecha_inicial"];
|
||||
else
|
||||
$fecha_ini = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"]));
|
||||
|
||||
if(isset($_POST["fecha_final"]))
|
||||
$fecha_fin = $_POST["fecha_final"];
|
||||
else
|
||||
$fecha_fin = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_fin"]));
|
||||
|
||||
$date = DateTime::createFromFormat('d/m/Y', $fecha_ini);
|
||||
$fecha_ini_db = $date->format('Y-m-d');
|
||||
|
||||
$date = DateTime::createFromFormat('d/m/Y', $fecha_fin);
|
||||
$fecha_fin_db = $date->format('Y-m-d');
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Reposiciones crear |
|
||||
<?= $user->facultad['facultad'] ?? "Administrador"; ?>
|
||||
</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
|
||||
integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw=="
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<?php
|
||||
include 'import/html_css_files.php';
|
||||
?>
|
||||
<link rel="stylesheet" href="css/jquery-ui.css">
|
||||
<link rel="stylesheet" href="css/calendar.css">
|
||||
<style>
|
||||
.wizard { height: 20px; width: 80%; background: #D0D0D0; }
|
||||
.wizard.full { background: #D0D0D0; }
|
||||
.wizard.active > div:first-child { background: #00A6CE; }
|
||||
.wizard.active > div:last-child { width: 0px; height: 0px; border-style: solid; border-width: 10px 0 10px 6px; border-color: transparent transparent transparent #00a6ce; transform: rotate(0deg); }
|
||||
</style>
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="js/bootstrap/popper.min.js"></script>
|
||||
<script src="js/bootstrap/bootstrap.min.js"></script>
|
||||
<script src="js/jquery-ui.js"></script>
|
||||
<script src="js/datepicker-es.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
<!-- -->
|
||||
|
||||
<body style="display: block;">
|
||||
<?php
|
||||
include('include/constantes.php');
|
||||
include("import/html_header.php");
|
||||
html_header("Cambios permanentes de horario", "Sistema de gestión de checador");
|
||||
?>
|
||||
|
||||
<main class="container content marco content-margin" id="local-app">
|
||||
<?php
|
||||
if($write==true && isset($prof_rs) && count($prof_rs)>0) {?>
|
||||
<!-- Botón para abrir el modal -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-12 text-right">
|
||||
<button type="button" class="btn btn-outline-secondary" data-tipo="1" data-toggle="modal" data-target="#modal" <?php if (!$en_fecha ) { echo "disabled"; } ?>><span class="ing-mas ing-fw"></span>Solicitar cambio</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php }?>
|
||||
<section id="message"></section>
|
||||
<?php require('import/periodo.php') ?>
|
||||
<?php if(!is_null($user->periodo_id)) { ?>
|
||||
<form id="asistencia" method="post" onsubmit="return validaFechas()">
|
||||
<div class="form-box">
|
||||
<input type="hidden" name="facultad" value="">
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="filtro_inicial" class="col-4 col-form-label">Fecha inicial</label>
|
||||
<div class="col-8 col-sm-4">
|
||||
<input id="filtro_inicial" name="fecha_inicial" type="text" class="form-control date-picker-filtro" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="" value="<?php echo $fecha_ini;?>">
|
||||
<div class="invalid-feedback">No es una fecha válida.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="filtro_final" class="col-4 col-form-label">Fecha final</label>
|
||||
<div class="col-8 col-sm-4">
|
||||
<input id="filtro_final" name="fecha_final" type="text" class="form-control date-picker-filtro" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="" value="<?php echo $fecha_fin;?>">
|
||||
<div class="invalid-feedback">El rango de fechas no es válido.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row justify-content-center">
|
||||
<button type="submit" class="btn btn-outline-primary mr-2" id="btn-buscar"><span class="ing-buscar ing-fw"></span> Buscar</button>
|
||||
<button type="button" class="btn btn-outline-danger" onclick="window.location.href = window.location.href"><span class="ing-borrar ing-fw"></span> Limpiar</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
$reposiciones_rs = $db->query('SELECT * FROM fs_cambios_solicitud(:f_ini, :f_fin, :usr ,NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<?php
|
||||
if(isset($reposiciones_rs) && count($reposiciones_rs)>0){ ?>
|
||||
<h3 class="mb-3">Reposiciones creadas</h3>
|
||||
<div class="col-12 table-responsive px-0">
|
||||
<table class="table table-sm table-striped table-white">
|
||||
<thead class="thead-dark">
|
||||
<tr >
|
||||
<th>Estado</th>
|
||||
<th>Materia</th>
|
||||
<th>Profesor</th>
|
||||
<th style="width:160px">Fecha</th>
|
||||
<th style="width:160px">Duración</th>
|
||||
<th>Salón</th>
|
||||
<?php if($write){ ?><th>Acciones</th><?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach($reposiciones_rs as $reposicion){
|
||||
?>
|
||||
<tr data-id="<?php echo $reposicion["reposicion_id"]; ?>" id="id<?php echo $reposicion["reposicion_id"]; ?>">
|
||||
<td class="align-middle text-center" style="color:<?php echo $reposicion["estado_color"];?>" title="<?php echo $reposicion["estado_nombre"];?>">
|
||||
<?php if($reposicion["estado_reposicion_id"]<3){ ?>
|
||||
<div class="wizard <?php if(intval($reposicion["estado_reposicion_id"])==2) echo "active";?> d-flex mx-auto">
|
||||
<div class="w-50 h-100"></div>
|
||||
<div class=""></div>
|
||||
</div>
|
||||
<?php } else if($reposicion["estado_reposicion_id"]==3){?>
|
||||
<div class="text-success text-center pt-1">
|
||||
<span class="ing-autorizar ing-lg"></span>
|
||||
</div>
|
||||
<?php } else {?>
|
||||
<div class="text-danger text-center pt-1">
|
||||
<span class="ing-negar ing-lg"></span>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="align-middle"><?php echo $reposicion["materia_nombre"]; ?></td>
|
||||
<td class="align-middle">
|
||||
<?php if($reposicion["es_reposicion"]) echo "Reposición"; else echo "Cambio"; ?>
|
||||
</td>
|
||||
<td class="align-middle text-center"><?php
|
||||
echo date("d/m/Y", strtotime($reposicion["fecha_clase"]))."<br>".substr($reposicion["horario_hora"],0,-3)." a ".substr($reposicion["horario_hora_fin"],0,-3)." hrs.";;
|
||||
?>
|
||||
</td>
|
||||
<td class="align-middle text-center"><?php
|
||||
|
||||
echo date("d/m/Y", strtotime($reposicion["fecha_nueva"])) ."<br>".substr($reposicion["hora_nueva"],0,-3)." a ".substr($reposicion["hora_nueva_fin"],0,-3)." hrs.";
|
||||
?>
|
||||
</td>
|
||||
<td class="align-middle text-center"><?php
|
||||
echo $reposicion["duracion_total"];
|
||||
?>
|
||||
</td>
|
||||
<td class="align-middle text-center"><?php
|
||||
if($reposicion["salon_id"] != ""){
|
||||
echo $reposicion["salon_id"];
|
||||
}else
|
||||
echo "Pendiente";
|
||||
?>
|
||||
</td>
|
||||
|
||||
<?php if($write){ ?>
|
||||
<td class="align-middle text-center icono-acciones">
|
||||
<?php
|
||||
|
||||
//no se ha aprobado
|
||||
if(($reposicion["estado_reposicion_id"] == 1 && $user->jefe_carrera) || ($reposicion["estado_reposicion_id"] == 2 && !$user->jefe_carrera)){?>
|
||||
<a href="#" data-tipo="2" title="Editar" data-toggle="modal" data-target="#modal"><?php echo $ICO["editar"];?></a>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_confirm" title="Borrar"><?php echo $ICO["cancelar"];?></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php }
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php } else {
|
||||
if(is_null($user->periodo_id)){ ?>
|
||||
<div class="col-12 text-center">
|
||||
<h4 class="mt-4 text-danger">Selecciona un periodo</h4>
|
||||
</div>
|
||||
<?php } else {?>
|
||||
<div class="col-12 text-center">
|
||||
<h4 class="mt-4 text-danger">No hay solicitudes de cambio disponibles que cumplan con los filtros</h4>
|
||||
</div>
|
||||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="col-12 modal-title text-center"><span id="modalLabel">Solicitar Cambio</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/cambio_insert.php" method="post" id="formaModal" onsubmit="return submitForm()">
|
||||
<input type="hidden" name="id" id="id">
|
||||
<input type="hidden" name="estado" value="1">
|
||||
<input type="hidden" name="ciclo" id="ciclo" value="0">
|
||||
<input type="hidden" name="bloque" id="bloque" value="0">
|
||||
|
||||
<div class="form-box">
|
||||
|
||||
<div class="form-group row" id="profBlock">
|
||||
<label for="prof" class="col-4 col-form-label">Profesor *</label>
|
||||
<div class="col-8">
|
||||
<div class="datalist datalist-select mb-1 w-100" id="dlProfesor">
|
||||
<div class="datalist-input">Selecciona un profesor</div>
|
||||
<span class="ing-buscar icono"></span>
|
||||
<ul style="display:none">
|
||||
<?php foreach($prof_rs as $prof){?>
|
||||
<li data-id="<?php echo $prof["profesor_id"];?>" <?php if($prof["profesor_id"]==$user->profesor){ echo "class='selected'";} ?> ><?php echo $prof["profesor_nombre"];?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<input type="hidden" id="prof" name="prof" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-box prof-selected">
|
||||
<div class="form-group row" id="materiaBlock">
|
||||
<label for="horario" class="col-4 col-form-label">Materia *</label>
|
||||
<div class="col-8">
|
||||
<div class="datalist datalist-select mb-1 w-100" id="dlMateria">
|
||||
<div class="datalist-input">Selecciona una materia</div>
|
||||
<span class="ing-buscar icono"></span>
|
||||
<ul style="display:none">
|
||||
|
||||
</ul>
|
||||
<input type="hidden" id="horario" name="horario" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row" id="profBlock">
|
||||
<label for="prof" class="col-4 col-form-label">Profesor nuevo*</label>
|
||||
<div class="col-8">
|
||||
<div class="datalist datalist-select mb-1 w-100" id="dlProfesor">
|
||||
<div class="datalist-input">Selecciona un profesor</div>
|
||||
<span class="ing-buscar icono"></span>
|
||||
<ul style="display:none">
|
||||
<?php foreach($prof_rs as $prof){?>
|
||||
<li data-id="<?php echo $prof["profesor_id"];?>" <?php if($prof["profesor_id"]==$user->profesor){ echo "class='selected'";} ?> ><?php echo $prof["profesor_nombre"];?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<input type="hidden" id="prof" name="prof" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row materia-block">
|
||||
<label for="duracion" class="col-4 col-form-label">Duración</label>
|
||||
<div class="col-4">
|
||||
<select name="duracion" id="duracion" class="form-control" required="required">
|
||||
<?php foreach($duracion_rs as $dura){?>
|
||||
<option value="<?php echo $dura["duracion_id"];?>" data-duracion="<?php echo $dura["duracion_interval"];?>" ><?php echo $dura["duracion_nombre"];?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<small class="form-text text-muted">Original: <span id="duracion_original">0</span></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row cambio_block materia-block">
|
||||
<label for="fecha_cambio" class="col-4 col-form-label">Fecha de cambio *</label>
|
||||
<div class="col-8">
|
||||
<small class="form-text text-muted">Selecciona el día a partir del cuál se aplicará</small>
|
||||
<input id="fecha_cambio" name="fecha_cambio" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="readonly" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row materia-block">
|
||||
<label for="hora_ini" class="col-4 col-form-label" id="hora_nombre">Hora cambio *</label>
|
||||
<?php
|
||||
//define("HORA_FINAL", 22);
|
||||
//define("FRACCION_HORA", 15);
|
||||
$default_h = 7; $default_m = 15;
|
||||
?>
|
||||
<div class="col-4">
|
||||
<select name="hora_ini" id="hora_ini" class="form-control" required="required">
|
||||
<?php for($h = $default_h; $h < HORA_FINAL; $h++){?>
|
||||
<option value="<?php echo sprintf( '%02d', $h );?>" <?php if($default_h == $h){ echo 'selected="selected"';}?>><?php echo sprintf( '%02d', $h );?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<small class="form-text text-muted">Original: <span id="hora_original">0</span></small>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<select name="min_ini" id="min_ini" class="form-control" required="required">
|
||||
<?php for($m = 0; $m < 60; $m+=(60/FRACCION_HORA)){?>
|
||||
<option value="<?php echo sprintf( '%02d', $m );?>" <?php if($default_m == $m){ echo 'selected="selected"';}?>><?php echo sprintf( '%02d', $m );?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row materia-block">
|
||||
<label for="salon" class="col-4 col-form-label">Alumnos aproximados *</label>
|
||||
<div class="col-8 col-md-4">
|
||||
<input type="number" name="alumnos" id="alumnos" class="form-control" value="1" min="1" max="50">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row materia-block">
|
||||
<label for="aula" class="col-4 col-form-label">Tipo aula *</label>
|
||||
<div class="col-8">
|
||||
<div class="datalist datalist-select mb-1 w-100" id="dlAula">
|
||||
<div class="datalist-input">Salón</div>
|
||||
<span class="ing-buscar icono"></span>
|
||||
<ul style="display:none">
|
||||
<?php
|
||||
$tipoaula_rs = $db->query('select * from tipoaula t order by t.tipoaula_id ');
|
||||
foreach($tipoaula_rs as $ta){ ?>
|
||||
<li data-id="<?php echo $ta["tipoaula_id"];?>"><?php echo $ta["tipoaula_nombre"];?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<input type="hidden" id="aula" name="aula" value="1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(!$user->jefe_carrera){//es coordinador
|
||||
$salones_rs = $db->query('SELECT * from salon_view where es_salon is true');
|
||||
?>
|
||||
<div class="row" id="salon-editar" style="display: none;">
|
||||
<div class="col-6 col-sm-4 barra-right text-right">
|
||||
<p class="font-weight-bold">Salón *</p>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<input list="lista_salones" name="dlSalon" id="dlSalon" class="form-control" placeholder="Salón">
|
||||
<div class="valid-feedback">
|
||||
Salón encontrado
|
||||
</div>
|
||||
<div class="invalid-feedback">
|
||||
Salón no encontrado
|
||||
</div>
|
||||
<datalist id="lista_salones">
|
||||
<?php
|
||||
foreach ($salones_rs as $salon) {
|
||||
extract($salon);
|
||||
$salon_json = json_decode($salon_array, true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$salon_nombre = join(" / ",$salon_json);
|
||||
?>
|
||||
<option data-id="<?= $salon_id ?>" data-nombre="<?= $salon_nombre ?>" value="<?= $salon_nombre ?>"></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</datalist>
|
||||
<!-- <ul class="list-group" id="salones"></ul> -->
|
||||
<input type="hidden" id="salon" name="salon" value="">
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="form-group row materia-block">
|
||||
<label for="comentario" class="col-4 col-form-label">Comentarios</label>
|
||||
<div class="col-8">
|
||||
<p><i>Requerimientos específicos del salón, software especializado, etc.</i></p>
|
||||
<textarea rows="3" class="form-control" id="comentario" name="comentario"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mt-3" id="submitGroup">
|
||||
<div class="offset-4 col-8">
|
||||
<button type="submit" class="btn btn-outline-primary materia-block" id="submitBtn" data-tipo="1"><?php echo $ICO["aceptar"];?> Guardar</button>
|
||||
<button type="reset" class="btn btn-outline-danger" data-dismiss="modal"><?php echo $ICO["cancelar"];?> Cancelar</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mt-3" id="loadingGroup" style="display:none">
|
||||
<div class="col-12 text-center">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="modal fade" id="modal_confirm" 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-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="font-weight-bold">¿Estás seguro de que quieres borrar la reposición?</p>
|
||||
<p>Esta acción no se puede deshacer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input type="hidden" id="id_borrar" value="">
|
||||
<button type="button" class="btn btn-outline-primary btn-borrar"><?php echo $ICO["aceptar"];?> Borrar</button>
|
||||
<button type="button" class="btn btn-outline-danger" data-dismiss="modal" aria-label="Close"><?php echo $ICO["cancelar"];?> Cancelar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<? include "import/html_footer.php"; ?>
|
||||
|
||||
<?php
|
||||
//--Manejo de errores y mensajes de exito
|
||||
if(isset($_GET["error"]) && is_numeric($_GET["error"])){
|
||||
switch ($_GET["error"]){
|
||||
case 0: $errorDesc = "No se reciberon los datos de la reposición."; break;
|
||||
case 1: $errorDesc = "Ocurrió un error al insertar los datos de la reposición/cambio."; break;
|
||||
case 2: $errorDesc = "Ocurrió un error al actualizar los datos de la reposición/cambio."; break;
|
||||
case 3: $errorDesc = "No tienes permisos para realizar esa acción."; break;
|
||||
case 4: $errorDesc = "Ocurrió un error al cargar los datos de la reposición/cambio."; break;
|
||||
case 6: $errorDesc = "La reposición/cambio que buscas no existe. Consulta la lista de reopsiciones disponibles en esta sección."; break;
|
||||
case 7: $errorDesc = "La reposición/cambio se empalma con el horario del grupo y no se puede guardar."; break;
|
||||
case 8: $errorDesc = "El salón de la reposición está siendo utilizado ese día a esa hora y no se puede guardar."; break;
|
||||
case 9: $errorDesc = "El profesor está asigndo a otra clase o reposición el mismo día a la misma hora y no se puede guardar."; break;
|
||||
case 10: $errorDesc = "El profesor está asigndo a una materia el mismo día a la misma hora y no se puede guardar."; break;
|
||||
case 11: $errorDesc = "No hay clases asignadas para esa materia y grupo en la fecha de falta."; break;
|
||||
}
|
||||
}
|
||||
if(isset($_GET["ok"]) && is_numeric($_GET["ok"])){
|
||||
switch ($_GET["ok"]){
|
||||
case 0: $successDesc = "La reposición se guardó correctamente."; break;
|
||||
case 1: $successDesc = "La reposición se actualizó correctamente."; break;
|
||||
}
|
||||
}
|
||||
require_once 'js/messages.php';
|
||||
?>
|
||||
<script>
|
||||
<?php if(isset($errorDesc)){ ?>
|
||||
triggerMessage("<?php echo $errorDesc;?>", "Error");
|
||||
<?php } else if(isset($successDesc)){ ?>
|
||||
triggerMessage("<?php echo $successDesc;?>", "Éxito", "success");
|
||||
<?php } ?>
|
||||
|
||||
var vacaciones=[
|
||||
<?php
|
||||
$vacaciones_rs = $db->query('SELECT diasfestivos_dia from diasfestivos d where :periodo = any(d.periodos_id)', [':periodo' => $user->periodo_id ]);
|
||||
|
||||
foreach($vacaciones_rs as $v){ echo '"'.$v["diasfestivos_dia"].'",';}
|
||||
?>
|
||||
];
|
||||
var _dias_asistencia = [];//ya registró asistencia, cambia con ajax
|
||||
var _dia_valido = 0;
|
||||
var _fecha_manhana = "<?php echo $fecha_man; ?>";
|
||||
var _periodo_fecha_inicial = "<?php echo date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); ?>";
|
||||
var _periodo_fecha_final = "<?php echo date("d/m/Y", strtotime($periodo_rs["periodo_fecha_fin"])); ?>";
|
||||
var datepickerOptions_filtro = { dateFormat: "dd/mm/yy", minDate:_periodo_fecha_inicial, maxDate:_periodo_fecha_final};
|
||||
|
||||
var datepickerOptions = { dateFormat: "dd/mm/yy", minDate:_periodo_fecha_inicial, maxDate:_periodo_fecha_final,
|
||||
beforeShowDay: function(date) {
|
||||
var day = date.getDay();
|
||||
var dateString = $.datepicker.formatDate("yy-mm-dd", date);
|
||||
|
||||
if (vacaciones.indexOf(dateString) !== -1 || _dias_asistencia.indexOf(dateString) !== -1)
|
||||
return [false];
|
||||
else
|
||||
return [true];
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
var datepickerOptions_future = { dateFormat: "dd/mm/yy", minDate:_fecha_manhana, maxDate:_periodo_fecha_final,
|
||||
beforeShowDay: function(date) {
|
||||
var day = date.getDay();
|
||||
var dateString = $.datepicker.formatDate("yy-mm-dd", date);
|
||||
if (day === 0) {// 0 representa el domingo
|
||||
return [false];
|
||||
} else {
|
||||
if (vacaciones.indexOf(dateString) !== -1) {
|
||||
return [false];
|
||||
} else {
|
||||
return [true];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function diaAAno(fecha_str){//de dd/mm/yyyy a yyyy-mm-dd
|
||||
if(fecha_str.charAt(2) == "/" && fecha_str.charAt(5) == "/"){//dd/mm/yyyy
|
||||
var fecha_arr = fecha_str.split("/");
|
||||
return fecha_arr[2]+"-"+fecha_arr[1]+"-"+fecha_arr[0];
|
||||
}
|
||||
return fecha_str;
|
||||
}
|
||||
function fechaMayor(fechaI, fechaF) {//cual es mayor >0 I mayor <0 F mayor
|
||||
return (Date.parse(diaAAno(fechaI)) - Date.parse(diaAAno(fechaF)));
|
||||
}
|
||||
|
||||
function validaFechas(){
|
||||
if(fechaMayor($('#filtro_inicial').val().trim(), $('#filtro_final').val().trim()) > 0){
|
||||
$('#filtro_final').addClass("is-invalid");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function submitForm(){
|
||||
var myBtn = $('#submitBtn');
|
||||
var error = false;
|
||||
|
||||
$("#gpo").removeClass("is-invalid");
|
||||
invalidDatalist("#materia", false);
|
||||
$("#fecha_inicial").removeClass("is-invalid");
|
||||
$("#fecha_falta").removeClass("is-invalid");
|
||||
$("#fecha_cambio").removeClass("is-invalid");
|
||||
|
||||
|
||||
if($("#tipo").val() == 1){//reposición
|
||||
if($("#fecha_falta").val() == ""){
|
||||
$("#fecha_falta").addClass("is-invalid");
|
||||
error = true;
|
||||
}
|
||||
if($("#fecha_inicial").val() == ""){//fecha reposición
|
||||
$("#fecha_inicial").addClass("is-invalid");
|
||||
error = true;
|
||||
}
|
||||
}else{
|
||||
if($("#fecha_cambio").val() == ""){
|
||||
$("#fecha_cambio").addClass("is-invalid");
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
if($("#horario").val().trim() == "" || $("#horario").val() === null){
|
||||
invalidDatalist("#horario", true);
|
||||
error = true;
|
||||
}
|
||||
|
||||
if(myBtn.data("tipo") == 2 ){
|
||||
$('#formaModal').prop("action", "./action/cambio_update.php");
|
||||
}else{
|
||||
$('#formaModal').prop("action", "./action/cambio_insert.php");
|
||||
}
|
||||
if(!error){
|
||||
$("#loadingGroup").show();
|
||||
$("#submitGroup").hide();
|
||||
}
|
||||
return !error;
|
||||
}
|
||||
|
||||
function cambiaTipo(tipo){
|
||||
if (tipo == 1){//reposición
|
||||
$(".repo_block").show();
|
||||
$(".cambio_block").hide();
|
||||
$(".repo_block").find("input[type=text]").attr("required", true);
|
||||
$(".cambio_block").find("input[type=text]").removeAttr("required");
|
||||
$("#hora_nombre").text("Hora reposición *");
|
||||
}else{//Cambio de salón
|
||||
$(".repo_block").hide();
|
||||
$(".cambio_block").show();
|
||||
$(".repo_block").find("input[type=text]").removeAttr("required");
|
||||
$(".cambio_block").find("input[type=text]").attr("required", true);
|
||||
$("#hora_nombre").text("Hora cambio *");
|
||||
var hora = $("#dlMateria ul li.selected").data("hr");
|
||||
var min = $("#dlMateria ul li.selected").data("min");
|
||||
$("#hora_ini").val(hora)
|
||||
$("#min_ini").val(min)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".prof-selected").hide();
|
||||
//fecha de clase
|
||||
$(".date-picker" ).datepicker(datepickerOptions);
|
||||
$(".date-picker" ).datepicker( $.datepicker.regional[ "es" ] );
|
||||
|
||||
//fecha de clase
|
||||
$(".date-picker-filtro" ).datepicker(datepickerOptions_filtro);
|
||||
$(".date-picker-filtro" ).datepicker( $.datepicker.regional[ "es" ] );
|
||||
|
||||
|
||||
function creaOpcion(id_horario, dia, hora, min, nombre, gpo, duracion){
|
||||
return '<li data-id="'+id_horario+'" data-dia="'+dia+'" data-hr="'+hora+'" data-min="'+min+'" data-gpo="'+gpo+'" data-duracion="'+duracion+'">'+nombre+'</li>';
|
||||
}
|
||||
|
||||
$('#filtro_final').focus(function(){
|
||||
$("#filtro_final").removeClass("is-invalid");
|
||||
});
|
||||
|
||||
function obtieneProf(pid){
|
||||
return $.ajax({
|
||||
url: './action/reposicion_profesor_materias.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { id: pid, },
|
||||
//async: false,
|
||||
success: function(result) {
|
||||
if(result["error"]!= "" && result["error"] !== undefined){
|
||||
triggerMessage(result["error"], "Error");
|
||||
$("#modal").modal('hide');
|
||||
$(".prof-selected").hide();
|
||||
}else{
|
||||
$(".prof-selected").show();
|
||||
$("#dlMateria ul").html("");
|
||||
for(i=0; i<result["materias"].length; i++){
|
||||
var html = creaOpcion(result["materias"][i]["horario_id"],
|
||||
result["materias"][i]["horario_dia"],
|
||||
result["materias"][i]["horario_hora"],
|
||||
result["materias"][i]["horario_min"],
|
||||
result["materias"][i]["materia_nombre"],
|
||||
result["materias"][i]["grupo"],
|
||||
result["materias"][i]["duracion"]
|
||||
);
|
||||
$("#dlMateria ul").append(html);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown ){
|
||||
triggerMessage(errorThrown, "Error");
|
||||
}
|
||||
});//ajax
|
||||
}
|
||||
|
||||
$(document).on( "click", "#dlProfesor ul li", function(event){//cambia datalist
|
||||
var pid = $(this).data('id');
|
||||
//busca materias del profesor
|
||||
var profCarga = obtieneProf(pid);
|
||||
profCarga.done(function(){
|
||||
$("#dlMateria ul li:first").click();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//Actualiza días elegibles de calendario
|
||||
$(document).on( "click", "#dlMateria ul li", function(event){//manda al frente de todos
|
||||
_dia_valido = $(this).data('dia');//variable global
|
||||
var grupo = $(this).data("gpo");
|
||||
var duracionMateria = $(this).data("duracion");
|
||||
|
||||
$(".date-picker" ).datepicker(datepickerOptions);
|
||||
var hora = $(this).data("hr");
|
||||
var min = $(this).data("min");
|
||||
$("#hora_ini").val(hora)
|
||||
$("#min_ini").val(min)
|
||||
|
||||
$("#ciclo").val(parseInt(grupo[6]));
|
||||
$("#bloque").val(parseInt(grupo[8])-1);
|
||||
|
||||
$('#duracion option').each(function() {
|
||||
if ($(this).data("duracion") === duracionMateria) {
|
||||
// Selecciona la opción correspondiente en el select de "duracion"
|
||||
$(this).prop('selected', true);
|
||||
}
|
||||
});
|
||||
$("#duracion_original").text(duracionMateria);
|
||||
$("#hora_original").text(hora+":"+min);
|
||||
/*
|
||||
return $.ajax({
|
||||
url: './action/asistenciasprofesor_select.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { "id": $("#prof").val(), "hor": $(this).data("id") },
|
||||
//async: false,
|
||||
success: function(result) {
|
||||
if(result["error"]!= "" && result["error"] !== undefined){
|
||||
triggerMessage(result["error"], "Error");
|
||||
$('#modal').modal("hide");
|
||||
}else{
|
||||
_dias_asistencia = result["asistenciaArr"];
|
||||
//Cambiar ciclo [6] y bloque [8]
|
||||
$("#ciclo").val(parseInt(grupo[6]));
|
||||
$("#bloque").val(parseInt(grupo[8])-1);
|
||||
|
||||
$('#duracion option').each(function() {
|
||||
if ($(this).data("duracion") === duracionMateria) {
|
||||
// Selecciona la opción correspondiente en el select de "duracion"
|
||||
$(this).prop('selected', true);
|
||||
}
|
||||
});
|
||||
$("#duracion_original").text(duracionMateria);
|
||||
$("#hora_original").text(hora+":"+min);
|
||||
}
|
||||
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown ){
|
||||
triggerMessage(errorThrown, "Error");
|
||||
}
|
||||
});//ajax
|
||||
*/
|
||||
|
||||
});
|
||||
|
||||
$("#dlTipo ul li").click(function(){//cambia datalist
|
||||
cambiaTipo($(this).data('id'));
|
||||
$(".date-picker" ).datepicker(datepickerOptions);
|
||||
});
|
||||
$("#dlAula ul li").click(function(){//cambia datalist
|
||||
if($(this).data("id") == 1){
|
||||
$("#salon-editar").hide();
|
||||
$("#dlSalon").val("");
|
||||
$("#salon").val("");
|
||||
|
||||
}else{
|
||||
$("#salon-editar").show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#modal_confirm').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var id = button.parents("tr").data("id");
|
||||
$("#id_borrar").val(id);
|
||||
});
|
||||
|
||||
$(".btn-borrar").click(function(){
|
||||
var r_id = $("#id_borrar").val();
|
||||
$.ajax({
|
||||
url: './action/cambio_delete.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { id: r_id},
|
||||
success: function(result) {
|
||||
if(result["error"]!= "" && result["error"] !== undefined){
|
||||
triggerMessage(result["error"], "Error");
|
||||
}else{
|
||||
triggerMessage(result["ok"], "Éxito", "success");
|
||||
$("#id"+r_id).remove();
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown ){
|
||||
triggerMessage(errorThrown, "Error");
|
||||
}
|
||||
});//ajax
|
||||
$('#modal_confirm').modal("hide");
|
||||
});
|
||||
|
||||
|
||||
$('#modal').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var tipo = button.data('tipo'); // 1 alta, 2 edicion
|
||||
var modal = $(this);
|
||||
|
||||
$("#loadingGroup").hide();
|
||||
$("#submitGroup").show();
|
||||
|
||||
$("#modal .is-invalid").removeClass("is-invalid");
|
||||
//$(this).find(".form-control:first-child").focus();
|
||||
|
||||
|
||||
$("#errorBox").collapse('hide');
|
||||
$("#errorBox_text").html("");
|
||||
if(tipo == 1){//alta
|
||||
$("#submitBtn").data('tipo', 1);
|
||||
$("#modalLabel").html("Solicitar cambio");
|
||||
modal.find("input[type=text]").val("");
|
||||
modal.find("#alumnos").val("15");
|
||||
$("#plan").attr("readonly", false);
|
||||
$("#sem").attr("readonly", false);
|
||||
$("#gpo").attr("readonly", false);
|
||||
|
||||
//$("#prof").attr("readonly", false);
|
||||
disableDatalist("#horario", false);
|
||||
disableDatalist("#tipo", false);
|
||||
if($("#prof").length>0)
|
||||
disableDatalist("#prof", false);
|
||||
setDatalistFirst("#tipo");
|
||||
setDatalistFirst("#aula");
|
||||
setDatalistFirst("#horario");
|
||||
$("#dlMateria ul li:first").click();
|
||||
|
||||
}else{//editar
|
||||
$("#submitBtn").data('tipo', 2);
|
||||
$("#modalLabel").html("Editar Reposición");
|
||||
$("#plan").attr("readonly", true);
|
||||
$("#sem").attr("readonly", true);
|
||||
$("#gpo").attr("readonly", true);
|
||||
//$("#materia").attr("readonly", true);
|
||||
disableDatalist("#horario");
|
||||
disableDatalist("#tipo");
|
||||
disableDatalist("#prof");
|
||||
/*if($("#prof").length>0)
|
||||
disableDatalist("#prof");
|
||||
$("#prof").attr("readonly", true);*/
|
||||
var r_id = $(button).parents("tr").data("id");
|
||||
$("#id").val(r_id);
|
||||
$.ajax({
|
||||
url: './action/cambio_select.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { id: r_id },
|
||||
async: true,
|
||||
success: function(result) {
|
||||
if(result["error"]!= "" && result["error"] !== undefined){
|
||||
triggerMessage(result["error"], "Error");
|
||||
$("#modal").modal('hide');
|
||||
}else{
|
||||
//setDatalist("#prof", result["profesor"]);
|
||||
setDatalist("#prof", result["profesor"]);
|
||||
|
||||
var profCarga = obtieneProf(result["profesor"]);
|
||||
|
||||
//$('#salon').val(result["salon"]);
|
||||
$("#fecha_falta").val(result["fecha_clase"]);
|
||||
|
||||
|
||||
$('#comentario').val(result["comentario"]);
|
||||
$('#alumnos').val(result["alumnos"]);
|
||||
$('#ciclo').val(result["ciclo"]);
|
||||
$('#bloque').val(result["bloque"]);
|
||||
|
||||
if(result["tipo"]){
|
||||
setDatalist("#tipo", 1);
|
||||
cambiaTipo(1);
|
||||
$("#fecha_inicial").val(result["fecha_nueva"]);
|
||||
}else{
|
||||
setDatalist("#tipo", 2);
|
||||
cambiaTipo(2);
|
||||
$("#fecha_cambio").val(result["fecha_nueva"]);
|
||||
}
|
||||
_dia_valido = parseInt(result["dia"]);
|
||||
$(".date-picker" ).datepicker(datepickerOptions);
|
||||
$("#dlTipo ul li:selected").click();
|
||||
|
||||
|
||||
profCarga.done(function(){
|
||||
setDatalist("#horario", result["horario"]);// No se actualiza TODO
|
||||
$('#hora_ini').val(result["hora_ini"]);
|
||||
$('#min_ini').val(result["min_ini"]);
|
||||
});
|
||||
setDatalist("#aula", result["aula"]);
|
||||
modal.modal('show');
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown ){
|
||||
triggerMessage(errorThrown, "Error");
|
||||
$("#modal").modal('hide');
|
||||
//$('#messageBox')[0].scrollIntoView({ block: "end" });
|
||||
}
|
||||
});//ajax
|
||||
}
|
||||
});//show
|
||||
|
||||
});
|
||||
|
||||
$(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
})
|
||||
</script>
|
||||
<script src="js/messages.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -181,7 +181,7 @@ $write = $user->admin || in_array($user->acceso, ['r']);
|
||||
:key="`${hour}-${block}-${día}`"
|
||||
:class="horarios.getHorarioData(hour, block, día) ? 'bg-light' : ''"
|
||||
class="align-middle h-100"
|
||||
:style="`width: ${(100 - 6) / (horarios.structure?.sábado ? 6 : 5)}%;`">
|
||||
:style="`width: ${(100 - 6) / (horarios.structure?.sábado ? 6 : 5)}%;`" :data-id="horarios.getHorarioData(hour, block, día)?.horario_id">
|
||||
<!-- Content Container -->
|
||||
<div class="overflow-auto" :style="`max-height: ${horarios.getHorarioData(hour, block, día)?.bloques * 2}em;
|
||||
min-height: 2em;
|
||||
|
||||
208
horarios_historicos.php
Normal file
208
horarios_historicos.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>
|
||||
Histórico de horarios
|
||||
</title>
|
||||
<?php
|
||||
include 'import/html_css_files.php';
|
||||
?>
|
||||
<style>
|
||||
[v-cloak] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<script src="js/jquery.min.js"></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="js/bootstrap/bootstrap.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?
|
||||
$redirect = $_SERVER['PHP_SELF'];
|
||||
include "import/html_header.php";
|
||||
global $user;
|
||||
|
||||
html_header(
|
||||
"Histórico de horarios",
|
||||
"Sistema de gestión de checador",
|
||||
);
|
||||
|
||||
|
||||
|
||||
if (!$user->periodo_id) { ?>
|
||||
<script defer src="js/jquery.min.js"></script>
|
||||
<script src="js/bootstrap/bootstrap.min.js"></script>
|
||||
|
||||
<div class="modal" id="seleccionar-periodo" tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title">Seleccionar periodo</h2>
|
||||
</div>
|
||||
<div class="modal-body container">
|
||||
<? include 'import/periodo.php' ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$('#seleccionar-periodo').modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false,
|
||||
});
|
||||
$('#seleccionar-periodo').modal('show');
|
||||
</script>
|
||||
<? exit;
|
||||
} ?>
|
||||
<main class="container-fluid px-4 mt-4" id="app" v-cloak @vue:mounted="mounted" style="min-height: 60vh;"
|
||||
v-scope="">
|
||||
<?php include "import/periodo.php" ?>
|
||||
|
||||
<form class="marco" v-scope="{profesor: null}">
|
||||
<!-- datalist profesores -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-box">
|
||||
<div class="form-group row">
|
||||
<label for="profesor" class="col-form-label col-4">Profesor</label>
|
||||
<input list="profesores" class="form-control col-6 mx-3" id="profesor" v-model="profesor"
|
||||
@input="buscarHorarios(profesor)">
|
||||
<datalist id="profesores">
|
||||
<option v-for="profesor in profesores" :value="profesor.profesor_clave">
|
||||
{{profesor.profesor_nombre}}
|
||||
</option>
|
||||
</datalist>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="table-responsive marco" v-if="horarios.length > 0" v-scope="">
|
||||
<table class="table table-hover table-striped table-bordered table-sm">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th scope="col" class="text-center align-middle px-2">
|
||||
Carrera
|
||||
</th>
|
||||
<th scope="col" class="text-center align-middle px-2">
|
||||
Materia
|
||||
</th>
|
||||
<th scope="col" class="text-center align-middle px-2">
|
||||
Grupo
|
||||
</th>
|
||||
<th scope="col" class="text-center align-middle px-2">
|
||||
Horario
|
||||
</th>
|
||||
<th scope="col" class="text-center align-middle px-2">
|
||||
Alta
|
||||
</th>
|
||||
<th scope="col" class="text-center align-middle px-2">
|
||||
Baja
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="horario in horarios" :key="`horario-${horario.horario_id}`">
|
||||
<td class="align-middle px-2">
|
||||
<small>
|
||||
<strong>{{horario.facultad_nombre}}</strong>
|
||||
</small>
|
||||
{{horario.carrera_nombre}}
|
||||
</td>
|
||||
<td class="align-middle px-2 text-center">
|
||||
{{horario.materia_nombre}}
|
||||
</td>
|
||||
<td class="align-middle px-2 text-center">
|
||||
{{horario.horario_grupo}}
|
||||
</td>
|
||||
<td class="align-middle px-2 text-center"
|
||||
v-scope="{días: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado']}">
|
||||
{{días[horario.horario_dia]}} - {{horario.horario_hora}} - {{horario.horario_fin}}
|
||||
</td>
|
||||
<td class="align-middle px-2 text-center">
|
||||
{{horario.horario_fecha_inicio}}
|
||||
</td>
|
||||
<td class="align-middle px-2 text-center">
|
||||
{{horario.horario_fecha_fin}}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal" tabindex="-1" id="cargando" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Cargando datos...</h4>
|
||||
|
||||
</div>
|
||||
<div class="modal-body container">
|
||||
<div class="row">
|
||||
<div class="col-12 text-center">
|
||||
<span class="spinner-border spinner-border-lg"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal" tabindex="-1" id="mensaje">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{{mensaje.titulo}}</h4>
|
||||
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body container">
|
||||
<div class="row">
|
||||
<div class="col-12 text-center">
|
||||
{{mensaje.texto}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</main>
|
||||
|
||||
<!-- <script src=" js/datalist.js"></script> -->
|
||||
<script type="module">
|
||||
import { createApp } from 'https://unpkg.com/petite-vue?module'
|
||||
createApp({
|
||||
horarios: [],
|
||||
profesores: [],
|
||||
|
||||
async buscarHorarios(profesor_clave) {
|
||||
// if existe la clave del profesor
|
||||
if (!this.profesores.find(profesor => profesor.profesor_clave === profesor_clave)) {
|
||||
this.horarios = []
|
||||
return
|
||||
}
|
||||
|
||||
const horarios = await fetch(`/action/horario_profesor.php?profesor=${profesor_clave}`)
|
||||
this.horarios = await horarios.json()
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
const profesores = await fetch('/action/action_profesor.php')
|
||||
this.profesores = await profesores.json()
|
||||
},
|
||||
}).mount('#app')
|
||||
</script>
|
||||
<script src="js/scrollables.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -7,7 +7,9 @@ $user or die("Error: no se pudo cargar el usuario");
|
||||
<div class="col-12">
|
||||
<?php
|
||||
$target = $target ?? strtok($_SERVER["REQUEST_URI"], '?');
|
||||
$niveles = $db->get("nivel");
|
||||
$niveles = $db
|
||||
->orderBy('nivel_nombre')
|
||||
->get("nivel");
|
||||
|
||||
// collect facultad_id's with facultad from $periodos
|
||||
?>
|
||||
@@ -33,7 +35,8 @@ $user or die("Error: no se pudo cargar el usuario");
|
||||
WHERE
|
||||
nivel_id = :nivel_id AND
|
||||
(facultad_id = :facultad_id OR :facultad_id IS NULL)
|
||||
GROUP BY periodo_id, periodo_nombre',
|
||||
GROUP BY periodo_id, periodo_nombre, periodo_fecha_inicio
|
||||
ORDER BY periodo_fecha_inicio DESC',
|
||||
[
|
||||
':nivel_id' => $nivel['nivel_id'],
|
||||
':facultad_id' => $user->facultad['facultad_id']
|
||||
|
||||
63
include/bd_pdo_rest.php
Normal file
63
include/bd_pdo_rest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
require_once "/usr/share/nginx/html/paad/vendor/autoload.php";
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv->load();
|
||||
use \SeinopSys\PostgresDb;
|
||||
|
||||
# Connect to the database
|
||||
try {
|
||||
// Postgres
|
||||
$pdo = new PDO("pgsql:host=" . $_ENV['DB_HOST'] . ";dbname=" . $_ENV['DB_NAME'], $_ENV['DB_USER'], $_ENV['DB_PASS']);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$db = new PostgresDb();
|
||||
$db->setConnection($pdo);
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
}
|
||||
|
||||
// check recursivelly if the array has only empty strings
|
||||
function is_response_empty($array)
|
||||
{
|
||||
foreach ($array as $value) {
|
||||
if (is_array($value)) {
|
||||
if (!is_response_empty($value)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!empty($value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// SQL function
|
||||
function query(string $sql, array $params = null, bool $single = true)
|
||||
{
|
||||
global $pdo;
|
||||
try {
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$response = $single ? $stmt->fetch(PDO::FETCH_ASSOC) : $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $response;
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage();
|
||||
return false;
|
||||
} finally {
|
||||
$stmt->closeCursor();
|
||||
$stmt = null;
|
||||
}
|
||||
}
|
||||
|
||||
function queryAll(string $sql, array $params = null)
|
||||
{
|
||||
return query($sql, $params, false);
|
||||
}
|
||||
|
||||
function toSQLArray(array $array): string
|
||||
{
|
||||
return sprintf("{%s}", implode(", ", $array));
|
||||
}
|
||||
BIN
include/db/postgrest
Normal file
BIN
include/db/postgrest
Normal file
Binary file not shown.
20
include/db/postgrest.conf
Normal file
20
include/db/postgrest.conf
Normal file
@@ -0,0 +1,20 @@
|
||||
# postgrest.conf
|
||||
|
||||
# The standard connection URI format, documented at
|
||||
# https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
|
||||
db-uri = "postgres://postgres:4ud1t0rf4lt4$$@localhost:5432/paad_pruebas"
|
||||
|
||||
# The database role to use when no client authentication is provided.
|
||||
# Should differ from authenticator
|
||||
db-anon-role = "postgres"
|
||||
|
||||
# The secret to verify the JWT for authenticated requests with.
|
||||
# Needs to be 32 characters minimum.
|
||||
jwt-secret = "reallyreallyreallyreallyverysafe"
|
||||
jwt-secret-is-base64 = false
|
||||
|
||||
# Port the postgrest process is listening on for http requests
|
||||
server-port = 3000
|
||||
|
||||
# the location root is /api
|
||||
server-host = "*"
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createApp } from 'https://unpkg.com/petite-vue?module';
|
||||
|
||||
// añade una ventana de confirmación al intentar cambiar de página
|
||||
const app = createApp({
|
||||
message: null,
|
||||
puestos: [],
|
||||
@@ -57,6 +59,8 @@ const app = createApp({
|
||||
});
|
||||
const data = await res.json();
|
||||
this.message = data.msg;
|
||||
|
||||
modificado = false;
|
||||
// after 3 seconds, remove the message
|
||||
setTimeout(() => {
|
||||
this.message = null;
|
||||
|
||||
@@ -163,6 +163,7 @@ if ($user->admin) {
|
||||
?>
|
||||
<tr data-id="<?= $materia["materia_id"]; ?>" id="<?= $materia["materia_id"]; ?>">
|
||||
<td class="text-primary">
|
||||
<small>(<?= $materia["clave_materia"]; ?>)</small>
|
||||
<?= $materia["materia_nombre"]; ?>
|
||||
</td>
|
||||
<td class="text-primary">
|
||||
|
||||
@@ -68,13 +68,12 @@ if ($user->admin) { //si es admin su facultad es null (todas las facultades)
|
||||
}
|
||||
}
|
||||
$fs_profesores = $db->query(
|
||||
"SELECT DISTINCT PROFESOR.*, FACULTAD.* FROM profesor
|
||||
"SELECT DISTINCT PROFESOR.*, horario_view.facultad as facultad_nombre, horario_view.facultad_id FROM profesor
|
||||
JOIN horario_profesor USING (profesor_id)
|
||||
JOIN horario USING (horario_id)
|
||||
JOIN facultad ON horario.facultad_id = facultad.facultad_id
|
||||
JOIN horario_view USING (horario_id)
|
||||
WHERE
|
||||
profesor_nombre ILIKE COALESCE(:nombre, profesor_nombre) AND profesor_clave ILIKE COALESCE(:clave, profesor_clave)
|
||||
AND facultad.facultad_id = COALESCE(:facultad, facultad.facultad_id)
|
||||
AND facultad_id = COALESCE(:facultad, facultad_id)
|
||||
LIMIT :maxc",
|
||||
array(
|
||||
":nombre" => "%$desc%",
|
||||
|
||||
19
puestos.php
19
puestos.php
@@ -34,7 +34,7 @@
|
||||
|
||||
<main class="container-fluid px-4 mt-4" id="app" v-cloak @vue:mounted="mounted" style="min-height: 70vh;"
|
||||
v-scope="{new_puesto: null}">
|
||||
|
||||
<!-- {{modificado}} -->
|
||||
<div class="marco alert alert-success" role="alert" v-if="message">
|
||||
{{message}}
|
||||
</div>
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
<div class="d-flex flex-wrap marco justify-content-around">
|
||||
<div class="accordion col-10 mx-auto my-5" id="puestos"
|
||||
v-scope="{selected_carrera_id: -1, current_materia: null, current_encargado: null}"
|
||||
v-scope="{selected_carrera_id: 0, current_materia: null, current_encargado: null}"
|
||||
v-if="puestos.length">
|
||||
|
||||
<div class="card mb-3 shadow-lg" v-for="(puesto, index) in puestos" :key="puesto.puesto_id">
|
||||
@@ -106,7 +106,7 @@
|
||||
<hr>
|
||||
|
||||
<?php if ($user->acceso == 'w') { ?>
|
||||
<div class="form-row justify-content-around align-items-center mb-2"
|
||||
<!-- <div class="form-row justify-content-around align-items-center mb-2"
|
||||
v-show="carreras.length">
|
||||
<label :for="`carrera-${puesto.puesto_id}`" class="col-2 barra-right">
|
||||
Carrera
|
||||
@@ -129,7 +129,7 @@
|
||||
</ul>
|
||||
<input type="hidden" id="carrera_id" name="id">
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-row justify-content-around align-items-center"
|
||||
v-scope="{to_add_materia: null}">
|
||||
@@ -186,10 +186,9 @@
|
||||
<li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center"
|
||||
v-for="materia in puesto.materias" :key="materia.materia_id"
|
||||
<?php if ($user->acceso == 'w') { ?>
|
||||
@click="puesto.materias.splice(puesto.materias.indexOf(materia), 1); materias.push(materia)"
|
||||
@click="modificado = true; puesto.materias.splice(puesto.materias.indexOf(materia), 1); materias.push(materia)"
|
||||
<?php } ?>
|
||||
style="cursor: pointer; transition: background-color 0.3s ease;">
|
||||
|
||||
<span class="flex-grow-1">
|
||||
{{materia.clave_materia}} - {{materia.materia_nombre}}
|
||||
</span>
|
||||
@@ -312,8 +311,16 @@
|
||||
<script src="js/puestos.js?<?= rand(0, 2) ?>" type="module"></script>
|
||||
<script src="js/scrollables.js"></script>
|
||||
<script>
|
||||
let modificado = false;
|
||||
|
||||
$(document).ready(function () {
|
||||
$('.collapse').collapse
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
if (modificado) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -27,10 +27,10 @@ if ($user->acceso === null && !$user->admin){
|
||||
|
||||
$supervisor = false;
|
||||
$coordinador = false;
|
||||
if($user->rol["rol_id"]==7){
|
||||
if($user->rol["rol_id"]==7 || $user->rol["rol_id"]==8){
|
||||
$supervisor = true;
|
||||
}
|
||||
if($user->rol["rol_id"]==9){
|
||||
if($user->rol["rol_id"]==9 || $user->rol["rol_id"]==8){
|
||||
$coordinador = true;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,9 @@ if($user->periodo_id!= ""){
|
||||
$repEdo_rs = $db->query('SELECT * FROM fs_estado_reposicion' );
|
||||
|
||||
$repoParams = array();
|
||||
$asigParams = array();
|
||||
$query = "";
|
||||
|
||||
if($user->rol["rol_id"] == 9){//es coordinador
|
||||
$query .= ":facultad, ";
|
||||
$repoParams[":facultad"] = $user->facultad["facultad_id"];
|
||||
@@ -101,7 +103,8 @@ if($user->periodo_id!= ""){
|
||||
}else{
|
||||
$query .= "NULL,";
|
||||
}
|
||||
$query .= ":f_ini, :f_fin, :edo, ";
|
||||
$query .= ":f_ini, :f_fin, ";
|
||||
$queryAsig = ":f_ini, :f_fin,";
|
||||
|
||||
|
||||
$date = DateTime::createFromFormat('d/m/Y', $fecha_ini);
|
||||
@@ -112,6 +115,9 @@ if($user->periodo_id!= ""){
|
||||
$repoParams[":f_ini"] = $fecha_ini_db;
|
||||
$repoParams[":f_fin"] = $fecha_fin_db;
|
||||
$repoParams[":edo"] = 1;//se sobreescribe
|
||||
|
||||
$asigParams[":f_ini"] = $fecha_ini_db;
|
||||
$asigParams[":f_fin"] = $fecha_fin_db;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
@@ -190,8 +196,14 @@ if($user->periodo_id!= ""){
|
||||
<button type="submit" class="btn btn-outline-primary mr-2" id="btn-buscar"><span class="ing-buscar ing-fw"></span> Buscar</button>
|
||||
<button type="button" class="btn btn-outline-danger" onclick="window.location.href = window.location.href"><span class="ing-borrar ing-fw"></span> Limpiar</button>
|
||||
</div>
|
||||
|
||||
<p class="text-right">
|
||||
<button class="btn btn-secondary" id="exportar"><span class="ing-descargar"></span>Descargar xls</button>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<ul class="nav nav-tabs d-print-none mb-4" id="myTab" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="tab1-tab" data-toggle="tab" href="#tab1" role="tab" aria-controls="calendario" aria-selected="true">Nuevas reposiciones</a>
|
||||
@@ -212,17 +224,52 @@ if($user->periodo_id!= ""){
|
||||
foreach($repEdo_rs as $redo){ ?>
|
||||
<div class="tab-pane fade" id="tab<?php echo $i;?>" role="tabpanel" aria-labelledby="tab<?php echo $i;?>-tab">
|
||||
<?php
|
||||
|
||||
$tablaArr = [];
|
||||
|
||||
$repoParams[":edo"]=$redo["estado_reposicion_id"];
|
||||
$asigParams[":edo"]=$redo["estado_reposicion_id"];
|
||||
if($user->rol["rol_id"] == 7){//es supervisor
|
||||
$repoParams[":sup"] = $user->user["id"];
|
||||
$reposiciones_rs = $db->query('SELECT * FROM fs_reposicion_solicitud(NULL, '.$query.'0, NULL, :sup) ', $repoParams );
|
||||
$reposiciones_rs = $db->query('SELECT * FROM fs_reposicion_solicitud(NULL, '.$query.':edo, 0, NULL, :sup) ', $repoParams );
|
||||
}else{
|
||||
$reposiciones_rs = $db->query('SELECT * FROM fs_reposicion_solicitud(NULL, '.$query.'0, NULL) ', $repoParams );
|
||||
$reposiciones_rs = $db->query('SELECT * FROM fs_reposicion_solicitud(NULL, '.$query.':edo, 0, NULL) ', $repoParams );
|
||||
}
|
||||
foreach($reposiciones_rs as $repo){
|
||||
$tablaArr[] = array("id"=>$repo["reposicion_solicitud_id"], "estado"=>$repo["estado_reposicion_id"], "tipo"=>($repo["es_reposicion"]==true?1:2),
|
||||
"profesor_clave"=>$repo["profesor_clave"], "profesor_nombre"=>$repo["profesor_nombre"], "materia_nombre"=>$repo["materia_nombre"], "horario_grupo"=>$repo["horario_grupo"],
|
||||
"fecha_falta"=>$repo["fecha_clase"], "fecha_nueva"=>$repo["fecha_nueva"], "hora_original"=> $repo["horario_hora"], "hora_nueva"=>$repo["hora_nueva"], "hora_nueva_fin"=>$repo["hora_nueva_fin"],
|
||||
"salon_id"=>$repo["salon_id"], "salon_array"=>$repo["salon_array"]);
|
||||
}
|
||||
|
||||
if($user->rol["rol_id"] == 7){//es supervisor
|
||||
$asigParams[":sup"] = $user->user["id"];
|
||||
$asignaciones_rs = $db->query('SELECT * FROM fs_asignacion_solicitud(NULL, '.$queryAsig.' :sup, :edo) ', $asigParams );
|
||||
}else{
|
||||
$asignaciones_rs = $db->query('SELECT * FROM fs_asignacion_solicitud(NULL, '.$queryAsig.' NULL, :edo) ', $asigParams );
|
||||
}
|
||||
|
||||
|
||||
foreach($asignaciones_rs as $asig){
|
||||
$tablaArr[] = array("id"=>$asig["asignacion_solicitud_id"], "estado"=>$asig["estado_reposicion_id"], "tipo"=>3,
|
||||
"profesor_clave"=>$asig["profesor_clave"], "profesor_nombre"=>$asig["profesor_nombre"], "materia_nombre"=>"", "horario_grupo"=>"",
|
||||
"fecha_falta"=>"", "fecha_nueva"=>$asig["fecha_nueva"], "hora_original"=>"", "hora_nueva"=>$asig["hora_nueva"], "hora_nueva_fin"=>$asig["hora_nueva_fin"],
|
||||
|
||||
"salon_id"=>$asig["salon_id"], "salon_array"=>$asig["salon_array"]);
|
||||
}
|
||||
|
||||
if(count($tablaArr)>0){
|
||||
//ordena $tablaArr por fecha_repo
|
||||
usort($tablaArr, function($a, $b) {
|
||||
return strtotime($a['fecha_nueva']) - strtotime($b['fecha_nueva']);
|
||||
});
|
||||
|
||||
}else{
|
||||
echo "No hay reposiciones en este estado";
|
||||
}
|
||||
?>
|
||||
|
||||
<h4 class="mb-4" <?php echo "style='color:".$redo["estado_color"]."'>".$redo["estado_nombre"]; ?> </h4>
|
||||
<h4 class="mb-4" <?php echo "style='color:".$redo["estado_color"]."'";?> > <?php echo $redo["estado_nombre"]; ?> </h4>
|
||||
|
||||
<table class="table table-sm table-striped table-white">
|
||||
<thead class="thead-dark">
|
||||
@@ -238,17 +285,17 @@ if($user->periodo_id!= ""){
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if(isset($reposiciones_rs)){
|
||||
foreach($reposiciones_rs as $reposicion){
|
||||
if(isset($tablaArr)){
|
||||
foreach($tablaArr as $reposicion){
|
||||
?>
|
||||
<tr data-id="<?php echo $reposicion["reposicion_solicitud_id"]; ?>" data-edo="<?php echo $reposicion["estado_reposicion_id"];?>" id="id<?php echo $reposicion["reposicion_solicitud_id"]; ?>">
|
||||
<tr data-id="<?php echo $reposicion["id"]; ?>" data-edo="<?php echo $reposicion["estado"];?>" id="id<?php echo $reposicion["id"]; ?>">
|
||||
<td class="align-middle">
|
||||
<?php if($reposicion["estado_reposicion_id"]<3){ ?>
|
||||
<div class="wizard <?php if(intval($reposicion["estado_reposicion_id"])==2) echo "active";?> d-flex mx-auto">
|
||||
<?php if($reposicion["estado"]<3){ ?>
|
||||
<div class="wizard <?php if(intval($reposicion["estado"])==2) echo "active";?> d-flex mx-auto">
|
||||
<div class="w-50 h-100"></div>
|
||||
<div class=""></div>
|
||||
</div>
|
||||
<?php } else if($reposicion["estado_reposicion_id"]==3){?>
|
||||
<?php } else if($reposicion["estado"]==3){?>
|
||||
<div class="text-success text-center pt-1">
|
||||
<span class="ing-autorizar ing-lg"></span>
|
||||
</div>
|
||||
@@ -259,7 +306,11 @@ if($user->periodo_id!= ""){
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<?php if($reposicion["es_reposicion"]) echo "Resposición"; else echo "Cambio"; ?>
|
||||
<?php switch($reposicion["tipo"]){
|
||||
case 1: echo "Resposición"; break;
|
||||
case 2: echo "Cambio"; break;
|
||||
case 3: echo "Asignación"; break;
|
||||
}?>
|
||||
</td>
|
||||
<td><?php
|
||||
echo $reposicion["profesor_clave"]." - ".$reposicion["profesor_nombre"];
|
||||
@@ -267,14 +318,19 @@ if($user->periodo_id!= ""){
|
||||
<br>
|
||||
<small>
|
||||
<?php echo $reposicion["materia_nombre"]; ?>
|
||||
(<?php
|
||||
echo $reposicion["horario_grupo"];
|
||||
?>)
|
||||
<?php
|
||||
if($reposicion["horario_grupo"]!="")
|
||||
echo "(".$reposicion["horario_grupo"].")";
|
||||
?>
|
||||
</small>
|
||||
</td>
|
||||
<td class="text-center align-middle text-nowrap"><?php
|
||||
$fechaI = date("d/m/Y", strtotime($reposicion["fecha_clase"]));
|
||||
echo $fechaI."<br>".substr($reposicion["horario_hora"],0, 5);
|
||||
if($reposicion["fecha_falta"]!=""){
|
||||
$fechaI = date("d/m/Y", strtotime($reposicion["fecha_falta"]));
|
||||
echo $fechaI."<br>".substr($reposicion["hora_original"],0, 5);
|
||||
}else{
|
||||
echo " - ";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td class="text-center align-middle text-nowrap"><?php
|
||||
@@ -295,24 +351,24 @@ if($user->periodo_id!= ""){
|
||||
<td class="text-center align-middle icono-acciones text-nowrap">
|
||||
<?php if (duracionMinutos($reposicion["fecha_nueva"], date("Y-m-d H:i:00")) < 0){ ?>
|
||||
<?php //no se cumple la fecha de la reposicion, es jefe de carrera
|
||||
if((!$user->jefe_carrera || $user->admin || !$coordinador) && $reposicion["estado_reposicion_id"] == 1){?>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_aprobar" data-tipo="2" title="Aprobar"><?php echo $ICO["ver"];?></a>
|
||||
if((!$user->jefe_carrera || $user->admin || !$coordinador) && $reposicion["estado"] == 1){?>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_aprobar" data-estado="2" data-tipo="<?php echo $reposicion["tipo"];?>" title="Aprobar"><?php echo $ICO["ver"];?></a>
|
||||
<?php } //no se cumple la fecha de la reposicion, no es jefe de carrera
|
||||
else if(($supervisor || $user->admin) && $reposicion["estado_reposicion_id"] == 2){?>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_aprobar" data-tipo="3" title="Autorizar" ><?php echo $ICO["ver"];?></a>
|
||||
else if(($supervisor || $user->admin) && $reposicion["estado"] == 2){?>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_aprobar" data-estado="3" data-tipo="<?php echo $reposicion["tipo"];?>" title="Autorizar" ><?php echo $ICO["ver"];?></a>
|
||||
<?php } else { ?>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_aprobar" data-tipo="1" title="Ver detalle"><?php echo $ICO["ver"];?></a>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_aprobar" data-estado="1" data-tipo="<?php echo $reposicion["tipo"];?>" title="Ver detalle"><?php echo $ICO["ver"];?></a>
|
||||
<?php } ?>
|
||||
<?php
|
||||
}else{ //fecha ya pasó?>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_aprobar" data-tipo="1" title="Ver detalle"><span class="text-danger"><?php echo $ICO["ver"];?></span></a>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_aprobar" data-estado="1" data-tipo="<?php echo $reposicion["tipo"];?>" title="Ver detalle"><span class="text-danger"><?php echo $ICO["ver"];?></span></a>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if($reposicion["estado_reposicion_id"]<4){
|
||||
if($reposicion["estado"]<4){
|
||||
if(
|
||||
(($user->jefe_carrera || $user->admin || $coordinador) && $reposicion["estado_reposicion_id"] == 1)/* nueva */
|
||||
|| (($user->admin || $coordinador || $supervisor) && $reposicion["estado_reposicion_id"] == 2)/* aprobado facultad */
|
||||
(($user->jefe_carrera || $user->admin || $coordinador) && $reposicion["estado"] == 1)/* nueva */
|
||||
|| (($user->admin || $coordinador || $supervisor) && $reposicion["estado"] == 2)/* aprobado facultad */
|
||||
){
|
||||
?>
|
||||
<a href="#" data-toggle="modal" data-target="#modal_confirm" title="Cancelar"><span class="text-danger"><?php echo $ICO["cancelar"];?></span></a>
|
||||
@@ -348,6 +404,7 @@ if($user->periodo_id!= ""){
|
||||
<form action="./action/reposicion_autoriza.php" method="post" id="formaModal">
|
||||
<input type="hidden" name="id" id="id">
|
||||
<input type="hidden" name="edo" id="edo" value="">
|
||||
<input type="hidden" name="tipo" id="tipo" value="">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6 col-sm-4 barra-right text-right">
|
||||
@@ -365,6 +422,14 @@ if($user->periodo_id!= ""){
|
||||
<p class="rep-fac"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 col-sm-4 barra-right text-right">
|
||||
<p class="font-weight-bold">Carrera</p>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<p class="rep-carr"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 col-sm-4 barra-right text-right">
|
||||
<p class="font-weight-bold">Materia</p>
|
||||
@@ -373,6 +438,14 @@ if($user->periodo_id!= ""){
|
||||
<p class="rep-mat"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 col-sm-4 barra-right text-right">
|
||||
<p class="font-weight-bold">Grupo</p>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<p class="rep-gpo"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 col-sm-4 barra-right text-right">
|
||||
<p class="font-weight-bold">Ciclo y bloque</p>
|
||||
@@ -467,6 +540,15 @@ if($user->periodo_id!= ""){
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="supervisor" style="display: none;">
|
||||
<div class="col-6 col-sm-4 barra-right text-right">
|
||||
<p class="font-weight-bold">Supervisor</p>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<p class="rep-sup"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-6 col-sm-4 barra-right text-right">
|
||||
@@ -486,7 +568,7 @@ if($user->periodo_id!= ""){
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mt-3">
|
||||
<div class="form-group row mt-3" id="submitGroup">
|
||||
<div class="col-12 text-center">
|
||||
|
||||
<p class="aprobar-block">Una vez realizada la acción no se puede deshacer.</p>
|
||||
@@ -497,6 +579,13 @@ if($user->periodo_id!= ""){
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mt-3" id="loadingGroup" style="display:none">
|
||||
<div class="col-12 text-center">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -629,13 +718,18 @@ if($user->periodo_id!= ""){
|
||||
$('#modal_aprobar').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||
var id = button.parents("tr").data("id");
|
||||
var edo = button.data('tipo');
|
||||
var edo = button.data('estado');
|
||||
var tipo = button.data('tipo');
|
||||
$("#loadingGroup").hide();
|
||||
$("#submitGroup").show();
|
||||
|
||||
//1 ver, 2 aprobar, 3 autorizar
|
||||
$("#edo").val(edo);
|
||||
$("#id").val(id);
|
||||
$("#tipo").val(tipo);
|
||||
|
||||
|
||||
var action_pag;
|
||||
if(tipo == 1 || tipo == 2){
|
||||
$.ajax({
|
||||
url: './action/reposicion_select.php',
|
||||
type: 'POST',
|
||||
@@ -649,7 +743,13 @@ if($user->periodo_id!= ""){
|
||||
$("#dlSalon").val("");
|
||||
$("#modal_aprobar .rep-prof").text(result["profesor_nombre"]);
|
||||
$("#modal_aprobar .rep-fac").text(result["facultad"]);
|
||||
$("#modal_aprobar .rep-carr").parents(".row").show();
|
||||
$("#modal_aprobar .rep-carr").text(result["carrera"]);
|
||||
$("#modal_aprobar .rep-gpo").parents(".row").show();
|
||||
$("#modal_aprobar .rep-gpo").text(result["grupo"]);
|
||||
$("#modal_aprobar .rep-mat").parents(".row").show();
|
||||
$("#modal_aprobar .rep-mat").text(result["materia_desc"]);
|
||||
$("#modal_aprobar .rep-ciclo").parents(".row").show();
|
||||
$("#modal_aprobar .rep-ciclo").text(result["ciclo"]);
|
||||
$("#modal_aprobar .rep-bloque").text(result["bloque"]);
|
||||
if(result["tipo"])
|
||||
@@ -658,6 +758,7 @@ if($user->periodo_id!= ""){
|
||||
$("#modal_aprobar .rep-tipo").text("Cambio");
|
||||
$("#modal_aprobar .rep-aula").text(result["aula_desc"])
|
||||
$("#modal_aprobar .rep-aula").data("aula",result["aula"]);
|
||||
$("#modal_aprobar .rep-falta").parents(".row").show();
|
||||
$("#modal_aprobar .rep-falta").text(result["fecha_clase"]);
|
||||
$("#modal_aprobar .rep-fecha").text(result["fecha_nueva"]+" de "+result["hora_ini"]+":"+result["min_ini"]+" a "+result["hora_fin"]+":"+result["min_fin"]);
|
||||
if(result["salon"] =="" || result["salon"] === undefined){
|
||||
@@ -669,6 +770,13 @@ if($user->periodo_id!= ""){
|
||||
$("#modal_aprobar .rep-comentarios").text(result["comentario"]);
|
||||
$('#modal_aprobar .rep-alumnos').text(result["alumnos"]);
|
||||
|
||||
if(result["supervisor_nombre"]!=""){
|
||||
$("#supervisor").show();
|
||||
$("#modal_aprobar .rep-sup").text(result["supervisor_nombre"]);
|
||||
}else{
|
||||
$("#supervisor").hide();
|
||||
}
|
||||
|
||||
if(result["estado"] == 4){//cancelada
|
||||
$('#modal_aprobar .rep-motivo').text(result["motivo_cancelacion"]);
|
||||
$("#cancelada-block").show();
|
||||
@@ -726,6 +834,108 @@ if($user->periodo_id!= ""){
|
||||
triggerMessage(errorThrown, "Error");
|
||||
}
|
||||
});//ajax
|
||||
}else{
|
||||
|
||||
$.ajax({
|
||||
url: './action/asignacion_select.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { id: id},
|
||||
success: function(result) {
|
||||
if(result["error"]!= "" && result["error"] !== undefined){
|
||||
triggerMessage(result["error"], "Error");
|
||||
$('#modal_aprobar').modal("hide");
|
||||
}else{
|
||||
$("#dlSalon").val("");
|
||||
$("#modal_aprobar .rep-prof").text(result["profesor_nombre"]);
|
||||
$("#modal_aprobar .rep-fac").text(result["facultad"]);
|
||||
$("#modal_aprobar .rep-carr").parents(".row").hide();
|
||||
$("#modal_aprobar .rep-gpo").parents(".row").hide();
|
||||
$("#modal_aprobar .rep-mat").parents(".row").hide();
|
||||
$("#modal_aprobar .rep-ciclo").parents(".row").hide();
|
||||
|
||||
$("#modal_aprobar .rep-tipo").text("Asignación");
|
||||
|
||||
$("#modal_aprobar .rep-aula").text(result["aula_desc"])
|
||||
$("#modal_aprobar .rep-aula").data("aula",result["aula"]);
|
||||
$("#modal_aprobar .rep-falta").parents(".row").hide();
|
||||
$("#modal_aprobar .rep-fecha").text(result["fecha_nueva"]+" de "+result["hora_ini"]+":"+result["min_ini"]+" a "+result["hora_fin"]+":"+result["min_fin"]);
|
||||
if(result["salon"] =="" || result["salon"] === undefined){
|
||||
$('#salon').prop("selectedIndex", 0);
|
||||
}else{
|
||||
$('#salon').val(result["salon"]);
|
||||
}
|
||||
$("#modal_aprobar .rep-salon").text(result["salon_desc"]);
|
||||
$("#modal_aprobar .rep-comentarios").text(result["comentario"]);
|
||||
$('#modal_aprobar .rep-alumnos').text(result["alumnos"]);
|
||||
|
||||
if(result["supervisor_nombre"]!=""){
|
||||
$("#supervisor").show();
|
||||
$("#modal_aprobar .rep-sup").text(result["supervisor_nombre"]);
|
||||
}else{
|
||||
$("#supervisor").hide();
|
||||
}
|
||||
|
||||
if(result["estado"] == 4){//cancelada
|
||||
$('#modal_aprobar .rep-motivo').text(result["motivo_cancelacion"]);
|
||||
$("#cancelada-block").show();
|
||||
}else{
|
||||
$("#cancelada-block").hide();
|
||||
}
|
||||
|
||||
if(edo == 1){// 1 ver
|
||||
$("#modalLabel").text("Detalle de reposición");
|
||||
$(".aprobar-block").hide();
|
||||
|
||||
/*if(parseInt($("#modal_aprobar .rep-aula").data("aula")) != 1){//tipo aula 1 (salon normal) - ver
|
||||
$("#salon-ver").hide();
|
||||
$("#salon-editar").show();
|
||||
}else{
|
||||
$("#salon-ver").show();
|
||||
$("#salon-editar").hide();
|
||||
}*/
|
||||
$("#salon-ver").show();
|
||||
$("#salon-editar").hide();
|
||||
|
||||
}else{
|
||||
$("#modalLabel").text("Aprobar reposición");
|
||||
$(".aprobar-block").show();
|
||||
|
||||
if(edo == 2 && parseInt($("#modal_aprobar .rep-aula").data("aula")) == 1){//tipo aula 1 (salon normal) - ver
|
||||
$("#salon-ver").show();
|
||||
$("#salon-editar").hide();
|
||||
}else if(edo == 3 && parseInt($("#modal_aprobar .rep-aula").data("aula")) != 1){//aprobar (con salón especial)
|
||||
$("#salon-ver").show();
|
||||
$("#salon-editar").hide();
|
||||
}else{
|
||||
$("#salon-ver").hide();
|
||||
$("#salon-editar").show();
|
||||
}
|
||||
}
|
||||
|
||||
if(result["aula_supervisor"]){//Solo supervisor
|
||||
<?php if($supervisor){ ?>
|
||||
$("#salon-editar").attr("disabled", false);
|
||||
<?php }else{?>
|
||||
$("#salon-editar").attr("disabled", true);
|
||||
<?php } ?>
|
||||
}else{// Facultad
|
||||
<?php if(!$supervisor){ ?>
|
||||
$("#salon-editar").attr("disabled", false);
|
||||
<?php }else{?>
|
||||
$("#salon-editar").attr("disabled", true);
|
||||
<?php } ?>
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown ){
|
||||
triggerMessage(errorThrown, "Error");
|
||||
}
|
||||
});//ajax
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
/*
|
||||
$(".btn-borrar").click(function(){
|
||||
@@ -760,6 +970,8 @@ if($user->periodo_id!= ""){
|
||||
var edo = parseInt($("#edo").val());
|
||||
console.log(edo)
|
||||
if((edo == 3 && valida()) || edo == 2){
|
||||
$("#loadingGroup").show();
|
||||
$("#submitGroup").hide();
|
||||
$("#formaModal").submit();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -59,13 +59,14 @@ if(!is_null($user->periodo_id)){
|
||||
if(strtotime($periodo_rs["periodo_fecha_inicio"])>strtotime(date("Y-m-d")) )
|
||||
$fecha_man = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"]));
|
||||
else{
|
||||
$dias = 3;
|
||||
if( intval(date("w")) >=3 && intval(date("w"))<=5 )//Mie a Vie
|
||||
$dias+=3;
|
||||
else if( intval(date("w")) ==6 )//Sab
|
||||
$dias+=2;
|
||||
else if( intval(date("w")) ==0 )//Do
|
||||
$dias+=1;
|
||||
$dia_actual = intval(date("w"));
|
||||
$dias = 2;//días mínimos Lun a Jue
|
||||
if($dia_actual ==5 || $dia_actual ==4 )//Vie
|
||||
$dias=4;
|
||||
else if( $dia_actual ==6 )//Sab
|
||||
$dias=3;
|
||||
else if( $dia_actual ==0 )//Do
|
||||
$dias=2;
|
||||
|
||||
$fecha_man = date("d/m/Y", strtotime("+".$dias." day"));
|
||||
}
|
||||
@@ -363,7 +364,7 @@ if(!is_null($user->periodo_id)){
|
||||
<label for="fecha_inicial" class="col-4 col-form-label">Fecha de reposicion *</label>
|
||||
<div class="col-8">
|
||||
<input id="fecha_inicial" name="fecha_inicial" type="text" class="form-control date-picker-future" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="readonly" value="">
|
||||
<small class="form-text text-muted">Las reposiciones se deben solicitar con al menos 72hrs de anticipación.<br>
|
||||
<small class="form-text text-muted">Las reposiciones se deben solicitar con al menos 48hrs de anticipación.<br>
|
||||
Recuerda que en sábado el límite para terminar la clase es a las 15:00hrs.
|
||||
</small>
|
||||
</div>
|
||||
@@ -406,9 +407,11 @@ if(!is_null($user->periodo_id)){
|
||||
<div class="datalist-input">Salón</div>
|
||||
<span class="ing-buscar icono"></span>
|
||||
<ul style="display:none">
|
||||
<li data-id="1">Salón</li>
|
||||
<li data-id="2">Sala de cómputo</li>
|
||||
<li data-id="3">Salón/Taller de la facultad</li>
|
||||
<?php
|
||||
$tipoaula_rs = $db->query('select * from tipoaula t order by t.tipoaula_id ');
|
||||
foreach($tipoaula_rs as $ta){ ?>
|
||||
<li data-id="<?php echo $ta["tipoaula_id"];?>"><?php echo $ta["tipoaula_nombre"];?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<input type="hidden" id="aula" name="aula" value="1">
|
||||
</div>
|
||||
@@ -459,12 +462,19 @@ if(!is_null($user->periodo_id)){
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mt-3">
|
||||
<div class="form-group row mt-3" id="submitGroup">
|
||||
<div class="offset-4 col-8">
|
||||
<button type="submit" class="btn btn-outline-primary materia-block" id="submitBtn" data-tipo="1"><?php echo $ICO["aceptar"];?> Guardar</button>
|
||||
<button type="reset" class="btn btn-outline-danger" data-dismiss="modal"><?php echo $ICO["cancelar"];?> Cancelar</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mt-3" id="loadingGroup" style="display:none">
|
||||
<div class="col-12 text-center">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -759,6 +769,10 @@ if(!is_null($user->periodo_id)){
|
||||
}else{
|
||||
$('#formaModal').prop("action", "./action/reposicion_insert.php");
|
||||
}
|
||||
if(!error){
|
||||
$("#loadingGroup").show();
|
||||
$("#submitGroup").hide();
|
||||
}
|
||||
return !error;
|
||||
}
|
||||
|
||||
@@ -946,6 +960,9 @@ if(!is_null($user->periodo_id)){
|
||||
var tipo = button.data('tipo'); // 1 alta, 2 edicion
|
||||
var modal = $(this);
|
||||
|
||||
$("#loadingGroup").hide();
|
||||
$("#submitGroup").show();
|
||||
|
||||
$("#modal .is-invalid").removeClass("is-invalid");
|
||||
//$(this).find(".form-control:first-child").focus();
|
||||
|
||||
@@ -1050,7 +1067,7 @@ if(!is_null($user->periodo_id)){
|
||||
})
|
||||
</script>
|
||||
<script src="js/messages.js"></script>
|
||||
<script type="module" src="js/reposiciones.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
57
rest/LogCambios.php
Normal file
57
rest/LogCambios.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Objeto para escribir los cambios
|
||||
*/
|
||||
|
||||
class LogCambios {
|
||||
//put your code here
|
||||
private $file, $month, $year;
|
||||
private $dir;
|
||||
|
||||
function __construct($ruta = "/log/"){
|
||||
$this->month = date("m");
|
||||
$this->year = date("Y");
|
||||
//$this->dir = $_SERVER['DOCUMENT_ROOT'].$ruta;
|
||||
$this->dir = $ruta;
|
||||
$this->updateFilename();
|
||||
}
|
||||
|
||||
function setMes($mes){
|
||||
$this->month = $mes;
|
||||
$this->updateFilename();
|
||||
}
|
||||
function setAno($ano){
|
||||
$this->year = $ano;
|
||||
$this->updateFilename();
|
||||
}
|
||||
private function updateFilename(){
|
||||
$this->file = "cambios_".$this->year."_".$this->month.".log";
|
||||
}
|
||||
|
||||
private function cleanLog($text){//remueve || de los textos para no afectar estructura
|
||||
return trim(str_ireplace( "||" , "" , $text));
|
||||
}
|
||||
|
||||
function appendLog($desc){
|
||||
$filename = $this->dir.$this->file;
|
||||
/*
|
||||
if (file_exists($this->dir)){
|
||||
$data = date('Y-m-d H:i:s')."||".$this->cleanLog($desc)."\n";
|
||||
//echo $filename;
|
||||
$res = file_put_contents($filename, $data, FILE_APPEND);
|
||||
//echo " result: $res<br>";
|
||||
}*/
|
||||
}
|
||||
/*
|
||||
function getLog($mes ="", $ano = ""){
|
||||
if($mes != "") $this->setMes($mes);
|
||||
if($ano != "") $this->setAno($ano);
|
||||
$filename = $this->dir.$this->file;
|
||||
if (file_exists($filename)){
|
||||
return file ($filename , FILE_SKIP_EMPTY_LINES);
|
||||
}else{
|
||||
return array();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
430
rest/horarios.php
Normal file
430
rest/horarios.php
Normal file
@@ -0,0 +1,430 @@
|
||||
<?php
|
||||
/*
|
||||
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
claveFacultad: clave de la facultad a consultar (opcional, cadena)
|
||||
claveCarrera: clave de la carrera a consultar (opcional, cadena)
|
||||
claveProfesor: clave del empleado a consultar (opcional, cadena)
|
||||
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
|
||||
*/
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('post_max_size', 1);
|
||||
ini_set('max_execution_time', 8*60);
|
||||
error_reporting(E_ALL);
|
||||
date_default_timezone_set('America/Mexico_City');
|
||||
|
||||
$ruta = "../";
|
||||
$ruta_superior = dirname(__DIR__);
|
||||
require_once $ruta_superior."/include/bd_pdo_rest.php";
|
||||
require_once __DIR__."/token.php";
|
||||
require_once __DIR__."/LogCambios.php";
|
||||
|
||||
//--------------ACTUALIZA HORARIOS--------------------------
|
||||
if(!empty($_GET["fecha"])){
|
||||
$hoy = $_GET["fecha"];
|
||||
}else{
|
||||
$hoy = date("Y-m-d");
|
||||
}
|
||||
$dia_hoy = date("w", strtotime($hoy));
|
||||
|
||||
|
||||
function compareByHash($a, $b) {
|
||||
return strcmp($a['hash'], $b['hash']);
|
||||
}
|
||||
|
||||
|
||||
$debug = false;
|
||||
if(isset($_GET["debug"])){
|
||||
$debug = true;
|
||||
print_r( $db->querySingle('select now()'));
|
||||
}
|
||||
$periodo_sgu_old = 0;
|
||||
$log_desc = "";
|
||||
|
||||
|
||||
/*$cambiocarreras_rs = $db->query('SELECT CLAVE_MATERIA, clave_carrera FROM materia join carrera using(carrera_id)');
|
||||
|
||||
function getCarrera($claveBuscar){
|
||||
global $cambiocarreras_rs;
|
||||
$i = array_search($claveBuscar, array_column($cambiocarreras_rs, 'clave_materia'));
|
||||
if($i>=0)
|
||||
return $cambiocarreras_rs[$i]["clave_carrera"];
|
||||
return $cambiocarreras_rs[0]["clave_carrera"];
|
||||
}*/
|
||||
|
||||
//------------------ACTUALIZA SALONES----------------------
|
||||
|
||||
$pag = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/espacios/seleccionar";
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $pag,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
//CURLOPT_ENCODING => "",
|
||||
//CURLOPT_MAXREDIRS => 10,
|
||||
// CURLOPT_TIMEOUT => 0,
|
||||
//CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode([]),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: ".$token,
|
||||
"username: SGU_APSA_AUD_ASIST",
|
||||
"Content-Type: application/json",
|
||||
'Transfer-Encoding: chunked'
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
$salonesData = json_decode($response, true);
|
||||
|
||||
//$salonesTotal_rs = $db->count('salon');
|
||||
$salonesTotal_rs = $db->where('salon_id', 0, '>')->count('salon');
|
||||
echo "$salonesTotal_rs tiene " . count($salonesData) . " salones<br>";
|
||||
//if($salonesTotal_rs < count($salonesData)){//faltan salones en BD
|
||||
$salones_rs = $db->query('SELECT id_espacio_sgu, salon FROM salon');
|
||||
//claves de espacios
|
||||
$arreglo_espacios = array_map(function ($item) {
|
||||
return $item['id_espacio_sgu'];
|
||||
}, $salones_rs);
|
||||
$arreglo_nombres = array_map(function ($item) {
|
||||
return $item['salon'];
|
||||
}, $salones_rs);
|
||||
|
||||
foreach($salonesData as $data){
|
||||
if( !in_array($data["IdEspacio"], $arreglo_espacios) || !in_array($data["NombreEspacio"], $arreglo_nombres)){
|
||||
//Insertar espacio
|
||||
if($debug){
|
||||
echo "Espacio nuevo: ".$data["NombreEspacio"]."<br>";
|
||||
}else{
|
||||
$db->query('INSERT INTO SALON (salon, id_espacio_sgu, id_espacio_padre) VALUES (:salon, :id, :id_padre)
|
||||
ON CONFLICT (id_espacio_sgu) DO UPDATE SET salon = :salon',
|
||||
[":salon"=>$data["NombreEspacio"], ":id"=>$data["IdEspacio"], ":id_padre"=>$data["IdEspacioPadre"]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
// -----------------------------
|
||||
|
||||
$pag = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/seleccionar";
|
||||
$elementos_bd_total = [];
|
||||
$elementos_sgu_total = [];
|
||||
$periodo_sgu_old = 0;
|
||||
try{
|
||||
$pdo->beginTransaction();
|
||||
|
||||
|
||||
$periodos_rs = $db->query('SELECT periodo_id, id_periodo_sgu, nivel_id FROM periodo WHERE :hoy BETWEEN periodo_fecha_inicio AND periodo_fecha_fin AND id_periodo_sgu != 0 ORDER BY periodo_id',
|
||||
[":hoy"=>$hoy]);
|
||||
foreach ($periodos_rs as $per){
|
||||
|
||||
//Verifica si el día de hoy es festivo
|
||||
$vacacion_rs = $db->querySingle('select es_festivo(:per, :hoy)', [":per"=>$per["periodo_id"], ":hoy"=>$hoy]);
|
||||
if($vacacion_rs["es_festivo"]){
|
||||
if($debug){
|
||||
echo "<h3>Dia festivo en Periodo: ".$per["id_periodo_sgu"]."[".$per["periodo_id"]."]</h3>";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$carreras_rs = $db->query('SELECT c.clave_carrera, c.carrera_id FROM carrera c WHERE nivel_id = :nivel',
|
||||
[":nivel"=>$per["nivel_id"]]);
|
||||
if($debug){
|
||||
echo "<h3>Periodo: ".$per["id_periodo_sgu"]."[".$per["periodo_id"]."] nivel: ".$per["nivel_id"]."</h3>";
|
||||
//print_r($carreras_rs);
|
||||
}
|
||||
if ($periodo_sgu_old != $per["id_periodo_sgu"]){
|
||||
$periodo_sgu_old = $per["id_periodo_sgu"];
|
||||
$params = [
|
||||
'idPeriodo'=>$per["id_periodo_sgu"],
|
||||
'fecha'=>$hoy
|
||||
];
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $pag,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
//CURLOPT_ENCODING => "",
|
||||
//CURLOPT_MAXREDIRS => 10,
|
||||
//CURLOPT_TIMEOUT => 0,
|
||||
//CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($params),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: ".$token,
|
||||
"username: SGU_APSA_AUD_ASIST",
|
||||
"Content-Type: application/json"
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
/*echo "Response<br>";
|
||||
print_r($response);*/
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
}
|
||||
$selectedData = json_decode($response, true);
|
||||
|
||||
//claves de carreras en el periodo
|
||||
$arreglo_claves = array_map(function ($item) {
|
||||
return $item['clave_carrera'];
|
||||
}, $carreras_rs);
|
||||
|
||||
//print_r($selectedData); exit();
|
||||
$sguHash = array();
|
||||
if(!empty($selectedData)){
|
||||
|
||||
//Recorre SGU y genera hash
|
||||
foreach( $selectedData as $row ){
|
||||
if(!$row["EsMateriaPorReposicion"]){
|
||||
$carrera = $row["ClaveCarrera"];
|
||||
if(is_null($carrera) || empty($carrera))
|
||||
$carrera = '0';
|
||||
/*else{
|
||||
if(!$row["EsMateriaPorAsignacion"])
|
||||
$carrera = getCarrera($row["ClaveMateria"]);
|
||||
}*/
|
||||
|
||||
$sguHash[] = array(
|
||||
"hash"=>( trim($row["HoraInicio"]."|".($row["NombreMateria"])."|".(trim($row["ClaveProfesor"])==""?"000000":trim($row["ClaveProfesor"]))."|".$row["IdEspacio"]."|".$per["periodo_id"]) ),
|
||||
"data"=>$row,
|
||||
"per"=>$per["periodo_id"]
|
||||
);
|
||||
}else{//reposición
|
||||
try{
|
||||
if(in_array($row["ClaveCarrera"] , $arreglo_claves)){
|
||||
//busca yyyy-mm-dd hh:mm:ss en la cadena
|
||||
if (preg_match("/\d{4}-\d{2}-\d{2} de \d{2}:\d{2}:\d{2}/", $row["Observaciones"], $matches)) {
|
||||
$fecha_orig = str_replace(" de", "", $matches[0]);
|
||||
$fecha_nueva = $row["FechaStr"]." ".$row["HoraInicio"];
|
||||
$hora_fin_nueva = $row["HoraFin"];
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fi_reposicion_sgu('$fecha_orig', '".$hora_fin_nueva."','".$fecha_nueva."' ,'".$row["ClaveProfesor"]."', ".$per["periodo_id"].", ".$row["IdEspacio"].")";
|
||||
}else{
|
||||
$db->query('SELECT * FROM fi_reposicion_sgu(:fecha_orig, :hora_fin, :fecha_rep, :prof, :per, :salon)',
|
||||
[":fecha_orig"=>$fecha_orig, ":hora_fin"=>$hora_fin_nueva, ":fecha_rep"=>$fecha_nueva, ":prof"=>$row["ClaveProfesor"], ":per"=>$per["periodo_id"], ":salon"=>$row["IdEspacio"] ]);
|
||||
$log_desc .="SELECT * FROM fi_reposicion_sgu($fecha_orig, ".$fecha_nueva.", ".$row["ClaveProfesor"].", ".$per["periodo_id"].") ## ";
|
||||
}
|
||||
}else{
|
||||
if($debug)
|
||||
echo "No se encontró fecha y hora en: ".$row["Observaciones"]."<br>";
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
echo "ERROR Reposición<br>".$e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($selectedData);
|
||||
}
|
||||
|
||||
echo count($sguHash)."Total <br>";
|
||||
|
||||
$horarios_sgu = [];
|
||||
|
||||
/*
|
||||
print_r($carreras_rs);
|
||||
echo "<br><hr><br>";*/
|
||||
print_r($arreglo_claves);
|
||||
echo "<br><hr><br>";
|
||||
|
||||
//$areacomun = array();
|
||||
foreach($sguHash as $sgu){
|
||||
if(in_array($sgu["data"]["ClaveCarrera"] , $arreglo_claves) /*&& !in_array($sgu["data"]["ClaveMateria"], $areacomun)*/){
|
||||
$horarios_sgu[] = $sgu;
|
||||
}
|
||||
}
|
||||
|
||||
//print_r($horarios_sgu);exit();
|
||||
unset($sguHash);
|
||||
$elementos_sgu_total = array_merge($elementos_sgu_total, $horarios_sgu);
|
||||
|
||||
//Recorre BD y genera hash
|
||||
$horarios_rs = $db->query('SELECT * FROM fs_horarios_hash(:dia, :periodo, :fecha)',
|
||||
[':dia' => $dia_hoy, ':periodo' => $per["periodo_id"], ':fecha'=>$hoy]);
|
||||
//echo "**** SELECT * FROM fs_horarios_hash($dia_hoy, ".$per["periodo_id"].")<br>";
|
||||
|
||||
//usort($horarios_rs, 'compareByHash');
|
||||
$elementos_bd_total = array_merge($elementos_bd_total, $horarios_rs);
|
||||
|
||||
}//foreach periodo
|
||||
//print_r($elementos_sgu_total);
|
||||
//exit();
|
||||
if($debug){
|
||||
echo "<h3>Resumen</h3>";
|
||||
echo "<h5>SGU [".count($elementos_sgu_total)."]</h5>";
|
||||
echo "<h5>BD [".count($elementos_bd_total)."]</h5>";
|
||||
}
|
||||
// Extraer los "hash" de $lista y $lista2 en arreglos separados
|
||||
$hashes_sgu = array_column($elementos_sgu_total, 'hash');
|
||||
$hashes_bd = array_column($elementos_bd_total, 'hash');
|
||||
|
||||
|
||||
//print_r($elementos_sgu_total);
|
||||
|
||||
//------------------
|
||||
// Encontrar los "hash" que están en $sgu pero no están en $bd
|
||||
$hashes_no_en_sgu = array_diff($hashes_bd, $hashes_sgu);
|
||||
if($debug) echo "hashes_no_en_sgu ".count($hashes_no_en_sgu)."<br>";
|
||||
|
||||
if(count($hashes_no_en_sgu)>0){
|
||||
// Ahora puedes obtener los elementos completos que cumplen la condición original
|
||||
$elementos_no_en_sgu = array_filter($elementos_bd_total, function ($item) use ($hashes_no_en_sgu) {
|
||||
return in_array($item['hash'], $hashes_no_en_sgu);
|
||||
});
|
||||
if($debug){
|
||||
print_r($elementos_no_en_sgu);
|
||||
echo "Sobran ".count($elementos_no_en_sgu)." en BD<br>";
|
||||
}
|
||||
|
||||
//Update fecha_fin
|
||||
$log_desc = "";
|
||||
foreach($elementos_no_en_sgu as $row){
|
||||
try{
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fu_horario_deshabilita(".$row["horario_id"].");";
|
||||
}else{
|
||||
$db->query('SELECT * FROM fu_horario_deshabilita(:horario)', [":horario"=>$row["horario_id"]]);
|
||||
$log_desc .="SELECT * FROM fu_horario_deshabilita(".$row["horario_id"].") ## ";
|
||||
}
|
||||
}catch(Exception $e){
|
||||
echo "ERROR horario deshabilita<br>".$e->getMessage();
|
||||
}
|
||||
}
|
||||
if(!$debug && !empty($log_desc)){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog($log_desc);
|
||||
}
|
||||
}
|
||||
|
||||
// Encontrar los "hash" que están en $sgu pero no están en $bd
|
||||
$hashes_no_en_bd = array_diff($hashes_sgu, $hashes_bd);
|
||||
|
||||
//echo "hashes_no_en_bd ".count($hashes_no_en_bd)."<br>";
|
||||
|
||||
|
||||
if(count($hashes_no_en_bd)>0){
|
||||
// Ahora puedes obtener los elementos completos que cumplen la condición original
|
||||
$elementos_no_en_bd = array_filter($elementos_sgu_total, function ($item) use ($hashes_no_en_bd) {
|
||||
return in_array($item['hash'], $hashes_no_en_bd);
|
||||
});
|
||||
if($debug){
|
||||
echo "<br>Faltan ".count($elementos_no_en_bd)." en BD<br>";
|
||||
print_r($elementos_no_en_bd); echo "<br>";
|
||||
}
|
||||
|
||||
|
||||
//Inserts
|
||||
foreach($elementos_no_en_bd as $row){
|
||||
if($row["data"]["ClaveMateria"] == "-")
|
||||
$row["data"]["ClaveMateria"] = "";
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fi_horario($dia_hoy, '".$row["data"]["HoraInicio"]."','".$row["data"]["HoraFin"]."','"
|
||||
.$row["data"]["ClaveDependencia"]."','"
|
||||
.$row["data"]["ClaveCarrera"]."','"
|
||||
.$row["data"]["NombreMateria"]."','"
|
||||
.$row["data"]["ClaveMateria"]."','"
|
||||
.$row["data"]["ClaveProfesor"]."','"
|
||||
.$row["data"]["NombreProfesor"]."','"
|
||||
.$row["data"]["CorreoElectronico"]."','"
|
||||
.$row["data"]["Grupo"]."',"
|
||||
.$row["data"]["IdEspacio"].","
|
||||
.$row["per"].");";
|
||||
if($row["data"]["EsMateriaPorAsignacion"]){ echo " ***Asignacion directa***";}
|
||||
}else{
|
||||
$horario_new_rs = $db->querySingle('SELECT * FROM fi_horario(:hoy, :ini, :fin, :dep, :carr, :nom_mat, :cve_mat, :cve_prof, :nom_prof, :correo, :gpo, :espacio, :periodo)',
|
||||
[":hoy"=>$dia_hoy,
|
||||
":ini"=>$row["data"]["HoraInicio"],
|
||||
":fin"=>$row["data"]["HoraFin"],
|
||||
":dep"=>$row["data"]["ClaveDependencia"],
|
||||
":carr"=>$row["data"]["ClaveCarrera"],
|
||||
":nom_mat"=>$row["data"]["NombreMateria"],
|
||||
":cve_mat"=>$row["data"]["ClaveMateria"],
|
||||
":cve_prof"=>$row["data"]["ClaveProfesor"]==""?"000000":$row["data"]["ClaveProfesor"],
|
||||
":nom_prof"=>$row["data"]["NombreProfesor"],
|
||||
":correo"=>$row["data"]["CorreoElectronico"],
|
||||
":gpo"=>$row["data"]["Grupo"],
|
||||
":espacio"=>$row["data"]["IdEspacio"],
|
||||
":periodo"=>$row["per"]
|
||||
]
|
||||
);
|
||||
//echo $horario_new_rs["fi_horario"]."<br>";
|
||||
if($horario_new_rs["fi_horario"] > 0){
|
||||
if($row["data"]["EsMateriaPorAsignacion"]){
|
||||
$matasig_rs = $db->querySingle('SELECT * FROM fi_materia_asignacion(:hor,:mat,:carr, :prof)',
|
||||
[":hor"=>$horario_new_rs["fi_horario"],
|
||||
":mat"=>$row["data"]["NombreMateria"],
|
||||
":carr"=>$row["data"]["Carrera"],
|
||||
":prof"=>$row["data"]["NombreProfesor"]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$log_desc .="SELECT * FROM fi_horario($dia_hoy, '".$row["data"]["HoraInicio"]."','".$row["data"]["HoraFin"]."','"
|
||||
.$row["data"]["ClaveDependencia"]."','"
|
||||
.$row["data"]["ClaveCarrera"]."','"
|
||||
.$row["data"]["NombreMateria"]."','"
|
||||
.$row["data"]["ClaveMateria"]."','"
|
||||
.$row["data"]["ClaveProfesor"]."','"
|
||||
.$row["data"]["NombreProfesor"]."','"
|
||||
.$row["data"]["CorreoElectronico"]."','"
|
||||
.$row["data"]["Grupo"]."',"
|
||||
.$row["data"]["IdEspacio"]."); [ID=".$horario_new_rs["fi_horario"]."] ##";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(!$debug && !empty($log_desc)){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog($log_desc);
|
||||
}
|
||||
|
||||
}
|
||||
$stmt = null; // cierra conexion
|
||||
|
||||
if($debug) {
|
||||
echo "<br><br><hr><br><br>";
|
||||
usort($elementos_sgu_total, 'compareByHash');
|
||||
usort($elementos_bd_total, 'compareByHash');
|
||||
|
||||
echo "<table><tr>";
|
||||
echo "<td valign='top'>";
|
||||
echo "<h5>SGU [".count($elementos_sgu_total)."]</h5>";
|
||||
foreach($elementos_sgu_total as $sgu){
|
||||
echo $sgu["hash"]."<br>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td valign='top'>";
|
||||
echo "<h5>BD [".count($elementos_bd_total)."]</h5>";
|
||||
foreach($elementos_bd_total as $sgu){
|
||||
echo $sgu["hash"]." [".$sgu["horario_id"]."]<br>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "</tr></table>";
|
||||
}else{
|
||||
$pdo->commit();
|
||||
echo "Commit";
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
echo "Error";
|
||||
"ERROR BD! ".$e->getMessage();
|
||||
$pdo->rollBack();
|
||||
if(!$debug){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog("ERROR BD! ".$e->getMessage());
|
||||
}
|
||||
print_r($e->getMessage());
|
||||
} catch(Exception $e2){
|
||||
echo "Error";
|
||||
print_r($e2->getMessage());
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
364
rest/horarios_new.php
Normal file
364
rest/horarios_new.php
Normal file
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
/*
|
||||
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
claveFacultad: clave de la facultad a consultar (opcional, cadena)
|
||||
claveCarrera: clave de la carrera a consultar (opcional, cadena)
|
||||
claveProfesor: clave del empleado a consultar (opcional, cadena)
|
||||
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
|
||||
*/
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('post_max_size', 1);
|
||||
ini_set('max_execution_time', 8*60);
|
||||
error_reporting(E_ALL);
|
||||
date_default_timezone_set('America/Mexico_City');
|
||||
|
||||
$ruta = "../";
|
||||
$ruta_superior = dirname(__DIR__);
|
||||
require_once $ruta_superior."/include/bd_pdo.php";
|
||||
require_once __DIR__."/token.php";
|
||||
require_once __DIR__."/LogCambios.php";
|
||||
|
||||
//------------------ACTUALIZA SALONES----------------------
|
||||
|
||||
$pag = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/espacios/seleccionar";
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $pag,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
//CURLOPT_ENCODING => "",
|
||||
//CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
//CURLOPT_POSTFIELDS => json_encode($params),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: ".$token,
|
||||
"username: SGU_APSA_AUD_ASIST",
|
||||
"Content-Type: application/json",
|
||||
'Transfer-Encoding: chunked'
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
$salonesData = json_decode($response, true);
|
||||
print_r($response);
|
||||
|
||||
$salonesTotal_rs = $db->querySingle('SELECT count(1) as total FROM salon');
|
||||
|
||||
echo $salonesTotal_rs["total"];
|
||||
exit();
|
||||
|
||||
//--------------ACTUALIZA HORARIOS--------------------------
|
||||
if(!empty($_GET["fecha"])){
|
||||
$hoy = $_GET["fecha"];
|
||||
}else{
|
||||
$hoy = date("Y-m-d");
|
||||
}
|
||||
$dia_hoy = date("w", strtotime($hoy));
|
||||
$pag = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/seleccionar";
|
||||
|
||||
function compareByHash($a, $b) {
|
||||
return strcmp($a['hash'], $b['hash']);
|
||||
}
|
||||
$elementos_bd_total = [];
|
||||
$elementos_sgu_total = [];
|
||||
$periodo_sgu_old = 0;
|
||||
|
||||
$debug = false;
|
||||
if(isset($_GET["debug"])){
|
||||
$debug = true;
|
||||
print_r( $db->querySingle('select now()'));
|
||||
}
|
||||
$periodo_sgu_old = 0;
|
||||
$log_desc = "";
|
||||
try{
|
||||
$pdo->beginTransaction();
|
||||
|
||||
|
||||
$periodos_rs = $db->query('SELECT periodo_id, id_periodo_sgu FROM periodo WHERE :hoy BETWEEN periodo_fecha_inicio AND periodo_fecha_fin AND id_periodo_sgu != 0 ORDER BY periodo_id',
|
||||
[":hoy"=>$hoy]);
|
||||
foreach ($periodos_rs as $per){
|
||||
|
||||
//Verifica si el día de hoy es festivo
|
||||
$vacacion_rs = $db->querySingle('select es_festivo(:per, :hoy)', [":per"=>$per["periodo_id"], ":hoy"=>$hoy]);
|
||||
if($vacacion_rs["es_festivo"]){
|
||||
if($debug){
|
||||
echo "<h3>Dia festivo en Periodo: ".$per["id_periodo_sgu"]."[".$per["periodo_id"]."]</h3>";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$carreras_rs = $db->query('SELECT c.clave_carrera, c.carrera_id FROM carrera c INNER JOIN periodo_carrera pc ON c.carrera_id = pc.carrera_id WHERE pc.periodo_id = :per',
|
||||
[":per"=>$per["periodo_id"]]);
|
||||
if($debug)
|
||||
echo "<h3>Periodo: ".$per["id_periodo_sgu"]."[".$per["periodo_id"]."]</h3>";
|
||||
if ($periodo_sgu_old != $per["id_periodo_sgu"]){
|
||||
$periodo_sgu_old = $per["id_periodo_sgu"];
|
||||
$params = [
|
||||
'idPeriodo'=>$per["id_periodo_sgu"],
|
||||
'fecha'=>$hoy
|
||||
];
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $pag,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
//CURLOPT_ENCODING => "",
|
||||
//CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($params),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: ".$token,
|
||||
"username: SGU_APSA_AUD_ASIST",
|
||||
"Content-Type: application/json"
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
}
|
||||
$selectedData = json_decode($response, true);
|
||||
|
||||
//claves de carreras en el periodo
|
||||
$arreglo_claves = array_map(function ($item) {
|
||||
return $item['clave_carrera'];
|
||||
}, $carreras_rs);
|
||||
|
||||
//print_r($selectedData);
|
||||
$sguHash = array();
|
||||
if(!empty($selectedData)){
|
||||
|
||||
//Recorre SGU y genera hash
|
||||
foreach( $selectedData as $row ){
|
||||
if(!$row["EsMateriaPorReposicion"]){
|
||||
$sguHash[] = array(
|
||||
"hash"=>( trim($row["HoraInicio"]."|".($row["NombreMateria"])."|".(trim($row["ClaveProfesor"])==""?"000000":trim($row["ClaveProfesor"]))."|".$row["IdEspacio"]) ),
|
||||
"data"=>$row
|
||||
);
|
||||
}else{//reposición
|
||||
|
||||
if(in_array($row["ClaveCarrera"] , $arreglo_claves)){
|
||||
//busca yyyy-mm-dd hh:mm:ss en la cadena
|
||||
if (preg_match("/\d{4}-\d{2}-\d{2} de \d{2}:\d{2}:\d{2}/", $row["Observaciones"], $matches)) {
|
||||
$fecha_orig = str_replace(" de", "", $matches[0]);
|
||||
$fecha_nueva = $row["FechaStr"]." ".$row["HoraInicio"];
|
||||
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fi_reposicion_sgu($fecha_orig, ".$fecha_nueva.", ".$row["ClaveProfesor"].", ".$per["periodo_id"].", ".$row["IdEspacio"].")";
|
||||
}else{
|
||||
$db->query('SELECT * FROM fi_reposicion_sgu(:fecha_orig, :fecha_rep, :prof, :per, :salon)',
|
||||
[":fecha_orig"=>$fecha_orig, ":fecha_rep"=>$fecha_nueva, ":prof"=>$row["ClaveProfesor"], ":per"=>$per["periodo_id"], ":salon"=>$row["IdEspacio"] ]);
|
||||
$log_desc .="SELECT * FROM fi_reposicion_sgu($fecha_orig, ".$fecha_nueva.", ".$row["ClaveProfesor"].", ".$per["periodo_id"].") ## ";
|
||||
}
|
||||
}else{
|
||||
if($debug)
|
||||
echo "No se encontró fecha y hora en: ".$row["Observaciones"]."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($selectedData);
|
||||
}
|
||||
|
||||
|
||||
$horarios_sgu = [];
|
||||
|
||||
/*
|
||||
print_r($carreras_rs);
|
||||
echo "<br><hr><br>";
|
||||
print_r($arreglo_claves);
|
||||
echo "<br><hr><br>";*/
|
||||
|
||||
//$areacomun = array();
|
||||
foreach($sguHash as $sgu){
|
||||
if(in_array($sgu["data"]["ClaveCarrera"] , $arreglo_claves) /*&& !in_array($sgu["data"]["ClaveMateria"], $areacomun)*/){
|
||||
$horarios_sgu[] = $sgu;
|
||||
}
|
||||
}
|
||||
|
||||
//print_r($horarios_sgu);exit();
|
||||
unset($sguHash);
|
||||
$elementos_sgu_total = array_merge($elementos_sgu_total, $horarios_sgu);
|
||||
|
||||
|
||||
//Recorre BD y genera hash
|
||||
$horarios_rs = $db->query('SELECT * FROM fs_horarios_hash(:dia, :periodo, :fecha)',
|
||||
[':dia' => $dia_hoy, ':periodo' => $per["periodo_id"], ':fecha'=>$hoy]);
|
||||
//echo "**** SELECT * FROM fs_horarios_hash($dia_hoy, ".$per["periodo_id"].")<br>";
|
||||
|
||||
//usort($horarios_rs, 'compareByHash');
|
||||
$elementos_bd_total = array_merge($elementos_bd_total, $horarios_rs);
|
||||
|
||||
}//foreach periodo
|
||||
//print_r($elementos_sgu_total);
|
||||
//exit();
|
||||
if($debug){
|
||||
echo "<h3>Resumen</h3>";
|
||||
echo "<h5>SGU [".count($elementos_sgu_total)."]</h5>";
|
||||
echo "<h5>BD [".count($elementos_bd_total)."]</h5>";
|
||||
}
|
||||
// Extraer los "hash" de $lista y $lista2 en arreglos separados
|
||||
$hashes_sgu = array_column($elementos_sgu_total, 'hash');
|
||||
$hashes_bd = array_column($elementos_bd_total, 'hash');
|
||||
|
||||
|
||||
//------------------
|
||||
// Encontrar los "hash" que están en $sgu pero no están en $bd
|
||||
$hashes_no_en_sgu = array_diff($hashes_bd, $hashes_sgu);
|
||||
if($debug) echo "hashes_no_en_sgu ".count($hashes_no_en_sgu)."<br>";
|
||||
|
||||
if(count($hashes_no_en_sgu)>0){
|
||||
// Ahora puedes obtener los elementos completos que cumplen la condición original
|
||||
$elementos_no_en_sgu = array_filter($elementos_bd_total, function ($item) use ($hashes_no_en_sgu) {
|
||||
return in_array($item['hash'], $hashes_no_en_sgu);
|
||||
});
|
||||
if($debug){
|
||||
print_r($elementos_no_en_sgu);
|
||||
echo "Sobran ".count($elementos_no_en_sgu)." en BD<br>";
|
||||
}
|
||||
|
||||
//Update fecha_fin
|
||||
$log_desc = "";
|
||||
foreach($elementos_no_en_sgu as $row){
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fu_horario_deshabilita(".$row["horario_id"].")";
|
||||
}else{
|
||||
$db->query('SELECT * FROM fu_horario_deshabilita(:horario)', [":horario"=>$row["horario_id"]]);
|
||||
$log_desc .="SELECT * FROM fu_horario_deshabilita(".$row["horario_id"].") ## ";
|
||||
}
|
||||
}
|
||||
if(!$debug && !empty($log_desc)){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog($log_desc);
|
||||
}
|
||||
}
|
||||
|
||||
// Encontrar los "hash" que están en $sgu pero no están en $bd
|
||||
$hashes_no_en_bd = array_diff($hashes_sgu, $hashes_bd);
|
||||
|
||||
//echo "hashes_no_en_bd ".count($hashes_no_en_bd)."<br>";
|
||||
|
||||
if(count($hashes_no_en_bd)>0){
|
||||
// Ahora puedes obtener los elementos completos que cumplen la condición original
|
||||
$elementos_no_en_bd = array_filter($elementos_sgu_total, function ($item) use ($hashes_no_en_bd) {
|
||||
return in_array($item['hash'], $hashes_no_en_bd);
|
||||
});
|
||||
if($debug){
|
||||
echo "<br>Faltan ".count($elementos_no_en_bd)." en BD<br>";
|
||||
print_r($elementos_no_en_bd); echo "<br>";
|
||||
}
|
||||
|
||||
//Inserts
|
||||
foreach($elementos_no_en_bd as $row){
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fi_horario($dia_hoy, '".$row["data"]["HoraInicio"]."','".$row["data"]["HoraFin"]."','"
|
||||
.$row["data"]["ClaveDependencia"]."','"
|
||||
.$row["data"]["ClaveCarrera"]."','"
|
||||
.$row["data"]["NombreMateria"]."','"
|
||||
.$row["data"]["ClaveMateria"]."','"
|
||||
.$row["data"]["ClaveProfesor"]."','"
|
||||
.$row["data"]["NombreProfesor"]."','"
|
||||
.$row["data"]["CorreoElectronico"]."','"
|
||||
.$row["data"]["Grupo"]."',"
|
||||
.$row["data"]["IdEspacio"].");";
|
||||
if($row["data"]["EsMateriaPorAsignacion"]){ echo " ***Asignacion directa***";}
|
||||
}else{
|
||||
$horario_new_rs = $db->querySingle('SELECT * FROM fi_horario(:hoy, :ini, :fin, :dep, :carr, :nom_mat, :cve_mat, :cve_prof, :nom_prof, :correo, :gpo, :espacio)',
|
||||
[":hoy"=>$dia_hoy,
|
||||
":ini"=>$row["data"]["HoraInicio"],
|
||||
":fin"=>$row["data"]["HoraFin"],
|
||||
":dep"=>$row["data"]["ClaveDependencia"],
|
||||
":carr"=>$row["data"]["ClaveCarrera"],
|
||||
":nom_mat"=>$row["data"]["NombreMateria"],
|
||||
":cve_mat"=>$row["data"]["ClaveMateria"],
|
||||
":cve_prof"=>$row["data"]["ClaveProfesor"]==""?"000000":$row["data"]["ClaveProfesor"],
|
||||
":nom_prof"=>$row["data"]["NombreProfesor"],
|
||||
":correo"=>$row["data"]["CorreoElectronico"],
|
||||
":gpo"=>$row["data"]["Grupo"],
|
||||
":espacio"=>$row["data"]["IdEspacio"]]
|
||||
);
|
||||
echo $horario_new_rs["fi_horario"]."<br>";
|
||||
if( !empty($horario_new_rs["fi_horario"]) ){
|
||||
if($row["data"]["EsMateriaPorAsignacion"]){
|
||||
$matasig_rs = $db->querySingle('SELECT * FROM fi_materia_asignacion(:hor,:mat,:carr, :prof)',
|
||||
[":hor"=>$horario_new_rs["fi_horario"],
|
||||
":mat"=>$row["data"]["NombreMateria"],
|
||||
":carr"=>$row["data"]["Carrera"],
|
||||
":prof"=>$row["data"]["NombreProfesor"]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$log_desc .="SELECT * FROM fi_horario($dia_hoy, '".$row["data"]["HoraInicio"]."','".$row["data"]["HoraFin"]."','"
|
||||
.$row["data"]["ClaveDependencia"]."','"
|
||||
.$row["data"]["ClaveCarrera"]."','"
|
||||
.$row["data"]["NombreMateria"]."','"
|
||||
.$row["data"]["ClaveMateria"]."','"
|
||||
.$row["data"]["ClaveProfesor"]."','"
|
||||
.$row["data"]["NombreProfesor"]."','"
|
||||
.$row["data"]["CorreoElectronico"]."','"
|
||||
.$row["data"]["Grupo"]."',"
|
||||
.$row["data"]["IdEspacio"]."); [ID=".$horario_new_rs["fi_horario"]."] ##";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(!$debug && !empty($log_desc)){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog($log_desc);
|
||||
}
|
||||
|
||||
}
|
||||
$stmt = null; // cierra conexion
|
||||
|
||||
if($debug) {
|
||||
echo "<br><br><hr><br><br>";
|
||||
usort($elementos_sgu_total, 'compareByHash');
|
||||
usort($elementos_bd_total, 'compareByHash');
|
||||
|
||||
echo "<table><tr>";
|
||||
echo "<td valign='top'>";
|
||||
echo "<h5>SGU [".count($elementos_sgu_total)."]</h5>";
|
||||
foreach($elementos_sgu_total as $sgu){
|
||||
echo $sgu["hash"]."<br>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td valign='top'>";
|
||||
echo "<h5>BD [".count($elementos_bd_total)."]</h5>";
|
||||
foreach($elementos_bd_total as $sgu){
|
||||
echo $sgu["hash"]." [".$sgu["horario_id"]."]<br>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "</tr></table>";
|
||||
}else{
|
||||
$pdo->commit();
|
||||
echo "Commit";
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
echo "Error";
|
||||
"ERROR BD! ".$e->getMessage();
|
||||
$pdo->rollBack();
|
||||
if(!$debug){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog("ERROR BD! ".$e->getMessage());
|
||||
}
|
||||
print_r($e->getMessage());
|
||||
} catch(Exception $e2){
|
||||
echo "Error";
|
||||
print_r($e2->getMessage());
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
403
rest/horarios_otro.php
Normal file
403
rest/horarios_otro.php
Normal file
@@ -0,0 +1,403 @@
|
||||
<?php
|
||||
/*
|
||||
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
claveFacultad: clave de la facultad a consultar (opcional, cadena)
|
||||
claveCarrera: clave de la carrera a consultar (opcional, cadena)
|
||||
claveProfesor: clave del empleado a consultar (opcional, cadena)
|
||||
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
|
||||
*/
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('post_max_size', 1);
|
||||
ini_set('max_execution_time', 8*60);
|
||||
error_reporting(E_ALL);
|
||||
date_default_timezone_set('America/Mexico_City');
|
||||
|
||||
$ruta = "../";
|
||||
$ruta_superior = dirname(__DIR__);
|
||||
require_once $ruta_superior."/include/bd_pdo.php";
|
||||
require_once __DIR__."/token.php";
|
||||
require_once __DIR__."/LogCambios.php";
|
||||
require_once __DIR__."/include/mailer.php";
|
||||
require_once __DIR__.'/include/phpmailer/PHPMailerAutoload.php';
|
||||
|
||||
//--------------ACTUALIZA HORARIOS--------------------------
|
||||
if(!empty($_GET["fecha"])){
|
||||
$hoy = $_GET["fecha"];
|
||||
}else{
|
||||
$hoy = date("Y-m-d");
|
||||
}
|
||||
$dia_hoy = date("w", strtotime($hoy));
|
||||
|
||||
|
||||
function compareByHash($a, $b) {
|
||||
return strcmp($a['hash'], $b['hash']);
|
||||
}
|
||||
|
||||
|
||||
$debug = false;
|
||||
if(isset($_GET["debug"])){
|
||||
$debug = true;
|
||||
print_r( $db->querySingle('select now()'));
|
||||
}
|
||||
$periodo_sgu_old = 0;
|
||||
$log_desc = "";
|
||||
|
||||
//------------------ACTUALIZA SALONES----------------------
|
||||
|
||||
$pag = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/espacios/seleccionar";
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $pag,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
//CURLOPT_ENCODING => "",
|
||||
//CURLOPT_MAXREDIRS => 10,
|
||||
// CURLOPT_TIMEOUT => 0,
|
||||
//CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode([]),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: ".$token,
|
||||
"username: SGU_APSA_AUD_ASIST",
|
||||
"Content-Type: application/json",
|
||||
'Transfer-Encoding: chunked'
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
$salonesData = json_decode($response, true);
|
||||
|
||||
//$salonesTotal_rs = $db->count('salon');
|
||||
$salonesTotal_rs = $db->where('salon_id', 0, '>')->count('salon');
|
||||
echo "BD $salonesTotal_rs vs SGU " . count($salonesData) . " salones<br>";
|
||||
if($salonesTotal_rs < count($salonesData)){//faltan salones en BD
|
||||
echo "Actualizar salones<br>";
|
||||
$salones_rs = $db->query('SELECT id_espacio_sgu FROM salon');
|
||||
//claves de espacios
|
||||
$arreglo_espacios = array_map(function ($item) {
|
||||
return $item['id_espacio_sgu'];
|
||||
}, $salones_rs);
|
||||
|
||||
foreach($salonesData as $data){
|
||||
if( !in_array($data["IdEspacio"], $arreglo_espacios)){
|
||||
//Insertar espacio
|
||||
if($debug){
|
||||
echo "Espacio nuevo: ".$data["NombreEspacio"]."<br>";
|
||||
}else{
|
||||
$db->query('INSERT INTO SALON (salon, id_espacio_sgu, id_espacio_padre) VALUES (:salon, :id, :id_padre)',
|
||||
[":salon"=>$data["NombreEspacio"], ":id"=>$data["IdEspacio"], ":id_padre"=>$data["IdEspacioPadre"]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// -----------------------------
|
||||
|
||||
$pag = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/seleccionar";
|
||||
$elementos_bd_total = [];
|
||||
$elementos_sgu_total = [];
|
||||
$periodo_sgu_old = 0;
|
||||
try{
|
||||
$pdo->beginTransaction();
|
||||
|
||||
|
||||
$periodos_rs = $db->query('SELECT periodo_id, id_periodo_sgu, nivel_id FROM periodo WHERE :hoy BETWEEN periodo_fecha_inicio AND periodo_fecha_fin AND id_periodo_sgu != 0 ORDER BY periodo_id',
|
||||
[":hoy"=>$hoy]);
|
||||
foreach ($periodos_rs as $per){
|
||||
|
||||
//Verifica si el día de hoy es festivo
|
||||
$vacacion_rs = $db->querySingle('select es_festivo(:per, :hoy)', [":per"=>$per["periodo_id"], ":hoy"=>$hoy]);
|
||||
if($vacacion_rs["es_festivo"]){
|
||||
if($debug){
|
||||
echo "<h3>Dia festivo en Periodo: ".$per["id_periodo_sgu"]."[".$per["periodo_id"]."]</h3>";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$carreras_rs = $db->query('SELECT c.clave_carrera, c.carrera_id FROM carrera c WHERE nivel_id = :nivel',
|
||||
[":nivel"=>$per["nivel_id"]]);
|
||||
if($debug){
|
||||
echo "<h3>Periodo: ".$per["id_periodo_sgu"]."[".$per["periodo_id"]."] nivel: ".$per["nivel_id"]."</h3>";
|
||||
//print_r($carreras_rs);
|
||||
}
|
||||
if ($periodo_sgu_old != $per["id_periodo_sgu"]){
|
||||
$periodo_sgu_old = $per["id_periodo_sgu"];
|
||||
$params = [
|
||||
'idPeriodo'=>$per["id_periodo_sgu"],
|
||||
'fecha'=>$hoy
|
||||
];
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $pag,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
//CURLOPT_ENCODING => "",
|
||||
//CURLOPT_MAXREDIRS => 10,
|
||||
//CURLOPT_TIMEOUT => 0,
|
||||
//CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($params),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: ".$token,
|
||||
"username: SGU_APSA_AUD_ASIST",
|
||||
"Content-Type: application/json"
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
}
|
||||
$selectedData = json_decode($response, true);
|
||||
|
||||
//claves de carreras en el periodo
|
||||
$arreglo_claves = array_map(function ($item) {
|
||||
return $item['clave_carrera'];
|
||||
}, $carreras_rs);
|
||||
|
||||
//print_r($selectedData); exit();
|
||||
$sguHash = array();
|
||||
if(!empty($selectedData)){
|
||||
|
||||
//Recorre SGU y genera hash
|
||||
foreach( $selectedData as $row ){
|
||||
if(!$row["EsMateriaPorReposicion"]){
|
||||
$sguHash[] = array(
|
||||
"hash"=>( trim($row["HoraInicio"]."|".($row["NombreMateria"])."|".(trim($row["ClaveProfesor"])==""?"000000":trim($row["ClaveProfesor"]))."|".$row["IdEspacio"]) ),
|
||||
"data"=>$row
|
||||
);
|
||||
}else{//reposición
|
||||
|
||||
if(in_array($row["ClaveCarrera"] , $arreglo_claves)){
|
||||
//busca yyyy-mm-dd hh:mm:ss en la cadena
|
||||
if (preg_match("/\d{4}-\d{2}-\d{2} de \d{2}:\d{2}:\d{2}/", $row["Observaciones"], $matches)) {
|
||||
$fecha_orig = str_replace(" de", "", $matches[0]);
|
||||
$fecha_nueva = $row["FechaStr"]." ".$row["HoraInicio"];
|
||||
$hora_fin_nueva = $row["HoraFin"];
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fi_reposicion_sgu($fecha_orig, ".$hora_fin_nueva.",".$fecha_nueva." ,".$row["ClaveProfesor"].", ".$per["periodo_id"].", ".$row["IdEspacio"].")";
|
||||
}else{
|
||||
$db->query('SELECT * FROM fi_reposicion_sgu(:fecha_orig, :hora_fin, :fecha_rep, :prof, :per, :salon)',
|
||||
[":fecha_orig"=>$fecha_orig, ":hora_fin"=>$hora_fin_nueva, ":fecha_rep"=>$fecha_nueva, ":prof"=>$row["ClaveProfesor"], ":per"=>$per["periodo_id"], ":salon"=>$row["IdEspacio"] ]);
|
||||
$log_desc .="SELECT * FROM fi_reposicion_sgu($fecha_orig, ".$hora_fin_nueva.",".$fecha_nueva." ,".$row["ClaveProfesor"].", ".$per["periodo_id"].", ".$row["IdEspacio"].") ## ";
|
||||
}
|
||||
}else{
|
||||
if($debug)
|
||||
echo "No se encontró fecha y hora en: ".$row["Observaciones"]."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($selectedData);
|
||||
}
|
||||
|
||||
|
||||
$horarios_sgu = [];
|
||||
|
||||
/*
|
||||
print_r($carreras_rs);
|
||||
echo "<br><hr><br>";*/
|
||||
print_r($arreglo_claves);
|
||||
echo "<br><hr><br>";
|
||||
|
||||
//$areacomun = array();
|
||||
foreach($sguHash as $sgu){
|
||||
if(in_array($sgu["data"]["ClaveCarrera"] , $arreglo_claves) /*&& !in_array($sgu["data"]["ClaveMateria"], $areacomun)*/){
|
||||
$horarios_sgu[] = $sgu;
|
||||
}
|
||||
}
|
||||
|
||||
//print_r($horarios_sgu);exit();
|
||||
unset($sguHash);
|
||||
$elementos_sgu_total = array_merge($elementos_sgu_total, $horarios_sgu);
|
||||
|
||||
|
||||
//Recorre BD y genera hash
|
||||
$horarios_rs = $db->query('SELECT * FROM fs_horarios_hash(:dia, :periodo, :fecha)',
|
||||
[':dia' => $dia_hoy, ':periodo' => $per["periodo_id"], ':fecha'=>$hoy]);
|
||||
//echo "**** SELECT * FROM fs_horarios_hash($dia_hoy, ".$per["periodo_id"].")<br>";
|
||||
|
||||
//usort($horarios_rs, 'compareByHash');
|
||||
$elementos_bd_total = array_merge($elementos_bd_total, $horarios_rs);
|
||||
|
||||
}//foreach periodo
|
||||
//print_r($elementos_sgu_total);
|
||||
//exit();
|
||||
if($debug){
|
||||
echo "<h3>Resumen</h3>";
|
||||
echo "<h5>SGU [".count($elementos_sgu_total)."]</h5>";
|
||||
echo "<h5>BD [".count($elementos_bd_total)."]</h5>";
|
||||
}
|
||||
// Extraer los "hash" de $lista y $lista2 en arreglos separados
|
||||
$hashes_sgu = array_column($elementos_sgu_total, 'hash');
|
||||
$hashes_bd = array_column($elementos_bd_total, 'hash');
|
||||
|
||||
|
||||
//------------------
|
||||
// Encontrar los "hash" que están en $sgu pero no están en $bd
|
||||
$hashes_no_en_sgu = array_diff($hashes_bd, $hashes_sgu);
|
||||
if($debug) echo "hashes_no_en_sgu ".count($hashes_no_en_sgu)."<br>";
|
||||
|
||||
if(count($hashes_no_en_sgu)>0){
|
||||
// Ahora puedes obtener los elementos completos que cumplen la condición original
|
||||
$elementos_no_en_sgu = array_filter($elementos_bd_total, function ($item) use ($hashes_no_en_sgu) {
|
||||
return in_array($item['hash'], $hashes_no_en_sgu);
|
||||
});
|
||||
if($debug){
|
||||
print_r($elementos_no_en_sgu);
|
||||
echo "Sobran ".count($elementos_no_en_sgu)." en BD<br>";
|
||||
}
|
||||
|
||||
//Update fecha_fin
|
||||
$log_desc = "";
|
||||
foreach($elementos_no_en_sgu as $row){
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fu_horario_deshabilita(".$row["horario_id"].")";
|
||||
}else{
|
||||
$db->query('SELECT * FROM fu_horario_deshabilita(:horario)', [":horario"=>$row["horario_id"]]);
|
||||
$log_desc .="SELECT * FROM fu_horario_deshabilita(".$row["horario_id"].") ## ";
|
||||
}
|
||||
}
|
||||
if(!$debug && !empty($log_desc)){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog($log_desc);
|
||||
}
|
||||
}
|
||||
|
||||
// Encontrar los "hash" que están en $sgu pero no están en $bd
|
||||
$hashes_no_en_bd = array_diff($hashes_sgu, $hashes_bd);
|
||||
|
||||
//echo "hashes_no_en_bd ".count($hashes_no_en_bd)."<br>";
|
||||
|
||||
if(count($hashes_no_en_bd)>0){
|
||||
// Ahora puedes obtener los elementos completos que cumplen la condición original
|
||||
$elementos_no_en_bd = array_filter($elementos_sgu_total, function ($item) use ($hashes_no_en_bd) {
|
||||
return in_array($item['hash'], $hashes_no_en_bd);
|
||||
});
|
||||
if($debug){
|
||||
echo "<br>Faltan ".count($elementos_no_en_bd)." en BD<br>";
|
||||
print_r($elementos_no_en_bd); echo "<br>";
|
||||
}
|
||||
|
||||
//Inserts
|
||||
foreach($elementos_no_en_bd as $row){
|
||||
if($debug){
|
||||
echo "<br>SELECT * FROM fi_horario($dia_hoy, '".$row["data"]["HoraInicio"]."','".$row["data"]["HoraFin"]."','"
|
||||
.$row["data"]["ClaveDependencia"]."','"
|
||||
.$row["data"]["ClaveCarrera"]."','"
|
||||
.$row["data"]["NombreMateria"]."','"
|
||||
.$row["data"]["ClaveMateria"]."','"
|
||||
.$row["data"]["ClaveProfesor"]."','"
|
||||
.$row["data"]["NombreProfesor"]."','"
|
||||
.$row["data"]["CorreoElectronico"]."','"
|
||||
.$row["data"]["Grupo"]."',"
|
||||
.$row["data"]["IdEspacio"].","
|
||||
.$per["periodo_id"].");";
|
||||
if($row["data"]["EsMateriaPorAsignacion"]){ echo " ***Asignacion directa***";}
|
||||
}else{
|
||||
$horario_new_rs = $db->querySingle('SELECT * FROM fi_horario(:hoy, :ini, :fin, :dep, :carr, :nom_mat, :cve_mat, :cve_prof, :nom_prof, :correo, :gpo, :espacio, :periodo)',
|
||||
[":hoy"=>$dia_hoy,
|
||||
":ini"=>$row["data"]["HoraInicio"],
|
||||
":fin"=>$row["data"]["HoraFin"],
|
||||
":dep"=>$row["data"]["ClaveDependencia"],
|
||||
":carr"=>$row["data"]["ClaveCarrera"],
|
||||
":nom_mat"=>$row["data"]["NombreMateria"],
|
||||
":cve_mat"=>$row["data"]["ClaveMateria"],
|
||||
":cve_prof"=>$row["data"]["ClaveProfesor"]==""?"000000":$row["data"]["ClaveProfesor"],
|
||||
":nom_prof"=>$row["data"]["NombreProfesor"],
|
||||
":correo"=>$row["data"]["CorreoElectronico"],
|
||||
":gpo"=>$row["data"]["Grupo"],
|
||||
":espacio"=>$row["data"]["IdEspacio"],
|
||||
":periodo"=>$per["periodo_id"]
|
||||
]
|
||||
);
|
||||
//echo $horario_new_rs["fi_horario"]."<br>";
|
||||
if($horario_new_rs["fi_horario"] > 0){
|
||||
if($row["data"]["EsMateriaPorAsignacion"]){
|
||||
$matasig_rs = $db->querySingle('SELECT * FROM fi_materia_asignacion(:hor,:mat,:carr, :prof)',
|
||||
[":hor"=>$horario_new_rs["fi_horario"],
|
||||
":mat"=>$row["data"]["NombreMateria"],
|
||||
":carr"=>$row["data"]["Carrera"],
|
||||
":prof"=>$row["data"]["NombreProfesor"]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$log_desc .="SELECT * FROM fi_horario($dia_hoy, '".$row["data"]["HoraInicio"]."','".$row["data"]["HoraFin"]."','"
|
||||
.$row["data"]["ClaveDependencia"]."','"
|
||||
.$row["data"]["ClaveCarrera"]."','"
|
||||
.$row["data"]["NombreMateria"]."','"
|
||||
.$row["data"]["ClaveMateria"]."','"
|
||||
.$row["data"]["ClaveProfesor"]."','"
|
||||
.$row["data"]["NombreProfesor"]."','"
|
||||
.$row["data"]["CorreoElectronico"]."','"
|
||||
.$row["data"]["Grupo"]."',"
|
||||
.$row["data"]["IdEspacio"]."); [ID=".$horario_new_rs["fi_horario"]."] ##";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(!$debug && !empty($log_desc)){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog($log_desc);
|
||||
}
|
||||
|
||||
}
|
||||
$stmt = null; // cierra conexion
|
||||
|
||||
if($debug) {
|
||||
echo "<br><br><hr><br><br>";
|
||||
|
||||
usort($elementos_sgu_total, 'compareByHash');
|
||||
usort($elementos_bd_total, 'compareByHash');
|
||||
|
||||
echo "<table><tr>";
|
||||
echo "<td valign='top'>";
|
||||
echo "<h5>SGU [".count($elementos_sgu_total)."]</h5>";
|
||||
foreach($elementos_sgu_total as $sgu){
|
||||
echo $sgu["hash"]."<br>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td valign='top'>";
|
||||
echo "<h5>BD [".count($elementos_bd_total)."]</h5>";
|
||||
foreach($elementos_bd_total as $sgu){
|
||||
echo $sgu["hash"]." [".$sgu["horario_id"]."]<br>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "</tr></table>";
|
||||
|
||||
|
||||
}else{
|
||||
$pdo->commit();
|
||||
echo "Commit";
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
echo "Error";
|
||||
"ERROR BD! ".$e->getMessage();
|
||||
$pdo->rollBack();
|
||||
if(!$debug){
|
||||
$log = new LogCambios(__DIR__."/log/");
|
||||
$log->appendLog("ERROR BD! ".$e->getMessage());
|
||||
|
||||
$texto = "<h1>ERROR BD</h1><p>".$e->getMessage()."</p>";
|
||||
$asunto = "Error correo automático";
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}
|
||||
print_r($e->getMessage());
|
||||
} catch(Exception $e2){
|
||||
echo "Error";
|
||||
print_r($e2->getMessage());
|
||||
$texto = "<h1>EXCEPTION</h1><p>".$e2->getMessage()."</p>";
|
||||
$asunto = "Error correo automático";
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
95
rest/include/mailer.php
Normal file
95
rest/include/mailer.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
//https://github.com/PHPMailer/PHPMailer
|
||||
//require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
|
||||
class Mailer{
|
||||
private const FROM = "academia@lasalle.mx";
|
||||
private const FROM_NAME = "Vicerrectoría Académica";
|
||||
private const FROM_PASS = "Foy25193";
|
||||
private const FOOTER = "<p style='margin-top:5em; color:#aaa;font-style:italics'><small>Este es un correo automatizado, esta cuenta no recibe correos.<small></p>";
|
||||
//private $lista_to, $asunto, $texto;
|
||||
|
||||
/**
|
||||
* Función estática para mandar correos. Los destinatarios pueden ser arreglo o cadena separada por ; incluir: include/phpmailer/PHPMailerAutoload.php
|
||||
*
|
||||
* @param array|string $lista_to El destinatario o lista de destinatarios. Puede ser un arreglo de direcciones de correo electrónico o una cadena de texto con direcciones de correo separadas por ;.
|
||||
* @param string $asunto El asunto del correo.
|
||||
* @param string $texto El cuerpo del mensaje del correo en HTML.
|
||||
* @param bool $bcc Indica si se debe enviar el correo como copia oculta (true) o no (false). Valor por defecto: false.
|
||||
*
|
||||
* @return bool True si el correo se envió exitosamente, false en caso contrario.
|
||||
*/
|
||||
public static function enviarCorreo($lista_to, $asunto, $texto, $bcc = false){
|
||||
try{
|
||||
//SMTP Settings
|
||||
$mail = new PHPMailer();
|
||||
$mail->CharSet = 'UTF-8';
|
||||
$mail->SMTPDebug = 0;
|
||||
$mail->isSMTP();
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->SMTPSecure = 'TLS';
|
||||
$mail->Host = "smtp.office365.com";
|
||||
$mail->Port = 587;
|
||||
$mail->Username = self::FROM;
|
||||
$mail->Password = self::FROM_PASS;
|
||||
|
||||
$mail->SetFrom(self::FROM, self::FROM_NAME); //from (verified email address)
|
||||
$mail->Subject = $asunto; //subject
|
||||
|
||||
$mail->IsHTML(true);
|
||||
$mail->MsgHTML($texto.self::FOOTER);//adjunta footer
|
||||
//recipient
|
||||
if(is_array($lista_to)){
|
||||
foreach($lista_to as $correo){
|
||||
if(trim($correo)!="")
|
||||
if($bcc)
|
||||
$mail->addBCC($correo);
|
||||
else
|
||||
$mail->AddAddress($correo);
|
||||
}
|
||||
}else{//cadena de texto separada por ;
|
||||
if(strpos($lista_to, ";")!==false){
|
||||
$toArr = explode(";", $lista_to);
|
||||
foreach($toArr as $correo){
|
||||
if(trim($correo)!=""){
|
||||
if($bcc)
|
||||
$mail->addBCC($correo);
|
||||
else
|
||||
$mail->AddAddress($correo);
|
||||
}
|
||||
}
|
||||
}elseif(strpos($lista_to, ",")!==false){
|
||||
$toArr = explode(",", $lista_to);
|
||||
foreach($toArr as $correo){
|
||||
if(trim($correo)!=""){
|
||||
if($bcc)
|
||||
$mail->addBCC($correo);
|
||||
else
|
||||
$mail->AddAddress($correo);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(trim($lista_to)!=""){
|
||||
if($bcc)
|
||||
$mail->addBCC($lista_to);
|
||||
else
|
||||
$mail->AddAddress($lista_to);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//Success
|
||||
if ($mail->Send()) {
|
||||
return true;
|
||||
}
|
||||
}catch(phpmailerException $e){
|
||||
echo $mail->ErrorInfo;
|
||||
return false;
|
||||
}catch(Exception $e2){
|
||||
echo $mail->ErrorInfo;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
50
rest/include/phpmailer/PHPMailerAutoload.php
Normal file
50
rest/include/phpmailer/PHPMailerAutoload.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPMailer SPL autoloader.
|
||||
* PHP Version 5
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
|
||||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
||||
* @author Brent R. Matzelle (original founder)
|
||||
* @copyright 2012 - 2014 Marcus Bointon
|
||||
* @copyright 2010 - 2012 Jim Jagielski
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailer SPL autoloader.
|
||||
* @param string $classname The name of the class to load
|
||||
*/
|
||||
function PHPMailerAutoload($classname)
|
||||
{
|
||||
//Can't use __DIR__ as it's only in PHP 5.3+
|
||||
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
|
||||
if (is_readable($filename)) {
|
||||
require $filename;
|
||||
}
|
||||
}
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
|
||||
//SPL autoloading was introduced in PHP 5.1.2
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
spl_autoload_register('PHPMailerAutoload', true, true);
|
||||
} else {
|
||||
spl_autoload_register('PHPMailerAutoload');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Fall back to traditional autoload for old PHP versions
|
||||
* @param string $classname The name of the class to load
|
||||
*/
|
||||
spl_autoload_register($classname);
|
||||
/*function __autoload($classname)
|
||||
{
|
||||
PHPMailerAutoload($classname);
|
||||
}*/
|
||||
}
|
||||
3884
rest/include/phpmailer/class.phpmailer.php
Normal file
3884
rest/include/phpmailer/class.phpmailer.php
Normal file
File diff suppressed because it is too large
Load Diff
1181
rest/include/phpmailer/class.smtp.php
Normal file
1181
rest/include/phpmailer/class.smtp.php
Normal file
File diff suppressed because it is too large
Load Diff
3
rest/info.php
Normal file
3
rest/info.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
20
rest/log/cambios_2023_08.log
Normal file
20
rest/log/cambios_2023_08.log
Normal file
File diff suppressed because one or more lines are too long
252
rest/materias.php
Normal file
252
rest/materias.php
Normal file
@@ -0,0 +1,252 @@
|
||||
<style>
|
||||
details {
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
padding: 0.5em 0.5em 0;
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
summary {
|
||||
font-weight: bold;
|
||||
margin: -0.5em -0.5em 0;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
details[open] {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
details[open] summary {
|
||||
border-bottom: 1px solid #aaa;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
padding: 8px;
|
||||
border: 1px solid #ccc;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
tr:nth-child(even):not(.empty):not(.area-comun) {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.json-container {
|
||||
white-space: pre-wrap;
|
||||
/* Since JSON is formatted with whitespace, this will keep formatting */
|
||||
word-break: break-word;
|
||||
/* To prevent horizontal scrolling */
|
||||
max-height: 150px;
|
||||
/* Set a max-height and add scroll to prevent very long JSON from cluttering the table */
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.empty {
|
||||
/* rosa pastel */
|
||||
background-color: #ffe8f4;
|
||||
}
|
||||
|
||||
.area-comun {
|
||||
/* naranja pastel */
|
||||
background-color: #ffe9d4;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
/*
|
||||
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
claveFacultad: clave de la facultad a consultar (opcional, cadena)
|
||||
claveCarrera: clave de la carrera a consultar (opcional, cadena)
|
||||
claveProfesor: clave del empleado a consultar (opcional, cadena)
|
||||
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
|
||||
*/
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('post_max_size', 1);
|
||||
ini_set('max_execution_time', 8 * 60);
|
||||
error_reporting(E_ALL);
|
||||
date_default_timezone_set('America/Mexico_City');
|
||||
|
||||
$ruta = "../";
|
||||
$ruta_superior = dirname(__DIR__);
|
||||
require_once $ruta_superior . "/include/bd_pdo.php";
|
||||
require_once __DIR__ . "/token.php";
|
||||
require_once __DIR__ . "/LogCambios.php";
|
||||
|
||||
$fecha = isset($_GET["fecha"]) ? $_GET["fecha"] : date("Y-m-d");
|
||||
$periodos = $db
|
||||
->where("id_periodo_sgu", 0, ">")
|
||||
->where("periodo_fecha_inicio", $fecha, "<=")
|
||||
->where("periodo_fecha_fin", $fecha, ">=")
|
||||
->orderBy("periodo_id")
|
||||
->get("periodo");
|
||||
?>
|
||||
<nav>
|
||||
<form action="" method="get">
|
||||
<label for="fecha">Fecha</label>
|
||||
<input type="date" name="fecha" id="fecha" value="<?= $fecha ?>">
|
||||
<button type="submit">Buscar</button>
|
||||
</form>
|
||||
<details>
|
||||
<summary>Periodos</summary>
|
||||
<pre>
|
||||
<code><?= json_encode($periodos, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code>
|
||||
</pre>
|
||||
</details>
|
||||
<?php
|
||||
$horarios = array();
|
||||
foreach (array_column($periodos, "id_periodo_sgu") as $idPeriodo) {
|
||||
$curl = curl_init();
|
||||
$params = array(
|
||||
'idPeriodo' => $idPeriodo,
|
||||
'fecha' => $fecha,
|
||||
);
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/seleccionar',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POSTFIELDS => json_encode($params),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: $token",
|
||||
'username: SGU_APSA_AUD_ASIST',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
$horarios = array_merge($horarios, $response);
|
||||
?>
|
||||
<details>
|
||||
<summary>Periodo
|
||||
<?= $idPeriodo ?>
|
||||
</summary>
|
||||
<pre><code><?= json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
|
||||
</details>
|
||||
<?php } ?>
|
||||
</nav>
|
||||
<main>
|
||||
<p>
|
||||
<?= count($horarios) ?> horarios encontrados para
|
||||
<?= $fecha ?>
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Materia en SGU</th>
|
||||
<th>Materia en Postgres</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
// $horarios with unique "NombreMateria" field
|
||||
$horarios = array_map("unserialize", array_unique(array_map("serialize", $horarios)));
|
||||
foreach ($horarios as $horario) {
|
||||
$materias = $db
|
||||
->where("materia_nombre", trim($horario["NombreMateria"]), "ILIKE")
|
||||
->join("carrera", "carrera.carrera_id = materia.carrera_id")
|
||||
->join("facultad", "facultad.facultad_id = carrera.facultad_id")
|
||||
->get("materia");
|
||||
if (
|
||||
count(array_filter($materias, fn($m) =>
|
||||
$m["clave_materia"] == trim($horario["ClaveMateria"]) and
|
||||
$m["clave_carrera"] == trim($horario["ClaveCarrera"]))) > 0
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// si de las materias alguna tiene carrera_id entre 1 y 4 entonces es de área común
|
||||
$area_comun = count(array_filter($materias, fn($m) => $m["carrera_id"] >= 1 and $m["carrera_id"] <= 4)) > 0;
|
||||
$vacío = count($materias) == 0;
|
||||
?>
|
||||
<!-- si es vacío ponle la clase empty y si es área común ponle la clase area-comun -->
|
||||
<tr class="<?= $vacío ? "empty" : "" ?> <?= $area_comun ? "area-comun" : "" ?>">
|
||||
<td class="json-container">
|
||||
<details>
|
||||
<summary>Horario</summary>
|
||||
<pre><code><?= json_encode($horario, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
|
||||
</details>
|
||||
<?= json_encode(array_intersect_key($horario, array_flip(["ClaveMateria", "NombreMateria", "ClaveCarrera", "Dependencia"])), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?>
|
||||
</td>
|
||||
<td class="json-container">
|
||||
<?php if ($vacío) { ?>
|
||||
<p>No se encontraron materias</p>
|
||||
<?php } else { ?>
|
||||
<details>
|
||||
<summary>Materias</summary>
|
||||
<pre><code><?= json_encode($materias, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></code></pre>
|
||||
</details>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Materia</th>
|
||||
<th>Carrera</th>
|
||||
<th>Facultad</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<script>
|
||||
async function copiar_seleccionados() {
|
||||
// en mi clipboard quiero (join con ,)
|
||||
const materias_seleccionadas = Array.from(document.querySelectorAll("input[name='materia_id']:checked"))
|
||||
.map(input => input.value)
|
||||
.join(",");
|
||||
// copiar al clipboard
|
||||
await navigator.clipboard.writeText(materias_seleccionadas);
|
||||
// mostrar mensaje de éxito
|
||||
alert("Copiado al portapapeles");
|
||||
}
|
||||
</script>
|
||||
<?php foreach ($materias as $materia) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="materia_id" id="materia_id"
|
||||
value="<?= $materia["materia_id"] ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?= $materia["materia_id"] ?>
|
||||
<small>
|
||||
(
|
||||
<?= $materia["clave_materia"] ?>)
|
||||
</small>
|
||||
<?= $materia["materia_nombre"] ?>
|
||||
</td>
|
||||
<td>
|
||||
<small>
|
||||
(
|
||||
<?= $materia["clave_carrera"] ?>)
|
||||
</small>
|
||||
<?= $materia["carrera_nombre"] ?>
|
||||
</td>
|
||||
<td>
|
||||
<small>
|
||||
(
|
||||
<?= $materia["clave_dependencia"] ?>)
|
||||
</small>
|
||||
<?= $materia["facultad_nombre"] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</main>
|
||||
149
rest/salon.php
Normal file
149
rest/salon.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<style>
|
||||
details {
|
||||
border: 1px solid #aaa;
|
||||
border-radius: 4px;
|
||||
padding: 0.5em 0.5em 0;
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
summary {
|
||||
font-weight: bold;
|
||||
margin: -0.5em -0.5em 0;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
details[open] {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
details[open] summary {
|
||||
border-bottom: 1px solid #aaa;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
padding: 8px;
|
||||
border: 1px solid #ccc;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
.json-container {
|
||||
white-space: pre-wrap;
|
||||
/* Since JSON is formatted with whitespace, this will keep formatting */
|
||||
word-break: break-word;
|
||||
/* To prevent horizontal scrolling */
|
||||
max-height: 150px;
|
||||
/* Set a max-height and add scroll to prevent very long JSON from cluttering the table */
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.empty {
|
||||
/* rosa pastel */
|
||||
background-color: #ffe8f4;
|
||||
}
|
||||
|
||||
.no-igual {
|
||||
/* púrpura pastel */
|
||||
background-color: #f4e8ff;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
/*
|
||||
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
claveFacultad: clave de la facultad a consultar (opcional, cadena)
|
||||
claveCarrera: clave de la carrera a consultar (opcional, cadena)
|
||||
claveProfesor: clave del empleado a consultar (opcional, cadena)
|
||||
fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
|
||||
*/
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('post_max_size', 1);
|
||||
ini_set('max_execution_time', 8 * 60);
|
||||
error_reporting(E_ALL);
|
||||
date_default_timezone_set('America/Mexico_City');
|
||||
|
||||
$ruta = "../";
|
||||
$ruta_superior = dirname(__DIR__);
|
||||
require_once $ruta_superior . "/include/bd_pdo.php";
|
||||
require_once __DIR__ . "/token.php";
|
||||
require_once __DIR__ . "/LogCambios.php";
|
||||
|
||||
$salon = array();
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL =>
|
||||
'https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/espacios/seleccionar',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POSTFIELDS => json_encode([]),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: $token",
|
||||
'username: SGU_APSA_AUD_ASIST',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
$json_flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT;
|
||||
$salones = json_decode($response, true, 512, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
?>
|
||||
<main>
|
||||
<p>
|
||||
<?= count($salones) ?> salones encontrados
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Salones en SGU</th>
|
||||
<th>SALONES en Postgres</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($salones as $salon) {
|
||||
$salon_db = $db->where("id_espacio_sgu", $salon["IdEspacio"])->get("salon");
|
||||
// si de el salon es igual NombreEspacio == salon
|
||||
$vacío = empty($salon_db);
|
||||
$igual = $salon["NombreEspacio"] == ($salon["salon"] ?? "");
|
||||
|
||||
if ($vacío) {
|
||||
$db->insert("salon", [
|
||||
"id_espacio_sgu" => $salon["IdEspacio"],
|
||||
"salon" => $salon["NombreEspacio"],
|
||||
"id_espacio_padre" => $salon["IdEspacioPadre"] > 0 ? $salon["IdEspacioPadre"] : null,
|
||||
]);
|
||||
} else if (!$igual) {
|
||||
$db->where("id_espacio_sgu", $salon["IdEspacio"])->update("salon", [
|
||||
"salon" => $salon["NombreEspacio"],
|
||||
// "id_espacio_padre" => $salon["IdEspacioPadre"] > 0 ? $salon["IdEspacioPadre"] : null,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<tr class="<?= $igual ? "empty" : "no-igual" ?>">
|
||||
<td class="json-container">
|
||||
<?= json_encode($salon, $json_flags) ?>
|
||||
</td>
|
||||
<td class="json-container">
|
||||
<?= json_encode($salon_db, $json_flags) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</main>
|
||||
35
rest/token.php
Normal file
35
rest/token.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
*/
|
||||
|
||||
$ruta = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/inicioSesion/seleccionar";
|
||||
|
||||
$required_params = [
|
||||
"username"=>"SGU_APSA_AUD_ASIST",
|
||||
"password"=>"B4qa594JFPr2ufHrZdHS8A=="
|
||||
];
|
||||
try{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $ruta,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($required_params),
|
||||
CURLOPT_HTTPHEADER => array('Content-Type:application/json'),
|
||||
]);
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
|
||||
$token = json_decode($response, true);
|
||||
//echo "token $token";
|
||||
}catch(Exception $e){
|
||||
echo $e->getMessage();
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
41
rest/token.php.save
Normal file
41
rest/token.php.save
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
*/
|
||||
|
||||
$ruta = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/inicioSesion/seleccionar";
|
||||
|
||||
$required_params = [
|
||||
"username"=>"SGU_APSA_AUD_ASIST",
|
||||
"password"=>"B4qa594JFPr2ufHrZdHS8A=="
|
||||
];
|
||||
try{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $ruta,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($required_params),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json"
|
||||
],
|
||||
]);
|
||||
$response = curl_exec($curl);
|
||||
print_r($response);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
|
||||
$token = json_decode($response, true);
|
||||
echo "token $token";
|
||||
}catch(Exception $e){
|
||||
echo $e->getMessage();
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
41
rest/token.php.save.1
Normal file
41
rest/token.php.save.1
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
*/
|
||||
|
||||
$ruta = "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/inicioSesion/seleccionar";
|
||||
|
||||
$required_params = [
|
||||
"username"=>"SGU_APSA_AUD_ASIST",
|
||||
"password"=>"B4qa594JFPr2ufHrZdHS8A=="
|
||||
];
|
||||
try{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $ruta,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($required_params),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json"
|
||||
],
|
||||
]);
|
||||
$response = curl_exec($curl);
|
||||
print_r($response);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
|
||||
$token = json_decode($response, true);
|
||||
echo "token $token";
|
||||
}catch(Exception $e){
|
||||
echo $e->getMessage();
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?
|
||||
$ruta = "../";
|
||||
require_once "$ruta/include/bd_pdo.php";
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// json data from service\periodos.v1.php (input)
|
||||
|
||||
$urls = array(
|
||||
'periodos.v1',
|
||||
'periodos.v2',
|
||||
'horarios',
|
||||
);
|
||||
|
||||
$urls = array_map(fn($item) => "../$item.php", $urls);
|
||||
|
||||
ob_start();
|
||||
include_once 'periodos.v1.php';
|
||||
$periodos_v1 = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
ob_start();
|
||||
include_once 'periodos.v2.php';
|
||||
$periodos_v2 = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
// echo $periodos_v1;
|
||||
echo $periodos_v2;
|
||||
@@ -1,76 +0,0 @@
|
||||
<?
|
||||
$ruta = "../../";
|
||||
require_once "$ruta/include/bd_pdo.php";
|
||||
header('Content-Type: application/json');
|
||||
global $db;
|
||||
// json data from service\periodos.v1.php (input)
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
// check if the input is empty
|
||||
|
||||
if (is_response_empty($data)) {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'No se recibieron datos',
|
||||
'data' => $data
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// check if data is array
|
||||
if (!is_array($data)) {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'La información recibida no es válida',
|
||||
'data' => $data
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* [{
|
||||
* carrera_nombre
|
||||
* carrera_clave
|
||||
* id_nivel
|
||||
* },]
|
||||
*/
|
||||
// check for this schema
|
||||
array_walk($data, function ($item) {
|
||||
if (!isset($item['ClaveCarrera']) || !isset($item['NombreCarrera']) || !isset($item['IdNivel'])) {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'Los datos recibidos no son validos',
|
||||
'data' => $item
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
array_walk($data, function ($item) use ($db) {
|
||||
|
||||
if ($db->where('carrera_nombre', "%{$item['NombreCarrera']}", 'ILIKE')->has('carrera'))
|
||||
$db
|
||||
->where('carrera_nombre', "%{$item['NombreCarrera']}", 'ILIKE')
|
||||
->update('carrera', [
|
||||
'carrera_nombre' => $item['NombreCarrera'],
|
||||
'id_referencia' => $item['ClaveCarrera'],
|
||||
]);
|
||||
else {
|
||||
try {
|
||||
$db->insert('carrera', [
|
||||
'carrera_nombre' => $item['NombreCarrera'],
|
||||
'id_referencia' => $item['ClaveCarrera'],
|
||||
'nivel_id' => $item['IdNivel'],
|
||||
]);
|
||||
} catch (PDOException $th) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => $th->getMessage(),
|
||||
'last_query' => $db->getLastQuery(),
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,62 +0,0 @@
|
||||
<?
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$ruta = "../../";
|
||||
require_once "$ruta/include/bd_pdo.php";
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// json data from service\periodos.v1.php (input)
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
// check if the input is empty
|
||||
|
||||
if (is_response_empty($data)) {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'No se recibieron datos',
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
{
|
||||
"IdNivel": 1,
|
||||
"IdPeriodo": 635,
|
||||
"NombreNivel": "LICENCIATURA",
|
||||
"NombrePeriodo": "241",
|
||||
"in_db": false
|
||||
inicio,
|
||||
fin
|
||||
}
|
||||
*/
|
||||
|
||||
// insert into database
|
||||
setlocale(LC_TIME, 'es_MX.UTF-8');
|
||||
$formatter = new IntlDateFormatter('es_MX', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Mexico_City', IntlDateFormatter::GREGORIAN, 'MMMM');
|
||||
$inicio = strtotime($data['inicio']);
|
||||
$fin = strtotime($data['fin']);
|
||||
try {
|
||||
|
||||
$result = $db->insert('periodo', [
|
||||
'id_periodo_sgu' => $data['IdPeriodo'],
|
||||
'periodo_nombre' => "{$data['NombreNivel']}: {$formatter->format($inicio)} - {$formatter->format($fin)} " . date('Y', $inicio),
|
||||
'nivel_id' => $data['IdNivel'],
|
||||
'periodo_fecha_inicio' => $data['inicio'],
|
||||
'periodo_fecha_fin' => $data['fin'],
|
||||
'estado_id' => 4,
|
||||
'periodo_clave' => $data['NombrePeriodo']
|
||||
], ['id_periodo_sgu']);
|
||||
} catch (PDOException $th) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => $th->getMessage()
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
echo json_encode($result ? [
|
||||
'success' => true,
|
||||
'message' => 'Periodo agregado correctamente'
|
||||
] : [
|
||||
'success' => false,
|
||||
'message' => 'Error al agregar el periodo'
|
||||
]);
|
||||
@@ -1,155 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Cliente REST</title>
|
||||
<script type="module" src="../js/client.js" defer></script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="../css/indivisa.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header class="container-fluid bg-dark text-white text-center">
|
||||
Página de Cliente REST
|
||||
</header>
|
||||
<main class="container" @vue:mounted="mounted">
|
||||
<div v-for="error in store.errors" class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<strong>Error!</strong> {{error}}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>Periodos activos</h1>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
|
||||
<li href="#" class="list-group-item" v-for="(periodo, index) in store.periodosV1" :key="periodo.IdPeriodo">
|
||||
<!-- v1
|
||||
IdNivel: number;
|
||||
IdPeriodo: number;
|
||||
NombreNivel: string;
|
||||
NombrePeriodo: string;
|
||||
-->
|
||||
<div class="row">
|
||||
<span class="badge bg-secondary">{{index}}</span>
|
||||
<h2 class="text-center">
|
||||
Información
|
||||
</h2>
|
||||
<div class="col-md-3">
|
||||
<strong>ID Nivel:</strong> {{periodo.IdNivel}}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<strong>ID Periodo:</strong> {{periodo.IdPeriodo}}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<strong>Nombre Nivel:</strong> {{periodo.NombreNivel}}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<strong>Nombre Periodo:</strong> {{periodo.NombrePeriodo}}
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
FechaFin: string;
|
||||
FechaInicio: string;
|
||||
IdPeriodo: number;
|
||||
-- info(IdPeriodo) --
|
||||
-->
|
||||
<div class="row mt-2" v-if="complete(periodo.IdPeriodo)">
|
||||
<h2 class="text-center">
|
||||
Fechas
|
||||
</h2>
|
||||
<div class="col-md-2">
|
||||
<strong>Fecha Inicio:</strong> {{info(periodo.IdPeriodo).FechaInicio}}
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<strong>Fecha Fin:</strong> {{info(periodo.IdPeriodo).FechaFin}}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!periodo.in_db" class="row mt-2">
|
||||
<!--
|
||||
PeriodoV2
|
||||
ClaveCarrera: string;
|
||||
NombreCarrera: string;
|
||||
PeriodoV1
|
||||
IdNivel: number;
|
||||
-->
|
||||
<div class="col-md-12">
|
||||
<button class="btn btn-primary float-end" @click="store.addPeriodo(periodo)"
|
||||
:disabled="!complete(periodo.IdPeriodo)">
|
||||
Agregar
|
||||
<i class="ing ing-mas"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="row mt-2">
|
||||
<div class="col-md-12">
|
||||
<button class="btn btn-success float-end disabled">
|
||||
Agregado
|
||||
<i class="ing-aceptar"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-2">
|
||||
<div class="col-md-12">
|
||||
<button class="btn btn-secondary float-end" @click="store.addCarreras(periodo.IdPeriodo)">
|
||||
Sincronizar Carreras
|
||||
<i class="ing ing-link"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion mt-2">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button collapsed" data-bs-toggle="collapse"
|
||||
:data-bs-target="`#collapse-${periodo.IdPeriodo}`">
|
||||
Horarios del periodo
|
||||
</button>
|
||||
</h2>
|
||||
<div :id="`collapse-${periodo.IdPeriodo}`" class="accordion-collapse collapse">
|
||||
<div class="accordion-body">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item"
|
||||
v-for="periodo in store.periodosV2.filter(periodov2 => periodov2.IdPeriodo === periodo.IdPeriodo)">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<strong>Clave Carrera:</strong> {{periodo.ClaveCarrera}}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<strong>Nombre Carrera:</strong> {{periodo.NombreCarrera}}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<span class="badge float-end mx-1"
|
||||
:class="periodo.linked ?'bg-success':'bg-secondary'">
|
||||
<i class="ing-link"></i>
|
||||
</span>
|
||||
<span class="badge float-end mx-1"
|
||||
:class="periodo.in_db ?'bg-success':'bg-secondary'">
|
||||
<i class="ing-aceptar"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</main>
|
||||
<footer>
|
||||
|
||||
</footer>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz"
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,81 +0,0 @@
|
||||
<?
|
||||
/*
|
||||
• idPeriodo: identificador del periodo a consultar (obligatorio, número entero)
|
||||
• claveFacultad: clave de la facultad a consultar (opcional, cadena)
|
||||
• claveCarrera: clave de la carrera a consultar (opcional, cadena)
|
||||
• claveProfesor: clave del empleado a consultar (opcional, cadena)
|
||||
• fecha: fecha de la clase (opcional, cadena en formato yyyy-MM-dd)
|
||||
*/
|
||||
$required_params = [
|
||||
'idPeriodo'
|
||||
];
|
||||
|
||||
$optional_params = [
|
||||
'claveFacultad',
|
||||
'claveCarrera',
|
||||
'claveProfesor',
|
||||
'fecha'
|
||||
];
|
||||
|
||||
// Check if all required params are present in $_GET
|
||||
$params = array_map('strtolower', $_GET); // Convert keys to lowercase for case-insensitive comparison
|
||||
|
||||
// Check for missing required parameters
|
||||
$missing_params = array_diff($required_params, array_keys($params));
|
||||
if (!empty($missing_params)) {
|
||||
$missing_params_str = implode(', ', $missing_params);
|
||||
die("Missing required parameter(s): $missing_params_str");
|
||||
}
|
||||
|
||||
// Filter and retain only the required and optional parameters
|
||||
$params = array_filter($params, function ($key) use ($required_params, $optional_params) {
|
||||
return in_array($key, $required_params) || in_array($key, $optional_params);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/seleccionar",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($params),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: 64293fb86c06e45331ab9963822762f77b9c403ca949adcc31286d550e902fff202e4c69d1574b2082ecf0b3a28b6cfd4d88b3a7d2c2ab7d329666b9a527fb1b",
|
||||
"username: SGU_APSA_AUD_ASIST",
|
||||
"Content-Type: application/json"
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
|
||||
|
||||
$selectedData = json_decode($response, true);
|
||||
|
||||
$rawInput = file_get_contents('php://input');
|
||||
|
||||
$input = json_decode($rawInput, true);
|
||||
// check for {collect: []} in raw input
|
||||
if (isset($input['collect']) && is_array($input['collect'])) {
|
||||
$collect = $input['collect'];
|
||||
$selectedData = array_map(function ($item) use ($collect) {
|
||||
return array_intersect_key($item, array_flip($collect));
|
||||
}, $selectedData);
|
||||
// unique and distinct
|
||||
$selectedData = array_unique($selectedData, SORT_REGULAR);
|
||||
}
|
||||
else {
|
||||
// return invalid request error
|
||||
die($rawInput);
|
||||
}
|
||||
|
||||
// Output the selected data directly
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($selectedData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
@@ -1,39 +0,0 @@
|
||||
<?
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$ruta = "../";
|
||||
require_once '../include/bd_pdo.php';
|
||||
$curl = curl_init();
|
||||
global $db;
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/periodos/v1/seleccionar",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POSTFIELDS => "",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: 64293fb86c06e45331ab9963822762f77b9c403ca949adcc31286d550e902fff202e4c69d1574b2082ecf0b3a28b6cfd4d88b3a7d2c2ab7d329666b9a527fb1b",
|
||||
"username: SGU_APSA_AUD_ASIST"
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
|
||||
$data = json_decode($response, true);
|
||||
|
||||
$in_db = array_map(function ($item) use ($db) {
|
||||
$item['in_db'] = $db->where('id_periodo_sgu', $item['IdPeriodo'])->has('periodo');
|
||||
return $item;
|
||||
}, $data);
|
||||
|
||||
$selectedData = array_unique($in_db, SORT_REGULAR);
|
||||
|
||||
// Output the selected data directly
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($selectedData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
@@ -1,41 +0,0 @@
|
||||
<?
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$ruta = "../";
|
||||
require_once '../include/bd_pdo.php';
|
||||
global $db;
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/periodos/v2/seleccionar",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POSTFIELDS => "",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"token: 64293fb86c06e45331ab9963822762f77b9c403ca949adcc31286d550e902fff202e4c69d1574b2082ecf0b3a28b6cfd4d88b3a7d2c2ab7d329666b9a527fb1b",
|
||||
"username: SGU_APSA_AUD_ASIST"
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if ($err)
|
||||
die("cURL Error #:$err");
|
||||
|
||||
|
||||
$json = json_decode($response, true);
|
||||
|
||||
$selectedData = array_map(function ($item) use ($db) {
|
||||
$item['in_db'] = $db->where('carrera_nombre', $item['NombreCarrera'], 'ILIKE')->has('carrera');
|
||||
$item['linked'] = $db->where('clave_carrera', $item['ClaveCarrera'], 'ILIKE')->has('carrera');
|
||||
return $item;
|
||||
}, $json);
|
||||
|
||||
// Output the selected data directly
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($selectedData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
||||
@@ -1,108 +0,0 @@
|
||||
<?
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$ruta = '../../';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/include/bd_pdo.php';
|
||||
header('Content-Type: application/json charset=utf-8');
|
||||
if (
|
||||
(!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== $_ENV['API_USER']) ||
|
||||
(!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] !== $_ENV['API_PASS'])
|
||||
) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'Usuario no autorizado']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$input_raw = file_get_contents('php://input');
|
||||
$input = json_decode($input_raw, true);
|
||||
|
||||
if (!isset($input['clave'])) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'clave no especificada']);
|
||||
exit();
|
||||
} else if (!isset($input['fecha']) and (!isset($input['fecha_inicio']) and !isset($input['fecha_fin']))) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'fecha no especificada']);
|
||||
exit();
|
||||
}
|
||||
|
||||
try {
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST')
|
||||
throw new Exception('method not allowed');
|
||||
|
||||
if (!$db->where('profesor_clave', $input['clave'])->has('profesor'))
|
||||
throw new Exception('clave no válida');
|
||||
|
||||
$profesor = $db->where('profesor_clave', $input['clave'])->getOne('profesor');
|
||||
|
||||
$data = $db->query(
|
||||
"WITH horarios AS (
|
||||
SELECT *,
|
||||
CASE
|
||||
WHEN horario_dia = 1 THEN 'Lunes'
|
||||
WHEN horario_dia = 2 THEN 'Martes'
|
||||
WHEN horario_dia = 3 THEN 'Miércoles'
|
||||
WHEN horario_dia = 4 THEN 'Jueves'
|
||||
WHEN horario_dia = 5 THEN 'Viernes'
|
||||
WHEN horario_dia = 6 THEN 'Sábado'
|
||||
WHEN horario_dia = 7 THEN 'Domingo'
|
||||
END as dia,
|
||||
horario_hora + duracion_interval as horario_fin
|
||||
FROM horario
|
||||
JOIN horario_profesor USING (horario_id)
|
||||
JOIN materia USING (materia_id)
|
||||
JOIN carrera USING (carrera_id)
|
||||
JOIN facultad ON facultad.facultad_id = carrera.facultad_id
|
||||
JOIN periodo_carrera USING (carrera_id)
|
||||
JOIN periodo_view USING (periodo_id)
|
||||
JOIN duracion USING (duracion_id)
|
||||
WHERE :profesor_id = profesor_id and periodo_view.activo
|
||||
),
|
||||
fechas AS (
|
||||
SELECT fechas_clase(h.horario_id) as registro_fecha_ideal, h.horario_id
|
||||
FROM horarios h
|
||||
)
|
||||
SELECT distinct
|
||||
materia_nombre as materia,
|
||||
facultad_nombre as facultad,
|
||||
carrera_nombre as carrera,
|
||||
registro_fecha_ideal as fecha_clase,
|
||||
horarios.horario_hora as hora_clase,
|
||||
horarios.horario_fin as fin_clase,
|
||||
horarios.dia as dia_clase,
|
||||
CASE
|
||||
when registro_justificada THEN 'Justificada'
|
||||
WHEN registro_retardo THEN 'Retardo'
|
||||
WHEN registro_reposicion THEN 'Respuesta'
|
||||
WHEN registro_fecha IS NOT NULL THEN 'Registrado'
|
||||
ELSE 'Sin registro' END as registro,
|
||||
TO_CHAR(registro_fecha::TIME, 'HH24:MI:SS') as hora_registro
|
||||
FROM horarios
|
||||
JOIN fechas using (horario_id)
|
||||
LEFT JOIN registro USING (horario_id, registro_fecha_ideal, profesor_id)
|
||||
WHERE registro.registro_fecha_ideal BETWEEN :fecha_inicio AND :fecha_fin
|
||||
ORDER BY fecha_clase DESC, materia_nombre",
|
||||
[
|
||||
':fecha_inicio' => $input['fecha'] ?? $input['fecha_inicio'] ?? null,
|
||||
':fecha_fin' => $input['fecha'] ?? $input['fecha_fin'] ?? null,
|
||||
':profesor_id' => $profesor['profesor_id'],
|
||||
]
|
||||
);
|
||||
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
} 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;
|
||||
}
|
||||
@@ -78,13 +78,13 @@
|
||||
{{ JSON.parse(ruta.salon_array).splice(1).join('/') }}
|
||||
<span class="badge mx-3"
|
||||
v-if="ruta.horarios.some(({estado_supervisor_id}) => !estado_supervisor_id)"
|
||||
:class="{ 'badge-success': ruta.horarios.length > 0, 'badge-danger': ruta.horarios.length == 0 }">
|
||||
:class="{ 'badge-success': ruta.horarios.length > 0 || ruta.reposiciones.length > 0, 'badge-danger': ruta.horarios.length == 0 }">
|
||||
{{ ruta.horarios.filter(({estado_supervisor_id}) => estado_supervisor_id).length
|
||||
}} / {{
|
||||
ruta.horarios.length }}
|
||||
</span>
|
||||
<span v-else class="badge mx-3"
|
||||
:class="{ 'badge-success': ruta.horarios.length > 0, 'badge-danger': ruta.horarios.length == 0 }">
|
||||
:class="{ 'badge-success': ruta.horarios.length > 0 || ruta.reposiciones.length > 0, 'badge-danger': ruta.horarios.length == 0 }">
|
||||
|
||||
<i class="ing-aceptar"></i>
|
||||
</span>
|
||||
@@ -227,7 +227,16 @@
|
||||
</button>
|
||||
</div>
|
||||
<td class="text-center align-middle">
|
||||
{{ clase.reposicion_hora?.slice(0, 5) }} - {{ clase.reposicion_fin?.slice(0, 5) }}
|
||||
<fieldset>
|
||||
<legend>Hora de la reposición</legend>
|
||||
{{ clase.reposicion_hora?.slice(0, 5) }} - {{ clase.reposicion_fin?.slice(0, 5)
|
||||
}}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Horario original</legend>
|
||||
{{ clase.horario_hora?.slice(0, 5) }} - {{ clase.horario_fin?.slice(0, 5) }} el
|
||||
día {{clase.registro_fecha_ideal}}
|
||||
</fieldset>
|
||||
</td>
|
||||
<td class="text-center align-middle text-nowrap">
|
||||
<!-- data-toggle="button" -->
|
||||
@@ -534,6 +543,11 @@
|
||||
icon: "ing-justificar",
|
||||
id: 4,
|
||||
},
|
||||
{
|
||||
color: "primary",
|
||||
icon: "ing-ubicacion",
|
||||
id: 5,
|
||||
}
|
||||
];
|
||||
|
||||
const messages = PetiteVue.reactive({
|
||||
@@ -579,8 +593,8 @@
|
||||
this.rutas.selected = index;
|
||||
},
|
||||
order() {
|
||||
const finals = this.rutas.data.filter(ruta => ruta.horarios.length > 0 && ruta.horarios.every(horario => horario.estado_supervisor_id));
|
||||
const lasts = this.rutas.data.filter(ruta => ruta.horarios.length == 0);
|
||||
const finals = this.rutas.data.filter((ruta => ruta.horarios.length > 0 && ruta.horarios.every(horario => horario.estado_supervisor_id)) || (ruta => ruta.reposiciones.length > 0 && ruta.reposiciones.every(reposicion => reposicion.estado_supervisor_id)));
|
||||
const lasts = this.rutas.data.filter(ruta => ruta.horarios.length == 0 && ruta.reposiciones.length == 0);
|
||||
const notLasts = this.rutas.data.filter(ruta => ruta.horarios.some(horario => !horario.estado_supervisor_id));
|
||||
this.rutas.data = [...notLasts, ...finals, ...lasts];
|
||||
},
|
||||
@@ -695,7 +709,6 @@
|
||||
return clases;
|
||||
},
|
||||
get reposiciones() {
|
||||
console.log('Rutas: ', store.rutas.data, store.rutas.selected);
|
||||
const reposiciones = store.rutas.data.find(ruta => ruta.salon_id == store.rutas.selected)?.reposiciones ?? [];
|
||||
return reposiciones;
|
||||
},
|
||||
@@ -710,7 +723,9 @@
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(store.rutas.data.map(ruta => ruta.horarios).flat(1).filter(clase => clase.pendiente).map(clase => ({
|
||||
body: JSON.stringify(store.rutas.data.map(ruta => ruta.horarios).flat(1).filter((clase, index, self) => clase.pendiente &&
|
||||
self.findIndex(c => c.horario_id == clase.horario_id && c.profesor_id == clase.profesor_id) === index
|
||||
).map(clase => ({
|
||||
horario_id: clase.horario_id,
|
||||
estado: clase.estado_supervisor_id,
|
||||
profesor_id: clase.profesor_id,
|
||||
@@ -758,14 +773,16 @@
|
||||
this.loading = true;
|
||||
this.header = `Cargando rutas para ${this.catálogo_rutas.data.find(ruta => ruta.id_espacio_sgu == id_espacio_sgu).salon}`;
|
||||
this.catálogo_rutas.selected = id_espacio_sgu;
|
||||
const url = 'action/rutas_salón_horario.php'
|
||||
const url = 'action/rutas_salón_horario.php';
|
||||
// obtener parámetros del url
|
||||
const searchParams = new URLSearchParams({
|
||||
id_espacio_sgu: id_espacio_sgu,
|
||||
bloque_horario_id: store.bloquesHorario.data[store.bloquesHorario.selected].id
|
||||
bloque_horario_id: store.bloquesHorario.data[store.bloquesHorario.selected].id,
|
||||
fecha: new URL(document.location).searchParams.get('fecha') ?? null,
|
||||
});
|
||||
try {
|
||||
const rutas = await fetch(`${url}?${searchParams}`).then(res => res.json());
|
||||
store.rutas.data = rutas.filter(ruta => ruta.horarios.length > 0);
|
||||
store.rutas.data = rutas.filter(ruta => ruta.horarios.length > 0 || ruta.reposiciones.length > 0);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.header = `Error al cargar rutas`;
|
||||
@@ -787,7 +804,7 @@
|
||||
|
||||
},
|
||||
get clase_vista() {
|
||||
if (!store.profesor_selected.horario_id || !(store.profesor_selected.profesor_id >= 0) )
|
||||
if (!store.profesor_selected.horario_id || !(store.profesor_selected.profesor_id >= 0))
|
||||
return false;
|
||||
|
||||
return store.profesor_selected.es_reposicion
|
||||
|
||||
28
usuarios.php
28
usuarios.php
@@ -10,8 +10,7 @@ if ($user->acceso == null) {
|
||||
} else {
|
||||
$user->print_to_log('Usuarios');
|
||||
}
|
||||
$fac = $user->facultad['facultad_id'] ?? null;
|
||||
#echo $fac;
|
||||
$fac = isset($_POST['facultad']) ? $_POST['facultad'] ?: null : null;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -85,6 +84,10 @@ $fac = $user->facultad['facultad_id'] ?? null;
|
||||
->orderBy('facultad_nombre', 'asc')
|
||||
->get('facultad');
|
||||
}
|
||||
|
||||
$facultades = $db
|
||||
->orderBy('facultad_nombre', 'asc')
|
||||
->get('facultad');
|
||||
?>
|
||||
<main class="content marco">
|
||||
<?php if (($_GET['error'] ?? null) == 2) { ?>
|
||||
@@ -135,6 +138,23 @@ $fac = $user->facultad['facultad_id'] ?? null;
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="filter_facultad" class="col-4 col-form-label">Facultad</label>
|
||||
<div class="col-8">
|
||||
<select id="filter_facultad" name="facultad" class="form-control" <?php if ($user->facultad['facultad_id']) { ?> disabled <?php } ?>>
|
||||
<option value="">Mostrar todas</option>
|
||||
<?php foreach ($facultades as $facultad) { ?>
|
||||
<option value="<?php echo $facultad['facultad_id']; ?>" <?php if (isset($_POST['facultad']) && $_POST['facultad'] == $facultad['facultad_id']) {
|
||||
echo 'selected';
|
||||
} ?>>
|
||||
<?php echo $facultad['facultad_nombre']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<lab el for="filter_rol" class="col-4 col-form-label">Rol</label>
|
||||
<div class="col-8">
|
||||
@@ -157,7 +177,6 @@ $fac = $user->facultad['facultad_id'] ?? null;
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</di v>
|
||||
<div class="form-group row">
|
||||
<div class="col-12 text-center">
|
||||
<button type="submit" class="btn btn-outline-primary">
|
||||
@@ -221,6 +240,9 @@ $fac = $user->facultad['facultad_id'] ?? null;
|
||||
<td class="text-center icono-acciones">
|
||||
<a href="#" data-toggle="modal" data-target="#modal" data-tipo="2" title="Editar"><span
|
||||
class="ing-editar ing-fw"></span></a>
|
||||
<a href="action/action_usuarios_delete.php?id=<?= $usuario['id'] ?>" title="Eliminar"
|
||||
onclick="return confirm('¿Estás seguro de que deseas eliminar este usuario?')"><span
|
||||
class="ing-borrar ing-fw"></span></a>
|
||||
</td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user