evoluindo na função imprimir fichas

This commit is contained in:
2024-12-19 20:07:23 -03:00
parent 335c5e1911
commit 2ac5acf4c0
3 changed files with 19 additions and 4 deletions

View File

@@ -47,7 +47,6 @@ Detalhes {{comanda.name}}
<tr>
<td>{{item.product.name}}</td>
<td>R$ {{item.product.price}}</td>
<!-- <td><button id="open_remove_product_comanda" onclick="open_remove_product_comanda()">🗑️ Apagar</button></td> -->
<td><button hx-get="{% url 'removeProductComanda' item.id %} " hx-trigger="click" hx-target="#list-products-comanda" onclick="open_remove_product_comanda()">🗑️ Apagar</button></td>
</tr>

Binary file not shown.

View File

@@ -18,12 +18,28 @@ function removeCloseModal() {
function imprimirFichas() {
const element = document.getElementById("list-products-comanda");
const style = `<style>
td, th {
border-collapse: collapse;
padding-top: 35px;
margin: 20px;
text-align: center;
font-size: 24px;}
</style>`;
const agora = new Date();
var dateString = agora.getDay() + '/' + agora.getMonth() + '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes()+' - Raul Rock Bar & Café';
if (element) {
var content = element.innerHTML;
console.log(content);
// console.log(content);
content = content.replace(/<button[^>]*>(?:(?!<\/button>)[\s\S])*<\/button>/gi,'');
const printWindow = window.open('', '_blank');
printWindow.document.write('<table>'+content+'</table>');
content = content.replace(/<th[^>]*>(?:(?!<\/th>)[\s\S])*<\/th>/gi,'');
content = content.replace(/<\/tr>/g,'</tr><tr><td colspan="2" style="font-size: 12px">'+dateString+'</td></tr>');
console.log(content);
var printWindow = window.open('', '_blank');
printWindow.document.write('<table>'+content+'</table>'+style);
printWindow.document.close();
printWindow.print();
printWindow.close();