mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
captura de dados pra dashbooad
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -6,12 +6,12 @@ from payments.models import Payments
|
||||
from typePay.models import TypePay
|
||||
|
||||
|
||||
def listProduct(request, comanda_id):
|
||||
def listProductBalcao(request, comanda_id):
|
||||
product = request.GET.get("search-product")
|
||||
products = Product.objects.filter(name__icontains=product)
|
||||
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products,'comanda_id':comanda_id})
|
||||
|
||||
def addProduct(request, product_id, comanda_id):
|
||||
def addProductBalcao(request, product_id, comanda_id):
|
||||
product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id)
|
||||
product_comanda.save()
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
@@ -21,7 +21,7 @@ def addProduct(request, product_id, comanda_id):
|
||||
return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total})
|
||||
|
||||
|
||||
def removeProductComanda(request, productComanda_id):
|
||||
def removeProductBalcao(request, productComanda_id):
|
||||
product_comanda = ProductComanda.objects.get(id=productComanda_id)
|
||||
consumo = ProductComanda.objects.filter(comanda=product_comanda.comanda)
|
||||
product_comanda.delete()
|
||||
@@ -31,16 +31,26 @@ def removeProductComanda(request, productComanda_id):
|
||||
return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total})
|
||||
|
||||
|
||||
def paymentComanda(request, comanda_id):
|
||||
def paymentBalcao(request, comanda_id):
|
||||
typePayment = TypePay.objects.get(id=1)
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO')
|
||||
print('ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg')
|
||||
print(f'ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg{vendasBalcao.id}')
|
||||
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
||||
total = 0
|
||||
for produto in consumo:
|
||||
total += produto.product.price
|
||||
removeProductComanda(request, produto.id)
|
||||
pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description='VENDA BALÃO')
|
||||
produto.comanda = 14
|
||||
produto.save()
|
||||
# newObject = ProductComanda.objects.get(comanda=produto.id)
|
||||
# newObject.comanda= 14
|
||||
|
||||
# newObject.save()
|
||||
|
||||
|
||||
pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description='VENDA BALCÃO')
|
||||
pagamento.save()
|
||||
comanda.save()
|
||||
# comanda.save()
|
||||
return redirect('comandas')
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
{% block 'title' %}
|
||||
Detalhes {{comanda.name}}
|
||||
{{comanda.name}}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ Detalhes {{comanda.name}}
|
||||
<td>{{item.product.name}}</td>
|
||||
<td>R$ {{item.product.price}}</td>
|
||||
<td><button
|
||||
hx-get="{% url 'removeProductComanda' item.id %} " hx-trigger="click" hx-swap="none"
|
||||
hx-get="{% url 'removeProductBalcao' item.id %} " hx-trigger="click" hx-swap="none"
|
||||
onclick="reloadPage()">🗑️ Excluir</button></td>
|
||||
</tr>
|
||||
|
||||
@@ -96,13 +96,16 @@ Detalhes {{comanda.name}}
|
||||
<!-- <article> -->
|
||||
|
||||
<form id="productForm" >
|
||||
<h2 style="text-align: center;">Adicionar Produto </h2>
|
||||
<input type="text" id="search-product" name="search-product" placeholder="Buscar Produto" hx-get="{% url 'listProduct' comanda.id %}" hx-trigger="keyup" hx-target="#product-list"><br>
|
||||
<div id="product-list" class="grid-list-products">
|
||||
{% for product in products %}
|
||||
<h2 style="text-align: center;">Buscar Produto </h2>
|
||||
<div class="grid-container">
|
||||
<input type="text" id="search-product" name="search-product" autofocus placeholder="Buscar Produto" hx-get="{% url 'listProduct' comanda.id %}" hx-trigger="keyup" hx-target="#product-list">
|
||||
<input type="number" id="qtd-product" name="qtd-product" value="1" required min="1"><br>
|
||||
</div>
|
||||
<div id="product-list" class="grid-list-products">
|
||||
{% for product in products %}
|
||||
|
||||
<article onclick="reloadPage()" style="background-color: #293552;" hx-get="{% url 'addProduct' product.id comanda.id %} " hx-trigger="click" hx-swap="none">
|
||||
{{product.name}} <br>
|
||||
{{ forloop.counter0 }} {{product.name}} <br>
|
||||
R$ {{product.price}}
|
||||
</article >
|
||||
{% endfor %}
|
||||
|
||||
@@ -14,12 +14,12 @@ urlpatterns = [
|
||||
|
||||
htmx_urlpatterns = [
|
||||
# path('listProduct/', htmx_views.listProduct, name='listProduct'),
|
||||
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('listProduct/<int:comanda_id>/', htmx_views.listProductBalcao, name='listProductBalcao'),
|
||||
path('addProduct<int:product_id>/<int:comanda_id>/', htmx_views.addProductBalcao, name='addProductBalcao'),
|
||||
path('removeProductComanda<int:productComanda_id>/', htmx_views.removeProductBalcao, name='removeProductBalcao'),
|
||||
# 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'),
|
||||
path('paymentComanda<int:comanda_id>/', htmx_views.paymentBalcao, name='paymentBalcao'),
|
||||
]
|
||||
|
||||
urlpatterns += htmx_urlpatterns
|
||||
Reference in New Issue
Block a user