tieneAcceso() || !$objSesion->puedeEditar()){ header("Location: ".$pag."?error=2&id=".$_POST["id"]); exit(); } unset($objValida); try { $pdo->beginTransaction(); if(!isset($_POST["id"]) || !isset($_POST["nombre"]) || !isset($_POST["apellidos"])){ header("Location:".$pag."?error=0"); exit(); } $usr_id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto $nombre = (trim(filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $apellidos = (trim(filter_input(INPUT_POST, "apellidos", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $curp = mb_strtoupper(trim(filter_input(INPUT_POST, "curp", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto //Valida que no esté solo en mayúsculas if($nombre == mb_strtoupper($nombre, "UTF-8")){ $nombre = mb_convert_case(mb_strtolower($nombre), MB_CASE_TITLE, "UTF-8"); } if($apellidos == mb_strtoupper($apellidos, "UTF-8")){ $apellidos = mb_convert_case(mb_strtolower($apellidos), MB_CASE_TITLE, "UTF-8"); } //---- Actualiza alumno --- $stmt = $pdo->prepare('Select * from fu_alumno(:id, :nombre, :apellidos, :curp)');//devuelve: Usuario_id $stmt->bindParam(":id", $usr_id); $stmt->bindParam(":nombre", $nombre); $stmt->bindParam(":apellidos", $apellidos); $stmt->bindParam(":curp", $curp); if(!$stmt->execute()){ $pdo->rollBack(); //print_r($stmt->errorInfo()); header("Location:".$pag."?id=".$usr_id."&error=1"); exit(); } $stmt->closeCursor(); // cierra conexion de resultado //---- Actualiza datos de contacto ---- $stmt = $pdo->prepare('Select * from fd_contacto(:usr, NULL)');//borra contacto actual $stmt->bindParam(":usr", $usr_id); if(!$stmt->execute()){ $pdo->rollBack(); //print_r($stmt->errorInfo()); header("Location:".$pag."?error=1"); exit(); } if(isset($_POST["contacto_tipo"]) ){ $tipoArr = $_POST["contacto_tipo"]; $valorArr = $_POST["contacto_valor"]; $perfilArr = $_POST["contacto_perfil"]; $subtipoArr = $_POST["contacto_subtipo"]; for($i=0; $i< count($tipoArr); $i++){ if(trim($valorArr[$i]) != ""){ if($subtipoArr[$i] != 0){ $stmt = $pdo->prepare('Select * from fi_contacto(:valor, :tipo, :usr, :perf, :subt)');//inserta contactos $stmt->bindParam(":subt", $subtipoArr[$i]); }else{ $stmt = $pdo->prepare('Select * from fi_contacto(:valor, :tipo, :usr, :perf, NULL)');//inserta contactos } $stmt->bindParam(":usr", $usr_id); $stmt->bindParam(":valor", $valorArr[$i]); $stmt->bindParam(":tipo", $tipoArr[$i]); $stmt->bindParam(":perf", $perfilArr[$i]); if(!$stmt->execute()){ $pdo->rollBack(); //echo "Error fi_contacto [".$valorArr[$i]."] [".$tipoArr[$i]."] [".$usr_id."]
"; //print_r($stmt->errorInfo()); header("Location:".$pag."?error=6"); exit(); } } } $stmt->closeCursor(); // cierra conexion de resultado } $log = new LogActividad(); $desc_log = "Actualiza alumno promocion ID[".$usr_id."] Nombre[".$nombre." ".$apellidos."] CURP[".$curp."]"; $log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log); $pdo->commit(); $stmt = null; // cierra conexion header("Location: ../alumnospromocion.php?ok=1"); } catch(PDOException $e) { $pdo->rollBack(); header("Location:".$pag."?id=".$usr_id."&error=1"); } ?>