diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc index 7ed29ab..b7b10ac 100644 Binary files a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc and b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc index 499be1b..706b9f3 100644 Binary files a/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc and b/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc index bfce7f7..e068e05 100644 Binary files a/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc and b/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/htmx_views.py b/gestaoRaul/comandas/htmx_views.py index 5973fab..f243484 100644 --- a/gestaoRaul/comandas/htmx_views.py +++ b/gestaoRaul/comandas/htmx_views.py @@ -93,21 +93,21 @@ def addProduct(request, product_id, comanda_id): return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'config':config, 'valores':valores,'parcials':parcial,'consumo': consumo,'comanda':comanda}) -@group_required(groupName='Garçom') -def editOrders(request, productComanda_id, obs): - order = Order.objects.get(productComanda=productComanda_id) - order.obs = obs - order.save() - msg = JsonResponse({ - 'type': 'broadcast', - 'message': obs, - 'local':'cozinha', - 'tipo':'edit', - 'id':order.id, - 'speak': f'Pedido alterado! {order.id_product.name}, é {obs}.' - }) - asyncio.run(enviar_mensagem(msg)) - return JsonResponse({'status': 'ok'}) +# @group_required(groupName='Garçom') +# def editOrders(request, productComanda_id, obs): +# order = Order.objects.get(productComanda=productComanda_id) +# order.obs = obs +# order.save() +# msg = JsonResponse({ +# 'type': 'broadcast', +# 'message': obs, +# 'local':'cozinha', +# 'tipo':'edit', +# 'id':order.id, +# 'speak': f'Pedido alterado! {order.id_product.name}, é {obs}.' +# }) +# # asyncio.run(enviar_mensagem(msg)) +# return JsonResponse({'status': 'ok'}) @group_required(groupName='Garçom') diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index 51d05e4..54f8db2 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -87,7 +87,7 @@ Detalhes {{comanda.name}} {{item.product.name}} {% if item.product.cuisine == True %} - + R$ {{item.product.price}} - - - {% if comanda.status != 'OPEN'%} {% else %} diff --git a/gestaoRaul/comandas/templatetags/__pycache__/custom_filter_tag.cpython-313.pyc b/gestaoRaul/comandas/templatetags/__pycache__/custom_filter_tag.cpython-313.pyc index c1decab..6cf9ae2 100644 Binary files a/gestaoRaul/comandas/templatetags/__pycache__/custom_filter_tag.cpython-313.pyc and b/gestaoRaul/comandas/templatetags/__pycache__/custom_filter_tag.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/urls.py b/gestaoRaul/comandas/urls.py index 0667507..6964903 100644 --- a/gestaoRaul/comandas/urls.py +++ b/gestaoRaul/comandas/urls.py @@ -11,6 +11,7 @@ urlpatterns = [ path('editComanda/', views.editComanda, name='editComanda'), path('addContaCliente/', views.addContaCliente, name='addContaCliente'), path('notificacao/', views.notificacao, name='notificacao'), + path('editOrders//', views.editOrders, name='editOrders'), @@ -22,7 +23,6 @@ htmx_urlpatterns = [ path('listProduct//', htmx_views.listProduct, name='listProduct'), path('addProduct//', htmx_views.addProduct, name='addProduct'), path('removeProductComanda/', htmx_views.removeProductComanda, name='removeProductComanda'), - path('editOrders//', htmx_views.editOrders, name='editOrders'), path('closeComanda/', htmx_views.closeComanda, name='closeComanda'), path('reopenComanda/', htmx_views.reopenComanda, name='reopenComanda'), path('paymentComanda/', htmx_views.paymentComanda, name='paymentComanda'), diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py index 7e379df..fd92fbe 100644 --- a/gestaoRaul/comandas/views.py +++ b/gestaoRaul/comandas/views.py @@ -138,3 +138,21 @@ def notificacao(request): 'notificacao': 'false', 'pronto':len(ordersPronto), }) + + + +@group_required(groupName='Garçom') +def editOrders(request, productComanda_id, obs): + order = Order.objects.get(productComanda=productComanda_id) + order.obs = obs + order.save() + msg = JsonResponse({ + 'type': 'broadcast', + 'message': obs, + 'local':'cozinha', + 'tipo':'edit', + 'id':order.id, + 'speak': f'Pedido alterado! {order.id_product.name}, é {obs}.' + }) + # asyncio.run(enviar_mensagem(msg)) + return JsonResponse({'status': 'ok', 'obs':order.obs}) \ No newline at end of file diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 27e81e1..68abbaf 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/templates/static/comandas/js/viewcomanda.js b/gestaoRaul/templates/static/comandas/js/viewcomanda.js index ef5b31b..517e3d5 100644 --- a/gestaoRaul/templates/static/comandas/js/viewcomanda.js +++ b/gestaoRaul/templates/static/comandas/js/viewcomanda.js @@ -213,22 +213,43 @@ function troco(){ function addOrder(){ - obs = document.getElementById('obs').value - var id = document.getElementById('id-temp').value - fetch(`/comandas/editOrders/${id}/${obs}`, { - method: 'GET', + obs = document.getElementById('obs') + id = document.getElementById('id-temp').value + tooltipObs = document.getElementById('tooltip-id-'+id) + + fetch(`/comandas/editOrders/${id}/${obs.value}`, { + method: 'POST', headers: { - 'Content-Type': 'application/json'} + 'Content-Type': 'application/json', + 'X-CSRFToken': document.querySelector('[name="csrfmiddlewaretoken"]').value} }) - .then(function(response) { - if(response.status == 200){ - closeModalObs() + .then(response => response.json()) + .then(data => { + if(data.status == 'ok'){ showToast('✅Pedido atualizado com sucesso!😁','success') - }else{ - showToast('❌Ocorreu um erro!😢','error') - } + tooltipObs.dataset.tooltip = data.obs + obs.value = '' + document.getElementById('modal-obs').style.display = 'none'; + + } }) + .catch(error => { + showToast('❌Ocorreu um erro!😢','error') + }); + + + // .then(function(response) { + // if(response.status == 200){ + // closeModalObs() + // showToast('✅Pedido atualizado com sucesso!😁','success') + // tooltipObs.dataset.tooltip = response.data + // }else{ + // showToast('❌Ocorreu um erro!😢','error') + // } + // }) } + + function showToastAdd(message, type ,duration = 3000) { const toast = document.getElementById('toast-add'); @@ -281,9 +302,4 @@ function taxa(){ } } -// document.getElementById('taxa').addEventListener("change", taxa); - -// document.getElementById('productForm').addEventListener('submit', function(event) { -// event.preventDefault(); -// }); diff --git a/gestaoRaul/templates/static/mesas/js/mesas_map.js b/gestaoRaul/templates/static/mesas/js/mesas_map.js index cbe0c6d..7c8764e 100644 --- a/gestaoRaul/templates/static/mesas/js/mesas_map.js +++ b/gestaoRaul/templates/static/mesas/js/mesas_map.js @@ -53,11 +53,13 @@ if (parentNodeClass == 'espaco' || targetId == 'drop'){ const url = `/mesas/locationMesa/${mesaId}/${targetId}/`; var resposta = fetch(url, {method: 'POST', - headers: {'Content-Type': 'application/json', + headers: { + 'Content-Type': 'application/json', 'X-CSRFToken': document.querySelector('[name="csrfmiddlewaretoken"]').value - },}).then(response => response.json()) - .then(data => { - if(data.status != 'ok'){ + },}) + .then(response => response.json()) + .then(data => { + if(data.status != 'ok'){ alert('Erro ao salvar local:', error) } })