access(); $duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion $fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto $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 $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"]; //-- Obtiene datos de horario regular de clase $horario_rs = $db->querySingle('SELECT * from horario_view where horario_id = :hor', [':hor' => $hor] ); $materia = $horario_rs["materia_id"]; $dia = $horario_rs["horario_dia"]; $hora = $hora_ini.":".$min_ini.":00"; $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 = '.$hor; echo intval($dia)." != ".intval($dia_falta);*/ exit(); } //Obtiene materia $materia_rs = $db->querySingle('SELECT materia_nombre from materia where materia_id = :mat',[':mat' => $materia]); //Obtiene correo $correos_rs = $db->querySingle('SELECT coor.usuario_correo, coor.usuario_nombre from usuario coor where rol_id = :rol_coord and facultad_id = ( select coalesce(facultad_id,0) from usuario u where u.usuario_id = :id_usr)',[':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{ $db->query('SELECT * from fi_asignacion_solicitud(:f_nueva, :hora_nueva, :prof, 1, :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"] ] ); }catch(Exception $e){ echo $e->getMessage(); //header("Location: ".$pag."?error=1"); exit(); } $texto = "
Se creó una reposición nueva.
"; $texto .= "".mb_strtoupper($materia_rs["materia_nombre"])." del día ".$fecha_falta." a las ".$hor." hrs. se propone reponer el ".$fecha_new." a las ".$hora." hrs."; $texto .= "
Ingresa al sistema PAAD para autorizarla.
"; /* $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_solicitud(:f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion, :usr)', [':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor, ':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"], ] ); }catch(Exception $e){ header("Location: ".$pag."?error=1"); exit(); } $texto = "Se creó un cambio de salón nuevo.
"; $texto .= "".mb_strtoupper($materia_rs["materia_nombre"])." del día ".$fecha_falta." a las ".$hora." hrs. se propone reponer el ".$fecha_nueva." a las ".$hora_nueva." hrs."; $texto .= "
Ingresa al sistema PAAD para autorizarlo.
"; /* $log = new LogActividad(); $desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_cambio.">".$fecha_cambio_nueva."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]"; $log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log); */ } if($to!= "" && ENVIO_CORREOS){ $asunto = "Reposición nueva - solicitud"; //crear plantilla $texto = '
'.$texto.'
';
require_once('../include/phpmailer/PHPMailerAutoload.php');
if($_ENV['DB_NAME'] == "paad_pruebas"){
$asunto = "PRUEBAS-".$asunto;
Mailer::enviarCorreo("alejandro.rosales@lasalle.mx", $asunto, $texto, true);
}else{
Mailer::enviarCorreo($to, $asunto, $texto, true);
}
}
exit();
header("Location: ".$pag."?ok=0");
?>