tieneAcceso()){ $objSesion->terminaSesion(); //print_r($objSesion->getError()); } if(!$objSesion->puedeEditar()){ header("Location: ".$pag); exit(); } unset($objValida); if(/*empty($_POST["fecha_inicial"]) ||*/ empty($_POST["hora_ini"]) || empty($_POST["min_ini"]) || empty($_POST["horario"]) ){ header("Location: ".$pag."?error=0"); exit(); } $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 $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 = $_SESSION["usuario_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(filter_input(INPUT_POST, "comentario", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto $stmt = $pdo->prepare('Select * from fs_horario(:hor)'); $stmt->bindParam(":hor", $hor); if(!$stmt->execute()){ print_r($stmt->errorInfo()); header("Location:".$pag."?error=4"); exit(); } $horario_rs = $stmt->fetch(); $stmt->closeCursor(); $materia = $horario_rs["Materia_id"]; $materia_id_sgu = $horario_rs["Materia_id_sgu"]; $gpo = $horario_rs["Grupo_id"]; $duracion = $horario_rs["Horario_duracion"]; $hora = $horario_rs["Horario_hora"]; //$duracion = 90; $hora_new = $hora_ini.":".$min_ini; $fecha_new = fechaGuion($fecha); $fecha_ini = fechaGuion($fecha)." ".$hora_ini.":".$min_ini.":00"; $fecha_fin = date('Y-m-d H:i:00', strtotime($fecha_ini.' + '.$duracion.' minute')); $dia = date('w', strtotime($fecha_ini)); if($tipo == 1){//Reposición $fecha_falta = fechaGuion($fecha_falta); $dia_falta = date('w', strtotime($fecha_falta)); }else{ $fecha_cambio = fechaGuion($fecha_cambio); $dia_falta = date('w', strtotime($fecha_cambio)); } //Obtiene clave ULSA $stmt = $pdo->prepare('SELECT * from fs_usuario(:id)'); $stmt->bindParam(":id", $prof); if(!$stmt->execute()){ //print_r($stmt->errorInfo()); header("Location:".$pag."?error=0"); exit(); } $prof_rs = $stmt->fetch(); $prof_clave = $prof_rs["Usuario_claveULSA"]; $stmt->closeCursor(); $stmt = null; unset($prof_rs); //Valida que tenga clase en la fecha de falta $stmt = $pdo->prepare('SELECT COUNT("HorarioGrupo_id") as total FROM "HorarioGrupo" hg WHERE "Grupo_id" = :gpo and "Materia_id" = :mat and "Dia_id" = :dia'); $stmt->bindParam(":mat", $materia); $stmt->bindParam(":gpo", $gpo); $stmt->bindParam(":dia", $dia_falta); if(!$stmt->execute()){ //print_r($stmt->errorInfo()); header("Location:".$pag."?error=1"); exit(); } $total_rs = $stmt->fetch(); $stmt->closeCursor(); $stmt = null; if(empty($total_rs["total"]) || $total_rs["total"] == 0){ //echo 'SELECT COUNT("HorarioGrupo_id") as total FROM "HorarioGrupo" hg WHERE "Grupo_id" = '.$gpo.' and "Materia_id" = '.$materia.' and "Dia_id" = '.$dia_falta; header("Location:".$pag."?error=11"); exit(); } // Valida que salón esté disponible /* if(!empty($salon)){ $result = validaConflictoSalon($pdo, $gpo, $dia, $hora_new, $materia, '-', $fecha_ini, $fecha_fin, $duracion, $salon, NULL, NULL); if($result != ""){//error //echo $result; header("Location:".$pag."?error=8"); exit(); } //Valida que no esté ocupado el salón con reposición $result = validaConflictoReposicionSalon($pdo, NULL, $_SESSION["periodo_id"], $fecha_ini, $duracion, $salon); if($result != ""){//error //echo $result; header("Location:".$pag."?error=8"); exit(); } }*/ /* $result = validaConflictoProfesorSalon($pdo, $gpo, $dia, $hora_new, $materia, $salon, '-', $fecha_ini, $fecha_fin, $duracion, array(array("profesor"=>$prof) ), null, 0); if($result != ""){//error //echo $result; header("Location:".$pag."?error=10"); exit(); } */ $client = new nusoap_client('http://200.13.89.27/checador_otros/admin_checador/webservice/reposiciones_service.php?wsdl', 'wsdl'); $error = $client->getError(); if ($error) { header("Location:".$pag."?error=12"); exit(); } $token = password_hash("W3bS3rv1c3.R3p0##", PASSWORD_DEFAULT); if($tipo == 1){//Reposición // Valida que grupo no tenga clases $result = validaConflictoHoras($pdo, $gpo, $dia, $hora_new, $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 $result = validaConflictoReposicionProfesorSalon($pdo, NULL, $_SESSION["periodo_id"], $fecha_ini, $duracion, $prof); if($result != ""){//error //echo $result; header("Location:".$pag."?error=9"); exit(); } $result = $client->call("reposicion_crea", array($token, $_SESSION["periodo_shortname"],$prof_clave, $materia_id_sgu, $tipo, $fecha_falta, $fecha_new, $hora, $hora_new, $alumnos, $aula, $comentario, $duracion )); //print_r(array($token, $_SESSION["periodo_shortname"],$prof_clave, $materia_id_sgu, $tipo, $fecha_falta, $fecha_new, $hora, $hora_new, $alumnos, $aula, $comentario, $duracion )); //print_r($result); //exit(); if ($client->fault) { //echo "fault"; header("Location:".$pag."?error=12"); exit(); } else { $error = $client->getError(); if ($error) { //echo "error [$error] "; header("Location:".$pag."?error=12"); exit(); } else { $ok = $result["result"]; $id_cronos = $result["id_result"]; if(!$ok || empty($id_cronos)){ //print_r($result); //echo "Not OK [$ok][$id_cronos]"; header("Location:".$pag."?error=12"); exit(); } } } $fecha_falta = $fecha_falta." ".$horario_rs["Horario_hora"]; $stmt = $pdo->prepare('Select * from fi_reposicion(:f_falta, :f_nueva, :hor, NULL, :prof, 1, :com, :alumnos, true, :aula, NULL, :id_cronos)'); $stmt->bindParam(":f_falta", $fecha_falta); $stmt->bindParam(":f_nueva", $fecha_ini); $stmt->bindParam(":hor", $hor); //$stmt->bindParam(":salon", $salon); $stmt->bindParam(":prof", $prof); $stmt->bindParam(":com", $comentario); $stmt->bindParam(":alumnos", $alumnos); $stmt->bindParam(":aula", $aula); $stmt->bindParam(":id_cronos", $id_cronos); if(!$stmt->execute()){ //echo $fecha_falta." ".$fecha_ini." ".$materia." ".$salon." ".$prof." ".$gpo." ".$com; //print_r($stmt->errorInfo()); header("Location:".$pag."?error=1"); exit(); } $rs = $stmt->fetch(); $stmt->closeCursor(); $stmt = null; $log = new LogActividad(); $desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_falta.">".$fecha_ini."] 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 $result = $client->call("reposicion_crea", array($token, $_SESSION["periodo_shortname"],$prof, $materia_id_sgu, $tipo, $fecha_cambio, $fecha_cambio, $hora ,$hora_new, $alumnos,$aula, $comentario, $duracion )); if ($client->fault) { header("Location:".$pag."?error=12"); exit(); } else { $error = $client->getError(); if ($error) { header("Location:".$pag."?error=12"); exit(); } else { $ok = $result["result"]; $id_cronos = $result["id_result"]; if(!$ok || empty($id_cronos)){ header("Location:".$pag."?error=12"); exit(); } } } $fecha_cambio_nueva = $fecha_cambio." ".$hora_ini.":".$min_ini.":00"; $stmt = $pdo->prepare('Select * from fi_reposicion(:f_falta, :f_nueva, :hor, NULL, :prof, 1, :com, :alumnos, false, :aula, NULL, :id_cronos)'); $stmt->bindParam(":f_falta", $fecha_cambio); $stmt->bindParam(":f_nueva", $fecha_cambio_nueva); $stmt->bindParam(":hor", $hor); //$stmt->bindParam(":salon", $salon); $stmt->bindParam(":prof", $prof); $stmt->bindParam(":com", $comentario); $stmt->bindParam(":alumnos", $alumnos); $stmt->bindParam(":aula", $aula); $stmt->bindParam(":id_cronos", $id_cronos); if(!$stmt->execute()){ //echo $fecha_falta." ".$fecha_ini." ".$materia." ".$salon." ".$prof." ".$gpo." ".$com; //print_r($stmt->errorInfo()); header("Location:".$pag."?error=1"); exit(); } $rs = $stmt->fetch(); $stmt->closeCursor(); $stmt = null; $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); exit(); ?>