mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 21:45:41 +00:00
feat: button on/off products
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -31,10 +31,6 @@ def listProductBalcao(request, comanda_id, search_product):
|
||||
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products,'comanda_id':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 addProductBalcao(request, product_id, comanda_id, qtd):
|
||||
for i in range(qtd):
|
||||
|
||||
@@ -69,8 +69,6 @@
|
||||
|
||||
<div id="add-produto">
|
||||
|
||||
<!-- <article> -->
|
||||
|
||||
<form id="productForm" >
|
||||
<h2 style="text-align: center;">Buscar Produto </h2>
|
||||
<div class="grid-container">
|
||||
@@ -128,22 +126,14 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<!-- </article> -->
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<dialog id="payment-comanda" style="display: none;" >
|
||||
<article>
|
||||
<h2>Receber</h2>
|
||||
|
||||
@@ -5,21 +5,16 @@ from balcao import htmx_views
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
# path('', views.comandas, name='comandas'),
|
||||
path('', views.viewBalcao, name='viewBalcao'),
|
||||
# path('createComanda/', views.createComanda, name='createComanda'),
|
||||
|
||||
]
|
||||
|
||||
|
||||
htmx_urlpatterns = [
|
||||
# path('listProduct/', htmx_views.listProduct, name='listProduct'),
|
||||
path('listProductBalcao/<int:comanda_id>/<str:search_product>/', htmx_views.listProductBalcao, name='listProductBalcao'),
|
||||
path('addProductBalcao<int:product_id>/<int:comanda_id>/<int:qtd>/', htmx_views.addProductBalcao, name='addProductBalcao'),
|
||||
path('addProductBalcaoTeclado<int:product_id>/<int:comanda_id>/<int:qtd>/', htmx_views.addProductBalcaoTeclado, name='addProductBalcaoTeclado'),
|
||||
path('removeProductBalcao<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('paymentBalcao<int:comanda_id>/', htmx_views.paymentBalcao, name='paymentBalcao'),
|
||||
]
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ from django.shortcuts import render, redirect
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
from products.models import Product
|
||||
from mesas.models import Mesa
|
||||
from django.db.models import Count, F
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
@@ -24,14 +24,6 @@ RRB&C - Mesas
|
||||
{% endif %}
|
||||
>{{mesa.name}}
|
||||
|
||||
|
||||
<form action="{% url 'onOffmesa' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="id-mesa" value="{{ mesa.id }}">
|
||||
<button type="submit">On/Off</button>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -19,25 +19,61 @@ Produtos
|
||||
|
||||
<body>
|
||||
<div class="grid-container">
|
||||
<div class="pico"><input class="pico" type="text"></div>
|
||||
<button class="pico" id="openModal">Adicionar Novo Produto</button>
|
||||
<div ><input type="text"></div>
|
||||
<button id="openModal">Adicionar Novo Produto</button>
|
||||
|
||||
<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;">Quantidade</th>
|
||||
<th style="text-align: left;">Categoria</th>
|
||||
<th style="text-align: left;">Ações</th>
|
||||
</tr>
|
||||
|
||||
{% for product in products %}
|
||||
|
||||
<div class="card">
|
||||
{{product.name}}
|
||||
</div>
|
||||
<tr>
|
||||
<td>{{product.name}}</td>
|
||||
<td>R$ {{product.price}}</td>
|
||||
<td>{{product.quantity}}</td>
|
||||
<td>{{product.category.name}}</td>
|
||||
<td>
|
||||
<div class="grid-buttons">
|
||||
<button>📝 Editar</button>
|
||||
|
||||
<form action="{% url 'onOffproduct' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="id-product" value="{{ product.id }}">
|
||||
|
||||
{% if product.active == True %}
|
||||
<button style="background-color: red;">🚫 Desativar</button>
|
||||
{% else %}
|
||||
<button style="background-color: green;" >✅ Ativar</button>
|
||||
|
||||
{% endif %}
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
<div class="modal" id="Modal-create-product">
|
||||
<div class="modal-content">
|
||||
|
||||
|
||||
<dialog id='Modal-create-product' >
|
||||
<article>
|
||||
|
||||
<form action="{% url 'create_product' %}" id="productForm" method="post" >
|
||||
{% csrf_token %}
|
||||
<h2>Cadastro de Produto</h2>
|
||||
@@ -55,8 +91,11 @@ Produtos
|
||||
<button type="submit">Salvar</button>
|
||||
<button type="button" onclick="closeModal()" style="background-color:red;">Fechar</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</article>
|
||||
</dialog>
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="{% static 'products/js/products.js' %}"></script>
|
||||
|
||||
@@ -5,5 +5,6 @@ from . import views
|
||||
urlpatterns = [
|
||||
path('', views.products, name='products'),
|
||||
path('create_product', views.createProduct, name='create_product'),
|
||||
path('onOffproduct', views.onOffProduct, name='onOffproduct'),
|
||||
|
||||
]
|
||||
|
||||
@@ -19,3 +19,12 @@ def createProduct(request):
|
||||
product.save()
|
||||
return redirect('/products')
|
||||
# return render(request, 'products.html')
|
||||
|
||||
|
||||
def onOffProduct(request):
|
||||
id = request.POST.get('id-product')
|
||||
product_id = int(id)
|
||||
product = Product.objects.get(id=product_id)
|
||||
product.active = not product.active
|
||||
product.save()
|
||||
return redirect('products')
|
||||
@@ -8,7 +8,6 @@ function close_modal_payment_comanda() {
|
||||
document.getElementById('payment-comanda').style.display = 'none';
|
||||
}
|
||||
|
||||
// document.cookie = 'qtd=1';
|
||||
|
||||
|
||||
function imprimirFichas() {
|
||||
@@ -28,6 +27,7 @@ function imprimirFichas() {
|
||||
if (element) {
|
||||
var content = element.innerHTML;
|
||||
content = content.replace(/<button[^>]*>(?:(?!<\/button>)[\s\S])*<\/button>/gi,'');
|
||||
content = content.replace(/<tfoot[^>]*>(?:(?!<\/tfoot>)[\s\S])*<\/tfoot>/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+ '<BR>VÁLIDO SOMENTE POR ESSA NOITE'+'</td></tr>');
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
button {
|
||||
background-color: #007BFF;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
padding: 10px 10px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
@@ -55,11 +55,19 @@ input, textarea {
|
||||
|
||||
|
||||
|
||||
.grid-container {
|
||||
.grid-buttons {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 10px;
|
||||
max-width: 500px; /* Define a largura máxima do grid */
|
||||
/* margin: 0 auto; */
|
||||
}
|
||||
|
||||
.grid-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(1, 1fr);
|
||||
gap: 20px;
|
||||
max-width: 800px; /* Define a largura máxima do grid */
|
||||
max-width: 1000px; /* Define a largura máxima do grid */
|
||||
margin: 0 auto; /* Centraliza o grid na página */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user