Merge main into sentry

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-11 14:48:01 -03:00
31 changed files with 711 additions and 137 deletions

View File

@@ -27,7 +27,7 @@
stroke:item.strokeClass||null,strokeChoice:item.strokeChoice||null,
sheets:(item.partes||[]).map(part=>part.production),
files:(item.localFiles||[]).map(file=>({name:file.name,size:file.size,lastModified:file.lastModified}))
})),treatment:!!$('fTratamento')?.checked,coupon:cupomCode()});
})),treatment:ajusteSnapshot(),coupon:cupomCode()});
}
// The quote this browser is paying, forgotten. clearDraft also empties the
// payment area; forgetDraft leaves on screen what is there (a confirmation).
@@ -87,9 +87,11 @@
// The art grade rules (front 8.5): the Site uses only the treatment rule,
// forcing the checkbox when the cart's worst grade is below it.
window.dtfGradeRules=session.grade_rules||{};
// Treatment by the designer (front 5): only offered when TREATMENT_CENTS
// is set; the server adds the same amount and the 24 h to the quote.
// Ajuste Fino (front 1a): per art, with a band by the order's number of
// arts. Only offered when TREATMENT_CENTS is set; the server adds the
// same amount and the 24 h to the quote.
TAXA_TRATAMENTO=(session.treatment_cents||0)/100;
FAIXAS.tratamento=session.treatment_bands||[];
const tratamentoBox=document.getElementById('tratamentoBox');
if(tratamentoBox){
tratamentoBox.hidden=!(TAXA_TRATAMENTO>0);
@@ -123,6 +125,7 @@
}
window.dtfProducts=session.products;
if(typeof folhas!=='undefined'&&folhas.length&&typeof pintaFolha==='function')pintaFolha();
if(typeof artes!=='undefined'&&artes.length&&typeof pintaArtes==='function')pintaArtes();
if(typeof itemAtual!=='undefined'&&itemAtual&&typeof carrinho==='function')carrinho();
if(typeof pintaTipoEnvio==='function')pintaTipoEnvio();
semPedidos=!Object.values(session.products).some(product=>product.enabled);
@@ -181,8 +184,11 @@
const prazo = approved.freight.days ? ' · até '+approved.freight.days+' dias úteis' : '';
rows.push(linha(pickup ? 'Retirada em Franca' : (approved.freight.description || 'Frete')+prazo,
approved.freight.total_cents ? rs(approved.freight.total_cents/100) : 'Grátis'));
if(quote.treatment?.cents)
rows.push(linha('Tratamento da arte pelo designer · +24 h', rs(quote.treatment.cents/100)));
if(quote.treatment?.cents){
const arts=Number(quote.treatment.arts)||0;
rows.push(linha('Ajuste Fino'+(arts?' · '+arts+(arts===1?' arte':' artes'):'')+' · +24 h',
rs(quote.treatment.cents/100)));
}
if(approved.coupon)
rows.push(linha('Cupom '+approved.coupon.code, '− '+rs(approved.coupon.discount_cents/100)));
rows.push(linha('Total', rs(approved.total_cents/100), 'tot'));
@@ -442,7 +448,9 @@
if (destination) content.destination = destination;
// "Quero aprovar uma prova antes de imprimir": the order waits for the customer.
if ($('fProva')?.checked) content.proof = true;
if ($('fTratamento')?.checked) content.treatment = true;
// Ajuste Fino: true for every art, or the [item, source] pairs chosen.
const treatment=tratamentoParaItens(sheets);
if (treatment) content.treatment = treatment;
if (cartSnapshot()!==initialCart) throw new Error('O carrinho mudou durante o envio. Confira os itens e envie de novo.');
// Browser timings for Números (item 0.12); they never affect the price.
const T=window.dtfTimings, timings={};

View File

@@ -1123,9 +1123,9 @@ h2 em{font-style:normal;color:var(--laranja)}
</div>
<div class="cxE" id="tratamentoBox" hidden>
<h4>Tratamento da arte</h4>
<h4>Ajuste Fino</h4>
<label class="provaOp"><input type="checkbox" id="fTratamento">
<span><b>Quero o tratamento pelo designer — <span id="tratamentoPreco"></span></b>
<span><b>Ajuste Fino em todas as artes — <span id="tratamentoPreco"></span> por arte</b>
O designer ajusta a arte para DTF, com fundo transparente e 300 DPI, e sobe o arquivo
pelo card. O prazo do pedido aumenta em 24 h.</span></label>
</div>

View File

@@ -10,7 +10,8 @@ const MONTAR_DPI_REFUSE=96, MONTAR_DPI_WARN=200;
const MONTAR_FILM_CM=57, MONTAR_GAP_CM=0.5;
const MONTAR={sizes:[],lines:[],seq:0,preview:null,timer:null,dirty:false,token:0,
layout:null,layoutTimer:null,layoutToken:0,layoutPending:false,creating:false,requestKey:null,
kind:null,internal:null,internalDirty:false,brands:new Map(),contactToken:0,contactTimer:null};
kind:null,internal:null,internalDirty:false,brands:new Map(),contactToken:0,contactTimer:null,
freights:null,freight:null,catalog:null};
const montarFolderReady=()=>!!FOLDER.handle&&!!FOLDER.granted;
const montarDpi=found=>found.width/(found.widthCm/2.54);
@@ -66,15 +67,138 @@ function montarPaintCustomer(){
}
const montarDelivery=()=>document.querySelector('input[name="montar-delivery"]:checked')?.value||'pickup';
function montarPaintDelivery(){
const withOrder=montarDelivery()==='with_order';
const delivery=montarDelivery(),withOrder=delivery==='with_order',ship=delivery==='ship';
$('montar-with-order').disabled=!withOrder;
if(!withOrder)$('montar-with-order').value='';
$('montar-shipping').hidden=!ship;
if(ship&&!$('montar-ship-recipient').value.trim())
$('montar-ship-recipient').value=$('montar-name').value.trim();
montarPaintFreights();
}
function montarWithOrder(){
if(MONTAR.kind!=='venda'||montarDelivery()!=='with_order')return null;
const value=Math.round(Number($('montar-with-order').value));
return Number.isInteger(value)&&value>=1&&value<=999999?value:null;
}
// ---- Envio (front 7a.4): the Site's own freight ---------------------------
// The Site's public routes for the CEP and the carrier quotes (app/api/health.py);
// the Kanban's api() helper only reaches /api/operator.
// The Site's UFS list (web/site-config.js), copied for the address select.
const MONTAR_UFS='AC AL AP AM BA CE DF ES GO MA MT MS MG PA PB PR PE PI RJ RN RS RO RR SC SP SE TO'.split(' ');
const montarCep=()=>$('montar-ship-cep').value.replace(/\D/g,'').slice(0,8);
function montarDestination(){
const destination={recipient:$('montar-ship-recipient').value.trim(),
street:$('montar-ship-street').value.trim(),number:$('montar-ship-number').value.trim(),
complement:$('montar-ship-complement').value.trim(),
district:$('montar-ship-district').value.trim(),city:$('montar-ship-city').value.trim(),
state:$('montar-ship-state').value.trim().toUpperCase(),postal_code:montarCep()};
const ok=destination.postal_code.length===8&&destination.recipient.length>=2&&
destination.street.length>=2&&destination.number.length>=1&&
destination.district.length>=2&&destination.city.length>=2&&MONTAR_UFS.includes(destination.state);
return ok?destination:null;
}
const montarShipReady=()=>montarDelivery()==='ship'&&!!montarDestination()&&
!!MONTAR.freight&&MONTAR.freight.postal_code===montarCep();
function montarResetFreight(){
MONTAR.freights=null;MONTAR.freight=null;
$('montar-freights').replaceChildren();$('montar-freights').hidden=true;
$('montar-freight-msg').textContent='';
}
async function montarPublic(path,options={}){
const response=await fetch('/api'+path,options);
const data=await response.json().catch(()=>({}));
if(!response.ok)throw new Error(typeof data.detail==='string'?data.detail:'Não foi possível agora ('+response.status+').');
return data;
}
async function montarCepLookup(){
const msg=$('montar-ship-msg'),cep=montarCep();
if(cep.length!==8){msg.textContent='Informe um CEP com oito dígitos.';return;}
msg.textContent='Buscando o endereço…';
try{
const address=await montarPublic('/cep/'+cep);
$('montar-ship-street').value=address.street||'';
$('montar-ship-district').value=address.district||'';
$('montar-ship-city').value=address.city||'';
if(MONTAR_UFS.includes(address.state))$('montar-ship-state').value=address.state;
if(!$('montar-ship-recipient').value.trim())$('montar-ship-recipient').value=$('montar-name').value.trim();
msg.textContent='';MONTAR.requestKey=null;montarPaintActions();
}catch(e){msg.textContent=e.message;}
}
// The item's packed metres and the table value of the items, as the server
// will price them: the band price of the loose-art mode on the billed metres.
function montarQuoteFigures(lines){
const heights=montarGroups(lines).map(group=>{
const cargas=[];
group.sources.forEach((source,sourceIndex)=>{
for(let copyIndex=0;copyIndex<source.copies;copyIndex++)
cargas.push({a:{sourceIndex,giro:0,esp:false},img:source.line.img,copyIndex,
w:source.line.widthCm,h:source.line.heightCm,travado:false});
});
return encaixar(cargas,MONTAR_FILM_CM).altura/100;
});
const catalog=MONTAR.catalog?.avulsa;
if(!catalog)throw new Error('Preço de tabela indisponível agora.');
const billed=heights.map(metres=>Math.max(1,Math.ceil(metres*10)/10));
const total=+billed.reduce((sum,metres)=>sum+metres,0).toFixed(2);
let unit=catalog.unit_cents,best=null;
for(const band of catalog.bands||[]){
const from=Number(band.from_metres);
if(total>=from&&(best===null||from>=best)){best=from;unit=band.unit_cents;}
}
return {metres:+heights.reduce((sum,metres)=>sum+metres,0).toFixed(4),
cents:billed.reduce((sum,metres)=>sum+Math.floor(Number((metres*unit).toFixed(6))),0)};
}
async function montarCatalog(){
if(MONTAR.catalog)return MONTAR.catalog;
const session=await montarPublic('/session');
MONTAR.catalog=session.products||null;
return MONTAR.catalog;
}
async function montarFreightQuote(){
const msg=$('montar-freight-msg'),cep=montarCep();
if(cep.length!==8){msg.textContent='Informe o CEP de entrega primeiro.';return;}
if(!MONTAR.lines.length||!MONTAR.layout||MONTAR.layoutPending){
msg.textContent='Monte a folha antes de cotar o frete.';return;
}
msg.textContent='Cotando o frete…';
const token=MONTAR.layoutToken;
try{
await montarCatalog();
if(token!==MONTAR.layoutToken||montarCep()!==cep)return;
const figures=montarQuoteFigures([...MONTAR.lines]);
const result=await montarPublic('/freight/options',{method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({postal_code:cep,metres:figures.metres,declared_cents:figures.cents})});
if(token!==MONTAR.layoutToken||montarCep()!==cep)return;
MONTAR.freights=result.options||[];
MONTAR.freight=MONTAR.freights.length?{...MONTAR.freights[0],postal_code:cep}:null;
MONTAR.requestKey=null;
msg.textContent='';montarPaintFreights();montarPaintActions();
}catch(e){
if(token!==MONTAR.layoutToken||montarCep()!==cep)return;
MONTAR.freights=null;MONTAR.freight=null;
$('montar-freights').replaceChildren();$('montar-freights').hidden=true;
msg.textContent=e.message;montarPaintActions();
}
}
function montarPaintFreights(){
const box=$('montar-freights'),options=MONTAR.freights||[];
box.hidden=!options.length;
box.replaceChildren(...options.map(option=>{
const label=node('label',undefined,'montar-freight');
const radio=node('input');radio.type='radio';radio.name='montar-freight';radio.value=option.service;
radio.checked=!!MONTAR.freight&&option.service===MONTAR.freight.service;
radio.onchange=()=>{
MONTAR.freight={...option,postal_code:montarCep()};MONTAR.requestKey=null;montarPaintActions();
};
const meta=node('span',undefined,'montar-freight-meta');
meta.append(node('b',option.description||option.service),
node('span',option.days?'até '+option.days+' dias úteis':'','sub'),
node('em',money(option.total_cents)));
label.append(radio,meta);
return label;
}));
}
// The brand of a stamp, recorded for the future catalogue (Marcus, 10/11):
// only Gestão edits it; everyone who assembles reads it.
async function montarStampBrand(code){
@@ -231,6 +355,7 @@ function montarChanged(){
MONTAR.layout=null;
MONTAR.layoutPending=true;
MONTAR.requestKey=null;
montarResetFreight();
montarPaintLines();
if(!MONTAR.lines.length)montarDrawPreview(null);
clearTimeout(MONTAR.layoutTimer);
@@ -302,6 +427,11 @@ function montarClearCustomer(){
for(const id of MONTAR_CUSTOMER)$(id).value='';
$('montar-customer-q').value='';
$('montar-customer-hits').hidden=true;
for(const id of ['montar-ship-cep','montar-ship-recipient','montar-ship-street','montar-ship-number',
'montar-ship-complement','montar-ship-district','montar-ship-city','montar-ship-state'])
$(id).value='';
$('montar-ship-msg').textContent='';
montarResetFreight();
document.querySelector('input[name="montar-delivery"][value="pickup"]').checked=true;
montarPaintDelivery();
MONTAR.requestKey=null;
@@ -311,13 +441,16 @@ function montarClearCustomer(){
function montarPaintActions(){
const build=$('montar-build');
const customerReady=MONTAR.kind==='interno'?montarInternalReady():montarCustomerFilled();
const deliveryReady=MONTAR.kind!=='venda'||montarDelivery()!=='ship'||montarShipReady();
const ready=!!(MONTAR.lines.length&&MONTAR.layout&&!MONTAR.layoutPending&&
customerReady&&!MONTAR.creating);
customerReady&&deliveryReady&&!MONTAR.creating);
build.disabled=!ready;
build.title=ready?'':(!MONTAR.lines.length?'Monte a folha primeiro.'
:(MONTAR.layoutPending||!MONTAR.layout)?'Aguarde a montagem da folha.'
:MONTAR.kind==='interno'?'Peça à Gestão para completar o cliente interno.'
:'Preencha os dados do cliente.');
:!customerReady?'Preencha os dados do cliente.'
:!deliveryReady?(!montarDestination()?'Preencha o endereço de entrega.':'Cote o frete e escolha uma opção.')
:'');
}
// The Site's grade for loose art (web/site-quality.js): each stamp's DPI over
// the ideal 200, from 6 to 100; the item's is the average of its stamps'.
@@ -345,13 +478,11 @@ function montarItem(sources){
}
// 20 sources and 4000 copies per item; a stamp above 200 copies becomes
// several sources of the same upload, 200 each; items in list order.
function montarItems(lines,uploads){
function montarGroups(lines){
const pool=[];
for(const line of lines){
const uploadId=uploads.get(line.id);
for(const line of lines)
for(let left=line.qty;left>0;left-=200)
pool.push({line,uploadId,copies:Math.min(200,left)});
}
pool.push({line,copies:Math.min(200,left)});
const groups=[];let current=null;
for(const source of pool){
if(!current||current.sources.length>=20||current.copies+source.copies>4000){
@@ -359,7 +490,11 @@ function montarItems(lines,uploads){
}
current.sources.push(source);current.copies+=source.copies;
}
return groups.map(group=>montarItem(group.sources));
return groups;
}
function montarItems(lines,uploads){
return montarGroups(lines).map(group=>montarItem(group.sources.map(source=>
({...source,uploadId:uploads.get(source.line.id)}))));
}
async function montarCreate(){
if(MONTAR.creating)return;
@@ -373,8 +508,18 @@ async function montarCreate(){
if(!montarCustomerFilled())return say('Preencha os dados do cliente.',true);
name=customer.name;
}
if(kind==='venda'&&montarDelivery()==='with_order'&&!montarWithOrder())
return say('Informe o número do pedido de roupa.',true);
let withOrder=null,deliveryFreight=null,destination=null;
if(kind==='venda'&&montarDelivery()==='with_order'){
withOrder=montarWithOrder();
if(!withOrder)return say('Informe o número do pedido de roupa.',true);
}
if(kind==='venda'&&montarDelivery()==='ship'){
destination=montarDestination();
if(!destination)return say('Preencha o endereço de entrega.',true);
if(!MONTAR.freight)return say('Cote o frete e escolha uma opção.',true);
if(MONTAR.freight.postal_code!==montarCep())return say('Cote o frete de novo para este CEP.',true);
deliveryFreight={service:MONTAR.freight.service,postal_code:montarCep()};
}
if(!MONTAR.lines.length)return say('Monte a folha primeiro.',true);
if(!MONTAR.layout||MONTAR.layoutPending)return say('A montagem ainda está sendo calculada.',true);
const lines=[...MONTAR.lines];
@@ -395,8 +540,9 @@ async function montarCreate(){
const body={request_key:MONTAR.requestKey,kind,items:montarItems(lines,uploads)};
if(kind==='venda'){
body.customer=customer;
const withOrder=montarWithOrder();
if(withOrder)body.with_order=withOrder;
if(deliveryFreight)body.freight=deliveryFreight;
if(destination)body.destination=destination;
}
const order=await api('/montador/orders',body);
MONTAR.requestKey=null;
@@ -574,12 +720,16 @@ function montarQueueContacts(){
MONTAR.contactTimer=setTimeout(()=>montarSearchContacts().catch(e=>say(e.message,true)),300);
}
function montarPickContact(contact){
const previous=$('montar-name').value.trim();
$('montar-name').value=contact.name||'';
$('montar-doc').value=contact.document||'';
$('montar-zap').value=contact.phone||'';
$('montar-mail').value=contact.email||'';
$('montar-customer-q').value=contact.name||contact.document||'';
$('montar-customer-hits').hidden=true;
const recipient=$('montar-ship-recipient').value.trim();
if(montarDelivery()==='ship'&&(!recipient||recipient===previous))
$('montar-ship-recipient').value=contact.name||'';
MONTAR.requestKey=null;
montarPaintActions();
const missing=MONTAR_CUSTOMER.find(id=>!$(id).value.trim());
@@ -643,8 +793,31 @@ $('montar-with-order').addEventListener('focus',()=>{
});
$('montar-with-order').addEventListener('input',()=>{MONTAR.requestKey=null;});
for(const radio of document.querySelectorAll('input[name="montar-delivery"]'))
radio.addEventListener('change',()=>{MONTAR.requestKey=null;montarPaintDelivery();});
radio.addEventListener('change',()=>{MONTAR.requestKey=null;montarPaintDelivery();montarPaintActions();});
$('montar-ship-cep').addEventListener('input',()=>{
const digits=$('montar-ship-cep').value.replace(/\D/g,'').slice(0,8);
$('montar-ship-cep').value=digits.length>5?digits.slice(0,5)+'-'+digits.slice(5):digits;
MONTAR.requestKey=null;montarResetFreight();montarPaintActions();
});
$('montar-cep-find').onclick=async()=>{
$('montar-cep-find').disabled=true;
try{await montarCepLookup();}catch(e){say(e.message,true);}
finally{$('montar-cep-find').disabled=false;}
};
$('montar-freight-quote').onclick=async()=>{
$('montar-freight-quote').disabled=true;
try{await montarFreightQuote();}catch(e){say(e.message,true);}
finally{$('montar-freight-quote').disabled=false;}
};
for(const id of ['montar-ship-recipient','montar-ship-street','montar-ship-number',
'montar-ship-complement','montar-ship-district','montar-ship-city'])
$(id).addEventListener('input',()=>{MONTAR.requestKey=null;montarPaintActions();});
$('montar-ship-state').addEventListener('change',()=>{MONTAR.requestKey=null;montarPaintActions();});
document.addEventListener('click',event=>{
if(!event.target.closest('.montar-customer-search'))$('montar-customer-hits').hidden=true;
});
const montarUfPlaceholder=node('option','UF');montarUfPlaceholder.value='';
$('montar-ship-state').append(montarUfPlaceholder,...MONTAR_UFS.map(uf=>{
const option=node('option',uf);option.value=uf;return option;
}));
montarPaintDelivery();

View File

@@ -3,7 +3,7 @@
which defines api, may, money, when, say, node and button.
A price is history: one that has started is never changed or deleted, so
only a scheduled (future) price may be cancelled. */
const SITE_UNIT_LABEL={metro:' /m',pedido:' por pedido'};
const SITE_UNIT_LABEL={metro:' /m',pedido:' por pedido',arte:' por arte'};
// Reais with a comma, as the Site shows them: "19,90" is 1990 cents.
function moneyInputCents(value){
@@ -18,10 +18,11 @@ function moneyInputCents(value){
// A price that already started is refused by the server (409).
const cancelScheduledPrice=id=>api('/site/prices/'+id+'/cancel',{});
// "5" or "5,5": a band's start in metres, as the table reads it.
// "5" or "5,5": a band's start, in metres or arts, as the table reads it.
function bandMetres(value){return String(Number(value)).replace('.',',');}
function bandsText(bands){
return (bands||[]).map(band=>' · '+bandMetres(band.from_metres)+' m: '+money(band.unit_cents)).join('');
function bandsText(bands,unit='metro'){
return (bands||[]).map(band=>' · '+bandMetres(band.from_metres)+' '+
(unit==='arte'?(Number(band.from_metres)===1?'arte':'artes'):'m')+': '+money(band.unit_cents)).join('');
}
function siteProductRow(product){
@@ -66,17 +67,18 @@ function sitePriceBlock(product){
starts.setAttribute('aria-label','Quando o novo preço de '+product.title+' começa');
startsLabel.append(starts);
// Faixas progressivas (front 8.2): a nova tabela começa vazia; as faixas
// viajam com este preço. O tratamento é um valor por pedido, sem faixas.
// viajam com este preço. Ajuste Fino conta as faixas em artes, os produtos em metros.
const bandUnit=product.unit==='arte'?'artes':'m';
const bandRows=node('div',undefined,'siteBandRows');
const addBand=node('button','Adicionar faixa','btn ghost');addBand.type='button';
const paintAdd=()=>{addBand.disabled=bandRows.children.length>=5;};
const bandRow=()=>{
const row=node('div',undefined,'siteBandRow');
const fromLabel=node('label');fromLabel.append(node('span','A partir de (m)'));
const fromLabel=node('label');fromLabel.append(node('span','A partir de ('+bandUnit+')'));
const from=node('input');from.type='text';from.inputMode='decimal';from.className='siteBandFrom';
from.setAttribute('aria-label','Metragem da faixa de '+product.title);
from.setAttribute('aria-label','Início da faixa em '+bandUnit+' de '+product.title);
fromLabel.append(from);
const priceLabel=node('label');priceLabel.append(node('span','R$ por metro'));
const priceLabel=node('label');priceLabel.append(node('span','R$ por '+(product.unit==='arte'?'arte':'metro')));
const bandPrice=node('input');bandPrice.type='text';bandPrice.inputMode='decimal';bandPrice.className='siteBandPrice';
bandPrice.setAttribute('aria-label','Preço da faixa de '+product.title);
priceLabel.append(bandPrice);
@@ -93,7 +95,7 @@ function sitePriceBlock(product){
const from=Number(row.querySelector('.siteBandFrom').value.replace(',','.'));
const unit=moneyInputCents(row.querySelector('.siteBandPrice').value);
if(!Number.isFinite(from)||from<=0||unit===null||unit<=0)
throw new Error('Confira as faixas: metragem e preço maiores que zero.');
throw new Error('Confira as faixas: início e preço maiores que zero.');
return {from_metres:String(from),unit_cents:unit};
});
const save=button('Salvar',async()=>{
@@ -103,18 +105,17 @@ function sitePriceBlock(product){
if(whenDate&&Number.isNaN(whenDate.getTime()))throw new Error('Data inválida.');
await api('/site/products/'+product.id+'/prices',
{unit_cents:cents,starts_at:whenDate?whenDate.toISOString():null,
bands:product.id==='tratamento'?[]:formBands()});
bands:formBands()});
say(whenDate?'Preço salvo para '+when(whenDate)+'.':'Preço salvo. Vale a partir de agora.');
await loadSiteAdmin();
},'btn pri');
form.append(priceLabel,startsLabel,save);
if(product.id!=='tratamento')form.append(bands);
form.append(priceLabel,startsLabel,save,bands);
const scheduled=node('div',undefined,'siteScheduled');
if(product.scheduled.length){
for(const row of product.scheduled){
const line=node('div',undefined,'siteScheduledRow');
line.append(node('span',money(row.unit_cents)+SITE_UNIT_LABEL[product.unit]+bandsText(row.bands)+
line.append(node('span',money(row.unit_cents)+SITE_UNIT_LABEL[product.unit]+bandsText(row.bands,product.unit)+
' a partir de '+when(row.starts_at)));
line.append(button('Cancelar',async()=>{
await cancelScheduledPrice(row.id);
@@ -132,7 +133,7 @@ function sitePriceBlock(product){
const body=node('tbody');
for(const row of product.history){
const tr=node('tr');
tr.append(node('td',money(row.unit_cents)+bandsText(row.bands),'nowrap'),node('td',when(row.starts_at),'nowrap'),
tr.append(node('td',money(row.unit_cents)+bandsText(row.bands,product.unit),'nowrap'),node('td',when(row.starts_at),'nowrap'),
node('td',row.created_by),node('td',when(row.created_at),'nowrap'));
body.append(tr);
}
@@ -188,7 +189,7 @@ async function loadGradeRules(){
ensureGradePanel();
const data=await api('/site/grade-rules');
const aviso=gradeRuleRow('Avisar o designer abaixo de',data.aviso);
const tratamento=gradeRuleRow('Exigir o tratamento abaixo de',data.tratamento);
const tratamento=gradeRuleRow('Exigir o Ajuste Fino abaixo de',data.tratamento);
const save=button('Salvar',async()=>{
const avisoValue=aviso.on.checked?Number(aviso.num.value):null;
const tratamentoValue=tratamento.on.checked?Number(tratamento.num.value):null;
@@ -196,14 +197,14 @@ async function loadGradeRules(){
if(value!==null&&(!Number.isInteger(value)||value<1||value>100))
throw new Error('A nota vai de 1 a 100.');
if(avisoValue!==null&&tratamentoValue!==null&&tratamentoValue>avisoValue)
throw new Error('A regra do tratamento precisa ser menor ou igual à do aviso.');
throw new Error('A regra do Ajuste Fino precisa ser menor ou igual à do aviso.');
await api('/site/grade-rules',{aviso:avisoValue,tratamento:tratamentoValue});
say('Regras da nota da arte salvas.');
await loadGradeRules();
},'btn pri');
const children=[aviso.row,tratamento.row];
if(!data.treatment_offered)
children.push(node('p','Ative e dê preço ao Tratamento pelo designer para esta regra valer.','siteGradeWarn'));
children.push(node('p','Ative e dê preço ao Ajuste Fino para esta regra valer.','siteGradeWarn'));
const foot=node('div',undefined,'siteGradeSave');foot.append(save);children.push(foot);
$('site-grade-body').replaceChildren(...children);
}

View File

@@ -1306,6 +1306,22 @@ dialog.viewer::backdrop{background:var(--scrim)}
#tab-montar .montar-radio:has(input[type="radio"]:checked){border-color:var(--acc);color:var(--tx)}
#tab-montar .montar-radio input[type="number"]{width:110px;height:28px;padding:0 8px;border-radius:7px;border:1px solid var(--ln2);background:var(--bg);color:var(--tx);font-family:inherit;font-size:13px}
#tab-montar .montar-radio input[type="number"]:disabled{opacity:.5}
#tab-montar .montar-shipping{margin-top:12px}
#tab-montar .montar-cep{display:flex;align-items:flex-end;gap:10px;flex-wrap:wrap}
#tab-montar .montar-cep .fld{flex:1;min-width:180px}
#tab-montar .montar-cep .btn{height:42px}
#tab-montar #montar-ship-msg,#tab-montar #montar-freight-msg{margin:8px 0 0;padding:0}
#tab-montar #montar-freight-msg{flex:1;min-width:180px}
#tab-montar .montar-ship-fields{margin-top:12px}
#tab-montar .montar-freight-actions{display:flex;align-items:center;gap:12px;margin-top:14px;flex-wrap:wrap}
#tab-montar .montar-freights{display:flex;flex-direction:column;gap:6px;margin-top:10px}
#tab-montar .montar-freight{display:flex;align-items:center;gap:10px;padding:9px 12px;border:1px solid var(--ln2);border-radius:9px;cursor:pointer}
#tab-montar .montar-freight:has(input:checked){border-color:var(--acc)}
#tab-montar .montar-freight input{accent-color:var(--acc)}
#tab-montar .montar-freight-meta{display:flex;flex:1;align-items:baseline;gap:10px;flex-wrap:wrap;min-width:0}
#tab-montar .montar-freight-meta b{font-size:13.5px;font-weight:650}
#tab-montar .montar-freight-meta .sub{font-size:12.5px;color:var(--tx3)}
#tab-montar .montar-freight-meta em{margin-left:auto;font-style:normal;font-weight:650}
#tab-montar .montar-brand{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:8px}
#tab-montar .montar-brand .lbl{font-size:12px;color:var(--tx3)}
#tab-montar .montar-brand b{font-size:13.5px;font-weight:650}

View File

@@ -154,12 +154,33 @@
<p class="phint" id="montar-interno-note" hidden>O cliente fixo dos pedidos internos.</p>
</div>
<div class="montar-delivery" id="montar-delivery">
<h3>Envio</h3>
<h3>Entrega</h3>
<div class="montar-delivery-options">
<label class="montar-radio"><input type="radio" name="montar-delivery" value="pickup" checked> Retirada</label>
<label class="montar-radio"><input type="radio" name="montar-delivery" value="with_order"> Junto com o pedido de roupa nº <input id="montar-with-order" type="number" min="1" max="999999" step="1" inputmode="numeric" disabled></label>
<label class="montar-radio"><input type="radio" name="montar-delivery" value="ship"> Envio</label>
</div>
<div class="montar-shipping" id="montar-shipping" hidden>
<div class="montar-cep">
<label class="fld"><span>CEP de entrega</span><input id="montar-ship-cep" inputmode="numeric" maxlength="9" autocomplete="off" placeholder="00000-000"></label>
<button class="btn" id="montar-cep-find" type="button">Buscar endereço</button>
</div>
<p class="phint" id="montar-ship-msg" role="status"></p>
<div class="montar-customer-fields montar-ship-fields">
<label class="fld"><span>Quem recebe</span><input id="montar-ship-recipient" maxlength="120" autocomplete="off" placeholder="Nome ou empresa"></label>
<label class="fld"><span>Rua / avenida</span><input id="montar-ship-street" maxlength="160" autocomplete="off"></label>
<label class="fld"><span>Número</span><input id="montar-ship-number" maxlength="20" autocomplete="off" placeholder="123 ou S/N"></label>
<label class="fld"><span>Complemento</span><input id="montar-ship-complement" maxlength="80" autocomplete="off"></label>
<label class="fld"><span>Bairro</span><input id="montar-ship-district" maxlength="80" autocomplete="off"></label>
<label class="fld"><span>Cidade</span><input id="montar-ship-city" maxlength="80" autocomplete="off"></label>
<label class="fld"><span>UF</span><select id="montar-ship-state"></select></label>
</div>
<div class="montar-freight-actions">
<button class="btn" id="montar-freight-quote" type="button">Cotar frete</button>
<span class="phint" id="montar-freight-msg" role="status"></span>
</div>
<div class="montar-freights" id="montar-freights" role="radiogroup" aria-label="Opções de entrega" hidden></div>
</div>
<p class="phint">Envio com o frete do Site chega na próxima etapa.</p>
</div>
<div class="montar-actions">
<button class="btn ghost" id="montar-clear" type="button">Limpar lista</button>

View File

@@ -1064,7 +1064,11 @@ function cardFlags(order){
if(redo.length)out.push(['bad','Retrabalho',redo.map(r=>'Retrabalho · '+REWORK_CAUSES[r.cause]+' · '+metres(r.metres)+(r.authorized?'':' · aguardando autorização')).join(' · ')]);
if(live&&s.items.some(mirroredItem))out.push(['warn','Espelhada',MIRROR_NOTE]);
if(waitingContact(order))out.push(['warn','Contato','Aguardando contato: '+order.contact_note+' · '+contactWho(order)]);
if(order.snapshot.treatment)out.push(['warn','Tratamento pago','O designer trata a arte antes de imprimir; prazo +24 h']);
if(order.snapshot.treatment){
const n=Number(order.snapshot.treatment.arts)||1;
out.push(['warn','Ajuste Fino · '+n+(n===1?' arte':' artes'),
'O designer faz o Ajuste Fino antes de imprimir; prazo +24 h']);
}
if(order.proof_parent)out.push(['warn','Prova do #'+order.proof_parent.number,'Card da prova do pedido #'+order.proof_parent.number]);
if(live&&waitingProof(order)&&order.state!=='tra')out.push(['warn','Aguardando prova','Entra na fila com Prova OK no card #'+order.proof_card.number]);
if(live&&proofRejected(order))out.push(['bad','Prova reprovada',order.proof_card.proof_reason+' · '+order.proof_card.proof_decided_by]);
@@ -1611,9 +1615,9 @@ function contractionList(order){
}
function approveParts(order,main=true){
if(order.snapshot.treatment){
const approve=button('Enviar arte tratada',()=>treatDialog(order),'btn lg'+(main?' pri':''));
const approve=button('Enviar arte do Ajuste Fino',()=>treatDialog(order),'btn lg'+(main?' pri':''));
approve.dataset.treat='';
return {text:'Tratamento pago: o designer precisa enviar o PNG tratado de cada item antes da fila.',
return {text:'Ajuste Fino pago: o designer precisa enviar o PNG do Ajuste Fino de cada item antes da fila.',
files:null,approve,extra:[]};
}
const ready=readyFinals(order), all=ready.every(Boolean), many=ready.length>1;
@@ -1705,8 +1709,8 @@ function nextBox(order){
}
if(st==='rec'||st==='cor'){
if(st==='rec'&&order.snapshot.treatment&&!treatmentDone(order)&&finalDone(order)){
title='Enviar a arte tratada';
note('O tratamento foi pago. Envie o PNG tratado de cada item antes de colocar o pedido na fila.');
title='Enviar a arte do Ajuste Fino';
note('O Ajuste Fino foi pago. Envie o PNG ajustado de cada item antes de colocar o pedido na fila.');
if(may('produce'))main.push(button('Tratar a arte',()=>treatDialog(order),'btn pri lg'));
return composeNext(title,body,main,more);
}
@@ -2403,7 +2407,7 @@ function filesView(order,revisions,view){
// Rework (Dropstar's rules D-02 to D-04). Gestão opens it with its cause,
// which never changes after; an Administrador authorizes or declines it,
// never one they opened. Bad art the customer approved is outside the goal.
const REWORK_CAUSES={impressao:'Falha de impressão',perfil_cor:'Perfil de cor',tratamento:'Erro de tratamento',
const REWORK_CAUSES={impressao:'Falha de impressão',perfil_cor:'Perfil de cor',tratamento:'Erro de Ajuste Fino',
pedido:'Erro de pedido',arte_cliente:'Arte aprovada pelo cliente'};
const REWORK_OUTSIDE='arte_cliente';
function reworkForm(order){

View File

@@ -4,6 +4,77 @@
scope and run top to bottom, exactly as the original did. */
// ── carrinho
let itemAtual=null;
// Ajuste Fino (front 1a): each art may be chosen under its warning, or the
// general switch chooses every art of the paying items.
function artesDoItem(it){
if(it.partes && it.partes.length)
return it.partes.reduce((t,p)=>t+((p.production&&p.production.sources||[]).length),0);
return (it.production&&it.production.sources||[]).length;
}
function artesSelecionadas(aPagar=itensAPagar()){
if(ajusteTudo) return aPagar.reduce((t,it)=>t+artesDoItem(it),0);
return aPagar.reduce((t,it)=>{
if(it.partes && it.partes.length)
return t+it.partes.reduce((s,p)=>s+(p.ajusteSources||[]).length,0);
return t+(it.ajusteSources||[]).length;
},0);
}
// While a product is open, its files are not in the cart yet; the rule must
// still see the arts the customer already checked under their warnings.
function artesEscolhidasNaTela(){
if(!modo) return 0;
return (ehFolha()?folhas:artes).filter(x=>x.ajuste).length;
}
// What the cart snapshot compares: the switch and every chosen source.
function ajusteSnapshot(){
return {tudo:!!ajusteTudo, itens:itensAPagar().map(it=>({
escolhas:it.ajusteSources||[],
partes:(it.partes||[]).map(p=>p.ajusteSources||[])
}))};
}
// A final cart item (after a split sheet becomes its own items) to the pairs.
function tratamentoParaItens(itens){
if(!(TAXA_TRATAMENTO>0)) return false;
if(ajusteTudo) return true;
const pairs=[];
itens.forEach((it,itemIndex)=>{
for(const source of it.ajusteSources||[]) pairs.push([itemIndex,source]);
});
return pairs.length?pairs:false;
}
function materializaAjuste(){
if(!ajusteTudo) return;
ajusteTudo=false;
for(const it of itensAPagar()){
if(it.partes && it.partes.length){
for(const part of it.partes)
part.ajusteSources=Array.from({length:(part.production&&part.production.sources||[]).length},(_,i)=>i);
}else{
it.ajusteSources=Array.from({length:(it.production&&it.production.sources||[]).length},(_,i)=>i);
}
}
for(const x of folhas) x.ajuste=true;
for(const a of artes) a.ajuste=true;
}
function limpaAjuste(){
ajusteTudo=false;
for(const it of itensAPagar()){
it.ajusteSources=[];
for(const part of it.partes||[]) part.ajusteSources=[];
}
for(const x of folhas) x.ajuste=false;
for(const a of artes) a.ajuste=false;
}
// Update the per-art boxes without repainting the list, which would discard
// the item the customer is still building.
function pintaAjusteCheckboxes(){
document.querySelectorAll('[data-ajuste]').forEach(el=>{
const x=folhas[+el.dataset.ajuste]; if(x)el.checked=ajusteTudo||!!x.ajuste;
});
document.querySelectorAll('[data-ajustea]').forEach(el=>{
const a=artes[+el.dataset.ajustea]; if(a)el.checked=ajusteTudo||!!a.ajuste;
});
}
function invalidaItemAtual(){
if(!itemAtual) return;
itemAtual=null;
@@ -31,7 +102,8 @@ function limpaPaineis(){
}
// Front 8.5: when the worst grade of the paying items is below the rule and
// the treatment is offered, the designer's treatment is required.
// Ajuste Fino is offered, it is required. The simple rule the server keeps:
// at least one art must be chosen; with none, the general switch selects all.
function mostraAvisoTratamento(texto){
const box=$('tratamentoBox'); if(!box)return;
let el=$('tratamentoAviso');
@@ -48,12 +120,27 @@ function aplicaTratamento(aPagar){
const required=offered&&rule>0&&worst!==null&&worst<rule;
box.hidden=!offered;
if(!offered){
check.checked=false;check.disabled=false;mostraAvisoTratamento('');
check.checked=false;check.disabled=false;
ajusteTudo=false;
for(const it of aPagar){
it.ajusteSources=[];
for(const part of it.partes||[]) part.ajusteSources=[];
}
for(const x of folhas) x.ajuste=false;
for(const a of artes) a.ajuste=false;
mostraAvisoTratamento('');
}else if(required){
check.checked=true;check.disabled=true;
mostraAvisoTratamento('Sua arte tem nota '+worst+': para imprimir com qualidade, o tratamento pelo designer é obrigatório neste pedido.');
const chosen=!!ajusteTudo || artesSelecionadas(aPagar)>0 || artesEscolhidasNaTela()>0;
if(!chosen){
ajusteTudo=true;
for(const x of folhas) x.ajuste=true;
for(const a of artes) a.ajuste=true;
document.querySelectorAll('[data-ajuste],[data-ajustea]').forEach(el=>{el.checked=true;});
}
check.checked=ajusteTudo;check.disabled=true;
mostraAvisoTratamento('Sua arte tem nota '+worst+': para imprimir com qualidade, o Ajuste Fino é obrigatório neste pedido.');
}else{
check.disabled=false;mostraAvisoTratamento('');
check.checked=ajusteTudo;check.disabled=false;mostraAvisoTratamento('');
}
}
// O carrinho junta itens de produtos diferentes e cobra uma vez só.
@@ -100,7 +187,8 @@ function pintaPedido(){
$('bEsvaziar').hidden = pedido.length+(itemAtual?1:0) < 2;
const itens = aPagar.reduce((t,it)=>t+it.total,0);
const frete = entrega.tipo==='frete' && entrega.cotado ? entrega.valor : 0;
const tratamento=$('fTratamento')?.checked&&TAXA_TRATAMENTO>0?TAXA_TRATAMENTO:0;
const artesAjuste = TAXA_TRATAMENTO>0 ? artesSelecionadas(aPagar) : 0;
const tratamento = artesAjuste ? Math.round(precoAjuste(artesAjuste)*artesAjuste*100)/100 : 0;
const soma = itens + frete + tratamento;
const n = aPagar.length, noCarrinho = pedido.length + (itemAtual?1:0);
$('resLin').innerHTML =
@@ -110,7 +198,8 @@ function pintaPedido(){
'</span><b>'+
(entrega.tipo==='retira' ? '<span style="color:var(--verde-ml)">Grátis</span>'
: entrega.cotado ? rs(frete) : 'a cotar')+'</b></div>'+
(tratamento?'<div class="l"><span>Tratamento da arte · +24 h</span><b>'+rs(tratamento)+'</b></div>':'')+
(tratamento?'<div class="l"><span>Ajuste Fino · '+artesAjuste+(artesAjuste===1?' arte':' artes')+
' · +24 h</span><b>'+rs(tratamento)+'</b></div>':'')+
'<div class="l"><span>Revisão e reencaixe</span>'+
'<b><span style="color:var(--verde-ml)">Grátis</span></b></div>';
$('carrTot').textContent=rs(soma);
@@ -151,6 +240,7 @@ function carrinho(){
'<div class="l" style="color:var(--laranja2)"><span>Revisão e reencaixe</span><b>grátis</b></div>';
$('carrLin').innerHTML=l;
$('atual').style.display='';
const escolhidas=lista=>lista.map((x,i)=>ajusteTudo||x.ajuste?i:null).filter(i=>i!==null);
const sources=(ehFolha()?folhas:artes).map(x=>ehFolha()
? {kind:'sheet',width_cm:x.med?.larg||larguraFilme(),length_cm:+(x.m*100).toFixed(4),
copies:x.rep||1,rotation_degrees:0,mirrored:false,
@@ -175,6 +265,7 @@ function carrinho(){
localFiles:f.artes.map(x=>x.f), fotos:f.artes.map(x=>x.fotoSrc||null),
metros:+(f.layout.height_cm/100).toFixed(4),
production:{version:3,film_width_cm:larguraFilme(),sources:f.artes.map(fonteDaArte),...f.layout},
ajusteSources:escolhidas(f.artes),
residueAccepted:residuosDasArtes(f.artes), ...tracoDoItem(f.artes,f.layout)}));
layout=null;
}else{
@@ -189,6 +280,7 @@ function carrinho(){
arquivos:(ehFolha()?folhas:artes).length,
production:layout?{version:3,film_width_cm:larguraFilme(),sources,...layout}:null,
partes,
...(partes?{}:{ajusteSources:escolhidas(ehFolha()?folhas:artes)}),
qualityStatus:$('ciente').classList.contains('recusa')?'rejected':
$('ciente').classList.contains('on')?'warning':nota===0?'unverified':'ok',
qualityAcknowledged:false,
@@ -210,7 +302,14 @@ function avisaDesfazer(texto,acao){
function fechaDesfazer(){ clearTimeout(desfazerTimer); desfazerAcao=null; $('desfazer').hidden=true; }
addEventListener('dtf-page-changed',fechaDesfazer);
$('desfazerBtn').addEventListener('click',()=>{ const acao=desfazerAcao; fechaDesfazer(); if(acao) acao(); });
$('fTratamento')?.addEventListener('change',()=>pintaPedido());
$('fTratamento')?.addEventListener('change',()=>{
if($('fTratamento').checked) ajusteTudo=true;
else limpaAjuste();
// The art cards show the same choice, one checkbox under each warning; do
// not repaint them, or the item being built is discarded.
pintaAjusteCheckboxes();
pintaPedido();
});
$('bEsvaziar').addEventListener('click',()=>{
const antes=pedido.slice();
pedido=[]; invalidaItemAtual(); pintaPedido();

View File

@@ -66,8 +66,11 @@ const FAIXAS={};
// 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;
// Fixed price of the designer treatment, set by the server (TREATMENT_CENTS).
// Ajuste Fino, per art, set by the server (TREATMENT_CENTS).
let TAXA_TRATAMENTO=0;
// Ajuste Fino for every art of the cart: the general switch, or true when
// the grade rule requires it. Individual choices live on the art objects.
let ajusteTudo=false;
const folhaManual=()=>ehFolha() && folhas.some(x=>!x.med);
const ehFolha=m=>!!MODOS[m||modo].folha;
const precoMetro=m=>PRECO[m||modo];
@@ -79,6 +82,16 @@ function precoNaMetragem(m, metros){
for(const band of bands) if(metros>=Number(band.from_metres) && (!alta || Number(band.from_metres)>=Number(alta.from_metres))) alta=band;
return alta ? alta.unit_cents/100 : PRECO[m];
}
// Ajuste Fino: the price of one art when the order has n arts. Below the first
// band it is the base, then the highest band reached, as app/catalog.py does.
function precoAjuste(n, base = TAXA_TRATAMENTO, bands = FAIXAS.tratamento) {
let price = base, best = null;
for (const band of bands || []) {
const start = Number(band.from_metres);
if (n >= start && (best === null || start >= best)) { best = start; price = band.unit_cents / 100; }
}
return price;
}
// A próxima faixa à frente, para o aviso de quanto falta.
function proximaFaixa(m, metros){
const bands=FAIXAS[m]||[];

View File

@@ -483,6 +483,27 @@ function avisosDaFolha(a,nome,i,aceito,aceitavel=false){
'usou e envie de novo. '+(varios?'Os círculos vermelhos na prévia mostram onde estão.':'O círculo vermelho na prévia mostra onde está.')+
(aceitavel?' Se '+(varios?'os pontos são':'o ponto é')+' da própria arte, marque abaixo.</p>'+aceite:'</p>');
}
// Ajuste Fino (front 1a): under a Prumo warning, the customer may hand this
// art to the designer. One choice per art; the cart has the general switch.
function temAvisoFolha(x){
const a=x.an;
if(!a || a.grande) return false;
return !!(a.fundoChapado || a.residuos || a.dpi<DPI_AVISA ||
(typeof tracoDoArquivo==='function' && typeof mista==='function' && mista(tracoDoArquivo(x))));
}
function temAvisoArte(a){
const an=analiseDaArte(a);
if(!an || an.grande) return false;
return !!(an.fundoChapado || an.residuos || an.dpi<DPI_AVISA ||
(typeof mista==='function' && mista(tracoDaArte(a))));
}
function ajusteLinha(i,attr){
if(!(TAXA_TRATAMENTO>0)) return '';
const marcado=ajusteTudo || (attr==='data-ajuste' ? folhas[i].ajuste : artes[i].ajuste);
return '<label class="aceiteRes ajusteArte"><input type="checkbox" '+attr+'="'+i+'"'+
(marcado?' checked':'')+'>'+
'<span>Quer que um designer resolva? <b>Ajuste Fino</b> — '+rs(TAXA_TRATAMENTO)+'</span></label>';
}
function detalhesDaFolha(a,i,aberto){
const linhas = a.grande
? ['Resolução '+a.dpi+' DPI, lida do arquivo',
@@ -514,6 +535,7 @@ function pintaFolha(){
medida='<div class="repMed"><b>'+n1(x.med.larg)+' × '+n1(x.med.alt)+' cm</b>'+
'<span>'+escapeHTML(extDe(x.f.name))+' · '+fmt(x.f.size)+'</span></div>'+
(a? '<ul class="chips">'+chipsDaFolha(a,residuoAceito(x))+'</ul>'+avisosDaFolha(a,x.f.name,i,residuoAceito(x),true)+
(temAvisoFolha(x)?ajusteLinha(i,'data-ajuste'):'')+
detalhesDaFolha(a,i,x.detAberto) : '')+
// Over 150 MB the browser cannot check a PDF: said before payment, as
// for a file opened by hand (Dropstar, 2026-10-23).
@@ -524,7 +546,7 @@ function pintaFolha(){
'Exportando em <b>PNG</b>, ou num PDF menor, a conferência sai aqui, antes de pagar.</p>' : '')+
(suspeito? '<p class="avisoF"><b>Este PDF passa do tamanho que o formato comporta.</b> '+
'A especificação para em 508 cm e o seu tem '+n1(x.med.alt)+' cm. '+
'Ele abre certo só em quem o gerou — aqui vai precisar de tratamento. '+
'Ele abre certo só em quem o gerou — aqui vai precisar do Ajuste Fino. '+
'Manda em <b>PNG ou TIFF</b>, ou divide em partes de até 5 m, que sai na hora.</p>':'')+
(larga? '<p class="avisoF"><b>Esta folha não roda neste filme.</b> Ela tem '+n1(x.med.larg)+
' cm de largura e o filme aqui tem '+n1(L)+' cm. Não dá para reduzir: '+
@@ -588,6 +610,11 @@ function pintaFolha(){
$('lista').querySelectorAll('[data-residuo]').forEach(el=>el.addEventListener('change',()=>{
folhas[+el.dataset.residuo].residuoAceito=el.checked; pintaFolha();
}));
$('lista').querySelectorAll('[data-ajuste]').forEach(el=>el.addEventListener('change',()=>{
if(ajusteTudo) materializaAjuste();
folhas[+el.dataset.ajuste].ajuste=el.checked;
pintaFolha(); pintaPedido();
}));
$('lista').querySelectorAll('[data-det]').forEach(d=>d.addEventListener('toggle',()=>{
folhas[+d.dataset.det].detAberto=d.open;
}));
@@ -688,7 +715,8 @@ function pintaArtes(){
'<button data-rm="'+i+'" aria-label="Remover '+escapeHTML(a.f.name)+'">'+icone('fechar')+'</button></div>'+
'<div class="repMed">'+medida+'<span>'+(a.px>0? a.px+' × '+a.py+' px · ' : '')+
escapeHTML(extDe(a.f.name))+' · '+fmt(a.f.size)+'</span></div>'+
barra+chips+aviso+dica+
barra+chips+aviso+
(a.cm>0 && (a.src||a.semPrevia) && temAvisoArte(a) ? ajusteLinha(i,'data-ajustea') : '')+dica+
'</div></div>'+
'<div class="cps">'+
'<div class="campo"><label for="cm'+i+'">Largura</label>'+
@@ -715,6 +743,11 @@ function pintaArtes(){
$('lista').querySelectorAll('[data-rm]').forEach(b=>b.addEventListener('click',()=>{artes.splice(+b.dataset.rm,1);pintaArtes();}));
$('lista').querySelectorAll('[data-residuoa]').forEach(el=>el.addEventListener('change',()=>{
artes[+el.dataset.residuoa].residuoAceito=el.checked; pintaArtes();}));
$('lista').querySelectorAll('[data-ajustea]').forEach(el=>el.addEventListener('change',()=>{
if(ajusteTudo) materializaAjuste();
artes[+el.dataset.ajustea].ajuste=el.checked;
pintaArtes(); pintaPedido();
}));
$('lista').querySelectorAll('[data-cm]').forEach(i=>i.addEventListener('change',()=>{artes[+i.dataset.cm].cm=+i.value||0;pintaArtes();}));
$('lista').querySelectorAll('[data-q]').forEach(i=>i.addEventListener('change',()=>{artes[+i.dataset.q].q=Math.max(1,Math.min(200,Math.floor(+i.value||1)));pintaArtes();}));
$('lista').querySelectorAll('[data-cm], [data-q]').forEach(i=>i.addEventListener('input',()=>{