function openModal() {
document.getElementById('Modal-add-product').style.display = 'block';
}
function openModalObs(id) {
document.getElementById('modal-obs').style.display = 'block';
idd = document.getElementById('id-temp').value = id;
obs = document.getElementById('obs').value;
console.log(id);
console.log(obs);
}
function modal_payment_comanda() {
document.getElementById('payment-comanda').style.display = 'block';
}
function close_modal_payment_comanda() {
document.getElementById('payment-comanda').style.display = 'none';
}
function closeModal() {
document.getElementById('Modal-add-product').style.display = 'none';
}
function closeModalObs() {
document.getElementById('modal-obs').style.display = 'none';
}
function imprimirFichas() {
const element = document.getElementById("list-products-comanda");
const style = ``;
const agora = new Date();
var dateString = agora.getDay() + '/' + agora.getMonth() + '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes()+' - Raul Rock Bar & Café';
if (element) {
var content = element.innerHTML;
// console.log(content);
content = content.replace(/
]*>(?:(?!<\/img>)[\s\S])*<\/img>/gi,'');
content = content.replace(/
]*>(?:(?!<\/th>)[\s\S])*<\/th>/gi,'');
content = content.replace(/<\/tr>/g,' | | '+dateString+' |
');
console.log(content);
var printWindow = window.open('', '_blank');
printWindow.document.write(''+style);
printWindow.document.close();
printWindow.print();
printWindow.close();
} else {
console.error(`Element with ID not found`);
}
}
function imprimirConta() {
reloadPage();
const element = document.getElementById("list-products-comanda");
const style = ``;
const agora = new Date();
var dateString = agora.getDay() + '/' + agora.getMonth() + '/' + agora.getFullYear() + ' - ' + agora.getHours() + ':' + agora.getMinutes()+' - Raul Rock Bar & Café';
if (element) {
var content = element.innerHTML;
// console.log(content);
content = content.replace(/
]*>(?:(?!<\/img>)[\s\S])*<\/img>/gi,'');
content = content.replace(/]*>(?:(?!<\/th>)[\s\S])*<\/th>/gi,'');
// content = content.replace(/<\/tr>/g,' | | '+dateString+' |
');
console.log(content);
var printWindow = window.open('', '_blank');
printWindow.document.write(''+style);
printWindow.document.close();
printWindow.print();
printWindow.close();
} else {
console.error(`Element with ID not found`);
}
}
function reloadPage(){
setTimeout(function() {
location.reload();}, 100);
}
function backPage() {
setTimeout(function() {
history.back();}, 100);
setTimeout(function() {
location.reload();}, 100);
}
// document.onkeydown = teclado
// function teclado(event){
// if (event.keyCode == 65){
// openModal()
// }
// else if (event.keyCode == 73){
// imprimirFichas()
// }
// }
function addOrder(){
obs = document.getElementById('obs').value
var id = document.getElementById('id-temp').value
fetch(`/comandas/editOrders/${id}/${obs}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'}
})
.then(function(response) {
if(response.status == 200){
closeModalObs()
alert('Pedido atualizado com sucesso!')
}else{
alert('Erro ao atualizar pedido!')
}
})
}
function addProductComanda(productId,comandaId, cuisine) {
obs = document.getElementById('obs');
console.log(obs.value);
console.log(cuisine);
if(cuisine == 'ggg'){
var obs = openModalObs();
}else{
fetch(`/comandas/addProduct${productId}/${comandaId}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'}
})
.then(function(response) {
return response.text();
}).then(function(text) {
console.log(text);
var listProductsBalcaoElement = document.getElementById("list-products-comanda");
listProductsBalcaoElement.innerHTML = text;
})
// const receber = document.getElementById('pagarComanda')
// const imprimir = document.getElementById('imprimirFichas')
// var search = document.getElementById('search-product')
// setTimeout(function() {
// updateTotal();}, 100);
alert('Produto adicionado com sucesso!');
}
}
// document.getElementById('openModal').addEventListener('click', openModal);
// document.getElementById('productForm').addEventListener('submit', function(event) {
// event.preventDefault();
// });
// hx-get="{% url 'addProduct' product.id comanda.id %} " hx-trigger="click" hx-target="#list-products-comanda"