216 lines
10 KiB
PHP
216 lines
10 KiB
PHP
<?php
|
|
/*
|
|
* Inserta reposición
|
|
*/
|
|
$pag = "../reposiciones_crear.php";
|
|
$ruta = "../";
|
|
require_once "../class/c_login.php";
|
|
require_once "../class/mailer.php";
|
|
|
|
define("COORDINADOR", 9);
|
|
define("ENVIO_CORREOS", true);
|
|
|
|
// check if the session is started
|
|
if (!isset($_SESSION['user']))
|
|
die('No se ha iniciado sesión');
|
|
|
|
$user = unserialize($_SESSION['user']);
|
|
//$user->access();
|
|
|
|
$estado = filter_input(INPUT_POST, "estado", FILTER_SANITIZE_NUMBER_INT);//
|
|
$tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//
|
|
$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion
|
|
$bloque = filter_input(INPUT_POST, "bloque", FILTER_SANITIZE_NUMBER_INT);//
|
|
$ciclo = filter_input(INPUT_POST, "ciclo", FILTER_SANITIZE_NUMBER_INT);//
|
|
$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//Reposicion
|
|
$fecha = trim(htmlspecialchars($_POST["fecha_nueva"], 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
|
|
$horario = filter_input(INPUT_POST, "horario", 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
|
|
$salon = NULL;
|
|
|
|
if(!$user->jefe_carrera){//coordinador
|
|
if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
|
$salon = filter_input(INPUT_POST, "dlSalon", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad
|
|
}
|
|
|
|
if(empty($_POST["prof"]))
|
|
$prof = $user->user["id"];
|
|
else
|
|
$prof = filter_input(INPUT_POST, "prof", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
|
|
|
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
|
|
|
|
|
|
|
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
|
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
|
|
|
//-- Obtiene datos de horario regular de clase
|
|
if($horario!= null && $tipo !=3)
|
|
{
|
|
$horario_rs = $db->querySingle('SELECT * from horario_view where horario_id = :hor',
|
|
[':hor' => $horario]
|
|
);
|
|
|
|
$materia = $horario_rs["materia_id"];
|
|
$dia = $horario_rs["horario_dia"];
|
|
$hora_orig = $horario_rs["horario_hora"];
|
|
}else{
|
|
$dia = date('w', strtotime($fecha));
|
|
}
|
|
|
|
$hora = $hora_ini.":".$min_ini.":00";
|
|
|
|
switch($tipo){
|
|
case 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));
|
|
|
|
//Valida que tenga clase en la fecha de falta
|
|
if(intval($dia) != intval($dia_falta)){
|
|
header("Location:".$pag."?error=11");
|
|
/*print_r($_POST);
|
|
echo 'SELECT * from horario_view where horario_id = '.$horario;
|
|
echo intval($dia)." != ".intval($dia_falta);*/
|
|
exit();
|
|
}
|
|
$fecha_nueva = date('d/m/Y', strtotime($fecha_new));
|
|
$fecha_clase = date('d/m/Y', strtotime($fecha_falta));
|
|
break;
|
|
case 2://Cambio
|
|
$fecha_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
|
$dia_falta = date('w', strtotime($fecha_cambio));
|
|
$fecha_nueva = date('d/m/Y', strtotime($fecha_cambio));
|
|
break;
|
|
case 3://Solicitud de espacio
|
|
$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_nueva = date('d/m/Y', strtotime($fecha_new));
|
|
break;
|
|
case 4://Cambio permanente
|
|
$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_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
|
$dia_falta = date('w', strtotime($fecha_cambio));
|
|
|
|
$fecha_nueva = date('d/m/Y', strtotime($fecha_new));
|
|
$fecha_clase = date('d/m/Y', strtotime($fecha_cambio));
|
|
break;
|
|
}
|
|
|
|
if($materia!= null && $tipo !=3){
|
|
//Obtiene materia
|
|
$materia_rs = $db->querySingle('SELECT materia_nombre from materia where materia_id = :mat',[':mat' => $materia]);
|
|
}
|
|
|
|
|
|
switch($tipo){
|
|
case 1://Reposición
|
|
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
|
|
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo]
|
|
)["traslape_profesor_reposicion"];
|
|
if($traslape){
|
|
//print_r($_POST);
|
|
//echo "SELECT * from traslape_profesor_reposicion($prof,'".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."' , '$hora', $duracion)";
|
|
header("Location:".$pag."?error=9");
|
|
exit();
|
|
}
|
|
|
|
$db_params=[
|
|
":f_falta"=>$fecha_falta, ":f_nueva"=>$fecha_new, ":hora_nueva"=>$hora, ":prof"=>$prof, ":desc"=>$comentario,
|
|
":edo"=>1, ":alumnos"=>$alumnos, ":aula"=>$aula, ":solicitudtipo"=>$tipo, ":usr"=>$user->user["id"],
|
|
":duracion"=>$duracion_tiempo, ":hor"=>$horario, ":bloque"=>$bloque, ":ciclo"=>$ciclo
|
|
];
|
|
$asunto = "Solicitud - Reposición nueva";
|
|
$texto = "<p>Se creó un cambio de salón nuevo.</p>";
|
|
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_falta." a las ".$hora_orig." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora." hrs.</b>";
|
|
|
|
/*
|
|
$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[".$horario."] Alumnos[".$alumnos."]";
|
|
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
|
break;
|
|
case 2:
|
|
$db_params=[
|
|
":f_falta"=>$fecha_cambio, ":f_nueva"=>$fecha_cambio, ":hora_nueva"=>$hora, ":prof"=>$prof, ":desc"=>$comentario,
|
|
":edo"=>1, ":alumnos"=>$alumnos, ":aula"=>$aula, ":solicitudtipo"=>$tipo, ":usr"=>$user->user["id"],
|
|
":duracion"=>$duracion_tiempo, ":hor"=>$horario, ":bloque"=>$bloque, ":ciclo"=>$ciclo
|
|
];
|
|
$asunto = "Solicitud - Cambio de salón";
|
|
$texto = "<p>Se creó una solicitud de cambio de salón nuevo.</p>";
|
|
$texto .= "<p>El día <b>".$fecha_nueva." a las ".$hora." hrs. </b>";
|
|
|
|
/*
|
|
$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[".$horario."] Alumnos[".$alumnos."]";
|
|
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
|
|
*/
|
|
break;
|
|
case 3:
|
|
$db_params=[
|
|
":f_falta"=>null, ":f_nueva"=>$fecha_new, ":hora_nueva"=>$hora, ":prof"=>$prof, ":desc"=>$comentario,
|
|
":edo"=>1, ":alumnos"=>$alumnos, ":aula"=>$aula, ":solicitudtipo"=>$tipo, ":usr"=>$user->user["id"],
|
|
":duracion"=>$duracion_tiempo, ":hor"=>null, ":bloque"=>null, ":ciclo"=>null
|
|
];
|
|
$asunto = "Solicitud - Asignación de espacio";
|
|
$texto = "<p>Se creó una solicitud de asignación de salón nuevo.</p>";
|
|
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_nueva." a las ".$hora." hrs. </b>";
|
|
break;
|
|
case 4:
|
|
$db_params=[
|
|
":f_falta"=>$fecha_cambio, ":f_nueva"=>$fecha_new, ":hora_nueva"=>$hora, ":prof"=>$prof, ":desc"=>$comentario,
|
|
":edo"=>1, ":alumnos"=>$alumnos, ":aula"=>$aula, ":solicitudtipo"=>$tipo, ":usr"=>$user->user["id"],
|
|
":duracion"=>$duracion_tiempo, ":hor"=>$horario, ":bloque"=>$bloque, ":ciclo"=>$ciclo
|
|
];
|
|
$asunto = "Solicitud - Cambio permanente";
|
|
$texto = "<p>Se creó una solicitud de asignación de salón nuevo.</p>";
|
|
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_clase." a las ".$hora_orig." hrs. </b> se propone cambiar para el <b>".$fecha_nueva." a las ".$hora." hrs.</b>";
|
|
break;
|
|
|
|
}
|
|
try{
|
|
$db->query('SELECT * from fi_solicitud(:f_falta, :f_nueva, :hora_nueva, :prof, :desc, :edo, :alumnos, :aula, :solicitudtipo, :usr, :duracion, :hor, :bloque, :ciclo)',
|
|
$db_params);
|
|
}catch(Exception $e){
|
|
echo "ERROR Cambio<br>".$e->getMessage();
|
|
//header("Location: ".$pag."?error=1");
|
|
exit();
|
|
}
|
|
|
|
|
|
MandaCorreos::enviarCorreo($db, $asunto, $texto, $user->facultad["facultad_id"], MandaCorreos::COORDINADOR);
|
|
|
|
/*if($to!= "" && ENVIO_CORREOS){
|
|
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarlo.</p>";
|
|
$asunto = "Reposición nueva - solicitud";
|
|
//crear plantilla
|
|
$texto = '<body >
|
|
<img src="https://paad.lci.ulsa.mx/imagenes/logo_lasalle.png" alt="La Salle" style="margin-bottom:60px">
|
|
'.$texto.'
|
|
</body>';
|
|
|
|
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
|
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
|
$asunto = "PRUEBAS-".$asunto;
|
|
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
|
}else{
|
|
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
|
}
|
|
|
|
}*/
|
|
|
|
header("Location: ".$pag."?ok=0");
|
|
exit();
|
|
?>
|