Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3d5c4fbca | |||
| 5f1d9a4e2f | |||
| cc45ed9df7 | |||
| 378a589572 | |||
| 50b0ba4498 | |||
| 7154901ce3 | |||
| 8b24a06496 | |||
| 3058908b37 | |||
| 9b1d45ae50 |
+103
-76
@@ -543,7 +543,8 @@
|
||||
<div class="cfg-section">
|
||||
<div class="cfg-section-title">🔐 Senha Admin (editar dias anteriores)</div>
|
||||
<div style="display:flex;gap:6px;margin-top:4px">
|
||||
<input type="password" id="cfg-admin-password" style="flex:1;padding:6px;border:1px solid #ddd;border-radius:4px;font-size:13px" placeholder="Deixe em branco se não quiser senha">
|
||||
<input type="password" id="cfg-admin-password" style="flex:1;padding:6px;border:1px solid #ddd;border-radius:4px;font-size:13px" placeholder="Senha fixa (ou deixe em branco)">
|
||||
<input type="password" id="cfg-dynamic-password" style="flex:1;padding:6px;border:1px solid #ddd;border-radius:4px;font-size:13px" placeholder="Dinâmica: 10+dia+mes (ex: 1217)">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -564,7 +565,7 @@
|
||||
<p style="font-size:13px;color:#444;margin-bottom:14px">
|
||||
Tem certeza que deseja <strong>enviar este fechamento e encerrar o caixa?</strong>
|
||||
</p>
|
||||
<div id="confirm-summary" style="border:1px solid #b3d9f7;border-radius:8px;padding:14px;background:#f0f7ff;font-size:14px;font-family:Arial,sans-serif;line-height:1.6">
|
||||
<div id="confirm-summary" style="border:1px solid #b3d9f7;border-radius:8px;padding:18px;background:#f0f7ff;font-size:16px;font-family:Arial,sans-serif;line-height:1.8">
|
||||
</div>
|
||||
<p style="font-size:11px;color:#888;margin-top:10px">
|
||||
Após enviar, <strong>não dá pra editar este fechamento</strong> sem a senha do Filipe.
|
||||
@@ -1233,6 +1234,7 @@ function loadConfig() {
|
||||
}
|
||||
function saveConfig() {
|
||||
config.admin_password = document.getElementById('cfg-admin-password').value.trim();
|
||||
config.dynamic_password = document.getElementById('cfg-dynamic-password').value.trim();
|
||||
try { localStorage.setItem(CFG_KEY, JSON.stringify(config)); } catch(e) {}
|
||||
buildDatalists();
|
||||
}
|
||||
@@ -1246,6 +1248,7 @@ function openConfig() {
|
||||
renderCfgList('clientes', 'cfg-clientes-list');
|
||||
renderCfgList('vales_nomes', 'cfg-vales-list');
|
||||
document.getElementById('cfg-admin-password').value = config.admin_password || '';
|
||||
document.getElementById('cfg-dynamic-password').value = config.dynamic_password || '';
|
||||
}
|
||||
function closeConfig() { document.getElementById('modal-config').classList.remove('open'); }
|
||||
function renderCfgList(key, containerId) {
|
||||
@@ -1792,21 +1795,21 @@ function openPrintPreview(data, mode) {
|
||||
|
||||
const previewStyle = `
|
||||
<style>
|
||||
body { width: 80mm; margin: 0 auto; font-family: 'Courier New', monospace; font-size: 13px; background: #fff; padding: 10px; }
|
||||
body { width: 80mm; margin: 0 auto; font-family: 'Courier New', monospace; font-size: 18px; background: #fff; padding: 10px; font-weight: bold; }
|
||||
.header { text-align: center; margin-bottom: 8px; }
|
||||
.header h1 { font-size: 18px; }
|
||||
.header h2 { font-size: 14px; font-weight: normal; }
|
||||
.header h1 { font-size: 24px; font-weight: bold; }
|
||||
.header h2 { font-size: 18px; font-weight: bold; }
|
||||
hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
|
||||
.section-title { font-weight: bold; font-size: 14px; border-top: 1px dashed #000; padding-top: 4px; margin-top: 6px; }
|
||||
.row { display: flex; justify-content: space-between; padding: 2px 0; }
|
||||
table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
||||
td { padding: 2px 4px; vertical-align: top; }
|
||||
.section-title { font-weight: bold; font-size: 17px; border-top: 1px dashed #000; padding-top: 4px; margin-top: 6px; }
|
||||
.row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 16px; font-weight: bold; }
|
||||
table { width: 100%; border-collapse: collapse; font-size: 16px; font-weight: bold; }
|
||||
td { padding: 2px 4px; vertical-align: top; font-weight: bold; }
|
||||
td:nth-child(2) { text-align: right; }
|
||||
td:nth-child(3) { text-align: right; color: #555; font-size: 11px; }
|
||||
.grand-total { font-size: 16px; font-weight: bold; text-align: center; padding: 6px; border: 2px solid #000; margin: 8px 0; }
|
||||
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; }
|
||||
.footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; }
|
||||
@media print { body { background: #fff; } }
|
||||
td:nth-child(3) { text-align: right; color: #555; font-size: 13px; }
|
||||
.grand-total { font-size: 20px; font-weight: bold; text-align: center; padding: 6px; border: 2px solid #000; margin: 8px 0; }
|
||||
.obs { font-size: 13px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
|
||||
.footer { text-align: center; font-size: 13px; color: #555; margin-top: 8px; font-weight: normal; }
|
||||
@media print { body { background: #fff; font-size: 18px !important; font-weight: bold !important; } }
|
||||
</style>
|
||||
`;
|
||||
|
||||
@@ -2002,26 +2005,26 @@ function openConfirmModal() {
|
||||
const diferenca = sysTotal - saldoEsp - cancelamentos;
|
||||
const diffClass = diferenca === 0 ? '#2e7d32' : (diferenca > 0 ? '#e65100' : '#c0272d');
|
||||
document.getElementById('confirm-summary').innerHTML =
|
||||
`<div style="margin-bottom:6px"><strong>📅 Data:</strong> ${estado.data} <strong>👤 Operador:</strong> ${operador} <strong>⏰ Turno:</strong> ${turno} <strong>🏪 Loja:</strong> ${loja}</div>
|
||||
`<div style="margin-bottom:6px;font-size:17px"><strong>📅 Data:</strong> ${estado.data} <strong>👤 Operador:</strong> ${operador} <strong>⏰ Turno:</strong> ${turno} <strong>🏪 Loja:</strong> ${loja}</div>
|
||||
<hr style="border:none;border-top:1px dashed #b3d9f7;margin:6px 0">
|
||||
<div>💸 Sangrias: <strong>${fmt(sangrias)}</strong></div>
|
||||
<div>📝 Despesas: <strong>${fmt(despesas)}</strong></div>
|
||||
<div>💰 Vales: <strong>${fmt(vales)}</strong></div>
|
||||
<div>👥 À Receber: <strong>${fmt(receber)}</strong></div>
|
||||
<div>🔵 PIX CNPJ: <strong>${fmt(pixcnpj)}</strong></div>
|
||||
<div>💳 Crédito: <strong>${fmt(cartCred)}</strong></div>
|
||||
<div>💳 Débito: <strong>${fmt(cartDeb)}</strong></div>
|
||||
<div>💳 Alimentação: <strong>${fmt(cartAli)}</strong></div>
|
||||
<div>❌ Cancelamentos: <strong>${fmt(cancelamentos)}</strong></div>
|
||||
<div>👥 Clientes: <strong>${estado.clientes || 0}</strong></div>
|
||||
<div>🍗 Frango Assado: <strong>${estado.frango || 0}</strong></div>
|
||||
<div>💰 Vendas: <strong>${fmt(estado.vendas || 0)}</strong></div>
|
||||
<div>📋 Fechamento (contado): <strong>${fmt(fechamento)}</strong></div>
|
||||
<div>🖥️ Total Sistema: <strong>${fmt(sysTotal)}</strong></div>
|
||||
<div style="font-size:16px">💸 Sangrias: <strong>${fmt(sangrias)}</strong></div>
|
||||
<div style="font-size:16px">📝 Despesas: <strong>${fmt(despesas)}</strong></div>
|
||||
<div style="font-size:16px">💰 Vales: <strong>${fmt(vales)}</strong></div>
|
||||
<div style="font-size:16px">👥 À Receber: <strong>${fmt(receber)}</strong></div>
|
||||
<div style="font-size:16px">🔵 PIX CNPJ: <strong>${fmt(pixcnpj)}</strong></div>
|
||||
<div style="font-size:16px">💳 Crédito: <strong>${fmt(cartCred)}</strong></div>
|
||||
<div style="font-size:16px">💳 Débito: <strong>${fmt(cartDeb)}</strong></div>
|
||||
<div style="font-size:16px">💳 Alimentação: <strong>${fmt(cartAli)}</strong></div>
|
||||
<div style="font-size:16px">❌ Cancelamentos: <strong>${fmt(cancelamentos)}</strong></div>
|
||||
<div style="font-size:16px">👥 Clientes: <strong>${estado.clientes || 0}</strong></div>
|
||||
<div style="font-size:16px">🍗 Frango Assado: <strong>${estado.frango || 0}</strong></div>
|
||||
<div style="font-size:16px">💰 Vendas: <strong>${fmt(estado.vendas || 0)}</strong></div>
|
||||
<div style="font-size:16px">📋 Fechamento (contado): <strong>${fmt(fechamento)}</strong></div>
|
||||
<div style="font-size:16px">🖥️ Total Sistema: <strong>${fmt(sysTotal)}</strong></div>
|
||||
<hr style="border:none;border-top:1px dashed #b3d9f7;margin:6px 0">
|
||||
<div>🎯 Saldo Esperado (contado): <strong>${fmt(saldoEsp)}</strong></div>
|
||||
<div style="margin-top:4px">📐 Diferença: <strong style="color:${diffClass}">${fmt(diferenca)}</strong></div>
|
||||
<div style="margin-top:4px;font-size:10px;color:#888">ID: ${estado.loja}_${estado.data}_${estado.operador}</div>`;
|
||||
<div style="font-size:16px">🎯 Saldo Esperado (contado): <strong>${fmt(saldoEsp)}</strong></div>
|
||||
<div style="margin-top:4px;font-size:16px">📐 Diferença: <strong style="color:${diffClass}">${fmt(diferenca)}</strong></div>
|
||||
<div style="margin-top:8px;font-size:12px;color:#888">ID: ${estado.loja}_${estado.data}_${estado.operador}</div>`;
|
||||
console.log('[DEBUG] openConfirmModal: tentando abrir modal');
|
||||
document.getElementById('modal-confirm').classList.add('open');
|
||||
}
|
||||
@@ -2102,25 +2105,48 @@ document.getElementById('btn-recibo').addEventListener('click', async () => {
|
||||
});
|
||||
|
||||
document.getElementById('btn-limpar').addEventListener('click', () => {
|
||||
if (!confirm('Limpar rascunho? Esta acção não pode ser revertida.')) return;
|
||||
localStorage.removeItem(LS_KEY);
|
||||
estado = {
|
||||
uuid: crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(),
|
||||
loja: estado.loja, data: estado.data, operador: '', turno: '',
|
||||
saldo_troco: 0, fechamento: 0, saldo_esperado: 0, diferenca: 0,
|
||||
despesas: [], sangrias: [], pixcnpj: [], vales: [], receber: [], cancelamentos: [],
|
||||
cartoes: { credito: [], debito: [], alimentacao: [], pix: [] },
|
||||
fechamento_contado: { dinheiro: 0, cartoes: 0, receber: 0 },
|
||||
observacoes: '', id_local: null, sync_status: 'local'
|
||||
};
|
||||
setVal('f-operador', ''); setVal('f-turno', '');
|
||||
setVal('f-fech-dinheiro', ''); setVal('f-fech-cartoes', ''); setVal('f-fech-receber', '');
|
||||
setVal('f-saldo-esperado', ''); setVal('f-obs', '');
|
||||
setVal('sys-troco', '');
|
||||
updateTotals();
|
||||
renderAllTables();
|
||||
syncUI();
|
||||
showToast('Rascunho limpo.', 'info');
|
||||
const overlay = document.createElement('div');
|
||||
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:999999;display:flex;align-items:center;justify-content:center;';
|
||||
overlay.id = 'clear-modal';
|
||||
overlay.innerHTML = `
|
||||
<div style="background:#fff;border-radius:10px;padding:28px;width:340px;text-align:center">
|
||||
<div style="font-size:20px;margin-bottom:12px">⚠️ Limpar Rascunho</div>
|
||||
<div style="font-size:13px;color:#555;margin-bottom:20px;line-height:1.5">Tem certeza?<br>Irá <strong>apagar todas as informações</strong> lançadas para iniciar uma nova.</div>
|
||||
<div style="display:flex;gap:10px;justify-content:center">
|
||||
<button id="clear-cancel-btn" style="padding:9px 20px;background:#888;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px">Cancelar</button>
|
||||
<button id="clear-ok-btn" style="padding:9px 20px;background:#c0272d;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px">Apagar tudo</button>
|
||||
</div>
|
||||
</div>`;
|
||||
document.body.appendChild(overlay);
|
||||
document.getElementById('clear-cancel-btn').addEventListener('click', () => overlay.remove());
|
||||
document.getElementById('clear-ok-btn').addEventListener('click', () => {
|
||||
overlay.remove();
|
||||
localStorage.removeItem(LS_KEY);
|
||||
estado = {
|
||||
uuid: crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(),
|
||||
loja: estado.loja, data: estado.data, operador: '', turno: '',
|
||||
saldo_troco: 0, fechamento: 0, saldo_esperado: 0, diferenca: 0,
|
||||
despesas: [], sangrias: [], pixcnpj: [], vales: [], receber: [], cancelamentos: [],
|
||||
cartoes: { credito: [], debito: [], alimentacao: [], pix: [] },
|
||||
fechamento_contado: { dinheiro: 0, cartoes: 0, receber: 0 },
|
||||
observacoes: '', id_local: null, sync_status: 'local'
|
||||
};
|
||||
estado.sangrias = []; estado.despesas = []; estado.pixcnpj = [];
|
||||
estado.vales = []; estado.receber = []; estado.cancelamentos = [];
|
||||
estado.cartoes = { credito: [], debito: [], alimentacao: [], pix: [] };
|
||||
estado.fechamento_contado = { dinheiro: 0, cartoes: 0, receber: 0 };
|
||||
setVal('f-operador', ''); setVal('f-turno', '');
|
||||
setVal('f-fech-dinheiro', ''); setVal('f-fech-cartoes', ''); setVal('f-fech-receber', '');
|
||||
setVal('f-saldo-esperado', ''); setVal('f-obs', '');
|
||||
setVal('f-vendas', ''); setVal('f-clientes', ''); setVal('f-frango', '');
|
||||
setVal('sys-troco', ''); setVal('sys-total', '');
|
||||
setVal('sys-credito', ''); setVal('sys-debito', '');
|
||||
setVal('sys-alimentacao', ''); setVal('sys-pixcnpj', '');
|
||||
Object.keys(TABLES).forEach(renderTable);
|
||||
updateTotals();
|
||||
syncUI();
|
||||
showToast('Rascunho limpo.', 'info');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Dia Anterior — seleção + consulta + edição de registros do Supabase ───
|
||||
@@ -2213,8 +2239,8 @@ function buildConsultaModal(recentList) {
|
||||
const saldoCaixa = calcSaldoCaixa(item);
|
||||
const canc = calcCancelamentos(item);
|
||||
const diff = saldoCaixa - (parseFloat(item.saldo_esperado)||0) - canc;
|
||||
const diffClass = diff === 0 ? '#2e7d32' : diff > 0 ? '#e65100' : '#c0272d';
|
||||
const diffLabel = diff === 0 ? '✓ OK' : diff > 0 ? `+R$ ${diff.toFixed(2).replace('.',',')}` : `-R$ ${Math.abs(diff).toFixed(2).replace('.',',')}`;
|
||||
const diffClass = Math.abs(diff) <= 4.50 ? '#2e7d32' : diff > 0 ? '#e65100' : '#c0272d';
|
||||
const diffLabel = Math.abs(diff) <= 4.50 ? `✓ OK (${diff===0?'0':(diff>0?'+':'-')+Math.abs(diff).toFixed(2).replace('.',',')})` : diff > 0 ? `+R$ ${diff.toFixed(2).replace('.',',')} SOBRANDO` : `-R$ ${Math.abs(diff).toFixed(2).replace('.',',')} FALTANDO`;
|
||||
return `<tr data-idx="${recentList.indexOf(item)}" style="background:${i%2===0?'#fff':'#fafafa'}" onmouseover="this.style.background='#fff3e0'" onmouseout="this.style.background='${i%2===0?'#fff':'#fafafa'}'">
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${fmtDate(item.data)}</td>
|
||||
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${item.operador||'?'}</td>
|
||||
@@ -2621,25 +2647,26 @@ window.toggleEditConsulta = async function() {
|
||||
// Se já está editando, apenas fecha
|
||||
if (window._editModalOpen) { closeEditModal(); return; }
|
||||
|
||||
// Pede senha admin primeiro — sempre, para proteger edições
|
||||
const pw = config.admin_password;
|
||||
if (pw) {
|
||||
const ok = await askPassword();
|
||||
if (!ok) return;
|
||||
} else {
|
||||
// Sem senha configurada — avisa e abre mesmo assim (primeiro uso)
|
||||
const ok = await askPassword(); // mostra diálogo vazio para o admin configurar mentalmente
|
||||
if (!ok) return;
|
||||
}
|
||||
// Pede senha — sempre, uma vez (aceita fixa ou dinâmica)
|
||||
if (!await askPassword()) return;
|
||||
|
||||
openEditModal(full);
|
||||
closeRelatorioModal();
|
||||
};
|
||||
|
||||
// Pede senha admin — retorna Promise<boolean>
|
||||
// Calcula senha dinâmica do dia: dia e mês como 2 dígitos cada, concatenados
|
||||
// ex: 17/12 → "1712"
|
||||
function getDynamicPw() {
|
||||
const d = new Date();
|
||||
const day = String(d.getDate()).padStart(2, '0');
|
||||
const month = String(d.getMonth() + 1).padStart(2, '0');
|
||||
return day + month;
|
||||
}
|
||||
|
||||
function askPassword() {
|
||||
return new Promise(resolve => {
|
||||
const pw = config.admin_password;
|
||||
const fixedPw = config.admin_password;
|
||||
const dynPw = getDynamicPw();
|
||||
const overlay = document.createElement('div');
|
||||
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:999999;display:flex;align-items:center;justify-content:center;';
|
||||
overlay.id = 'pw-modal';
|
||||
@@ -2664,7 +2691,7 @@ function askPassword() {
|
||||
inp.addEventListener('keydown', e => { if (e.key === 'Enter') document.getElementById('pw-ok-btn').click(); });
|
||||
document.getElementById('pw-ok-btn').addEventListener('click', () => {
|
||||
const val = document.getElementById('pw-input').value;
|
||||
if (val === pw) {
|
||||
if (val === fixedPw || val === dynPw) {
|
||||
document.getElementById('pw-modal').remove();
|
||||
resolve(true);
|
||||
} else {
|
||||
@@ -3522,26 +3549,26 @@ window.printRelatorio = function() {
|
||||
<title>Fechamento de Caixa</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body { font-family: 'Courier New', monospace; font-size: 14px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
||||
body { font-family: 'Courier New', monospace; font-size: 18px; width: 80mm; margin: 0 auto; padding: 8px; font-weight: bold; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
||||
.header { text-align: center; margin-bottom: 8px; }
|
||||
.header h1 { font-size: 20px; font-weight: bold; }
|
||||
.header h2 { font-size: 15px; font-weight: normal; }
|
||||
.header h1 { font-size: 24px; font-weight: bold; }
|
||||
.header h2 { font-size: 18px; font-weight: normal; }
|
||||
hr { border: none; border-top: 2px solid #000; margin: 6px 0; }
|
||||
.section-title { font-weight: bold; font-size: 14px; border-top: 2px solid #000; padding-top: 4px; margin-top: 8px; }
|
||||
.row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 13px; font-weight: bold; }
|
||||
.section-title { font-weight: bold; font-size: 17px; border-top: 2px solid #000; padding-top: 4px; margin-top: 8px; }
|
||||
.row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 16px; font-weight: bold; }
|
||||
.row.total-row { font-weight: bold; }
|
||||
.cart-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; font-weight: bold; }
|
||||
.cart-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 16px; margin-top: 4px; font-weight: bold; }
|
||||
.cart-table th { font-weight: bold; border-bottom: 2px solid #000; padding: 2px; width: 25%; }
|
||||
.cart-table td { padding: 2px 4px; text-align: right; font-weight: bold; }
|
||||
.cart-table td:first-child { text-align: left; }
|
||||
.cart-table tr.total-row { font-weight: bold; border-top: 2px solid #000; }
|
||||
.subtotal { font-size: 13px; margin-top: 4px; }
|
||||
.subtotal { font-size: 16px; margin-top: 4px; }
|
||||
.subtotal .row { padding: 2px 0; }
|
||||
.diff-ok { color: #2e7d32; font-weight: bold; }
|
||||
.diff-bad { color: #c0272d; font-weight: bold; }
|
||||
.obs { font-size: 11px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
|
||||
.footer { text-align: center; font-size: 11px; color: #555; margin-top: 8px; }
|
||||
@media print { body { background: #fff; font-weight: bold !important; } }
|
||||
.obs { font-size: 13px; color: #555; margin-top: 6px; white-space: pre-wrap; font-weight: normal; }
|
||||
.footer { text-align: center; font-size: 13px; color: #555; margin-top: 8px; }
|
||||
@media print { body { background: #fff; font-weight: bold !important; font-size: 18px !important; } }
|
||||
</style>
|
||||
</head><body>
|
||||
${buildPrintHTML(data)}
|
||||
|
||||
Reference in New Issue
Block a user