document.getElementById("sm_stick_price").innerHTML = '
Rozmiar naklejek (mm)
szerokość:
wysokość:
Liczba naklejek
(minimum: )
Cena brutto
zł za 1 naklejkę
Podsumowanie
Liczba naklejek:
Wymiary: x mm
Kształt:
Folia:
Laminat:
Cięcie:
Układ: x
Podgląd rozmieszczenia naklejek na folii
Szerokość folii: cm. Długość folii: cm.
'; var foilType = 'shine'; var laminat = 'nie'; var shape = 'rect'; var cut = 'ark'; var allWidth = 975; // Szerokość folii var allHeight = 500; // Minimalna wysokość folii var widthMod = 1; // Modyfikator szerokości do liczenia metra kwadratowego var selSizeId = 'size_50_30'; var selFoilType = 'shine'; var selLaminat = 'lam_nie'; var selShape = 'shape_rect'; var selCut = 'cut_ark'; var showNetto = 0; //////////////////// PARAMETRY var lamFrostyCost = 10; // Dopłata za laminat frosty za m2 var lamNormCost = 20; // Dopłata za laminat za m2 var lamHoloCost = 25; // Dopłata za laminat na folii holo za m2 var kosztObrysu = 8; // Dopłata za wykonanie obrysu - jednorazowa var cutsetPrice = 22; // Dopłata za cięcie na zestawy za m2 var cutPrice = 6.6; // Dopłata za cięcie na diecut za m2 var extracutPrice = 13.2; // Dopłata za cięcie die cut extra pole za m2 var morePrice = 5; // Dopłata jeśli liczba naklejek na metr kwadratowy jest większa niż 300 i wybrano cięcie diecut lub diecut extrapoole za m2 var shipVal = 13; // Koszt dostawy var cennikPodstawowy = { 'min': { 'len': 1000, 'price': 50 }, // Do 1m 50zł 'max': { 'len': 2000, 'price': 45 }, // Powyżej 1m 45zł. Pomiędzy będzie się zmieniało liniowo. }; var cennikHolo = { 'min': { 'len': 500, 'price': 150 }, // Do 50cm 150zł 'max': { 'len': 2000, 'price': 90 }, // Powyżej 2m 90zł. Pomiędzy będzie się zmieniało liniowo. }; var cennikBlysk = { 'min': { 'len': 500, 'price': 160 }, // Do 50cm 160zł 'max': { 'len': 2000, 'price': 100 }, // Powyżej 2m 100zł. Pomiędzy będzie się zmieniało liniowo. }; //////////////////// KOD SKRYPTU function calcStickCnt(e) { // Sprawdzam czy wymiary i liczba nklejek są liczbą. document.getElementById("sm_s_width").value = document.getElementById("sm_s_width").value.replace(/\D/g, ''); document.getElementById("sm_s_height").value = document.getElementById("sm_s_height").value.replace(/\D/g, ''); document.getElementById("sm_s_cnt").value = document.getElementById("sm_s_cnt").value.replace(/\D/g, ''); var spad = getSpad(); // Uaktualniam spad. // Sprawdzam czy szerokośc naklejki nie przekracza szerokości folii minus spady if (document.getElementById("sm_s_width").value > allWidth-(spad*2)) document.getElementById("sm_s_width").value = allWidth - (spad*2) ; var sWidth = Number(document.getElementById("sm_s_width").value); // Szerokośc naklejki var sHeight = Number(document.getElementById("sm_s_height").value); // Wysokość naklejki // Ustawiam wymiar na 10 jeśli podano mniej if (sWidth < 10) sWidth = 10; if (sHeight < 10) sHeight = 10; // Ustawiam szerokość naklejki jako wpisana wartość + spad z obu stron var sWidthB = sWidth + (spad * 2); // Szerokośc naklejki + spady //var sCntInLine = Math.floor((allWidth+(spad * 2))/sWidthB); // Liczba naklejek w linii. Pomijam spady przy krawędzi folii var sCntInLine = Math.floor(allWidth/sWidthB); // Liczba naklejek w linii. // Ustawiam szerokość naklejki jako wpisana wartość + spad z obu stron var sHeightB = sHeight + (spad * 2); // Wysokość naklejki + spady var sCntLineMin = Math.ceil(allHeight/sHeightB); // Minimalna liczba linii naklejek if (sCntLineMin % 2 !== 0 && sHeight < 150) sCntLineMin = sCntLineMin + 1; // Jeżeli minimalna liczba linii naklejek jest nieparzysta to dodaję jedną linię var sCntMin = sCntInLine * sCntLineMin; // Obliczam minimalną liczbę naklejek var sCnt = Number(document.getElementById("sm_s_cnt").value); // Wybrana liczba naklejek // Aktualizuję wpisaną liczbę naklejek jeśli jest mniejsza niż minimalna liczba naklejek dla danej folii. if ((userCnt < sCntMin || userCnt < sCnt) && document.getElementById("sm_s_cnt") != document.activeElement) { document.getElementById("sm_s_cnt").value = (userCnt > sCntMin) ? userCnt : sCntMin; sCnt = (userCnt > sCntMin) ? userCnt : sCntMin; } var sCntLine = Math.ceil(sCnt/sCntInLine); // Liczba linii naklejek var fLenBase = sHeightB * sCntLine - (spad * 2); // Długość folii potrzebna do wydrukowania naklejek. Pomijam spady przy krawędzi folii /////////// KOSZT PODSTAWOWY ZA DDŁUGOŚĆ I RODZAJ FOLII var priceMod = 0; // Cena za metr kwadratowy var cennik = cennikPodstawowy; if (foilType == 'holo') { cennik = cennikHolo; } if (foilType == 'shine60' || foilType == 'transparent60') { cennik = cennikBlysk; } if (fLenBase <= cennik['min']['len']) { // Poniżej minimalnej długości z cennika priceMod = cennik['min']['price']; } else if (fLenBase >= cennik['max']['len']) { // Powyżej maksymalnej długości z cennika priceMod = cennik['max']['price']; } else { // Pomiędzy długościami z cennika. Wyliczam kwotę proporcjonalnie. var lenCalc = fLenBase - cennik['min']['len']; var procMod = lenCalc / (cennik['max']['len'] - cennik['min']['len']); var addPriceMod = procMod * (cennik['max']['price'] - cennik['min']['price']); priceMod = cennik['min']['price'] + addPriceMod; } //console.log('Cena za metr: ' + priceMod ); var fLen = fLenBase + Math.ceil(fLenBase / 20) * 2; // Do długości folii dodaje 2cm za każde rozpoczęte bazowe 20cm folii allPrice = fLen * priceMod * widthMod / 1000; // Cena za całą długość folii // Doliczenia do ceny na rodzaj i długośc folii // Doliczam opłatę za m2 jeśli wybrano cięcie na diecut if (cut == 'die') { allPrice = allPrice + cutPrice; if (fLen > 1000) allPrice = allPrice + (Math.ceil((fLen-1000)*widthMod/1000)*cutPrice); } // Doliczam opłatę za m2 jeśli wybrano cięcie die cut extra pole if (cut == 'dieep') { allPrice = allPrice + extracutPrice; if (fLen > 1000) allPrice = allPrice + (Math.ceil((fLen-1000)*widthMod/1000)*extracutPrice); } // Doliczam opłatę za m2 jeśli wybrano cięcie na zestawy if (cut == 'set') { allPrice = allPrice + cutsetPrice; if (fLen > 1000) allPrice = allPrice + (Math.ceil((fLen-1000)*widthMod/1000)*cutsetPrice); } // Doliczam opłatę za m2 jeśli wybrano laminat if (laminat == 'tak' && foilType != 'holo') { allPrice = allPrice + lamNormCost; if (fLen > 1000) allPrice = allPrice + (((fLen-1000)/1000)*lamNormCost); } // Doliczam opłatę za m2 jeśli wybrano laminat w folii holo if (laminat == 'tak' && foilType == 'holo') { allPrice = allPrice + lamHoloCost; if ((fLen*widthMod) > 1000) allPrice = allPrice + ((((fLen*widthMod)-1000)/1000)*lamHoloCost); } // Doliczam opłatę za m2 jeśli wybrano laminat frosty if (laminat == 'fro') { allPrice = allPrice + lamFrostyCost; if (fLen > 1000) allPrice = allPrice + (((fLen-1000)/1000)*lamFrostyCost); } // Doliczam opłatę za m2 jeśli liczba naklejek na metr kwadratowy jest większa niż 300 i wybrano cięcie lub diecut ### 2023-09-06 if ((sCntInLine * Math.ceil(1000 / sHeight) > 300) && (cut == 'die' || cut == 'dieep')) { allPrice = allPrice + (Math.ceil(fLen/1000)*morePrice); } // Doliczam opłatę za wykonanie obrysu if (shape == 'other') { allPrice = allPrice + kosztObrysu; } // Doliczam koszt dostawy allPrice = allPrice + shipVal; // Dodaję VAT i zaokrąglam allPrice = Math.ceil(allPrice * 1.23); var sOnePrice = Math.round(allPrice * 100 / sCnt) / 100; // Średnia cena za pojedyńczą naklejkę document.getElementById("sm_s_cnt_min").innerHTML = sCntMin; document.getElementById("sm_f_len").innerHTML = Math.round(fLen) / 10; document.getElementById("sm_s_all_price").innerHTML = allPrice; document.getElementById("sm_s_one_price").innerHTML = sOnePrice; // Podsumowanie document.getElementById("sum_s_cnt_all").innerHTML = sCnt; document.getElementById("sum_s_w").innerHTML = sWidth; document.getElementById("sum_s_h").innerHTML = sHeight; document.getElementById("sum_laminat").innerHTML = document.getElementById('lam_'+laminat).innerHTML; document.getElementById("sum_shape").innerHTML = document.getElementById('shape_'+shape).innerHTML; document.getElementById("sum_cut").innerHTML = document.getElementById('cut_'+cut).innerHTML; document.getElementById("sum_foiltype").innerHTML = document.getElementById('ft_'+foilType).innerHTML; if (showNetto == 1) document.getElementById("sum_netto").innerHTML = 'Netto: ' + (Math.ceil(allPrice * 100 / 1.23) / 100) + '
'; document.getElementById("sum_f_col").innerHTML = sCntInLine; document.getElementById("sum_f_row").innerHTML = sCntLine; if (document.getElementsByClassName('fpf-field fpf-text') && document.getElementsByClassName('fpf-field fpf-text')[0] && document.getElementsByClassName('fpf-field fpf-text')[0].getElementsByTagName('INPUT')[0]) { document.getElementsByClassName('fpf-field fpf-text')[0].style.display = 'none'; document.getElementsByClassName('fpf-field fpf-text')[0].getElementsByTagName('INPUT')[0].value = document.getElementById("sum_text").innerText.replaceAll("\n","; "); } var prevHTML = ''; var col = 0; for(i=0;i'; if (col == sCntInLine) {col = 0; prevHTML += '
';} if (i > 1000 && col == 0) { prevHTML += '
i tak dalej...
'; break; } } document.getElementById("allPrev").innerHTML = prevHTML; document.getElementById('sm_stick_price').parentElement.parentElement.style.height = 'auto'; if (document.getElementsByName('quantity')[0]) { document.getElementsByName('quantity')[0].readOnly = true; document.getElementsByName('quantity')[0].parentElement.style.display = 'none'; document.getElementsByName('quantity')[0].parentElement.parentElement.getElementsByTagName('button')[0].style.marginLeft = '0px'; document.getElementsByName('quantity')[0].value = allPrice; } if (document.getElementById('cena')) { document.getElementById('cena').getElementsByTagName('bdi')[0].innerHTML = allPrice + ' '; } } function getSpad() { if (cut == 'die') { spad = 2.5; } else if (cut == 'dieep') { spad = 5.5; } else if (cut == 'set') { spad = 2.5; } else { spad = 1.5; } return spad; } function setUserCnt() { userCnt = Number(document.getElementById("sm_s_cnt").value); calcStickCnt(); } function setFoilType(fType) { foilType = fType; if (foilType == 'normal') { allWidth = 975; allHeight = 500; widthMod = 1; } if (foilType == 'mat') { allWidth = 975; allHeight = 500; widthMod = 1; } if (foilType == 'shine') { allWidth = 975; allHeight = 500; widthMod = 1; } if (foilType == 'inside') { allWidth = 975; allHeight = 500; widthMod = 1; } if (foilType == 'transparent') { allWidth = 975; allHeight = 500; widthMod = 1; } if (foilType == 'holo') { allWidth = 590; allHeight = 300; widthMod = 0.61; } if (foilType == 'shine60') { allWidth = 585; allHeight = 300; widthMod = 0.61; } if (foilType == 'transparent60') { allWidth = 585; allHeight = 300; widthMod = 0.61; } divW = document.getElementById("allPrev").offsetWidth; wmod = divW / allWidth; hmod = divW / allWidth; document.getElementById("divPrev").style.minHeight = ((allHeight * hmod)+4) + 'px'; document.getElementById("sm_f_width").innerHTML = Math.round(allWidth + 25) / 10; if (selFoilType != fType && document.getElementById('ft_'+selFoilType) && document.getElementById('ft_'+fType)) { document.getElementById('ft_'+selFoilType).className = ''; document.getElementById('ft_'+fType).className = 'sm-sel'; } selFoilType = fType; if (document.getElementById("sm_s_height").value < 40 && document.getElementById("sm_s_width").value < 40) { setCut(document.getElementById('cut_ark')); document.getElementById('cut_die').style.display = 'none'; document.getElementById('cut_dieep').style.display = 'none'; document.getElementById('cut_set').style.display = 'none'; } else { document.getElementById('cut_die').style.display = 'block'; document.getElementById('cut_dieep').style.display = 'block'; document.getElementById('cut_set').style.display = 'block'; } if (foilType == 'inside') { setLaminat(document.getElementById('lam_tak')); document.getElementById('lam_nie').style.display = 'none'; document.getElementById('lam_tsz').style.display = 'none'; document.getElementById('lam_bro').style.display = 'none'; document.getElementById('lam_fro').style.display = 'none'; } else if (foilType == 'shine60' || foilType == 'transparent60') { setLaminat(document.getElementById('lam_tsz')); document.getElementById('lam_tsz').style.display = 'block'; document.getElementById('lam_bro').style.display = 'block'; document.getElementById('lam_fro').style.display = foilType == 'shine60' ? 'block' : 'none'; document.getElementById('lam_nie').style.display = 'none'; document.getElementById('lam_tak').style.display = 'none'; } else { if (laminat != 'tak') setLaminat(document.getElementById('lam_nie')); document.getElementById('lam_tsz').style.display = 'none'; document.getElementById('lam_bro').style.display = 'none'; document.getElementById('lam_fro').style.display = 'none'; document.getElementById('lam_nie').style.display = 'block'; document.getElementById('lam_tak').style.display = 'block'; } calcStickCnt(); } function setLaminat(e) { var aId = e.id.split('_'); laminat = aId[1]; if (selLaminat != e.id) { document.getElementById(selLaminat).className = ''; document.getElementById(e.id).className = 'sm-sel'; } selLaminat = e.id; calcStickCnt(); } function setShape(e) { var aId = e.id.split('_'); shape = aId[1]; if (selShape != e.id) { document.getElementById(selShape).className = ''; document.getElementById(e.id).className = 'sm-sel'; } selShape = e.id; calcStickCnt(); } function setCut(e) { var aId = e.id.split('_'); cut = aId[1]; if (selCut != e.id) { document.getElementById(selCut).className = ''; document.getElementById(e.id).className = 'sm-sel'; } selCut = e.id; calcStickCnt(); } function roundSize() { document.getElementById("sm_s_width").value = Math.floor(document.getElementById("sm_s_width").value ); if (document.getElementById("sm_s_width").value > allWidth-4) document.getElementById("sm_s_width").value = allWidth-4; if (document.getElementById("sm_s_width").value < 10) document.getElementById("sm_s_width").value = 10; document.getElementById("sm_s_height").value = Math.floor(document.getElementById("sm_s_height").value); if (document.getElementById("sm_s_height").value < 10) document.getElementById("sm_s_height").value = 10; if (document.getElementById("sm_s_height").value < 40 && document.getElementById("sm_s_width").value < 40) { setCut(document.getElementById('cut_ark')); document.getElementById('cut_die').style.display = 'none'; document.getElementById('cut_dieep').style.display = 'none'; document.getElementById('cut_set').style.display = 'none'; } else { document.getElementById('cut_die').style.display = 'block'; document.getElementById('cut_dieep').style.display = 'block'; document.getElementById('cut_set').style.display = 'block'; } } function digitsOnly() { document.getElementById("sm_s_width").value = Math.floor(document.getElementById("sm_s_width").value ); if (document.getElementById("sm_s_width").value > allWidth-4) document.getElementById("sm_s_width").value = allWidth-4; if (document.getElementById("sm_s_width").value < 10) document.getElementById("sm_s_width").value = 10; document.getElementById("sm_s_height").value = Math.floor(document.getElementById("sm_s_height").value); if (document.getElementById("sm_s_height").value < 10) document.getElementById("sm_s_height").value = 10; } document.getElementById("sm_s_width").addEventListener("keyup", calcStickCnt); document.getElementById("sm_s_width").addEventListener("change", calcStickCnt); document.getElementById("sm_s_width").addEventListener("blur", roundSize); document.getElementById("sm_s_height").addEventListener("keyup", calcStickCnt); document.getElementById("sm_s_height").addEventListener("change", calcStickCnt); document.getElementById("sm_s_height").addEventListener("blur", roundSize); document.getElementById("sm_s_cnt").addEventListener("keyup", setUserCnt); document.getElementById("sm_s_cnt").addEventListener("change", setUserCnt); document.getElementById("sm_s_cnt").addEventListener("change", calcStickCnt); document.getElementById("sm_s_cnt").addEventListener("blur", calcStickCnt); addEventListener("resize", (event) => { divW = document.getElementById("allPrev").offsetWidth; wmod = divW / allWidth; hmod = divW / allWidth; document.getElementById("divPrev").style.minHeight = ((allHeight * hmod)+4) + 'px'; calcStickCnt(); }); var userCnt = 0; var divW = document.getElementById("allPrev").offsetWidth; var wmod = divW / allWidth; var hmod = divW / allWidth; document.getElementById("divPrev").style.minHeight = ((allHeight * hmod)+4) + 'px';document.getElementById('ft_holo').style.display = 'none';document.getElementById('ft_inside').style.display = 'none';document.getElementById('ft_transparent').style.display = 'none';document.getElementById('ft_mat').style.display = 'none';document.getElementById('ft_shine').style.display = 'none';setLaminat(document.getElementById('lam_tsz')); setFoilType('shine60'); calcStickCnt(); setTimeout(function() { setFoilType('shine60'); },100); document.getElementById('sm_stick_price').parentElement.parentElement.style.height = 'auto'; document.getElementById('sm_stick_price').parentElement.style.height = 'auto';