NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Copiar datos de reserva
// @namespace http://zengarden/zm/*/tools/zenmeeting/detalleReserva.php
// @version 1.0.0.20210624
// @description asd
// @author Roberto Orden Erena
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @match http://zengarden/zm/*/tools/zenmeeting/detalleReserva*
// @license MIT
// @grant none
// ==/UserScript==
$(() => {
$("#cabTitulo").css({
width: "80%"
})
let button = $("<button>");
button.attr("type", "button");
button.text("Copiar");
button.css({
width: "100px",
height: "100%",
backgroundColor: "lightseagreen",
color: "white"
});
$("#fila_0").append(button);
button.click(() => {
const qp = new URLSearchParams(window.location.search);
jQuery.ajax({
type: "POST",
url: "ajax/sala.php",
dataType: "xml",
data:
{
accion: "infoReservaId",
idUser: $("#iduser").val(),
reservaId: qp.get("idreserva")
},
async: true,
// código a ejecutar si la petición es satisfactoria;
// la respuesta es pasada como argumento a la función
success: function (a) {
var xml = a.documentElement;
var infoReservas = $(xml).children("infoReserva");
let params = [];
params["titulo"] = $(infoReservas[0]).attr("titulo");
params["contenido"] = $(infoReservas[0]).attr("contenido");
params["notaprivada"] = $(infoReservas[0]).attr("comentario");
params["enlaces"] = $(infoReservas[0]).attr("valor");
// Informar rol de los empleados relacionados con la reserva
var infoRol = $(xml).children("infoRol");
let users = []
let roles = []
for (var i = 0; i < infoRol.length; i++) {
users.push($(infoRol[i]).attr("usuarioId"));
roles.push(parseInt($(infoRol[i]).attr("rolId")));
}
let queryParam = "";
for (let key in params) {
let val = params[key];
queryParam += key;
queryParam += "=";
let asd = encodeURI(val);
queryParam += asd;
queryParam += "&";
}
users.forEach(element => {
queryParam += "users[]=" + element + "&";
});
roles.forEach(element => {
queryParam += "roles[]=" + element + "&";
});
let url = window.location.origin + "/" + window.location.pathname.split("/").slice(1).reverse().slice(1).reverse().join("/") + "/index.php?" + queryParam;
console.log(url);
window.location.href = url;
// http://zengarden/zm/q/tools/zenmeeting/index.php?
// users[]=10&users[]=13&users[]=154&users[]=167&users[]=180&users[]=20&users[]=219&users[]=25&users[]=6&users[]=65&users[]=88
// &roles[]=1&roles[]=1&roles[]=3&roles[]=1&roles[]=1&roles[]=3&roles[]=1&roles[]=1&roles[]=1&roles[]=1&roles[]=1
// &
},
// código a ejecutar si la petición falla;
error: function () {
var mensaje = "Existe un problema al traer datos de la reserva.";
notificacion("<span style='color:red;'>ERROR:</span>", mensaje);
}
});
});
})