mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
create comanda | detalhe comanda
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -14,6 +14,8 @@ class Comanda(models.Model):
|
|||||||
dt_close = models.DateTimeField(null=True, blank=True)
|
dt_close = models.DateTimeField(null=True, blank=True)
|
||||||
client = models.ForeignKey(Client, on_delete=models.SET_NULL, null=True, blank=True)
|
client = models.ForeignKey(Client, on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return self.name
|
||||||
|
|
||||||
class ProductComanda(models.Model):
|
class ProductComanda(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
@@ -21,3 +23,5 @@ class ProductComanda(models.Model):
|
|||||||
data_time = models.DateTimeField(auto_now_add=True)
|
data_time = models.DateTimeField(auto_now_add=True)
|
||||||
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
||||||
applicant = models.CharField(max_length=255, null=True, blank=True)
|
applicant = models.CharField(max_length=255, null=True, blank=True)
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return self.comanda.name + " - " + self.product.name
|
||||||
@@ -11,12 +11,15 @@ Comandas{% endblock %}
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block 'body' %}
|
{% block 'body' %}
|
||||||
|
|
||||||
body>
|
<body>
|
||||||
<div class="grid-container">
|
<div class="grid-container">
|
||||||
|
<button class="button" id="openModal">Abrir Comanda</button>
|
||||||
|
|
||||||
{% for comanda in comandas %}
|
{% for comanda in comandas %}
|
||||||
|
|
||||||
<div href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}" class="card"> <a href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}">{{comanda.name}} </a>
|
<div href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}" class="card">
|
||||||
|
<a href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}">{{comanda.name}} </a> <br>
|
||||||
|
<a href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}">{{comanda.mesa}}</a>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -25,7 +28,32 @@ body>
|
|||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal" id="Modal-create-comanda">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form id="form-comanda" method="post" action="{% url 'createComanda' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<h2>Abrir Comanda</h2>
|
||||||
|
<input type="text" id="name-comanda" name="name-comanda" required placeholder="Nome"><br>
|
||||||
|
<select name="select-mesa" >
|
||||||
|
|
||||||
|
{% for mesa in mesas %}
|
||||||
|
<option value="{{mesa.id}}">{{mesa.name}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <option value="opcao1">Opção 1</option>
|
||||||
|
<option value="opcao2">Opção 2</option>
|
||||||
|
<option value="opcao3" >Opção 3</option> -->
|
||||||
|
</select>
|
||||||
|
<button type="submit">Abrir</button>
|
||||||
|
<button type="button" onclick="closeModal()" style="background-color:red;">Fechar</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<script src="{% static 'comandas/js/comandas.js' %}"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,22 +5,73 @@
|
|||||||
|
|
||||||
|
|
||||||
{% block 'title' %}
|
{% block 'title' %}
|
||||||
Comandas{% endblock %}
|
Detalhes {{comanda.name}}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block 'head' %}
|
{% block 'head' %}
|
||||||
<link rel="stylesheet" href="{% static 'comandas/css/viewcomanda.css' %}">
|
<link rel="stylesheet" href="{% static 'comandas/css/viewcomanda.css' %}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block 'body' %}
|
{% block 'body' %}
|
||||||
|
|
||||||
body>
|
<body>
|
||||||
<div class="grid-container">
|
<div class="grid-container">
|
||||||
<h4>{{comanda.id}}</h4>
|
<button class="button" id="openModal">Adicionar Produto</button>
|
||||||
<h4>{{comanda.name}}</h4>
|
<!-- <p>{{comanda.id}}</p> -->
|
||||||
<h4>{{comanda.mesa}}</h4>
|
<p>{{comanda.name}}</p>
|
||||||
<h4>{{comanda.dt_open}}</h4>
|
<p>{{comanda.mesa}}</p>
|
||||||
|
<p>{{comanda.dt_open}}</p>
|
||||||
|
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th style="text-align: left;">Produto</th>
|
||||||
|
<th style="text-align: left;">Preço</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% for item in consumo%}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{{item.product.name}}</td>
|
||||||
|
<td>R$ {{item.product.price}}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" style="text-align: center;">Total R$ {{total}}</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="modal" id="Modal-add-product">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form id="productForm" >
|
||||||
|
<h2>Adicionar Produto <button type="button" onclick="closeModal()" style="background-color:red;">Fechar</button></h2>
|
||||||
|
<input type="text" id="search-product" name="search-product" required placeholder="Buscar Produto"><br>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <input type="number" step="1" id="product-qtd" name="qtd" required placeholder="Quantidade"><br> -->
|
||||||
|
<!-- <button type="submit">Salvar</button> -->
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="{% static 'comandas/js/viewcomanda.js' %}"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from . import views
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.comandas, name='comandas'),
|
path('', views.comandas, name='comandas'),
|
||||||
path('viewcomanda/', views.viewComanda, name='viewcomanda'),
|
path('viewcomanda/', views.viewComanda, name='viewcomanda'),
|
||||||
|
path('createComanda/', views.createComanda, name='createComanda'),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
|
|
||||||
from comandas.models import Comanda
|
from comandas.models import Comanda, ProductComanda
|
||||||
|
from mesas.models import Mesa
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
def comandas(request):
|
def comandas(request):
|
||||||
comandas = Comanda.objects.all()
|
comandas = Comanda.objects.all()
|
||||||
return render(request, 'comandas.html', {'comandas': comandas})
|
mesas = Mesa.objects.all()
|
||||||
|
return render(request, 'comandas.html', {'comandas': comandas, 'mesas': mesas})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -15,5 +17,27 @@ def viewComanda(request):
|
|||||||
id = request.GET.get('parametro')
|
id = request.GET.get('parametro')
|
||||||
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)
|
||||||
|
total = 0
|
||||||
|
for produto in consumo:
|
||||||
|
total += produto.product.price
|
||||||
|
|
||||||
return render(request, 'viewcomanda.html', {'comanda': comanda})
|
return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total})
|
||||||
|
|
||||||
|
|
||||||
|
def addProduct(request):
|
||||||
|
pass
|
||||||
|
# id = request.GET.get('parametro')
|
||||||
|
# comanda_id = int(id)
|
||||||
|
# comanda = Comanda.objects.get(id=comanda_id)
|
||||||
|
# return render(request, 'addproduct.html', {'comanda': comanda})
|
||||||
|
|
||||||
|
|
||||||
|
def createComanda(request):
|
||||||
|
name = request.POST.get('name-comanda')
|
||||||
|
mesa_id = int(request.POST.get('select-mesa')[0])
|
||||||
|
mesa = Mesa.objects.get(id=mesa_id)
|
||||||
|
comanda = Comanda(name=name, mesa=mesa)
|
||||||
|
comanda.save()
|
||||||
|
|
||||||
|
return redirect('comandas')
|
||||||
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,7 @@ from django.contrib import admin
|
|||||||
|
|
||||||
from categories.models import Categories
|
from categories.models import Categories
|
||||||
from clients.models import Client
|
from clients.models import Client
|
||||||
from comandas.models import Comanda
|
from comandas.models import Comanda, ProductComanda
|
||||||
from typePay.models import TypePay
|
from typePay.models import TypePay
|
||||||
from products.models import Product
|
from products.models import Product
|
||||||
from mesas.models import Mesa
|
from mesas.models import Mesa
|
||||||
@@ -14,5 +14,6 @@ admin.site.register(Categories)
|
|||||||
admin.site.register(Client)
|
admin.site.register(Client)
|
||||||
admin.site.register(Comanda)
|
admin.site.register(Comanda)
|
||||||
admin.site.register(TypePay)
|
admin.site.register(TypePay)
|
||||||
|
admin.site.register(ProductComanda)
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|||||||
@@ -7,13 +7,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
width: 120px;
|
width: 220px;
|
||||||
height: 120px;
|
height: 220px;
|
||||||
background-color: #f2f2f2;
|
background-color: #f2f2f2;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
|
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 120px; /* Centraliza o texto verticalmente */
|
line-height: 50px; /* Centraliza o texto verticalmente */
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #333;
|
color: #333;
|
||||||
@@ -24,3 +24,56 @@
|
|||||||
transform: scale(1.05);
|
transform: scale(1.05);
|
||||||
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
|
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
button {
|
||||||
|
background-color: #007BFF;
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
padding: 20px;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-content {
|
||||||
|
background-color: #fefefe;
|
||||||
|
margin: 15% auto;
|
||||||
|
padding: 20px;
|
||||||
|
border: 1px solid #888;
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 90%;
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, textarea {
|
||||||
|
width: 95%;
|
||||||
|
max-width: 95%;
|
||||||
|
padding: 8px;
|
||||||
|
margin-top: 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.grid-container {
|
.grid-container {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(1, 2fr);
|
grid-template-columns: repeat(2, 2fr);
|
||||||
gap: 20px;
|
gap: 10px;
|
||||||
max-width: 800px; /* Define a largura máxima do grid */
|
max-width: 800px; /* Define a largura máxima do grid */
|
||||||
margin: 0 auto; /* Centraliza o grid na página */
|
margin: 0 auto; /* Centraliza o grid na página */
|
||||||
}
|
}
|
||||||
@@ -24,3 +24,63 @@
|
|||||||
transform: scale(1.05);
|
transform: scale(1.05);
|
||||||
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
|
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table td th {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
button {
|
||||||
|
background-color: #007BFF;
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
padding: 20px;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
background-color: rgba(0, 0, 0, 0.4);
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-content {
|
||||||
|
background-color: #fefefe;
|
||||||
|
margin: 15% auto;
|
||||||
|
padding: 20px;
|
||||||
|
border: 1px solid #888;
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 90%;
|
||||||
|
height: 90%;
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, textarea {
|
||||||
|
width: 95%;
|
||||||
|
max-width: 95%;
|
||||||
|
padding: 8px;
|
||||||
|
margin-top: 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
function openModal() {
|
||||||
|
document.getElementById('Modal-create-comanda').style.display = 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
document.getElementById('Modal-create-comanda').style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('openModal').addEventListener('click', openModal);
|
||||||
|
|
||||||
|
// document.getElementById('form-comanda').addEventListener('submit', function(event) {
|
||||||
|
// event.preventDefault();
|
||||||
|
|
||||||
|
// const productName = document.getElementById('productName').value;
|
||||||
|
// const productPrice = document.getElementById('productPrice').value;
|
||||||
|
// const productDescription = document.getElementById('productDescription').value;
|
||||||
|
|
||||||
|
// closeModal();
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
20
gestaoRaul/templates/static/comandas/js/viewcomanda.js
Normal file
20
gestaoRaul/templates/static/comandas/js/viewcomanda.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
function openModal() {
|
||||||
|
document.getElementById('Modal-add-product').style.display = 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
document.getElementById('Modal-add-product').style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('openModal').addEventListener('click', openModal);
|
||||||
|
|
||||||
|
document.getElementById('productForm').addEventListener('submit', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
// const productName = document.getElementById('productName').value;
|
||||||
|
// const productPrice = document.getElementById('productPrice').value;
|
||||||
|
// const productDescription = document.getElementById('productDescription').value;
|
||||||
|
|
||||||
|
// closeModal();
|
||||||
|
});
|
||||||
|
|
||||||
Reference in New Issue
Block a user