Commit Bulk
This commit is contained in:
@@ -24,8 +24,16 @@ try {
|
||||
fechas AS (
|
||||
SELECT fechas_clase(h.horario_id) as registro_fecha_ideal, h.horario_id
|
||||
FROM horarios h
|
||||
),
|
||||
sin_registro AS (
|
||||
SELECT * FROM ESTADO_SUPERVISOR WHERE (estado_color, estado_icon) = ('dark', 'ing-cancelar')
|
||||
)
|
||||
SELECT estado_supervisor.*, usuario.*, registro.*, profesor.*, horarios.*, fechas.*,
|
||||
SELECT
|
||||
usuario.*, registro.*, profesor.*, horarios.*, fechas.*,
|
||||
coalesce(estado_supervisor.estado_supervisor_id, sin_registro.estado_supervisor_id) as estado_supervisor_id,
|
||||
coalesce(estado_supervisor.nombre, sin_registro.nombre) as nombre,
|
||||
coalesce(estado_supervisor.estado_color, sin_registro.estado_color) as estado_color,
|
||||
coalesce(estado_supervisor.estado_icon, sin_registro.estado_icon) as estado_icon,
|
||||
justificador.usuario_nombre as justificador_nombre,
|
||||
justificador.usuario_clave as justificador_clave,
|
||||
facultad.facultad_nombre as justificador_facultad,
|
||||
@@ -36,6 +44,7 @@ try {
|
||||
JOIN profesor using (profesor_id)
|
||||
LEFT JOIN registro USING (horario_id, registro_fecha_ideal, profesor_id)
|
||||
LEFT join estado_supervisor using (estado_supervisor_id)
|
||||
CROSS JOIN sin_registro
|
||||
LEFT JOIN USUARIO ON USUARIO.usuario_id = REGISTRO.supervisor_id
|
||||
LEFT JOIN USUARIO JUSTIFICADOR ON JUSTIFICADOR.usuario_id = REGISTRO.justificador_id
|
||||
LEFT JOIN ROL on ROL.rol_id = justificador.rol_id
|
||||
|
||||
@@ -1,35 +1,56 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
<?
|
||||
#input $_GET['id_espacio_sgu']
|
||||
#output rutas: [ ...ruta, salones: [{...salon}] ]
|
||||
header('Content-Type: application/json charset=utf-8');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php");
|
||||
|
||||
extract($_POST);
|
||||
|
||||
$dias = array("domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado");
|
||||
$horarios = $db
|
||||
->get("fs_horario($periodo, $carrera, '$grupo', true)");
|
||||
|
||||
// get each id from $horarios (might be duplicate)
|
||||
|
||||
try {
|
||||
$horarios = array_map(function ($horario) use ($dias, $db) {
|
||||
$horario['profesores'] = array_map(
|
||||
fn ($profesor) =>
|
||||
$db->where("id", $profesor)->getOne("fs_profesor"),
|
||||
explode(",", substr($horario['profesores'], 1, -1))
|
||||
);
|
||||
$horario['dia'] = $dias[$horario['dia']];
|
||||
return $horario;
|
||||
}, $horarios);
|
||||
} catch (Exception $e) {
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"message" => $e->getMessage(),
|
||||
]));
|
||||
require_once $ruta . "class/c_login.php";
|
||||
if (!isset($_SESSION['user'])) {
|
||||
http_response_code(401);
|
||||
die(json_encode(['error' => 'unauthorized']));
|
||||
}
|
||||
?>
|
||||
<?= json_encode([
|
||||
"status" => "success",
|
||||
"horario" => $horarios,
|
||||
]) ?>
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
// check method
|
||||
try {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if (!isset($_GET['profesor_id'])) {
|
||||
throw new Exception('missing parameters');
|
||||
}
|
||||
$data = $db->query(
|
||||
"SELECT *, (EXTRACT(EPOCH FROM (horario_fin - horario_hora) ) / EXTRACT(EPOCH FROM interval '15 minute'))::INT AS bloques
|
||||
FROM horario_view
|
||||
JOIN horario_profesor ON horario_profesor.horario_id = horario_view.horario_id
|
||||
WHERE horario_profesor.profesor_id = :profesor_id
|
||||
AND (facultad_id = :facultad_id OR :facultad_id IS NULL)",
|
||||
[
|
||||
'profesor_id' => $_GET['profesor_id'],
|
||||
'facultad_id' => $user->facultad['facultad_id'],
|
||||
]
|
||||
);
|
||||
|
||||
$last_query = [
|
||||
'query' => $db->getLastQuery(),
|
||||
];
|
||||
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
throw new Exception('invalid method');
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ if (!isset($_SESSION['user']))
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
if (!$user->admin && ($access = $user->access('asistencia')) == 'n')
|
||||
if (($access = $user->access('asistencia')) == 'n')
|
||||
die(json_encode(['error' => true]));
|
||||
|
||||
$user->print_to_log('Consultar materias');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
global $db;
|
||||
if(isset($_POST['lectura']))
|
||||
$ver = $_POST['lectura'];
|
||||
if(isset($_POST['editar']))
|
||||
@@ -10,30 +10,26 @@
|
||||
$edit_separado = explode("_", $edit);
|
||||
$completo[]=$edit_separado;
|
||||
}
|
||||
#echo "<br><br><br><br>";
|
||||
#print_r($ver);
|
||||
#print_r($editar);
|
||||
query("SELECT fd_permiso()", null, false);
|
||||
$db->query("SELECT fd_permiso()");
|
||||
foreach($ver as $lectura){
|
||||
$igual=false;
|
||||
$ver_separado = explode("_", $lectura);
|
||||
#print_r($ver_separado);
|
||||
foreach($completo as $comp){
|
||||
if($ver_separado[0] == $comp[0] && $ver_separado[1] == $comp[1]){
|
||||
#echo " igual";
|
||||
$igual=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#echo "<br>";
|
||||
if(!$igual)
|
||||
$completo[]=$ver_separado;
|
||||
}
|
||||
#print_r($completo);
|
||||
foreach($completo as $actual){
|
||||
$sql = "SELECT fi_permiso(:pagina, :rol, :tipo)";
|
||||
$params = [':pagina' => $actual['0'], ':rol' => $actual['1'], ':tipo' => $actual['2']];
|
||||
query($sql, $params, false);
|
||||
|
||||
$db->insert('permiso', [
|
||||
'pagina_id' => $actual['0'],
|
||||
'rol_id' => $actual['1'],
|
||||
'permiso_tipo' => $actual['2'],
|
||||
]);
|
||||
}
|
||||
header("Location: ../permisos.php");
|
||||
exit();
|
||||
|
||||
@@ -1,14 +1,57 @@
|
||||
<?php
|
||||
<?
|
||||
#input $_GET['id_espacio_sgu']
|
||||
#output rutas: [ ...ruta, salones: [{...salon}] ]
|
||||
header('Content-Type: application/json charset=utf-8');
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php");
|
||||
require_once $ruta . "class/c_login.php";
|
||||
if (!isset($_SESSION['user'])) {
|
||||
http_response_code(401);
|
||||
die(json_encode(['error' => 'unauthorized']));
|
||||
}
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
extract($_GET);
|
||||
// check method
|
||||
try {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$data = $db->query(
|
||||
"SELECT DISTINCT profesor.*
|
||||
FROM profesor
|
||||
JOIN horario_profesor using (profesor_id)
|
||||
JOIN horario using (horario_id)
|
||||
JOIN materia using (materia_id)
|
||||
JOIN carrera using (carrera_id)
|
||||
WHERE carrera.facultad_id = :facultad_id OR :facultad_id IS NULL
|
||||
ORDER BY profesor.profesor_nombre",
|
||||
array(
|
||||
":facultad_id" => $user->facultad['facultad_id']
|
||||
)
|
||||
);
|
||||
|
||||
$profesores = $db
|
||||
->where("facultad_id", $facultad ?? 0)
|
||||
->get("fs_profesor");
|
||||
$last_query = [
|
||||
'query' => $db->getLastQuery(),
|
||||
];
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"profesores" => $profesores
|
||||
]);
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
http_response_code(405);
|
||||
echo json_encode(['error' => 'method not allowed']);
|
||||
exit;
|
||||
}
|
||||
} catch (PDOException $th) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => $th->getMessage(),
|
||||
'query' => $db->getLastQuery(),
|
||||
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR);
|
||||
exit;
|
||||
} catch (Exception $th) {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => $th->getMessage(),
|
||||
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
exit;
|
||||
}
|
||||
@@ -1,22 +1,26 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
if(isset($_POST['dlfacultad']))
|
||||
$facultad=$_POST['dlfacultad'];
|
||||
else
|
||||
$facultad=$_POST['mfacultad'];
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $db;
|
||||
if (isset($_POST['dlfacultad']))
|
||||
$facultad = $_POST['dlfacultad'];
|
||||
else
|
||||
$facultad = $_POST['mfacultad'];
|
||||
|
||||
$hecho = query("SELECT * FROM fs_usuario WHERE clave = :clave", [':clave' => $_POST['mclave']], true);
|
||||
if(!$hecho){
|
||||
$sql = "SELECT fi_usuario(:nombre, :correo, :clave, :rol, :facultad)";
|
||||
$params = [':nombre' => mb_strtoupper($_POST['mnombre']), ':correo' => $_POST['mcorreo'], ':clave' => $_POST['mclave'], ':rol' => $_POST['mrol'], ':facultad' => $facultad];
|
||||
$hecho = query($sql, $params, true);
|
||||
header("Location: ../usuarios.php", true, 307);
|
||||
exit();
|
||||
}
|
||||
else{
|
||||
header("Location: ../usuarios.php?error=1");
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
if ($db->where('usuario_clave', $_POST['mclave'])->has('usuario')) {
|
||||
header("Location: ../usuarios.php?error=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
$db->insert('usuario', [
|
||||
'usuario_nombre' => mb_strtoupper($_POST['mnombre']),
|
||||
'usuario_correo' => $_POST['mcorreo'],
|
||||
'usuario_clave' => $_POST['mclave'],
|
||||
'rol_id' => $_POST['mrol'] ?? null,
|
||||
'facultad_id' => empty($facultad) ? null : $facultad,
|
||||
]);
|
||||
|
||||
header("Location: ../usuarios.php", true, 307);
|
||||
26
action/asistenciasprofesor_select.php
Normal file
26
action/asistenciasprofesor_select.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
if(!isset($_POST["id"]) || !isset($_POST["hor"])){
|
||||
$return["error"] = "Error! No se recibió la información del usuario.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "hor", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
$rs = $db->query('SELECT * from fs_asistenciaprofesor_horario(:id, :hor)', [':id' => $id, ':hor' => $hor]);
|
||||
$asistArr = array();
|
||||
|
||||
foreach($rs as $row){
|
||||
$asistArr[] = $row["registro_fecha_ideal"];
|
||||
}
|
||||
$return["asistenciaArr"] = $asistArr;
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
98
action/reposicion_autoriza.php
Normal file
98
action/reposicion_autoriza.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
Cambia de estado la 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']);
|
||||
|
||||
$pag = "../reposiciones_autorizar.php";
|
||||
|
||||
|
||||
|
||||
if(!isset($_POST["id"]) || !isset($_POST["edo"]) ){
|
||||
header("Location: ".$pag."?error=0");
|
||||
exit();
|
||||
}
|
||||
|
||||
$id_repo = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$edo = filter_input(INPUT_POST, "edo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
$salon = trim(filter_input(INPUT_POST, "salon", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
|
||||
|
||||
$motivo = "";
|
||||
if(isset($_POST["motivo"]) && $_POST["motivo"] != "")
|
||||
$motivo = trim($_POST["motivo"]);
|
||||
|
||||
if($edo == 4){//cancelación
|
||||
$db->querySingle('SELECT fu_reposicion_cancela(:id, :motivo)',
|
||||
[':id' => $id_repo, ':motivo' => $motivo]
|
||||
);
|
||||
}else{
|
||||
if(!empty($salon)){
|
||||
$db->querySingle('SELECT fu_reposicion(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':sal' => $salon, ':edo' => $edo]
|
||||
);
|
||||
}else{
|
||||
$db->querySingle('SELECT fu_reposicion(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)',
|
||||
[':id' => $id_repo, ':edo' => $edo]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Obtener datos del usuario que creó la reposición y mandar correo
|
||||
/*$stmt = $pdo->prepare('Select * from fs_reposicion(:id, :periodo, NULL, NULL, NULL, NULL, NULL, 0, 1)');
|
||||
$stmt->bindParam(":id", $id_repo);
|
||||
$stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
|
||||
if(!$stmt->execute()){
|
||||
header("Location:".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$rs = $stmt->fetch();
|
||||
$stmt->closeCursor();
|
||||
$stmt = null;
|
||||
|
||||
$stmt = $pdo->prepare('Select * from fs_contacto(:usr, 3, NULL)');//3 = correo
|
||||
$stmt->bindParam(":usr", $rs["Usuario_id"]);
|
||||
if(!$stmt->execute()){
|
||||
header("Location:".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$correos_rs = $stmt->fetchAll();
|
||||
$stmt->closeCursor();
|
||||
$stmt = null;
|
||||
|
||||
$correoList = "";
|
||||
foreach($correos_rs as $c){
|
||||
if($c.substr("lasallistas.org,mx",0) || $c.substr("lasalle.mx",0)){
|
||||
$correoList .= $c.";";
|
||||
}
|
||||
}
|
||||
|
||||
//$correoHTML = "<p>Se aprobó la reposición para el <b> a las </b> en el salón <b></b>.</p>";
|
||||
*/
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
if($edo == 4){
|
||||
$desc_log = "Cancela reposición ID[".$id_repo."] edo[".$edo."]";
|
||||
$ok = 2;
|
||||
}else{
|
||||
$desc_log = "Autoriza reposición ID[".$id_repo."] edo[".$edo."] Salon[".(empty($salon)?"":$salon)."]";
|
||||
$ok = 0;
|
||||
if($edo == 3){
|
||||
$ok = 1;
|
||||
//if($correoList!= "")
|
||||
//Mailer::enviarCorreo($correoList , "Reposición autorizada", $correoHTML);
|
||||
}
|
||||
}
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
|
||||
*/
|
||||
header("Location: ".$pag."?ok=".$ok);
|
||||
exit();
|
||||
?>
|
||||
33
action/reposicion_delete.php
Normal file
33
action/reposicion_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"], $_POST["prof"])){
|
||||
$return["error"] = "Error! No se recibió la información necesaria.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$prof = $user["id"];
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fd_reposicion(:id, :prof)', [":id"=> $id, ":prof"=>$prof]);
|
||||
$return["ok"] = "La reposición se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al borrar la reposición.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
124
action/reposicion_insert.php
Normal file
124
action/reposicion_insert.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/*
|
||||
* Inserta 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']);
|
||||
|
||||
|
||||
$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "horario", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio
|
||||
$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
||||
|
||||
if(empty($_POST["prof"]))
|
||||
$prof = $user["id"];
|
||||
else
|
||||
$prof = filter_input(INPUT_POST, "prof", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
//if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
//$salon = trim(filter_input(INPUT_POST, "salon", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
//-- Obtiene datos de horario regular de clase
|
||||
$horario_rs = $db->querySingle('SELECT * from fs_horario_basic where id = :hor',
|
||||
[':hor' => $hor]
|
||||
);
|
||||
|
||||
$materia = $horario_rs["materia_id"];
|
||||
$gpo = $horario_rs["grupo"];
|
||||
$duracion = $horario_rs["duracion_total"];
|
||||
$dia = $horario_rs["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 H:i:00", strtotime($fecha_new.' + '.$duracion.' minute'));
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
$fecha_falta = DateTime::createFromFormat('d/m/Y', $fecha_falta)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_falta));
|
||||
}else{
|
||||
$fecha_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_cambio));
|
||||
}
|
||||
|
||||
|
||||
//Valida que tenga clase en la fecha de falta
|
||||
if(intval($dia) != intval($dia_falta)){
|
||||
//header("Location:".$pag."?error=11");
|
||||
echo intval($dia)." != ".intval($dia_falta);
|
||||
exit();
|
||||
}
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia_new, $hora, $materia, "-", $fecha_new, $fecha_fin_new, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
*/
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo
|
||||
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
|
||||
[':prof' => $prof, ':fecha'=>$fecha_falta, ':hora'=>$hora, ':dur'=>$duracion]
|
||||
)["traslape_profesor_reposicion"];
|
||||
if($traslape){
|
||||
header("Location:".$pag."?error=9");
|
||||
exit();
|
||||
}
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fi_reposicion(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_falta.">".$fecha_new."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
|
||||
|
||||
}else{//Cambio salón / hora
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fi_reposicion(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_cambio.">".$fecha_cambio_nueva."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
header("Location: ".$pag."?ok=0");
|
||||
exit();
|
||||
?>
|
||||
64
action/reposicion_select.php
Normal file
64
action/reposicion_select.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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{
|
||||
$rs = $db->querySingle('SELECT * from fs_reposicion(:id, NULL, NULL, NULL, 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);
|
||||
}
|
||||
|
||||
|
||||
$return["fecha_clase"] = date('d/m/Y', strtotime($rs["fecha_clase"]));
|
||||
$return["fecha_nueva"] = date('d/m/Y', strtotime($rs["fecha_nueva"]));
|
||||
$hora_nueva = explode(":",$rs["hora_nueva"]);
|
||||
$return["hora_ini"] = $hora_nueva[0];
|
||||
$return["min_ini"] = $hora_nueva[1];
|
||||
$hora_nueva_fin = explode(":",$rs["hora_nueva_fin"]);
|
||||
$return["hora_fin"] = $hora_nueva_fin[0];
|
||||
$return["min_fin"] = $hora_nueva_fin[1];
|
||||
$return["duracion"] = $rs["duracion_total"];
|
||||
|
||||
// $return["carrera"] = $rs["PlanEstudio_desc"];
|
||||
$return["horario"] = $rs["horario_id"];
|
||||
$return["materia"] = $rs["materia_id"];
|
||||
$return["materia_desc"] = $rs["materia_nombre"];
|
||||
$return["salon"] = $rs["salon_id"];
|
||||
$return["salon_desc"] = $rs["Salon_desc"]=="" ? "-Pendiente-": $rs["Salon_desc"];
|
||||
$return["grupo"] = $rs["horario_grupo"];
|
||||
$return["profesor"] = $rs["profesor_id"];
|
||||
$return["profesor_nombre"] = $rs["profesor_nombre"];
|
||||
$return["comentario"] = $rs["descripcion"];
|
||||
$return["alumnos"] = $rs["alumnos"];
|
||||
$return["tipo"] = $rs["es_reposicion"];
|
||||
$return["aula"] = $rs["tipoaula_id"];
|
||||
$return["aula_desc"] = $rs["tipoaula_nombre"];
|
||||
$return["aula_supervisor"] = $rs["tipoaula_supervisor"];
|
||||
$return["dia"] = date('w', strtotime($rs["fecha_clase"]));
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
121
action/reposicion_update.php
Normal file
121
action/reposicion_update.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Actualiza reposición
|
||||
*/
|
||||
$pag = "../reposiciones_crear.php";
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
|
||||
/*if(!isset($_POST["id"]) || !isset($_POST["fecha_falta"]) || !isset($_POST["fecha_inicial"]) || !isset($_POST["hora_ini"]) || !isset($_POST["min_ini"]) || !isset($_POST["materia"]) || !isset($_POST["grupo"])){
|
||||
header("Location: ".$pag."?error=0");
|
||||
exit();
|
||||
}*/
|
||||
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$fecha_falta = trim(filter_input(INPUT_POST, "fecha_falta", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
|
||||
$fecha = trim(filter_input(INPUT_POST, "fecha_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
|
||||
$fecha_cambio = trim(filter_input(INPUT_POST, "fecha_cambio", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
|
||||
$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$hor = filter_input(INPUT_POST, "horario", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
$prof = $_SESSION["usuario_id"];
|
||||
//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(filter_input(INPUT_POST, "comentario", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//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
|
||||
$comentario = trim(filter_input(INPUT_POST, "comentario", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
|
||||
|
||||
$horario_rs = $db->querySingle('SELECT * from fs_horario_basic where id = :hor',
|
||||
[':hor' => $hor]
|
||||
);
|
||||
|
||||
$materia = $horario_rs["materia_id"];
|
||||
$gpo = $horario_rs["grupo"];
|
||||
$duracion = $horario_rs["duracion_total"];
|
||||
$dia = $horario_rs["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 H:i:00", strtotime($fecha_new.' + '.$duracion.' minute'));
|
||||
$dia_new = date('w', strtotime($fecha_new));
|
||||
|
||||
echo $fecha_new."<br>";
|
||||
echo $fecha_fin_new."<br>";
|
||||
if($tipo == 1){//Reposición
|
||||
$fecha_falta = DateTime::createFromFormat('d/m/Y', $fecha_falta)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_falta));
|
||||
}else{
|
||||
$fecha_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_cambio));
|
||||
}
|
||||
|
||||
//Valida que tenga clase en la fecha de falta
|
||||
if(intval($dia) != intval($dia_falta)){
|
||||
//header("Location:".$pag."?error=11");
|
||||
echo intval($dia)." != ".intval($dia_falta);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia, $hora, $materia, "-", $fecha_ini, $fecha_fin, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo
|
||||
*/
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
|
||||
[':prof' => $prof, ':fecha'=>$fecha_falta, ':hora'=>$hora, ':dur'=>$duracion]
|
||||
)["traslape_profesor_reposicion"];
|
||||
if($traslape){
|
||||
header("Location:".$pag."?error=9");
|
||||
exit();
|
||||
}
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fu_reposicion(:id, :f_falta, :f_nueva, :hora_nueva, NULL, 1, :desc, :alumnos, true, :aula)',
|
||||
[':id'=> $id, ':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
header("Location: ".$pag."?error=2");
|
||||
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);*/
|
||||
}else{
|
||||
|
||||
try{
|
||||
$db->query('SELECT * from fu_reposicion(:id, :f_falta, :f_nueva, :hora_nueva, NULL, 1, :desc, :alumnos, true, :aula)',
|
||||
[':id'=> $id, ':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora,
|
||||
':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
header("Location: ".$pag."?error=2");
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
header("Location: ".$pag);
|
||||
exit();
|
||||
?>
|
||||
Reference in New Issue
Block a user