mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
criado metodo de mais vendidos no comandas.models | limitar lista de products a 15 itens
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -16,23 +16,13 @@ from gestaoRaul.decorators import group_required
|
|||||||
def listProductBalcao(request, comanda_id, search_product):
|
def listProductBalcao(request, comanda_id, search_product):
|
||||||
comanda_id = request.GET.get("id-comanda-balcao")
|
comanda_id = request.GET.get("id-comanda-balcao")
|
||||||
if search_product == '*':
|
if search_product == '*':
|
||||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
products_ordenados = ProductComanda.maisVendidos()
|
||||||
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.active == True and p.name == produto['nome']:
|
|
||||||
products_ordenados.append(p)
|
|
||||||
|
|
||||||
|
|
||||||
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products_ordenados,'comanda_id':comanda_id})
|
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products_ordenados,'comanda_id':comanda_id})
|
||||||
else:
|
else:
|
||||||
product = search_product
|
product = search_product
|
||||||
products = Product.objects.filter(name__icontains=product, active=True)
|
products = Product.objects.filter(name__icontains=product, active=True)
|
||||||
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products,'comanda_id':comanda_id})
|
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products[:15],'comanda_id':comanda_id})
|
||||||
|
|
||||||
|
|
||||||
@group_required(groupName='Garçom')
|
@group_required(groupName='Garçom')
|
||||||
|
|||||||
@@ -20,17 +20,7 @@ def viewBalcao(request):
|
|||||||
comanda.save()
|
comanda.save()
|
||||||
|
|
||||||
consumo = ProductComanda.objects.filter(comanda=comanda.id)
|
consumo = ProductComanda.objects.filter(comanda=comanda.id)
|
||||||
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
|
products_ordenados = ProductComanda.maisVendidos()
|
||||||
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
|
total = 0
|
||||||
for produto in consumo:
|
for produto in consumo:
|
||||||
total += produto.product.price
|
total += produto.product.price
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.db.models import Count, F
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -7,7 +8,6 @@ from clients.models import Client
|
|||||||
from products.models import Product
|
from products.models import Product
|
||||||
from mesas.models import Mesa
|
from mesas.models import Mesa
|
||||||
from typePay.models import TypePay
|
from typePay.models import TypePay
|
||||||
# from payments.models import Payments
|
|
||||||
|
|
||||||
class Comanda(models.Model):
|
class Comanda(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
@@ -32,3 +32,15 @@ class ProductComanda(models.Model):
|
|||||||
return self.comanda.name + " - " + self.product.name
|
return self.comanda.name + " - " + self.product.name
|
||||||
|
|
||||||
|
|
||||||
|
def maisVendidos():
|
||||||
|
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)
|
||||||
|
return products_ordenados[:15]
|
||||||
@@ -32,24 +32,12 @@ def viewComanda(request):
|
|||||||
comanda_id = int(id)
|
comanda_id = int(id)
|
||||||
comanda = Comanda.objects.get(id=comanda_id)
|
comanda = Comanda.objects.get(id=comanda_id)
|
||||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||||
# consumo[0].product.
|
|
||||||
parcial = Payments.objects.filter(comanda=comanda_id)
|
parcial = Payments.objects.filter(comanda=comanda_id)
|
||||||
mesas = Mesa.objects.all()
|
mesas = Mesa.objects.all()
|
||||||
clients = Client.objects.filter(active=True)
|
clients = Client.objects.filter(active=True)
|
||||||
|
products_ordenados = ProductComanda.maisVendidos()
|
||||||
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)
|
|
||||||
valores = somar(consumo,comanda)
|
valores = somar(consumo,comanda)
|
||||||
|
return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados[:15],'mesas':mesas})
|
||||||
return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados,'mesas':mesas})
|
|
||||||
|
|
||||||
|
|
||||||
@group_required(groupName='Garçom')
|
@group_required(groupName='Garçom')
|
||||||
@@ -202,9 +190,12 @@ def addProduct(request, product_id, comanda_id):
|
|||||||
|
|
||||||
|
|
||||||
def listProduct(request, comanda_id, product):
|
def listProduct(request, comanda_id, product):
|
||||||
allProducts = Product.objects.filter(name__icontains=product)
|
if product == '*':
|
||||||
|
allProducts = ProductComanda.maisVendidos()
|
||||||
|
else:
|
||||||
|
allProducts = Product.objects.filter(name__icontains=product)
|
||||||
products = []
|
products = []
|
||||||
for p in allProducts:
|
for p in allProducts:
|
||||||
if p.active == True:
|
if p.active == True:
|
||||||
products.append(p)
|
products.append(p)
|
||||||
return render(request, "htmx_components/comandas/htmx_list_products.html", {"products": products,'comanda_id':comanda_id})
|
return render(request, "htmx_components/comandas/htmx_list_products.html", {"products": products[:15],'comanda_id':comanda_id})
|
||||||
Binary file not shown.
Binary file not shown.
@@ -2,6 +2,7 @@ from django.db import models
|
|||||||
|
|
||||||
from categories.models import Categories
|
from categories.models import Categories
|
||||||
|
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class Product(models.Model):
|
class Product(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ Produtos
|
|||||||
<button class="btn-primary"
|
<button class="btn-primary"
|
||||||
onclick="openModal()" id="openModal">Novo Produto</button>
|
onclick="openModal()" id="openModal">Novo Produto</button>
|
||||||
<input type="text" id="search-product" name="search-product" placeholder="Buscar Produto" hx-get="{% url 'searchProduct' %}" hx-trigger="keyup" hx-target="#product-list">
|
<input type="text" id="search-product" name="search-product" placeholder="Buscar Produto" hx-get="{% url 'searchProduct' %}" hx-trigger="keyup" hx-target="#product-list">
|
||||||
|
<a href="https://raulrockbar.blogspot.com/p/cardapio.html" target="_blank">Cardápio Digital</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table id="product-list">
|
<table id="product-list">
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ input, textarea, select {
|
|||||||
align-content: center;
|
align-content: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
background: var(--main-gradient);
|
/* background: var(--main-gradient); */
|
||||||
box-shadow: 3px 3px 10px rgba(2, 2, 2, 0.678);
|
/* box-shadow: 3px 3px 10px rgba(2, 2, 2, 0.678); */
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
transition: transform 0.4s, box-shadow 0.4s;
|
transition: transform 0.4s, box-shadow 0.4s;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
@@ -168,9 +168,9 @@ input, textarea, select {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 150px;
|
width: 100%;
|
||||||
height: 130px;
|
height: 100%;
|
||||||
background-color: rgba(0, 0, 0, 0.737);
|
background-color: rgba(0, 0, 0, 0.595);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-product-p {
|
.card-product-p {
|
||||||
@@ -186,6 +186,14 @@ input, textarea, select {
|
|||||||
box-shadow: 0px 0px 10px rgba(86, 187, 255, 0.815);
|
box-shadow: 0px 0px 10px rgba(86, 187, 255, 0.815);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@media screen and (max-width: 1028px) {
|
||||||
|
.card-product {
|
||||||
|
background-size: cover !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.p-header {
|
.p-header {
|
||||||
background-color: #24252a;
|
background-color: #24252a;
|
||||||
box-shadow: 0px 3px 10px #464646;
|
box-shadow: 0px 3px 10px #464646;
|
||||||
|
|||||||
@@ -31,9 +31,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.modal-product{
|
.modal-product{
|
||||||
/* position: relative; */
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
/* height: 400px; */
|
/* height: 750; */
|
||||||
background-image: url('https://placehold.co/600x800/efc7b8/49291c?text=Sem_Imagem'); /* URL da imagem */
|
background-image: url('https://placehold.co/600x800/efc7b8/49291c?text=Sem_Imagem'); /* URL da imagem */
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user