mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
feedback pagamento de multiplas comandas
This commit is contained in:
Binary file not shown.
@@ -17,10 +17,10 @@ Comandas
|
|||||||
<div style="justify-self: center;">
|
<div style="justify-self: center;">
|
||||||
<h4>{{client.name}}</h4>
|
<h4>{{client.name}}</h4>
|
||||||
<h4>R$ {{client.id | totalFiado}}</h4><br>
|
<h4>R$ {{client.id | totalFiado}}</h4><br>
|
||||||
<h4 id="total-selecionado">R$</h4>
|
<!-- <h4 id="total-selecionado">R$</h4> -->
|
||||||
<button id="btn-fechar-comandas" class="btn-fechar" onclick="enviarComandasSelecionadas()">
|
<button id="btn-fechar-comandas" class="btn-fechar" onclick="enviarComandasSelecionadas()">
|
||||||
<span class="icon">✓</span>
|
|
||||||
Fechar Comandas Selecionadas
|
Receber
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -96,13 +96,13 @@ def payDebt(request):
|
|||||||
except Comanda.DoesNotExist:
|
except Comanda.DoesNotExist:
|
||||||
return JsonResponse({'error': f'Comanda com ID {comanda_id} não encontrada'}, status=404)
|
return JsonResponse({'error': f'Comanda com ID {comanda_id} não encontrada'}, status=404)
|
||||||
|
|
||||||
return redirect(f'/clients/viewClient/{comanda.client.id}')
|
# return redirect(f'/clients/viewClient/{comanda.client.id}')
|
||||||
|
|
||||||
# return JsonResponse({
|
return JsonResponse({
|
||||||
# 'success': True,
|
'success': True,
|
||||||
# 'message': f'{len(comanda_ids)} comandas processadas',
|
'message': f'{len(comanda_ids)} comandas processadas',
|
||||||
# 'ids': comanda_ids
|
'ids': comanda_ids
|
||||||
# }, status=200)
|
}, status=200)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -156,6 +156,8 @@
|
|||||||
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -175,3 +175,15 @@ function openFullscreen() {
|
|||||||
toast.classList.remove('show');
|
toast.classList.remove('show');
|
||||||
}, duration);
|
}, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function feedback(message, status, subMessage) {
|
||||||
|
var feedbackMsg = Swal.fire({
|
||||||
|
title: message,
|
||||||
|
text: subMessage || '',
|
||||||
|
icon: status,
|
||||||
|
background: 'rgba(8, 9, 10, 0.75)',
|
||||||
|
confirmButtonColor: 'linear-gradient(145deg, #1E2A3B, #2C3E50)',
|
||||||
|
});
|
||||||
|
return feedbackMsg;
|
||||||
|
}
|
||||||
@@ -57,6 +57,8 @@ function editclient(id) {
|
|||||||
|
|
||||||
|
|
||||||
function calcularTotalSelecionado() {
|
function calcularTotalSelecionado() {
|
||||||
|
const btn = document.getElementById('btn-fechar-comandas');
|
||||||
|
|
||||||
let total = 0;
|
let total = 0;
|
||||||
// Seleciona todos os checkboxes marcados (exceto o "selectAll")
|
// Seleciona todos os checkboxes marcados (exceto o "selectAll")
|
||||||
const checkboxes = document.querySelectorAll('input[type="checkbox"]:checked:not(#selectAll)');
|
const checkboxes = document.querySelectorAll('input[type="checkbox"]:checked:not(#selectAll)');
|
||||||
@@ -79,12 +81,10 @@ function calcularTotalSelecionado() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(total)
|
|
||||||
|
|
||||||
// Exibe o total na tela (você pode ajustar onde mostrar)
|
// Exibe o total no botão de receber
|
||||||
const totalElement = document.getElementById('total-selecionado');
|
if (btn) {
|
||||||
if (totalElement) {
|
btn.innerHTML = 'Receber '+total.toLocaleString('pt-BR', {style: 'currency', currency: 'BRL'});
|
||||||
totalElement.textContent = total.toLocaleString('pt-BR', {style: 'currency', currency: 'BRL'});
|
|
||||||
} else {
|
} else {
|
||||||
// Cria um elemento para mostrar o total se não existir
|
// Cria um elemento para mostrar o total se não existir
|
||||||
const display = document.createElement('div');
|
const display = document.createElement('div');
|
||||||
@@ -141,9 +141,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function enviarComandasSelecionadas() {
|
async function enviarComandasSelecionadas() {
|
||||||
const btn = document.getElementById('btn-fechar-comandas');
|
const btn = document.getElementById('btn-fechar-comandas');
|
||||||
const feedback = document.getElementById('api-feedback');
|
|
||||||
|
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
btn.innerHTML = '<span class="icon">⏳</span> Processando...';
|
btn.innerHTML = '<span class="icon">⏳</span> Processando...';
|
||||||
@@ -160,8 +160,8 @@ async function enviarComandasSelecionadas() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (ids.length === 0) {
|
if (ids.length === 0) {
|
||||||
feedback.textContent = 'Nenhuma comanda válida selecionada.';
|
feedback('Nenhuma comanda selecionada.', 'error', 'Selecione uma comanda e tente novamente.');
|
||||||
feedback.className = 'feedback-message error';
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,8 +188,8 @@ async function enviarComandasSelecionadas() {
|
|||||||
throw new Error(data.error || `Erro HTTP: ${response.status}`);
|
throw new Error(data.error || `Erro HTTP: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
feedback.textContent = data.message || `${ids.length} comandas processadas com sucesso!`;
|
feedback(`${ids.length} comandas pagas com sucesso!`, 'success');
|
||||||
feedback.className = 'feedback-message success';
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@@ -197,15 +197,14 @@ async function enviarComandasSelecionadas() {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erro:', error);
|
console.error('Erro:', error);
|
||||||
feedback.textContent = error.message || 'Erro ao processar comandas. Verifique o console para mais detalhes.';
|
feedback('Erro', 'error', error);
|
||||||
feedback.className = 'feedback-message error';
|
|
||||||
} finally {
|
} finally {
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '<span class="icon">✓</span> Fechar Comandas Selecionadas';
|
btn.innerHTML = 'Receber';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Função auxiliar para pegar o token CSRF
|
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
let cookieValue = null;
|
let cookieValue = null;
|
||||||
if (document.cookie && document.cookie !== '') {
|
if (document.cookie && document.cookie !== '') {
|
||||||
@@ -221,5 +220,3 @@ function getCookie(name) {
|
|||||||
return cookieValue;
|
return cookieValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exemplo de como chamar a função (pode ser vinculada a um botão)
|
|
||||||
// document.getElementById('btn-fechar-comandas').addEventListener('click', enviarComandasSelecionadas);
|
|
||||||
Reference in New Issue
Block a user