Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 50b0ba4498 | |||
| 7154901ce3 | |||
| 8b24a06496 | |||
| 3058908b37 | |||
| 9b1d45ae50 | |||
| fbed0e57c2 | |||
| 362a76961b | |||
| 7a3a4b221b |
+57
-20
@@ -543,7 +543,8 @@
|
|||||||
<div class="cfg-section">
|
<div class="cfg-section">
|
||||||
<div class="cfg-section-title">🔐 Senha Admin (editar dias anteriores)</div>
|
<div class="cfg-section-title">🔐 Senha Admin (editar dias anteriores)</div>
|
||||||
<div style="display:flex;gap:6px;margin-top:4px">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1233,6 +1234,7 @@ function loadConfig() {
|
|||||||
}
|
}
|
||||||
function saveConfig() {
|
function saveConfig() {
|
||||||
config.admin_password = document.getElementById('cfg-admin-password').value.trim();
|
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) {}
|
try { localStorage.setItem(CFG_KEY, JSON.stringify(config)); } catch(e) {}
|
||||||
buildDatalists();
|
buildDatalists();
|
||||||
}
|
}
|
||||||
@@ -1246,6 +1248,7 @@ function openConfig() {
|
|||||||
renderCfgList('clientes', 'cfg-clientes-list');
|
renderCfgList('clientes', 'cfg-clientes-list');
|
||||||
renderCfgList('vales_nomes', 'cfg-vales-list');
|
renderCfgList('vales_nomes', 'cfg-vales-list');
|
||||||
document.getElementById('cfg-admin-password').value = config.admin_password || '';
|
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 closeConfig() { document.getElementById('modal-config').classList.remove('open'); }
|
||||||
function renderCfgList(key, containerId) {
|
function renderCfgList(key, containerId) {
|
||||||
@@ -2102,7 +2105,22 @@ document.getElementById('btn-recibo').addEventListener('click', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('btn-limpar').addEventListener('click', () => {
|
document.getElementById('btn-limpar').addEventListener('click', () => {
|
||||||
if (!confirm('Limpar rascunho? Esta acção não pode ser revertida.')) return;
|
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);
|
localStorage.removeItem(LS_KEY);
|
||||||
estado = {
|
estado = {
|
||||||
uuid: crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(),
|
uuid: crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(),
|
||||||
@@ -2113,14 +2131,22 @@ document.getElementById('btn-limpar').addEventListener('click', () => {
|
|||||||
fechamento_contado: { dinheiro: 0, cartoes: 0, receber: 0 },
|
fechamento_contado: { dinheiro: 0, cartoes: 0, receber: 0 },
|
||||||
observacoes: '', id_local: null, sync_status: 'local'
|
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-operador', ''); setVal('f-turno', '');
|
||||||
setVal('f-fech-dinheiro', ''); setVal('f-fech-cartoes', ''); setVal('f-fech-receber', '');
|
setVal('f-fech-dinheiro', ''); setVal('f-fech-cartoes', ''); setVal('f-fech-receber', '');
|
||||||
setVal('f-saldo-esperado', ''); setVal('f-obs', '');
|
setVal('f-saldo-esperado', ''); setVal('f-obs', '');
|
||||||
setVal('sys-troco', '');
|
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();
|
updateTotals();
|
||||||
renderAllTables();
|
|
||||||
syncUI();
|
syncUI();
|
||||||
showToast('Rascunho limpo.', 'info');
|
showToast('Rascunho limpo.', 'info');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ─── Dia Anterior — seleção + consulta + edição de registros do Supabase ───
|
// ─── Dia Anterior — seleção + consulta + edição de registros do Supabase ───
|
||||||
@@ -2175,19 +2201,21 @@ function buildConsultaModal(recentList) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Calcula saldo de caixa real (mesma fórmula do relatório)
|
// Calcula saldo de caixa real (mesma fórmula do relatório)
|
||||||
// Lê tanto do top-level quanto do JSON dados (old records compatibility)
|
// SALDO CAIXA = soma dos campos individuais (total do sistema no relatório)
|
||||||
|
// Lê do top-level E do JSON dados (compatibilidade com registros antigos)
|
||||||
|
// SALDO CAIXA = soma dos campos individuais (total do sistema no relatório)
|
||||||
|
// Prioriza top-level, só usa dados.dados se top-level for 0/missing (compat old records)
|
||||||
|
const f = (item, dados, field) => parseFloat(item[field]||dados[field]||0);
|
||||||
const calcSaldoCaixa = item => {
|
const calcSaldoCaixa = item => {
|
||||||
const dados = item.dados || {};
|
const dados = item.dados || {};
|
||||||
return (parseFloat(item.saldo_troco)||0)
|
return f(item,dados,'saldo_troco')
|
||||||
+ (parseFloat(item.saldo_credito)||0)
|
+ f(item,dados,'saldo_credito')
|
||||||
+ (parseFloat(item.saldo_debito)||0)
|
+ f(item,dados,'saldo_debito')
|
||||||
+ (parseFloat(item.saldo_alimentacao)||0)
|
+ f(item,dados,'saldo_alimentacao')
|
||||||
+ (parseFloat(item.saldo_vales)||0)
|
+ f(item,dados,'saldo_vales')
|
||||||
+ (parseFloat(item.saldo_areceber)||0)
|
+ f(item,dados,'saldo_areceber')
|
||||||
+ (parseFloat(item.total_pixcnpj)||0)
|
+ f(item,dados,'total_pixcnpj')
|
||||||
+ (parseFloat(item.total_cartao_pix)||0)
|
+ f(item,dados,'total_cartao_pix');
|
||||||
+ (parseFloat(dados.total_pixcnpj)||0)
|
|
||||||
+ (parseFloat(dados.total_cartao_pix)||0);
|
|
||||||
};
|
};
|
||||||
const calcCancelamentos = item => {
|
const calcCancelamentos = item => {
|
||||||
const dados = item.dados || {};
|
const dados = item.dados || {};
|
||||||
@@ -2211,8 +2239,8 @@ function buildConsultaModal(recentList) {
|
|||||||
const saldoCaixa = calcSaldoCaixa(item);
|
const saldoCaixa = calcSaldoCaixa(item);
|
||||||
const canc = calcCancelamentos(item);
|
const canc = calcCancelamentos(item);
|
||||||
const diff = saldoCaixa - (parseFloat(item.saldo_esperado)||0) - canc;
|
const diff = saldoCaixa - (parseFloat(item.saldo_esperado)||0) - canc;
|
||||||
const diffClass = diff === 0 ? '#2e7d32' : diff > 0 ? '#e65100' : '#c0272d';
|
const diffClass = Math.abs(diff) <= 4.50 ? '#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 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'}'">
|
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)})">${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>
|
<td style="padding:6px 8px;border-bottom:1px solid #eee;font-size:12px;cursor:pointer" onclick="openConsultaRegistro(${recentList.indexOf(item)})">${item.operador||'?'}</td>
|
||||||
@@ -2634,10 +2662,19 @@ window.toggleEditConsulta = async function() {
|
|||||||
closeRelatorioModal();
|
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() {
|
function askPassword() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const pw = config.admin_password;
|
const fixedPw = config.admin_password;
|
||||||
|
const dynPw = getDynamicPw();
|
||||||
const overlay = document.createElement('div');
|
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.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';
|
overlay.id = 'pw-modal';
|
||||||
@@ -2662,7 +2699,7 @@ function askPassword() {
|
|||||||
inp.addEventListener('keydown', e => { if (e.key === 'Enter') document.getElementById('pw-ok-btn').click(); });
|
inp.addEventListener('keydown', e => { if (e.key === 'Enter') document.getElementById('pw-ok-btn').click(); });
|
||||||
document.getElementById('pw-ok-btn').addEventListener('click', () => {
|
document.getElementById('pw-ok-btn').addEventListener('click', () => {
|
||||||
const val = document.getElementById('pw-input').value;
|
const val = document.getElementById('pw-input').value;
|
||||||
if (val === pw) {
|
if (val === fixedPw || val === dynPw) {
|
||||||
document.getElementById('pw-modal').remove();
|
document.getElementById('pw-modal').remove();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user