pickList("subjects", C.subject_set_ids, s => ({ v: s.id, main: s.subject, sub: "" }), "subject_set_ids") + `
${["round_robin", "random", "fixed_first"].map(m => ` `).join("")}
`; } else if (step === 4) { b.innerHTML = H("Step 4 — HTML templates") + hint("Select one or more templates and how they sequence across recipients.") + pickList("templates", C.template_ids, t => ({ v: t.id, main: t.name, sub: "" }), "template_ids") + `
---BINDATT--- function bindStep() { if (step === 1) $("#w_name").oninput = e => C.name = e.target.value; if (step === 2) bindPick("recipient_list_id", true); if (step === 3) { bindPick("subject_set_ids"); $$('input[name="subjRot"]').forEach(r => r.onchange = () => C.subject_rotation = r.value); } if (step === 4) { bindPick("template_ids"); $$('input[name="tplMode"]').forEach(r => r.onchange = () => C.template_sequence_mode = r.value); } if (step === 5) { $$('input[name="attMode"]').forEach(r => r.onchange = () => { C.attach_mode = r.value; if (C.attach_mode !== "pdf") C.attach_pdf = false; bindAttExtra(); renderStep(); }); } if (step === 6) { const keep = (k, id) => { const n = $(id); if (n) n.oninput = () => C.variable_config[k] = n.value; }; keep("invoice_prefix", "#w_invoice_prefix"); keep("invoice_format", "#w_invoice_format"); ["amount_min", "amount_max", "shipping_min", "shipping_max"].forEach(k => { const n = $("#w_" + k); if (n) n.oninput = () => C.variable_config[k] = n.value === "" ? undefined : parseFloat(n.value); }); } if (step === 7) bindPick("account_ids"); if (step === 8) $$('input[name="rotStrat"]').forEach(r => r.onchange = () => { C.rotation_strategy = r.value; bindRotExtra(); }); if (step === 9) ["max_per_account", "send_interval_seconds", "rate_per_minute", "max_retries", "retry_delay_seconds"].forEach(k => { const n = $("#w_" + k); if (n) n.oninput = () => C[k] = n.value === "" ? undefined : parseFloat(n.value); }); if (step === 10) { $$('input[name="phSel"]').forEach(r => r.onchange = () => { C.phone_selection = r.value; renderStep(); }); bindPick("phone_fixed", true); $$('#pk_phone_fixed input').forEach(i => i.onchange = () => { C.variable_config.phone_id = +i.value; }); } if (step === 11) { $("#w_unsub").onchange = e => C.unsubscribe_enabled = e.target.checked; $("#w_pss").oninput = e => C.preview_sample_size = parseInt(e.target.value, 10) || 5; } } function bindPick(key, radio = false) { const inputs = $$(`#pk_${key} input`); inputs.forEach(i => i.onchange = () => { if (radio) { C[key] = +i.value; } else { C[key] = inputs.filter(x => x.checked).map(x => +x.value); } }); } function bindAttExtra() { const box = $("#attExtra"); if (!box) return; const mode = C.attach_mode; if (mode === "none") { box.innerHTML = ""; return; } if (mode === "pdf") { C.attach_pdf = true; box.innerHTML = `` + pickList("templates", C.attach_pdf_template_id, t => ({ v: t.id, main: t.name, sub: "" }), "attach_pdf_template_id", true); bindPick("attach_pdf_template_id", true); } else { box.innerHTML = `` + pickList("attachments", C.attachment_id, a => ({ v: a.id, main: a.name + " (" + a.kind + ")", sub: a.filename }), "attachment_id", true); bindPick("attachment_id", true); } } function bindRotExtra() { const box = $("#rotExtra"); if (!box) return; if (C.rotation_strategy !== "weighted") { box.innerHTML = ""; return; } const accs = (OPT.accounts || []).filter(a => C.account_ids.includes(a.id)); if (!accs.length) { box.innerHTML = `
⚠
Select accounts in Step 7 first, then return here to set weights.
`; return; } box.innerHTML = `` +