tieneAcceso()){ $objSesion->terminaSesion(); //print_r($objSesion->getError()); } if(!$objSesion->puedeEditar()){ header("Location: ".$pag); exit(); } unset($objValida); if(!isset($_POST["id"]) || !isset($_POST["desc"])){ header("Location: ".$pag."?error=0"); exit(); } $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto $desc = trim(filter_input(INPUT_POST, "desc", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto $fecha_inicial = fechaGuion(trim(filter_input(INPUT_POST, "fecha_inicial", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $fecha_final = fechaGuion(trim(filter_input(INPUT_POST, "fecha_final", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $nivel = filter_input(INPUT_POST, "nivel", FILTER_SANITIZE_NUMBER_INT);//limpia texto $estado = filter_input(INPUT_POST, "estado", FILTER_SANITIZE_NUMBER_INT);//limpia texto $fecha_jefes = fechaGuion(trim(filter_input(INPUT_POST, "fecha_jefes", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $horario = filter_input(INPUT_POST, "horario", FILTER_SANITIZE_NUMBER_INT);//limpia texto $inter = filter_input(INPUT_POST, "inter", FILTER_SANITIZE_NUMBER_INT);//limpia texto $fecha_inicial_per = fechaGuion(trim(filter_input(INPUT_POST, "fecha_inicial_per", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $fecha_final_per = fechaGuion(trim(filter_input(INPUT_POST, "fecha_final_per", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $fecha_inicial_extras = fechaGuion(trim(filter_input(INPUT_POST, "fecha_inicial_extras", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $fecha_final_extras = fechaGuion(trim(filter_input(INPUT_POST, "fecha_final_extras", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW))));//limpia texto $horario = ($horario == 1 ? 'true' : 'false'); $inter_text = ($inter == 1 ? 'true' : 'false'); try { $pdo->beginTransaction(); if($fecha_jefes == "") $stmt = $pdo->prepare('Select * from fu_periodo(:id, :desc, :fini, :ffin, :edo, NULL, '.$horario.', '.$inter_text.')'); else{ $stmt = $pdo->prepare('Select * from fu_periodo(:id, :desc, :fini, :ffin, :edo, :fjefes, '.$horario.', '.$inter_text.')'); $stmt->bindParam(":fjefes", $fecha_jefes); } $stmt->bindParam(":id", $id); $stmt->bindParam(":desc", $desc); $stmt->bindParam(":fini", $fecha_inicial); $stmt->bindParam(":ffin", $fecha_final); $stmt->bindParam(":edo", $estado); if(!$stmt->execute()){ $pdo->rollBack(); //print_r($stmt->errorInfo()); header("Location:".$pag."?error=2"); exit(); } $stmt->closeCursor(); $stmt = null; $stmt = $pdo->prepare('Select * from fi_fechaimportante(:periodo, 3, :fechai, :fechaf )');//fechas periodo $stmt->bindParam(":periodo", $id); $stmt->bindParam(":fechai", $fecha_inicial_per); $stmt->bindParam(":fechaf", $fecha_final_per); if(!$stmt->execute()){ $pdo->rollBack(); //echo "3";print_r($stmt->errorInfo());exit(); header("Location:".$pag."?error=5"); exit(); } $stmt->closeCursor(); if($nivel == 1 && $inter == 0){ if($fecha_inicial_extras != "" && $fecha_final_extras != ""){ $stmt = $pdo->prepare('Select * from fi_fechaimportante(:periodo, 2, :fechai, :fechaf )');//fehas extraordinarios $stmt->bindParam(":periodo", $id); $stmt->bindParam(":fechai", $fecha_inicial_extras); $stmt->bindParam(":fechaf", $fecha_final_extras); if(!$stmt->execute()){ $pdo->rollBack(); //echo "2";print_r($stmt->errorInfo());exit(); header("Location:".$pag."?error=5"); exit(); } $stmt->closeCursor(); } }else{ $stmt = $pdo->prepare('Select * from fd_fechaimportante(:periodo, 2)');//fehas extraordinarios $stmt->bindParam(":periodo", $id); if(!$stmt->execute()){ $pdo->rollBack(); //echo "2 delete";print_r($stmt->errorInfo());exit(); header("Location:".$pag."?error=5"); exit(); } $stmt->closeCursor(); } if($id == $_SESSION["periodo_id"]){//Si se editó periodo en sesión, actualizar información if($estado != 2){//no es inactivo $_SESSION["periodo_desc"] = $desc; }else{//se desactiva unset($_SESSION["periodo_id"]); unset($_SESSION["periodo_desc"]); } } $pdo->commit(); $log = new LogActividad(); $desc_log = "Actualiza periodo nuevo ID[".$id."] Nombre[".$desc."] FechaInicial[".$fecha_inicial."] FechaFinal[".$fecha_final."] Nivel[".$nivel."] Estado[".$estado."] FechaJefes[".$fecha_jefes."]"; $log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log); header("Location: ".$pag."?ok=1"); exit(); } catch(PDOException $e) { $pdo->rollBack(); header("Location:".$pag."?error=2"); //print_r($e); } ?>