(function(){var d=window.applicationCache;if(!d.addEventListener){return}function a(){switch(d.status){case 0:dummy=("Cache status: Uncached");break;case 1:dummy=("Cache status: Idle");break;case 2:dummy=("Cache status: Checking");break;case 3:dummy=("Cache status: Downloading");break;case 4:dummy=("Cache status: Updateready");break;case 5:dummy=("Cache status: Obsolete");break}}function c(){d.swapCache();dummy=("Cache has been updated due to a change found in the manifest")}function b(){dummy=("You're either offline or something has gone horribly wrong.")}if(RegExp("WebKit").test(navigator.userAgent)){window.addEventListener("load",a,false);d.addEventListener("updateready",c,false);d.addEventListener("error",b,false)}})();Date.prototype.format=function(e){var d="";var c=Date.replaceChars;for(var b=0;b<e.length;b++){var a=e.charAt(b);if(c[a]){d+=c[a].call(this)}else{d+=a}}return d};Date.replaceChars={shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longMonths:["January","February","March","April","May","June","July","August","September","October","November","December"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d:function(){return(this.getDate()<10?"0":"")+this.getDate()},D:function(){return Date.replaceChars.shortDays[this.getDay()]},j:function(){return this.getDate()},l:function(){return Date.replaceChars.longDays[this.getDay()]},N:function(){return this.getDay()+1},S:function(){return(this.getDate()%10==1&&this.getDate()!=11?"st":(this.getDate()%10==2&&this.getDate()!=12?"nd":(this.getDate()%10==3&&this.getDate()!=13?"rd":"th")))},w:function(){return this.getDay()},z:function(){return"Not Yet Supported"},W:function(){return"Not Yet Supported"},F:function(){return Date.replaceChars.longMonths[this.getMonth()]},m:function(){return(this.getMonth()<9?"0":"")+(this.getMonth()+1)},M:function(){return Date.replaceChars.shortMonths[this.getMonth()]},n:function(){return this.getMonth()+1},t:function(){return"Not Yet Supported"},L:function(){return(((this.getFullYear()%4==0)&&(this.getFullYear()%100!=0))||(this.getFullYear()%400==0))?"1":"0"},o:function(){return"Not Supported"},Y:function(){return this.getFullYear()},y:function(){return(""+this.getFullYear()).substr(2)},a:function(){return this.getHours()<12?"am":"pm"},A:function(){return this.getHours()<12?"AM":"PM"},B:function(){return"Not Yet Supported"},g:function(){return this.getHours()%12||12},G:function(){return this.getHours()},h:function(){return((this.getHours()%12||12)<10?"0":"")+(this.getHours()%12||12)},H:function(){return(this.getHours()<10?"0":"")+this.getHours()},i:function(){return(this.getMinutes()<10?"0":"")+this.getMinutes()},s:function(){return(this.getSeconds()<10?"0":"")+this.getSeconds()},e:function(){return"Not Yet Supported"},I:function(){return"Not Supported"},O:function(){return(-this.getTimezoneOffset()<0?"-":"+")+(Math.abs(this.getTimezoneOffset()/60)<10?"0":"")+(Math.abs(this.getTimezoneOffset()/60))+"00"},P:function(){return(-this.getTimezoneOffset()<0?"-":"+")+(Math.abs(this.getTimezoneOffset()/60)<10?"0":"")+(Math.abs(this.getTimezoneOffset()/60))+":"+(Math.abs(this.getTimezoneOffset()%60)<10?"0":"")+(Math.abs(this.getTimezoneOffset()%60))},T:function(){var b=this.getMonth();this.setMonth(0);var a=this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/,"$1");this.setMonth(b);return a},Z:function(){return -this.getTimezoneOffset()*60},c:function(){return this.format("Y-m-d")+"T"+this.format("H:i:sP")},r:function(){return this.toString()},U:function(){return this.getTime()/1000}};String.prototype.trim=function(){return this.replace(/^\s*/,"").replace(/\s*$/,"")};Date.prototype.addDays=function(a){var b=new Date(this.getFullYear(),this.getMonth(),this.getDate()+a,this.getHours(),this.getMinutes(),this.getSeconds(),this.getMilliseconds());return b};Date.prototype.getUnixtime=function(){var a=this.getTime();a=Math.round(a/1000,0);return a};Date.prototype.setISO8601=function(b){var c="([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";var f=b.match(new RegExp(c));var e=0;var a=new Date(f[1],0,1);if(f[3]){a.setMonth(f[3]-1)}if(f[5]){a.setDate(f[5])}if(f[7]){a.setHours(f[7])}if(f[8]){a.setMinutes(f[8])}if(f[10]){a.setSeconds(f[10])}if(f[12]){a.setMilliseconds(Number("0."+f[12])*1000)}this.setTime(a.getTime());return this};var CLMWCONNECTOR={strUsername:null,strPassword:null,fncExecOnReturn:null,blnExecuting:false,blnConnected:false,chrWordSplit:"~~~~",chrLineSplit:"||||",strLastCommand:null,arrCustomerDataFormat:null,tmp1:null,tmp2:null,tmp3:null,tmp4:null,tmp5:null,intCurrCustomerListView:0,intCurrProductListView:1,intCurrAccountListView:0,intCurrTransListView:0,intCurrJobListView:0,strTransListCust:"",blnAddNewCustFromNewSo:false,strAddNewCustCode:"",strNewSalesOrderCustCode:"",objLastTransDate:new Date(Date.now()-7*24*3600*1000),arrTransSeq:new Array(),intSyncCurrent:0,syncLocalData:function(){var a=localStorage.getItem("toSave");if(a){a=new TAFFY(a);if(a.getLength()==0){return}if(a.getLength()<CLMWCONNECTOR.intSyncCurrent){return}var b=a.get(CLMWCONNECTOR.intSyncCurrent);if(b){CLMWCONNECTOR.saveData(b.data,b.importMap,function(c){if(c.Ok){dummy=("Saved "+b.data);if(a.getLength()==CLMWCONNECTOR.intSyncCurrent){$("#menu_view_sendsaved").hide();localStorage.setItem("toSave",null);CLMWCONNECTOR.intSyncCurrent=0}else{$("#menu_view_sendsaved").show()}}CLMWCONNECTOR.intSyncCurrent++;CLMWCONNECTOR.syncLocalData()},true)}}return},doLogin:function(a){dummy=("Doing login ");this.fncExecOnReturn=a;this.blnExecuting=true;this.strLastCommand="doLogin";if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"doLogin"},function(d){CLMWVIEW.hideLoading();CLMWCONNECTOR.blnExecuting=false;var e=CLMWCONNECTOR.hashValue();dummy=("saving hash "+e+" "+d.data);CLMWCONNECTOR.fncExecOnReturn(d)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var c=CLMWCONNECTOR.hashValue();var b=localStorage.getItem(c);dummy=("checking hash "+c+" : found - "+b);if((b=="undefined")||(b==null)){data={data:"error"}}data={data:b};CLMWCONNECTOR.fncExecOnReturn(data)}},getTableData:function(e,b,f,g,k){dummy=("Getting table: "+e+" with search "+f);this.fncExecOnReturn=k;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"getTableData",columns:b,search:f,sort:g,table:e,fetchall:0},function(l){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(l);CLMWCONNECTOR.blnExecuting=false;var m=CLMWCONNECTOR.hashValue();CLMWCONNECTOR.fncExecOnReturn(l)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var a=CLMWCONNECTOR.hashValue();var d=localStorage.getItem(a);dummy=("checking hash "+a+" : found - "+d);if((d=="undefined")||(d==null)){alert("Sorry! selected data is not available in offline mode");return}else{var h=new TAFFY(d);var c=new Array();h.forEach(function(m,l){c[l]=m});data={data:c};CLMWCONNECTOR.fncExecOnReturn(data)}}},loadRecord:function(f,a,e,b){dummy=("Loading record: "+f+" with ID "+e);this.fncExecOnReturn=b;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"loadRecord",data:e,searchCol:a,table:f},function(g){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(g);CLMWCONNECTOR.blnExecuting=false;var h=CLMWCONNECTOR.hashValue();dummy=("saving hash "+h+" "+g.data);CLMWCONNECTOR.fncExecOnReturn(g)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var d=CLMWCONNECTOR.hashValue();var c=localStorage.getItem(d);dummy=("checking hash "+d+" : found - "+c);if((c=="undefined")||(c==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:c};CLMWCONNECTOR.fncExecOnReturn(data)}}},loadTran:function(d,a){dummy=("Loading transcation:  with ID "+d);this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"loadTran",seq:d},function(e){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(e);CLMWCONNECTOR.blnExecuting=false;var f=CLMWCONNECTOR.hashValue();CLMWCONNECTOR.fncExecOnReturn(e)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var c=CLMWCONNECTOR.hashValue();var b=localStorage.getItem(c);if((b=="undefined")||(b==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:b};CLMWCONNECTOR.fncExecOnReturn(data)}}},listAccounts:function(c,a){dummy=("Loading account for : "+c);this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,account:c,word_split:CLMWCONNECTOR.chrWordSplit,line_split:CLMWCONNECTOR.chrLineSplit,command:"listAccounts"},function(e){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(e);CLMWCONNECTOR.blnExecuting=false;var f=CLMWCONNECTOR.hashValue();CLMWCONNECTOR.fncExecOnReturn(e)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var d=CLMWCONNECTOR.hashValue();var b=localStorage.getItem(d);if((b=="undefined")||(b==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:b};CLMWCONNECTOR.fncExecOnReturn(data)}}},loadJob:function(d,a){dummy=("Loading transcation:  with Code "+d);this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"loadJob",code:d},function(e){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(e);CLMWCONNECTOR.blnExecuting=false;var f=CLMWCONNECTOR.hashValue();CLMWCONNECTOR.fncExecOnReturn(e)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var c=CLMWCONNECTOR.hashValue();var b=localStorage.getItem(c);if((b=="undefined")||(b==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:b};CLMWCONNECTOR.fncExecOnReturn(data)}}},saveData:function(f,c,e,a){dummy=("Exporting data: "+f+" using map "+c);this.fncExecOnReturn=e;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"saveData",data:f,importMap:c},function(g){CLMWVIEW.hideLoading();dummy=("Returned for save!");dummy=(g);CLMWCONNECTOR.blnExecuting=false;if((g.data.indexOf("created")==-1)||(g.data.indexOf("updated")==-1)||g.error){}else{g.Ok=1}CLMWCONNECTOR.fncExecOnReturn(g)},"json")}else{if(!a){var d={data:f,importMap:c,id:(new Date()).getTime()};var b=localStorage.getItem("toSave");if(!b){b=new TAFFY([d])}else{b=new TAFFY(b);b.insert(d)}localStorage.setItem("toSave",b.stringify());$("#menu_view_sendsaved").show();CLMWCONNECTOR.fncExecOnReturn({Ok:1})}}},saveTrans:function(b,a){dummy=("Exporting trans: "+b);this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"saveData",data:b,importMap:"web_salesorder_import.impo"},function(c){CLMWVIEW.hideLoading();dummy=("Returned for save!");dummy=(c);CLMWCONNECTOR.blnExecuting=false;if(c.error){alert("Saving failed! Error given :"+c.error)}CLMWCONNECTOR.fncExecOnReturn(c)},"json")}},getSOData:function(a){dummy=("Getting new sales order customer/products");this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"getSOData"},function(d){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(d);CLMWCONNECTOR.blnExecuting=false;var e=CLMWCONNECTOR.hashValue();dummy=("saving hash "+e+" "+d.data);CLMWCONNECTOR.fncExecOnReturn(d)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var c=CLMWCONNECTOR.hashValue();var b=localStorage.getItem(c);dummy=("checking hash "+c+" : found - "+b);if((b=="undefined")||(b==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:b};CLMWCONNECTOR.fncExecOnReturn(data)}}},getCustomers:function(a){dummy=("Getting new customer");this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"getCustomers"},function(d){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(d);CLMWCONNECTOR.blnExecuting=false;var e=CLMWCONNECTOR.hashValue();dummy=("saving hash "+e+" "+d.data);CLMWCONNECTOR.fncExecOnReturn(d)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var c=CLMWCONNECTOR.hashValue();var b=localStorage.getItem(c);dummy=("checking hash "+c+" : found - "+b);if((b=="undefined")||(b==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:b};CLMWCONNECTOR.fncExecOnReturn(data)}}},getProducts:function(a){dummy=("Getting new products");this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"getProducts"},function(d){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(d);CLMWCONNECTOR.blnExecuting=false;var e=CLMWCONNECTOR.hashValue();dummy=("saving hash "+e+" "+d.data);CLMWCONNECTOR.fncExecOnReturn(d)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var c=CLMWCONNECTOR.hashValue();var b=localStorage.getItem(c);dummy=("checking hash "+c+" : found - "+b);if((b=="undefined")||(b==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:b};CLMWCONNECTOR.fncExecOnReturn(data)}}},intTransCountAvail:1,intTransCurrStartSeq:Math.pow(2,31),intTransCurrTotal:0,loadTrans:function(a,b,c){strCommand="loadTrans";dummy=("changed command "+strCommand);this.fncExecOnReturn=c;this.blnExecuting=true;if(this.strLastCommand!=(strCommand+b)){this.intTransCurrLimit=0}this.strLastCommand=strCommand+b;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:strCommand,columns:a,search:b,start:this.intTransCurrStartSeq},function(f){CLMWVIEW.hideLoading();CLMWCONNECTOR.blnExecuting=false;var g=CLMWCONNECTOR.hashValue();dummy=("saving hash "+g+" "+f.data);CLMWCONNECTOR.fncExecOnReturn(f)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var e=CLMWCONNECTOR.hashValue();var d=localStorage.getItem(e);dummy=("checking hash "+e+" : found - "+d);if((d=="undefined")||(d==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:d};CLMWCONNECTOR.fncExecOnReturn(data)}}},doAccountBalance:function(e,a,b){dummy=("Doing account balance of "+e);this.fncExecOnReturn=b;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"doBalance",id:e,months:a},function(f){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(f);CLMWCONNECTOR.blnExecuting=false;var g=CLMWCONNECTOR.hashValue();dummy=("saving hash "+g+" "+f.data);CLMWCONNECTOR.fncExecOnReturn(f.data)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var d=CLMWCONNECTOR.hashValue();var c=localStorage.getItem(d);dummy=("checking hash "+d+" : found - "+c);if((c=="undefined")||(c==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:c};CLMWCONNECTOR.fncExecOnReturn(data)}}},doAccountMovement:function(e,a,b){dummy=("Doing account movement of "+e);this.fncExecOnReturn=b;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"doMovement",id:e,months:a},function(f){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(f);CLMWCONNECTOR.blnExecuting=false;var g=CLMWCONNECTOR.hashValue();dummy=("saving hash "+g+" "+f.data);CLMWCONNECTOR.fncExecOnReturn(f.data)},"json")}else{CLMWCONNECTOR.blnExecuting=false;var d=CLMWCONNECTOR.hashValue();var c=localStorage.getItem(d);dummy=("checking hash "+d+" : found - "+c);if((c=="undefined")||(c==null)){alert("Sorry! selected data is not available in offline mode");return}else{data={data:c};CLMWCONNECTOR.fncExecOnReturn(data)}}},doReportList:function(a){dummy=("Doing report list");this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,command:"reportList"},function(b){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(b);CLMWCONNECTOR.blnExecuting=false;CLMWCONNECTOR.fncExecOnReturn(b.data)},"json")}else{alert("Sorry! selected data is not available in offline mode");return}},runReport:function(b,a){dummy=("Running report "+b);this.fncExecOnReturn=a;this.blnExecuting=true;if(navigator.onLine){CLMWVIEW.showLoading();$.post("process.php",{username:this.strUsername,password:this.strPassword,report:b,command:"runReport"},function(c){CLMWVIEW.hideLoading();dummy=("Returned for load!");dummy=(c);CLMWCONNECTOR.blnExecuting=false;CLMWCONNECTOR.fncExecOnReturn(c.data)},"json")}else{alert("Sorry! selected data is not available in offline mode");return}},blnFlagBundyStop:false,strJobRecording:null,intJobStartTime:null,showJobElapsed:function(){if(!CLMWCONNECTOR.strJobRecording){return}if(!CLMWCONNECTOR.intJobStartTime){return}var c=new Date();c=c.getTime();var d=c-CLMWCONNECTOR.intJobStartTime;d=Math.round(d/1000);d=d/3600;var a=Math.floor(d);var b=Math.floor((d-a)*60);if(b<10){b="0"+b}$("#menu_stop_clock").text("Stop "+CLMWCONNECTOR.strJobRecording+" (Elapsed "+a+":"+b+")")},hashValue:function(){return MD5(this.strUsername+this.strPassword+this.strLastCommand)},arrSOProducts:new Array(),arrSOCustomers:new Array(),splitString:function(e){var b=new Array();var a=e.split(this.chrLineSplit);var d;for(var c=0;c<a.length-1;c++){d=a[c].split(this.chrWordSplit);b[c]=d}return b}};var CLMWVIEW={strCurrentListView:null,fnEditFunc:null,tmp1:null,tmp2:null,tmp3:null,tmp4:null,tmp5:null,arrTableData:new Array(),colours:new Array("None","orange","red","magenta","cyan","blue","green","brown"),blnAppendTable:false,populateTable:function(d,e,h,f,b){var c="";var a="";this.arrTableData=e;for(j=0;j<e.length;j++){var g=e[j];if(g.Colour){a=' style="color:'+g.Colour+';"'}c+='<li class="detail" rel="'+g.id+'"><a href="#'+f+'" '+a+">"+h(g)+"</a></li>"}if(this.blnAppendTable){$("#"+d+" > ul").append(c)}else{$("#"+d+" > ul").html(c)}this.fnEditFunc=b;if(this.blnAppendTable){this.blnAppendTable=false}},clearForm:function(strFormName,defaults){var children=$("#"+strFormName+" > ul > li > input");this.tmp1=strFormName;this.tmp2=defaults;dummy=("Clearing form "+strFormName);$.each(children,function(){var id=$(this).attr("id");if(!id){return}$(this).val("");var fname=id.replace(CLMWVIEW.tmp1+"_","");if(CLMWVIEW.tmp2&&eval("CLMWVIEW.tmp2."+fname)){$(this).val(eval("CLMWVIEW.tmp2."+fname))}else{$(this).val("")}})},strLastViewedDiv:"main_menu",swapView:function(c,b,a){CLMWVIEW.strLastViewedDiv=c;jQT.goTo("#"+b,"dissolve",(a==undefined)?false:a);return;$("#"+c).hide();$("#"+b).show();$("#"+b).removeClass("hidden")},showLoading:function(){$("#trans_more").prepend('<img src="assets/images/ajax-loader.gif" width="15" height="15"/>&nbsp;');$("#loading").attr("width","100%");$("#loading").attr("height","100%");$("#loading").show()},hideLoading:function(){$("#trans_more").text("More");$("#loading").hide()},populateFieldValues:function(b,a){dummy=("Populating "+b);this.tmp1=b;this.tmp2=a.data;$.each(a.data,function(c,e){var d=CLMWVIEW.tmp1;if(document.getElementById(d+"_"+c)){if($("#"+d+"_"+c).is("input")){$("#"+d+"_"+c).val(e)}else{if($("#"+d+"_"+c).is("select")){$("#"+d+"_"+c).val(e)}else{$("#"+d+"_"+c).text(e)}}}})},populateViewCell:function(b,d,c){if(jQuery.trim(d)!=""){var a=$("#"+b);a.text(d);if(c!=""){a.attr("href",c+d)}if(document.getElementById(b+"_holder")){$("#"+b+"_holder").show()}a.show()}else{if(document.getElementById(b+"_holder")){$("#"+b+"_holder").hide()}}},arrJoin:function(c,d){var a="";for(var b=0;b<c.length;b++){if(c[b]!=""){a+=c[b]+d}}return a},formatNumber:function(a){return parseFloat(a)},toFloat:function(a){a=a+"";a=a.replace(/[^-\d.]/g,"");a=a.substr(0,1)+a.substr(1).replace(/-/g,"");a=a.replace(/\./,",").replace(/\./g,"").replace(/,/,".");a=parseFloat(parseFloat(a).toFixed(4));if(isNaN(a)){return null}return a},formatCurrency:function(a){a=CLMWVIEW.toFloat(a);if(a<0){negativeSign="-";a=Math.abs(a)}else{negativeSign=""}a=parseFloat(a).toFixed(2);intPart=a.substr(0,a.indexOf("."));decPart=a.substr(a.indexOf(".")+1);intPart=intPart.replace(/\d{1,3}(?=(\d{3})+(?!\d))/g,"$&,");a=intPart+"."+decPart;return negativeSign+"$"+a},sectionDisplaySet:function(a){a.find("ul.rounded").each(function(){var c=$(this);if(c.is(".always_show")){return}if(c.find("li:visible").length==0){c.hide()}else{c.show()}var b=c.prev("h2");if(b.length&&!b.is(".view_header")&&c.is(":hidden")){b.hide()}else{if(b.length){b.show()}}})},plot_graph:function(b,e){var d=$("#"+b);if(d.length==0||!d.is(":visible")){return}var f=$.plot(d,[{data:e||[],label:"Balance",color:"rgb(216, 50, 50)"}],{xaxis:{mode:"time",timeformat:"%b-%y",ticks:(jQT.getOrientation()=="landscape"?9:6)},monthNames:CLMWVIEW.arrMonths,legend:{show:false,position:"se",backgroundColor:"",backgroundOpacity:0,noColumns:2},crosshair:{mode:"x"},grid:{show:true,hoverable:true,autoHighlight:true,clickable:true},series:{lines:{show:true,steps:false},points:{show:false},bars:{show:false,barWidth:1}}});var g,l=null;var h=$("#graph_legend");CLMWVIEW.arrGData=e;var a=b;var k=function(){var o;l=null;for(var q=0,r;(r=CLMWVIEW.arrGData[q])!=undefined;++q){var n=r[0];if(n>g.x){var p=new Date();p.setTime(n);o=r[1];$("#graph_legend").text(CLMWVIEW.arrMonths[p.getMonth()].toUpperCase()+"/"+(p.getFullYear()+"").substring(2)+": Balance "+CLMWVIEW.formatCurrency(o));return}}};var c=new Date();g={x:c.getMonth()};k();d.bind("plothover",function(n,o,m){g=o;if(!l){l=setTimeout(k,50)}});d.bind("touchmove",function(m){pos={x:m.x,y:m.y};g=pos;if(!l){l=setTimeout(k,50)}});d.bind("swipe",function(m){pos={x:m.x,y:m.y};g=pos;if(!l){l=setTimeout(k,50)}})},arrMonths:["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],arrGData:new Array(),plot_bar:function(b,d){var c=$("#"+b);if(c.length==0||!c.is(":visible")){return}var e=$.plot(c,[{data:d||[],label:"Balance",color:"rgb(216, 50, 50)"}],{xaxis:{mode:"time",timeformat:"%b-%y",ticks:(jQT.getOrientation()=="landscape"?9:6)},monthNames:CLMWVIEW.arrMonths,legend:{show:false,position:"se",backgroundColor:"",backgroundOpacity:0,noColumns:2},crosshair:{mode:"x"},grid:{show:true,hoverable:true,autoHighlight:true,clickable:true},series:{lines:{show:false,steps:false},points:{show:false},bars:{show:true,barWidth:(24*60*60*1000*15),align:"center"}}});var f,k=null;var h=$("#graph_legend");this.arrGData=d;var a=b;var g=function(){var n;k=null;var r=new Date();r.setTime(f.x);var q=(new Date(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),23,59,59)).getTime();for(var p=CLMWVIEW.arrGData.length-1,s;(s=CLMWVIEW.arrGData[p])!=undefined;p--){var l=s[0]-15*24*60*60*1000;if((l)<=q){var o=new Date();o.setTime(s[0]);n=s[1];$("#graph_legend").text(CLMWVIEW.arrMonths[o.getMonth()].toUpperCase()+"/"+(o.getFullYear()+"").substring(2)+": Balance "+CLMWVIEW.formatCurrency(n));return}}};$("#graph_legend").text(".");c.bind("plothover",function(m,n,l){f=n;if(!k){k=setTimeout(g,50)}});c.bind("touchmove",function(l){pos={x:l.x,y:l.y};f=pos;if(!k){k=setTimeout(g,50)}});c.bind("swipe",function(l){pos={x:l.x,y:l.y};f=pos;if(!k){k=setTimeout(g,50)}})},dateFormat:function(a){return a.getDate()+"/"+(a.getMonth()+1)+"/"+a.getFullYear()},transTypeDesc:function(a){if(a.substr(0,2)=="DI"){return"Debtor Invoice"}if(a.substr(0,2)=="SO"){return"Sales Order"}if(a.substr(0,2)=="PO"){return"Purchase Order"}if(a.substr(0,2)=="CI"){return"Creditor Invoice"}if(a.substr(0,2)=="JN"){return"Journal"}if(a.substr(0,2)=="CP"){return"Payment"}if(a.substr(0,2)=="CR"){return"Receipt"}return a}};function loadCustomer(a){CLMWCONNECTOR.loadRecord("Name","Code",a,function(b){CLMWVIEW.populateFieldValues("customer_form",(b));$("#customer_view ul").show();$("#customer_view_Code").text(b.data.Code);$("#customer_view_Name").text(b.data.Name);var c=parseInt(b.data.Colour);if(c>0){$("#customer_view_Name").css("color",CLMWVIEW.colours[c])}else{$("#customer_view_Name").css("color","")}CLMWVIEW.populateViewCell("customer_view_Phone",b.data.Phone,"tel:");CLMWVIEW.populateViewCell("customer_view_Fax",b.data.Fax,"fax:");CLMWVIEW.populateViewCell("customer_view_WebURL",b.data.WebURL.replace("http://",""),"http://");CLMWVIEW.populateViewCell("customer_view_Contact",b.data.Contact);CLMWVIEW.populateViewCell("customer_view_eMail",b.data.eMail,"mailto:");CLMWVIEW.populateViewCell("customer_view_DDI",b.data.DDI,"tel:");CLMWVIEW.populateViewCell("customer_view_Mobile",b.data.Mobile,"tel:");CLMWVIEW.populateViewCell("customer_view_AfterHours",b.data.AfterHours,"tel:");CLMWVIEW.populateViewCell("customer_view_Contact2",b.data.Contact2);CLMWVIEW.populateViewCell("customer_view_eMail2",b.data.eMail2,"mailto:");CLMWVIEW.populateViewCell("customer_view_DDI2",b.data.DDI2,"tel:");CLMWVIEW.populateViewCell("customer_view_Mobile2",b.data.Mobile2,"tel:");CLMWVIEW.populateViewCell("customer_view_AfterHours2",b.data.AfterHours2,"tel:");if(b.data.Address1!=""||b.data.Address2!=""){$("#customer_view_MailingAddress").html(CLMWVIEW.arrJoin(new Array(b.data.Address1,b.data.Address2,b.data.Address3,b.data.Address4,(b.data.State+" "+b.data.PostCode),b.data.AddressCountry),"<br/>")).show();$("#customer_view_MailingAddress").attr("href","http://maps.google.com/maps?q="+CLMWVIEW.arrJoin(new Array((b.data.Address1+" "+b.data.Address2+" "+b.data.Address3+" "+b.data.Address4),b.data.PostCode,b.data.State,b.data.AddressCountry),","));$("#customer_view_MailingAddress").parent().show()}else{CLMWVIEW.populateViewCell("customer_view_MailingAddress","","")}if(b.data.Delivery1!=""||b.data.Delivery2!=""){$("#customer_view_DeliveryAddress").html(CLMWVIEW.arrJoin(new Array(b.data.Delivery1,b.data.Delivery2,b.data.Delivery3,b.data.Delivery4,(b.data.DeliveryState+" "+b.data.DeliveryPostcode),b.data.DeliveryCountry),"<br/>")).show();$("#customer_view_DeliveryAddress").attr("href","http://maps.google.com/maps?q="+CLMWVIEW.arrJoin(new Array((b.data.Delivery1+" "+b.data.Delivery2+" "+b.data.Delivery3+" "+b.data.Delivery4),b.data.DeliveryPostcode,b.data.DeliveryState,b.data.DeliveryCountry),","));$("#customer_view_DeliveryAddress").parent().show()}else{CLMWVIEW.populateViewCell("customer_view_DeliveryAddress","","")}CLMWVIEW.populateViewCell("customer_view_DBalance",CLMWVIEW.formatCurrency(b.data.DBalance));CLMWVIEW.populateViewCell("customer_view_D30Plus",CLMWVIEW.formatCurrency(b.data.D30Plus));CLMWVIEW.populateViewCell("customer_view_D60Plus",CLMWVIEW.formatCurrency(b.data.D60Plus));CLMWVIEW.populateViewCell("customer_view_D90Plus",CLMWVIEW.formatCurrency(b.data.D90Plus));CLMWVIEW.populateViewCell("customer_view_ProductPricing",b.data.ProductPricing);CLMWVIEW.populateViewCell("customer_view_Salesperson",b.data.Salesperson);$("#customer_view_transactions").attr("rel",b.data.Code);$("#customer_view_jobs").attr("rel",b.data.Code);$("#customer_view_addso").attr("rel",b.data.Code);$("#customer_view_edit").attr("rel",b.data.Code);if(b.data.CustomerType>0){$("#customer_view_addso").show()}else{$("#customer_view_addso").hide()}$("#customer_form_Code").attr("readOnly",true);CLMWVIEW.sectionDisplaySet($("#customer_view"))})}function loadProduct(a){CLMWCONNECTOR.loadRecord("Product","Code",a,function(b){CLMWVIEW.populateFieldValues("product_form",(b));CLMWVIEW.populateFieldValues("product_view",(b));$("#product_view_Code").text(b.data.Code);$("#product_view_Description").text(b.data.Description);$("#product_view .currency").each(function(){$this=$(this);$this.text(CLMWVIEW.formatCurrency($this.text()))});$("#product_view .number").each(function(){$this=$(this);$this.text(CLMWVIEW.formatNumber($this.text()))});var c=parseInt(b.data.Colour);if(c>0){$("#product_view_Description").css("color",CLMWVIEW.colours[c])}else{$("#product_view_Description").css("color","")}$("#product_view_edit").attr("rel",b.data.Code);$("#product_form_Code").attr("readOnly",true);CLMWVIEW.sectionDisplaySet($("#product_view"))})}var graphOrientationChange=function(){$("#account_view :radio").filter(":checked").trigger("click")};function loadAccount(a){CLMWCONNECTOR.loadRecord("Account","Code",a,function(b){$("#account_view_Code").val(b.data.Code);$("#account_view_Description").text(b.data.Description+" ("+b.data.Code+")");var c=parseInt(b.data.Colour);if(c>0){$("#account_view_Description").css("color",CLMWVIEW.colours[c])}else{$("#account_view_Description").css("color","")}if($("#account_view :radio").filter(":checked").length==0){$("#account_view_balance").attr("checked",true).trigger("click")}else{$("#account_view :radio").filter(":checked").trigger("click")}})}function loadTransaction(a){CLMWCONNECTOR.loadTran(a,function(b){CLMWVIEW.populateFieldValues("trans_view",(b));var e=(b.data.Type=="SOI")?true:false;var d=0;$("#trans_view_OurRef").text(b.data.OurRef+" ("+CLMWVIEW.transTypeDesc(b.data.Type)+")");$("#trans_view_Detail").find(":visible").remove();if($.isArray(b.detail)){$.each(b.detail,function(){line=this;if(parseInt(line.Detail_Flags)<0){return}var f=$("#trans_view_Detail_Template").clone();if(line.Detail_StockCode){f.find(".trans-view-Product").text(line.Detail_StockCode).addClass("JumpProduct");f.find(".trans-view-Qty").text(CLMWVIEW.formatNumber(line.Detail_StockQty>0?line.Detail_StockQty:line.Detail_OrderQty))}else{if(line.Detail_Account){f.find(".trans-view-Product").text(line.Detail_Account).addClass("JumpAccount")}}if(e){tot=line.Detail_UnitPrice*line.Detail_OrderQty;f.find(".trans-view-Amount").text(CLMWVIEW.formatCurrency(tot));d+=tot}else{f.find(".trans-view-Amount").text(CLMWVIEW.formatCurrency(line.Detail_Gross-line.Detail_Tax))}f.find(".trans-view-Description").text(this.Detail_Description);$("#trans_view_Detail").append(f);f.show()})}CLMWVIEW.sectionDisplaySet($("#trans_view"));$(".JumpAccount").click(function(){loadAccount($(this).text());$(window).unbind("orientationchange",graphOrientationChange);$(window).bind("orientationchange",graphOrientationChange)});$(".JumpProduct").click(function(){loadProduct($(this).text())});if(e){dummy=("Incomplete sales order found!");$("#trans_view_SubTotal").text(CLMWVIEW.formatCurrency(d));$("#trans_view_Gross").text(CLMWVIEW.formatCurrency(d+parseFloat(b.data.FreightAmount)))}else{$("#trans_view_SubTotal").text(b.data.Gross-b.data.TaxAmount-b.data.FreightAmount)}$("#trans_view .currency").each(function(){$this=$(this);$this.text(CLMWVIEW.formatCurrency($this.text()))});$("#trans_view .number").each(function(){$this=$(this);$this.text(CLMWVIEW.formatNumber($this.text()))});var c=parseInt(b.data.Colour);if(c>0){$("#trans_view_Description").css("color",CLMWVIEW.colours[c])}else{$("#trans_view_Description").css("color","")}})}function trans_form_calculate(){var d=$("#trans_form_NameCode").data("PriceClass");var a=0;var b=0,c=0;$("#trans_view_Details li").each(function(){var f=$(this);if(f.children(".trans-form-product").length==0){return}var e=f.children(".trans-form-product").val();for(i=0;i<CLMWCONNECTOR.arrSOProducts.length;i++){if(CLMWCONNECTOR.arrSOProducts[i].id==e){if(d=="B"){a=CLMWCONNECTOR.arrSOProducts[i].SellPriceB}else{if(d=="C"){a=CLMWCONNECTOR.arrSOProducts[i].SellPriceC}else{if(d=="D"){a=CLMWCONNECTOR.arrSOProducts[i].SellPriceD}else{if(d=="E"){a=CLMWCONNECTOR.arrSOProducts[i].SellPriceE}else{if(d=="F"){a=CLMWCONNECTOR.arrSOProducts[i].SellPriceF}else{a=CLMWCONNECTOR.arrSOProducts[i].SellPrice}}}}}f.children(".trans-form-product").data("uprice",a);c=(a)*parseFloat(f.children(".trans-form-qty").val());f.children(".trans-form-total").text(CLMWVIEW.formatCurrency(c));b+=c;return}}});$("#trans_form_SubTotal").text(CLMWVIEW.formatCurrency(b))}function loadJob(b,a){if(a){CLMWCONNECTOR.blnFlagBundyStop=true}CLMWCONNECTOR.loadJob(b,function(c){CLMWVIEW.populateFieldValues("job_form",(c));CLMWVIEW.populateFieldValues("job_view",(c));$("#job_view_Code").text(c.data.Code);$("#job_view_Description").text(c.data.Description);$("#job_view .currency").each(function(){$this=$(this);$this.text(CLMWVIEW.formatCurrency($this.text()))});$("#job_view .number").each(function(){$this=$(this);$this.text(CLMWVIEW.formatNumber($this.text()))});var d=parseInt(c.data.Colour);if(d>0){$("#job_view_Description").css("color",CLMWVIEW.colours[d])}else{$("#job_view_Description").css("color","")}CLMWVIEW.populateViewCell("job_view_Phone",c.data.Phone,"tel:");if(c.data.Status=="OP"){$("#job_view_Status").text("Active")}if(c.data.Status=="CO"){$("#job_view_Status").text("Completed")}else{$("#job_view_Status").text("Quoted")}$("#job_form_Client").data("selected",c.data.Client);$("#job_view_edit").attr("rel",c.data.Code);$("#job_view_recordtime").data("JobCode",c.data.Code);$("#job_form_Code").attr("readOnly",true);$("#job_view_Items").find(".jobs-view-ItemLine").remove();if($.isArray(c.detail)){$.each(c.detail,function(){var e=$("#job_view_Items_Template").clone();e.addClass("jobs-view-ItemLine");e.find(".job-view-Qty").text(CLMWVIEW.formatNumber(this.Qty));e.find(".job-view-Product").text(this.Resource);e.find(".job-view-Charge").text(CLMWVIEW.formatCurrency(this.SellPrice));e.find(".job-view-Memo").text(this.Date+": "+this.Memo);e.data("item",this);e.css("color",CLMWVIEW.colours[parseInt(this.Colour)]);$("#job_view_Items").append(e);e.show()})}CLMWVIEW.sectionDisplaySet($("#job_view"));if(CLMWCONNECTOR.blnFlagBundyStop){CLMWCONNECTOR.blnFlagBundyStop=false;$("#job_view_addnewitem").trigger("click");CLMWCONNECTOR.strJobRecording=null;CLMWCONNECTOR.intJobStartTime=null;localStorage.setItem("RecordTimeJOB","");localStorage.setItem("RecordTimeTS","")}})}$(document).ready(function(){if(RegExp(" Mobile/").test(navigator.userAgent)&&!navigator.standalone){}if(navigator.onLine){}$("#login_username").keyup(function(b){if(b.keyCode==13){$("#login_submit").trigger("click")}});$("#login_password").keyup(function(b){if(b.keyCode==13){$("#login_submit").trigger("click")}});$("#login_username").val(localStorage.getItem("login_username"));$("#login_password").val(localStorage.getItem("login_password"));$("#login_submit").click(function(){CLMWCONNECTOR.strUsername=$("#login_username").val();CLMWCONNECTOR.strPassword=$("#login_password").val();$(this).text("Please wait..");CLMWCONNECTOR.doLogin(function(b){if(!b||!b.data){alert("Invalid login");$("#login_submit").html("Login");return false}if(b.error){alert(b.error);return false}$("#main_menu_header").text(b.data);document.title=b.data;dummy=("Successful login!");CLMWCONNECTOR.blnConnected=true;jQT.goTo("#main_menu","dissolve",false);$("#login_submit").text("Login");if($("#login_rememberme").is(":checked")){localStorage.setItem("login_username",CLMWCONNECTOR.strUsername);localStorage.setItem("login_password",CLMWCONNECTOR.strPassword)}else{localStorage.removeItem("login_username");localStorage.removeItem("login_password")}if(navigator.onLine){CLMWCONNECTOR.syncLocalData()}return})});$("#back_to_menu").click(function(){});$(".cdatalist").delegate("li.detail","click",function(){dummy=(this);var b=$(this).attr("rel");CLMWVIEW.fnEditFunc(b);return true});$("#menu_view_customer").click(function(){var b="CustomerType>=0";if(CLMWCONNECTOR.intCurrCustomerListView==1){b="CustomerType>0"}else{if(CLMWCONNECTOR.intCurrCustomerListView==2){b="SupplierType>0"}}if($.trim($("#customer_list_search").val()).length>0){b="(name=`"+$("#customer_list_search").val()+"@` or code=`"+$("#customer_list_search").val()+"@`) and "+b}CLMWCONNECTOR.getTableData("Name",{id:"[Code]",Name:"[Name]",DCurrent:"[DCurrent]",Colour:"[Colour]"},b,"Name",function(c){if(c.toomany){alert("Too many results were found! Please be more specific in search");return}CLMWVIEW.populateTable("customer_list",c.data,function(f){var d=f.Name;if(jQuery.trim(d)==""){d=f.id}var e=parseFloat(f.DCurrent);if(e!=0){d+='<span class="dlist">'+CLMWVIEW.formatCurrency(e)+"</span>"}return d},"customer_view",function(d){$("#customer_form_header").text("Edit");loadCustomer(d)})})});$("#customer_list .list_type_holder_item").click(function(){$this=$(this);CLMWCONNECTOR.intCurrCustomerListView=$this.attr("rel");$("#menu_view_customer").trigger("click");$("#customer_list .list_selected").removeClass("list_selected");$this.addClass("list_selected")});$("#customer_list_search").blur(function(){$("#menu_view_customer").trigger("click")});$("#customer_list_search").bind("keypress",function(b){if(b.keyCode==13){$("#menu_view_customer").trigger("click");return false}});$("#customer_list_new").click(function(){CLMWVIEW.clearForm("customer_form",null);$("#customer_form_header").text("New Customer");$("#customer_form_Code").removeAttr("readOnly")});$("#customer_submit").click(function(){var b=new Array($("#customer_form_Code").val(),$("#customer_form_Name").val(),$("#customer_form_Phone").val(),$("#customer_form_Fax").val(),$("#customer_form_WebURL").val(),$("#customer_form_Contact").val(),$("#customer_form_eMail").val(),$("#customer_form_DDI").val(),$("#customer_form_Mobile").val(),$("#customer_form_AfterHours").val(),$("#customer_form_Address1").val(),$("#customer_form_Address2").val(),$("#customer_form_Address3").val(),$("#customer_form_Address4").val(),$("#customer_form_State").val(),$("#customer_form_PostCode").val(),$("#customer_form_AddressCountry").val(),$("#customer_form_Delivery1").val(),$("#customer_form_Delivery2").val(),$("#customer_form_Delivery3").val(),$("#customer_form_Delivery4").val(),$("#customer_form_DeliveryState").val(),$("#customer_form_DeliveryPostcode").val(),$("#customer_form_DeliveryCountry").val(),$("#customer_form_Contact2").val(),$("#customer_form_eMail2").val(),$("#customer_form_DDI2").val(),$("#customer_form_Mobile2").val(),$("#customer_form_AfterHours2").val(),$("#customer_form_Salesperson").val(),$("#customer_form_ProductPricing").val(),$("#customer_form_Colour").val());b=b.join("\t");if(CLMWCONNECTOR.blnAddNewCustFromNewSo){CLMWCONNECTOR.strAddNewCustCode=$("#customer_form_Code").val()}CLMWCONNECTOR.saveData(b,"web_customer_import.impo",function(c){if(!c.Ok){alert("Error in saving! Please complete all fields. If error presist, please contact your MoneyWorks Administrator");return}if(CLMWCONNECTOR.blnAddNewCustFromNewSo){setTimeout('$("#menu_new_salesorder").trigger("click"); CLMWVIEW.swapView("customer_view" , "trans_form" , false);',500)}else{loadCustomer($("#customer_form_Code").val());CLMWVIEW.swapView("customer_form","customer_view")}})});$("#customer_cancel").click(function(){});$("#customer_view_transactions").click(function(){var c=$(this);var b=c.attr("rel");CLMWCONNECTOR.strTransListCust=b;CLMWCONNECTOR.intCurrTransListView=0;$("#trans_list .list_selected").removeClass("list_selected");$("#trans_list").find("[rel=0]").addClass("list_selected");CLMWVIEW.swapView("customer_view","trans_list",true);$("#menu_view_transaction").trigger("click")});$("#customer_view_jobs").click(function(){var c=$(this);var b=c.attr("rel");$("#job_list_search").val(b);CLMWCONNECTOR.intCurrJobListView=0;$("#job_list .list_selected").removeClass("list_selected");$("#job_list").find("[rel=0]").addClass("list_selected");CLMWVIEW.swapView("customer_view","job_list",true);$("#menu_view_job").trigger("click")});$("#customer_view_addso").click(function(){var c=$(this);var b=c.attr("rel");CLMWCONNECTOR.strNewSalesOrderCustCode=b;CLMWVIEW.swapView("customer_view","trans_form",true);$("#menu_new_salesorder").trigger("click")});$("#customer_form_copy_mail").click(function(){$("#customer_form_Delivery1").val($("#customer_form_Address1").val());$("#customer_form_Delivery2").val($("#customer_form_Address2").val());$("#customer_form_Delivery3").val($("#customer_form_Address3").val());$("#customer_form_Delivery4").val($("#customer_form_Address4").val());$("#customer_form_DeliveryState").val($("#customer_form_State").val());$("#customer_form_DeliveryPostcode").val($("#customer_form_PostCode").val());$("#customer_form_DeliveryCountry").val($("#customer_form_AddressCountry").val())});$("#menu_view_product").click(function(){var b="Code=`@`";if(CLMWCONNECTOR.intCurrProductListView==1){b="Type=`P`"}else{if(CLMWCONNECTOR.intCurrProductListView==2){b="Type=`R`"}else{b="Type=`T` or Type=`S`"}}if($.trim($("#product_list_search").val()).length>0){b="(description=`"+$("#product_list_search").val()+"@` or code=`"+$("#product_list_search").val()+"@`) and "+b}CLMWCONNECTOR.getTableData("Product",{id:"[Code]",Description:"[Description]",SellPrice:"[SellPrice]",StockOnHand:"[StockOnHand]",Colour:"[Colour]"},b,"Description",function(c){if(c.toomany){alert("Too many results were found! Please be more specific in search");return}CLMWVIEW.populateTable("product_list",c.data,function(f){var d=f.Description;var e=parseFloat(f.SellPrice);var g=parseFloat(f.StockOnHand);d+='<span class="dlist">';if(e!=0){d+="P: "+CLMWVIEW.formatCurrency(e)+" "}if(g!=0){d+="[S: "+g+"]"}d+="</span>";return d},"product_view",function(d){dummy=("Loading product "+d);loadProduct(d)})})});$("#product_list .list_type_holder_item").click(function(){$this=$(this);CLMWCONNECTOR.intCurrProductListView=$this.attr("rel");$("#menu_view_product").trigger("click");$("#product_list .list_selected").removeClass("list_selected");$this.addClass("list_selected")});$("#product_list_search").blur(function(){$("#menu_view_product").trigger("click")});$("#product_list_search").bind("keypress",function(b){if(b.keyCode==13){$("#menu_view_product").trigger("click");return false}});$(".JumpToName").click(function(){loadCustomer($(this).text())});$(".JumpToJob").click(function(){loadJob($(this).text())});$("#product_submit").click(function(){var b=new Array($("#product_form_Code").val(),$("#product_form_Description").val(),$("#product_form_SellPrice").val(),$("#product_view_SellPriceB").val(),$("#product_view_SellPriceC").val(),$("#product_view_SellPriceD").val(),$("#product_view_SellPriceE").val(),$("#product_view_SellPriceF").val(),$("#product_form_SellWeight").val(),$("#product_form_BuyPrice").val(),$("#product_form_Supplier").val(),$("#product_form_SuppliersCode").val(),$("#product_form_LeadTimeDays").val(),$("#product_form_BuyWeight").val(),$("#product_form_Colour").val());b=b.join("\t");CLMWCONNECTOR.saveData(b,"web_product_import.impo",function(c){if(!c.Ok){alert("Error in saving! Please complete all fields. If error presist, please contact your MoneyWorks Administrator");return}loadProduct($("#product_form_Code").val());CLMWVIEW.swapView("product_form","product_view")})});$("#product_list_new").click(function(){CLMWVIEW.clearForm("product_form",null);$("#product_form_header").text("New Product");$("#product_form_Code").removeAttr("readOnly")});$("#product_cancel").click(function(){});$("#menu_view_account").click(function(){var b="@";if(CLMWCONNECTOR.intCurrAccountListView==1){b="IN` or Type=`SA";$("#account_list_header").text("Income")}else{if(CLMWCONNECTOR.intCurrAccountListView==2){b="EX";$("#account_list_header").text("Expenses")}else{if(CLMWCONNECTOR.intCurrAccountListView==3){b="CL";$("#account_list_header").text("Current Liability")}else{if(CLMWCONNECTOR.intCurrAccountListView==4){b="CA";$("#account_list_header").text("Current Assets")}else{b="@";$("#account_list_header").text("All Accounts")}}}}var c=0;CLMWCONNECTOR.listAccounts(b,function(d){CLMWVIEW.populateTable("account_list",d.data,function(g){var e=g.Description+" ("+g.id+")";var f=parseFloat(g.Balance);c+=f;e+='<span class="dlist">';if(f!=0){e+=CLMWVIEW.formatCurrency(f)+" "}e+="</span>";return e},"account_view",function(e){$(window).unbind("orientationchange",graphOrientationChange);$(window).bind("orientationchange",graphOrientationChange);loadAccount(e)});$("#account_list .total_row span").text(CLMWVIEW.formatCurrency(c))})});$("#account_list .list_type_holder_item").click(function(){$this=$(this);CLMWCONNECTOR.intCurrAccountListView=$this.attr("rel");$("#menu_view_account").trigger("click");$("#account_list .list_selected").removeClass("list_selected");$this.addClass("list_selected")});$("#account_cancel").click(function(){});$("#account_view_balance").click(function(){if($("#account_view_Code").val()==""){return}CLMWCONNECTOR.doAccountBalance($("#account_view_Code").val(),12,function(b){CLMWVIEW.plot_graph("account_graph",b)})});$("#account_view_movement").click(function(){CLMWCONNECTOR.doAccountMovement($("#account_view_Code").val(),12,function(b){CLMWVIEW.plot_bar("account_graph",b)})});$(".account_view_back").click(function(){$(window).unbind("orientationchange",graphOrientationChange);$("#graph_legend").text(" ")});$("#menu_view_report").click(function(){$("#data_list_header").text("Reports");$("#list_new").hide();CLMWCONNECTOR.doReportList(function(d){var b=new Array();for(var c=0;c<d.length;c++){b[b.length]={id:d[c],Colour:"black"}}CLMWVIEW.populateTable("data_list",b,function(f){var e=f.id;e=e.replace(".crep","");return e},"report_view",function(e){$("#report_view_display").html("");$("#report_view_name").text(e.replace(".crep",""));CLMWCONNECTOR.runReport(e,function(f){$("#report_view_display").html(f);$("#report_view_display").find("table").each(function(){$this=$(this);$this.css("width","100%")})})})})});$("#menu_view_transaction").click(function(){if($(".current").attr("id")=="main_menu"){CLMWCONNECTOR.strTransListCust=""}var d={id:"[SequenceNumber]",Name:"[Lookup(NameCode,`Name.Name`)]",TransDate:"[TransDate]",Gross:"[Gross]",Type:"[Type]",Description:"[Description]",Colour:"[Colour]"};var b="";if(CLMWCONNECTOR.intCurrTransListView==1){b=" (Type=`SO@` or Type=`PO@` or Type=`QU@`)";$("#trans_list_header").text("Orders/Payments/Quotes")}else{if(CLMWCONNECTOR.intCurrTransListView==2){b="(Type=`DI@` or Type=`CI@`)";$("#trans_list_header").text("Debtor/Creditor Invoices")}else{if(CLMWCONNECTOR.intCurrTransListView==3){b="(Type=`CP@` or Type=`CR@`)";$("#trans_list_header").text("Payments")}else{b="SequenceNumber>=0";$("#trans_list_header").text("All Transactions")}}}if(CLMWCONNECTOR.strTransListCust!=""){b+=" and (NameCode=`"+CLMWCONNECTOR.strTransListCust+"`)"}else{b+="/"}var c=0;CLMWCONNECTOR.loadTrans(d,b,function(e){CLMWVIEW.populateTable("trans_list",e.data,function(h){var f="";if(jQuery.trim(h.Name)!=""){f+=h.Name}else{f+=h.Description}var g=parseFloat(h.Gross);CLMWCONNECTOR.intTransCurrTotal+=g;f+='<span class="dlist">';if(g!=0){f+=CLMWVIEW.formatCurrency(g)+" "}f+="</span>";f+='<span class="list_subtext">('+CLMWVIEW.transTypeDesc(h.Type)+" - "+h.TransDate+")</span>";CLMWCONNECTOR.intTransCurrStartSeq=h.id;return f},"trans_view",function(f){loadTransaction(f)});$("#trans_list .total_row span").text(CLMWVIEW.formatCurrency(CLMWCONNECTOR.intTransCurrTotal));if(e.found&&e.found>=20){$("#trans_more").show()}else{$("#trans_more").hide()}})});$("#trans_list .list_type_holder_item").click(function(){$this=$(this);CLMWCONNECTOR.intTransCurrStartSeq=Math.pow(2,31);CLMWCONNECTOR.intTransCurrTotal=0;CLMWCONNECTOR.intCurrTransListView=$this.attr("rel");$("#menu_view_transaction").trigger("click");$("#trans_list .list_selected").removeClass("list_selected");$this.addClass("list_selected")});$("#trans_more").click(function(){CLMWVIEW.blnAppendTable=true;$("#menu_view_transaction").trigger("click")});$("#menu_new_salesorder").click(function(){CLMWCONNECTOR.getSOData(function(e){var b=CLMWCONNECTOR.arrSOCustomers=(e.data.customers);var c;$("#trans_form_NameCode").empty();$("#trans_form_NameCode").append('<option value="0">Please Select...</option>');for(c=0;c<CLMWCONNECTOR.arrSOCustomers.length;c++){$("#trans_form_NameCode").append('<option value="'+b[c].id+'">'+b[c].Name+"</option>")}$("#trans_form_NameCode").append('<option value="-1">Add New....</option>');if(CLMWCONNECTOR.strNewSalesOrderCustCode!=""){$("#trans_form_NameCode").val(CLMWCONNECTOR.strNewSalesOrderCustCode);CLMWCONNECTOR.strNewSalesOrderCustCode=""}if(CLMWCONNECTOR.blnAddNewCustFromNewSo){$("#trans_form_NameCode").val(CLMWCONNECTOR.strAddNewCustCode);CLMWCONNECTOR.blnAddNewCustFromNewSo=false;CLMWCONNECTOR.strAddNewCustCode=""}var b=CLMWCONNECTOR.arrSOProducts=(e.data.products);var c;var d=$("#trans_view_Details li").eq(0).find("select");d.empty();d.append('<option value="">Select...</option>');for(c=0;c<CLMWCONNECTOR.arrSOProducts.length;c++){d.append('<option value="'+b[c].id+'">'+b[c].id+"</option>")}})});$("#trans_form_cancel").click(function(){CLMWVIEW.swapView("trans_form",CLMWVIEW.strLastViewedDiv,false)});$("#trans_form_NameCode").change(function(){var c;var b=$(this).val();var d="A";if(b=="-1"){CLMWCONNECTOR.blnAddNewCustFromNewSo=true;$("#customer_list_new").trigger("click");return}for(c=0;c<CLMWCONNECTOR.arrSOCustomers.length;c++){if(CLMWCONNECTOR.arrSOCustomers[c].id==b){d=CLMWCONNECTOR.arrSOCustomers[c].ProductPricing;break}}$(this).data("PriceClass",d);trans_form_calculate();return true});$(".trans-form-product").change(function(){var c=$(this);var b=c.val();if(b==""){return}var d=$("#trans_form_NameCode").data("PriceClass");c.next().val("1");for(i=0;i<CLMWCONNECTOR.arrSOProducts.length;i++){if(CLMWCONNECTOR.arrSOProducts[i].id==b){c.siblings(".trans-form-desc").val(CLMWCONNECTOR.arrSOProducts[i].Description);c.siblings(".trans-form-stock").text("Stock:"+CLMWCONNECTOR.arrSOProducts[i].StockOnHand);break}}trans_form_calculate();return true});$(".trans-form-qty").blur(function(){var b=$(this);var c=parseFloat(b.val());if(isNaN(c)){b.val(1)}trans_form_calculate();return true});$("#trans_form_addnew").click(function(){var b=$("#trans_view_Details li").eq(0);var d=b.clone(true);d.find(".trans-form-desc").val("");d.find(".trans-form-product").val("0");d.find(".trans-form-qty").val("");d.insertAfter($("#trans_view_Details li").last());d.find(".trans-form-remove").removeClass("invisible");d.find(".trans-form-product").focus()});$(".trans-form-remove").click(function(){var b=$(this).parent();b.remove();trans_form_calculate()});$("#trans_form_submit").click(function(){trans_form_calculate();var d=new Date();d=d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear();var f=$("#trans_form_NameCode").val();if((f==0)||(f==-1)||($("#trans_form_NameCode").attr("selectedIndex")==0)){alert("Please select a customer!");document.getElementById("trans_form_NameCode").focus();return}var b=new Array(f,$("#trans_form_TheirRef").val(),$("#trans_form_Description").val());var e=new Array();var c=false;$("#trans_view_Details li").each(function(){var l=$(this);if(l.hasClass("trans_form_addnew_holder")){return}var k=l.children(".trans-form-product").val();var m=l.children(".trans-form-qty").val();var g=l.children(".trans-form-product").data("uprice");var h=l.children(".trans-form-desc").val();if(k==""||k==null){c=true;alert("Please enter a product code");l.children(".trans-form-product").focus();return}b[3]=m;b[4]=k;b[5]=g;b[6]=h;b[7]=d;e[e.length]=b.join("\t");return});if(c){return}e=e.join("\n");CLMWCONNECTOR.saveData(e,"web_salesorder_import.impo",function(k){if(k.Ok){alert("Sales Order Saved");CLMWVIEW.swapView("trans_form","main_menu");$("#trans_form").find("input").each(function(){$(this).val("")});$("#trans_form").find(".trans-form-qty").val("");$(".trans-form-stock").text("");$(".trans-form-total").text("$0.00");$("#trans_form_SubTotal").text("");var h=$("#trans_view_Details").find("li").length;var g=0;$("#trans_view_Details").find("li").each(function(){if(g==0){g++;return}$(this).remove();g++})}else{alert("Error in saving! Please complete all fields. If error presist, please contact your MoneyWorks Administrator");return}})});$("#menu_do_wipe").click(function(){if(confirm("Are you sure you want to wipe all local data and logout? This action will remove all saved data in your device.")){localStorage.clear();location.reload()}});$("#menu_view_sendsaved").click(function(){if(!navigator.onLine){alert("Cannot send data as we are not online right now. Please go online before trying again.");return}CLMWCONNECTOR.syncLocalData()});$("#menu_view_syncdata").click(function(){$("#menu_new_salesorder").trigger("click");$(".list_type_holder").find("a").each(function(){$(this).trigger("click")})});$("#list_new").click(function(){var b=$(this);var c=b.attr("href").replace("#","");CLMWVIEW.clearForm(c,null)});$("#menu_view_job").click(function(){var b="Status>`A`";if(CLMWCONNECTOR.intCurrJobListView==1){b="Status=`QU`"}else{if(CLMWCONNECTOR.intCurrJobListView==2){b="Status=`OP`"}else{if(CLMWCONNECTOR.intCurrJobListView==3){b="Status=`CO`"}}}if($.trim($("#job_list_search").val()).length>0){b="(client=`"+$("#job_list_search").val()+"@` or code=`"+$("#job_list_search").val()+"@`) and "+b}CLMWCONNECTOR.getTableData("Job",{id:"[Code]",Client:"[Lookup(Client,`Name.Name`)]",PercentComplete:"[PercentComplete]",Comment:"[Comment]",Colour:"[Colour]"},b,"Code",function(c){if(c.toomany){alert("Too many results were found! Please be more specific in search");return}CLMWVIEW.populateTable("job_list",c.data,function(f){var d=f.Client;if(jQuery.trim(d)==""){d=f.id}d+=" - "+f.Comment;var e=parseFloat(f.PercentComplete);if(e!=0){d+='<span class="dlist">'+CLMWVIEW.formatNumber(e)+"%</span>"}return d},"job_view",function(d){$("#job_form_header").text("Edit");loadJob(d)})})});$("#job_list .list_type_holder_item").click(function(){$this=$(this);CLMWCONNECTOR.intCurrJobListView=$this.attr("rel");$("#menu_view_job").trigger("click");$("#job_list .list_selected").removeClass("list_selected");$this.addClass("list_selected")});$("#job_list_search").blur(function(){$("#menu_view_job").trigger("click")});$("#job_list_search").bind("keypress",function(b){if(b.keyCode==13){$("#menu_view_job").trigger("click");return false}});$("#job_list_new").click(function(){CLMWVIEW.clearForm("job_form",null);$("#job_form_header").text("New Job");$("#job_form_Code").removeAttr("readOnly")});$("#job_submit").click(function(){var b=new Array($("#job_form_Code").val(),$("#job_form_Description").val(),$("#job_form_Category1").val(),$("#job_form_Category2").val(),$("#job_form_Category3").val(),$("#job_form_Category4").val(),$("#job_form_OrderNum").val(),$("#job_form_Contact").val(),$("#job_form_Phone").val(),$("#job_form_Markup").val(),$("#job_form_Quote").val(),$("#job_form_PercentComplete").val(),$("#job_form_Comment").val(),$("#job_form_Custom1").val(),$("#job_form_Custom2").val(),$("#job_form_Custom3").val(),$("#job_form_Custom4").val(),$("#job_form_Colour").val(),$("#job_form_Client").val());b=b.join("\t");CLMWCONNECTOR.saveData(b,"web_job_import.impo",function(c){if(!c.Ok){alert("Error in saving! Please complete all fields. If error presist, please contact your MoneyWorks Administrator");return}loadJob($("#job_form_Code").val());CLMWVIEW.swapView("job_form","job_view",false)})});$("#job_view_edit, #job_list_new").click(function(){CLMWCONNECTOR.getCustomers(function(d){CLMWCONNECTOR.arrSOCustomers=d.data;$("#job_form_Client").empty();$("#job_form_Client").append('<option value="0">Please Select...</option>');dummy=(d);d=d.data;for(var b=0;b<d.length;b++){$("#job_form_Client").append('<option value="'+d[b].id+'">'+d[b].Name+"</option>")}var c=$("#job_form_Client").data("selected");if(c){$("#job_form_Client").val(c);$("#job_form_Client").data("selected",false)}})});$("#job_view_addnewitem").click(function(){CLMWVIEW.clearForm("jobitem_form",null);$("#jobitem_form_header").text("New Job Item");CLMWVIEW.swapView("job_view","jobitem_form",false);var c=$("#job_view_edit").attr("rel");$("#jobitem_form").data("Code",c);if(c==CLMWCONNECTOR.strJobRecording){var e=new Date();e=e.getTime();var f=e-CLMWCONNECTOR.intJobStartTime;f=Math.round(f/1000);var b=Math.round((f/3600)*100)/100;$("#jobitem_form_Qty").val(b)}else{$("#jobitem_form_Qty").val(1)}var g=new Date();$("#jobitem_form_Date").val(g.format("d/m/y"));CLMWCONNECTOR.getProducts(function(k){CLMWCONNECTOR.arrSOProducts=k.data;$("#jobitem_form_Resource").empty();$("#jobitem_form_Resource").append('<option value="0">Please Select...</option>');dummy=(k);k=k.data;for(var d=0;d<k.length;d++){$("#jobitem_form_Resource").append('<option value="'+k[d].id+'">'+k[d].Description+"</option>")}var h=$("#jobitem_form_Resource").data("selected");if(h){$("#jobitem_form_Resource").val(h);$("#jobitem_form_Resource").data("selected",false)}})});$("#job_view_Items").delegate("li","click",function(){CLMWVIEW.clearForm("jobitem_form",null);$("#jobitem_form_header").text("Edit Job shet");CLMWVIEW.swapView("job_view","jobitem_form",false);$("#jobitem_form_Qty").val(1);var b=$(this).data("item");$("#jobitem_form").data("Code",b.Job);CLMWVIEW.populateFieldValues("jobitem_form",{data:b});$("#jobitem_form_Resource").data("selected",b.Resource);CLMWCONNECTOR.getProducts(function(e){$("#jobitem_form_Resource").empty();$("#jobitem_form_Resource").append('<option value="0">Please Select...</option>');dummy=(e);e=e.data;for(var c=0;c<e.length;c++){$("#jobitem_form_Resource").append('<option value="'+e[c].id+'">'+e[c].Description+"</option>")}var d=$("#jobitem_form_Resource").data("selected");if(d){$("#jobitem_form_Resource").val(d);$("#jobitem_form_Resource").data("selected",false)}})});$("#jobitem_form_Resource").bind("change",function(){var c=$(this);var b=c.val();if(b==""){return}if($("#jobitem_form_Memo").val()==""){for(i=0;i<CLMWCONNECTOR.arrSOProducts.length;i++){if(CLMWCONNECTOR.arrSOProducts[i].id==b){$("#jobitem_form_Memo").val(CLMWCONNECTOR.arrSOProducts[i].Description);$("#jobitem_form_CostPrice").val(CLMWVIEW.formatNumber(CLMWCONNECTOR.arrSOProducts[i].CostPrice*$("#jobitem_form_Qty").val()));$("#jobitem_form_SellPrice").val(CLMWVIEW.formatNumber(CLMWCONNECTOR.arrSOProducts[i].SellPrice*$("#jobitem_form_Qty").val()));return true}}}return true});$("#jobitem_submit").click(function(){var b=new Array($("#jobitem_form").data("Code"),$("#jobitem_form_Qty").val(),$("#jobitem_form_Resource").val(),$("#jobitem_form_Date").val(),$("#jobitem_form_Analysis").val(),$("#jobitem_form_Activity").val(),$("#jobitem_form_CostPrice").val(),$("#jobitem_form_SellPrice").val(),$("#jobitem_form_Memo").val(),$("#jobitem_form_Colour").val());b=b.join("\t");CLMWCONNECTOR.saveData(b,"web_jobsheet_import.impo",function(c){if(!c.Ok){alert("Error in saving! Please complete all fields. If error presist, please contact your MoneyWorks Administrator");return}loadJob($("#jobitem_form").data("Code"));CLMWVIEW.swapView("jobitem_form","job_view",false)})});$("#job_view_recordtime").click(function(){if(!confirm("Start recording time?")){return}if((localStorage.getItem("RecordTimeJOB")!="")&&(localStorage.getItem("RecordTimeJOB")!=null)){if(!confirm("You are already running job "+localStorage.getItem("RecordTimeJOB")+". Do you want to cancel it?")){return}}var b=new Date();CLMWCONNECTOR.strJobRecording=$(this).data("JobCode");CLMWCONNECTOR.intJobStartTime=b.getTime();localStorage.setItem("RecordTimeJOB",CLMWCONNECTOR.strJobRecording);localStorage.setItem("RecordTimeTS",CLMWCONNECTOR.intJobStartTime);$("#menu_stop_clock").removeClass("hidden").show();CLMWVIEW.swapView("job_view","main_menu",false)});setInterval(function(){CLMWCONNECTOR.showJobElapsed()},2000);$("#menu_stop_clock").click(function(){if(!confirm("Are you sure you want finish job "+CLMWCONNECTOR.strJobRecording+"?")){return}loadJob(CLMWCONNECTOR.strJobRecording,true);CLMWVIEW.swapView("main_menu","job_view",false);$("#menu_stop_clock").addClass("hidden").hide()});if((localStorage.getItem("RecordTimeJOB")!=null)&&(localStorage.getItem("RecordTimeJOB")!="")){$("#menu_stop_clock").removeClass("hidden").show();CLMWCONNECTOR.strJobRecording=localStorage.getItem("RecordTimeJOB");CLMWCONNECTOR.intJobStartTime=localStorage.getItem("RecordTimeTS")}var a="";$.each(CLMWVIEW.colours,function(c,b){a+='<option value="'+c+'">'+b+"</option>"});$("#customer_form_Colour").html(a);$("#product_form_Colour").html(a);$("#job_form_Colour").html(a);$("#jobitem_form_Colour").html(a);if($("#login_username").val()!=""){document.getElementById("login_rememberme").checked=true}});
