Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 50b0ba4498 | |||
| 7154901ce3 |
+58
-32
@@ -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>
|
||||
@@ -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) {
|
||||
@@ -2102,34 +2105,48 @@ document.getElementById('btn-recibo').addEventListener('click', async () => {
|
||||
});
|
||||
|
||||
document.getElementById('btn-limpar').addEventListener('click', () => {
|
||||
if (!confirm('Tem certeza? Irá apagar todas as informações para iniciar uma nova.')) 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'
|
||||
};
|
||||
// Limpa arrays
|
||||
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 };
|
||||
// Limpa todos os campos do formulário principal
|
||||
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');
|
||||
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 ───
|
||||
@@ -2645,10 +2662,19 @@ window.toggleEditConsulta = async function() {
|
||||
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';
|
||||
@@ -2673,7 +2699,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 {
|
||||
|
||||
Reference in New Issue
Block a user