41 lines
1.8 KiB
JavaScript
41 lines
1.8 KiB
JavaScript
document.addEventListener("DOMContentLoaded", function () {
|
|
const params = new URLSearchParams(window.location.search);
|
|
const idCompra = params.get("id");
|
|
|
|
console.log(idCompra);
|
|
|
|
if (!idCompra) {
|
|
document.getElementById("comprobanteInfo").innerHTML = "<p>Error: No se especificó una compra.</p>";
|
|
return;
|
|
}
|
|
|
|
fetch("controladores/comprobante.php?id=" + idCompra)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
console.log("Datos del comprobante recibidos:", data);
|
|
|
|
if (data.error) {
|
|
document.getElementById("comprobanteInfo").innerHTML = "<p>" + data.error + "</p>";
|
|
} else {
|
|
document.getElementById("evento").textContent = "Evento: " + data.artista;
|
|
document.getElementById("fecha").textContent = "Fecha: " + data.fecha;
|
|
document.getElementById("lugar").textContent = "Lugar: " + data.lugar;
|
|
document.getElementById("cantidad").textContent = "Boletos Comprados: " + data.cantidad;
|
|
document.getElementById("total").textContent = "Total Pagado: $" + data.total;
|
|
document.getElementById("precio").textContent = "Precio por boleto: $" + data.precio;
|
|
|
|
let listaAsientos = document.getElementById("asientos");
|
|
listaAsientos.innerHTML = "";
|
|
data.asientos.forEach(asiento => {
|
|
let li = document.createElement("li");
|
|
li.textContent = asiento;
|
|
listaAsientos.appendChild(li);
|
|
});
|
|
}
|
|
})
|
|
.catch(error => {
|
|
document.getElementById("comprobanteInfo").innerHTML = "<p>Error al cargar el comprobante.</p>";
|
|
console.error("Error al obtener datos del comprobante:", error);
|
|
});
|
|
});
|