feat: abre modal de informações do status da order ao clicar sobre o nome do product na viewcomanda

This commit is contained in:
2025-06-27 17:14:08 -03:00
parent 1ef263d033
commit c8c3653bf8
12 changed files with 72 additions and 50 deletions

View File

@@ -94,23 +94,24 @@ Detalhes {{comanda.name}}
<tr> <tr>
<td id="id-for-print-{{item.id}}"> <td id="id-for-print-{{item.id}}">
{{item.product.name}} <spam style="cursor: pointer;" onclick="inforOrders({{item.id}})">
{{item.product.name}}</spam>
{% if item.product.cuisine == True %} {% if item.product.cuisine == True %}
<input hidden id="{{item.id}}-obsOrder" type="order" value="{{item.id | obsOrder}}"> <input hidden id="{{item.id}}-obsOrder" type="order" value="{{item.id | obsOrder}}">
<span id="tooltip-id-{{item.id}}" data-tooltip="{{item.id | obsOrder}}" data-flow="top">
<img <img
onclick="openModalObs({{item.id}})" onclick="openModalObs({{item.id}})"
src="{% static 'midia/icons/note.svg' %}" src="{% static 'midia/icons/note.svg' %}"
style="width: 25px; height: 35px; cursor: pointer;"> style="width: 25px; height: 35px; cursor: pointer;">
</img> </img>
</span>
<img
onclick="printOrder({{item.id}})" <img
src="{% static 'midia/icons/print.svg' %}" onclick="printOrder({{item.id}})"
style="width: 35px; height: 35px; cursor: pointer;"> src="{% static 'midia/icons/print.svg' %}"
</img> style="width: 35px; height: 35px; cursor: pointer;">
</img>
{% endif %} {% endif %}
</td> </td>
@@ -129,7 +130,7 @@ Detalhes {{comanda.name}}
</img> </img>
</td> </td>
{% endif %} {% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
{% if config.taxa %} {% if config.taxa %}
<tr> <tr>
@@ -155,7 +156,7 @@ Detalhes {{comanda.name}}
<tfoot> <tfoot>
<tr> <tr>
{% if config.taxa %} {% if config.taxa %}
<td colspan="2" style="text-align: center;"><b>Total R$ {{valores.totalComTaxa}}</b></td> <td colspan="2" style="text-align: center;"><b>Total R$ {{valores.totalComTaxa}}</b></td>

View File

@@ -62,7 +62,7 @@ def obsOrder(id):
try: try:
productComanda_obj = ProductComanda.objects.get(pk=id) productComanda_obj = ProductComanda.objects.get(pk=id)
order = Order.objects.get(productComanda=productComanda_obj) order = Order.objects.get(productComanda=productComanda_obj)
return order.obs return order
except: except:
return '' return ''

Binary file not shown.

View File

@@ -1,4 +1,5 @@
from django.db import models from django.db import models
from django.utils.formats import date_format
from products.models import Product from products.models import Product
from comandas.models import Comanda, ProductComanda from comandas.models import Comanda, ProductComanda
@@ -16,4 +17,12 @@ class Order(models.Model):
canceled = models.DateTimeField(null=True, blank=True) canceled = models.DateTimeField(null=True, blank=True)
def __str__(self): def __str__(self):
return f"Pedido {self.id} - Produto: {self.id_product} - Comanda: {self.id_comanda.name}" status = 'Em espera'
if self.preparing:
status = 'Preparando'
if self.finished:
status = 'Pronto'
if self.delivered:
status = 'Entregue'
return f"{self.id_product}| {self.obs}|{status}|{self.id_comanda.name}|{self.id_comanda.mesa.name}|{date_format(self.queue, 'd/m/Y H:i')}"

View File

@@ -23,7 +23,7 @@
<body> <body>
{% block 'body' %} {% block 'body' %}
<div class="container"> <div class="container">
<h1>Pedidos cozinha</h1> <h1 id="title">Pedidos cozinha</h1>
<div class="kanban-board"> <div class="kanban-board">
{% csrf_token %} {% csrf_token %}
<div class="column"> <div class="column">

View File

@@ -11,17 +11,16 @@
<tr> <tr>
<td id="id-for-print-{{item.id}}"> <td id="id-for-print-{{item.id}}">
{{item.product.name}} <spam style="cursor: pointer;" onclick="inforOrders({{item.id}})">
{{item.product.name}}</spam>
{% if item.product.cuisine == True %} {% if item.product.cuisine == True %}
<input hidden id="{{item.id}}-obsOrder" type="order" value="{{item.id | obsOrder}}"> <input hidden id="{{item.id}}-obsOrder" type="order" value="{{item.id | obsOrder}}">
<span id="tooltip-id-{{item.id}}" data-tooltip="{{item.id | obsOrder}}" data-flow="top">
<img <img
onclick="openModalObs({{item.id}})" onclick="openModalObs({{item.id}})"
src="{% static 'midia/icons/note.svg' %}" src="{% static 'midia/icons/note.svg' %}"
style="width: 25px; height: 35px; cursor: pointer;"> style="width: 25px; height: 35px; cursor: pointer;">
</img> </img>
</span>
<img <img
onclick="printOrder({{item.id}})" onclick="printOrder({{item.id}})"

View File

@@ -411,7 +411,7 @@ white-space: nowrap;
} }
@media screen and (max-width: 768px) { @media screen and (max-width: 1028px) {
.toast-add { .toast-add {
width: 90%; width: 90%;
} }

View File

@@ -177,13 +177,15 @@ function openFullscreen() {
} }
function feedback(message, status, subMessage) { function feedback(message, icon, subMessage) {
console.log(subMessage)
var feedbackMsg = Swal.fire({ var feedbackMsg = Swal.fire({
title: message, color: 'white',
text: subMessage || '', title: message,
icon: status, text: subMessage || '',
background: 'rgba(8, 9, 10, 0.75)', icon: icon || 'info',
confirmButtonColor: 'linear-gradient(145deg, #1E2A3B, #2C3E50)', background: 'rgb(23, 38, 54)',
}); confirmButtonColor: 'linear-gradient(145deg, #1E2A3B, #2C3E50)',
});
return feedbackMsg; return feedbackMsg;
} }

View File

@@ -115,28 +115,20 @@ function imprimirFichas() {
} }
} }
function printOrder(id) { function printOrder(id) {
var item = document.getElementById('id-for-print-'+id).innerText var order = document.getElementById(id+'-obsOrder').value
var cliente = document.getElementById('name-comanda').innerText order = order.split('|');
var local = document.getElementById('mesa-comanda').innerText
var obs = document.getElementById(id+'-obsOrder').value
const agora = new Date();
var dateString = agora.getDate() + '/' + (agora.getMonth()+1) + '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes();
console.log(item)
console.log(cliente)
console.log(local)
const body = `<style> const body = `<style>
td, th { td, th {
border-collapse: collapse; border-collapse: collapse;
padding-top: 20px; padding-top: 10px;
margin: 20px; margin: 10px;
text-align: center; text-align: center;
font-size: 20px;} font-size: 20px;}
</style> </style>
<tr><td>${item}</td></tr> <tr><td>${order[0]}</td></tr>
<tr><td>${obs}</td></tr> <tr><td>${order[1]}</td></tr>
<tr><td>${cliente}${local}</td></tr> <tr><td>${order[3]} - ${order[4]}</td></tr>
<tr><td>${dateString}</td></tr> <tr><td>${order[5]}</td></tr>
`; `;
var printWindow = window.open('', '_blank'); var printWindow = window.open('', '_blank');
@@ -254,11 +246,11 @@ function troco(){
function addOrder(){ function addOrder(){
obs = document.getElementById('obs') var obs = document.getElementById('obs')
id = document.getElementById('id-temp').value id = document.getElementById('id-temp').value
var obsPrint = document.getElementById(id+'-obsOrder') var obsPrint = document.getElementById(id+'-obsOrder')
tooltipObs = document.getElementById('tooltip-id-'+id) var order = obsPrint.value.split('|');
var newOrder = '';
fetch(`/comandas/editOrders/${id}/${obs.value}`, { fetch(`/comandas/editOrders/${id}/${obs.value}`, {
method: 'POST', method: 'POST',
@@ -270,9 +262,12 @@ function addOrder(){
.then(data => { .then(data => {
if(data.status == 'ok'){ if(data.status == 'ok'){
showToast('✅Pedido atualizado com sucesso!😁','success') showToast('✅Pedido atualizado com sucesso!😁','success')
tooltipObs.dataset.tooltip = data.obs
obs.value = '' obs.value = ''
obsPrint.value = data.obs order[1] = data.obs;
for(var i = 0; i < order.length; i++){
newOrder += order[i] + '|';
}
obsPrint.value = newOrder;
document.getElementById('modal-obs').style.display = 'none'; document.getElementById('modal-obs').style.display = 'none';
} }
@@ -338,3 +333,8 @@ function taxa(){
} }
function inforOrders(id){
var order = document.getElementById(id+'-obsOrder').value.split('|');
feedback(order[2], "", order[1]+' - '+order[5]);
}

View File

@@ -4,7 +4,14 @@
color: black; color: black;
} }
h2 {
font-size: 18px;
justify-self: center;
margin-bottom: 0px;
}
.container { .container {
margin-top: -50px;
border-radius: 8px; border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 0px; padding: 0px;
@@ -91,4 +98,8 @@
} }
#title {
display:none;
}
} }