Update script.js
Browse files
script.js
CHANGED
|
@@ -32,7 +32,6 @@ function render() {
|
|
| 32 |
mesaNumero--;
|
| 33 |
mesaInput.querySelector('.mesa-number').textContent = mesaNumero;
|
| 34 |
}
|
| 35 |
-
|
| 36 |
};
|
| 37 |
|
| 38 |
mesaInput.querySelector('.increase-mesa').onclick = (event) => {
|
|
@@ -178,22 +177,31 @@ function gestionarMesa(index) {
|
|
| 178 |
|
| 179 |
const atrasButton = document.createElement('button');
|
| 180 |
atrasButton.textContent = '← Atrás';
|
| 181 |
-
atrasButton.className = 'btn btn-outline-secondary btn-block';
|
| 182 |
atrasButton.onclick = () => render();
|
| 183 |
app.appendChild(atrasButton);
|
| 184 |
|
| 185 |
-
const
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
const total = mesa.pedidos.reduce((sum, p) => sum + p.precio * p.cantidad, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
if (total > 0) {
|
| 191 |
generarTicket(index, total);
|
| 192 |
} else {
|
| 193 |
alert("La mesa no tiene productos");
|
| 194 |
}
|
| 195 |
};
|
| 196 |
-
app.appendChild(
|
| 197 |
}
|
| 198 |
|
| 199 |
// Generación del PDF con jsPDF
|
|
|
|
| 32 |
mesaNumero--;
|
| 33 |
mesaInput.querySelector('.mesa-number').textContent = mesaNumero;
|
| 34 |
}
|
|
|
|
| 35 |
};
|
| 36 |
|
| 37 |
mesaInput.querySelector('.increase-mesa').onclick = (event) => {
|
|
|
|
| 177 |
|
| 178 |
const atrasButton = document.createElement('button');
|
| 179 |
atrasButton.textContent = '← Atrás';
|
| 180 |
+
atrasButton.className = 'btn btn-outline-secondary btn-block mb-2';
|
| 181 |
atrasButton.onclick = () => render();
|
| 182 |
app.appendChild(atrasButton);
|
| 183 |
|
| 184 |
+
const totalButton = document.createElement('button');
|
| 185 |
+
totalButton.textContent = 'Calcular Total';
|
| 186 |
+
totalButton.className = 'btn btn-warning btn-block mb-2';
|
| 187 |
+
totalButton.onclick = () => {
|
| 188 |
const total = mesa.pedidos.reduce((sum, p) => sum + p.precio * p.cantidad, 0);
|
| 189 |
+
alert(`El total de la mesa es: €${total.toFixed(2)}`);
|
| 190 |
+
};
|
| 191 |
+
app.appendChild(totalButton);
|
| 192 |
+
|
| 193 |
+
const qrButton = document.createElement('button');
|
| 194 |
+
qrButton.textContent = 'Generar QR';
|
| 195 |
+
qrButton.className = 'btn btn-primary btn-block';
|
| 196 |
+
qrButton.onclick = () => {
|
| 197 |
+
const total = mesa.pedidos.reduce((sum, p) => sum + p.precio * p.cantidad, 0);
|
| 198 |
if (total > 0) {
|
| 199 |
generarTicket(index, total);
|
| 200 |
} else {
|
| 201 |
alert("La mesa no tiene productos");
|
| 202 |
}
|
| 203 |
};
|
| 204 |
+
app.appendChild(qrButton);
|
| 205 |
}
|
| 206 |
|
| 207 |
// Generación del PDF con jsPDF
|