mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
alter: alteracao metodo POST osbOrder
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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')
|
||||
|
||||
@@ -87,7 +87,7 @@ Detalhes {{comanda.name}}
|
||||
{{item.product.name}}
|
||||
{% if item.product.cuisine == True %}
|
||||
<input hidden id="{{item.id}}-obsOrder" type="order" value="{{item.id | obsOrder}}">
|
||||
<span data-tooltip="{{item.id | obsOrder}}" data-flow="top">
|
||||
<span id="tooltip-id-{{item.id}}" data-tooltip="{{item.id | obsOrder}}" data-flow="top">
|
||||
|
||||
<img
|
||||
onclick="openModalObs({{item.id}})"
|
||||
@@ -106,9 +106,6 @@ Detalhes {{comanda.name}}
|
||||
</td>
|
||||
<td>R$ {{item.product.price}}</td>
|
||||
|
||||
|
||||
|
||||
|
||||
{% if comanda.status != 'OPEN'%}
|
||||
{% else %}
|
||||
<td>
|
||||
|
||||
Binary file not shown.
@@ -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/<int:productComanda_id>/<str:obs>', views.editOrders, name='editOrders'),
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +23,6 @@ htmx_urlpatterns = [
|
||||
path('listProduct/<int:comanda_id>/', htmx_views.listProduct, name='listProduct'),
|
||||
path('addProduct<int:product_id>/<int:comanda_id>/', htmx_views.addProduct, name='addProduct'),
|
||||
path('removeProductComanda<int:productComanda_id>/', htmx_views.removeProductComanda, name='removeProductComanda'),
|
||||
path('editOrders/<int:productComanda_id>/<str:obs>', htmx_views.editOrders, name='editOrders'),
|
||||
path('closeComanda<int:comanda_id>/', htmx_views.closeComanda, name='closeComanda'),
|
||||
path('reopenComanda<int:comanda_id>/', htmx_views.reopenComanda, name='reopenComanda'),
|
||||
path('paymentComanda<int:comanda_id>/', htmx_views.paymentComanda, name='paymentComanda'),
|
||||
|
||||
@@ -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})
|
||||
Binary file not shown.
@@ -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();
|
||||
// });
|
||||
|
||||
|
||||
@@ -53,9 +53,11 @@ 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(response => response.json())
|
||||
.then(data => {
|
||||
if(data.status != 'ok'){
|
||||
alert('Erro ao salvar local:', error)
|
||||
|
||||
Reference in New Issue
Block a user