feat: obs from orders print

This commit is contained in:
2025-03-21 16:34:14 -03:00
parent 725e566d74
commit 53d156b919
9 changed files with 47 additions and 15 deletions

View File

@@ -86,7 +86,8 @@ Detalhes {{comanda.name}}
<td id="id-for-print-{{item.id}}"> <td id="id-for-print-{{item.id}}">
{{item.product.name}} {{item.product.name}}
{% if item.product.cuisine == True %} {% if item.product.cuisine == True %}
<span data-tooltip="Observações para preparo." data-flow="top"> <input hidden id="{{item.id}}-obsOrder" type="order" value="{{item.id | obsOrder}}">
<span data-tooltip="{{item.id | obsOrder}}" data-flow="top">
<img <img
onclick="openModalObs({{item.id}})" onclick="openModalObs({{item.id}})"

View File

@@ -1,5 +1,6 @@
from decimal import Decimal from decimal import Decimal
from django import template from django import template
from orders.models import Order
from comandas.models import Comanda, ProductComanda from comandas.models import Comanda, ProductComanda
from clients.models import Client from clients.models import Client
@@ -53,4 +54,16 @@ def viewClient(clientId):
@register.filter(name='groupUser') @register.filter(name='groupUser')
def has_group(user, group_name): def has_group(user, group_name):
return user.groups.filter(name=group_name).exists() return user.groups.filter(name=group_name).exists()
@register.filter(name='obsOrder')
def obsOrder(id):
product_comanda_obj = ProductComanda.objects.get(pk=id) # Supondo que você tenha o ID do ProductComanda
produto_associado = product_comanda_obj.product
pedidos_relacionados = Order.objects.filter(id_product=produto_associado)
pedido = pedidos_relacionados[0]
return pedido.obs

View File

@@ -48,6 +48,7 @@ def viewComanda(request):
comanda_id = int(id) comanda_id = int(id)
comanda = Comanda.objects.get(id=comanda_id) comanda = Comanda.objects.get(id=comanda_id)
consumo = ProductComanda.objects.filter(comanda=comanda_id) consumo = ProductComanda.objects.filter(comanda=comanda_id)
# consumo[0].product.
parcial = Payments.objects.filter(comanda=comanda_id) parcial = Payments.objects.filter(comanda=comanda_id)
mesas = Mesa.objects.all() mesas = Mesa.objects.all()
clients = Client.objects.filter(active=True) clients = Client.objects.filter(active=True)
@@ -63,6 +64,7 @@ def viewComanda(request):
if p.name == produto['nome'] and p.active == True: if p.name == produto['nome'] and p.active == True:
products_ordenados.append(p) products_ordenados.append(p)
valores = somar(consumo,comanda) valores = somar(consumo,comanda)
return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados,'mesas':mesas}) return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados,'mesas':mesas})

Binary file not shown.

View File

@@ -11,7 +11,8 @@
<td id="id-for-print-{{item.id}}"> <td id="id-for-print-{{item.id}}">
{{item.product.name}} {{item.product.name}}
{% if item.product.cuisine == True %} {% if item.product.cuisine == True %}
<span data-tooltip="Observações para preparo." data-flow="top"> <input hidden id="{{item.id}}-obsOrder" type="order" value="{{item.id | obsOrder}}">
<span data-tooltip="{{item.id | obsOrder}}" data-flow="top">
<img <img
onclick="openModalObs({{item.id}})" onclick="openModalObs({{item.id}})"

View File

@@ -68,36 +68,50 @@ websocket.addEventListener('message', (event) => {
switch (data.local) { switch (data.local) {
case 'cozinha': case 'cozinha':
if (document.getElementById('Fila') !== null && data.tipo === 'add'){ if (document.getElementById('Fila') !== null && data.tipo === 'add'){
const novoElemento = document.createElement('div');
// const novoElemento = document.getElementById('Fila');
novoElemento.innerHTML = data.message; // const novoElemento = document.createElement('div');
var fila = document.getElementById('Fila').appendChild(novoElemento); // novoElemento.innerHTML = data.message;
// var fila = document.getElementById('Fila').appendChild(novoElemento);
let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1"); let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
if (valorAtual === 'true') { if (valorAtual === 'true') {
texto = new SpeechSynthesisUtterance(data.speak); texto = new SpeechSynthesisUtterance(data.speak);
window.speechSynthesis.speak(texto); window.speechSynthesis.speak(texto);
setTimeout(function() {
location.reload();
}, 6000);
} }
} }
else if (document.getElementById('obs-'+data.id) !== null && data.tipo === 'edit'){ else if (document.getElementById('obs-'+data.id) !== null && data.tipo === 'edit'){
const obs = document.getElementById('obs-'+data.id) const obs = document.getElementById('obs-'+data.id)
const card = obs.parentNode; // const card = obs.parentNode;
card.style.backgroundColor = 'rgb(243, 165, 75)'; // card.style.backgroundColor = 'rgb(243, 165, 75)';
obs.innerHTML = data.message; // obs.innerHTML = data.message;
let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1"); let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
if (valorAtual === 'true') { if (valorAtual === 'true') {
texto = new SpeechSynthesisUtterance(data.speak); texto = new SpeechSynthesisUtterance(data.speak);
window.speechSynthesis.speak(texto); window.speechSynthesis.speak(texto);
setTimeout(function() {
location.reload();
}, 6000);
} }
} }
else if (document.getElementById('m-card-'+data.id) !== null && data.tipo === 'delete'){ else if (document.getElementById('m-card-'+data.id) !== null && data.tipo === 'delete'){
const card = document.getElementById('m-card-'+data.id) // const card = document.getElementById('m-card-'+data.id)
card.style.backgroundColor = 'rgb(253, 69, 69)'; // card.style.backgroundColor = 'rgb(253, 69, 69)';
let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1"); let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1");
if (valorAtual === 'true') { if (valorAtual === 'true') {
texto = new SpeechSynthesisUtterance(data.speak); texto = new SpeechSynthesisUtterance(data.speak);
window.speechSynthesis.speak(texto); window.speechSynthesis.speak(texto);
setTimeout(function() {
location.reload();
}, 6000);
} }
} }

View File

@@ -114,6 +114,7 @@ function printOrder(id) {
var item = document.getElementById('id-for-print-'+id).innerText var item = document.getElementById('id-for-print-'+id).innerText
var cliente = document.getElementById('name-comanda').innerText var cliente = document.getElementById('name-comanda').innerText
var local = document.getElementById('mesa-comanda').innerText var local = document.getElementById('mesa-comanda').innerText
var obs = document.getElementById(id+'-obsOrder').value
const agora = new Date(); const agora = new Date();
var dateString = agora.getDate() + '/' + (agora.getMonth()+1) + '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes(); var dateString = agora.getDate() + '/' + (agora.getMonth()+1) + '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes();
console.log(item) console.log(item)
@@ -123,14 +124,14 @@ function printOrder(id) {
td, th { td, th {
border-collapse: collapse; border-collapse: collapse;
padding-top: 35px; padding-top: 20px;
margin: 20px; margin: 20px;
text-align: center; text-align: center;
font-size: 20px;} font-size: 20px;}
</style> </style>
<tr><td>${item}</td></tr> <tr><td>${item}</td></tr>
<tr><td>${cliente}</td></tr> <tr><td>${obs}</td></tr>
<tr><td>${local}</td></tr> <tr><td>${cliente}${local}</td></tr>
<tr><td>${dateString}</td></tr> <tr><td>${dateString}</td></tr>
`; `;