bug: search products balcao

This commit is contained in:
2025-01-04 18:06:05 -03:00
parent 0460040af3
commit 0ac4609ce6
11 changed files with 21 additions and 19 deletions

View File

@@ -9,10 +9,8 @@ from products.models import Product
from payments.models import Payments
from typePay.models import TypePay
@csrf_exempt
def listProductBalcao(request, comanda_id, search_product):
print(search_product)
if len(search_product) == 0:
if search_product == '*':
produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
quantidade=Count('product'),
nome=F('product__name') ).order_by('-quantidade'))
@@ -24,7 +22,7 @@ def listProductBalcao(request, comanda_id, search_product):
if p.name == produto['nome']:
products_ordenados.append(p)
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_ordenados,'comanda_id':comanda_id})
else:
product = search_product
products = Product.objects.filter(name__icontains=product)

View File

@@ -73,7 +73,7 @@
<h2 style="text-align: center;">Buscar Produto </h2>
<div class="grid-container">
<input
onkeypress="searchProduct()"
oninput="searchProduct()"
type="text"
id="search-product"
name="search-product"
@@ -143,7 +143,7 @@
<ul>
</ul>
<footer>
<button class="secondary" hx-get="{% url 'paymentBalcao' comanda.id %} " hx-trigger="click" hx-swap="none" onclick="backPage()">
<button class="secondary" hx-get="{% url 'paymentBalcao' comanda.id %} " hx-trigger="click" hx-swap="none" onclick="reloadPage()">
Comfimar
</button>

Binary file not shown.

View File

@@ -122,7 +122,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'pt-BR'
TIME_ZONE = 'UTC'
TIME_ZONE = 'America/Sao_Paulo'
USE_I18N = True

View File

@@ -25,10 +25,10 @@ Produtos
<table id="list-products">
<tr>
<th style="text-align: left;">Produto</th>
<th style="text-align: left;">Preço</th>
<th style="text-align: left;width: 20%;">Preço</th>
<th style="text-align: left;">Quantidade</th>
<th style="text-align: left;">Categoria</th>
<th style="text-align: left;">Ações</th>
<th style="text-align: left;width: 20%;">Ações</th>
</tr>
{% for product in products %}
@@ -40,7 +40,7 @@ Produtos
<td id="category-{{product.id}}" >{{product.category.name}}</td>
<td>
<div class="grid-buttons">
<button onclick="editProduct({{product.id}})" >📝 Editar</button>
<h2 onclick="editProduct({{product.id}})" style="cursor: pointer;" >📝</h2>
<input type="hidden" id="h-category-{{product.id}}" value="{{ product.category.id }}">
<input type="hidden" id="description-{{product.id}}" value="{{ product.description }}">
@@ -49,9 +49,9 @@ Produtos
<input type="hidden" name="id-product" id="id-{{product.id}}" value="{{ product.id }}">
{% if product.active == True %}
<button style="background-color: red;">🚫 Desativar</button>
<button style="background-color: rgba(255, 0, 0, 0);"></button>
{% else %}
<button style="background-color: green;" >✅ Ativar</button>
<button style="background-color: rgba(0, 128, 0, 0);" >🚫</button>
{% endif %}

View File

@@ -22,7 +22,7 @@ function imprimirFichas() {
font-size: 24px;}
</style>`;
const agora = new Date();
var dateString = agora.getDay() + '/' + agora.getMonth() + '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes()+' - Raul Rock Bar & Café';
var dateString = agora.getDate() + '/' +( agora.getMonth() + 1 )+ '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes()+' - Raul Rock Bar & Café';
if (element) {
var content = element.innerHTML;
@@ -74,7 +74,8 @@ function updateTotal(){
function addProductBalcao() {
var productId = document.getElementById('0').innerText;
var comandaId = document.getElementById('comanda0').innerText;
var qtd = document.getElementById('qtd-product').value;
fieldQtd = document.getElementById('qtd-product');
var qtd = fieldQtd.value;
const url = `/balcao/addProductBalcaoTeclado${productId}/${comandaId}/${qtd}/`;
fetch(url, {
method: 'GET',
@@ -90,6 +91,7 @@ function addProductBalcao() {
const imprimir = document.getElementById('imprimirFichas')
receber.removeAttribute('disabled');
imprimir.removeAttribute('disabled');
fieldQtd.value = 1;
setTimeout(function() {
updateTotal();}, 100);
}
@@ -130,7 +132,7 @@ function searchProduct() {
function time(){
var search_product = document.getElementById('search-product').value.trim()
var productListElement = document.getElementById("product-list");
if(search_product.length >= 1 ){
if(search_product.length == 0 ){search_product ='*';}
fetch(`/balcao/listProductBalcao/13/${search_product}`, {
method: 'GET',}
).then(function(response) {
@@ -138,11 +140,12 @@ function searchProduct() {
}).then(function(text) {
productListElement.innerHTML = text;
})}}
})}
}
function addProductClick(productId, comandaId) {
var qtd = document.getElementById('qtd-product').value
fieldQtd = document.getElementById('qtd-product');
var qtd = fieldQtd.value;
fetch(`/balcao/addProductBalcaoTeclado${productId}/${comandaId}/${qtd}`, {
method: 'GET',
headers: {
@@ -160,6 +163,7 @@ function addProductClick(productId, comandaId) {
const imprimir = document.getElementById('imprimirFichas')
receber.removeAttribute('disabled');
imprimir.removeAttribute('disabled');
fieldQtd.value = 1;
setTimeout(function() {
updateTotal();}, 100);

View File

@@ -72,8 +72,8 @@ input, textarea {
display: grid;
grid-template-columns: repeat(1, 1fr);
gap: 20px;
max-width: 1000px; /* Define a largura máxima do grid */
margin: 0 auto; /* Centraliza o grid na página */
max-width: 1300px;
margin: 0 auto;
}
.card {