tieneAcceso()){ $objSesion->terminaSesion(); //print_r($objSesion->getError()); } if(!$objSesion->puedeEditar()){ header("Location: ".$pag); exit(); } unset($objValida); if(!isset($_POST["id"]) || !isset($_POST["fecha_falta"]) || !isset($_POST["fecha_inicial"]) || !isset($_POST["hora_ini"]) || !isset($_POST["min_ini"]) ){ header("Location: ".$pag."?error=0"); exit(); } $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto $id_cronos = filter_input(INPUT_POST, "id_cronos", 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 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 $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 $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"]; $gpo = $horario_rs["Grupo_id"]; $duracion = $horario_rs["Horario_duracion"]; $hora = $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){ header("Location:".$pag."?error=11"); exit(); } // Valida que salón esté disponible /* $result = validaConflictoSalon($pdo, $gpo, $dia, $hora, $materia, '-', $fecha_ini, $fecha_fin, $duracion, $salon, NULL, NULL); if($result != ""){//error echo $result; header("Location:".$pag."?error=8&otro=1"); exit(); } //Valida que no esté ocupado el salón con reposición $result = validaConflictoReposicionSalon($pdo, $id, $_SESSION["periodo_id"], $fecha_ini, $duracion, $salon); if($result != ""){//error echo $result; header("Location:".$pag."?error=8&otro=2"); exit(); } */ /* $result = validaConflictoProfesorSalon($pdo, $gpo, $dia, $hora, $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, $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, $id, $_SESSION["periodo_id"], $fecha_ini, $duracion, $prof); if($result != ""){//error echo $result; header("Location:".$pag."?error=9"); exit(); } if(!empty($id_cronos)){//sincronoza reposiciones $result = $client->call("reposicion_actualiza", array($token, $id_cronos, $prof_clave, $tipo, $fecha_falta, $fecha_new, $hora, $alumnos, $aula, $comentario, $duracion )); //print_r(array($token, $id_cronos, $prof_clave, $tipo, $fecha_falta, $fecha_new, $hora, $alumnos, $aula, $comentario, $duracion )); //echo "
SELECT * from fu_reposicion($id_cronos, $fecha_falta, $fecha_new, $hora, NULL, 1, $comentario, $alumnos, true, $aula)"; //print_r($result); if ($client->fault) { echo "fault"; //header("Location:".$pag."?error=13"); exit(); } else { $error = $client->getError(); if ($error) { //header("Location:".$pag."?error=13"); echo "error"; exit(); } else { $ok = $result["result"]; if(!$ok){ echo "not OK"; //header("Location:".$pag."?error=13"); exit(); } } } } $fecha_falta = $fecha_falta." ".$horario_rs["Horario_hora"]; $stmt = $pdo->prepare('Select * from fu_reposicion(:id, :f_falta, :f_nueva, NULL, 1, :com, :al, true, :aula)'); $stmt->bindParam(":id", $id); $stmt->bindParam(":f_falta", $fecha_falta); $stmt->bindParam(":f_nueva", $fecha_ini); $stmt->bindParam(":al", $alumnos); $stmt->bindParam(":aula", $aula); //$stmt->bindParam(":edo", $edo); $stmt->bindParam(":com", $comentario); if(!$stmt->execute()){ print_r($stmt->errorInfo()); //header("Location:".$pag."?error=1"); exit(); } $rs = $stmt->fetch(); $stmt->closeCursor(); $stmt = null; $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{ if(!empty($id_cronos)){//sincronoza reposiciones $result = $client->call("reposicion_actualiza", array($token, $id_cronos, $prof, $tipo, $fecha_cambio, $fecha_cambio, $hora, $alumnos, $aula, $comentario, $duracion )); if ($client->fault) { header("Location:".$pag."?error=13"); exit(); } else { $error = $client->getError(); if ($error) { header("Location:".$pag."?error=13"); exit(); } else { $ok = $result["result"]; if(!$ok){ header("Location:".$pag."?error=13"); exit(); } } } } $fecha_cambio_nueva = $fecha_cambio." ".$hora_ini.":".$min_ini.":00"; $stmt = $pdo->prepare('Select * from fu_reposicion(:id, :f_falta, :f_nueva, NULL, 1, :com, :al, true, :aula)'); $stmt->bindParam(":id", $id); $stmt->bindParam(":f_falta", $fecha_cambio); $stmt->bindParam(":f_nueva", $fecha_cambio_nueva); $stmt->bindParam(":al", $alumnos); $stmt->bindParam(":aula", $aula); //$stmt->bindParam(":edo", $edo); $stmt->bindParam(":com", $comentario); if(!$stmt->execute()){ print_r($stmt->errorInfo()); //header("Location:".$pag."?error=1"); exit(); } $rs = $stmt->fetch(); } header("Location: ".$pag); exit(); ?>