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,17 +94,18 @@ Detalhes {{comanda.name}}
<tr>
<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 %}
<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
onclick="openModalObs({{item.id}})"
src="{% static 'midia/icons/note.svg' %}"
style="width: 25px; height: 35px; cursor: pointer;">
</img>
</span>
<img
onclick="printOrder({{item.id}})"

View File

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

Binary file not shown.

View File

@@ -1,4 +1,5 @@
from django.db import models
from django.utils.formats import date_format
from products.models import Product
from comandas.models import Comanda, ProductComanda
@@ -16,4 +17,12 @@ class Order(models.Model):
canceled = models.DateTimeField(null=True, blank=True)
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>
{% block 'body' %}
<div class="container">
<h1>Pedidos cozinha</h1>
<h1 id="title">Pedidos cozinha</h1>
<div class="kanban-board">
{% csrf_token %}
<div class="column">

View File

@@ -11,17 +11,16 @@
<tr>
<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 %}
<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
onclick="openModalObs({{item.id}})"
src="{% static 'midia/icons/note.svg' %}"
style="width: 25px; height: 35px; cursor: pointer;">
</img>
</span>
<img
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 {
width: 90%;
}

View File

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

View File

@@ -115,28 +115,20 @@ function imprimirFichas() {
}
}
function printOrder(id) {
var item = document.getElementById('id-for-print-'+id).innerText
var cliente = document.getElementById('name-comanda').innerText
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)
var order = document.getElementById(id+'-obsOrder').value
order = order.split('|');
const body = `<style>
td, th {
border-collapse: collapse;
padding-top: 20px;
margin: 20px;
padding-top: 10px;
margin: 10px;
text-align: center;
font-size: 20px;}
</style>
<tr><td>${item}</td></tr>
<tr><td>${obs}</td></tr>
<tr><td>${cliente}${local}</td></tr>
<tr><td>${dateString}</td></tr>
<tr><td>${order[0]}</td></tr>
<tr><td>${order[1]}</td></tr>
<tr><td>${order[3]} - ${order[4]}</td></tr>
<tr><td>${order[5]}</td></tr>
`;
var printWindow = window.open('', '_blank');
@@ -254,11 +246,11 @@ function troco(){
function addOrder(){
obs = document.getElementById('obs')
var obs = document.getElementById('obs')
id = document.getElementById('id-temp').value
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}`, {
method: 'POST',
@@ -270,9 +262,12 @@ function addOrder(){
.then(data => {
if(data.status == 'ok'){
showToast('✅Pedido atualizado com sucesso!😁','success')
tooltipObs.dataset.tooltip = data.obs
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';
}
@@ -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;
}
h2 {
font-size: 18px;
justify-self: center;
margin-bottom: 0px;
}
.container {
margin-top: -50px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 0px;
@@ -91,4 +98,8 @@
}
#title {
display:none;
}
}