Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 292d0b85d9 | |||
| a8edab029d | |||
| cbaef8772d | |||
| 80740afbf0 | |||
| 7134c85bb7 | |||
| 4a157d27cb | |||
| a0f2f91131 |
@@ -140,6 +140,7 @@ impl SupabaseClient {
|
|||||||
"observacoes": estado.get("observacoes").and_then(|v| v.as_str()).unwrap_or(""),
|
"observacoes": estado.get("observacoes").and_then(|v| v.as_str()).unwrap_or(""),
|
||||||
"clientes": estado.get("clientes").and_then(|v| v.as_i64()).unwrap_or(0),
|
"clientes": estado.get("clientes").and_then(|v| v.as_i64()).unwrap_or(0),
|
||||||
"frango": estado.get("frango").and_then(|v| v.as_i64()).unwrap_or(0),
|
"frango": estado.get("frango").and_then(|v| v.as_i64()).unwrap_or(0),
|
||||||
|
"vendas": estado.get("vendas").and_then(|v| v.as_f64()).unwrap_or(0.0),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Primeiro tenta INSERT (upsert via Prefer)
|
// Primeiro tenta INSERT (upsert via Prefer)
|
||||||
@@ -396,6 +397,48 @@ impl SupabaseClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tenta forçar PostgREST a recarregar schema com novas colunas (vendas, edited_at, edited_by).
|
||||||
|
/// Estratégia: INSERT com novas colunas → se PGRST204, espera 1.5s → retry.
|
||||||
|
/// Fire-and-forget — falha não bloqueia.
|
||||||
|
pub fn run_migration(&self) {
|
||||||
|
let payload = serde_json::json!({
|
||||||
|
"id_fechamento": "_mig_probe_1900",
|
||||||
|
"loja": "_probe_",
|
||||||
|
"data": "1900-01-01",
|
||||||
|
"operador": "_probe_",
|
||||||
|
"vendas": 0,
|
||||||
|
"edited_at": null,
|
||||||
|
"edited_by": null
|
||||||
|
});
|
||||||
|
let r1 = self.http
|
||||||
|
.post(&format!("{}/rest/v1/fechamentos_web", self.base_url))
|
||||||
|
.headers(self.headers(true))
|
||||||
|
.header("Prefer", "resolution=merge-duplicates")
|
||||||
|
.json(&payload)
|
||||||
|
.send();
|
||||||
|
if let Ok(resp) = r1 {
|
||||||
|
if resp.status().as_u16() == 400 {
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(1500));
|
||||||
|
let _ = self.http
|
||||||
|
.post(&format!("{}/rest/v1/fechamentos_web", self.base_url))
|
||||||
|
.headers(self.headers(true))
|
||||||
|
.header("Prefer", "resolution=merge-duplicates")
|
||||||
|
.json(&serde_json::json!({
|
||||||
|
"id_fechamento": "_mig_probe_1900",
|
||||||
|
"vendas": 0,
|
||||||
|
"edited_at": null,
|
||||||
|
"edited_by": null
|
||||||
|
}))
|
||||||
|
.send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Limpa probe
|
||||||
|
let _ = self.http
|
||||||
|
.delete(&format!("{}/rest/v1/fechamentos_web?id_fechamento=eq._mig_probe_1900", self.base_url))
|
||||||
|
.headers(self.headers(true))
|
||||||
|
.send();
|
||||||
|
}
|
||||||
|
|
||||||
/// Verifica se está online.
|
/// Verifica se está online.
|
||||||
pub fn health_check(&self) -> bool {
|
pub fn health_check(&self) -> bool {
|
||||||
let url = format!("{}/rest/v1/?limit=0", self.base_url);
|
let url = format!("{}/rest/v1/?limit=0", self.base_url);
|
||||||
|
|||||||
+543
-133
@@ -427,6 +427,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- CONTADORES -->
|
||||||
|
<div class="section">
|
||||||
|
<div class="section-header">📦 Vendas</div>
|
||||||
|
<div style="display:flex;gap:12px">
|
||||||
|
<div style="flex:1">
|
||||||
|
<label style="font-size:12px;color:#666">Vendas (R$)</label>
|
||||||
|
<input type="text" id="f-vendas" placeholder="0,00" style="width:100%;padding:8px;border:1px solid var(--border);border-radius:var(--radius);font-size:15px;text-align:right" onblur="fmtMoneyInput(this)" onfocus="unfmtMoneyInput(this)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- CONTADORES -->
|
<!-- CONTADORES -->
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section-header">👥 Clientes & Frango Assado</div>
|
<div class="section-header">👥 Clientes & Frango Assado</div>
|
||||||
@@ -593,7 +604,7 @@ let estado = {
|
|||||||
despesas: [], sangrias: [], pixcnpj: [], vales: [], receber: [], cancelamentos: [],
|
despesas: [], sangrias: [], pixcnpj: [], vales: [], receber: [], cancelamentos: [],
|
||||||
cartoes: { credito: [], debito: [], alimentacao: [], pix: [] },
|
cartoes: { credito: [], debito: [], alimentacao: [], pix: [] },
|
||||||
fechamento_contado: { dinheiro: 0, cartoes: 0, receber: 0 },
|
fechamento_contado: { dinheiro: 0, cartoes: 0, receber: 0 },
|
||||||
clientes: 0, frango: 0, // contadores
|
clientes: 0, frango: 0, vendas: 0, // contadores
|
||||||
observacoes: '', id_local: null, sync_status: 'local'
|
observacoes: '', id_local: null, sync_status: 'local'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -627,6 +638,14 @@ const fmtNum = v => {
|
|||||||
// Always 2 decimal places for money
|
// Always 2 decimal places for money
|
||||||
return n.toLocaleString('pt-BR', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
return n.toLocaleString('pt-BR', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||||
};
|
};
|
||||||
|
const fmtMoneyInput = el => {
|
||||||
|
const raw = parseNum(el.value);
|
||||||
|
if (raw > 0) el.value = fmtNum(raw);
|
||||||
|
};
|
||||||
|
const unfmtMoneyInput = el => {
|
||||||
|
const raw = parseNum(el.value);
|
||||||
|
if (raw > 0) el.value = raw.toString();
|
||||||
|
};
|
||||||
|
|
||||||
// Format time: 4 digits → HH:MM
|
// Format time: 4 digits → HH:MM
|
||||||
function fmtTime(v) {
|
function fmtTime(v) {
|
||||||
@@ -667,7 +686,7 @@ function makeRow(tblId, rowIndex, rowData) {
|
|||||||
// For numeric cols that hold money, format with 2 decimals
|
// For numeric cols that hold money, format with 2 decimals
|
||||||
// For text cols (hora, desc, obs, nome, gerente, motivo, numero) keep as-is
|
// For text cols (hora, desc, obs, nome, gerente, motivo, numero) keep as-is
|
||||||
const numericCols = ['valor', 'retirada'];
|
const numericCols = ['valor', 'retirada'];
|
||||||
inp.value = rowData[col] !== undefined
|
inp.value = rowData[col] !== undefined && rowData[col] !== null
|
||||||
? (numericCols.includes(col) ? (rowData[col] === 0 ? '' : fmtNum(rowData[col])) : (rowData[col] || ''))
|
? (numericCols.includes(col) ? (rowData[col] === 0 ? '' : fmtNum(rowData[col])) : (rowData[col] || ''))
|
||||||
: '';
|
: '';
|
||||||
inp.placeholder = col === 'valor' || col === 'retirada' ? '0,00' : (col === 'hora' ? 'HH:MM' : '');
|
inp.placeholder = col === 'valor' || col === 'retirada' ? '0,00' : (col === 'hora' ? 'HH:MM' : '');
|
||||||
@@ -1119,6 +1138,7 @@ function buildEstadoForBackend() {
|
|||||||
observacoes: estado.observacoes,
|
observacoes: estado.observacoes,
|
||||||
clientes: estado.clientes,
|
clientes: estado.clientes,
|
||||||
frango: estado.frango,
|
frango: estado.frango,
|
||||||
|
vendas: estado.vendas,
|
||||||
sync_status: estado.sync_status,
|
sync_status: estado.sync_status,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1137,6 +1157,7 @@ function saveState() {
|
|||||||
};
|
};
|
||||||
estado.clientes = parseInt(document.getElementById('f-clientes').value) || 0;
|
estado.clientes = parseInt(document.getElementById('f-clientes').value) || 0;
|
||||||
estado.frango = parseInt(document.getElementById('f-frango').value) || 0;
|
estado.frango = parseInt(document.getElementById('f-frango').value) || 0;
|
||||||
|
estado.vendas = parseNum(val('f-vendas'));
|
||||||
estado.updatedAt = new Date().toISOString();
|
estado.updatedAt = new Date().toISOString();
|
||||||
try { localStorage.setItem(LS_KEY, JSON.stringify(estado)); } catch(e) {}
|
try { localStorage.setItem(LS_KEY, JSON.stringify(estado)); } catch(e) {}
|
||||||
}
|
}
|
||||||
@@ -1158,6 +1179,7 @@ function loadState() {
|
|||||||
estado.observacoes = saved.observacoes || '';
|
estado.observacoes = saved.observacoes || '';
|
||||||
estado.clientes = saved.clientes || 0;
|
estado.clientes = saved.clientes || 0;
|
||||||
estado.frango = saved.frango || 0;
|
estado.frango = saved.frango || 0;
|
||||||
|
estado.vendas = saved.vendas || 0;
|
||||||
estado.sync_status = saved.sync_status || 'local';
|
estado.sync_status = saved.sync_status || 'local';
|
||||||
// Restore tables (always as arrays of objects)
|
// Restore tables (always as arrays of objects)
|
||||||
estado.despesas = Array.isArray(saved.despesas) ? saved.despesas : [];
|
estado.despesas = Array.isArray(saved.despesas) ? saved.despesas : [];
|
||||||
@@ -1672,6 +1694,7 @@ ${cancLines.map(l => `<div class="row"><span>${l.label}</span><span>${fmt(l.valo
|
|||||||
<div class="section-title">CONTADORES</div>
|
<div class="section-title">CONTADORES</div>
|
||||||
<div class="row"><span>Clientes:</span><span>${data.clientes || 0}</span></div>
|
<div class="row"><span>Clientes:</span><span>${data.clientes || 0}</span></div>
|
||||||
<div class="row"><span>Frango Assado:</span><span>${data.frango || 0}</span></div>
|
<div class="row"><span>Frango Assado:</span><span>${data.frango || 0}</span></div>
|
||||||
|
<div class="row"><span>Vendas:</span><span>${fmt(data.vendas || 0)}</span></div>
|
||||||
|
|
||||||
${data.observacoes ? `<div class="obs">${data.observacoes}</div>` : ''}
|
${data.observacoes ? `<div class="obs">${data.observacoes}</div>` : ''}
|
||||||
|
|
||||||
@@ -1741,6 +1764,7 @@ function buildReportHTML(data) {
|
|||||||
<hr>
|
<hr>
|
||||||
<div class="row"><span>👥 Clientes:</span><span class="val">${data.clientes || 0}</span></div>
|
<div class="row"><span>👥 Clientes:</span><span class="val">${data.clientes || 0}</span></div>
|
||||||
<div class="row"><span>🍗 Frango Assado:</span><span class="val">${data.frango || 0}</span></div>
|
<div class="row"><span>🍗 Frango Assado:</span><span class="val">${data.frango || 0}</span></div>
|
||||||
|
<div class="row"><span>💰 Vendas:</span><span class="val">${fmt(data.vendas || 0)}</span></div>
|
||||||
<hr>
|
<hr>
|
||||||
<div style="text-align:center;font-size:10px;color:#888">ID: ${data.loja}_${data.data}_${data.operador}</div>
|
<div style="text-align:center;font-size:10px;color:#888">ID: ${data.loja}_${data.data}_${data.operador}</div>
|
||||||
<div class="footer">Gerado em ${new Date().toLocaleString('pt-BR')}</div>
|
<div class="footer">Gerado em ${new Date().toLocaleString('pt-BR')}</div>
|
||||||
@@ -1889,6 +1913,7 @@ function buildReciboData() {
|
|||||||
observacoes: estado.observacoes,
|
observacoes: estado.observacoes,
|
||||||
clientes: estado.clientes,
|
clientes: estado.clientes,
|
||||||
frango: estado.frango,
|
frango: estado.frango,
|
||||||
|
vendas: estado.vendas || 0,
|
||||||
sync_status: estado.sync_status,
|
sync_status: estado.sync_status,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1957,6 +1982,7 @@ function openConfirmModal() {
|
|||||||
<div>❌ Cancelamentos: <strong>${fmt(cancelamentos)}</strong></div>
|
<div>❌ Cancelamentos: <strong>${fmt(cancelamentos)}</strong></div>
|
||||||
<div>👥 Clientes: <strong>${estado.clientes || 0}</strong></div>
|
<div>👥 Clientes: <strong>${estado.clientes || 0}</strong></div>
|
||||||
<div>🍗 Frango Assado: <strong>${estado.frango || 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>📋 Fechamento (contado): <strong>${fmt(fechamento)}</strong></div>
|
||||||
<div>🖥️ Total Sistema: <strong>${fmt(sysTotal)}</strong></div>
|
<div>🖥️ Total Sistema: <strong>${fmt(sysTotal)}</strong></div>
|
||||||
<hr style="border:none;border-top:1px dashed #b3d9f7;margin:6px 0">
|
<hr style="border:none;border-top:1px dashed #b3d9f7;margin:6px 0">
|
||||||
@@ -2318,97 +2344,15 @@ function buildRelatorioModal(full) {
|
|||||||
<div style="display:flex;justify-content:space-between"><span>Total Despesas</span><span>${fmtMoney(totalDespesas)}</span></div>
|
<div style="display:flex;justify-content:space-between"><span>Total Despesas</span><span>${fmtMoney(totalDespesas)}</span></div>
|
||||||
<div style="display:flex;justify-content:space-between"><span>Clientes</span><span>${clientes}</span></div>
|
<div style="display:flex;justify-content:space-between"><span>Clientes</span><span>${clientes}</span></div>
|
||||||
<div style="display:flex;justify-content:space-between"><span>Frango Assado</span><span>${frango}</span></div>
|
<div style="display:flex;justify-content:space-between"><span>Frango Assado</span><span>${frango}</span></div>
|
||||||
|
<div style="display:flex;justify-content:space-between"><span>Vendas</span><span>${fmtMoney(full.vendas || 0)}</span></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${obs ? `<div style="background:#fff8e1;border-radius:6px;padding:8px;margin-bottom:10px;font-size:12px"><strong>Obs:</strong> ${obs}</div>` : ''}
|
${obs ? `<div style="background:#fff8e1;border-radius:6px;padding:8px;margin-bottom:10px;font-size:12px"><strong>Obs:</strong> ${obs}</div>` : ''}
|
||||||
|
|
||||||
<div id="edit-section" style="display:none;margin-bottom:10px">
|
|
||||||
<input type="hidden" id="edit-id" value="${full.id || ''}" />
|
|
||||||
<div style="font-size:12px;color:#666;margin-bottom:6px;font-weight:bold">✏️ Editar valores do caixa (requer senha admin):</div>
|
|
||||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:8px">
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Troco:</label>
|
|
||||||
<input type="text" id="edit-troco" value="${fmtMoney(troco)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Credito:</label>
|
|
||||||
<input type="text" id="edit-credito" value="${fmtMoney(credito)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Debito:</label>
|
|
||||||
<input type="text" id="edit-debito" value="${fmtMoney(debito)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Alimentacao:</label>
|
|
||||||
<input type="text" id="edit-alimentacao" value="${fmtMoney(alimentacao)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Vales:</label>
|
|
||||||
<input type="text" id="edit-vales" value="${fmtMoney(vales)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">PIX Cartao:</label>
|
|
||||||
<input type="text" id="edit-pixcartao" value="${fmtMoney(pixCartao)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">PIX CNPJ:</label>
|
|
||||||
<input type="text" id="edit-pixcnpj" value="${fmtMoney(pixCnpj)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">A Receber:</label>
|
|
||||||
<input type="text" id="edit-areceber" value="${fmtMoney(parseFloat(full.saldo_areceber||0))}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="font-size:12px;color:#666;margin-bottom:4px;font-weight:bold;margin-top:6px">💰 Valores Contados:</div>
|
|
||||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;margin-bottom:8px">
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Dinheiro:</label>
|
|
||||||
<input type="text" id="edit-fd" value="${fmtMoney(fd)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Cartoes:</label>
|
|
||||||
<input type="text" id="edit-fc" value="${fmtMoney(fc)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">A Receber:</label>
|
|
||||||
<input type="text" id="edit-fr" value="${fmtMoney(fr)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:6px;margin-bottom:8px">
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Sangrias:</label>
|
|
||||||
<input type="text" id="edit-sangrias" value="${fmtMoney(totalSangrias)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Despesas:</label>
|
|
||||||
<input type="text" id="edit-despesas" value="${fmtMoney(totalDespesas)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Clientes:</label>
|
|
||||||
<input type="number" id="edit-clientes" value="${clientes}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label style="font-size:10px;color:#555">Frango:</label>
|
|
||||||
<input type="number" id="edit-frango" value="${frango}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="font-size:12px;color:#666;margin-bottom:4px;font-weight:bold;margin-top:6px">📋 Meta / Observacoes:</div>
|
|
||||||
<div style="margin-bottom:6px">
|
|
||||||
<label style="font-size:10px;color:#555">Saldo Esperado:</label>
|
|
||||||
<input type="text" id="edit-esperado" value="${fmtMoney(saldoEsperado)}" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px" />
|
|
||||||
</div>
|
|
||||||
<div style="margin-bottom:6px">
|
|
||||||
<label style="font-size:10px;color:#555">Observacoes:</label>
|
|
||||||
<textarea id="edit-obs" style="width:100%;padding:3px;border:1px solid #ccc;border-radius:3px;font-size:12px;height:50px">${obs}</textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="display:flex;gap:8px;flex-wrap:wrap">
|
<div style="display:flex;gap:8px;flex-wrap:wrap">
|
||||||
<button onclick="window.printRelatorio()" style="flex:1;padding:8px;background:#1565c0;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px">🖨️ Imprimir</button>
|
<button onclick="window.printRelatorio()" style="flex:1;padding:8px;background:#1565c0;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px">🖨️ Imprimir</button>
|
||||||
<button onclick="window.abrirFechamentoEdicao(full)" style="flex:1;padding:8px;background:#7b1fa2;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px">✏️ Editar caixa completo</button>
|
<button onclick="window.toggleEditConsulta()" style="flex:1;padding:8px;background:#e65100;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px" id="btn-edit-consulta">✏️ Editar (senha)</button>
|
||||||
<button onclick="window.toggleEditConsulta()" style="flex:1;padding:8px;background:#e65100;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px" id="btn-edit-consulta">✏️ Editar totais (senha)</button>
|
|
||||||
<button onclick="window.salvarEdicaoConsulta()" style="flex:1;padding:8px;background:#2e7d32;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px;display:none" id="btn-salvar-consulta">💾 Salvar</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@@ -2437,8 +2381,18 @@ window.abrirFechamentoEdicao = function(full) {
|
|||||||
estado.turno = dados.turno || full.turno || '';
|
estado.turno = dados.turno || full.turno || '';
|
||||||
estado.clientes = dados.clientes ?? full.clientes ?? 0;
|
estado.clientes = dados.clientes ?? full.clientes ?? 0;
|
||||||
estado.frango = dados.frango ?? full.frango ?? 0;
|
estado.frango = dados.frango ?? full.frango ?? 0;
|
||||||
|
estado.vendas = dados.vendas ?? full.vendas ?? 0;
|
||||||
estado.observacoes = dados.observacoes || full.observacoes || '';
|
estado.observacoes = dados.observacoes || full.observacoes || '';
|
||||||
estado.saldo_esperado = dados.saldo_esperado ?? full.saldo_esperado ?? 0;
|
estado.saldo_esperado = dados.saldo_esperado ?? full.saldo_esperado ?? 0;
|
||||||
|
// Campos de sistema — vem dos campos flat do Supabase
|
||||||
|
estado.saldo_troco = parseFloat(full.saldo_troco || dados.saldo_troco || 0);
|
||||||
|
estado.saldo_credito = parseFloat(full.saldo_credito || dados.saldo_credito || 0);
|
||||||
|
estado.saldo_debito = parseFloat(full.saldo_debito || dados.saldo_debito || 0);
|
||||||
|
estado.saldo_alimentacao = parseFloat(full.saldo_alimentacao || dados.saldo_alimentacao || 0);
|
||||||
|
estado.saldo_vales = parseFloat(full.saldo_vales || dados.saldo_vales || 0);
|
||||||
|
estado.saldo_areceber = parseFloat(full.saldo_areceber || dados.saldo_areceber || 0);
|
||||||
|
estado.total_cartao_pix = parseFloat(full.total_cartao_pix || dados.total_cartao_pix || 0);
|
||||||
|
estado.total_pixcnpj = parseFloat(full.total_pixcnpj || dados.total_pixcnpj || 0);
|
||||||
|
|
||||||
// Listas detalhadas
|
// Listas detalhadas
|
||||||
estado.sangrias = (dados.sangrias || []).map(r => ({ hora: r.hora||r.Hora||'', retirada: r.retirada||r.Retirada||r.valor||0, gerente: r.gerente||r.Gerente||'' }));
|
estado.sangrias = (dados.sangrias || []).map(r => ({ hora: r.hora||r.Hora||'', retirada: r.retirada||r.Retirada||r.valor||0, gerente: r.gerente||r.Gerente||'' }));
|
||||||
@@ -2448,17 +2402,30 @@ window.abrirFechamentoEdicao = function(full) {
|
|||||||
estado.receber = (dados.receber || []).map(r => ({ nome: r.nome||r.Nome||'', valor: r.valor||r.Valor||0 }));
|
estado.receber = (dados.receber || []).map(r => ({ nome: r.nome||r.Nome||'', valor: r.valor||r.Valor||0 }));
|
||||||
estado.cancelamentos = (dados.cancelamentos || []).map(r => ({ numero: r.numero||r.Numero||'', valor: r.valor||r.Valor||0 }));
|
estado.cancelamentos = (dados.cancelamentos || []).map(r => ({ numero: r.numero||r.Numero||'', valor: r.valor||r.Valor||0 }));
|
||||||
estado.cartoes = {
|
estado.cartoes = {
|
||||||
credito: (dados.cartoes?.credito || dados.cartoes_credito || []).map(r => ({ valor: r.valor||r.Valor||0 })),
|
credito: (dados.cartoes?.credito || dados.cartoes_credito || []).map(r => ({ valor: typeof r === 'object' ? (r.valor ?? r.Valor ?? 0) : (parseFloat(r) || 0) })),
|
||||||
debito: (dados.cartoes?.debito || dados.cartoes_debito || []).map(r => ({ valor: r.valor||r.Valor||0 })),
|
debito: (dados.cartoes?.debito || dados.cartoes_debito || []).map(r => ({ valor: typeof r === 'object' ? (r.valor ?? r.Valor ?? 0) : (parseFloat(r) || 0) })),
|
||||||
alimentacao:(dados.cartoes?.alimentacao|| dados.cartoes_alimentacao || []).map(r => ({ valor: r.valor||r.Valor||0 })),
|
alimentacao:(dados.cartoes?.alimentacao|| dados.cartoes_alimentacao || []).map(r => ({ valor: typeof r === 'object' ? (r.valor ?? r.Valor ?? 0) : (parseFloat(r) || 0) })),
|
||||||
pix: (dados.cartoes?.pix || dados.cartoes_pix || []).map(r => ({ valor: r.valor||r.Valor||0 }))
|
pix: (dados.cartoes?.pix || dados.cartoes_pix || []).map(r => ({ valor: typeof r === 'object' ? (r.valor ?? r.Valor ?? 0) : (parseFloat(r) || 0) }))
|
||||||
};
|
};
|
||||||
|
estado.pixcnpj = (dados.pixcnpj || []).map(r => ({ nome: r.nome || r.Nome || r.desc || r.Desc || '', valor: typeof r === 'object' ? (r.valor ?? r.Valor ?? 0) : (parseFloat(r) || 0) }));
|
||||||
estado.fechamento_contado = dados.fechamento_contado || { dinheiro: 0, cartoes: 0, receber: 0 };
|
estado.fechamento_contado = dados.fechamento_contado || { dinheiro: 0, cartoes: 0, receber: 0 };
|
||||||
|
|
||||||
// Fecha o modal de consulta
|
// Fecha o modal de consulta
|
||||||
closeRelatorioModal();
|
closeRelatorioModal();
|
||||||
closeConsultaModal();
|
closeConsultaModal();
|
||||||
|
|
||||||
|
// Campos de sistema (saldo de caixa)
|
||||||
|
setVal('sys-troco', fmtNum(estado.saldo_troco));
|
||||||
|
setVal('sys-credito', fmtNum(estado.saldo_credito));
|
||||||
|
setVal('sys-debito', fmtNum(estado.saldo_debito));
|
||||||
|
setVal('sys-alimentacao',fmtNum(estado.saldo_alimentacao));
|
||||||
|
setVal('sys-pixcnpj', fmtNum(estado.total_pixcnpj));
|
||||||
|
// Fechamento contado
|
||||||
|
setVal('f-fech-dinheiro', estado.fechamento_contado?.dinheiro || '');
|
||||||
|
setVal('f-fech-cartoes', estado.fechamento_contado?.cartoes || '');
|
||||||
|
setVal('f-fech-receber', estado.fechamento_contado?.receber || '');
|
||||||
|
setVal('f-saldo-esperado', estado.saldo_esperado || '');
|
||||||
|
|
||||||
// Preenche os campos do formulário
|
// Preenche os campos do formulário
|
||||||
setVal('f-loja', estado.loja);
|
setVal('f-loja', estado.loja);
|
||||||
setVal('f-data', estado.data);
|
setVal('f-data', estado.data);
|
||||||
@@ -2466,6 +2433,7 @@ window.abrirFechamentoEdicao = function(full) {
|
|||||||
setVal('f-turno', estado.turno);
|
setVal('f-turno', estado.turno);
|
||||||
setVal('f-clientes', estado.clientes);
|
setVal('f-clientes', estado.clientes);
|
||||||
setVal('f-frango', estado.frango);
|
setVal('f-frango', estado.frango);
|
||||||
|
setVal('f-vendas', estado.vendas);
|
||||||
|
|
||||||
// Renderiza todas as tabelas com os dados restaurados
|
// Renderiza todas as tabelas com os dados restaurados
|
||||||
renderTable('tbl-sangrias', estado.sangrias);
|
renderTable('tbl-sangrias', estado.sangrias);
|
||||||
@@ -2488,59 +2456,499 @@ window.abrirFechamentoEdicao = function(full) {
|
|||||||
alert('✅ Caixa carregado para edição. Verifique todos os valores antes de enviar.');
|
alert('✅ Caixa carregado para edição. Verifique todos os valores antes de enviar.');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Toggle modo de edição — pede senha admin via modal (não via prompt)
|
// Abre a tela de edição (modal separado) — requer senha admin
|
||||||
window.toggleEditConsulta = async function() {
|
window.toggleEditConsulta = async function() {
|
||||||
if (window._editMode) {
|
const full = window._currentConsulta;
|
||||||
// Cancela edição
|
if (!full) return;
|
||||||
window._editMode = false;
|
|
||||||
document.getElementById('edit-section').style.display = 'none';
|
|
||||||
document.getElementById('btn-salvar-consulta').style.display = 'none';
|
|
||||||
document.getElementById('btn-edit-consulta').textContent = '✏️ Editar (senha)';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Se já está editando, apenas fecha
|
||||||
|
if (window._editModalOpen) { closeEditModal(); return; }
|
||||||
|
|
||||||
|
// Pede senha admin primeiro (se configurada)
|
||||||
const pw = config.admin_password;
|
const pw = config.admin_password;
|
||||||
if (!pw) {
|
if (pw) {
|
||||||
window._editMode = true;
|
const ok = await askPassword();
|
||||||
document.getElementById('edit-section').style.display = 'block';
|
if (!ok) return;
|
||||||
document.getElementById('btn-salvar-consulta').style.display = 'block';
|
|
||||||
document.getElementById('btn-edit-consulta').textContent = '✕ Cancelar';
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modal com senha oculta
|
openEditModal(full);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Pede senha admin — retorna Promise<boolean>
|
||||||
|
function askPassword() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const pw = config.admin_password;
|
||||||
|
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';
|
||||||
|
overlay.innerHTML = `
|
||||||
|
<div style="background:#fff;border-radius:10px;padding:24px;width:300px;text-align:center">
|
||||||
|
<div style="font-size:18px;margin-bottom:16px">🔐 Senha Admin</div>
|
||||||
|
<input type="password" id="pw-input" placeholder="Digite a senha..." style="width:100%;padding:10px;font-size:14px;border:1px solid #ccc;border-radius:6px;box-sizing:border-box;margin-bottom:12px" />
|
||||||
|
<div id="pw-error" style="color:#c0272d;font-size:12px;margin-bottom:8px;display:none">Senha incorreta</div>
|
||||||
|
<div style="display:flex;gap:8px;justify-content:center">
|
||||||
|
<button id="pw-cancel-btn" style="padding:8px 16px;background:#888;color:#fff;border:none;border-radius:6px;cursor:pointer">Cancelar</button>
|
||||||
|
<button id="pw-ok-btn" style="padding:8px 16px;background:#e65100;color:#fff;border:none;border-radius:6px;cursor:pointer">OK</button>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
const inp = document.getElementById('pw-input');
|
||||||
|
inp.focus();
|
||||||
|
|
||||||
|
document.getElementById('pw-cancel-btn').addEventListener('click', () => {
|
||||||
|
document.getElementById('pw-modal').remove();
|
||||||
|
resolve(false);
|
||||||
|
});
|
||||||
|
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) {
|
||||||
|
document.getElementById('pw-modal').remove();
|
||||||
|
resolve(true);
|
||||||
|
} else {
|
||||||
|
document.getElementById('pw-error').style.display = 'block';
|
||||||
|
inp.value = '';
|
||||||
|
inp.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monta HTML de uma grade editável dentro do modal
|
||||||
|
function editTableHTML(id, headers, rows, numericCols) {
|
||||||
|
const hdr = headers.map((h,i) => `<th style="padding:2px 4px;text-align:${numericCols.includes(i)?'right':'left'};font-size:10px;white-space:nowrap">${h}</th>`).join('');
|
||||||
|
const body = rows.map((row, ri) => {
|
||||||
|
const cells = row.map((val, ci) => {
|
||||||
|
const isNum = numericCols.includes(ci);
|
||||||
|
const displayVal = (val !== null && val !== undefined && val !== '')
|
||||||
|
? (isNum ? fmtMoney(val) : val)
|
||||||
|
: '';
|
||||||
|
return `<td style="padding:1px 2px"><input data-tbl="${id}" data-row="${ri}" data-col="${ci}" value="${displayVal}" ${isNum ? `style="width:100%;padding:2px;font-size:11px;text-align:right;border:1px solid #ccc;border-radius:2px"` : `style="width:100%;padding:2px;font-size:11px;border:1px solid #ccc;border-radius:2px"`} /></td>`;
|
||||||
|
}).join('');
|
||||||
|
return `<tr>${cells}</tr>`;
|
||||||
|
}).join('');
|
||||||
|
return `<table style="width:100%;border-collapse:collapse;font-size:11px;margin-bottom:4px"><thead><tr>${hdr}</tr></thead><tbody>${body}</tbody></table>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monta uma grade vazia com N linhas editáveis
|
||||||
|
function editTableEmpty(id, headers, nRows, numericCols) {
|
||||||
|
const emptyRows = Array.from({length: nRows}, () => headers.map(() => ''));
|
||||||
|
return editTableHTML(id, headers, emptyRows, numericCols);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adiciona linha a uma grade editável no modal
|
||||||
|
window._editAddRow = function(tblId) {
|
||||||
|
const container = document.getElementById('tbl-edit-' + tblId);
|
||||||
|
if (!container) return;
|
||||||
|
const tbl = container.querySelector('table');
|
||||||
|
if (!tbl) return;
|
||||||
|
const numericCols = container.dataset.numeric ? JSON.parse(container.dataset.numeric) : [];
|
||||||
|
const cols = tbl.querySelector('tr').cells.length;
|
||||||
|
const newRowIdx = tbl.rows.length;
|
||||||
|
const row = tbl.insertRow(-1);
|
||||||
|
for (let c = 0; c < cols; c++) {
|
||||||
|
const td = row.insertCell(-1);
|
||||||
|
const isNum = numericCols.includes(c);
|
||||||
|
td.innerHTML = `<input data-tbl="${tblId}" data-row="${newRowIdx}" data-col="${c}" value="" ${isNum ? `style="width:100%;padding:2px;font-size:11px;text-align:right;border:1px solid #ccc;border-radius:2px"` : `style="width:100%;padding:2px;font-size:11px;border:1px solid #ccc;border-radius:2px"`} />`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Lê todos os dados das grades editáveis do modal
|
||||||
|
function readEditTables() {
|
||||||
|
const inputs = document.querySelectorAll('#modal-edit input[data-tbl]');
|
||||||
|
const tables = {};
|
||||||
|
inputs.forEach(inp => {
|
||||||
|
const tbl = inp.dataset.tbl;
|
||||||
|
const row = parseInt(inp.dataset.row);
|
||||||
|
const col = parseInt(inp.dataset.col);
|
||||||
|
if (!tables[tbl]) tables[tbl] = [];
|
||||||
|
while (tables[tbl].length <= row) tables[tbl].push([]);
|
||||||
|
tables[tbl][row][col] = inp.value;
|
||||||
|
});
|
||||||
|
// Converte valores numéricos
|
||||||
|
const numericCols = {
|
||||||
|
'credito': [0], 'debito': [0], 'alimentacao': [0], 'pix': [0],
|
||||||
|
'vales': [1], 'despesas': [2], 'sangrias': [1],
|
||||||
|
'cancelamentos': [1], 'pixcnpj': [1], 'receber': [1]
|
||||||
|
};
|
||||||
|
Object.keys(tables).forEach(tbl => {
|
||||||
|
const ncols = numericCols[tbl] || [];
|
||||||
|
tables[tbl] = tables[tbl].filter(row => row.some(c => c !== '' && c != null));
|
||||||
|
tables[tbl] = tables[tbl].map(row => row.map((val, ci) => {
|
||||||
|
if (ncols.includes(ci)) return parseNum(val);
|
||||||
|
return (val || '').trim();
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
return tables;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modal de edição completo com todas as grades
|
||||||
|
function openEditModal(full) {
|
||||||
|
window._editModalOpen = true;
|
||||||
|
|
||||||
|
const dados = full.dados || {};
|
||||||
|
|
||||||
|
// helper para fmt dinheiro
|
||||||
|
const fmtMR = v => {
|
||||||
|
const n = parseFloat(v||0);
|
||||||
|
if (isNaN(n) || n === 0) return '';
|
||||||
|
return 'R$ ' + n.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
|
||||||
|
};
|
||||||
|
|
||||||
|
// helper para fmt table cell
|
||||||
|
const fmtCell = (v, isNum) => {
|
||||||
|
if (v === null || v === undefined || v === '') return '';
|
||||||
|
if (isNum) {
|
||||||
|
const n = parseFloat(v);
|
||||||
|
return isNaN(n) ? '' : 'R$ ' + n.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
|
const editedInfo = full.edited_at
|
||||||
|
? `<div style="background:#fff8e1;border-radius:4px;padding:6px 10px;font-size:11px;color:#666;margin-bottom:8px">
|
||||||
|
<strong>⚠️ Última edição:</strong> ${full.edited_at.replace('T',' ').substring(0,16)} por <strong>${full.edited_by||'?'}</strong>
|
||||||
|
</div>`
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// --- Cartões ---
|
||||||
|
const cartCred_rows = (dados.cartoes?.credito || full.cartoes_credito || []).map((r, i) => [fmtCell(typeof r === 'object' ? r.valor : r, true)]);
|
||||||
|
const cartDeb_rows = (dados.cartoes?.debito || full.cartoes_debito || []).map((r, i) => [fmtCell(typeof r === 'object' ? r.valor : r, true)]);
|
||||||
|
const cartAli_rows = (dados.cartoes?.alimentacao || full.cartoes_alimentacao || []).map((r, i) => [fmtCell(typeof r === 'object' ? r.valor : r, true)]);
|
||||||
|
const cartPix_rows = (dados.cartoes?.pix || full.cartoes_pix || []).map((r, i) => [fmtCell(typeof r === 'object' ? r.valor : r, true)]);
|
||||||
|
|
||||||
|
const cartCredHTML = editTableHTML('credito', ['Valor (R$)'], cartCred_rows.length ? cartCred_rows : [['']], [0]);
|
||||||
|
const cartDebHTML = editTableHTML('debito', ['Valor (R$)'], cartDeb_rows.length ? cartDeb_rows : [['']], [0]);
|
||||||
|
const cartAliHTML = editTableHTML('alimentacao', ['Valor (R$)'], cartAli_rows.length ? cartAli_rows : [['']], [0]);
|
||||||
|
const cartPixHTML = editTableHTML('pix', ['Valor (R$)'], cartPix_rows.length ? cartPix_rows : [['']], [0]);
|
||||||
|
|
||||||
|
// --- Vales ---
|
||||||
|
const vales_rows = (full.vales || []).map(r => [r.nome||r.Nome||'', fmtCell(r.valor, true), r.obs||r.Obs||'']);
|
||||||
|
const valesHTML = editTableHTML('vales', ['Nome', 'Valor (R$)', 'Obs'], vales_rows.length ? vales_rows : [['','','']], [1]);
|
||||||
|
|
||||||
|
// --- Despesas ---
|
||||||
|
const despesas_rows = (full.despesas || []).map(r => [r.desc||r.Desc||'', r.obs||r.Obs||'', fmtCell(r.valor, true)]);
|
||||||
|
const despesasHTML = editTableHTML('despesas', ['Descrição', 'Obs', 'Valor (R$)'], despesas_rows.length ? despesas_rows : [['','','']], [2]);
|
||||||
|
|
||||||
|
// --- Sangrias ---
|
||||||
|
const sangrias_rows = (full.sangrias || []).map(r => [r.hora||r.Hora||'', fmtCell(r.retirada, true), r.gerente||r.Gerente||'']);
|
||||||
|
const sangriasHTML = editTableHTML('sangrias', ['Hora', 'Valor (R$)', 'Gerente'], sangrias_rows.length ? sangrias_rows : [['','','']], [1]);
|
||||||
|
|
||||||
|
// --- Cancelamentos ---
|
||||||
|
const cancel_rows = (full.cancelamentos || []).map(r => [r.numero||r.Numero||'', fmtCell(r.valor, true), r.motivo||r.Motivo||'']);
|
||||||
|
const cancelHTML = editTableHTML('cancelamentos', ['Número', 'Valor (R$)', 'Motivo'], cancel_rows.length ? cancel_rows : [['','','']], [1]);
|
||||||
|
|
||||||
|
// --- PIX CNPJ ---
|
||||||
|
const pixcnpj_rows = (full.pixcnpj || []).map(r => [r.nome||r.Nome||'', fmtCell(r.valor, true)]);
|
||||||
|
const pixcnpjHTML = editTableHTML('pixcnpj', ['Nome', 'Valor (R$)'], pixcnpj_rows.length ? pixcnpj_rows : [['','']], [1]);
|
||||||
|
|
||||||
|
// --- A Receber ---
|
||||||
|
const receber_rows = (full.receber || []).map(r => [r.nome||r.Nome||'', fmtCell(r.valor, true)]);
|
||||||
|
const receberHTML = editTableHTML('receber', ['Nome', 'Valor (R$)'], receber_rows.length ? receber_rows : [['','']], [1]);
|
||||||
|
|
||||||
|
// --- Totais (só leitura formatado) ---
|
||||||
|
const totaisInfo = `
|
||||||
|
<div style="display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:4px;background:#f5f5f5;border-radius:6px;padding:8px;margin-bottom:8px;font-size:11px">
|
||||||
|
<div><strong>Total Crédito:</strong> <span id="edit-total-credito">${fmtMR(full.total_cartao_credito||0)}</span></div>
|
||||||
|
<div><strong>Total Débito:</strong> <span id="edit-total-debito">${fmtMR(full.total_cartao_debito||0)}</span></div>
|
||||||
|
<div><strong>Total Alimentação:</strong> <span id="edit-total-alimentacao">${fmtMR(full.total_cartao_alimentacao||0)}</span></div>
|
||||||
|
<div><strong>Total PIX:</strong> <span id="edit-total-pix">${fmtMR(full.total_cartao_pix||0)}</span></div>
|
||||||
|
<div><strong>Total Sangrias:</strong> ${fmtMR(full.total_sangrias||0)}</div>
|
||||||
|
<div><strong>Total Despesas:</strong> ${fmtMR(full.total_despesas||0)}</div>
|
||||||
|
<div><strong>Total Vales:</strong> ${fmtMR(full.total_vales||0)}</div>
|
||||||
|
<div><strong>Total PIX CNPJ:</strong> ${fmtMR(full.total_pixcnpj||0)}</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
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.id = 'modal-edit';
|
||||||
overlay.id = 'pw-modal';
|
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.6);z-index:99998;overflow-y:auto';
|
||||||
overlay.innerHTML = `
|
overlay.innerHTML = `
|
||||||
<div style="background:#fff;border-radius:10px;padding:24px;width:300px;text-align:center">
|
<div style="background:#fff;margin:16px auto;border-radius:12px;padding:16px;max-width:800px;width:95%;font-size:13px">
|
||||||
<div style="font-size:18px;margin-bottom:16px">🔐 Senha Admin</div>
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;position:sticky;top:0;background:#fff;z-index:1">
|
||||||
<input type="password" id="pw-input" placeholder="Digite a senha..." style="width:100%;padding:10px;font-size:14px;border:1px solid #ccc;border-radius:6px;box-sizing:border-box;margin-bottom:12px" />
|
<h2 style="margin:0;font-size:15px;color:#e65100">✏️ Editar Fechamento Completo</h2>
|
||||||
<div id="pw-error" style="color:#c0272d;font-size:12px;margin-bottom:8px;display:none">Senha incorreta</div>
|
<button onclick="closeEditModal()" style="background:none;border:none;font-size:18px;cursor:pointer;padding:4px 8px">✕</button>
|
||||||
<div style="display:flex;gap:8px;justify-content:center">
|
</div>
|
||||||
<button onclick="document.getElementById('pw-modal').remove()" style="padding:8px 16px;background:#888;color:#fff;border:none;border-radius:6px;cursor:pointer">Cancelar</button>
|
|
||||||
<button id="pw-ok-btn" style="padding:8px 16px;background:#e65100;color:#fff;border:none;border-radius:6px;cursor:pointer">OK</button>
|
${editedInfo}
|
||||||
|
|
||||||
|
<!-- Identificação -->
|
||||||
|
<div style="background:#f5f5f5;border-radius:6px;padding:8px;margin-bottom:10px">
|
||||||
|
<div style="display:grid;grid-template-columns:1fr 1fr 1fr 1fr;gap:8px">
|
||||||
|
<div><label style="font-size:10px;color:#555">Data:</label><input type="date" id="edit-data" value="${full.data||''}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Loja:</label>
|
||||||
|
<select id="edit-loja" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px">
|
||||||
|
<option value="alianca" ${(full.loja||'').toLowerCase()==='alianca'?'selected':''}>Aliança</option>
|
||||||
|
<option value="uniao" ${(full.loja||'').toLowerCase()==='uniao'?'selected':''}>União</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Turno:</label>
|
||||||
|
<select id="edit-turno" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px">
|
||||||
|
<option value="manha" ${(full.turno||'')==='manha'?'selected':''}>Manhã</option>
|
||||||
|
<option value="tarde" ${(full.turno||'')==='tarde'?'selected':''}>Tarde</option>
|
||||||
|
<option value="integral" ${(full.turno||'')==='integral'?'selected':''}>Integral</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Operador:</label><input type="text" id="edit-operador" value="${full.operador||''}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px" /></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Totais (leitura) -->
|
||||||
|
${totaisInfo}
|
||||||
|
|
||||||
|
<!-- Cartões de Crédito -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#1565c0">💳 Cartão de Crédito</strong>
|
||||||
|
<button onclick="_editAddRow('credito')" style="background:#1565c0;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-credito" data-numeric="[0]">${cartCredHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Cartões de Débito -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#2e7d32">💳 Cartão de Débito</strong>
|
||||||
|
<button onclick="_editAddRow('debito')" style="background:#2e7d32;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-debito" data-numeric="[0]">${cartDebHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Alimentação -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#e65100">🍽️ Alimentação</strong>
|
||||||
|
<button onclick="_editAddRow('alimentacao')" style="background:#e65100;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-alimentacao" data-numeric="[0]">${cartAliHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- PIX -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#7b1fa2">📱 PIX</strong>
|
||||||
|
<button onclick="_editAddRow('pix')" style="background:#7b1fa2;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-pix" data-numeric="[0]">${cartPixHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Vales -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#c62828">📋 Vales</strong>
|
||||||
|
<button onclick="_editAddRow('vales')" style="background:#c62828;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-vales" data-numeric="[1]">${valesHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Despesas -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#ef6c00">💸 Despesas</strong>
|
||||||
|
<button onclick="_editAddRow('despesas')" style="background:#ef6c00;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-despesas" data-numeric="[2]">${despesasHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sangrias -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#00695c">🏧 Sangrias</strong>
|
||||||
|
<button onclick="_editAddRow('sangrias')" style="background:#00695c;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-sangrias" data-numeric="[1]">${sangriasHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- PIX CNPJ -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#6a1b9a">PIX CNPJ</strong>
|
||||||
|
<button onclick="_editAddRow('pixcnpj')" style="background:#6a1b9a;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-pixcnpj" data-numeric="[1]">${pixcnpjHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- A Receber -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#283593">📬 A Receber</strong>
|
||||||
|
<button onclick="_editAddRow('receber')" style="background:#283593;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-receber" data-numeric="[1]">${receberHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Cancelamentos -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">
|
||||||
|
<strong style="font-size:12px;color:#777">❌ Cancelamentos</strong>
|
||||||
|
<button onclick="_editAddRow('cancelamentos')" style="background:#777;color:#fff;border:none;border-radius:4px;padding:2px 8px;cursor:pointer;font-size:11px">+ Linha</button>
|
||||||
|
</div>
|
||||||
|
<div id="tbl-edit-cancelamentos" data-numeric="[1]">${cancelHTML}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Saldo de Caixa (editável) -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<strong style="font-size:12px;color:#333;margin-bottom:4px;display:block">💰 Saldo de Caixa</strong>
|
||||||
|
<div style="display:grid;grid-template-columns:repeat(4,1fr);gap:6px">
|
||||||
|
<div><label style="font-size:10px;color:#555">Troco:</label><input type="text" id="edit-troco" value="${fmtMR(full.saldo_troco)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Crédito:</label><input type="text" id="edit-sld-credito" value="${fmtMR(full.saldo_credito)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Débito:</label><input type="text" id="edit-sld-debito" value="${fmtMR(full.saldo_debito)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Alimentação:</label><input type="text" id="edit-sld-alimentacao" value="${fmtMR(full.saldo_alimentacao)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Vales:</label><input type="text" id="edit-sld-vales" value="${fmtMR(full.saldo_vales)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">PIX CNPJ:</label><input type="text" id="edit-sld-pixcnpj" value="${fmtMR(full.total_pixcnpj)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">À Receber:</label><input type="text" id="edit-sld-areceber" value="${fmtMR(full.saldo_areceber)}" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;text-align:right" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Vendas (R$):</label><input type="text" id="edit-vendas" value="${fmtMR(dados.vendas||full.vendas||0)}" style="width:100%;padding:5px;border:1px solid #e65100;border-radius:4px;text-align:right;font-weight:bold" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Contadores -->
|
||||||
|
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;margin-bottom:12px">
|
||||||
|
<div><label style="font-size:10px;color:#555">Clientes:</label><input type="number" id="edit-clientes" value="${dados.clientes||full.clientes||0}" min="0" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Frango Assado:</label><input type="number" id="edit-frango" value="${dados.frango||full.frango||0}" min="0" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px" /></div>
|
||||||
|
<div><label style="font-size:10px;color:#555">Saldo Esperado:</label><input type="text" id="edit-esperado" value="${fmtMR(full.saldo_esperado)}" style="width:100%;padding:5px;border:1px solid #e65100;border-radius:4px;text-align:right;font-weight:bold" onblur="this.value=fmtBR(this)" /></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Observações -->
|
||||||
|
<div style="margin-bottom:12px">
|
||||||
|
<label style="font-size:10px;color:#555">Observações:</label>
|
||||||
|
<textarea id="edit-obs" style="width:100%;padding:5px;border:1px solid #ccc;border-radius:4px;font-size:13px;height:60px">${full.observacoes||''}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display:flex;gap:8px;flex-wrap:wrap">
|
||||||
|
<button onclick="window.salvarEdicaoModal()" style="flex:1;padding:10px;background:#2e7d32;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px;font-weight:bold">💾 Salvar Alterações</button>
|
||||||
|
<button onclick="closeEditModal()" style="padding:10px 16px;background:#888;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px">Cancelar</button>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
document.body.appendChild(overlay);
|
document.body.appendChild(overlay);
|
||||||
const inp = document.getElementById('pw-input');
|
}
|
||||||
inp.focus();
|
|
||||||
inp.addEventListener('keydown', e => { if (e.key === 'Enter') document.getElementById('pw-ok-btn').click(); });
|
// Formata campo de dinheiro brasileiro
|
||||||
document.getElementById('pw-ok-btn').addEventListener('click', () => {
|
function fmtBR(inp) {
|
||||||
const val = document.getElementById('pw-input').value;
|
const v = parseNum(inp.value);
|
||||||
const err = document.getElementById('pw-error');
|
if (isNaN(v) || v === 0) return '';
|
||||||
if (val === pw) {
|
return 'R$ ' + v.toLocaleString('pt-BR', { minimumFractionDigits: 2 });
|
||||||
document.getElementById('pw-modal').remove();
|
}
|
||||||
window._editMode = true;
|
|
||||||
document.getElementById('edit-section').style.display = 'block';
|
// Fecha modal de edição
|
||||||
document.getElementById('btn-salvar-consulta').style.display = 'block';
|
function closeEditModal() {
|
||||||
document.getElementById('btn-edit-consulta').textContent = '✕ Cancelar';
|
const m = document.getElementById('modal-edit');
|
||||||
} else {
|
if (m) document.body.removeChild(m);
|
||||||
err.style.display = 'block';
|
window._editModalOpen = false;
|
||||||
inp.value = '';
|
}
|
||||||
inp.focus();
|
|
||||||
}
|
// Salva edições do modal de edição completo
|
||||||
});
|
window.salvarEdicaoModal = async function() {
|
||||||
|
const full = window._currentConsulta;
|
||||||
|
if (!full) return;
|
||||||
|
|
||||||
|
const p = v => parseNum(v);
|
||||||
|
const inp = id => { const el = document.getElementById(id); return el ? el.value : ''; };
|
||||||
|
|
||||||
|
// Lê todas as grades editáveis
|
||||||
|
const tables = readEditTables();
|
||||||
|
|
||||||
|
// Calcula totais dos cartões
|
||||||
|
const cartCred_tot = (tables.credito || []).reduce((s, r) => s + (r[0] || 0), 0);
|
||||||
|
const cartDeb_tot = (tables.debito || []).reduce((s, r) => s + (r[0] || 0), 0);
|
||||||
|
const cartAli_tot = (tables.alimentacao || []).reduce((s, r) => s + (r[0] || 0), 0);
|
||||||
|
const cartPix_tot = (tables.pix || []).reduce((s, r) => s + (r[0] || 0), 0);
|
||||||
|
const vales_tot = (tables.vales || []).reduce((s, r) => s + (r[1] || 0), 0);
|
||||||
|
const desp_tot = (tables.despesas || []).reduce((s, r) => s + (r[2] || 0), 0);
|
||||||
|
const sang_tot = (tables.sangrias || []).reduce((s, r) => s + (r[1] || 0), 0);
|
||||||
|
const pixcnpj_tot = (tables.pixcnpj || []).reduce((s, r) => s + (r[1] || 0), 0);
|
||||||
|
const recv_tot = (tables.receber || []).reduce((s, r) => s + (r[1] || 0), 0);
|
||||||
|
const canc_tot = (tables.cancelamentos || []).reduce((s, r) => s + (r[1] || 0), 0);
|
||||||
|
|
||||||
|
// Monta estruturas de volta
|
||||||
|
const cartoes = {
|
||||||
|
credito: (tables.credito || []).map(r => r[0]),
|
||||||
|
debito: (tables.debito || []).map(r => r[0]),
|
||||||
|
alimentacao: (tables.alimentacao || []).map(r => r[0]),
|
||||||
|
pix: (tables.pix || []).map(r => r[0]),
|
||||||
|
};
|
||||||
|
|
||||||
|
const vales = (tables.vales || []).map(r => ({ nome: r[0], valor: r[1], obs: r[2]||'' }));
|
||||||
|
const despesas = (tables.despesas || []).map(r => ({ desc: r[0], obs: r[1]||'', valor: r[2] }));
|
||||||
|
const sangrias = (tables.sangrias || []).map(r => ({ hora: r[0], retirada: r[1], gerente: r[2]||'' }));
|
||||||
|
const cancelamentos = (tables.cancelamentos || []).map(r => ({ numero: r[0], valor: r[1], motivo: r[2]||'' }));
|
||||||
|
const pixcnpj = (tables.pixcnpj || []).map(r => ({ nome: r[0], valor: r[1] }));
|
||||||
|
const receber = (tables.receber || []).map(r => ({ nome: r[0], valor: r[1] }));
|
||||||
|
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const operador = estado.operador || full.operador || '';
|
||||||
|
|
||||||
|
const updates = {
|
||||||
|
// Identificação
|
||||||
|
loja: inp('edit-loja'),
|
||||||
|
data: inp('edit-data'),
|
||||||
|
turno: inp('edit-turno'),
|
||||||
|
operador: inp('edit-operador'),
|
||||||
|
|
||||||
|
// Cartões (como arrays de números crus)
|
||||||
|
cartoes_credito: cartoes.credito,
|
||||||
|
cartoes_debito: cartoes.debito,
|
||||||
|
cartoes_alimentacao: cartoes.alimentacao,
|
||||||
|
cartoes_pix: cartoes.pix,
|
||||||
|
|
||||||
|
// Totais de cartões
|
||||||
|
total_cartao_credito: cartCred_tot,
|
||||||
|
total_cartao_debito: cartDeb_tot,
|
||||||
|
total_cartao_alimentacao: cartAli_tot,
|
||||||
|
total_cartao_pix: cartPix_tot,
|
||||||
|
|
||||||
|
// Saldo de caixa (editável via tabela saldo)
|
||||||
|
saldo_troco: p(inp('edit-troco')),
|
||||||
|
saldo_credito: p(inp('edit-sld-credito')),
|
||||||
|
saldo_debito: p(inp('edit-sld-debito')),
|
||||||
|
saldo_alimentacao: p(inp('edit-sld-alimentacao')),
|
||||||
|
saldo_vales: p(inp('edit-sld-vales')),
|
||||||
|
total_pixcnpj: p(inp('edit-sld-pixcnpj')),
|
||||||
|
saldo_areceber: p(inp('edit-sld-areceber')),
|
||||||
|
|
||||||
|
// Totais
|
||||||
|
total_vales: vales_tot,
|
||||||
|
total_despesas: desp_tot,
|
||||||
|
total_sangrias: sang_tot,
|
||||||
|
total_areceber: recv_tot,
|
||||||
|
total_cancelamentos: canc_tot,
|
||||||
|
|
||||||
|
// Lançamentos detalhados
|
||||||
|
vales: vales,
|
||||||
|
despesas: despesas,
|
||||||
|
sangrias: sangrias,
|
||||||
|
cancelamentos: cancelamentos,
|
||||||
|
pixcnpj: pixcnpj,
|
||||||
|
receber: receber,
|
||||||
|
|
||||||
|
// Contadores
|
||||||
|
clientes: parseInt(inp('edit-clientes') || '0'),
|
||||||
|
frango: parseInt(inp('edit-frango') || '0'),
|
||||||
|
vendas: p(inp('edit-vendas')),
|
||||||
|
|
||||||
|
// Meta
|
||||||
|
saldo_esperado: p(inp('edit-esperado')),
|
||||||
|
observacoes: inp('edit-obs'),
|
||||||
|
|
||||||
|
// Edit log
|
||||||
|
edited_at: now,
|
||||||
|
edited_by: operador,
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasTauri = !!(window.__TAURI__ && window.__TAURI__.core);
|
||||||
|
if (!hasTauri) { alert('Tauri não disponível.'); return; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
const id = inp('edit-id') || full.id;
|
||||||
|
if (!id) { alert('ID do registro não encontrado.'); return; }
|
||||||
|
|
||||||
|
await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id, updates });
|
||||||
|
closeEditModal();
|
||||||
|
closeRelatorioModal();
|
||||||
|
alert('✅ Atualizado com sucesso!');
|
||||||
|
} catch(e) {
|
||||||
|
console.error('Erro ao salvar:', e);
|
||||||
|
alert('Erro ao salvar: ' + (e?.message || e));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Salva edições de volta ao Supabase
|
// Salva edições de volta ao Supabase
|
||||||
@@ -2567,6 +2975,7 @@ window.salvarEdicaoConsulta = async function() {
|
|||||||
total_despesas: p(inp('edit-despesas')),
|
total_despesas: p(inp('edit-despesas')),
|
||||||
clientes: parseInt(inp('edit-clientes') || '0'),
|
clientes: parseInt(inp('edit-clientes') || '0'),
|
||||||
frango: parseInt(inp('edit-frango') || '0'),
|
frango: parseInt(inp('edit-frango') || '0'),
|
||||||
|
vendas: p(inp('edit-vendas')),
|
||||||
saldo_esperado: p(inp('edit-esperado')),
|
saldo_esperado: p(inp('edit-esperado')),
|
||||||
observacoes: inp('edit-obs')
|
observacoes: inp('edit-obs')
|
||||||
};
|
};
|
||||||
@@ -2679,6 +3088,7 @@ function consultaToPrintData(full) {
|
|||||||
observacoes: full.observacoes || '',
|
observacoes: full.observacoes || '',
|
||||||
clientes: full.clientes || 0,
|
clientes: full.clientes || 0,
|
||||||
frango: full.frango || 0,
|
frango: full.frango || 0,
|
||||||
|
vendas: dados.vendas ?? full.vendas ?? 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user