Update script.js
Browse files
script.js
CHANGED
|
@@ -183,8 +183,8 @@ function gestionarMesa(index) {
|
|
| 183 |
|
| 184 |
// Generación del PDF con jsPDF
|
| 185 |
function generarTicket(index, total) {
|
| 186 |
-
// Almacenar el index de la mesa
|
| 187 |
-
const mesaIndex = index;
|
| 188 |
const mesa = mesas[mesaIndex];
|
| 189 |
|
| 190 |
// Crear un nuevo documento PDF
|
|
@@ -199,15 +199,18 @@ function generarTicket(index, total) {
|
|
| 199 |
});
|
| 200 |
doc.text(`Total: €${total.toFixed(2)}`, 10, yOffset);
|
| 201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
// Mostrar el total debajo del QR
|
| 203 |
const totalText = document.createElement('p');
|
| 204 |
totalText.textContent = `Total: €${total.toFixed(2)}`;
|
| 205 |
totalText.className = 'text-center';
|
| 206 |
app.appendChild(totalText);
|
| 207 |
|
| 208 |
-
// Generar el PDF y descargarlo
|
| 209 |
-
doc.save(`ticket-mesa-${mesa.numero}.pdf`);
|
| 210 |
-
|
| 211 |
// Mostrar el QR
|
| 212 |
const qrContainer = document.createElement('div');
|
| 213 |
qrContainer.className = 'text-center';
|
|
@@ -226,7 +229,7 @@ function generarTicket(index, total) {
|
|
| 226 |
const volverButton = document.createElement('button');
|
| 227 |
volverButton.textContent = '← Volver';
|
| 228 |
volverButton.className = 'btn btn-outline-danger btn-block';
|
| 229 |
-
volverButton.onclick = () => render();
|
| 230 |
app.appendChild(volverButton);
|
| 231 |
}
|
| 232 |
|
|
|
|
| 183 |
|
| 184 |
// Generación del PDF con jsPDF
|
| 185 |
function generarTicket(index, total) {
|
| 186 |
+
// **Almacenar el index de la mesa**
|
| 187 |
+
const mesaIndex = index;
|
| 188 |
const mesa = mesas[mesaIndex];
|
| 189 |
|
| 190 |
// Crear un nuevo documento PDF
|
|
|
|
| 199 |
});
|
| 200 |
doc.text(`Total: €${total.toFixed(2)}`, 10, yOffset);
|
| 201 |
|
| 202 |
+
// Generar el PDF y descargarlo
|
| 203 |
+
doc.save(`ticket-mesa-${mesa.numero}.pdf`);
|
| 204 |
+
|
| 205 |
+
// **Limpiar app DESPUÉS de generar el PDF**
|
| 206 |
+
app.innerHTML = '';
|
| 207 |
+
|
| 208 |
// Mostrar el total debajo del QR
|
| 209 |
const totalText = document.createElement('p');
|
| 210 |
totalText.textContent = `Total: €${total.toFixed(2)}`;
|
| 211 |
totalText.className = 'text-center';
|
| 212 |
app.appendChild(totalText);
|
| 213 |
|
|
|
|
|
|
|
|
|
|
| 214 |
// Mostrar el QR
|
| 215 |
const qrContainer = document.createElement('div');
|
| 216 |
qrContainer.className = 'text-center';
|
|
|
|
| 229 |
const volverButton = document.createElement('button');
|
| 230 |
volverButton.textContent = '← Volver';
|
| 231 |
volverButton.className = 'btn btn-outline-danger btn-block';
|
| 232 |
+
volverButton.onclick = () => render();
|
| 233 |
app.appendChild(volverButton);
|
| 234 |
}
|
| 235 |
|