style e verificaçao: display flex para os botoes da viewComandas | verificação para apagar produto da comanda

This commit is contained in:
2025-03-28 14:28:35 -03:00
parent ac2a0283d0
commit b35fc39a60
5 changed files with 35 additions and 28 deletions

View File

@@ -102,27 +102,29 @@ def removeProductComanda(request, productComanda_id):
} }
product_comanda = ProductComanda.objects.get(id=productComanda_id) product_comanda = ProductComanda.objects.get(id=productComanda_id)
comanda = Comanda.objects.get(id= product_comanda.comanda.id) comanda = Comanda.objects.get(id= product_comanda.comanda.id)
parcial = Payments.objects.filter(comanda=comanda) if comanda.status == 'OPEN':
consumo = ProductComanda.objects.filter(comanda=comanda) parcial = Payments.objects.filter(comanda=comanda)
valores = somar(consumo,comanda) consumo = ProductComanda.objects.filter(comanda=comanda)
if product_comanda.product.cuisine == True: valores = somar(consumo,comanda)
order = Order.objects.get(productComanda=product_comanda) if product_comanda.product.cuisine == True:
product_comanda.delete() order = Order.objects.get(productComanda=product_comanda)
msg = JsonResponse({ product_comanda.delete()
'type': 'broadcast', msg = JsonResponse({
'message': 'Atenção! Pedido cancelado', 'type': 'broadcast',
'local':'cozinha', 'message': 'Atenção! Pedido cancelado',
'tipo':'delete', 'local':'cozinha',
'id':order.id, 'tipo':'delete',
'speak': f'Pedido cancelado! {order.id_product.name}.' 'id':order.id,
}) 'speak': f'Pedido cancelado! {order.id_product.name}.'
asyncio.run(enviar_mensagem(msg)) })
# order.delete() asyncio.run(enviar_mensagem(msg))
# order.delete()
else:
product_comanda.delete()
return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'config':config, 'valores': valores,'parcials':parcial,'consumo': consumo, 'comanda':comanda})
else: else:
product_comanda.delete() pass
return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'config':config, 'valores': valores,'parcials':parcial,'consumo': consumo, 'comanda':comanda})

View File

@@ -21,7 +21,7 @@ Detalhes {{comanda.name}}
<body> <body>
<input hidden id="id-temp" type="number"> <input hidden id="id-temp" type="number">
<div class="grid-container" > <div class="grid-container" >
<div> <div style="display: flex;padding: 5px;gap:8px">
<button class="btn-primary" id="openModal" onclick="openModal()" popovertarget="addProduct" <button class="btn-primary" id="openModal" onclick="openModal()" popovertarget="addProduct"
{% if comanda.status != 'OPEN'%} {% if comanda.status != 'OPEN'%}
disabled disabled
@@ -38,6 +38,11 @@ Detalhes {{comanda.name}}
<button class="btn-secondary" id="pagarComanda" <button class="btn-secondary" id="pagarComanda"
onclick="modal_payment_comanda()" onclick="modal_payment_comanda()"
>Receber</button> >Receber</button>
<button class="btn-primary" id="printComanda"
style="display: flex;"
onclick="imprimirConta()"
>Imprimir Conta</button>
{% else %} {% else %}
<button class="btn-secondary" id="pagarComanda" <button class="btn-secondary" id="pagarComanda"
@@ -45,12 +50,12 @@ Detalhes {{comanda.name}}
style="display: none;" style="display: none;"
>Receber</button> >Receber</button>
<button class="btn-primary" id="printComanda"
style="display: none;"
onclick="imprimirConta()"
>Imprimir Conta</button>
{% endif %} {% endif %}
<button class="btn-primary" id="printComanda"
style="display: none;"
onclick="imprimirConta()">Imprimir Conta</button>
{% if user|groupUser:"Gerente" %} {% if user|groupUser:"Gerente" %}
<button class="btn-primary" id="reOpenComanda" hx-get="{% url 'reopenComanda' comanda.id %} " hx-trigger="click" hx-swap="none" onclick="reloadPage()" <button class="btn-primary" id="reOpenComanda" hx-get="{% url 'reopenComanda' comanda.id %} " hx-trigger="click" hx-swap="none" onclick="reloadPage()"

Binary file not shown.

View File

@@ -208,11 +208,11 @@ function closeConta(id){
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if(data.status == 'ok'){ if(data.status == 'ok'){
buttonPrintComanda.style.display = 'block' buttonPrintComanda.style.display = 'flex'
buttonClose.style.display = 'none' buttonClose.style.display = 'none'
buttonAdd.style.display = 'none' buttonAdd.style.display = 'none'
buttonreOpenComanda.style.display = 'block' buttonreOpenComanda.style.display = 'flex'
buttonPayment.style.display = 'block' buttonPayment.style.display = 'flex'
showToast('✅Comanda encerrada!😁','success') showToast('✅Comanda encerrada!😁','success')
imprimirConta() imprimirConta()
} }