diff --git a/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc index 0925044..a77ea7a 100644 Binary files a/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc index a79bde7..9fa1582 100644 Binary files a/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc index 2e07121..6fe7555 100644 Binary files a/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/models.py b/gestaoRaul/comandas/models.py index 2235073..0e3672b 100644 --- a/gestaoRaul/comandas/models.py +++ b/gestaoRaul/comandas/models.py @@ -14,10 +14,14 @@ class Comanda(models.Model): dt_close = models.DateTimeField(null=True, blank=True) client = models.ForeignKey(Client, on_delete=models.SET_NULL, null=True, blank=True) name = models.CharField(max_length=255) + def __str__(self) -> str: + return self.name class ProductComanda(models.Model): id = models.AutoField(primary_key=True) comanda = models.ForeignKey(Comanda, on_delete=models.CASCADE) data_time = models.DateTimeField(auto_now_add=True) product = models.ForeignKey(Product, on_delete=models.CASCADE) - applicant = models.CharField(max_length=255, null=True, blank=True) \ No newline at end of file + applicant = models.CharField(max_length=255, null=True, blank=True) + def __str__(self) -> str: + return self.comanda.name + " - " + self.product.name \ No newline at end of file diff --git a/gestaoRaul/comandas/templates/comandas.html b/gestaoRaul/comandas/templates/comandas.html index 7abc4b3..1bfd0ef 100644 --- a/gestaoRaul/comandas/templates/comandas.html +++ b/gestaoRaul/comandas/templates/comandas.html @@ -11,12 +11,15 @@ Comandas{% endblock %} {% endblock %} {% block 'body' %} -body> -
+ +
+ {% for comanda in comandas %} - + + + diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index e202a90..f4fed07 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -5,22 +5,73 @@ {% block 'title' %} -Comandas{% endblock %} +Detalhes {{comanda.name}} +{% endblock %} + + + + {% block 'head' %} {% endblock %} + + {% block 'body' %} -body> +
-

{{comanda.id}}

-

{{comanda.name}}

-

{{comanda.mesa}}

-

{{comanda.dt_open}}

+ + +

{{comanda.name}}

+

{{comanda.mesa}}

+

{{comanda.dt_open}}

+ + + + + + + {% for item in consumo%} + + + + + + + + + {% endfor %} + + + + + +
ProdutoPreço
{{item.product.name}}R$ {{item.product.price}}
Total R$ {{total}}
+
+ + + + + + + + + diff --git a/gestaoRaul/comandas/urls.py b/gestaoRaul/comandas/urls.py index 4b9539a..81d739d 100644 --- a/gestaoRaul/comandas/urls.py +++ b/gestaoRaul/comandas/urls.py @@ -5,6 +5,7 @@ from . import views urlpatterns = [ path('', views.comandas, name='comandas'), path('viewcomanda/', views.viewComanda, name='viewcomanda'), + path('createComanda/', views.createComanda, name='createComanda'), diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py index 8f5c437..476bde9 100644 --- a/gestaoRaul/comandas/views.py +++ b/gestaoRaul/comandas/views.py @@ -1,12 +1,14 @@ from django.shortcuts import render, redirect -from comandas.models import Comanda +from comandas.models import Comanda, ProductComanda +from mesas.models import Mesa # Create your views here. def comandas(request): comandas = Comanda.objects.all() - return render(request, 'comandas.html', {'comandas': comandas}) + mesas = Mesa.objects.all() + return render(request, 'comandas.html', {'comandas': comandas, 'mesas': mesas}) @@ -15,5 +17,27 @@ def viewComanda(request): id = request.GET.get('parametro') comanda_id = int(id) comanda = Comanda.objects.get(id=comanda_id) + consumo = ProductComanda.objects.filter(comanda=comanda_id) + total = 0 + for produto in consumo: + total += produto.product.price - return render(request, 'viewcomanda.html', {'comanda': comanda}) \ No newline at end of file + return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total}) + + +def addProduct(request): + pass + # id = request.GET.get('parametro') + # comanda_id = int(id) + # comanda = Comanda.objects.get(id=comanda_id) + # return render(request, 'addproduct.html', {'comanda': comanda}) + + +def createComanda(request): + name = request.POST.get('name-comanda') + mesa_id = int(request.POST.get('select-mesa')[0]) + mesa = Mesa.objects.get(id=mesa_id) + comanda = Comanda(name=name, mesa=mesa) + comanda.save() + + return redirect('comandas') \ No newline at end of file diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 7e27881..b5fae26 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/mesas/__pycache__/admin.cpython-310.pyc b/gestaoRaul/mesas/__pycache__/admin.cpython-310.pyc index 79f575d..496b963 100644 Binary files a/gestaoRaul/mesas/__pycache__/admin.cpython-310.pyc and b/gestaoRaul/mesas/__pycache__/admin.cpython-310.pyc differ diff --git a/gestaoRaul/mesas/admin.py b/gestaoRaul/mesas/admin.py index bfa7ebe..a3c618c 100644 --- a/gestaoRaul/mesas/admin.py +++ b/gestaoRaul/mesas/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from categories.models import Categories from clients.models import Client -from comandas.models import Comanda +from comandas.models import Comanda, ProductComanda from typePay.models import TypePay from products.models import Product from mesas.models import Mesa @@ -14,5 +14,6 @@ admin.site.register(Categories) admin.site.register(Client) admin.site.register(Comanda) admin.site.register(TypePay) +admin.site.register(ProductComanda) # Register your models here. diff --git a/gestaoRaul/templates/static/comandas/css/comandas.css b/gestaoRaul/templates/static/comandas/css/comandas.css index 0124740..34146c8 100644 --- a/gestaoRaul/templates/static/comandas/css/comandas.css +++ b/gestaoRaul/templates/static/comandas/css/comandas.css @@ -7,13 +7,13 @@ } .card { - width: 120px; - height: 120px; + width: 220px; + height: 220px; background-color: #f2f2f2; border-radius: 15px; box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2); text-align: center; - line-height: 120px; /* Centraliza o texto verticalmente */ + line-height: 50px; /* Centraliza o texto verticalmente */ font-size: 20px; font-weight: bold; color: #333; @@ -23,4 +23,57 @@ .card:hover { transform: scale(1.05); box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3); - } \ No newline at end of file + } + + + button { + background-color: #007BFF; + color: white; + padding: 10px 20px; + border: none; + border-radius: 5px; + cursor: pointer; +} + +button:hover { + background-color: #0056b3; +} + +.modal { + display: none; + position: fixed; + padding: 20px; + top: 50%; + left: 50%; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgba(0, 0, 0, 0.4); + transform: translate(-50%, -50%); +} + +.modal-content { + background-color: #fefefe; + margin: 15% auto; + padding: 20px; + border: 1px solid #888; + border-radius: 10px; + width: 90%; + max-width: 500px; +} + + +form { + display: flex; + flex-direction: column; + gap: 10px; +} + +input, textarea { + width: 95%; + max-width: 95%; + padding: 8px; + margin-top: 5px; + border-radius: 5px; + border: 1px solid #ccc; +} diff --git a/gestaoRaul/templates/static/comandas/css/viewcomanda.css b/gestaoRaul/templates/static/comandas/css/viewcomanda.css index 372b50b..2f38c3c 100644 --- a/gestaoRaul/templates/static/comandas/css/viewcomanda.css +++ b/gestaoRaul/templates/static/comandas/css/viewcomanda.css @@ -1,7 +1,7 @@ .grid-container { display: grid; - grid-template-columns: repeat(1, 2fr); - gap: 20px; + grid-template-columns: repeat(2, 2fr); + gap: 10px; max-width: 800px; /* Define a largura máxima do grid */ margin: 0 auto; /* Centraliza o grid na página */ } @@ -23,4 +23,64 @@ .card:hover { transform: scale(1.05); box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3); - } \ No newline at end of file + } + + table td th { + text-align: center; + } + + + + + button { + background-color: #007BFF; + color: white; + padding: 10px 20px; + border: none; + border-radius: 5px; + cursor: pointer; +} + +button:hover { + background-color: #0056b3; +} + +.modal { + display: none; + position: fixed; + padding: 20px; + top: 50%; + left: 50%; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgba(0, 0, 0, 0.4); + transform: translate(-50%, -50%); +} + +.modal-content { + background-color: #fefefe; + margin: 15% auto; + padding: 20px; + border: 1px solid #888; + border-radius: 10px; + width: 90%; + height: 90%; + max-width: 500px; +} + + +form { + display: flex; + flex-direction: column; + gap: 10px; +} + +input, textarea { + width: 95%; + max-width: 95%; + padding: 8px; + margin-top: 5px; + border-radius: 5px; + border: 1px solid #ccc; +} diff --git a/gestaoRaul/templates/static/comandas/js/comandas.js b/gestaoRaul/templates/static/comandas/js/comandas.js index e69de29..99a42ff 100644 --- a/gestaoRaul/templates/static/comandas/js/comandas.js +++ b/gestaoRaul/templates/static/comandas/js/comandas.js @@ -0,0 +1,21 @@ +function openModal() { + document.getElementById('Modal-create-comanda').style.display = 'block'; +} + +function closeModal() { + document.getElementById('Modal-create-comanda').style.display = 'none'; +} + +document.getElementById('openModal').addEventListener('click', openModal); + +// document.getElementById('form-comanda').addEventListener('submit', function(event) { +// event.preventDefault(); + + // const productName = document.getElementById('productName').value; + // const productPrice = document.getElementById('productPrice').value; + // const productDescription = document.getElementById('productDescription').value; + + // closeModal(); +// } +// ); + \ No newline at end of file diff --git a/gestaoRaul/templates/static/comandas/js/viewcomanda.js b/gestaoRaul/templates/static/comandas/js/viewcomanda.js new file mode 100644 index 0000000..149ed10 --- /dev/null +++ b/gestaoRaul/templates/static/comandas/js/viewcomanda.js @@ -0,0 +1,20 @@ +function openModal() { + document.getElementById('Modal-add-product').style.display = 'block'; +} + +function closeModal() { + document.getElementById('Modal-add-product').style.display = 'none'; +} + +document.getElementById('openModal').addEventListener('click', openModal); + +document.getElementById('productForm').addEventListener('submit', function(event) { + event.preventDefault(); + + // const productName = document.getElementById('productName').value; + // const productPrice = document.getElementById('productPrice').value; + // const productDescription = document.getElementById('productDescription').value; + + // closeModal(); +}); + \ No newline at end of file