Update script.js
Browse files
script.js
CHANGED
|
@@ -183,7 +183,9 @@ function gestionarMesa(index) {
|
|
| 183 |
|
| 184 |
// Generación del PDF con jsPDF
|
| 185 |
function generarTicket(index, total) {
|
| 186 |
-
|
|
|
|
|
|
|
| 187 |
|
| 188 |
// Crear un nuevo documento PDF
|
| 189 |
const doc = new jsPDF();
|
|
@@ -211,7 +213,8 @@ function generarTicket(index, total) {
|
|
| 211 |
qrContainer.className = 'text-center';
|
| 212 |
app.appendChild(qrContainer);
|
| 213 |
|
| 214 |
-
|
|
|
|
| 215 |
const qrUrl = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(qrContent)}&size=256x256`;
|
| 216 |
|
| 217 |
const qrImage = document.createElement('img');
|
|
@@ -223,9 +226,9 @@ function generarTicket(index, total) {
|
|
| 223 |
const volverButton = document.createElement('button');
|
| 224 |
volverButton.textContent = '← Volver';
|
| 225 |
volverButton.className = 'btn btn-outline-danger btn-block';
|
| 226 |
-
volverButton.onclick = () => render();
|
| 227 |
app.appendChild(volverButton);
|
| 228 |
}
|
| 229 |
|
| 230 |
// Inicializar la aplicación
|
| 231 |
-
render();
|
|
|
|
| 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
|
| 191 |
const doc = new jsPDF();
|
|
|
|
| 213 |
qrContainer.className = 'text-center';
|
| 214 |
app.appendChild(qrContainer);
|
| 215 |
|
| 216 |
+
// Usar mesaIndex para acceder a la mesa correcta
|
| 217 |
+
const qrContent = `Mesa ${mesas[mesaIndex].numero}\n${mesas[mesaIndex].pedidos.map(p => `${p.item} (${p.opcion || ''}) x${p.cantidad} - €${(p.precio * p.cantidad).toFixed(2)}`).join('\n')}\nTotal: €${total.toFixed(2)}`;
|
| 218 |
const qrUrl = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(qrContent)}&size=256x256`;
|
| 219 |
|
| 220 |
const qrImage = document.createElement('img');
|
|
|
|
| 226 |
const volverButton = document.createElement('button');
|
| 227 |
volverButton.textContent = '← Volver';
|
| 228 |
volverButton.className = 'btn btn-outline-danger btn-block';
|
| 229 |
+
volverButton.onclick = () => render(); // Volver a renderizar la UI principal
|
| 230 |
app.appendChild(volverButton);
|
| 231 |
}
|
| 232 |
|
| 233 |
// Inicializar la aplicación
|
| 234 |
+
render();
|