Generate your Quotation

Your details

Tools required

Subtotal (0 tools)AED 0.00
",gt);if(e<0)return null; return html.slice(gt+1,e); } function parseBis(html){ var i=html.indexOf("_BISConfig.product = ");if(i<0)return null; var s=html.slice(i+21),depth=0,inStr=false,esc=false,end=-1; for(var k=0;k",a);if(gt<0)break; var e=html.indexOf("",gt);if(e<0)break; var txt=html.slice(gt+1,e);i=e+1; try{var d=JSON.parse(txt); var inv=(d&&d.inventories)||{},vars=(d&&d.product&&d.product.variants)||[]; if(vars.length){ for(var k=0;k0){s+=w._cur.pr*q;n++}}); $("kq-subv").textContent=fmt(s); $("kq-cnt").textContent="("+n+" tool"+(n===1?"":"s")+" added)"; } function addRow(){ var w=document.createElement("div");w.className="rw"; w.innerHTML='
'+ '
'+ ''+ '
'+ '
'+ ''+ ''+ '

'; $("kq-items").appendChild(w);updateSub(); var pn=w.querySelector(".pn"),dd=w.querySelector(".dd"),bs=w.querySelector(".bs"),inf=w.querySelector(".inf"),qty=w.querySelector(".qty"), ds=w.querySelector(".ds"),mq=w.querySelector(".mq"),up=w.querySelector(".up"),tp=w.querySelector(".tp"),si=w.querySelector(".kq-si"); w.querySelector(".x").onclick=function(){w.remove();updateSub()}; function fill(d){ w._cur=d||null; si.textContent=""; if(!d){ds.value=mq.value=up.value=tp.value="";qty.min=1;qty.step=1;updateSub();return} var q=parseInt(qty.value,10); ds.value=d.n||"-";mq.value="MOQ: "+d.moq;up.value=fmt(d.pr); tp.value=q>0?fmt(d.pr*q):""; qty.min=d.moq;qty.step=d.moq;updateSub(); stockStatus(d,function(s){if(w._cur!==d)return;si.textContent=s?"Stock: "+s:"";si.style.color=(s==="Out of stock")?"#cc0000":""}); } function show(d){w._it=d;pn.value=d.p;dd.style.display="none";info()} function info(){ var d=resolve(w);inf.className="inf";inf.textContent=""; if(!pn.value.trim()){fill(null);return} if(d==="amb"){fill(null);inf.textContent="Part number exists in several brands – please choose the brand.";inf.className="inf e";return} if(!d){fill(null);inf.textContent="Part number not found – pick from the suggestions.";inf.className="inf e";return} var m=ENFORCE_MOQ?d.moq:1,q=parseInt(qty.value,10),n=(!q||q1)inf.textContent="Sold in packs of "+m+" – quantity must be "+m+", "+(2*m)+", "+(3*m)+"…"+(n!==q&&q>0?" (adjusted to "+n+")":""); } pn.addEventListener("input",function(){w._it=null; var r=search(pn.value,bs.value); dd.dataset.tid=String(Number(dd.dataset.tid||0)+1);var tid=dd.dataset.tid; dd.innerHTML=r.map(function(d,i){return '
'+esc(d.p)+' '+esc(d.b)+' · '+esc(d.n.slice(0,70))+' · '+fmt(d.pr)+'
'}).join(""); dd.style.display=r.length?"block":"none"; Array.prototype.forEach.call(dd.children,function(c,i){c.onmousedown=function(e){e.preventDefault();show(r[i])}}); if(dd._stkT)clearTimeout(dd._stkT); dd._stkT=setTimeout(function(){if(dd.dataset.tid!==tid)return; Array.prototype.forEach.call(dd.children,function(c,i){stockStatus(r[i],function(s){ if(dd.dataset.tid!==tid)return;var el=dd.children[i]&&dd.children[i].querySelector(".kq-stk"); if(el){el.textContent=s?" · "+s:"";el.style.color=s==="Out of stock"?"#cc0000":""}})}); },350); info();}); pn.addEventListener("blur",function(){setTimeout(function(){dd.style.display="none"},150)}); bs.addEventListener("change",function(){w._it=null;info()}); qty.addEventListener("input",function(){var d=resolve(w);if(d&&d!=="amb")fill(d)}); qty.addEventListener("change",info); } function resolve(w){ var pn=w.querySelector(".pn").value.trim(),b=w.querySelector(".bs").value; if(!pn)return null; if(w._it&&w._it.p===pn&&(!b||w._it.b===b))return w._it; var m=exact(pn,b);return m.length===1?m[0]:(m.length>1?"amb":null); } function pdf(){ var msg=$("msg");msg.textContent=""; var c={n:$("kq-name").value.trim(),e:$("kq-email").value.trim(),p:$("kq-phone").value.trim(),l:$("kq-loc").value.trim()}; ["kq-name","kq-email","kq-phone","kq-loc"].forEach(function(i){$(i).style.borderColor=""}); function bad(id,t){$(id).style.borderColor="#cc0000";$(id).focus();msg.textContent=t} if(!c.n){bad("kq-name","Please enter your name.");return} if(!c.e){bad("kq-email","Please enter your email address.");return} if(!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(c.e)){bad("kq-email","Please enter a valid email address (e.g. name@company.com).");return} if(!c.p){bad("kq-phone","Please enter your contact number.");return} if(!/^\d{7,15}$/.test(c.p)){bad("kq-phone","Contact number must be 7 to 15 digits, numbers only.");return} if(!c.l){bad("kq-loc","Please enter your location.");return} var lines=[],rows=document.querySelectorAll("#kq-items .row"); for(var i=0;i1&&q%d.moq!==0){msg.textContent=d.p+" is sold in packs of "+d.moq+" – quantity must be "+d.moq+", "+(2*d.moq)+", "+(3*d.moq)+"…";return} lines.push({d:d,q:q});} if(!lines.length){msg.textContent="Add at least one tool.";return} var win=window.open("","_blank");if(win)win.document.write("

Preparing your quotation…

"); var ps=lines.map(function(l){return stockP(l.d).then(function(s){l.stk=s})}); Promise.all(ps).then(function(){renderPdf(lines,win,c)}); } function renderPdf(lines,win,c){ var doc=new window.jspdf.jsPDF({unit:"mm",format:"a4"}),W=doc.internal.pageSize.getWidth(); var now=new Date(); var ds=function(x){return x.toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}; var qno="Q-"+now.toISOString().slice(0,10).replace(/-/g,"")+"-"+Math.floor(1000+Math.random()*9000); doc.setProperties({title:qno});doc.setFillColor(204,0,0);doc.rect(0,0,W,24,"F");doc.setTextColor(255);doc.setFont("helvetica","bold"); doc.setFontSize(20);doc.text(COMPANY,14,15);doc.setFontSize(14);doc.text("QUOTATION",W-14,15,{align:"right"}); doc.setTextColor(30);doc.setFontSize(10);doc.text("Quote to",14,35);doc.setFont("helvetica","normal"); [c.n,c.e,c.p,c.l].forEach(function(t,i){doc.text(t,14,41+i*5.5)}); doc.setFont("helvetica","bold");doc.text("Quote no:",W-70,35);doc.text("Date:",W-70,40.5); doc.setFont("helvetica","normal");doc.text(qno,W-14,35,{align:"right"});doc.text(ds(now),W-14,40.5,{align:"right"}); var tot=0,body=lines.map(function(l,i){var a=l.d.pr*l.q;tot+=a;return [i+1,l.d.b,l.d.p,l.d.n||"-",l.stk||"-",l.q,fmt(l.d.pr),fmt(a)]}); doc.autoTable({startY:66,head:[["#","Brand","Part No.","Tool","Stock","Qty","Unit Price","Amount"]],body:body, margin:{top:18,left:14,right:14},headStyles:{fillColor:[204,0,0]},styles:{fontSize:8.5,cellPadding:2.2}, columnStyles:{0:{cellWidth:8},1:{cellWidth:20},2:{cellWidth:26},4:{cellWidth:24},5:{halign:"center",cellWidth:10},6:{halign:"right",cellWidth:23},7:{halign:"right",cellWidth:24}}, didParseCell:function(h){var L=lines[h.row.index];if(h.section==="body"&&h.column.index===3&&L&&L.d.l)h.cell.styles.textColor=[0,70,200]}, didDrawCell:function(h){if(h.section==="body"&&(h.column.index===3||h.column.index===2)){var L=lines[h.row.index];var lk=L&&L.d.l;if(lk)doc.link(h.cell.x,h.cell.y,h.cell.width,h.cell.height,{url:lk})}}}); var y=doc.lastAutoTable.finalY+9;if(y>255){doc.addPage();y=22} doc.setDrawColor(204,0,0);doc.line(W-95,y-5,W-14,y-5); doc.setFont("helvetica","bold");doc.setFontSize(11);doc.text("TOTAL",W-95,y);doc.text(fmt(tot),W-14,y,{align:"right"});doc.setFontSize(9);doc.text("Items listed: "+lines.length,14,y); y+=8;doc.setFont("helvetica","normal");doc.setFontSize(9);doc.setTextColor(90); var H=doc.internal.pageSize.getHeight(); var LW=86, RW=74, RX=W-14-RW; doc.setFont("helvetica","bold");doc.setFontSize(9); var share=doc.splitTextToSize("Please share this quotation with us via WhatsApp or email.",LW); doc.setFont("helvetica","normal");doc.setFontSize(8); var para=[];FOOT.forEach(function(t){para=para.concat(doc.splitTextToSize(t,LW))}); var lh=doc.getLineHeight()/doc.internal.scaleFactor; var leftH=share.length*4+3+para.length*lh+2+11; var rightH=7+(VAL.length+1)*5.6+9; var ty=H-12-Math.max(leftH,rightH); if(y+6>ty-6)doc.addPage(); doc.setDrawColor(204,0,0);doc.line(14,ty-4,W-14,ty-4); doc.setTextColor(30);doc.setFont("helvetica","bold");doc.setFontSize(9); doc.text(share,14,ty+1); var p0=ty+1+share.length*4+2; doc.setFont("helvetica","normal");doc.setFontSize(8);doc.setTextColor(60); doc.text(para,14,p0); var ly=p0+para.length*lh+2; doc.setTextColor(30);doc.text("WhatsApp:",14,ly);doc.text("Email:",14,ly+5.5); var x1=14+doc.getTextWidth("WhatsApp: "),x2=14+doc.getTextWidth("Email: "); doc.setTextColor(0,70,200); doc.textWithLink(WA,x1,ly,{url:"https://"+WA}); doc.textWithLink(MAIL,x2,ly+5.5,{url:"mailto:"+MAIL}); doc.setTextColor(30);doc.setFont("helvetica","bold");doc.setFontSize(9);doc.text("Price Validity",RX,ty+1); var cp={top:1,bottom:1,left:1.5,right:1.5}; doc.autoTable({startY:ty+3,head:[["Brands","Valid Till"]],body:VAL,tableWidth:74,margin:{left:RX,right:14,top:0,bottom:0},theme:"grid", headStyles:{fillColor:[204,0,0],textColor:255,fontSize:7.5,cellPadding:cp}, styles:{fontSize:7.5,cellPadding:cp,lineColor:[200,200,200],lineWidth:.15,textColor:[40,40,40]}, columnStyles:{0:{cellWidth:48,fontStyle:"bold"},1:{cellWidth:26,halign:"left"}}}); doc.setFont("helvetica","normal");doc.setFontSize(8);doc.setTextColor(0,70,200); doc.textWithLink("Delivery & Shipping",RX,doc.lastAutoTable.finalY+4.5,{url:DELIV}); var np=doc.getNumberOfPages(); for(var pg=1;pg<=np;pg++){doc.setPage(pg);doc.setFont("helvetica","normal");doc.setFontSize(8);doc.setTextColor(110);if(pg===1){if(np>1)doc.text("Page 1 of "+np+" – continued on next page",W-14,30,{align:"right"})}else doc.text(qno+" | Page "+pg+" of "+np,W-14,9,{align:"right"})} var url=URL.createObjectURL(doc.output("blob")); if(win){win.location.href=url}else{$("kq-open").href=url;$("kq-fallback").style.display="block"} } return {addRow:addRow,pdf:pdf}; })();