feat: password recovery by e-mail, team alerts, and a price for files opened by hand
Pilot customers had no way to reset a forgotten password, and the 7 October meeting asked for two things that only needed the client's inputs to go live. Password recovery: "Esqueci minha senha" in Minha conta sends a link that works once, for an hour (/conta/redefinir#token, in the fragment so it never reaches a server or a Referer). Only the token's hash is stored, the e-mail's text is erased once sent, the answer never says whether an account exists, and a reset signs out every other session. Limited per address and source. Team alerts: Kanban users who tick "Receber alertas por e-mail" in Usuários get one when an order is paid, a cart waits for review, or a payment needs attention. Messages are queued in the transaction that caused them and sent by the worker with retries (app/mail.py). Integrações shows an E-mail row with "Enviar teste". E-mail is off in production (MAIL_ADAPTER=off; recovery keeps offering WhatsApp) until the client's SMTP account exists; then it is only settings (docs/PORTAINER.md). The local stack keeps messages in the database and log. Files opened by hand: a finished sheet in CDR, AI, PSD or TIFF (or with a length the customer typed) pays the full price plus MANUAL_FILE_EXTRA_CENTS per metre, to steer customers to PNG as the meeting asked. It is 0 until Marcus gives the amount. The Site shows it before checkout, the server charges it, Tiny gets it in the unit price, and the Kanban says it. Tested: new tests/mail_test (reset flow, SMTP delivery against a local SMTP server, retry, who gets alerts), pricing unit tests, and the browser test now checks the Site total equals the server's, run with the charge at 0 and at R$ 5,00. The full CI suite passes in a CI-style stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,14 @@
|
||||
window.dtfUploadMaxBytes=session.max_upload_bytes;
|
||||
const limit=document.getElementById('zLimite');
|
||||
if(limit)limit.textContent='Até '+(session.max_upload_bytes/1073741824).toFixed(0)+' GB por arquivo.';
|
||||
if(session.manual_extra_cents>0){
|
||||
TAXA_MANUAL=session.manual_extra_cents/100;
|
||||
const zona=document.getElementById('zManual');
|
||||
if(zona)zona.innerHTML='Tem <b>CDR, AI, PSD ou TIFF</b>? Pode mandar também. Alguém abre na mão: '+
|
||||
'o metro sai pelo preço cheio, mais '+rs(TAXA_MANUAL)+'.';
|
||||
if(typeof folhas!=='undefined'&&folhas.length&&typeof pintaFolha==='function')pintaFolha();
|
||||
if(typeof itemAtual!=='undefined'&&itemAtual&&typeof carrinho==='function')carrinho();
|
||||
}
|
||||
}).catch(()=>{});
|
||||
window.dtfSessionReady=ready;
|
||||
window.dtfApi=api;
|
||||
|
||||
@@ -884,7 +884,7 @@ function itemCard(order,item,index){
|
||||
const spec=item.production;
|
||||
const title=node('div',undefined,'title');title.append(node('b',PRODUCT[item.mode]),gradePill(item.grade),node('span',metres(item.billed_metres),'mono'));
|
||||
body.append(title,facts([['Folha',sheetSize(spec)],['Peças',spec?String(spec.placements.length):null],
|
||||
['Metro',item.unit_cents?money(item.unit_cents):null],['Arquivos',spec&&spec.sources.length>1?String(spec.sources.length):null]]));
|
||||
['Metro',item.unit_cents?money(item.unit_cents)+manualExtra(item):null],['Arquivos',spec&&spec.sources.length>1?String(spec.sources.length):null]]));
|
||||
if(item.quality_status==='warning')body.append(badge('! Ressalva de resolução aceita','warn'));
|
||||
// After a customer correction, that file is the artwork: the generated
|
||||
// print file, or the reason it could not be made, no longer applies.
|
||||
@@ -991,7 +991,7 @@ function renderUsers(){
|
||||
const machineName=id=>machines.find(m=>m.id===id)?.name||'—';
|
||||
const rows=users.map(u=>{
|
||||
const tr=node('tr');if(!u.active)tr.classList.add('off');
|
||||
const who=node('td');who.append(node('b',u.name||u.email),node('span',u.email,'faint block'));
|
||||
const who=node('td');who.append(node('b',u.name||u.email),node('span',u.email+(u.alerts?' · recebe alertas':''),'faint block'));
|
||||
const machinesTd=node('td',u.machines.length?u.machines.map(machineName).join(', '):(u.role==='operador'?'Todas':'—'));
|
||||
const seen=node('td',u.last_login_at?when(u.last_login_at):'nunca entrou','faint');
|
||||
const actions=node('td',undefined,'actions');
|
||||
@@ -1037,14 +1037,16 @@ function userForm(u){
|
||||
pass.required=!editing;pass.placeholder=editing?'Deixe em branco para manter':'12 caracteres ou mais';
|
||||
const active=node('input');active.type='checkbox';active.checked=u?u.active:true;active.disabled=u?.email===ME.email;
|
||||
const activeLabel=node('label',undefined,'check');activeLabel.append(active,'Ativo (pode entrar no Kanban)');
|
||||
const alerts=node('input');alerts.type='checkbox';alerts.checked=!!u?.alerts;
|
||||
const alertsLabel=node('label',undefined,'check');alertsLabel.append(alerts,'Receber alertas por e-mail (pedido pago, cotação para revisar, pagamento com problema)');
|
||||
const boxes=usersData.machines.map(m=>{const c=node('input');c.type='checkbox';c.value=m.id;c.checked=!!u?.machines.includes(m.id);
|
||||
const l=node('label',undefined,'check');l.append(c,m.name);return l;});
|
||||
const machinesField=node('div',undefined,'mfield');
|
||||
machinesField.append('Máquinas (só para operadores; nenhuma = todas)',...(boxes.length?boxes:[node('span','Nenhuma máquina cadastrada.','faint')]));
|
||||
const syncMachines=()=>{machinesField.hidden=role.value!=='operador';};role.onchange=syncMachines;syncMachines();
|
||||
dialog(editing?'Editar usuário':'Novo usuário',[field('Nome',name),field('E-mail',email),field('Perfil',role),
|
||||
field(editing?'Nova senha':'Senha inicial',pass),machinesField,activeLabel],async()=>{
|
||||
const body={name:name.value,email:email.value,role:role.value==='superadmin'?'admin':role.value,active:active.checked,
|
||||
field(editing?'Nova senha':'Senha inicial',pass),machinesField,activeLabel,alertsLabel],async()=>{
|
||||
const body={name:name.value,email:email.value,role:role.value==='superadmin'?'admin':role.value,active:active.checked,alerts:alerts.checked,
|
||||
machines:role.value==='operador'?boxes.map(l=>l.querySelector('input')).filter(c=>c.checked).map(c=>c.value):[],
|
||||
password:pass.value||null};
|
||||
await api(editing?'/users/'+u.id:'/users',body);
|
||||
@@ -1311,7 +1313,7 @@ function quoteItem(item,fields,priced){
|
||||
const title=node('div',undefined,'title');
|
||||
title.append(node('b',PRODUCT[item.mode]),gradePill(item.grade),...(priced?[node('span',money(priced.total_cents),'mono')]:[]));
|
||||
body.append(title,facts([['Folha',sheetSize(spec)],['Cobrado',priced?metres(priced.billed_metres):null],
|
||||
['Metro',priced?money(priced.unit_cents):null],['Peças',spec?String(spec.placements.length):null],
|
||||
['Metro',priced?money(priced.unit_cents)+manualExtra(priced):null],['Peças',spec?String(spec.placements.length):null],
|
||||
['Arquivos',spec?String(spec.sources.length):null]]));
|
||||
const chips=node('div',undefined,'flags');
|
||||
chips.append(item.quality_status==='ok'?badge('✓ Qualidade conferida','ok'):item.quality_status==='warning'?
|
||||
@@ -1330,6 +1332,9 @@ function quoteItem(item,fields,priced){
|
||||
body.append(buttons);box.append(preview,body);return box;
|
||||
}
|
||||
|
||||
// A finished sheet someone opens by hand pays this per metre on top (app/core/pricing.py).
|
||||
const manualExtra=item=>item?.manual_extra_cents?' (com '+money(item.manual_extra_cents)+' de arquivo manual)':'';
|
||||
|
||||
// ---- Payments and integrations ------------------------------------------
|
||||
|
||||
const tinyResult=new URLSearchParams(location.search).get('tiny');
|
||||
@@ -1561,6 +1566,7 @@ function renderIntegrations(){
|
||||
node('p',fr.box_cm?'A Jadlog cobra o maior entre o peso real e o cubado.':'Sem a caixa, a cotação usa só o peso real.')]})
|
||||
: integration({name:'Frete',state:'Não configurado',tone:'off',summary:'Somente retirada.'}));
|
||||
rows.push(integration({name:'WhatsApp',state:'Não configurado',tone:'off',summary:'Mensagens registradas, sem envio.'}));
|
||||
rows.push(mailRow(board.providers?.mail||{}));
|
||||
const bk=board.providers?.backup||{};
|
||||
const ontem=bk.last_ok&&Date.now()-new Date(bk.last_ok)<26*3600e3;
|
||||
const tam=bk.bytes?(bk.bytes<1048576?Math.max(1,Math.round(bk.bytes/1024))+' KB':(bk.bytes/1048576).toFixed(1).replace('.',',')+' MB'):'';
|
||||
@@ -1573,6 +1579,23 @@ function renderIntegrations(){
|
||||
$('integrations').replaceChildren(...rows);
|
||||
eventFilters();
|
||||
}
|
||||
// E-mail: customers' password recovery and the team's alerts (app/mail.py).
|
||||
function mailRow(m){
|
||||
const name='E-mail';
|
||||
if(m.adapter!=='smtp'&&m.adapter!=='log')return integration({name,state:'Não configurado',tone:'off',
|
||||
summary:'Sem recuperação de senha por e-mail: o cliente é orientado a chamar no WhatsApp.'});
|
||||
const local=m.adapter==='log';
|
||||
const who=m.alerts?m.alerts+(m.alerts>1?' pessoas recebem':' pessoa recebe')+' os alertas':'ninguém recebe os alertas ainda';
|
||||
return integration({name,state:m.error?'Verificar':local?'Só registro':'Ativo',tone:m.error?'warn':local?'off':'ok',
|
||||
summary:m.error?'Falhou o envio para '+m.error.to+': '+m.error.error:'Recuperação de senha e alertas · '+who+'.',
|
||||
actions:[button('Enviar teste',async()=>{const r=await api('/mail/test',{});
|
||||
say(local?'Teste registrado. Neste ambiente os e-mails ficam só no registro do servidor.':'Teste enviado para '+r.to+'. Confira a caixa de entrada (e o spam).');})],
|
||||
details:[...(local?[node('p','Ambiente local: os e-mails não saem do servidor, ficam no registro do worker.')]:[]),
|
||||
['Remetente',m.from||'—'],...(m.host?[['Servidor',m.host]]:[]),
|
||||
['Último envio',m.last_sent?when(m.last_sent):'Nenhum ainda'],['Na fila',String(m.pending||0)],
|
||||
...(m.error?[['Último erro',when(m.error.at)+' · '+m.error.error]]:[]),
|
||||
node('p','Quem recebe os alertas se escolhe em Usuários → Editar → “Receber alertas por e-mail”.')]});
|
||||
}
|
||||
function mercadoPagoCheck(r){
|
||||
const w=r.webhooks||{};
|
||||
return [['Credencial',r.token==='test'?'De teste':'De produção'],
|
||||
|
||||
@@ -42,7 +42,18 @@
|
||||
<input id="password" type="password" autocomplete="current-password" required>
|
||||
<button class="bPri">Entrar</button>
|
||||
<button type="button" class="bLink" id="esqueci">Esqueci minha senha</button>
|
||||
<p class="nota2" id="esqueciTx" hidden>A recuperação por e-mail chega em breve. Enquanto isso, fale com a Dropstar pelo WhatsApp <a href="https://wa.me/message/NJ76CLIOUGXLB1" target="_blank" rel="noopener">16 99428-0056</a>.</p>
|
||||
</form>
|
||||
<!-- Takes the place of "Entrar" while open. -->
|
||||
<form class="bloco" id="fEsqueci" hidden>
|
||||
<h2>Esqueci minha senha</h2>
|
||||
<div id="esqueciMailBox">
|
||||
<p class="nota2">Informe o e-mail da sua conta. Enviamos um link para você criar uma nova senha.</p>
|
||||
<label for="esqueciMail">E-mail</label>
|
||||
<input id="esqueciMail" type="email" autocomplete="username" required>
|
||||
<button class="bPri" id="esqueciEnviar">Enviar link</button>
|
||||
</div>
|
||||
<p class="nota2" id="esqueciZap" hidden>Fale com a Dropstar pelo WhatsApp <a href="https://wa.me/message/NJ76CLIOUGXLB1" target="_blank" rel="noopener">16 99428-0056</a> para criar uma nova senha.</p>
|
||||
<button type="button" class="bLink" id="voltarEntrar">Voltar para entrar</button>
|
||||
</form>
|
||||
<form class="bloco" id="register">
|
||||
<h2>Criar conta</h2>
|
||||
@@ -60,6 +71,22 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- /conta/redefinir#<link do e-mail> -->
|
||||
<section class="acesso" id="redefinir" hidden aria-labelledby="tRedefinir">
|
||||
<h1 id="tRedefinir">Criar nova senha</h1>
|
||||
<div class="acessoGrid">
|
||||
<form class="bloco" id="fRedefinir">
|
||||
<h2>Nova senha</h2>
|
||||
<p class="nota2">Depois de salvar, você já entra na sua conta.</p>
|
||||
<label for="rNova">Nova senha <span class="obs">12 caracteres ou mais</span></label>
|
||||
<input id="rNova" type="password" minlength="12" maxlength="128" autocomplete="new-password" required>
|
||||
<label for="rRepete">Repita a nova senha</label>
|
||||
<input id="rRepete" type="password" minlength="12" maxlength="128" autocomplete="new-password" required>
|
||||
<button class="bPri">Salvar e entrar</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- /conta, /conta/pedidos, /conta/dados -->
|
||||
<div class="area" id="area" hidden>
|
||||
<nav class="lateral" aria-label="Minha conta">
|
||||
|
||||
@@ -42,6 +42,7 @@ function forgetCheckout(){for(const k of ['dtf-quote','dtf-request-key','dtf-req
|
||||
function vista(){
|
||||
const p=location.pathname.replace(/\/+$/,'');
|
||||
if(p==='/conta/entrar') return 'entrar';
|
||||
if(p==='/conta/redefinir') return 'redefinir';
|
||||
if(p==='/conta/dados') return 'dados';
|
||||
if(p==='/conta') return 'geral';
|
||||
return 'pedidos'; // /conta/pedidos, and the old /portal.html
|
||||
@@ -61,12 +62,14 @@ async function mostra(){
|
||||
if((v==='geral'||v==='dados')&&!conta){history.replaceState({},'','/conta/entrar?next='+encodeURIComponent(location.pathname));return mostra();}
|
||||
if(v==='entrar'&&conta){history.replaceState({},'',proximo&&/^\/conta(\/[a-z]+)?$/.test(proximo)?proximo:'/conta');return mostra();}
|
||||
$('auth').hidden=v!=='entrar';
|
||||
$('area').hidden=v==='entrar';
|
||||
$('redefinir').hidden=v!=='redefinir';
|
||||
$('area').hidden=v==='entrar'||v==='redefinir';
|
||||
if(v==='redefinir'&&!resetToken)aviso('Este link está incompleto. Peça outro em “Esqueci minha senha”.',true);
|
||||
$('vGeral').hidden=v!=='geral';$('vPedidos').hidden=v!=='pedidos';$('vDados').hidden=v!=='dados';
|
||||
for(const a of document.querySelectorAll('.lateral a'))a.classList.toggle('on',a.dataset.view===v);
|
||||
for(const a of document.querySelectorAll('.lateral [data-conta]'))a.hidden=!conta;
|
||||
$('navEntrar').hidden=!!conta;$('logout').hidden=!conta;
|
||||
document.title=({entrar:'Entrar',geral:'Minha conta',pedidos:'Pedidos',dados:'Dados da conta'})[v]+' · DTF Dropstar';
|
||||
document.title=({entrar:'Entrar',redefinir:'Criar nova senha',geral:'Minha conta',pedidos:'Pedidos',dados:'Dados da conta'})[v]+' · DTF Dropstar';
|
||||
if(v==='geral')await geral();
|
||||
else if(v==='pedidos')await pedidos();
|
||||
else if(v==='dados')dados();
|
||||
@@ -328,23 +331,51 @@ async function migrateGuestCart(previous,next){
|
||||
await new Promise((resolve,reject)=>{const tx=database.transaction('cart','readwrite'),store=tx.objectStore('cart'),req=store.get(previous);req.onsuccess=()=>{if(req.result){store.put(req.result,next);store.delete(previous);}};tx.oncomplete=resolve;tx.onerror=()=>reject(tx.error);});
|
||||
database.close();
|
||||
}
|
||||
async function authenticate(path,body){
|
||||
async function authenticate(path,body,destino){
|
||||
const previous=scope,guest=!conta;
|
||||
const r=await api(path,body);forgetCheckout();
|
||||
const next=(await api('/session')).cart_scope;scope=next;
|
||||
if(guest)try{await migrateGuestCart(previous,next);}catch{aviso('Não foi possível transferir o carrinho salvo neste navegador.',true);}
|
||||
conta=r.customer;$('quem').textContent=conta.mail;
|
||||
$('password').value='';$('register-password').value='';
|
||||
if(destino)history.replaceState({},'',destino);
|
||||
await mostra();
|
||||
}
|
||||
$('login').onsubmit=async event=>{event.preventDefault();try{await authenticate('/account/login',{email:$('email').value,password:$('password').value});}catch(e){aviso(e.message,true);}};
|
||||
$('register').onsubmit=async event=>{event.preventDefault();try{await authenticate('/account/register',{customer:{cnpj:$('cnpj').value,zap:$('phone').value,mail:$('register-email').value},password:$('register-password').value});}catch(e){aviso(e.status===422?'Confira o CNPJ, o WhatsApp e o e-mail. A senha precisa ter 12 caracteres ou mais.':e.message,true);}};
|
||||
$('esqueci').onclick=()=>{$('esqueciTx').hidden=!$('esqueciTx').hidden;};
|
||||
// Password recovery: a link by e-mail when the server sends e-mail,
|
||||
// otherwise the WhatsApp. The link arrives in the address's fragment.
|
||||
let recovery=false, resetToken='';
|
||||
if(location.pathname.replace(/\/+$/,'')==='/conta/redefinir'&&location.hash.length>1){
|
||||
resetToken=location.hash.slice(1);history.replaceState({},'','/conta/redefinir');
|
||||
}
|
||||
function esqueci(abrir){
|
||||
$('login').hidden=abrir;$('fEsqueci').hidden=!abrir;
|
||||
$('esqueciMailBox').hidden=!recovery;$('esqueciZap').hidden=recovery;
|
||||
if(abrir){$('esqueciMail').value=$('email').value;(recovery?$('esqueciMail'):$('voltarEntrar')).focus();}
|
||||
else $('email').focus();
|
||||
}
|
||||
$('esqueci').onclick=()=>esqueci(true);
|
||||
$('voltarEntrar').onclick=()=>{aviso('');esqueci(false);};
|
||||
$('fEsqueci').onsubmit=async event=>{
|
||||
event.preventDefault();$('esqueciEnviar').disabled=true;
|
||||
try{const r=await api('/account/forgot',{email:$('esqueciMail').value});aviso(r.message);}
|
||||
catch(e){aviso(e.status===422?'Confira o e-mail.':e.message,true);}
|
||||
finally{$('esqueciEnviar').disabled=false;}
|
||||
};
|
||||
$('fRedefinir').onsubmit=async event=>{
|
||||
event.preventDefault();
|
||||
if($('rNova').value!==$('rRepete').value){aviso('A nova senha e a repetição não conferem.',true);return;}
|
||||
try{await authenticate('/account/reset',{token:resetToken,password:$('rNova').value},'/conta');
|
||||
resetToken='';$('rNova').value='';$('rRepete').value='';aviso('Senha criada. Você já está na sua conta.');}
|
||||
catch(e){aviso(e.status===422?(resetToken?'A nova senha precisa ter 12 caracteres ou mais.':'Este link está incompleto. Peça outro em “Esqueci minha senha”.'):e.message,true);}
|
||||
};
|
||||
$('logout').onclick=async()=>{try{await window.dtfForgetPrivateData();await api('/account/logout',{});location.assign('/conta/entrar');}catch(error){aviso('Não foi possível limpar os dados deste navegador. Feche as abas do Site e limpe os dados do site nas configurações do navegador.',true);}};
|
||||
|
||||
(async()=>{
|
||||
try{
|
||||
const session=await api('/session');scope=session.cart_scope;environment=session.environment;
|
||||
recovery=!!session.password_recovery;
|
||||
$('dev-notice').hidden=environment!=='local';
|
||||
conta=(await api('/account/me')).customer;
|
||||
if(conta)$('quem').textContent=conta.mail;
|
||||
|
||||
@@ -58,7 +58,7 @@ function pintaPedido(){
|
||||
const soma = itens + frete;
|
||||
const n = aPagar.length, noCarrinho = pedido.length + (itemAtual?1:0);
|
||||
const eco = aPagar
|
||||
.reduce((t,it)=>t+(TABELA[it.modo]-it.unit)*it.cob, 0);
|
||||
.reduce((t,it)=>t+(TABELA[it.modo]-(it.unit-(it.extra||0)))*it.cob, 0);
|
||||
$('resLin').innerHTML =
|
||||
'<div class="l"><span>'+n+(n===1?' item':' itens')+'</span><b>'+rs(itens+eco)+'</b></div>'+
|
||||
(eco>0.01? '<div class="l" style="color:var(--verde-ml)"><span>Desconto pela nota</span>'+
|
||||
@@ -82,7 +82,8 @@ function pintaPedido(){
|
||||
|
||||
function carrinho(){
|
||||
const base=precoBase(nota), cob=cobrar(metros);
|
||||
const unit=base, tot=cob*unit, sobra=+(cob-metros).toFixed(2);
|
||||
const extra=folhaManual()? TAXA_MANUAL : 0;
|
||||
const unit=base+extra, tot=cob*unit, sobra=+(cob-metros).toFixed(2);
|
||||
$('carr').classList.add('on');
|
||||
let l='<div class="l"><span>'+MODOS[modo].tit+'</span><b>'+rs(base)+'/m</b></div>';
|
||||
{
|
||||
@@ -94,6 +95,7 @@ function carrinho(){
|
||||
}
|
||||
if(!ehFolha()) l += '<div class="l" style="color:#8D9AB0"><span>Montagem da folha</span>'+
|
||||
'<b>inclusa · '+rs(MONTAGEM[modo])+'/m</b></div>';
|
||||
if(extra) l += '<div class="l"><span>Arquivo aberto na mão</span><b>+'+rs(extra)+'/m</b></div>';
|
||||
l += '<div class="l"><span>Metragem'+(sobra>0.001?' · arredondada para 10 cm':'')+
|
||||
'</span><b>'+fmtM(cob)+' m</b></div>';
|
||||
l += '<div class="l"><span>Preço final do metro</span><b>'+rs(unit)+'</b></div>'+
|
||||
@@ -124,7 +126,7 @@ function carrinho(){
|
||||
if(!montagemLayout) return;
|
||||
layout=montagemLayout;
|
||||
}
|
||||
itemAtual={modo, tit:MODOS[modo].tit, nota, metros, cob, unit, total:tot,
|
||||
itemAtual={modo, tit:MODOS[modo].tit, nota, metros, cob, unit, extra, total:tot,
|
||||
localFiles:(ehFolha()?folhas:artes).map(x=>x.f),
|
||||
mini:(ehFolha()?folhas:artes).map(x=>x.miniSrc).find(Boolean)||null,
|
||||
fotos:(ehFolha()?folhas:artes).map(x=>x.fotoSrc||null),
|
||||
@@ -138,7 +140,7 @@ function carrinho(){
|
||||
pintaPedido();
|
||||
previa();
|
||||
if(nota<90){
|
||||
const piso=pisoEscada(), ganho=(base-piso)*cob;
|
||||
const piso=pisoEscada(), ganho=(unit-piso)*cob;
|
||||
if(ganho>0.5) qm('<b>Dá para pagar menos.</b> Com a arte em 300 DPI, '+
|
||||
'o metro cai para '+rs(piso)+' — são '+rs(ganho)+' a menos neste pedido.','var(--verde)');
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
(min? min*3+'+'+(i? '' : ' DPI') : semNota? 'cheio' : 'menos')+'</span>'+
|
||||
'<b>'+rs(v).slice(3)+'</b></li>').join('');
|
||||
const analisadas=ehFolha(it.modo) && folhas.length && folhas.every(x=>x.an);
|
||||
$('cMetroLbl').textContent = semNota ? 'Metro · preço cheio'
|
||||
$('cMetroLbl').textContent = it.extra ? 'Metro · cheio + '+rs(it.extra)+' manual'
|
||||
: semNota ? 'Metro · preço cheio'
|
||||
: analisadas && folhas.every(x=>x.an.vetor) ? 'Metro · arte vetorial'
|
||||
: analisadas ? 'Metro · '+Math.min(...folhas.map(x=>x.an.dpi))+' DPI'
|
||||
: 'Metro';
|
||||
$('cMetro').textContent=rs(it.unit);
|
||||
$('cMetragem').textContent=fmtM(it.cob)+' m';
|
||||
const economia=(TABELA[it.modo]-it.unit)*it.cob;
|
||||
const economia=(TABELA[it.modo]-(it.unit-(it.extra||0)))*it.cob;
|
||||
$('cEco').textContent = economia>0.005 ? rs(economia)+' a menos pela resolução da arte' : '';
|
||||
const partes=ehFolha(it.modo) ? Math.ceil(it.metros/20) : 1;
|
||||
$('cPartes').textContent = partes>1 ? ' Sai em '+partes+' partes de até 20 m.' : '';
|
||||
|
||||
@@ -55,6 +55,10 @@ const FAIXAS={
|
||||
};
|
||||
const TABELA={file:19.90, avulsa:29.90, uvfile:85.90, uv:99.90}; // teto de cada escada
|
||||
const MONTAGEM={avulsa:10.00, uv:14.00}; // o que a montagem soma sobre a folha pronta
|
||||
// Folha que alguém abre na mão (CDR, AI, PSD, TIFF): R$ a mais por metro.
|
||||
// Vem do servidor (/api/session), que cobra o mesmo; zero não soma nada.
|
||||
let TAXA_MANUAL=0;
|
||||
const folhaManual=()=>ehFolha() && folhas.some(x=>!x.med);
|
||||
const ehFolha=m=>!!MODOS[m||modo].folha;
|
||||
const pisoEscada=m=>FAIXAS[m||modo][0][1];
|
||||
const MINIMO_M=1, GAP_CM=0.5, RODAPE_CM=5;
|
||||
|
||||
@@ -438,10 +438,11 @@ function pintaFolha(){
|
||||
'<p class="avisoF"><b>Este PDF não pode ser orçado.</b> '+escapeHTML(x.measurementError)+'</p>';
|
||||
}else{
|
||||
const teto=TABELA[modo], piso=pisoEscada();
|
||||
const dif=(x.m>0)? (teto-piso)*cobrar(x.m*(x.rep||1)) : 0;
|
||||
const dif=(x.m>0)? (teto+TAXA_MANUAL-piso)*cobrar(x.m*(x.rep||1)) : 0;
|
||||
medida='<span class="chipSo">Conferência manual · preço cheio</span>'+
|
||||
'<p class="repTxt">O navegador não abre '+escapeHTML(extDe(x.f.name))+', então alguém da equipe '+
|
||||
'confere antes de imprimir e o metro sai pela tabela, <b>'+rs(teto)+'</b>. '+
|
||||
'confere antes de imprimir e o metro sai pela tabela, <b>'+rs(teto)+'</b>'+
|
||||
(TAXA_MANUAL? ', mais <b>'+rs(TAXA_MANUAL)+'</b> pela abertura manual' : '')+'. '+
|
||||
'Exportando em <b>PNG ou PDF</b>, o metro pode cair até <b>'+rs(piso)+'</b>'+
|
||||
(dif>0.5? ' — <b>'+rs(dif)+' a menos</b> só nesta folha' : '')+'.</p>';
|
||||
manual='<div class="campo"><label for="comp'+i+'">Comprimento</label>'+
|
||||
|
||||
@@ -264,6 +264,8 @@ section+section{border-top:0}
|
||||
#ampliaArea .folhaPilha img{display:block;width:auto;max-width:100%;height:auto;max-height:calc(100vh - 180px)!important}
|
||||
#ampliaArea figcaption{padding:8px 12px;font-size:15px;color:var(--texto2);border-top:1px solid var(--linha)}
|
||||
.cLin{display:flex;align-items:baseline;gap:8px}
|
||||
/* A price never breaks across lines; a long label wraps instead. */
|
||||
.cLin>b{white-space:nowrap}
|
||||
.cLin>span:last-child,.cLin>b{margin-left:auto;display:flex;gap:8px;align-items:baseline}
|
||||
.cLin s{font-size:15px;color:#707070}
|
||||
.cObs{margin:-4px 0 0;font-size:15px;color:var(--verde)}
|
||||
|
||||
Reference in New Issue
Block a user