Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="cost-estimator" class="idi-estimator">
- <style>
- .idi-estimator{
- --c:#0ea5e9; --bg:#0b1220; --panel:#121a2a; --muted:#8aa0bd; --ok:#16a34a; --warn:#f59e0b;
- font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif; color:#e6eefb; border-radius:18px;}
- .idi-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}
- @media(max-width:900px){.idi-grid{grid-template-columns:1fr}}
- .idi-card{background:var(--panel);border:1px solid rgba(255,255,255,.06);border-radius:16px;padding:16px}
- .idi-title{font-size:22px;font-weight:700;margin:0 0 12px}
- .idi-sub{font-size:12px;color:var(--muted);margin-bottom:12px}
- .idi-row{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:center;margin:10px 0}
- .idi-row label{font-size:14px}
- .idi-row input[type="number"],.idi-row select{width:190px;background:#0e1626;color:#e6eefb;border:1px solid rgba(255,255,255,.08);border-radius:10px;padding:8px 10px}
- .idi-check{display:flex;align-items:center;gap:10px;margin:6px 0}
- .idi-check input{transform:scale(1.2)}
- .idi-total{font-size:28px;font-weight:800}
- .idi-badges{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
- .idi-badge{background:#0e1626;border:1px solid rgba(255,255,255,.08);padding:4px 8px;border-radius:999px;font-size:12px;color:var(--muted)}
- .idi-breakdown{margin:10px 0 0;padding:0;list-style:none;color:#cfe0ff}
- .idi-breakdown li{display:flex;justify-content:space-between;border-bottom:1px dashed rgba(255,255,255,.09);padding:7px 0}
- .idi-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}
- .idi-btn{background:var(--c);border:none;color:#001322;font-weight:700;padding:10px 14px;border-radius:12px;cursor:pointer}
- .idi-btn.secondary{background:#0e1626;color:#e6eefb;border:1px solid rgba(255,255,255,.12)}
- .idi-note{font-size:12px;color:var(--muted);margin-top:8px}
- .idi-hint{font-size:12px;color:#a8ffc2}
- .idi-divider{height:1px;background:linear-gradient(90deg,transparent,rgba(255,255,255,.12),transparent);margin:14px 0}
- .idi-right .idi-title{display:flex;justify-content:space-between;align-items:center}
- .idi-right .idi-title small{font-weight:600;color:var(--muted);font-size:12px}
- /* ново: ред за бележки на цяла ширина */
- .idi-row.full{grid-template-columns:1fr}
- .idi-row.full textarea{width:100%;min-height:100px;background:#0e1626;color:#e6eefb;border:1px solid rgba(255,255,255,.08);border-radius:10px;padding:10px}
- </style>
- <div class="idi-grid">
- <!-- ЛЯВО: Входове -->
- <div class="idi-card">
- <h3 class="idi-title">Калкулатор за цена на уебсайт</h3>
- <p class="idi-sub">Изберете опции. Сумата се изчислява след избор (BGN & EUR).</p>
- <div class="idi-row">
- <label>Тип проект</label>
- <select id="projectType">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="landing">Ландинг страница</option>
- <option value="corporate">Корпоративен сайт</option>
- <option value="ecommerce">Онлайн магазин</option>
- <option value="redesign">Редизайн</option>
- </select>
- </div>
- <div class="idi-row">
- <label>Брой страници</label>
- <input id="pages" type="number" min="1" max="100" placeholder="напр. 6" value="">
- </div>
- <div class="idi-row">
- <label>Езици</label>
- <select id="languages">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- </select>
- </div>
- <div class="idi-row">
- <label>Ниво на дизайн</label>
- <select id="designLevel">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="basic">Базов</option>
- <option value="custom">Къстъм</option>
- <option value="premium">Премиум</option>
- </select>
- </div>
- <div class="idi-check">
- <input id="ecom" type="checkbox">
- <label for="ecom">Е-магазин (WooCommerce)</label>
- </div>
- <div class="idi-row" id="productCountRow" style="display:none">
- <label>Продукти (приблиз.)</label>
- <input id="products" type="number" min="0" step="10" value="0">
- </div>
- <div class="idi-check">
- <input id="blog" type="checkbox">
- <label for="blog">Блог</label>
- </div>
- <div class="idi-check">
- <input id="booking" type="checkbox">
- <label for="booking">Резервации / Записвания</label>
- </div>
- <div class="idi-check">
- <input id="payments" type="checkbox">
- <label for="payments">Онлайн плащания (Stripe/PayPal)</label>
- </div>
- <div class="idi-check">
- <input id="couriers" type="checkbox">
- <label for="couriers">Интеграция с куриери (Еконт/Спиди)</label>
- </div>
- <div class="idi-row">
- <label>Качване на съдържание</label>
- <select id="contentYesNo">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="no">Не</option>
- <option value="yes">Да</option>
- </select>
- </div>
- <div class="idi-row">
- <label>Имате ли лого?</label>
- <select id="hasLogo">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="yes">Да</option>
- <option value="no">Не (нужно е лого)</option>
- </select>
- </div>
- <div class="idi-row">
- <label>SEO пакет</label>
- <select id="seoYesNo">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="no">Не</option>
- <option value="yes">Да</option>
- </select>
- </div>
- <div class="idi-row">
- <label>Оптимизация на скорост</label>
- <select id="speedYesNo">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="no">Не</option>
- <option value="yes">Да</option>
- </select>
- </div>
- <div class="idi-row">
- <label>Поддръжка (месеци)</label>
- <select id="maintenance">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="0">Без</option>
- <option value="3">3 месеца</option>
- <option value="6">6 месеца</option>
- <option value="12">12 месеца</option>
- </select>
- </div>
- <div class="idi-row">
- <label>Хостинг (1 година)</label>
- <select id="hosting">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="0">Не</option>
- <option value="1">Да</option>
- </select>
- </div>
- <!-- НОВО: ДДС -->
- <div class="idi-row">
- <label>ДДС</label>
- <select id="vatMode">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="novat">Без ДДС</option>
- <option value="withvat">С ДДС (20%)</option>
- </select>
- </div>
- <div class="idi-divider"></div>
- <div class="idi-row">
- <label>Срок</label>
- <select id="rush">
- <option value="" selected disabled hidden>— Изберете —</option>
- <option value="standard">Стандартен</option>
- <option value="fast">Бърз (≈ +15%)</option>
- <option value="express">Експрес (≈ +30%)</option>
- </select>
- </div>
- <!-- НОВО: Бележки -->
- <div class="idi-row full">
- <label>Бележки / допълнителна информация</label>
- <textarea id="notes" placeholder="Пример: Прехвърляне на съдържание от стар сайт; специфични интеграции; срокове и др."></textarea>
- </div>
- <p class="idi-hint">При избор „Онлайн магазин“ се показва поле за брой продукти.</p>
- </div>
- <!-- ДЯСНО: Резултат -->
- <div class="idi-card idi-right">
- <h3 class="idi-title">
- Обобщение
- <small id="calcStatus">Live</small>
- </h3>
- <div class="idi-badges" id="badges"></div>
- <ul class="idi-breakdown" id="breakdown"></ul>
- <div class="idi-divider"></div>
- <div class="idi-row">
- <div>
- <div class="idi-sub">Общо (BGN)</div>
- <div class="idi-total" id="totalBGN">—</div>
- </div>
- <div>
- <div class="idi-sub">Общо (EUR)</div>
- <div class="idi-total" id="totalEUR">—</div>
- </div>
- </div>
- <div class="idi-actions">
- <button class="idi-btn" id="copyQuote">Копирай офертата</button>
- <a id="emailQuote" class="idi-btn secondary" href="#" target="_blank" rel="noopener">Изпрати по имейл</a>
- <button class="idi-btn secondary" id="pdfExport" type="button">Експорт PDF</button>
- <button class="idi-btn secondary" id="resetForm" type="button">Нулирай</button>
- </div>
- <p class="idi-note">* Цените са ориентировъчни. Финална оферта след кратък разговор за обхвата.</p>
- <p class="idi-note">* EUR е изчислено при 1 EUR = 1.95583 BGN.</p>
- </div>
- </div>
- <script>
- (function(){
- // ===== ЦЕНООБРАЗУВАНЕ =====
- const RATE_EUR = 1.95583;
- const VAT_RATE = 0.20; // 20%
- const PRICING = {
- baseFee: { landing: 240, corporate: 320, ecommerce: 420, redesign: 280 },
- pagePrice: { basic: 120, custom: 180, premium: 260 },
- multiLangFactorPerExtraLang: 0.35,
- ecommerce: {
- enableAddon: 800,
- productTiers: [
- { max: 0, add: 0 },
- { max: 50, add: 200 },
- { max: 200, add: 500 },
- { max: Infinity, add: 900 }
- ]
- },
- blogAddon: 150,
- bookingAddon: 250,
- paymentsAddon: 200,
- couriersAddon: 180,
- contentUploadYes: 120,
- logoDesign: 300,
- seoYes: 350,
- speedYes: 200,
- maintenanceMonthly: 70,
- hostingYearly: 120,
- rushMultiplier: { standard: 1, fast: 1.15, express: 1.30 }
- };
- // ===== ЕЛЕМЕНТИ =====
- const el = id => document.getElementById(id);
- const projectType = el('projectType');
- const pages = el('pages');
- const languages = el('languages');
- const designLevel = el('designLevel');
- const ecom = el('ecom');
- const products = el('products');
- const productCountRow = el('productCountRow');
- const blog = el('blog');
- const booking = el('booking');
- const payments = el('payments');
- const couriers = el('couriers');
- const contentYesNo = el('contentYesNo');
- const hasLogo = el('hasLogo');
- const seoYesNo = el('seoYesNo');
- const speedYesNo = el('speedYesNo');
- const maintenance = el('maintenance');
- const hosting = el('hosting');
- const vatMode = el('vatMode'); // ново
- const rush = el('rush');
- const notes = el('notes'); // ново
- const totalBGN = el('totalBGN');
- const totalEUR = el('totalEUR');
- const breakdown = el('breakdown');
- const badges = el('badges');
- const copyBtn = el('copyQuote');
- const emailBtn = el('emailQuote');
- const resetBtn = el('resetForm');
- const pdfBtn = el('pdfExport');
- // ===== ПОМОЩНИ =====
- const fmtBGN = n => new Intl.NumberFormat('bg-BG', { style:'currency', currency:'BGN', maximumFractionDigits:0 }).format(n);
- const fmtEUR = n => new Intl.NumberFormat('de-DE', { style:'currency', currency:'EUR', maximumFractionDigits:0 }).format(n);
- const toEUR = bgn => bgn / RATE_EUR;
- const clampInt = (v,min,max)=>{ v=parseInt(v||0,10); if(isNaN(v)) v=min; return Math.min(Math.max(v,min),max); };
- const escapeHtml = s => String(s).replace(/[&<>"']/g, m => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[m]));
- const maps = {
- project: {landing:'Ландинг страница', corporate:'Корпоративен сайт', ecommerce:'Онлайн магазин', redesign:'Редизайн'},
- design: {basic:'Базов', custom:'Къстъм', premium:'Премиум'},
- rush: {standard:'Стандартен', fast:'Бърз (≈ +15%)', express:'Експрес (≈ +30%)'},
- yn: {yes:'Да', no:'Не'}
- };
- function labelProject(key){ return maps.project[key]||key; }
- function updateBadges(){
- const list = [];
- const badge = t => `<span class="idi-badge">${t}</span>`;
- if(projectType.value) list.push(badge(labelProject(projectType.value)));
- if(designLevel.value) list.push(badge(maps.design[designLevel.value]));
- if(parseInt(languages.value,10) > 1) list.push(badge(languages.value + ' езика'));
- if(ecom.checked) list.push(badge('e-магазин'));
- if(blog.checked) list.push(badge('блог'));
- if(booking.checked) list.push(badge('резервации'));
- if(payments.checked) list.push(badge('плащания'));
- if(couriers.checked) list.push(badge('Еконт/Спиди'));
- if(contentYesNo.value==='yes') list.push(badge('качване съдърж.'));
- if(hasLogo.value) list.push(badge('лого: '+(hasLogo.value==='yes'?'да':'не')));
- if(seoYesNo.value==='yes') list.push(badge('SEO'));
- if(speedYesNo.value==='yes') list.push(badge('скорост'));
- const m = parseInt(maintenance.value,10)||0;
- if(m>0) list.push(badge('поддръжка '+m+'м.'));
- if(hosting.value==='1') list.push(badge('хостинг'));
- if(vatMode.value==='withvat') list.push(badge('с ДДС'));
- if(vatMode.value==='novat') list.push(badge('без ДДС'));
- if(rush.value) list.push(badge(rush.value));
- badges.innerHTML = list.join('');
- }
- function isReadyToCalculate(){
- if(!projectType.value || !designLevel.value) return false;
- const p = parseInt(pages.value||'0',10);
- if(!p || p<1) return false;
- return true;
- }
- function gatherSelections(p, langs, rushKey){
- const sel = {
- 'Тип проект': labelProject(projectType.value||''),
- 'Брой страници': p,
- 'Езици': langs || '1',
- 'Ниво на дизайн': maps.design[designLevel.value||''] || '',
- 'Е-магазин': ecom.checked ? 'Да' : 'Не'
- };
- if(ecom.checked) sel['Продукти (прибл.)'] = clampInt(products.value||'0',0,100000);
- sel['Блог'] = blog.checked ? 'Да' : 'Не';
- sel['Резервации/Записвания'] = booking.checked ? 'Да' : 'Не';
- sel['Онлайн плащания'] = payments.checked ? 'Да' : 'Не';
- sel['Куриери (Еконт/Спиди)'] = couriers.checked ? 'Да' : 'Не';
- sel['Качване на съдържание'] = maps.yn[contentYesNo.value||'no'];
- sel['Имате ли лого?'] = (hasLogo.value==='no') ? 'Не' : (hasLogo.value==='yes' ? 'Да' : '—');
- sel['SEO пакет'] = maps.yn[seoYesNo.value||'no'];
- sel['Оптимизация на скорост'] = maps.yn[speedYesNo.value||'no'];
- const m = parseInt(maintenance.value||'0',10);
- sel['Поддръжка (месеци)'] = m>0 ? m : 'Без';
- sel['Хостинг (1 година)'] = hosting.value==='1' ? 'Да' : 'Не';
- sel['ДДС'] = vatMode.value==='withvat' ? 'С ДДС (20%)' : (vatMode.value==='novat' ? 'Без ДДС' : '—');
- sel['Срок'] = maps.rush[rushKey] || maps.rush.standard;
- const note = (notes.value||'').trim();
- if(note) sel['Бележки'] = note;
- return sel;
- }
- function calculate(){
- // показване на продукти при е-магазин
- productCountRow.style.display = ecom.checked ? 'grid' : 'none';
- if(!isReadyToCalculate()){
- breakdown.innerHTML = '';
- totalBGN.textContent = '—';
- totalEUR.textContent = '—';
- badges.innerHTML = '';
- return;
- }
- const pt = projectType.value;
- const p = clampInt(pages.value,1,100);
- const langs = clampInt(languages.value||'1',1,10);
- const dl = designLevel.value;
- const isEcom = ecom.checked;
- const prodCount = clampInt(products.value||'0',0,100000);
- const hasBlog = blog.checked;
- const hasBooking = booking.checked;
- const hasPayments = payments.checked;
- const hasCouriers = couriers.checked;
- const contentYN = contentYesNo.value;
- const logo = hasLogo.value;
- const seoYN = seoYesNo.value;
- const speedYN = speedYesNo.value;
- const maintMonths = maintenance.value === '' ? 0 : clampInt(maintenance.value,0,60);
- const hasHosting = hosting.value === '1';
- const rushKey = rush.value || 'standard';
- const includeVAT = (vatMode.value === 'withvat');
- const items = [];
- const base = PRICING.baseFee[pt];
- items.push(['База ('+labelProject(pt)+')', base]);
- const perPage = PRICING.pagePrice[dl];
- const pagesCost = p * perPage;
- items.push([`Страници (${p} × ${perPage} BGN)`, pagesCost]);
- if(langs > 1){
- const extraLangs = langs - 1;
- const langAdd = Math.round(pagesCost * PRICING.multiLangFactorPerExtraLang * extraLangs);
- items.push([`Доп. езици (+${extraLangs})`, langAdd]);
- }
- if(isEcom){
- let eAdd = PRICING.ecommerce.enableAddon;
- for(const t of PRICING.ecommerce.productTiers){ if(prodCount <= t.max){ eAdd += t.add; break; } }
- items.push([`Е-магазин настройка`, eAdd]);
- }
- if(hasBlog) items.push(['Блог', PRICING.blogAddon]);
- if(hasBooking) items.push(['Резервации/Записвания', PRICING.bookingAddon]);
- if(hasPayments)items.push(['Интеграция на плащания', PRICING.paymentsAddon]);
- if(hasCouriers)items.push(['Куриери (Еконт/Спиди)', PRICING.couriersAddon]);
- if(contentYN==='yes') items.push([`Качване на съдържание`, PRICING.contentUploadYes]);
- if(logo==='no') items.push([`Изработка на лого`, PRICING.logoDesign]);
- if(seoYN==='yes') items.push([`SEO пакет`, PRICING.seoYes]);
- if(speedYN==='yes') items.push([`Оптимизация на скорост`, PRICING.speedYes]);
- if(maintMonths>0) items.push([`Поддръжка (${maintMonths} месеца)`, maintMonths * PRICING.maintenanceMonthly]);
- if(hasHosting) items.push([`Хостинг (1 година)`, PRICING.hostingYearly]);
- // междинна сума и срок
- const sub = items.reduce((a,[_t,v]) => a + v, 0);
- const mult = PRICING.rushMultiplier[rushKey] || 1;
- const baseTotal = Math.round(sub * mult);
- // ДДС
- let vat = 0, grand = baseTotal;
- if(includeVAT){
- vat = Math.round(baseTotal * VAT_RATE);
- grand = baseTotal + vat;
- }
- // рендер
- breakdown.innerHTML =
- items.map(([t,v])=>`<li><span>${escapeHtml(t)}</span><strong>${fmtBGN(v)}</strong></li>`).join('') +
- (mult>1 ? `<li><span>Коеф. срок</span><strong>× ${mult.toFixed(2)}</strong></li>` : '') +
- (includeVAT ? `<li><span>ДДС (20%)</span><strong>${fmtBGN(vat)}</strong></li>` : '');
- totalBGN.textContent = fmtBGN(grand);
- totalEUR.textContent = fmtEUR(toEUR(grand));
- updateBadges();
- // параметри за имейл/копиране
- const selections = gatherSelections(p, langs, rushKey);
- const subject = encodeURIComponent('Запитване: калкулатор за уебсайт');
- const body = encodeURIComponent(makeEmailBody(items, mult, includeVAT, vat, grand, selections));
- emailBtn.href = `mailto:[email protected]?subject=${subject}&body=${body}`;
- copyBtn.onclick = () => {
- const txt = makePlainText(items, mult, includeVAT, vat, grand, selections);
- navigator.clipboard.writeText(txt).then(()=>{
- copyBtn.textContent='Копирано!';
- setTimeout(()=>copyBtn.textContent='Копирай офертата', 1200);
- });
- };
- }
- function makeEmailBody(items, mult, includeVAT, vat, total, sel){
- const lines = [];
- lines.push('Здравей, Красимир,','','Ориентировъчна калкулация за уебсайт.','', 'Параметри:');
- for(const [k,v] of Object.entries(sel)){ lines.push(`• ${k}: ${v}`); }
- lines.push('', 'Разбивка:');
- for(const [t,v] of items){ lines.push(`• ${t}: ${v} BGN`); }
- if(mult>1) lines.push(`• Коеф. срок: × ${mult.toFixed(2)}`);
- if(includeVAT) lines.push(`• ДДС (20%): ${vat} BGN`);
- lines.push('', `ОБЩО: ${Math.round(total)} BGN (≈ ${Math.round(toEUR(total))} EUR)`, '', 'Ще се радвам да уточним детайлите и да финализираме офертата.');
- return lines.join('\n');
- }
- function makePlainText(items, mult, includeVAT, vat, total, sel){
- const lines = [];
- lines.push('Ориентировъчна оферта – уебсайт','Параметри:');
- for(const [k,v] of Object.entries(sel)){ lines.push(`${k}: ${v}`); }
- lines.push('----------------------');
- for(const [t,v] of items){ lines.push(`${t}: ${v} BGN`); }
- if(mult>1) lines.push(`Коеф. срок: × ${mult.toFixed(2)}`);
- if(includeVAT) lines.push(`ДДС (20%): ${vat} BGN`);
- lines.push('----------------------', `ОБЩО: ${Math.round(total)} BGN (≈ ${Math.round(toEUR(total))} EUR)`);
- return lines.join('\n');
- }
- // ===== ЕКСПОРТ В PDF =====
- function parseBGNtoNumber(txt){
- const n = (txt||'').replace(/[^\d,.\s]/g,'').replace(/\s/g,'');
- const i = n.lastIndexOf(',');
- const norm = i>-1 ? n.slice(0,i).replace(/[,]/g,'') + '.' + n.slice(i+1) : n.replace(/[,]/g,'');
- return Number(norm) || 0;
- }
- function exportPDF(){
- if(!isReadyToCalculate()){
- alert('Попълнете минимум: Тип проект, Брой страници и Ниво на дизайн.');
- return;
- }
- const root = document.getElementById('cost-estimator');
- const title = root.querySelector('.idi-title')?.textContent.trim() || 'Оферта – уебсайт';
- const p = clampInt(pages.value,1,100);
- const langs = clampInt(languages.value||'1',1,10);
- const rushKey = rush.value || 'standard';
- const selections = gatherSelections(p, langs, rushKey);
- const rows = [];
- root.querySelectorAll('.idi-breakdown li').forEach(li=>{
- const k = li.querySelector('span')?.textContent.trim();
- const v = li.querySelector('strong')?.textContent.trim();
- if(k && v) rows.push([k, v]);
- });
- const rowsHTML = rows.map(([k,v])=>`<tr><td>${k}</td><td class="r">${v}</td></tr>`).join('');
- const totalBGNtxt = totalBGN.textContent.trim();
- const totalBGNnum = parseBGNtoNumber(totalBGNtxt);
- const totalEURnum = Math.round(totalBGNnum / RATE_EUR);
- const selHTML = Object.entries(selections)
- .map(([k,v])=>`<div class="row"><span class="k">${k}</span><span class="v">${v}</span></div>`).join('');
- const now = new Date();
- const dateStr = new Intl.DateTimeFormat('bg-BG', {year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit'}).format(now);
- const html = `<!doctype html>
- <html lang="bg">
- <head>
- <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
- <title>${title}</title>
- <style>
- *{box-sizing:border-box}
- body{font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;margin:0;padding:24px;background:#fff;color:#111}
- .wrap{max-width:820px;margin:0 auto}
- .head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px}
- .brand{font-weight:800;font-size:20px}
- .meta{color:#666;font-size:12px}
- h2{font-size:16px;margin:18px 0 8px;color:#444}
- .grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}
- .card{border:1px solid #e6e6e6;border-radius:12px;padding:16px}
- .row{display:flex;justify-content:space-between;border-bottom:1px dashed #e6e6e6;padding:6px 0}
- .row .k{color:#444}
- .row .v{font-weight:600}
- table{width:100%;border-collapse:collapse;margin-top:6px}
- td{padding:8px 6px;border-bottom:1px solid #eee}
- td.r{text-align:right;white-space:nowrap}
- .total{font-size:20px;font-weight:900;margin-top:10px}
- .muted{color:#666;font-size:12px;margin-top:6px}
- .footer{margin-top:24px;font-size:12px;color:#666}
- @media print {.no-print{display:none}}
- </style>
- </head>
- <body onload="window.print()">
- <div class="wrap">
- <div class="head">
- <div>
- <div class="brand">${title}</div>
- <div class="meta">Генерирана: ${dateStr} • ${location.host}</div>
- </div>
- </div>
- <div class="grid">
- <div class="card">
- <h2>Параметри</h2>
- ${selHTML || '<div class="muted">Няма избрани параметри.</div>'}
- </div>
- <div class="card">
- <h2>Разбивка</h2>
- <table>${rowsHTML || '<tr><td colspan="2" class="r">—</td></tr>'}</table>
- <div class="total">ОБЩО: ${totalBGNtxt || '—'} (≈ ${isFinite(totalEURnum)? totalEURnum : '—'} EUR)</div>
- <div class="muted">Курс: 1 EUR = ${RATE_EUR} BGN</div>
- </div>
- </div>
- <div class="footer">
- * Офертата е ориентировъчна и подлежи на уточнение според обхват, съдържание, интеграции и срокове.
- </div>
- <div class="no-print" style="margin-top:16px">
- <button onclick="window.print()">Печат / Запази като PDF</button>
- </div>
- </div>
- </body>
- </html>`;
- const w = window.open('', '_blank', 'width=900,height=900');
- if(!w){ alert('Разрешете pop-up за сайта, за да се отвори PDF прозорец.'); return; }
- w.document.write(html);
- w.document.close();
- w.focus();
- }
- // ===== СЪБИТИЯ =====
- ['change','input'].forEach(evt=>{
- document.querySelectorAll('#cost-estimator select, #cost-estimator input, #cost-estimator textarea')
- .forEach(el=>el.addEventListener(evt, calculate));
- });
- projectType.addEventListener('change', ()=>{
- if(projectType.value==='ecommerce'){ ecom.checked = true; }
- calculate();
- });
- ecom.addEventListener('change', calculate);
- if (pdfBtn) pdfBtn.addEventListener('click', exportPDF);
- if(resetBtn){
- resetBtn.addEventListener('click', ()=>{
- [projectType,languages,designLevel,hasLogo,seoYesNo,speedYesNo,maintenance,hosting,vatMode,rush].forEach(sel=>{
- if(sel){ sel.selectedIndex = 0; }
- });
- pages.value = '';
- products.value = '0';
- [ecom, blog, booking, payments, couriers].forEach(cb => cb.checked = false);
- document.getElementById('productCountRow').style.display = 'none';
- breakdown.innerHTML = '';
- totalBGN.textContent = '—';
- totalEUR.textContent = '—';
- badges.innerHTML = '';
- if(notes) notes.value = '';
- });
- }
- // init
- document.querySelectorAll('#cost-estimator select, #cost-estimator input, #cost-estimator textarea')
- .forEach(el=>el.setAttribute('autocomplete','off'));
- breakdown.innerHTML=''; totalBGN.textContent='—'; totalEUR.textContent='—';
- })();
- </script>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment