mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 21:45:41 +00:00
ordem add produtos na comanda
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -8,7 +8,11 @@ from typePay.models import TypePay
|
||||
|
||||
def listProduct(request, comanda_id):
|
||||
product = request.GET.get("search-product")
|
||||
products = Product.objects.filter(name__icontains=product)
|
||||
allProducts = Product.objects.filter(name__icontains=product)
|
||||
products = []
|
||||
for p in allProducts:
|
||||
if p.active == True:
|
||||
products.append(p)
|
||||
return render(request, "htmx_components/htmx_list_products.html", {"products": products,'comanda_id':comanda_id})
|
||||
|
||||
def addProduct(request, product_id, comanda_id):
|
||||
|
||||
@@ -21,7 +21,7 @@ Detalhes {{comanda.name}}
|
||||
<body>
|
||||
<div class="grid-container" >
|
||||
<div>
|
||||
<button class="primary" id="openModal"
|
||||
<button class="primary" id="openModal" onclick="openModal()"
|
||||
{% if comanda.status != 'OPEN'%}
|
||||
disabled
|
||||
{% endif %}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from django.shortcuts import render, redirect
|
||||
from django.db.models import Count, F
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
from products.models import Product
|
||||
@@ -17,12 +18,23 @@ def viewComanda(request):
|
||||
comanda_id = int(id)
|
||||
comanda = Comanda.objects.get(id=comanda_id)
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
|
||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
nome=F('product__name') ).order_by('-quantidade'))
|
||||
|
||||
products = Product.objects.all()
|
||||
products_ordenados = []
|
||||
for produto in produtos_mais_vendidos:
|
||||
for p in products:
|
||||
if p.name == produto['nome'] and p.active == True:
|
||||
products_ordenados.append(p)
|
||||
total = 0
|
||||
|
||||
for produto in consumo:
|
||||
total += produto.product.price
|
||||
|
||||
return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products})
|
||||
return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados})
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,9 +1,8 @@
|
||||
|
||||
|
||||
{% for product in products %}
|
||||
{{co}}
|
||||
|
||||
<article style="background-color: #293552;" hx-get="{% url 'addProduct' product.id comanda_id %} " hx-trigger="click" hx-target="#list-products-comanda">
|
||||
<article onclick="addProductComanda({{product.id}})" style="background-color: #293552;" hx-get="{% url 'addProduct' product.id comanda_id %} " hx-trigger="click" hx-target="#list-products-comanda">
|
||||
{{product.name}} <br>
|
||||
R$ {{product.price}}
|
||||
</article>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
function openModal() {
|
||||
document.getElementById('Modal-add-product').style.display = 'block';
|
||||
// document.getElementById('Modal-add-product').setAttribute();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +45,7 @@ function imprimirFichas() {
|
||||
if (element) {
|
||||
var content = element.innerHTML;
|
||||
// console.log(content);
|
||||
content = content.replace(/<button[^>]*>(?:(?!<\/button>)[\s\S])*<\/button>/gi,'');
|
||||
content = content.replace(/<img[^>]*>(?:(?!<\/img>)[\s\S])*<\/img>/gi,'');
|
||||
content = content.replace(/<th[^>]*>(?:(?!<\/th>)[\s\S])*<\/th>/gi,'');
|
||||
content = content.replace(/<\/tr>/g,'</tr><tr><td colspan="2" style="font-size: 12px">'+dateString+'</td></tr>');
|
||||
console.log(content);
|
||||
@@ -78,7 +79,7 @@ function imprimirConta() {
|
||||
if (element) {
|
||||
var content = element.innerHTML;
|
||||
// console.log(content);
|
||||
content = content.replace(/<button[^>]*>(?:(?!<\/button>)[\s\S])*<\/button>/gi,'');
|
||||
content = content.replace(/<img[^>]*>(?:(?!<\/img>)[\s\S])*<\/img>/gi,'');
|
||||
content = content.replace(/<th[^>]*>(?:(?!<\/th>)[\s\S])*<\/th>/gi,'');
|
||||
// content = content.replace(/<\/tr>/g,'</tr><tr><td colspan="2" style="font-size: 12px">'+dateString+'</td></tr>');
|
||||
console.log(content);
|
||||
@@ -106,19 +107,17 @@ function backPage() {
|
||||
}
|
||||
|
||||
|
||||
document.onkeydown = teclado
|
||||
// document.onkeydown = teclado
|
||||
|
||||
// function teclado(event){
|
||||
// if (event.keyCode == 65){
|
||||
// openModal()
|
||||
// }
|
||||
// else if (event.keyCode == 73){
|
||||
// imprimirFichas()
|
||||
// }
|
||||
|
||||
function teclado(event){
|
||||
if (event.keyCode == 65){
|
||||
openModal()
|
||||
}
|
||||
else if (event.keyCode == 73){
|
||||
imprimirFichas()
|
||||
}
|
||||
// else if (event.keyCode == 70){
|
||||
// imprimirConta()
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
function addProductComanda(productId) {
|
||||
@@ -134,11 +133,11 @@ function addProductComanda(productId) {
|
||||
|
||||
|
||||
|
||||
document.getElementById('openModal').addEventListener('click', openModal);
|
||||
// document.getElementById('openModal').addEventListener('click', openModal);
|
||||
|
||||
document.getElementById('productForm').addEventListener('submit', function(event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
// document.getElementById('productForm').addEventListener('submit', function(event) {
|
||||
// event.preventDefault();
|
||||
// });
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user