diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc index 89427d4..599eb80 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 f0e50d3..f9dd458 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/htmx_views.py b/gestaoRaul/comandas/htmx_views.py index 6aa19c7..f017cf7 100644 --- a/gestaoRaul/comandas/htmx_views.py +++ b/gestaoRaul/comandas/htmx_views.py @@ -1,7 +1,9 @@ -from django.shortcuts import render, redirect +from django.shortcuts import render, redirect, HttpResponse from comandas.models import Comanda, ProductComanda from products.models import Product +from payments.models import Payments +from typePay.models import TypePay def listProduct(request, comanda_id): @@ -29,9 +31,30 @@ def removeProductComanda(request, productComanda_id): return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total}) def closeComanda(request, comanda_id): - # id = request.POST.get('id-comanda') - # comanda_id = int(id) comanda = Comanda.objects.get(id=comanda_id) comanda.status = "PAYING" comanda.save() - return redirect('comandas') \ No newline at end of file + # return redirect('back') + + +def reopenComanda(request, comanda_id): + comanda = Comanda.objects.get(id=comanda_id) + if comanda.status == 'CLOSED': + pass + else: + comanda.status = "OPEN" + comanda.save() + # return redirect('back') + +def paymentComanda(request, comanda_id): + typePayment = TypePay.objects.get(id=1) + consumo = ProductComanda.objects.filter(comanda=comanda_id) + comanda = Comanda.objects.get(id=comanda_id) + total = 0 + for produto in consumo: + total += produto.product.price + pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description='tipo de pagamento mokado') + pagamento.save() + comanda.status = 'CLOSED' + comanda.save() + return redirect('comandas') diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index 45a0bd4..194b22a 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -27,23 +27,34 @@ Detalhes {{comanda.name}} {% endif %} >Adicionar Produto - - - + + + -
Nome: {{comanda.name}} | Mesa: {{comanda.mesa}} @@ -63,7 +74,11 @@ Detalhes {{comanda.name}} {{item.product.name}} R$ {{item.product.price}} - + @@ -124,6 +139,24 @@ Detalhes {{comanda.name}} + + diff --git a/gestaoRaul/comandas/urls.py b/gestaoRaul/comandas/urls.py index 3501964..9bf1eec 100644 --- a/gestaoRaul/comandas/urls.py +++ b/gestaoRaul/comandas/urls.py @@ -20,6 +20,8 @@ htmx_urlpatterns = [ path('addProduct//', htmx_views.addProduct, name='addProduct'), path('removeProductComanda/', htmx_views.removeProductComanda, name='removeProductComanda'), path('closeComanda/', htmx_views.closeComanda, name='closeComanda'), + path('reopenComanda/', htmx_views.reopenComanda, name='reopenComanda'), + path('paymentComanda/', htmx_views.paymentComanda, name='paymentComanda'), ] urlpatterns += htmx_urlpatterns \ No newline at end of file diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 710ba1e..71ce128 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-313.pyc b/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-313.pyc index 12cc2b7..d3b2366 100644 Binary files a/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-313.pyc and b/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-313.pyc differ diff --git a/gestaoRaul/gestaoRaul/settings.py b/gestaoRaul/gestaoRaul/settings.py index 7b4f20e..1655c38 100644 --- a/gestaoRaul/gestaoRaul/settings.py +++ b/gestaoRaul/gestaoRaul/settings.py @@ -52,6 +52,7 @@ INSTALLED_APPS = [ 'comandas', 'categories', 'home', + 'payments', ] MIDDLEWARE = [ diff --git a/gestaoRaul/payments/__pycache__/__init__.cpython-313.pyc b/gestaoRaul/payments/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..51c00e9 Binary files /dev/null and b/gestaoRaul/payments/__pycache__/__init__.cpython-313.pyc differ diff --git a/gestaoRaul/payments/__pycache__/admin.cpython-313.pyc b/gestaoRaul/payments/__pycache__/admin.cpython-313.pyc new file mode 100644 index 0000000..14089d9 Binary files /dev/null and b/gestaoRaul/payments/__pycache__/admin.cpython-313.pyc differ diff --git a/gestaoRaul/payments/__pycache__/apps.cpython-313.pyc b/gestaoRaul/payments/__pycache__/apps.cpython-313.pyc new file mode 100644 index 0000000..4f6f335 Binary files /dev/null and b/gestaoRaul/payments/__pycache__/apps.cpython-313.pyc differ diff --git a/gestaoRaul/payments/__pycache__/models.cpython-313.pyc b/gestaoRaul/payments/__pycache__/models.cpython-313.pyc new file mode 100644 index 0000000..fe8c717 Binary files /dev/null and b/gestaoRaul/payments/__pycache__/models.cpython-313.pyc differ diff --git a/gestaoRaul/payments/migrations/0001_initial.py b/gestaoRaul/payments/migrations/0001_initial.py new file mode 100644 index 0000000..750b11b --- /dev/null +++ b/gestaoRaul/payments/migrations/0001_initial.py @@ -0,0 +1,30 @@ +# Generated by Django 5.1.4 on 2024-12-20 17:33 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('clients', '0001_initial'), + ('comandas', '0003_comanda_status_alter_productcomanda_product'), + ('typePay', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Payments', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('value', models.DecimalField(decimal_places=2, max_digits=10)), + ('description', models.CharField(max_length=255)), + ('datetime', models.DateTimeField(auto_now_add=True)), + ('client', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='clients.client')), + ('comanda', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='comandas.comanda')), + ('type_pay', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='typePay.typepay')), + ], + ), + ] diff --git a/gestaoRaul/payments/migrations/__pycache__/0001_initial.cpython-313.pyc b/gestaoRaul/payments/migrations/__pycache__/0001_initial.cpython-313.pyc new file mode 100644 index 0000000..07e806a Binary files /dev/null and b/gestaoRaul/payments/migrations/__pycache__/0001_initial.cpython-313.pyc differ diff --git a/gestaoRaul/payments/migrations/__pycache__/__init__.cpython-313.pyc b/gestaoRaul/payments/migrations/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..a6e8988 Binary files /dev/null and b/gestaoRaul/payments/migrations/__pycache__/__init__.cpython-313.pyc differ diff --git a/gestaoRaul/templates/static/comandas/js/viewcomanda.js b/gestaoRaul/templates/static/comandas/js/viewcomanda.js index b4d641b..67e5b77 100644 --- a/gestaoRaul/templates/static/comandas/js/viewcomanda.js +++ b/gestaoRaul/templates/static/comandas/js/viewcomanda.js @@ -7,6 +7,14 @@ function open_remove_product_comanda() { document.getElementById('remove-product-comanda').style.display = 'block'; } +function modal_payment_comanda() { + document.getElementById('payment-comanda').style.display = 'block'; +} + +function close_modal_payment_comanda() { + document.getElementById('payment-comanda').style.display = 'none'; +} + function closeModal() { document.getElementById('Modal-add-product').style.display = 'none'; } @@ -49,6 +57,53 @@ function imprimirFichas() { } +function imprimirConta() { + reloadPage(); + const element = document.getElementById("list-products-comanda"); + const style = ``; + const agora = new Date(); + var dateString = agora.getDay() + '/' + agora.getMonth() + '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes()+' - Raul Rock Bar & Café'; + + if (element) { + var content = element.innerHTML; + // console.log(content); + content = content.replace(/]*>(?:(?!<\/button>)[\s\S])*<\/button>/gi,''); + content = content.replace(/]*>(?:(?!<\/th>)[\s\S])*<\/th>/gi,''); + // content = content.replace(/<\/tr>/g,''+dateString+''); + console.log(content); + + var printWindow = window.open('', '_blank'); + printWindow.document.write(''+content+'
'+style); + printWindow.document.close(); + printWindow.print(); + printWindow.close(); + } else { + console.error(`Element with ID not found`); + } + } + +function reloadPage(){ + setTimeout(function() { + location.reload();}, 100); +} + +function backPage() { + setTimeout(function() { + history.back();}, 100); + setTimeout(function() { + location.reload();}, 100); +} + + + document.getElementById('openModal').addEventListener('click', openModal);