Update script.js
Browse files
script.js
CHANGED
|
@@ -178,16 +178,23 @@ function gestionarMesa(index) {
|
|
| 178 |
// Generación del QR y ticket
|
| 179 |
function generarTicket(index, total) {
|
| 180 |
const mesa = mesas[index];
|
| 181 |
-
let qrContent = `Mesa ${mesa.numero}
|
|
|
|
| 182 |
mesa.pedidos.forEach(pedido => {
|
| 183 |
qrContent += `${pedido.item} (${pedido.opcion || ''}) x${pedido.cantidad} - €${(pedido.precio * pedido.cantidad).toFixed(2)}\n`;
|
| 184 |
});
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
const qrContainer = document.createElement('div');
|
| 187 |
qrContainer.className = 'text-center';
|
| 188 |
app.appendChild(qrContainer);
|
| 189 |
|
| 190 |
-
|
|
|
|
| 191 |
text: qrContent,
|
| 192 |
width: 256,
|
| 193 |
height: 256,
|
|
@@ -196,13 +203,13 @@ function generarTicket(index, total) {
|
|
| 196 |
correctLevel: QRCode.CorrectLevel.H
|
| 197 |
});
|
| 198 |
|
|
|
|
| 199 |
const volverButton = document.createElement('button');
|
| 200 |
volverButton.textContent = '← Volver';
|
| 201 |
volverButton.className = 'btn btn-outline-danger btn-block';
|
| 202 |
volverButton.onclick = () => render();
|
| 203 |
app.appendChild(volverButton);
|
| 204 |
}
|
| 205 |
-
|
| 206 |
// Inicializar la aplicación
|
| 207 |
render();
|
| 208 |
|
|
|
|
| 178 |
// Generación del QR y ticket
|
| 179 |
function generarTicket(index, total) {
|
| 180 |
const mesa = mesas[index];
|
| 181 |
+
let qrContent = `Mesa ${mesa.numero}\n`;
|
| 182 |
+
|
| 183 |
mesa.pedidos.forEach(pedido => {
|
| 184 |
qrContent += `${pedido.item} (${pedido.opcion || ''}) x${pedido.cantidad} - €${(pedido.precio * pedido.cantidad).toFixed(2)}\n`;
|
| 185 |
});
|
| 186 |
|
| 187 |
+
qrContent += `\nTotal: €${total.toFixed(2)}`;
|
| 188 |
+
|
| 189 |
+
console.log('QR Content:', qrContent); // Para depurar el contenido antes de generar el QR.
|
| 190 |
+
|
| 191 |
+
// Asegúrate de limpiar el contenedor del QR antes de generarlo
|
| 192 |
const qrContainer = document.createElement('div');
|
| 193 |
qrContainer.className = 'text-center';
|
| 194 |
app.appendChild(qrContainer);
|
| 195 |
|
| 196 |
+
// Generación del QR
|
| 197 |
+
const qrCode = new QRCode(qrContainer, {
|
| 198 |
text: qrContent,
|
| 199 |
width: 256,
|
| 200 |
height: 256,
|
|
|
|
| 203 |
correctLevel: QRCode.CorrectLevel.H
|
| 204 |
});
|
| 205 |
|
| 206 |
+
// Volver a la vista anterior
|
| 207 |
const volverButton = document.createElement('button');
|
| 208 |
volverButton.textContent = '← Volver';
|
| 209 |
volverButton.className = 'btn btn-outline-danger btn-block';
|
| 210 |
volverButton.onclick = () => render();
|
| 211 |
app.appendChild(volverButton);
|
| 212 |
}
|
|
|
|
| 213 |
// Inicializar la aplicación
|
| 214 |
render();
|
| 215 |
|