diff --git a/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc index 5bad460..f14f58b 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 592de94..168de6e 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/templates/comandas.html b/gestaoRaul/comandas/templates/comandas.html index 554d35c..90a07ae 100644 --- a/gestaoRaul/comandas/templates/comandas.html +++ b/gestaoRaul/comandas/templates/comandas.html @@ -60,7 +60,7 @@ Comandas - + diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index eaa8d1f..0c65e75 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -63,9 +63,16 @@ Detalhes {{comanda.name}}
+ Nome: {{comanda.name}} | Mesa: {{comanda.mesa}} + + +

Aberta em: {{comanda.dt_open|date:"D"}} {{comanda.dt_open|date:"d/m/Y - H:i"}}

@@ -164,6 +171,31 @@ Detalhes {{comanda.name}} + + +
+
+ {% csrf_token %} +

Editar Comanda

+ + +
+ + + + +
+
+
+ + + diff --git a/gestaoRaul/comandas/urls.py b/gestaoRaul/comandas/urls.py index 5012b3e..5ba273a 100644 --- a/gestaoRaul/comandas/urls.py +++ b/gestaoRaul/comandas/urls.py @@ -8,6 +8,7 @@ urlpatterns = [ path('', views.comandas, name='comandas'), path('viewcomanda/', views.viewComanda, name='viewcomanda'), path('createComanda/', views.createComanda, name='createComanda'), + path('editComanda/', views.editComanda, name='editComanda'), diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py index 7489f26..8c193ef 100644 --- a/gestaoRaul/comandas/views.py +++ b/gestaoRaul/comandas/views.py @@ -20,6 +20,7 @@ def viewComanda(request): comanda_id = int(id) comanda = Comanda.objects.get(id=comanda_id) consumo = ProductComanda.objects.filter(comanda=comanda_id) + mesas = Mesa.objects.all() produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate( quantidade=Count('product'), @@ -35,7 +36,7 @@ def viewComanda(request): for produto in consumo: total += produto.product.price - return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados}) + return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados,'mesas':mesas}) @group_required(groupName='Garçom') @@ -47,3 +48,13 @@ def createComanda(request): comanda.save() return redirect('comandas') +@group_required(groupName='Garçom') +def editComanda(request): + name = request.POST.get('nameComanda') + comanda = Comanda.objects.get(id=int(request.POST.get('h-comandaId'))) + mesa = Mesa.objects.get(id=int(request.POST.get('select-mesa'))) + comanda.mesa = mesa + comanda.name = name + comanda.save() + return redirect('comandas') + diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 2119300..6f071a4 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 03fdf9d..5000bd6 100644 --- a/gestaoRaul/templates/static/comandas/js/viewcomanda.js +++ b/gestaoRaul/templates/static/comandas/js/viewcomanda.js @@ -3,6 +3,22 @@ function openModal() { document.getElementById('Modal-add-product').style.display = 'block'; } +function openModalAlter() { + document.getElementById('Modal-alter-comanda').style.display = 'block'; + var name = document.getElementById('name-comanda').innerText.replace('Nome: ','').replace(' | ', '') + var mesa = document.getElementById('h-mesaId').value + console.log(name) + console.log(mesa) + + var fildName = document.getElementById('nameComanda') + fildName.value = name + var fildMesa = document.getElementById('select-mesa') + fildMesa.value = mesa +} + +function closeModalAlter() { + document.getElementById('Modal-alter-comanda').style.display = 'none'; +} function openModalObs(id) { document.getElementById('modal-obs').style.display = 'block'; idd = document.getElementById('id-temp').value = id;