Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

!function(t){t.fn.openpos=function(){function e(){return Mustache.render("{{close_warning}..

Decoded Output download

<?  !function(t){t.fn.openpos=function(){function e(){return Mustache.render("{{close_warning}}",lang)}function a(e){t.indexedDB(D,{schema:{1:function(t){var e=(t.createObjectStore("pos",{keyPath:"key"}),t.createObjectStore("category",{keyPath:"category_id"}));e.createIndex("category_id");var a=t.createObjectStore("product",{keyPath:"product_id"});a.createIndex("upc",{unique:!1});var o=t.createObjectStore("cart",{keyPath:"id",autoIncrement:!0});o.createIndex("product_id",{unique:!1}),o.createIndex("type",{unique:!1});var n=t.createObjectStore("order",{keyPath:"id",autoIncrement:!0});n.createIndex("status",{unique:!1});var i=t.createObjectStore("tax",{keyPath:"tax_rule_id"});i.createIndex("customer_group_id",{unique:!1}),i.createIndex("tax_class_id",{unique:!1}),i.createIndex("based",{unique:!1});var r=t.createObjectStore("cart_saved",{keyPath:"id",autoIncrement:!0});r.createIndex("name",{unique:!1})}}}).done(function(){t.indexedDB(D).objectStore("pos").clear(),t.indexedDB(D).objectStore("category").clear(),t.indexedDB(D).objectStore("product").clear(),t.indexedDB(D).objectStore("tax").clear(),t.indexedDB(D).objectStore("cart").clear(),t.indexedDB(D).objectStore("cart_saved").clear()}).then(function(){o(function(){t("#container #content #content-loading").remove(),t("#content .box").show()}),void 0!=e&&e()})}function o(e){t.ajax({type:"GET",url:data_url,dataType:"json",beforeSend:function(){t("#container #content").append('<div id="content-loading">Loading....!!!! Please wait....!</div>'),t("#content .box").hide()},success:function(a){var o=t.indexedDB(D).objectStore("product"),i=t.indexedDB(D).objectStore("pos"),r=t.indexedDB(D).objectStore("category"),c=(t.indexedDB(D).objectStore("zone"),t.indexedDB(D).objectStore("tax"));t.each(a.pos,function(t,e){i.add(e)}),t.each(a.categories,function(t,e){r.add(e)}),t.each(a.products,function(t,e){o.add(e)}),t.each(a.tax,function(t,e){c.add(e)}),t("#container #content #content-loading").remove(),t("#content .box").show(),n(),t("button[value='0']").trigger("click"),u(),void 0!=e&&e()}})}function n(){t(".jcarousel ul").empty(),t(".jcarousel ul").append('<li><button id="category-btn" value="0">'+Mustache.render("{{all_category}}",lang)+"</button></li>"),t(".jcarousel").jcarousel("reload"),t.indexedDB(D).objectStore("category").each(function(e){t(".jcarousel ul").append('<li><button id="category-btn" value="'+e.value.category_id+'">'+e.value.name+"("+e.value.total+")</button></li>"),t(".jcarousel").jcarousel("reload")}),t("#categories").on("click","#category-btn",function(){var e=this;t("#categories li button").each(function(){t(this).removeClass("cat-active")}),t(e).addClass("cat-active"),0==t(e).attr("value")?r():c(t(e).attr("value"))})}function r(){t("#ajaxproducts ul").empty();var e=t.indexedDB(D).objectStore("product");e.count().done(function(a){var o=a,n=1,i="";e.each(function(e){var a="instock";e.value.quantity<=0&&(a="outstock"),i+='<div id="product-container"><div class="product-info" product-data="'+e.value.product_id+'"><div class="'+a+' product-stock">'+e.value.quantity+'</div><img src="'+e.value.image+'"><p>'+e.value.name+"</p></div></div>",(n%20==0||n==o)&&(t("#ajaxproducts ul").append('<li style="width:'+t("#ajaxproducts").width()+'px;">'+i+"</li>"),t("#ajaxproducts").jcarousel("reload"),i=""),n++})})}function c(e){t("#ajaxproducts ul").empty();var a=t.indexedDB(D).objectStore("product"),o=t.indexedDB(D).objectStore("category");o.get(e).done(function(o){var n=o.total,i=[];a.each(function(t){t.value.category_id&&-1!=t.value.category_id.indexOf(e)&&i.push(t.value)}).done(function(){var e=1,a="";for(q in i){var o="instock";i[q].quantity<=0&&(o="outstock"),a+='<div id="product-container"><div class="product-info" product-data="'+i[q].product_id+'"><div class="'+o+' product-stock">'+i[q].quantity+'</div><img src="'+i[q].image+'"><p>'+i[q].name+"</p></div></div>",(e%20==0||e==n)&&(t("#ajaxproducts ul").append('<li style="width:'+t("#ajaxproducts").width()+'px;">'+a+"</li>"),t("#ajaxproducts").jcarousel("reload"),a=""),e++}})})}function l(){var e=t.indexedDB(D).objectStore("product"),a=t.indexedDB(D).objectStore("cart");t("#ajaxproducts").on("click",".product-info",function(){var o=t(this).attr("product-data"),n=!1;e.get(o).done(function(t){a.index("product_id").each(function(e){0==t.options.length&&(n=!0,e.value.qty=e.value.qty+1,e.value.subtotal=String(parseFloat(e.value.subtotal)+parseFloat(e.value.price)),a.put(e.value).done(function(){u()}))},o).done(function(){n||e.get(o).done(function(t){_(t.product_id,1,function(e){var o=new Object;o.price=e.price,o.price_no_opt=e.price,o.base_price=e.base_price,o.qty=1,o.dummy=t.dummy,o.name=t.name,o.model=t.model,o.point=t.points,o.type="product",o.product_id=t.product_id,o.options=new Array,o.subtotal=e.price,o.tax_class_id=t.tax_class_id,o.tax=new Object,o.tax.total=0,o.tax.tax=new Array,o.tax.modified=!1,a.add(o).done(function(t){y(t,function(){u()})}).then(function(){})})})})})})}function u(){var e=t.indexedDB(D).objectStore("cart"),a=t.indexedDB(D).objectStore("product");t("#product-cart-list table").empty(),t("#product-cart-list").jScrollPane({showArrows:!0}).data("jsp").scrollToBottom(),e.index("type").each(function(e){var o=e.value.product_id,n=0;e.value.tax.total&&(n=e.value.tax.total),a.get(o).done(function(a){h(e.value.base_price,function(o){h(e.value.price,function(r){h(e.value.subtotal,function(c){h(n,function(l){var u="";if(o!=r&&(u='<p><span id="old_price">'+o+"</span></p>"),1==e.value.dummy){var d=config.currency.number_format;r='<input type="text" name="item_price" item_id="'+e.value.id+'" id="item_price" value="'+numeral(e.value.price).format(d)+'">'}if(parseFloat(n)>0)var s='<tr id="row-'+e.value.id+'"><td class="del-col" product-data="'+e.value.id+'">x</td><td class="product-col"><p>'+a.name+'</p></td><td class="price-col"><p>'+r+"</p>"+u+'</td><td class="tax-col"><button type="button" product-data="'+e.value.id+'">'+l+'</button></td><td class="qty-col"><div id="qty-plus" product-data="'+e.value.id+'"></div><input type="text" id="input-qty" name="qty" value="'+e.value.qty+'"/><div id="qty-less" product-data="'+e.value.id+'"></div></td><td class="subtotal-col">'+c+'</td><td class="non-option-col" product-data="'+e.value.id+'"></td></tr>';else var s='<tr id="row-'+e.value.id+'"><td class="del-col" product-data="'+e.value.id+'">x</td><td class="product-col"><p>'+a.name+'</p></td><td class="price-col"><p>'+r+"</p>"+u+'</td><td class="tax-col">'+l+'</td><td class="qty-col"><div id="qty-plus" product-data="'+e.value.id+'"></div><input type="text" id="input-qty" name="qty" value="'+e.value.qty+'"/><div id="qty-less" product-data="'+e.value.id+'"></div></td><td class="subtotal-col">'+c+'</td><td class="non-option-col" product-data="'+e.value.id+'"></td></tr>';if(a.options.length>0){var p=e.value.options,v=new Array,m=new Array,f=!0;for(i in p){var _=p[i];m.push(_.product_option_id)}console.log(a.options);for(i in a.options){var _=a.options[i];("select"==_.type||"radio"==_.type||"checkbox"==_.type)&&1==_.required&&v.push(_.product_option_id)}if(v.length>0)for(i in v)-1==m.indexOf(v[i])&&(f=!1);var h="";f||(h='class="require"');var y="";if(e.value.options.length>0){y+='<p id="option_str">';for(i in e.value.options){var g=e.value.options[i];y+=g.name+": "+g.value+"; "}y+="</p>"}s=parseFloat(n)>0?"<tr "+h+' id="row-'+e.value.id+'"><td class="del-col" product-data="'+e.value.id+'">x</td><td class="product-col"><p>'+a.name+"</p>"+y+'</td><td class="price-col"><p>'+r+"</p>"+u+'</td><td class="tax-col"><button type="button" product-data="'+e.value.id+'">'+l+'</button></td><td class="qty-col"><div id="qty-plus" product-data="'+e.value.id+'"></div><input type="text" id="input-qty" name="qty" value="'+e.value.qty+'"/><div id="qty-less" product-data="'+e.value.id+'"></div></td><td class="subtotal-col">'+c+'</td><td class="option-col" product-data="'+e.value.id+'"></td></tr>':"<tr "+h+'  id="row-'+e.value.id+'"><td class="del-col" product-data="'+e.value.id+'">x</td><td class="product-col"><p>'+a.name+"</p>"+y+'</td><td class="price-col"><p>'+r+"</p>"+u+'</td><td class="tax-col">'+l+'</td><td class="qty-col"><div id="qty-plus" product-data="'+e.value.id+'"></div><input type="text" id="input-qty" name="qty" value="'+e.value.qty+'"/><div id="qty-less" product-data="'+e.value.id+'"></div></td><td class="subtotal-col">'+c+'</td><td class="option-col" product-data="'+e.value.id+'"></td></tr>'}t("#product-cart-list table").append(s),t("#product-cart-list").jScrollPane({showArrows:!0}).data("jsp").scrollToBottom()})})})})})},"product").then(function(){b(),t("#scancode").focus()})}function d(e){var a=t.indexedDB(D).objectStore("order");if(e.length>0){t("#status").removeClass("ok").addClass("lock");for(i in e){var o=e[i];if(0==o.status){o.status=2,a.put(o).done(function(){t.ajax({type:"POST",url:data_url,dataType:"json",data:{action:"order",data:JSON.stringify(o)},beforeStart:function(){t("#status").removeClass("ok").addClass("lock")},success:function(){e.shift(),d(e)},error:function(){o.status=0,a.put(o).done(function(){d(e)})}})});break}}}else t("#status").removeClass("lock").addClass("ok")}function s(){var e=t.indexedDB(D).objectStore("cart"),a=t.indexedDB(D).objectStore("product"),o=t.indexedDB(D).objectStore("order"),n=new Array;setInterval(function(){o.index("status").each(function(t){n.push(t.value)},0).then(function(){d(n)})},5e3),setInterval(function(){o.index("status").each(function(t){var e=new Date,a=Math.round(e.getTime()/1e3);if(t.value.created_time||(t.value.created_time=0),a-parseInt(t.value.created_time)>86400){var n=t.value.id;o.delete(parseInt(n))}},2)},1e3),t("#botbuttons #cancel").click(function(){var a=t("<div>"+Mustache.render("{{clear_cart_warning}}",lang)+"</div>");a.dialog({title:Mustache.render("{{clear_cart_title}}",lang),modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t(this);e.clear().done(function(){t("#total_paid input").val("0"),u(),a.dialog("close").remove()})},Cancel:function(){return t(this).dialog("close").remove(),!1}}})}),t("#pro-col-header .del-col").click(function(){t("#botbuttons #cancel").trigger("click")}),t("#product-cart-list").on("click",".del-col",function(){if(t(this).attr("product-data")){var a=t(this).attr("product-data");e.delete(parseInt(a)).done(function(){u()})}}),t("#product-cart-list").on("click","#qty-plus",function(){if(t(this).attr("product-data")){var a=t(this).attr("product-data");e.get(parseInt(a)).done(function(t){var a=t.qty+1;_(t.product_id,a,function(o){var n=parseFloat(o.price)*parseInt(a),i=o.price;t.options.length>0&&(t.opt_total_price&&(i=parseFloat(o.price)+parseFloat(t.opt_total_price),n=i*parseInt(a)),t.opt_total_price&&parseFloat(o.price)>parseFloat(parseFloat(t.price)-parseFloat(t.opt_total_price))&&(n=parseFloat(t.price)*parseInt(a),i=t.price)),t.price=i,t.qty=a,t.subtotal=n,e.put(t).done(function(){u()})})})}}),t("#product-cart-list").on("click","#qty-less",function(){if(t(this).attr("product-data")){var a=t(this).attr("product-data");e.get(parseInt(a)).done(function(t){if(t.qty>0){var a=t.qty-1;_(t.product_id,a,function(o){var n=parseFloat(o.price)*parseInt(a),i=o.price;t.options.length>0&&(t.opt_total_price&&(i=parseFloat(o.price)+parseFloat(t.opt_total_price),n=i*parseInt(a)),t.opt_total_price&&parseFloat(o.price)>parseFloat(parseFloat(t.price)-parseFloat(t.opt_total_price))&&(n=parseFloat(t.price)*parseInt(a),i=t.price)),t.price=i,t.qty=a,t.subtotal=n,e.put(t).done(function(){u()})})}})}}),t("#product-cart-list").on("click",".option-col",function(){if(t(this).attr("product-data")){var e=parseInt(t(this).attr("product-data"));m(e,function(a){f(a.product_id,function(o){var n=o.options,r=a.options,c='<div><form id="option-'+e+'">',l=new Array,d="";for(i in n){var s=n[i],p=new Array;for(j in r){var m=r[j];m.product_option_id==s.product_option_id&&p.push(m.product_option_value_id)}if(1==s.required&&(l.push(s.option_id),d='<span id="require">*</span>'),"select"==s.type){c+='<div class="select-option" id="option_'+s.product_option_id+'">'+s.name+d+': <select name="option_'+s.product_option_id+'">';for(j in s.option_value){var f=s.option_value[j],_="";if(_=p.indexOf(f.option_value_id)>-1?' selected="selected" ':"",f.price){var h=config.currency.number_format,y=numeral(f.price).format(h);c+="<option "+_+' value="'+f.option_value_id+'">'+f.name+"("+f.price_prefix+y+")</option>"}else c+="<option "+_+' value="'+f.option_value_id+'">'+f.name+"</option>"}c+="</select></div>"}if("radio"==s.type){c+='<div class="radio-option">'+s.name+":<ul>";for(k in s.option_value){var f=s.option_value[k],_="";if(_=p.indexOf(f.option_value_id)>-1?' checked="checked" ':"",f.price){var h=config.currency.number_format,y=numeral(f.price).format(h);c+="<li><input  "+_+'  type="radio" name="option_'+s.product_option_id+'" value="'+f.option_value_id+'">'+f.name+"("+f.price_prefix+y+")</li>"}else c+="<li><input  "+_+'  type="radio" name="option_'+s.product_option_id+'" value="'+f.option_value_id+'">'+f.name+"</li>"}c+="</ul></div>"}if("checkbox"==s.type){c+='<div class="checkbox-option">'+s.name+":<ul>";for(k in s.option_value){var f=s.option_value[k],_="";_=p.indexOf(f.option_value_id)>-1?' checked="checked" ':"";var h=config.currency.number_format,y=numeral(f.price).format(h);c+="<li> <input  "+_+' type="checkbox" name="option_'+s.product_option_id+'" value="'+f.option_value_id+'">'+f.name+"("+f.price_prefix+y+") </li>"}c+="</ul></div>"}}c+="</form></div>",t(c).dialog({title:o.name,modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=o.options,n=t("form#option-"+e).serializeArray(),r=new Array,c=t(this);for(i in n){var l=n[i],d=new Object,s=l.name.split("_");d.product_option_id=s[1],d.product_option_value_id=l.value;for(j in a){var p=a[j];if(p.product_option_id==s[1]){d.name=p.name,d.type=p.type;for(k in p.option_value){var m=p.option_value[k];m.option_value_id==d.product_option_value_id&&(d.value=m.name,d.price_prefix=m.price_prefix,d.price=m.price)}}}r.push(d)}v(e,r,function(){u(),c.dialog("close").remove()})},Cancel:function(){return t(this).dialog("close").remove(),!1}}})})})}}),t("#product-cart-list").on("click",".tax-col button",function(){var a=t(this).attr("product-data"),o='<div><div id="tax_popup"><form id="tax_form" onsubmit="return false;"><ul>';e.get(parseInt(a)).done(function(e){var a=e.tax,n=config.currency.number_format;for(i in a.tax){var r=a.tax[i],c=numeral(r.tax_price).format(n);o+='<li><div id="tax-title">'+r.name+':</div><div id="tax-value">'+c+"</div></li>"}numeral(e.total).format(n);o+="</ul></form></div></div>",t(o).dialog({title:"Tax Details",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Cancel:function(){return t(this).dialog("close").remove(),!1}}})})}),t("#totaldiv").on("click","#discount_button",function(){var a='<div><div id="discount-message"></div><form id="discount_form" onSubmit="return false;"><ul>';a+='<li><input type="radio" name="discount" value="egift"/>Use Gift Card</li>',e.index("type").each(function(e){e.value.id!=parseInt(config.default_customer.customer_id)&&(a='<li><input type="radio" name="discount" value="coupon"/>Use Reward Point</li>',t("li#custom").after(a))},"customer"),a+='<li id="custom"><input type="radio" name="discount" value="custom"/>Custom</li>',a+='<li id="dicount_input"></li>',a+="</ul></form></div>",t(a).dialog({title:"Discount Details",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t("input:radio[name='discount']:checked").val(),o=t(this);if("egift"==a){var n=t("input[name='egift_code']").val();""==n?t("#discount-message").html("Please enter your gift voucher code!"):t.ajax({url:data_url,type:"GET",data:{action:"checkegift",code:n},dataType:"json",success:function(a){if(0==a.status)t("#discount-message").html("Your gift voucher code invalid !");else{var n=!1;e.index("type").each(function(t){n=!0;var i=t.value;i.value.egift=a.info,e.put(i).done(function(){u(),o.dialog("close").remove()})},"discount").then(function(){n||(tmp=new Object,tmp.type="discount",tmp.value=new Array,tmp.value.egift=a.info,e.add(tmp).done(function(){u(),o.dialog("close").remove()}))})}}})}if("custom"==a){var i=t("input[name='coupon_code']").val(),r=t("select[name='custom_type']").val();if(""==i)t("#discount-message").html("Please enter discount amount!");else{var c=!1;e.index("type").each(function(t){c=!0;var a=t.value,n=new Object;n.type=r,n.price=i,n.total=(r="F")?i:0,a.value.custom=n,e.put(a).done(function(){u(),o.dialog("close").remove()})},"discount").then(function(){if(!c){tmp=new Object,tmp.type="discount",tmp.value=new Array;var t=new Object;t.type=r,t.price=i,t.total=(r="F")?i:0,tmp.value.custom=t,e.add(tmp).done(function(){u(),o.dialog("close").remove()})}})}}},Cancel:function(){return t(this).dialog("close").remove(),!1}}}),t("input:radio[name='discount']").click(function(){var e=t("input:radio[name='discount']:checked").val();"custom"==e&&t("#dicount_input").html('<input type="text" placeholder="Enter amount" name="coupon_code" value="" id="coupon_code"><select name="custom_type"><option value="F">fixed</option><option value="P">Pecentage</option></select>'),"egift"==e&&t("#dicount_input").html('<input type="text" placeholder="Enter your gift voucher code here" name="egift_code" value="" id="egift_code">')})}),t("#totaldiv").on("click","#customer_button",function(){var o="",n="",i="",r="",c=0,l=0,d='checked="checked"';e.index("type").each(function(t){var e=t.value;c=e.value.customer_id,l=e.value.customer_group_id,o=e.value.firstname,n=e.value.lastname,i=e.value.email,r=e.value.telephone,comment_str=e.comment,d=""},"customer").then(function(){var s='<div><div id="errormsg"></div><form id="customer_form" onSubmit="return false;">';s+='<div id="search_customer"><input type="text" id="customer-text" name="value" value="" placeholder="Enter name, phone, email to search"></div>',s+='<input id="customer_id" name="customer_id" type="hidden" value="'+c+'">',s+='<input id="customer_group_id" name="customer_group_id" type="hidden" value="'+l+'">';var p='<ul id="new-customer-form">';p+='<li><div id="label">First Name:</div><div id="input"><input type="text" name="firstname" value="'+o+'" /></div></li>',p+='<li><div id="label">Last Name:</div><div id="input"><input type="text" name="lastname" value="'+n+'"/></div></li>',p+='<li><div id="label">Email:</div><div id="input"><input type="text" name="email" value="'+i+'"/></div></li>',p+='<li><div id="label">Phone Number:</div><div id="input"><input type="text" name="telephone" value="'+r+'"/></div></li>',p+='<li><input type="checkbox" '+d+' name="new_customer" value="1">Create new account ?</li>',p+="</ul>",s+='<div id="search_customer_result">'+p+"</div>",s+="</form></div>",t(s).dialog({title:"Customer Details",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var o=t("input[name=firstname]").val(),n=t("input[name=lastname]").val(),i=t("input[name=email]").val(),r=t("input[name=telephone]").val(),c=t("input[name=new_customer]").val(),l=t("input[name=customer_id]").val(),d=t("input[name=customer_group_id]").val(),s=!1,p=t(this);return w(i)?""==r?(t("#errormsg").html('<span style="color:red;">Phone number can not empty.</span>'),!1):void e.index("type").each(function(t){s=!0;var a=t.value;tmp=new Object,tmp.id=a.id,tmp.type="customer",tmp.value=new Object,tmp.value.customer_id=l,tmp.value.firstname=o,tmp.value.lastname=n,tmp.value.email=i,tmp.value.telephone=r,tmp.value.createnew=c,tmp.value.customer_group_id=d,a=tmp,e.put(a).done(function(){u(),p.dialog("close").remove()})},"customer").then(function(){s||(tmp=new Object,tmp.type="customer",tmp.value=new Object,tmp.value.customer_id=l,tmp.value.firstname=o,tmp.value.lastname=n,tmp.value.email=i,tmp.value.telephone=r,tmp.value.createnew=c,tmp.value.customer_group_id=d,e.add(tmp).done(function(){e.index("type").each(function(t){var o=t.value;a.get(o.product_id).done(function(t){if(t.special.length>0){var a=t.special,n=new Array;for(var i in a)if(a[i].customer_group_id==d){var r=new Date,c=r.getDate(),l=r.getMonth()+1,s=r.getFullYear();parseInt(c)<10&&(c="0"+c),parseInt(l)<10&&(l="0"+l);var p=a[i].date_start,v=a[i].date_end,m=s+"-"+l+"-"+c;(new Date(m).getTime()>new Date(p).getTime()||"0000-00-00"==p)&&(new Date(m).getTime()<new Date(v).getTime()||"0000-00-00"==v)&&n.push(a[i])}if(n.length>0){var f=F(n,"priority"),_=f[0].price;o.price_no_opt=_;var h=o.options,g=0;if(h.length>0)for(i in h){var b=h[i];b.price&&("+"==b.price_prefix?(_=parseFloat(_)+parseFloat(b.price),g=parseFloat(g)+parseFloat(b.price)):(_=parseFloat(_)-parseFloat(b.price),g=parseFloat(g)-parseFloat(b.price)))}o.price=_,o.opt_total_price=g,o.subtotal=o.price*o.qty+o.tax.total,e.put(o).done(function(){y(o.id,function(){u()})})}}})},"product"),u(),p.dialog("close").remove()}))}):(t("#errormsg").html('<span style="color:red;">Your email incorrect.</span>'),!1)},Cancel:function(){return t(this).dialog("close").remove(),!1}}}),t("#customer-text").autocomplete({source:function(e,a){t.ajax({url:data_url,dataType:"json",data:{action:"customersearch",term:e.term},success:function(e){a(t.map(e,function(e){t("<div />").html(e.label);return{label:e.label,value:e.label,email:e.email,telephone:e.telephone,firstname:e.firstname,lastname:e.lastname,customer_id:e.value,customer_group_id:e.customer_group_id}}))}})},minLength:2,select:function(e,a){console.log(a);var o=a.item;t("input[name=firstname]").val(o.firstname),t("input[name=lastname]").val(o.lastname),t("input[name=email]").val(o.email),t("input[name=email]").attr("disabled","disabled"),t("input[name=telephone]").val(o.telephone),t("input[name=customer_id]").val(o.customer_id),t("input[name=customer_group_id]").val(o.customer_group_id),t("input[name=new_customer]").removeAttr("checked")},open:function(){t(this).removeClass("ui-corner-all").addClass("ui-corner-top")},close:function(){t(this).removeClass("ui-corner-top").addClass("ui-corner-all")}})})}),t("#totaldiv").on("click","#order_comment",function(){var a="";e.index("type").each(function(t){check=!0;var e=t.value;a=e.comment},"comment").then(function(){var o=t('<div id="commentbox"><textarea style="width:262px;" id="order_comment_textarea">'+a+"</textarea></div>");o.dialog({title:"Comment Details",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t("#order_comment_textarea").val(),o=!1,n=t(this);e.index("type").each(function(t){o=!0;var i=t.value;i.comment=a,e.put(i).done(function(){u(),n.dialog("close").remove()})},"comment").then(function(){o||(tmp=new Object,tmp.type="comment",tmp.comment=a,e.add(tmp).done(function(){u(),n.dialog("close").remove()}))})},Cancel:function(){return t(this).dialog("close").remove(),!1}}})})}),t("input[name='total_paid']").change(function(){var e=t("input[name='total_paid']").val(),a=config.currency.number_format,o=numeral(e).format(a),n=t("#total_able span").attr("total");t("input[name='total_paid']").val(o);var i=numeral(parseFloat(e)-parseFloat(n)).format(config.currency.default_format);t("#refund_value span").html(i)}),t("#botbuttons button#hold").click(function(){var a=t('<div><div id="discount-message"></div><input type="text" id="hold_name" name="hold_name" placeholder="Enter your hold name"></div>');a.dialog({title:"Hold Cart",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t(this),o=t("#hold_name").val();if(""==o)t("#discount-message").html("Please enter your hold name.");else{var n=t.indexedDB(D).objectStore("cart_saved"),i=new Array;e.each(function(t){i.push(t.value)}).done(function(){var r=new Object;r.name=o,r.data=i;var c=new Date,l=c.getDate()+"/"+c.getMonth()+"/"+c.getFullYear()+" "+c.getHours()+":"+c.getMinutes();r.time=l,n.add(r).done(function(){e.clear().done(function(){t("#total_paid input").val("0"),u(),a.dialog("close").remove()})})})}},Cancel:function(){return t(this).dialog("close").remove(),!1}}})}),t("#saved_count").click(function(){var a=t.indexedDB(D).objectStore("cart_saved"),o=Math.floor(100*Math.random()+1),n='<div><table id="cart_saved_list" class="cart_saved_'+o+'" width="100%">';n+="<tr><th>Name</th><th>Date Created</th><th>Action</th></tr>",a.each(function(t){n+='<tr><td><a href="javascript:void(0);" id="item_saved_name" data="'+t.value.id+'">'+t.value.name+"</a></td><td>"+t.value.time+'</td><td><a id="item_saved_delete" href="javascript:void(0);" data="'+t.value.id+'">delete</a></td></tr>'}).done(function(){n+="</table></div>",t(n).dialog({title:"Hold Cart",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Cancel:function(){return t(this).dialog("close").remove(),!1}}}),t(".cart_saved_"+o).on("click","#item_saved_name",function(){var o=t(this).attr("data");a.get(parseInt(o)).done(function(a){e.clear().done(function(){t("#total_paid input").val("0");for(i in a.data){var o=a.data[i];o.type&&e.add(o).done(function(){})}})}).then(function(){u()})}),t(".cart_saved_"+o).on("click","#item_saved_delete",function(){var e=t(this).attr("data"),o=t(this);a.delete(parseInt(e)).done(function(){o.closest("tr").hide(),u()})})})}),t("button#payment").click(function(){var a=parseFloat(numeral().unformat(t("#total-payable").attr("total"))),o=t('input[name="total_paid"]').val(),n=parseFloat(numeral().unformat(o))-parseFloat(a),r="";if(0==parseFloat(a)){var r="<div><center>"+Mustache.render("{{checkout_cart_empty_warning}}",lang)+"</center></div>";t(r).dialog({title:Mustache.render("{{checkout_warning}}",lang),modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Cancel:function(){return t(this).dialog("close").remove(),!1}}})}else{var c=t("#product-cart-list tr.require").length;if(c>0){var r="<div><center>"+Mustache.render("{{checkout_product_option_require_warning}}",lang)+"</center></div>";t(r).dialog({title:Mustache.render("{{checkout_warning}}",lang),modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Cancel:function(){return t(this).dialog("close").remove(),!1}}})}else{{var l=new Array;t(this)}e.each(function(t){l.push(t.value)}).done(function(){var r=new Object;r.grand_total=a,r.total_paid=numeral().unformat(o),r.balance=n,r.data=l;var c=new Date((new Date).getTime()-(72e5+6e4*(new Date).getTimezoneOffset()));c=new Date,r.invoice_id=Math.round(c.getTime()/1e3),r.created_time=Math.round(c.getTime()/1e3),r.status=0,r.store_id=config.store.store_id,r.default_customer=config.default_customer,r.cash_user_id=config.cash_user_id;var u=new Array,d=new Array,s=0;for(i in l){if("discount"==l[i].type){if(l[i].value.coupon){var v=new Object;v.type="coupon",v.value=l[i].value.coupon,u.push(v)}if(l[i].value.egift){var v=new Object;v.type="egift",v.value=l[i].value.egift,u.push(v)}if(l[i].value.custom){var v=new Object;v.type="custom",v.value=l[i].value.custom,u.push(v)}}if("product"==l[i].type){s+=l[i].tax.total;for(j in l[i].tax.tax){var m=l[i].tax.tax[j],f=!1;for(k in d)if(m.tax_rate_id==d[k].tax_rate_id){d[k].total=d[k].total+m.tax_price*l[i].qty;var f=!0}f||(m.total=m.tax_price*l[i].qty,d.push(m))}}}r.tax_total=s,r.tax=d,r.discount=u;var _=(new Date,config.currency.default_format,0),u=0;for(i in r.data){var h=r.data[i];if("product"==h.type){if(h.options.length>0){var y="";for(j in h.options){var g=h.options[j];y=g.name+": "+g.value+"; "}}_+=parseFloat(h.subtotal)}}for(i in r.discount){var b=r.discount[i];u+="custom"==b.type?"P"==b.value.type?_*b.value.price/100:b.value.price:b.value.amount}var x=t.indexedDB(D).objectStore("pos");x.get("quick_checkout").done(function(a){x.get("default_payment").done(a&&1==a.value?function(a){var o=!1;if(a&&a.value>0){for(i in payment)if(item=payment[i],console.log(payment),a.value==item.payment_id){o=item;var n=o.payment_id,c="",l=o.payment_name,u=new Array,d=t(this),s=new Object;s.name=n,s.id=n,s.ref=c,s.title=l,r.payment=s,r.cashier=cashier_name,e.each(function(t){u.push(t.value)}).done(function(){p(r,d,u)})}}else alert("Please choose 1 default payment method.")}:function(a){var o="<div id='panel-payment'><div id='discount-message'></div><form id='payment_method'><ul>";for(i in payment){var n=payment[i];o+=a?a.value==n.payment_id?'<li><input type="radio" name="pay" id="pay-'+n.payment_id+'" checked="checked" value="'+n.payment_id+'" title="'+n.payment_name+'"><button type="button" onClick="setPayment('+n.payment_id+');">'+n.payment_name+"</button></li>":'<li><input type="radio" name="pay" id="pay-'+n.payment_id+'" value="'+n.payment_id+'" title="'+n.payment_name+'"><button  type="button" onClick="setPayment('+n.payment_id+');">'+n.payment_name+"</button></li>":0==i?'<li><input type="radio" id="pay-'+n.payment_id+'" name="pay" checked="checked" value="'+n.payment_id+'" title="'+n.payment_name+'"><button  type="button" onClick="setPayment('+n.payment_id+');">'+n.payment_name+"</button></li>":'<li><input type="radio" id="pay-'+n.payment_id+'" name="pay" value="'+n.payment_id+'" title="'+n.payment_name+'"><button  type="button" onClick="setPayment('+n.payment_id+');">'+n.payment_name+"</buton></li>"}o+='<li id="payment_ref">'+Mustache.render("{{payment_ref}}",lang)+'<input type="text" name="pay_ref" value=""></li>',o+="</ul></form></div>",t(o).dialog({title:Mustache.render("{{payment_method_title}}",lang),modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Checkout:function(){var a=t('input[name="pay"]:checked').val(),o=t('input[name="pay_ref"]').val(),n=t('input[name="pay"]:checked').attr("title");if(null==a)t("#discount-message").html(Mustache.render("{{payment_method_warning}}",lang));else{var i=new Array,c=t(this),l=new Object;l.name=a,l.id=a,l.ref=o,l.title=n,r.payment=l,r.cashier=cashier_name,e.each(function(t){i.push(t.value)}).done(function(){p(r,c,i)})}},Cancel:function(){return t(this).dialog("close").remove(),!1}}})})})})}}}),t("form#barcode_scanner").on("submit",function(){var a=t("input#scancode").val().toLowerCase(),o=t.indexedDB(D).objectStore("product");return o.index("upc").each(function(a){var o=a.value,n=a.value.product_id,i=!1;e.index("product_id").each(function(a){0==o.options.length&&(i=!0,a.value.qty=a.value.qty+1,a.value.subtotal=String(parseFloat(a.value.subtotal)+parseFloat(a.value.price)),e.put(a.value).done(function(){u(),t("input#scancode").val("")}))},n).done(function(){i||_(o.product_id,1,function(a){var n=new Object;n.price=a.price,n.price_no_opt=a.price,n.base_price=a.base_price,n.qty=1,n.name=o.name,n.model=o.model,n.point=o.points,n.type="product",n.product_id=o.product_id,n.options=new Array,n.subtotal=a.price,n.tax_class_id=o.tax_class_id,n.tax=new Object,n.tax.total=0,n.tax.tax=new Array,n.tax.modified=!1,e.add(n).done(function(t){y(t,function(){u()})}).then(function(){t("input#scancode").val("")})})})},a),!1}),t("#scancode").autocomplete({source:function(e,a){var o=e.term.toLowerCase(),n=t.indexedDB(D).objectStore("product"),i=new Array;n.each(function(t){var e=t.value;(-1!=String(e.name).toLowerCase().search(o)||-1!=String(e.model).toLowerCase().search(o)||-1!=String(e.upc).toLowerCase().search(o))&&i.push(e)}).done(function(){var e=t("input#scancode").val().toLowerCase();a(t.map(i,function(e){t("<div />").html(e.name);return{label:e.name,value:e.upc,product_id:e.product_id}})),1==i.length&&i[0].upc==e&&t("#scancode").autocomplete("close")})},minLength:2,select:function(t,e){e.item},open:function(){t(this).removeClass("ui-corner-all").addClass("ui-corner-top")},close:function(){t("form#barcode_scanner").trigger("submit"),t(this).removeClass("ui-corner-top").addClass("ui-corner-all"),t("#scancode").autocomplete("instance")}}),t("#refund a").click(function(){var e=t.indexedDB(D).objectStore("order"),a="";a+='<div class="order-list-panel">',a+='<div class="jcarousel-orders-wrapper">',a+='<div class="jcarousel-orders"><ul>';var o=new Array;e.each(function(t){var e=t.value,a=new Date(1e3*e.invoice_id),n="Guest";null!=e.default_customer.customer_id&&(n=e.default_customer.firstname+" "+e.default_customer.lastname);var i=e.payment.title,r=e.cashier,c=config.currency.default_format;thml=void 0!=typeof e.is_cancel&&parseInt(e.is_cancel)>0?"<tr><td>"+e.invoice_id+"</td><td>"+n+"</td><td>"+numeral(e.grand_total).format(c)+"</td><td>"+numeral(e.total_paid).format(c)+"</td><td>"+e.balance+"</td><td>"+i+"</td><td>"+r+"</td><td>"+a.getDate()+"/"+(a.getMonth()+1)+"/"+a.getFullYear()+"</tr>":"<tr><td>"+e.invoice_id+"</td><td>"+n+"</td><td>"+numeral(e.grand_total).format(c)+"</td><td>"+numeral(e.total_paid).format(c)+"</td><td>"+e.balance+"</td><td>"+i+"</td><td>"+r+"</td><td>"+a.getDate()+"/"+(a.getMonth()+1)+"/"+a.getFullYear()+"</td></tr>",o.push(thml) 
}).then(function(){var e="<thead><tr><th>Invoice</th><th>Customer</th><th>Grand Total</th><th>Total Paid</th><th>Balance</th><th>Payment</th><th>Cashier</th><th>Time</th></tr></thead>",n='<li><table width="650">'+e;o.reverse();for(var i in o){var r=parseInt(i)+1;console.log(r),n+=r%6==0?i==o.length-1?o[i]+"</table></li>":o[i]+'</table></li><li><table width="650">'+e:i==o.length-1?o[i]+"</table></li>":o[i]}a+=n+"</ul></div>",a+="</div>",a+='<div class="pagination-control">',a+='<a href="javascript:void(0);" class="orders-jcarousel-control-prev">&lsaquo;</a>',a+='<a href="javascript:void(0);" class="orders-jcarousel-control-next">&rsaquo;</a>',a+="</div>",a+="</div>",t(a).dialog({title:"Orders List",minHeight:300,minWidth:700,modal:!0,create:function(){t(".jcarousel-orders").jcarousel(),t(".orders-jcarousel-control-prev").on("jcarouselcontrol:active",function(){t(this).removeClass("inactive")}).on("jcarouselcontrol:inactive",function(){t(this).addClass("inactive")}).jcarouselControl({target:"-=1"}),t(".orders-jcarousel-control-next").on("jcarouselcontrol:active",function(){t(this).removeClass("inactive")}).on("jcarouselcontrol:inactive",function(){t(this).addClass("inactive")}).jcarouselControl({target:"+=1"})}})})}),t("body").on("click","#refund-list .pagination .links a",function(){var e=t(this).attr("href");return t.ajax({url:e,success:function(e){t("body #refund-list").html(e)}}),!1}),t("#transaction a").click(function(){var e=t("<div id='transaction-list'></div>");t.ajax({url:transaction_url,success:function(a){e.html(a).dialog({modal:!0,minWidth:800,title:Mustache.render("{{transaction_title}}",lang),close:function(){t("#transaction-list").remove()}}).dialog("open")}})}),t("#calculator-panel a").click(function(e){e.preventDefault();var a=t("#calculator"),o='<div class="top"><span class="clear">C</span><div class="screen"></div></div><div class="keys"><span>7</span><span>8</span><span>9</span><span class="operator">+</span><span>4</span><span>5</span><span>6</span><span class="operator">-</span><span>1</span><span>2</span><span>3</span><span class="operator">/</span><span>0</span><span>.</span><span class="eval">=</span><span class="operator">x</span></div>';a.html(o).dialog({modal:!0,minWidth:400,title:Mustache.render("{{calculator_title}}",lang)}).dialog("open"),calculator()}),t("body").on("click","#transfer-btn",function(){t.ajax({type:"post",url:add_transaction_url,data:t("body #frm-transfer").serialize(),dataType:"json",success:function(e){"1"==e.status&&(t("body #transactions-list tbody").prepend(e.html),t("body .transaction-total").html(e.total),t("body #frm-transfer")[0].reset(),setInterval(function(){t("body .new-trans").removeClass("new-trans")},5e3))}})}),t("body").on("click","#help a",function(){var e=t("<div id='help-form'></div>"),a='<div style="text-align: center;font-weight: bold;">Get Suport or Report Bug</div><ul>';a+="<li>SkypeId: vna_typn",a+='<li>Email: <a href="mailto:[email protected]">[email protected]</a></li>',a+='<li>Website: <a href="http://magetop.com">magetop.com</a></li>',a+="</ul>",e.html(a).dialog({modal:!0})}),t("body").on("click","#transaction-list .pagination .links a",function(){var e=t(this).attr("href");return t.ajax({url:e,success:function(e){t("body #transaction-list").html(e)}}),!1}),t("body").on("click","#refund-btn",function(){var a=t(this).attr("order_id");t("#refund-list").dialog("close"),t("#refund-list").remove();var o=t("<div id='refund-form'></div>");t.ajax({url:refund_url,type:"post",data:{order_id:a},success:function(n){o.html(n).dialog({modal:!0,minWidth:800,title:"Orders #"+a,close:function(){t("#refund-form").remove()},buttons:{Apply:function(){var a=t(this);e.clear().done(function(){a.dialog("close").remove()})},Cancel:function(){return t(this).dialog("close").remove(),!1}}}).dialog("open")}})}),t("body").on("change","#item_price",function(){var e=t(this).attr("item_id"),a=t.indexedDB(D).objectStore("cart"),o=t(this).val();e=parseInt(e),a.get(e).done(function(t){t.price=o,t.subtotal=t.price*t.qty,a.put(t).done(function(){y(e,function(){u()})})})}),t(document).on("click","#setting-panel",function(){var e=t.indexedDB(D).objectStore("pos"),a="";e.get("default_payment").done(function(t){a+='<div class="setting-box">',a+="<form>",a+='<div class="setting-payment">',a+='<div class="setting-title">Default Payment Method</div>',a+='<ul style="list-style:none;">';for(i in payment){var e=payment[i];a+=t&&e.payment_id==t.value?'<li><input type="radio" name="default-payment" id="pay-'+e.payment_id+'" checked="checked" value="'+e.payment_id+'" title="'+e.payment_name+'">'+e.payment_name+"</li>":'<li><input type="radio" name="default-payment" id="pay-'+e.payment_id+'" value="'+e.payment_id+'" title="'+e.payment_name+'">'+e.payment_name+"</li>"}a+="</ul>",a+="</div>"}).then(function(){e.get("quick_checkout").done(function(t){a+='<div class="setting-quick-checkout">',a+='<div class="setting-title">Enable Quick Checkout</div>',a+='<ul style="list-style: none;">',t&&1==t.value?(a+='<li><input name="quick_checkout" type="radio" value="0">No</li>',a+='<li><input name="quick_checkout" type="radio" value="1" checked="checked">Yes</li>'):(a+='<li><input name="quick_checkout" type="radio" value="0" checked="checked">No</li>',a+='<li><input name="quick_checkout" type="radio" value="1">Yes</li>'),a+="</form>",a+="</div>"}).then(function(){e.get("disable_print_receipt").done(function(t){a+='<div class="setting-print-receipt">',a+='<div class="setting-title">Print Receipt</div>',a+='<ul style="list-style: none;">',t&&1==t.value?(a+='<li><input name="disable_print_receipt" type="radio" value="0">Yes</li>',a+='<li><input name="disable_print_receipt" type="radio" value="1" checked="checked">No</li>'):(a+='<li><input name="disable_print_receipt" type="radio" value="0" checked="checked">Yes</li>',a+='<li><input name="disable_print_receipt" type="radio" value="1">No</li>'),a+="</ul>",a+="</div>",a+="</form>",a+="</div>"}).then(function(){t(a).dialog({title:"Setting",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t('input[name="default-payment"]:checked').val(),o=t('input[name="quick_checkout"]:checked').val(),n=t('input[name="disable_print_receipt"]:checked').val(),i=new Object;i.key="default_payment",i.value=a,e.put(i).done(function(){});var r=new Object;r.key="quick_checkout",r.value=o,e.put(r).done(function(){});var c=new Object;return c.key="disable_print_receipt",c.value=n,e.put(c).done(function(){}),t(this).dialog("close").remove(),!1},Cancel:function(){return t(this).dialog("close").remove(),!1}}})})})})})}function p(e,a,o){var n=t.indexedDB(D).objectStore("cart"),r=t.indexedDB(D).objectStore("order");r.add(e).done(function(){n.clear().done(function(){t("#total_paid input").val("0"),u(),a.dialog("close").remove()}).then(function(){t("#total_paid input").val("0"),u()}).then(function(){var a=new Date,n=config.currency.default_format,r="<!DOCTYPE HTML>";r+='<html lang="en-us">',r+="<head></head>",r+="<body>",r+=receipt_template,r+="</body>",r+="</html>";var c=new Array,l=0,u=0;for(i in e.data){var d=e.data[i];"product"==d.type&&(d.price_formated=numeral(d.price).format(n),d.subtotal_formated=numeral(d.subtotal).format(n),c.push(d),l+=parseFloat(d.subtotal))}for(i in e.discount){var s=e.discount[i];u+="custom"==s.type?"P"==s.value.type?l*s.value.price/100:s.value.price:s.value.amount}var p=new Object;for(i in o)"customer"==o[i].type&&(p=o[i].value);var v={date:a.getDate()+"/"+a.getMonth()+"/"+a.getFullYear(),invoice:config.store.config_invoice_prefix+e.invoice_id,invoice_prefix:config.store.config_invoice_prefix,products:c,discount:u,subtotal:l,discount:u,tax:e.tax_total,grand_total:e.grand_total,subtotal_formated:numeral(l).format(n),tax_formated:numeral(e.tax_total).format(n),discount_formated:numeral(u).format(n),grandtotal_formated:numeral(e.grand_total).format(n),customer:p,cashier:cashier_name},r=Mustache.render(r,v),m=t.indexedDB(D).objectStore("product");m.each(function(t){var e=t.value.quantity;for(i in c)c[i].product_id==t.value.product_id&&e>0&&(e-=c[i].qty);t.value.quantity=e,m.put(t.value)});var f=t.indexedDB(D).objectStore("pos"),_=0;f.get("disable_print_receipt").done(function(t){t&&1==t.value&&(_=1)}).then(function(){if(0==_){var t=window.open("","_blank","width=700,height=800");t.document.writeln(r),t.document.close(),t.focus(),t.print(),x(t)}}),t("button[value='0']").trigger("click")})})}function v(e,a,o){var n=t.indexedDB(D).objectStore("cart");n.get(e).done(function(t){var r=t.price_no_opt,c=0;for(i in a){var l=a[i];l.price&&("+"==l.price_prefix?(r=parseFloat(r)+parseFloat(l.price),c=parseFloat(c)+parseFloat(l.price)):(r=parseFloat(r)-parseFloat(l.price),c=parseFloat(c)-parseFloat(l.price)))}t.opt_total_price=c,t.price=r,t.subtotal=t.price*t.qty,t.options=a,n.put(t).done(function(){y(e,function(){o(t)})})})}function m(e,a){var o=t.indexedDB(D).objectStore("cart");o.get(e).done(function(t){a(t)})}function f(e,a){e=String(e);var o=t.indexedDB(D).objectStore("product");o.get(e).done(function(t){a(t)})}function _(e,a,o){e=String(e);var n=t.indexedDB(D).objectStore("product"),r=t.indexedDB(D).objectStore("pos"),c=t.indexedDB(D).objectStore("cart");r.get("default_customer_id").done(function(t){if(void 0!=typeof t.value.customer_group_id){var r=t.value.customer_group_id;c.index("type").each(function(t){r=t.value.value.customer_group_id},"customer").then(function(){n.get(e).done(function(t){if(t.price){var e=new Object;if(e.price=t.base_price,e.base_price=t.base_price,e.special_price=null,e.discount_price=null,t.special.length>0){var n=new Array;for(i in t.special)if(String(t.special[i].customer_group_id)==String(r)){var c=!1,l=!1,u=new Date,d=new Date(t.special[i].date_start),s=new Date(t.special[i].date_end);("0000-00-00"==t.special[i].date_start||u>d)&&(c=!0),("0000-00-00"==t.special[i].date_end||s>u)&&(l=!0),c&&l&&(n[t.special[i].priority]=n[t.special[i].priority]&&parseFloat(n[t.special[i].priority].base_price)<parseFloat(t.special[i].base_price)?n[t.special[i].priority]:t.special[i])}if(n.length>0){var p=Math.min.apply(Math,Object.keys(n));e.price=n[p].base_price,e.special_price=n[p].base_price}}if(t.discounts.length>0){var v=e.price;for(i in t.discounts){var m=t.discounts[i];m.quantity<=a&&parseFloat(m.price)<parseFloat(v)&&(v=m.price)}e.price=v,e.discount_price=v}o(e)}})})}})}function h(t,e){var a="",o=config.currency.default_format,a=numeral(t).format(o);e(a)}function y(e,a){var o=(t.indexedDB(D).objectStore("pos"),t.indexedDB(D).objectStore("tax")),n=t.indexedDB(D).objectStore("cart");g("tax_class_base",function(t){var r=t;if(0!=r&&-1!=r&&g("tax_base_on",function(t){var c=t;g("default_customer_id",function(t){var l=t,u=new Array;o.index("customer_group_id").each(function(t){t.value.based==c&&u.push(t.value)},l.customer_group_id).then(function(){var t=new Object;n.get(e).done(function(e){var o=new Array,c=0,l=0;for(i in u)if(u[i].tax_class_id==r){var d=u[i];if(e.qty>0){d.qty=e.qty;var s=d.rate,p=d.type,v=0,m=new Object;m.name=d.name,m.tax_rate_id=d.tax_rate_id,o[l]=m,v+="P"==p?parseFloat(e.price)/100*parseFloat(s):parseFloat(s),c+=v,o[l].tax_price=v,l++}}t.item_id=e.id,t.total=c,t.modified=!1,t.tax=o,e.tax=t,n.put(e).done(function(){a(e)})},"product")})})}),0==r){var c=new Object;n.get(e).done(function(t){var e=new Array;c.item_id=t.id,c.total=0,c.modified=!1,c.tax=e,t.tax=c,n.put(t).done(function(){a(t)})},"product")}-1==r&&g("tax_base_on",function(t){var r=t;g("default_customer_id",function(t){var c=t,l=new Array;o.index("customer_group_id").each(function(t){t.value.based==r&&l.push(t.value)},c.customer_group_id).then(function(){var t=new Object;n.get(e).done(function(e){var o=new Array,r=0,c=0;for(i in l)if(l[i].tax_class_id==e.tax_class_id){var u=l[i];if(e.qty>0){u.qty=e.qty;var d=u.rate,s=u.type,p=0,v=new Object;v.name=u.name,v.tax_rate_id=u.tax_rate_id,o[c]=v,p+="P"==s?parseFloat(e.price)/100*parseFloat(d):parseFloat(d),r+=p,o[c].tax_price=p,c++}}t.item_id=e.id,t.total=r,t.modified=!1,t.tax=o,e.tax=t,n.put(e).done(function(){a(e)})},"product")})})})})}function g(e,a){var o=t.indexedDB(D).objectStore("pos");o.get(e).done(function(t){t&&a(t.value)})}function b(){var e=t.indexedDB(D).objectStore("cart"),a=0,o=0,n=0,i=0,r="",c="",l=0,u=t.indexedDB(D).objectStore("cart_saved");u.count().done(function(e){t("#saved_count").html(parseInt(e))}),e.each(function(t){if("product"==t.value.type&&(a=parseFloat(a)+parseFloat(t.value.subtotal),n=parseFloat(n)+parseFloat(t.value.subtotal),t.value.tax.total&&(l+=parseFloat(t.value.tax.total)*parseInt(t.value.qty)),o+=t.value.qty),"comment"==t.value.type&&(r=t.value.comment),"customer"==t.value.type&&(c=t.value.value.firstname+" "+t.value.value.lastname),"discount"==t.value.type){var e=t.value.value;if(e.egift&&(i=parseFloat(i)+parseFloat(e.egift.amount),n=parseFloat(n)-parseFloat(i)),e.custom){var u=e.custom,d=u.price;if(parseFloat(u.price)<parseFloat(a))if("P"==u.type){var s=parseFloat(a)*parseFloat(d)/100;i=parseFloat(i)+parseFloat(s),n=parseFloat(n)-parseFloat(s)}else i=parseFloat(i)+parseFloat(d),n=parseFloat(n)-parseFloat(d)}}}).then(function(){t("#item_count span").html(o),n+=l;var e=config.currency.number_format;t("#total_paid input").val(numeral(n).format(e));var u=(numeral(t("#total_paid input").val()).format(e),numeral(n).format(e),numeral(parseFloat(numeral().unformat(t("#total_paid input").val()))-parseFloat(n)).format(config.currency.default_format));t("#refund_value span").html(u),h(l,function(e){t("#tax_value").html(e)}),h(a,function(e){t("#total_value span").html(e)}),h(n,function(e){t("#total_able span").html(e),t("#total_able span").attr("total",parseFloat(n))}),h(i,function(e){t("#discount_value button").html(e)}),""==r&&(r=Mustache.render("{{no_comment}}",lang)),t("#comment_value span").html(r),""!=c?t("#customer_value button").html(c):(c=void 0!=config.default_customer.customer_id?config.default_customer.firstname+" "+config.default_customer.lastname:Mustache.render("{{default_guest_name}}",lang),t("#customer_value button").html(c))})}function x(t){"complete"==document.readyState?t.close():setTimeout("CheckWindowState()",2e3)}function w(t){var e=/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return e.test(t)}function F(t,e){return t.sort(function(t,a){var o=t[e],n=a[e];return n>o?-1:o>n?1:0})}var q=null;const D="OpenPos";window.onbeforeunload=e,t(".menu-refresh").click(function(){t(".menu-refresh img#refresh").hide(),t(".menu-refresh img#loading").show(),t.ajax({url:data_url,faild:function(){alert("No internet connection. Your POS in Offline Mode."),t(".menu-refresh img#refresh").show(),t(".menu-refresh img#loading").hide()},success:function(){t.indexedDB(D).deleteDatabase().done(function(){a(function(){t(".menu-refresh img#refresh").show(),t(".menu-refresh img#loading").hide(),l(),s()})})}})}),a(function(){l(),s(),t("#product-cart-list").jScrollPane({showArrows:!0})})}}(jQuery); ?>

Did this file decode correctly?

Original Code

!function(t){t.fn.openpos=function(){function e(){return Mustache.render("{{close_warning}}",lang)}function a(e){t.indexedDB(D,{schema:{1:function(t){var e=(t.createObjectStore("pos",{keyPath:"key"}),t.createObjectStore("category",{keyPath:"category_id"}));e.createIndex("category_id");var a=t.createObjectStore("product",{keyPath:"product_id"});a.createIndex("upc",{unique:!1});var o=t.createObjectStore("cart",{keyPath:"id",autoIncrement:!0});o.createIndex("product_id",{unique:!1}),o.createIndex("type",{unique:!1});var n=t.createObjectStore("order",{keyPath:"id",autoIncrement:!0});n.createIndex("status",{unique:!1});var i=t.createObjectStore("tax",{keyPath:"tax_rule_id"});i.createIndex("customer_group_id",{unique:!1}),i.createIndex("tax_class_id",{unique:!1}),i.createIndex("based",{unique:!1});var r=t.createObjectStore("cart_saved",{keyPath:"id",autoIncrement:!0});r.createIndex("name",{unique:!1})}}}).done(function(){t.indexedDB(D).objectStore("pos").clear(),t.indexedDB(D).objectStore("category").clear(),t.indexedDB(D).objectStore("product").clear(),t.indexedDB(D).objectStore("tax").clear(),t.indexedDB(D).objectStore("cart").clear(),t.indexedDB(D).objectStore("cart_saved").clear()}).then(function(){o(function(){t("#container #content #content-loading").remove(),t("#content .box").show()}),void 0!=e&&e()})}function o(e){t.ajax({type:"GET",url:data_url,dataType:"json",beforeSend:function(){t("#container #content").append('<div id="content-loading">Loading....!!!! Please wait....!</div>'),t("#content .box").hide()},success:function(a){var o=t.indexedDB(D).objectStore("product"),i=t.indexedDB(D).objectStore("pos"),r=t.indexedDB(D).objectStore("category"),c=(t.indexedDB(D).objectStore("zone"),t.indexedDB(D).objectStore("tax"));t.each(a.pos,function(t,e){i.add(e)}),t.each(a.categories,function(t,e){r.add(e)}),t.each(a.products,function(t,e){o.add(e)}),t.each(a.tax,function(t,e){c.add(e)}),t("#container #content #content-loading").remove(),t("#content .box").show(),n(),t("button[value='0']").trigger("click"),u(),void 0!=e&&e()}})}function n(){t(".jcarousel ul").empty(),t(".jcarousel ul").append('<li><button id="category-btn" value="0">'+Mustache.render("{{all_category}}",lang)+"</button></li>"),t(".jcarousel").jcarousel("reload"),t.indexedDB(D).objectStore("category").each(function(e){t(".jcarousel ul").append('<li><button id="category-btn" value="'+e.value.category_id+'">'+e.value.name+"("+e.value.total+")</button></li>"),t(".jcarousel").jcarousel("reload")}),t("#categories").on("click","#category-btn",function(){var e=this;t("#categories li button").each(function(){t(this).removeClass("cat-active")}),t(e).addClass("cat-active"),0==t(e).attr("value")?r():c(t(e).attr("value"))})}function r(){t("#ajaxproducts ul").empty();var e=t.indexedDB(D).objectStore("product");e.count().done(function(a){var o=a,n=1,i="";e.each(function(e){var a="instock";e.value.quantity<=0&&(a="outstock"),i+='<div id="product-container"><div class="product-info" product-data="'+e.value.product_id+'"><div class="'+a+' product-stock">'+e.value.quantity+'</div><img src="'+e.value.image+'"><p>'+e.value.name+"</p></div></div>",(n%20==0||n==o)&&(t("#ajaxproducts ul").append('<li style="width:'+t("#ajaxproducts").width()+'px;">'+i+"</li>"),t("#ajaxproducts").jcarousel("reload"),i=""),n++})})}function c(e){t("#ajaxproducts ul").empty();var a=t.indexedDB(D).objectStore("product"),o=t.indexedDB(D).objectStore("category");o.get(e).done(function(o){var n=o.total,i=[];a.each(function(t){t.value.category_id&&-1!=t.value.category_id.indexOf(e)&&i.push(t.value)}).done(function(){var e=1,a="";for(q in i){var o="instock";i[q].quantity<=0&&(o="outstock"),a+='<div id="product-container"><div class="product-info" product-data="'+i[q].product_id+'"><div class="'+o+' product-stock">'+i[q].quantity+'</div><img src="'+i[q].image+'"><p>'+i[q].name+"</p></div></div>",(e%20==0||e==n)&&(t("#ajaxproducts ul").append('<li style="width:'+t("#ajaxproducts").width()+'px;">'+a+"</li>"),t("#ajaxproducts").jcarousel("reload"),a=""),e++}})})}function l(){var e=t.indexedDB(D).objectStore("product"),a=t.indexedDB(D).objectStore("cart");t("#ajaxproducts").on("click",".product-info",function(){var o=t(this).attr("product-data"),n=!1;e.get(o).done(function(t){a.index("product_id").each(function(e){0==t.options.length&&(n=!0,e.value.qty=e.value.qty+1,e.value.subtotal=String(parseFloat(e.value.subtotal)+parseFloat(e.value.price)),a.put(e.value).done(function(){u()}))},o).done(function(){n||e.get(o).done(function(t){_(t.product_id,1,function(e){var o=new Object;o.price=e.price,o.price_no_opt=e.price,o.base_price=e.base_price,o.qty=1,o.dummy=t.dummy,o.name=t.name,o.model=t.model,o.point=t.points,o.type="product",o.product_id=t.product_id,o.options=new Array,o.subtotal=e.price,o.tax_class_id=t.tax_class_id,o.tax=new Object,o.tax.total=0,o.tax.tax=new Array,o.tax.modified=!1,a.add(o).done(function(t){y(t,function(){u()})}).then(function(){})})})})})})}function u(){var e=t.indexedDB(D).objectStore("cart"),a=t.indexedDB(D).objectStore("product");t("#product-cart-list table").empty(),t("#product-cart-list").jScrollPane({showArrows:!0}).data("jsp").scrollToBottom(),e.index("type").each(function(e){var o=e.value.product_id,n=0;e.value.tax.total&&(n=e.value.tax.total),a.get(o).done(function(a){h(e.value.base_price,function(o){h(e.value.price,function(r){h(e.value.subtotal,function(c){h(n,function(l){var u="";if(o!=r&&(u='<p><span id="old_price">'+o+"</span></p>"),1==e.value.dummy){var d=config.currency.number_format;r='<input type="text" name="item_price" item_id="'+e.value.id+'" id="item_price" value="'+numeral(e.value.price).format(d)+'">'}if(parseFloat(n)>0)var s='<tr id="row-'+e.value.id+'"><td class="del-col" product-data="'+e.value.id+'">x</td><td class="product-col"><p>'+a.name+'</p></td><td class="price-col"><p>'+r+"</p>"+u+'</td><td class="tax-col"><button type="button" product-data="'+e.value.id+'">'+l+'</button></td><td class="qty-col"><div id="qty-plus" product-data="'+e.value.id+'"></div><input type="text" id="input-qty" name="qty" value="'+e.value.qty+'"/><div id="qty-less" product-data="'+e.value.id+'"></div></td><td class="subtotal-col">'+c+'</td><td class="non-option-col" product-data="'+e.value.id+'"></td></tr>';else var s='<tr id="row-'+e.value.id+'"><td class="del-col" product-data="'+e.value.id+'">x</td><td class="product-col"><p>'+a.name+'</p></td><td class="price-col"><p>'+r+"</p>"+u+'</td><td class="tax-col">'+l+'</td><td class="qty-col"><div id="qty-plus" product-data="'+e.value.id+'"></div><input type="text" id="input-qty" name="qty" value="'+e.value.qty+'"/><div id="qty-less" product-data="'+e.value.id+'"></div></td><td class="subtotal-col">'+c+'</td><td class="non-option-col" product-data="'+e.value.id+'"></td></tr>';if(a.options.length>0){var p=e.value.options,v=new Array,m=new Array,f=!0;for(i in p){var _=p[i];m.push(_.product_option_id)}console.log(a.options);for(i in a.options){var _=a.options[i];("select"==_.type||"radio"==_.type||"checkbox"==_.type)&&1==_.required&&v.push(_.product_option_id)}if(v.length>0)for(i in v)-1==m.indexOf(v[i])&&(f=!1);var h="";f||(h='class="require"');var y="";if(e.value.options.length>0){y+='<p id="option_str">';for(i in e.value.options){var g=e.value.options[i];y+=g.name+": "+g.value+"; "}y+="</p>"}s=parseFloat(n)>0?"<tr "+h+' id="row-'+e.value.id+'"><td class="del-col" product-data="'+e.value.id+'">x</td><td class="product-col"><p>'+a.name+"</p>"+y+'</td><td class="price-col"><p>'+r+"</p>"+u+'</td><td class="tax-col"><button type="button" product-data="'+e.value.id+'">'+l+'</button></td><td class="qty-col"><div id="qty-plus" product-data="'+e.value.id+'"></div><input type="text" id="input-qty" name="qty" value="'+e.value.qty+'"/><div id="qty-less" product-data="'+e.value.id+'"></div></td><td class="subtotal-col">'+c+'</td><td class="option-col" product-data="'+e.value.id+'"></td></tr>':"<tr "+h+'  id="row-'+e.value.id+'"><td class="del-col" product-data="'+e.value.id+'">x</td><td class="product-col"><p>'+a.name+"</p>"+y+'</td><td class="price-col"><p>'+r+"</p>"+u+'</td><td class="tax-col">'+l+'</td><td class="qty-col"><div id="qty-plus" product-data="'+e.value.id+'"></div><input type="text" id="input-qty" name="qty" value="'+e.value.qty+'"/><div id="qty-less" product-data="'+e.value.id+'"></div></td><td class="subtotal-col">'+c+'</td><td class="option-col" product-data="'+e.value.id+'"></td></tr>'}t("#product-cart-list table").append(s),t("#product-cart-list").jScrollPane({showArrows:!0}).data("jsp").scrollToBottom()})})})})})},"product").then(function(){b(),t("#scancode").focus()})}function d(e){var a=t.indexedDB(D).objectStore("order");if(e.length>0){t("#status").removeClass("ok").addClass("lock");for(i in e){var o=e[i];if(0==o.status){o.status=2,a.put(o).done(function(){t.ajax({type:"POST",url:data_url,dataType:"json",data:{action:"order",data:JSON.stringify(o)},beforeStart:function(){t("#status").removeClass("ok").addClass("lock")},success:function(){e.shift(),d(e)},error:function(){o.status=0,a.put(o).done(function(){d(e)})}})});break}}}else t("#status").removeClass("lock").addClass("ok")}function s(){var e=t.indexedDB(D).objectStore("cart"),a=t.indexedDB(D).objectStore("product"),o=t.indexedDB(D).objectStore("order"),n=new Array;setInterval(function(){o.index("status").each(function(t){n.push(t.value)},0).then(function(){d(n)})},5e3),setInterval(function(){o.index("status").each(function(t){var e=new Date,a=Math.round(e.getTime()/1e3);if(t.value.created_time||(t.value.created_time=0),a-parseInt(t.value.created_time)>86400){var n=t.value.id;o.delete(parseInt(n))}},2)},1e3),t("#botbuttons #cancel").click(function(){var a=t("<div>"+Mustache.render("{{clear_cart_warning}}",lang)+"</div>");a.dialog({title:Mustache.render("{{clear_cart_title}}",lang),modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t(this);e.clear().done(function(){t("#total_paid input").val("0"),u(),a.dialog("close").remove()})},Cancel:function(){return t(this).dialog("close").remove(),!1}}})}),t("#pro-col-header .del-col").click(function(){t("#botbuttons #cancel").trigger("click")}),t("#product-cart-list").on("click",".del-col",function(){if(t(this).attr("product-data")){var a=t(this).attr("product-data");e.delete(parseInt(a)).done(function(){u()})}}),t("#product-cart-list").on("click","#qty-plus",function(){if(t(this).attr("product-data")){var a=t(this).attr("product-data");e.get(parseInt(a)).done(function(t){var a=t.qty+1;_(t.product_id,a,function(o){var n=parseFloat(o.price)*parseInt(a),i=o.price;t.options.length>0&&(t.opt_total_price&&(i=parseFloat(o.price)+parseFloat(t.opt_total_price),n=i*parseInt(a)),t.opt_total_price&&parseFloat(o.price)>parseFloat(parseFloat(t.price)-parseFloat(t.opt_total_price))&&(n=parseFloat(t.price)*parseInt(a),i=t.price)),t.price=i,t.qty=a,t.subtotal=n,e.put(t).done(function(){u()})})})}}),t("#product-cart-list").on("click","#qty-less",function(){if(t(this).attr("product-data")){var a=t(this).attr("product-data");e.get(parseInt(a)).done(function(t){if(t.qty>0){var a=t.qty-1;_(t.product_id,a,function(o){var n=parseFloat(o.price)*parseInt(a),i=o.price;t.options.length>0&&(t.opt_total_price&&(i=parseFloat(o.price)+parseFloat(t.opt_total_price),n=i*parseInt(a)),t.opt_total_price&&parseFloat(o.price)>parseFloat(parseFloat(t.price)-parseFloat(t.opt_total_price))&&(n=parseFloat(t.price)*parseInt(a),i=t.price)),t.price=i,t.qty=a,t.subtotal=n,e.put(t).done(function(){u()})})}})}}),t("#product-cart-list").on("click",".option-col",function(){if(t(this).attr("product-data")){var e=parseInt(t(this).attr("product-data"));m(e,function(a){f(a.product_id,function(o){var n=o.options,r=a.options,c='<div><form id="option-'+e+'">',l=new Array,d="";for(i in n){var s=n[i],p=new Array;for(j in r){var m=r[j];m.product_option_id==s.product_option_id&&p.push(m.product_option_value_id)}if(1==s.required&&(l.push(s.option_id),d='<span id="require">*</span>'),"select"==s.type){c+='<div class="select-option" id="option_'+s.product_option_id+'">'+s.name+d+': <select name="option_'+s.product_option_id+'">';for(j in s.option_value){var f=s.option_value[j],_="";if(_=p.indexOf(f.option_value_id)>-1?' selected="selected" ':"",f.price){var h=config.currency.number_format,y=numeral(f.price).format(h);c+="<option "+_+' value="'+f.option_value_id+'">'+f.name+"("+f.price_prefix+y+")</option>"}else c+="<option "+_+' value="'+f.option_value_id+'">'+f.name+"</option>"}c+="</select></div>"}if("radio"==s.type){c+='<div class="radio-option">'+s.name+":<ul>";for(k in s.option_value){var f=s.option_value[k],_="";if(_=p.indexOf(f.option_value_id)>-1?' checked="checked" ':"",f.price){var h=config.currency.number_format,y=numeral(f.price).format(h);c+="<li><input  "+_+'  type="radio" name="option_'+s.product_option_id+'" value="'+f.option_value_id+'">'+f.name+"("+f.price_prefix+y+")</li>"}else c+="<li><input  "+_+'  type="radio" name="option_'+s.product_option_id+'" value="'+f.option_value_id+'">'+f.name+"</li>"}c+="</ul></div>"}if("checkbox"==s.type){c+='<div class="checkbox-option">'+s.name+":<ul>";for(k in s.option_value){var f=s.option_value[k],_="";_=p.indexOf(f.option_value_id)>-1?' checked="checked" ':"";var h=config.currency.number_format,y=numeral(f.price).format(h);c+="<li> <input  "+_+' type="checkbox" name="option_'+s.product_option_id+'" value="'+f.option_value_id+'">'+f.name+"("+f.price_prefix+y+") </li>"}c+="</ul></div>"}}c+="</form></div>",t(c).dialog({title:o.name,modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=o.options,n=t("form#option-"+e).serializeArray(),r=new Array,c=t(this);for(i in n){var l=n[i],d=new Object,s=l.name.split("_");d.product_option_id=s[1],d.product_option_value_id=l.value;for(j in a){var p=a[j];if(p.product_option_id==s[1]){d.name=p.name,d.type=p.type;for(k in p.option_value){var m=p.option_value[k];m.option_value_id==d.product_option_value_id&&(d.value=m.name,d.price_prefix=m.price_prefix,d.price=m.price)}}}r.push(d)}v(e,r,function(){u(),c.dialog("close").remove()})},Cancel:function(){return t(this).dialog("close").remove(),!1}}})})})}}),t("#product-cart-list").on("click",".tax-col button",function(){var a=t(this).attr("product-data"),o='<div><div id="tax_popup"><form id="tax_form" onsubmit="return false;"><ul>';e.get(parseInt(a)).done(function(e){var a=e.tax,n=config.currency.number_format;for(i in a.tax){var r=a.tax[i],c=numeral(r.tax_price).format(n);o+='<li><div id="tax-title">'+r.name+':</div><div id="tax-value">'+c+"</div></li>"}numeral(e.total).format(n);o+="</ul></form></div></div>",t(o).dialog({title:"Tax Details",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Cancel:function(){return t(this).dialog("close").remove(),!1}}})})}),t("#totaldiv").on("click","#discount_button",function(){var a='<div><div id="discount-message"></div><form id="discount_form" onSubmit="return false;"><ul>';a+='<li><input type="radio" name="discount" value="egift"/>Use Gift Card</li>',e.index("type").each(function(e){e.value.id!=parseInt(config.default_customer.customer_id)&&(a='<li><input type="radio" name="discount" value="coupon"/>Use Reward Point</li>',t("li#custom").after(a))},"customer"),a+='<li id="custom"><input type="radio" name="discount" value="custom"/>Custom</li>',a+='<li id="dicount_input"></li>',a+="</ul></form></div>",t(a).dialog({title:"Discount Details",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t("input:radio[name='discount']:checked").val(),o=t(this);if("egift"==a){var n=t("input[name='egift_code']").val();""==n?t("#discount-message").html("Please enter your gift voucher code!"):t.ajax({url:data_url,type:"GET",data:{action:"checkegift",code:n},dataType:"json",success:function(a){if(0==a.status)t("#discount-message").html("Your gift voucher code invalid !");else{var n=!1;e.index("type").each(function(t){n=!0;var i=t.value;i.value.egift=a.info,e.put(i).done(function(){u(),o.dialog("close").remove()})},"discount").then(function(){n||(tmp=new Object,tmp.type="discount",tmp.value=new Array,tmp.value.egift=a.info,e.add(tmp).done(function(){u(),o.dialog("close").remove()}))})}}})}if("custom"==a){var i=t("input[name='coupon_code']").val(),r=t("select[name='custom_type']").val();if(""==i)t("#discount-message").html("Please enter discount amount!");else{var c=!1;e.index("type").each(function(t){c=!0;var a=t.value,n=new Object;n.type=r,n.price=i,n.total=(r="F")?i:0,a.value.custom=n,e.put(a).done(function(){u(),o.dialog("close").remove()})},"discount").then(function(){if(!c){tmp=new Object,tmp.type="discount",tmp.value=new Array;var t=new Object;t.type=r,t.price=i,t.total=(r="F")?i:0,tmp.value.custom=t,e.add(tmp).done(function(){u(),o.dialog("close").remove()})}})}}},Cancel:function(){return t(this).dialog("close").remove(),!1}}}),t("input:radio[name='discount']").click(function(){var e=t("input:radio[name='discount']:checked").val();"custom"==e&&t("#dicount_input").html('<input type="text" placeholder="Enter amount" name="coupon_code" value="" id="coupon_code"><select name="custom_type"><option value="F">fixed</option><option value="P">Pecentage</option></select>'),"egift"==e&&t("#dicount_input").html('<input type="text" placeholder="Enter your gift voucher code here" name="egift_code" value="" id="egift_code">')})}),t("#totaldiv").on("click","#customer_button",function(){var o="",n="",i="",r="",c=0,l=0,d='checked="checked"';e.index("type").each(function(t){var e=t.value;c=e.value.customer_id,l=e.value.customer_group_id,o=e.value.firstname,n=e.value.lastname,i=e.value.email,r=e.value.telephone,comment_str=e.comment,d=""},"customer").then(function(){var s='<div><div id="errormsg"></div><form id="customer_form" onSubmit="return false;">';s+='<div id="search_customer"><input type="text" id="customer-text" name="value" value="" placeholder="Enter name, phone, email to search"></div>',s+='<input id="customer_id" name="customer_id" type="hidden" value="'+c+'">',s+='<input id="customer_group_id" name="customer_group_id" type="hidden" value="'+l+'">';var p='<ul id="new-customer-form">';p+='<li><div id="label">First Name:</div><div id="input"><input type="text" name="firstname" value="'+o+'" /></div></li>',p+='<li><div id="label">Last Name:</div><div id="input"><input type="text" name="lastname" value="'+n+'"/></div></li>',p+='<li><div id="label">Email:</div><div id="input"><input type="text" name="email" value="'+i+'"/></div></li>',p+='<li><div id="label">Phone Number:</div><div id="input"><input type="text" name="telephone" value="'+r+'"/></div></li>',p+='<li><input type="checkbox" '+d+' name="new_customer" value="1">Create new account ?</li>',p+="</ul>",s+='<div id="search_customer_result">'+p+"</div>",s+="</form></div>",t(s).dialog({title:"Customer Details",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var o=t("input[name=firstname]").val(),n=t("input[name=lastname]").val(),i=t("input[name=email]").val(),r=t("input[name=telephone]").val(),c=t("input[name=new_customer]").val(),l=t("input[name=customer_id]").val(),d=t("input[name=customer_group_id]").val(),s=!1,p=t(this);return w(i)?""==r?(t("#errormsg").html('<span style="color:red;">Phone number can not empty.</span>'),!1):void e.index("type").each(function(t){s=!0;var a=t.value;tmp=new Object,tmp.id=a.id,tmp.type="customer",tmp.value=new Object,tmp.value.customer_id=l,tmp.value.firstname=o,tmp.value.lastname=n,tmp.value.email=i,tmp.value.telephone=r,tmp.value.createnew=c,tmp.value.customer_group_id=d,a=tmp,e.put(a).done(function(){u(),p.dialog("close").remove()})},"customer").then(function(){s||(tmp=new Object,tmp.type="customer",tmp.value=new Object,tmp.value.customer_id=l,tmp.value.firstname=o,tmp.value.lastname=n,tmp.value.email=i,tmp.value.telephone=r,tmp.value.createnew=c,tmp.value.customer_group_id=d,e.add(tmp).done(function(){e.index("type").each(function(t){var o=t.value;a.get(o.product_id).done(function(t){if(t.special.length>0){var a=t.special,n=new Array;for(var i in a)if(a[i].customer_group_id==d){var r=new Date,c=r.getDate(),l=r.getMonth()+1,s=r.getFullYear();parseInt(c)<10&&(c="0"+c),parseInt(l)<10&&(l="0"+l);var p=a[i].date_start,v=a[i].date_end,m=s+"-"+l+"-"+c;(new Date(m).getTime()>new Date(p).getTime()||"0000-00-00"==p)&&(new Date(m).getTime()<new Date(v).getTime()||"0000-00-00"==v)&&n.push(a[i])}if(n.length>0){var f=F(n,"priority"),_=f[0].price;o.price_no_opt=_;var h=o.options,g=0;if(h.length>0)for(i in h){var b=h[i];b.price&&("+"==b.price_prefix?(_=parseFloat(_)+parseFloat(b.price),g=parseFloat(g)+parseFloat(b.price)):(_=parseFloat(_)-parseFloat(b.price),g=parseFloat(g)-parseFloat(b.price)))}o.price=_,o.opt_total_price=g,o.subtotal=o.price*o.qty+o.tax.total,e.put(o).done(function(){y(o.id,function(){u()})})}}})},"product"),u(),p.dialog("close").remove()}))}):(t("#errormsg").html('<span style="color:red;">Your email incorrect.</span>'),!1)},Cancel:function(){return t(this).dialog("close").remove(),!1}}}),t("#customer-text").autocomplete({source:function(e,a){t.ajax({url:data_url,dataType:"json",data:{action:"customersearch",term:e.term},success:function(e){a(t.map(e,function(e){t("<div />").html(e.label);return{label:e.label,value:e.label,email:e.email,telephone:e.telephone,firstname:e.firstname,lastname:e.lastname,customer_id:e.value,customer_group_id:e.customer_group_id}}))}})},minLength:2,select:function(e,a){console.log(a);var o=a.item;t("input[name=firstname]").val(o.firstname),t("input[name=lastname]").val(o.lastname),t("input[name=email]").val(o.email),t("input[name=email]").attr("disabled","disabled"),t("input[name=telephone]").val(o.telephone),t("input[name=customer_id]").val(o.customer_id),t("input[name=customer_group_id]").val(o.customer_group_id),t("input[name=new_customer]").removeAttr("checked")},open:function(){t(this).removeClass("ui-corner-all").addClass("ui-corner-top")},close:function(){t(this).removeClass("ui-corner-top").addClass("ui-corner-all")}})})}),t("#totaldiv").on("click","#order_comment",function(){var a="";e.index("type").each(function(t){check=!0;var e=t.value;a=e.comment},"comment").then(function(){var o=t('<div id="commentbox"><textarea style="width:262px;" id="order_comment_textarea">'+a+"</textarea></div>");o.dialog({title:"Comment Details",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t("#order_comment_textarea").val(),o=!1,n=t(this);e.index("type").each(function(t){o=!0;var i=t.value;i.comment=a,e.put(i).done(function(){u(),n.dialog("close").remove()})},"comment").then(function(){o||(tmp=new Object,tmp.type="comment",tmp.comment=a,e.add(tmp).done(function(){u(),n.dialog("close").remove()}))})},Cancel:function(){return t(this).dialog("close").remove(),!1}}})})}),t("input[name='total_paid']").change(function(){var e=t("input[name='total_paid']").val(),a=config.currency.number_format,o=numeral(e).format(a),n=t("#total_able span").attr("total");t("input[name='total_paid']").val(o);var i=numeral(parseFloat(e)-parseFloat(n)).format(config.currency.default_format);t("#refund_value span").html(i)}),t("#botbuttons button#hold").click(function(){var a=t('<div><div id="discount-message"></div><input type="text" id="hold_name" name="hold_name" placeholder="Enter your hold name"></div>');a.dialog({title:"Hold Cart",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t(this),o=t("#hold_name").val();if(""==o)t("#discount-message").html("Please enter your hold name.");else{var n=t.indexedDB(D).objectStore("cart_saved"),i=new Array;e.each(function(t){i.push(t.value)}).done(function(){var r=new Object;r.name=o,r.data=i;var c=new Date,l=c.getDate()+"/"+c.getMonth()+"/"+c.getFullYear()+" "+c.getHours()+":"+c.getMinutes();r.time=l,n.add(r).done(function(){e.clear().done(function(){t("#total_paid input").val("0"),u(),a.dialog("close").remove()})})})}},Cancel:function(){return t(this).dialog("close").remove(),!1}}})}),t("#saved_count").click(function(){var a=t.indexedDB(D).objectStore("cart_saved"),o=Math.floor(100*Math.random()+1),n='<div><table id="cart_saved_list" class="cart_saved_'+o+'" width="100%">';n+="<tr><th>Name</th><th>Date Created</th><th>Action</th></tr>",a.each(function(t){n+='<tr><td><a href="javascript:void(0);" id="item_saved_name" data="'+t.value.id+'">'+t.value.name+"</a></td><td>"+t.value.time+'</td><td><a id="item_saved_delete" href="javascript:void(0);" data="'+t.value.id+'">delete</a></td></tr>'}).done(function(){n+="</table></div>",t(n).dialog({title:"Hold Cart",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Cancel:function(){return t(this).dialog("close").remove(),!1}}}),t(".cart_saved_"+o).on("click","#item_saved_name",function(){var o=t(this).attr("data");a.get(parseInt(o)).done(function(a){e.clear().done(function(){t("#total_paid input").val("0");for(i in a.data){var o=a.data[i];o.type&&e.add(o).done(function(){})}})}).then(function(){u()})}),t(".cart_saved_"+o).on("click","#item_saved_delete",function(){var e=t(this).attr("data"),o=t(this);a.delete(parseInt(e)).done(function(){o.closest("tr").hide(),u()})})})}),t("button#payment").click(function(){var a=parseFloat(numeral().unformat(t("#total-payable").attr("total"))),o=t('input[name="total_paid"]').val(),n=parseFloat(numeral().unformat(o))-parseFloat(a),r="";if(0==parseFloat(a)){var r="<div><center>"+Mustache.render("{{checkout_cart_empty_warning}}",lang)+"</center></div>";t(r).dialog({title:Mustache.render("{{checkout_warning}}",lang),modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Cancel:function(){return t(this).dialog("close").remove(),!1}}})}else{var c=t("#product-cart-list tr.require").length;if(c>0){var r="<div><center>"+Mustache.render("{{checkout_product_option_require_warning}}",lang)+"</center></div>";t(r).dialog({title:Mustache.render("{{checkout_warning}}",lang),modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Cancel:function(){return t(this).dialog("close").remove(),!1}}})}else{{var l=new Array;t(this)}e.each(function(t){l.push(t.value)}).done(function(){var r=new Object;r.grand_total=a,r.total_paid=numeral().unformat(o),r.balance=n,r.data=l;var c=new Date((new Date).getTime()-(72e5+6e4*(new Date).getTimezoneOffset()));c=new Date,r.invoice_id=Math.round(c.getTime()/1e3),r.created_time=Math.round(c.getTime()/1e3),r.status=0,r.store_id=config.store.store_id,r.default_customer=config.default_customer,r.cash_user_id=config.cash_user_id;var u=new Array,d=new Array,s=0;for(i in l){if("discount"==l[i].type){if(l[i].value.coupon){var v=new Object;v.type="coupon",v.value=l[i].value.coupon,u.push(v)}if(l[i].value.egift){var v=new Object;v.type="egift",v.value=l[i].value.egift,u.push(v)}if(l[i].value.custom){var v=new Object;v.type="custom",v.value=l[i].value.custom,u.push(v)}}if("product"==l[i].type){s+=l[i].tax.total;for(j in l[i].tax.tax){var m=l[i].tax.tax[j],f=!1;for(k in d)if(m.tax_rate_id==d[k].tax_rate_id){d[k].total=d[k].total+m.tax_price*l[i].qty;var f=!0}f||(m.total=m.tax_price*l[i].qty,d.push(m))}}}r.tax_total=s,r.tax=d,r.discount=u;var _=(new Date,config.currency.default_format,0),u=0;for(i in r.data){var h=r.data[i];if("product"==h.type){if(h.options.length>0){var y="";for(j in h.options){var g=h.options[j];y=g.name+": "+g.value+"; "}}_+=parseFloat(h.subtotal)}}for(i in r.discount){var b=r.discount[i];u+="custom"==b.type?"P"==b.value.type?_*b.value.price/100:b.value.price:b.value.amount}var x=t.indexedDB(D).objectStore("pos");x.get("quick_checkout").done(function(a){x.get("default_payment").done(a&&1==a.value?function(a){var o=!1;if(a&&a.value>0){for(i in payment)if(item=payment[i],console.log(payment),a.value==item.payment_id){o=item;var n=o.payment_id,c="",l=o.payment_name,u=new Array,d=t(this),s=new Object;s.name=n,s.id=n,s.ref=c,s.title=l,r.payment=s,r.cashier=cashier_name,e.each(function(t){u.push(t.value)}).done(function(){p(r,d,u)})}}else alert("Please choose 1 default payment method.")}:function(a){var o="<div id='panel-payment'><div id='discount-message'></div><form id='payment_method'><ul>";for(i in payment){var n=payment[i];o+=a?a.value==n.payment_id?'<li><input type="radio" name="pay" id="pay-'+n.payment_id+'" checked="checked" value="'+n.payment_id+'" title="'+n.payment_name+'"><button type="button" onClick="setPayment('+n.payment_id+');">'+n.payment_name+"</button></li>":'<li><input type="radio" name="pay" id="pay-'+n.payment_id+'" value="'+n.payment_id+'" title="'+n.payment_name+'"><button  type="button" onClick="setPayment('+n.payment_id+');">'+n.payment_name+"</button></li>":0==i?'<li><input type="radio" id="pay-'+n.payment_id+'" name="pay" checked="checked" value="'+n.payment_id+'" title="'+n.payment_name+'"><button  type="button" onClick="setPayment('+n.payment_id+');">'+n.payment_name+"</button></li>":'<li><input type="radio" id="pay-'+n.payment_id+'" name="pay" value="'+n.payment_id+'" title="'+n.payment_name+'"><button  type="button" onClick="setPayment('+n.payment_id+');">'+n.payment_name+"</buton></li>"}o+='<li id="payment_ref">'+Mustache.render("{{payment_ref}}",lang)+'<input type="text" name="pay_ref" value=""></li>',o+="</ul></form></div>",t(o).dialog({title:Mustache.render("{{payment_method_title}}",lang),modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Checkout:function(){var a=t('input[name="pay"]:checked').val(),o=t('input[name="pay_ref"]').val(),n=t('input[name="pay"]:checked').attr("title");if(null==a)t("#discount-message").html(Mustache.render("{{payment_method_warning}}",lang));else{var i=new Array,c=t(this),l=new Object;l.name=a,l.id=a,l.ref=o,l.title=n,r.payment=l,r.cashier=cashier_name,e.each(function(t){i.push(t.value)}).done(function(){p(r,c,i)})}},Cancel:function(){return t(this).dialog("close").remove(),!1}}})})})})}}}),t("form#barcode_scanner").on("submit",function(){var a=t("input#scancode").val().toLowerCase(),o=t.indexedDB(D).objectStore("product");return o.index("upc").each(function(a){var o=a.value,n=a.value.product_id,i=!1;e.index("product_id").each(function(a){0==o.options.length&&(i=!0,a.value.qty=a.value.qty+1,a.value.subtotal=String(parseFloat(a.value.subtotal)+parseFloat(a.value.price)),e.put(a.value).done(function(){u(),t("input#scancode").val("")}))},n).done(function(){i||_(o.product_id,1,function(a){var n=new Object;n.price=a.price,n.price_no_opt=a.price,n.base_price=a.base_price,n.qty=1,n.name=o.name,n.model=o.model,n.point=o.points,n.type="product",n.product_id=o.product_id,n.options=new Array,n.subtotal=a.price,n.tax_class_id=o.tax_class_id,n.tax=new Object,n.tax.total=0,n.tax.tax=new Array,n.tax.modified=!1,e.add(n).done(function(t){y(t,function(){u()})}).then(function(){t("input#scancode").val("")})})})},a),!1}),t("#scancode").autocomplete({source:function(e,a){var o=e.term.toLowerCase(),n=t.indexedDB(D).objectStore("product"),i=new Array;n.each(function(t){var e=t.value;(-1!=String(e.name).toLowerCase().search(o)||-1!=String(e.model).toLowerCase().search(o)||-1!=String(e.upc).toLowerCase().search(o))&&i.push(e)}).done(function(){var e=t("input#scancode").val().toLowerCase();a(t.map(i,function(e){t("<div />").html(e.name);return{label:e.name,value:e.upc,product_id:e.product_id}})),1==i.length&&i[0].upc==e&&t("#scancode").autocomplete("close")})},minLength:2,select:function(t,e){e.item},open:function(){t(this).removeClass("ui-corner-all").addClass("ui-corner-top")},close:function(){t("form#barcode_scanner").trigger("submit"),t(this).removeClass("ui-corner-top").addClass("ui-corner-all"),t("#scancode").autocomplete("instance")}}),t("#refund a").click(function(){var e=t.indexedDB(D).objectStore("order"),a="";a+='<div class="order-list-panel">',a+='<div class="jcarousel-orders-wrapper">',a+='<div class="jcarousel-orders"><ul>';var o=new Array;e.each(function(t){var e=t.value,a=new Date(1e3*e.invoice_id),n="Guest";null!=e.default_customer.customer_id&&(n=e.default_customer.firstname+" "+e.default_customer.lastname);var i=e.payment.title,r=e.cashier,c=config.currency.default_format;thml=void 0!=typeof e.is_cancel&&parseInt(e.is_cancel)>0?"<tr><td>"+e.invoice_id+"</td><td>"+n+"</td><td>"+numeral(e.grand_total).format(c)+"</td><td>"+numeral(e.total_paid).format(c)+"</td><td>"+e.balance+"</td><td>"+i+"</td><td>"+r+"</td><td>"+a.getDate()+"/"+(a.getMonth()+1)+"/"+a.getFullYear()+"</tr>":"<tr><td>"+e.invoice_id+"</td><td>"+n+"</td><td>"+numeral(e.grand_total).format(c)+"</td><td>"+numeral(e.total_paid).format(c)+"</td><td>"+e.balance+"</td><td>"+i+"</td><td>"+r+"</td><td>"+a.getDate()+"/"+(a.getMonth()+1)+"/"+a.getFullYear()+"</td></tr>",o.push(thml)
}).then(function(){var e="<thead><tr><th>Invoice</th><th>Customer</th><th>Grand Total</th><th>Total Paid</th><th>Balance</th><th>Payment</th><th>Cashier</th><th>Time</th></tr></thead>",n='<li><table width="650">'+e;o.reverse();for(var i in o){var r=parseInt(i)+1;console.log(r),n+=r%6==0?i==o.length-1?o[i]+"</table></li>":o[i]+'</table></li><li><table width="650">'+e:i==o.length-1?o[i]+"</table></li>":o[i]}a+=n+"</ul></div>",a+="</div>",a+='<div class="pagination-control">',a+='<a href="javascript:void(0);" class="orders-jcarousel-control-prev">&lsaquo;</a>',a+='<a href="javascript:void(0);" class="orders-jcarousel-control-next">&rsaquo;</a>',a+="</div>",a+="</div>",t(a).dialog({title:"Orders List",minHeight:300,minWidth:700,modal:!0,create:function(){t(".jcarousel-orders").jcarousel(),t(".orders-jcarousel-control-prev").on("jcarouselcontrol:active",function(){t(this).removeClass("inactive")}).on("jcarouselcontrol:inactive",function(){t(this).addClass("inactive")}).jcarouselControl({target:"-=1"}),t(".orders-jcarousel-control-next").on("jcarouselcontrol:active",function(){t(this).removeClass("inactive")}).on("jcarouselcontrol:inactive",function(){t(this).addClass("inactive")}).jcarouselControl({target:"+=1"})}})})}),t("body").on("click","#refund-list .pagination .links a",function(){var e=t(this).attr("href");return t.ajax({url:e,success:function(e){t("body #refund-list").html(e)}}),!1}),t("#transaction a").click(function(){var e=t("<div id='transaction-list'></div>");t.ajax({url:transaction_url,success:function(a){e.html(a).dialog({modal:!0,minWidth:800,title:Mustache.render("{{transaction_title}}",lang),close:function(){t("#transaction-list").remove()}}).dialog("open")}})}),t("#calculator-panel a").click(function(e){e.preventDefault();var a=t("#calculator"),o='<div class="top"><span class="clear">C</span><div class="screen"></div></div><div class="keys"><span>7</span><span>8</span><span>9</span><span class="operator">+</span><span>4</span><span>5</span><span>6</span><span class="operator">-</span><span>1</span><span>2</span><span>3</span><span class="operator">/</span><span>0</span><span>.</span><span class="eval">=</span><span class="operator">x</span></div>';a.html(o).dialog({modal:!0,minWidth:400,title:Mustache.render("{{calculator_title}}",lang)}).dialog("open"),calculator()}),t("body").on("click","#transfer-btn",function(){t.ajax({type:"post",url:add_transaction_url,data:t("body #frm-transfer").serialize(),dataType:"json",success:function(e){"1"==e.status&&(t("body #transactions-list tbody").prepend(e.html),t("body .transaction-total").html(e.total),t("body #frm-transfer")[0].reset(),setInterval(function(){t("body .new-trans").removeClass("new-trans")},5e3))}})}),t("body").on("click","#help a",function(){var e=t("<div id='help-form'></div>"),a='<div style="text-align: center;font-weight: bold;">Get Suport or Report Bug</div><ul>';a+="<li>SkypeId: vna_typn",a+='<li>Email: <a href="mailto:[email protected]">[email protected]</a></li>',a+='<li>Website: <a href="http://magetop.com">magetop.com</a></li>',a+="</ul>",e.html(a).dialog({modal:!0})}),t("body").on("click","#transaction-list .pagination .links a",function(){var e=t(this).attr("href");return t.ajax({url:e,success:function(e){t("body #transaction-list").html(e)}}),!1}),t("body").on("click","#refund-btn",function(){var a=t(this).attr("order_id");t("#refund-list").dialog("close"),t("#refund-list").remove();var o=t("<div id='refund-form'></div>");t.ajax({url:refund_url,type:"post",data:{order_id:a},success:function(n){o.html(n).dialog({modal:!0,minWidth:800,title:"Orders #"+a,close:function(){t("#refund-form").remove()},buttons:{Apply:function(){var a=t(this);e.clear().done(function(){a.dialog("close").remove()})},Cancel:function(){return t(this).dialog("close").remove(),!1}}}).dialog("open")}})}),t("body").on("change","#item_price",function(){var e=t(this).attr("item_id"),a=t.indexedDB(D).objectStore("cart"),o=t(this).val();e=parseInt(e),a.get(e).done(function(t){t.price=o,t.subtotal=t.price*t.qty,a.put(t).done(function(){y(e,function(){u()})})})}),t(document).on("click","#setting-panel",function(){var e=t.indexedDB(D).objectStore("pos"),a="";e.get("default_payment").done(function(t){a+='<div class="setting-box">',a+="<form>",a+='<div class="setting-payment">',a+='<div class="setting-title">Default Payment Method</div>',a+='<ul style="list-style:none;">';for(i in payment){var e=payment[i];a+=t&&e.payment_id==t.value?'<li><input type="radio" name="default-payment" id="pay-'+e.payment_id+'" checked="checked" value="'+e.payment_id+'" title="'+e.payment_name+'">'+e.payment_name+"</li>":'<li><input type="radio" name="default-payment" id="pay-'+e.payment_id+'" value="'+e.payment_id+'" title="'+e.payment_name+'">'+e.payment_name+"</li>"}a+="</ul>",a+="</div>"}).then(function(){e.get("quick_checkout").done(function(t){a+='<div class="setting-quick-checkout">',a+='<div class="setting-title">Enable Quick Checkout</div>',a+='<ul style="list-style: none;">',t&&1==t.value?(a+='<li><input name="quick_checkout" type="radio" value="0">No</li>',a+='<li><input name="quick_checkout" type="radio" value="1" checked="checked">Yes</li>'):(a+='<li><input name="quick_checkout" type="radio" value="0" checked="checked">No</li>',a+='<li><input name="quick_checkout" type="radio" value="1">Yes</li>'),a+="</form>",a+="</div>"}).then(function(){e.get("disable_print_receipt").done(function(t){a+='<div class="setting-print-receipt">',a+='<div class="setting-title">Print Receipt</div>',a+='<ul style="list-style: none;">',t&&1==t.value?(a+='<li><input name="disable_print_receipt" type="radio" value="0">Yes</li>',a+='<li><input name="disable_print_receipt" type="radio" value="1" checked="checked">No</li>'):(a+='<li><input name="disable_print_receipt" type="radio" value="0" checked="checked">Yes</li>',a+='<li><input name="disable_print_receipt" type="radio" value="1">No</li>'),a+="</ul>",a+="</div>",a+="</form>",a+="</div>"}).then(function(){t(a).dialog({title:"Setting",modal:!0,overlay:{backgroundColor:"#000",opacity:.5},buttons:{Apply:function(){var a=t('input[name="default-payment"]:checked').val(),o=t('input[name="quick_checkout"]:checked').val(),n=t('input[name="disable_print_receipt"]:checked').val(),i=new Object;i.key="default_payment",i.value=a,e.put(i).done(function(){});var r=new Object;r.key="quick_checkout",r.value=o,e.put(r).done(function(){});var c=new Object;return c.key="disable_print_receipt",c.value=n,e.put(c).done(function(){}),t(this).dialog("close").remove(),!1},Cancel:function(){return t(this).dialog("close").remove(),!1}}})})})})})}function p(e,a,o){var n=t.indexedDB(D).objectStore("cart"),r=t.indexedDB(D).objectStore("order");r.add(e).done(function(){n.clear().done(function(){t("#total_paid input").val("0"),u(),a.dialog("close").remove()}).then(function(){t("#total_paid input").val("0"),u()}).then(function(){var a=new Date,n=config.currency.default_format,r="<!DOCTYPE HTML>";r+='<html lang="en-us">',r+="<head></head>",r+="<body>",r+=receipt_template,r+="</body>",r+="</html>";var c=new Array,l=0,u=0;for(i in e.data){var d=e.data[i];"product"==d.type&&(d.price_formated=numeral(d.price).format(n),d.subtotal_formated=numeral(d.subtotal).format(n),c.push(d),l+=parseFloat(d.subtotal))}for(i in e.discount){var s=e.discount[i];u+="custom"==s.type?"P"==s.value.type?l*s.value.price/100:s.value.price:s.value.amount}var p=new Object;for(i in o)"customer"==o[i].type&&(p=o[i].value);var v={date:a.getDate()+"/"+a.getMonth()+"/"+a.getFullYear(),invoice:config.store.config_invoice_prefix+e.invoice_id,invoice_prefix:config.store.config_invoice_prefix,products:c,discount:u,subtotal:l,discount:u,tax:e.tax_total,grand_total:e.grand_total,subtotal_formated:numeral(l).format(n),tax_formated:numeral(e.tax_total).format(n),discount_formated:numeral(u).format(n),grandtotal_formated:numeral(e.grand_total).format(n),customer:p,cashier:cashier_name},r=Mustache.render(r,v),m=t.indexedDB(D).objectStore("product");m.each(function(t){var e=t.value.quantity;for(i in c)c[i].product_id==t.value.product_id&&e>0&&(e-=c[i].qty);t.value.quantity=e,m.put(t.value)});var f=t.indexedDB(D).objectStore("pos"),_=0;f.get("disable_print_receipt").done(function(t){t&&1==t.value&&(_=1)}).then(function(){if(0==_){var t=window.open("","_blank","width=700,height=800");t.document.writeln(r),t.document.close(),t.focus(),t.print(),x(t)}}),t("button[value='0']").trigger("click")})})}function v(e,a,o){var n=t.indexedDB(D).objectStore("cart");n.get(e).done(function(t){var r=t.price_no_opt,c=0;for(i in a){var l=a[i];l.price&&("+"==l.price_prefix?(r=parseFloat(r)+parseFloat(l.price),c=parseFloat(c)+parseFloat(l.price)):(r=parseFloat(r)-parseFloat(l.price),c=parseFloat(c)-parseFloat(l.price)))}t.opt_total_price=c,t.price=r,t.subtotal=t.price*t.qty,t.options=a,n.put(t).done(function(){y(e,function(){o(t)})})})}function m(e,a){var o=t.indexedDB(D).objectStore("cart");o.get(e).done(function(t){a(t)})}function f(e,a){e=String(e);var o=t.indexedDB(D).objectStore("product");o.get(e).done(function(t){a(t)})}function _(e,a,o){e=String(e);var n=t.indexedDB(D).objectStore("product"),r=t.indexedDB(D).objectStore("pos"),c=t.indexedDB(D).objectStore("cart");r.get("default_customer_id").done(function(t){if(void 0!=typeof t.value.customer_group_id){var r=t.value.customer_group_id;c.index("type").each(function(t){r=t.value.value.customer_group_id},"customer").then(function(){n.get(e).done(function(t){if(t.price){var e=new Object;if(e.price=t.base_price,e.base_price=t.base_price,e.special_price=null,e.discount_price=null,t.special.length>0){var n=new Array;for(i in t.special)if(String(t.special[i].customer_group_id)==String(r)){var c=!1,l=!1,u=new Date,d=new Date(t.special[i].date_start),s=new Date(t.special[i].date_end);("0000-00-00"==t.special[i].date_start||u>d)&&(c=!0),("0000-00-00"==t.special[i].date_end||s>u)&&(l=!0),c&&l&&(n[t.special[i].priority]=n[t.special[i].priority]&&parseFloat(n[t.special[i].priority].base_price)<parseFloat(t.special[i].base_price)?n[t.special[i].priority]:t.special[i])}if(n.length>0){var p=Math.min.apply(Math,Object.keys(n));e.price=n[p].base_price,e.special_price=n[p].base_price}}if(t.discounts.length>0){var v=e.price;for(i in t.discounts){var m=t.discounts[i];m.quantity<=a&&parseFloat(m.price)<parseFloat(v)&&(v=m.price)}e.price=v,e.discount_price=v}o(e)}})})}})}function h(t,e){var a="",o=config.currency.default_format,a=numeral(t).format(o);e(a)}function y(e,a){var o=(t.indexedDB(D).objectStore("pos"),t.indexedDB(D).objectStore("tax")),n=t.indexedDB(D).objectStore("cart");g("tax_class_base",function(t){var r=t;if(0!=r&&-1!=r&&g("tax_base_on",function(t){var c=t;g("default_customer_id",function(t){var l=t,u=new Array;o.index("customer_group_id").each(function(t){t.value.based==c&&u.push(t.value)},l.customer_group_id).then(function(){var t=new Object;n.get(e).done(function(e){var o=new Array,c=0,l=0;for(i in u)if(u[i].tax_class_id==r){var d=u[i];if(e.qty>0){d.qty=e.qty;var s=d.rate,p=d.type,v=0,m=new Object;m.name=d.name,m.tax_rate_id=d.tax_rate_id,o[l]=m,v+="P"==p?parseFloat(e.price)/100*parseFloat(s):parseFloat(s),c+=v,o[l].tax_price=v,l++}}t.item_id=e.id,t.total=c,t.modified=!1,t.tax=o,e.tax=t,n.put(e).done(function(){a(e)})},"product")})})}),0==r){var c=new Object;n.get(e).done(function(t){var e=new Array;c.item_id=t.id,c.total=0,c.modified=!1,c.tax=e,t.tax=c,n.put(t).done(function(){a(t)})},"product")}-1==r&&g("tax_base_on",function(t){var r=t;g("default_customer_id",function(t){var c=t,l=new Array;o.index("customer_group_id").each(function(t){t.value.based==r&&l.push(t.value)},c.customer_group_id).then(function(){var t=new Object;n.get(e).done(function(e){var o=new Array,r=0,c=0;for(i in l)if(l[i].tax_class_id==e.tax_class_id){var u=l[i];if(e.qty>0){u.qty=e.qty;var d=u.rate,s=u.type,p=0,v=new Object;v.name=u.name,v.tax_rate_id=u.tax_rate_id,o[c]=v,p+="P"==s?parseFloat(e.price)/100*parseFloat(d):parseFloat(d),r+=p,o[c].tax_price=p,c++}}t.item_id=e.id,t.total=r,t.modified=!1,t.tax=o,e.tax=t,n.put(e).done(function(){a(e)})},"product")})})})})}function g(e,a){var o=t.indexedDB(D).objectStore("pos");o.get(e).done(function(t){t&&a(t.value)})}function b(){var e=t.indexedDB(D).objectStore("cart"),a=0,o=0,n=0,i=0,r="",c="",l=0,u=t.indexedDB(D).objectStore("cart_saved");u.count().done(function(e){t("#saved_count").html(parseInt(e))}),e.each(function(t){if("product"==t.value.type&&(a=parseFloat(a)+parseFloat(t.value.subtotal),n=parseFloat(n)+parseFloat(t.value.subtotal),t.value.tax.total&&(l+=parseFloat(t.value.tax.total)*parseInt(t.value.qty)),o+=t.value.qty),"comment"==t.value.type&&(r=t.value.comment),"customer"==t.value.type&&(c=t.value.value.firstname+" "+t.value.value.lastname),"discount"==t.value.type){var e=t.value.value;if(e.egift&&(i=parseFloat(i)+parseFloat(e.egift.amount),n=parseFloat(n)-parseFloat(i)),e.custom){var u=e.custom,d=u.price;if(parseFloat(u.price)<parseFloat(a))if("P"==u.type){var s=parseFloat(a)*parseFloat(d)/100;i=parseFloat(i)+parseFloat(s),n=parseFloat(n)-parseFloat(s)}else i=parseFloat(i)+parseFloat(d),n=parseFloat(n)-parseFloat(d)}}}).then(function(){t("#item_count span").html(o),n+=l;var e=config.currency.number_format;t("#total_paid input").val(numeral(n).format(e));var u=(numeral(t("#total_paid input").val()).format(e),numeral(n).format(e),numeral(parseFloat(numeral().unformat(t("#total_paid input").val()))-parseFloat(n)).format(config.currency.default_format));t("#refund_value span").html(u),h(l,function(e){t("#tax_value").html(e)}),h(a,function(e){t("#total_value span").html(e)}),h(n,function(e){t("#total_able span").html(e),t("#total_able span").attr("total",parseFloat(n))}),h(i,function(e){t("#discount_value button").html(e)}),""==r&&(r=Mustache.render("{{no_comment}}",lang)),t("#comment_value span").html(r),""!=c?t("#customer_value button").html(c):(c=void 0!=config.default_customer.customer_id?config.default_customer.firstname+" "+config.default_customer.lastname:Mustache.render("{{default_guest_name}}",lang),t("#customer_value button").html(c))})}function x(t){"complete"==document.readyState?t.close():setTimeout("CheckWindowState()",2e3)}function w(t){var e=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return e.test(t)}function F(t,e){return t.sort(function(t,a){var o=t[e],n=a[e];return n>o?-1:o>n?1:0})}var q=null;const D="OpenPos";window.onbeforeunload=e,t(".menu-refresh").click(function(){t(".menu-refresh img#refresh").hide(),t(".menu-refresh img#loading").show(),t.ajax({url:data_url,faild:function(){alert("No internet connection. Your POS in Offline Mode."),t(".menu-refresh img#refresh").show(),t(".menu-refresh img#loading").hide()},success:function(){t.indexedDB(D).deleteDatabase().done(function(){a(function(){t(".menu-refresh img#refresh").show(),t(".menu-refresh img#loading").hide(),l(),s()})})}})}),a(function(){l(),s(),t("#product-cart-list").jScrollPane({showArrows:!0})})}}(jQuery);

Function Calls

None

Variables

None

Stats

MD5 bd02f6c92b6fdd5b352b62cc0c635c4b
Eval Count 0
Decode Time 99 ms