123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- /*
- * Cambia estado de usuario
- * Recibe:
- * id
- * estado
- *
- * Error:
- * 0 - no se recibieron todos los campos
- * 1 - error al guardar en base de datos
- *
- * Success:
- */
- require_once("../../include/constantes.php");
- include_once("../../include/nocache.php");//continue on error
- require_once("../../include/bd_pdo.php");//die on error
- require_once("../../classes/ValidaSesion.php");//die on error
- require_once("../classes/LogActividad.php");//die on error
- $objValida = new ValidaSesion($pdo, 31, APSA);
- if(!$objValida->tieneAcceso()){
- $objValida->terminaSesion();
- }
- if(!$objSesion->puedeEditar()){
- header("Location: ../main.php");
- exit();
- }
- unset($objValida);
- $pag = "../usuario.php";
- if(isset($_POST["id"]) || isset($_POST["estado"])){
- header("Location:".$pag."?error=0");
- exit();
- }
- $usr_id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $estado = filter_input(INPUT_POST, "estado", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- try {
- $stmt = $pdo->prepare('Select * from fu_usuariocambiaestado(:id, :edo)');
- $stmt->bindParam(":id", $usr_id);
- $stmt->bindParam(":edo", $estado);
- if(!$stmt->execute()){
- header("Location:".$pag."?error=1");
- exit();
- }
-
- $log = new LogActividad();
- $desc_log = "Cambia estado de usuario ID[".$usr_id."] Estado[".$estado."]";
- $log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
-
- $stmt->closeCursor(); // cierra conexion de resultado
- $stmt = null; // cierra conexion
- header("Location:".$pag);
- } catch(PDOException $e) {
- $pdo->rollBack();
- header("Location:".$pag."?error=1");
- }
- ?>
|