Formato de solicitudes
This commit is contained in:
33
action/solicitud_delete.php
Normal file
33
action/solicitud_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_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]);
|
||||
$return["ok"] = "La solicitud se borró correctamente";
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al borrar la solicitud.";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
214
action/solicitud_insert.php
Normal file
214
action/solicitud_insert.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?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)
|
||||
{
|
||||
$horario_rs = $db->querySingle('SELECT * from horario_view where horario_id = :hor',
|
||||
[':hor' => $horario]
|
||||
);
|
||||
|
||||
$materia = $horario_rs["materia_id"];
|
||||
$dia = $horario_rs["horario_dia"];
|
||||
}else{
|
||||
$dia = date('w', strtotime($fecha));
|
||||
}
|
||||
|
||||
$hora = $hora_ini.":".$min_ini.":00";
|
||||
|
||||
|
||||
if($tipo == 2){//Cambio
|
||||
$fecha_cambio = DateTime::createFromFormat('d/m/Y', $fecha_cambio)->format('Y-m-d');
|
||||
$dia_falta = date('w', strtotime($fecha_cambio));
|
||||
}else{
|
||||
$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();
|
||||
}
|
||||
|
||||
//Obtiene materia
|
||||
$materia_rs = $db->querySingle('SELECT materia_nombre from materia where materia_id = :mat',[':mat' => $materia]);
|
||||
|
||||
//Obtiene correo
|
||||
$correos_rs = $db->querySingle('SELECT coor.usuario_correo, coor.usuario_nombre from usuario coor where rol_id = :rol_coord and facultad_id = (
|
||||
select coalesce(facultad_id,0) from usuario u where u.usuario_id = :id_usr) and coor.usuario_correo != \'\'',[':rol_coord' => COORDINADOR, ':id_usr' => $user->user["id"]]
|
||||
);
|
||||
if( count($correos_rs) > 0 ){
|
||||
$to = $correos_rs["usuario_correo"];
|
||||
}
|
||||
|
||||
if($tipo == 1){//Reposición
|
||||
// Valida que grupo no tenga clases
|
||||
/*$result = validaConflictoHoras($pdo, $gpo, $dia_new, $hora, $materia, "-", $fecha_new, $fecha_fin_new, $duracion);
|
||||
if($result != ""){//error
|
||||
//echo $result;
|
||||
header("Location:".$pag."?error=7");
|
||||
exit();
|
||||
}
|
||||
*/
|
||||
//Valida que profesor no este en 2 reposiciones al mismo tiempo en la fecha nueva
|
||||
|
||||
$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)',
|
||||
[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo]
|
||||
)["traslape_profesor_reposicion"];
|
||||
if($traslape){
|
||||
//print_r($_POST);
|
||||
//echo "SELECT * from traslape_profesor_reposicion($prof,'".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."' , '$hora', $duracion)";
|
||||
|
||||
header("Location:".$pag."?error=9");
|
||||
exit();
|
||||
}
|
||||
|
||||
try{
|
||||
if($user->jefe_carrera){//jefe
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':hor' => $horario,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo
|
||||
]
|
||||
);
|
||||
|
||||
}else{//coordinador
|
||||
echo 'SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo, '.$salon.')';
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo, :salon)',
|
||||
[':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':hor' => $horario,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo, ':salon'=>$salon
|
||||
]
|
||||
);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
|
||||
echo "ERROR Reposición<br>".$e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$fecha_clase = date('d/m/Y', strtotime($fecha_falta));
|
||||
$fecha_nueva = date('d/m/Y', strtotime($fecha_new));
|
||||
$texto = "<p>Se creó una reposición nueva.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_clase." a las ".$horario_rs["horario_hora"]." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora." hrs.</b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_falta.">".$fecha_new."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$horario."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/
|
||||
|
||||
|
||||
}else{//Cambio salón / hora
|
||||
|
||||
try{
|
||||
if($user->jefe_carrera){//jefe
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, false, :aula, :duracion, :usr, :bloque, :ciclo)',
|
||||
[':f_falta' => $fecha_cambio, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $horario,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo
|
||||
]
|
||||
);
|
||||
}else{//coordinador
|
||||
$db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, false, :aula, :duracion, :usr, :bloque, :ciclo, :salon)',
|
||||
[':f_falta' => $fecha_cambio, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $horario,
|
||||
':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"],
|
||||
':bloque' => $bloque, ':ciclo' => $ciclo, ':salon'=>$salon
|
||||
]
|
||||
);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
echo "ERROR Cambio<br>".$e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$texto = "<p>Se creó un cambio de salón nuevo.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_falta." a las ".$hora." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora." hrs.</b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarlo.</p>";
|
||||
|
||||
/*
|
||||
$log = new LogActividad();
|
||||
$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_cambio.">".$fecha_cambio_nueva."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$horario."] Alumnos[".$alumnos."]";
|
||||
$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
if($to!= "" && ENVIO_CORREOS){
|
||||
$asunto = "Reposición nueva - solicitud";
|
||||
//crear plantilla
|
||||
$texto = '<body >
|
||||
<img src="https://paad.lci.ulsa.mx/imagenes/logo_lasalle.png" alt="La Salle" style="margin-bottom:60px">
|
||||
'.$texto.'
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header("Location: ".$pag."?ok=0");
|
||||
exit();
|
||||
?>
|
||||
88
action/solicitud_select.php
Normal file
88
action/solicitud_select.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Obtiene datos de reposición
|
||||
*/
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die('No se ha iniciado sesión');
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
|
||||
//--- Objeto para validar usuario. El id de usuario lo lee desde sesión
|
||||
/*if(!$objSesion->tieneAcceso()){
|
||||
$return["error"] = "Error! No tienes permisos para realizar esta acción.";
|
||||
}else*/ if(!isset($_POST["id"])){
|
||||
$return["error"] = "Error! No se recibió la información de la reposición.";
|
||||
}else{
|
||||
$id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
|
||||
|
||||
try{
|
||||
if($user->rol["rol_id"] == 7){//es supervisor
|
||||
$rs = $db->querySingle('SELECT * from fs_solicitud(:id, NULL, NULL, NULL, NULL, NULL, NULL, :sup)',
|
||||
[':id' => $id, ':sup'=>$user->user["id"]]
|
||||
);
|
||||
}else{//coordinador
|
||||
$rs = $db->querySingle('SELECT * from fs_solicitud(:id, :fac, NULL, NULL, NULL, NULL, NULL, null)',
|
||||
[':id' => $id, ":fac"=>$user->facultad["facultad_id"] ]
|
||||
);
|
||||
}
|
||||
|
||||
}catch(Exception $e){
|
||||
$return["error"] = "Ocurrió un error al leer los datos de la reposición.";
|
||||
echo json_encode($return);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$return["fecha_clase"] = date('d/m/Y', strtotime($rs["fecha_clase"]));
|
||||
$return["fecha_nueva"] = date('d/m/Y', strtotime($rs["fecha_nueva"]));
|
||||
$hora_nueva = explode(":",$rs["hora_nueva"]);
|
||||
$return["hora_ini"] = $hora_nueva[0];
|
||||
$return["min_ini"] = $hora_nueva[1];
|
||||
$hora_nueva_fin = explode(":",$rs["hora_nueva_fin"]);
|
||||
$return["hora_fin"] = $hora_nueva_fin[0];
|
||||
$return["min_fin"] = $hora_nueva_fin[1];
|
||||
$return["duracion"] = $rs["duracion_interval"];
|
||||
|
||||
// $return["carrera"] = $rs["PlanEstudio_desc"];
|
||||
$return["horario"] = $rs["horario_id"];
|
||||
$return["materia"] = $rs["materia_id"];
|
||||
$return["materia_desc"] = $rs["materia_nombre"];
|
||||
$return["salon"] = $rs["salon_id"];
|
||||
if($rs["salon_id"]==""){
|
||||
$return["salon_desc"] = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$return["salon_desc"] = join(" / ",$salon_json);
|
||||
}
|
||||
|
||||
//$return["salon_desc"] = $rs["salon"]=="" ? "-Pendiente-": $rs["salon"];
|
||||
$return["ciclo"] = $rs["ciclo"];
|
||||
$return["bloque"] = $rs["bloque"];
|
||||
$return["profesor"] = $rs["profesor_id"];
|
||||
$return["profesor_nombre"] = $rs["profesor_nombre"];
|
||||
$return["comentario"] = $rs["descripcion"];
|
||||
$return["alumnos"] = $rs["alumnos"];
|
||||
$return["tipo"] = $rs["es_reposicion"];
|
||||
$return["aula"] = $rs["tipoaula_id"];
|
||||
$return["aula_desc"] = $rs["tipoaula_nombre"];
|
||||
$return["aula_supervisor"] = $rs["tipoaula_supervisor"];
|
||||
$return["dia"] = date('w', strtotime($rs["fecha_clase"]));
|
||||
$return["motivo_cancelacion"] = $rs["motivo_cancelacion"];
|
||||
$return["estado"] = $rs["estado_reposicion_id"];
|
||||
$return["facultad"] = $rs["facultad_nombre"];
|
||||
$return["carrera"] = $rs["carrera_nombre"];
|
||||
$return["grupo"] = $rs["horario_grupo"];
|
||||
$return["supervisor_nombre"] = $rs["supervisor_nombre"];
|
||||
$return["solicitudtipo_id"] = $rs["solicitudtipo_id"];
|
||||
}
|
||||
echo json_encode($return);
|
||||
?>
|
||||
Reference in New Issue
Block a user