/*
 Ext.ux.grid.RowActions is licensed under the terms of
 the Open Source LGPL 3.0 license.  Commercial use is permitted to the extent
 that the code/component(s) do NOT become part of another Open Source or Commercially
 licensed development library or toolkit without explicit permission.

 <p>License details: <a href="http://www.gnu.org/licenses/lgpl.html"
 target="_blank">http://www.gnu.org/licenses/lgpl.html</a></p>

*/
Ext.namespace("NECS.application");Ext.namespace("NECS.data");Ext.namespace("NECS.form");Ext.namespace("NECS.form.Action");Ext.namespace("NECS.grid");Ext.namespace("NECS.grid.columns");Ext.namespace("NECS.rpc");Ext.namespace("NECS.rpc.JSON");Ext.namespace("NECS.util");Ext.namespace("NECS.page.customer.guide");Ext.namespace("NECS.page.customer.order");Ext.namespace("NECS.page.customer.search");Ext.namespace("NECS.page.customer.catalog");Ext.namespace("NECS.page.customer.account");Ext.namespace("NECS.page.customer.specials");
Ext.namespace("NECS.page.customer.index");Ext.namespace("NECS.page.customer.report");Ext.namespace("NECS.page.customer.help");Ext.namespace("NECS.page.distributor");Ext.namespace("NECS.page.distributor.settings");Ext.namespace("NECS.page.distributor.customer");Ext.namespace("NECS.page.distributor.salesperson");Ext.namespace("NECS.page.distributor.configure");Ext.namespace("NECS.page.salesperson.index");Ext.namespace("NECS.page.common");Ext.namespace("NECS.page.layout");Ext.namespace("NECS.panel");
Ext.namespace("NECS.pref");Ext.namespace("NECS.report");Ext.namespace("NECS.window");Ext.namespace("NECS.prospect");var gIgnoreRpcErrors=false;NECS.PT_UNKNOWN=0;NECS.PT_USER=1;NECS.PT_LEVEL=2;NECS.PT_FUT_LEVEL=3;NECS.PT_GROUP_CODE=4;NECS.PT_SPECIAL=5;NECS.PT_BID1=6;NECS.PT_BID2=7;NECS.PT_SALE=8;NECS.PT_BREAK=9;NECS.PT_CUST_BREAK=10;NECS.SM_EXACT=0;NECS.SM_MATCH=1;NECS.SM_CONTAINS=2;NECS.SM_FULLTEXT=3;NECS.IS_WARNMINMAX=1;NECS.prospect.ST_NEW=0;NECS.prospect.ST_CONVERT=1;NECS.prospect.ST_PENDING=2;
NECS.prospect.ST_CUSTOMER=3;NECS.pref.COLS_STANDARD=1E3;NECS.pref.COLS_SEARCH=1001;NECS.pref.COLS_QUICK=1002;NECS.pref.COLS_AR_HISTORY=1003;NECS.pref.COLS_DIST_SEARCH=1004;NECS.pref.COLS_ORD_VIEW=1005;NECS.pref.COLS_ORD_MISSING=1006;NECS.Themes=[["aqua","Aqua"],["blue","Blue"],["cream","Cream"],["gray","Gray"],["lavender","Lavender"],["lime","Lime"],["mint","Mint"],["peach","Peach"],["pink","Pink"],["purple","Purple"],["red","Red"]];
NECS.TimezoneData=["Canada/Newfoundland","Canada/Atlantic","Canada/Central","Canada/East-Saskatchewan","Canada/Saskatchewan","Canada/Eastern","Canada/Mountain","Canada/Pacific","US/Eastern","US/Central","US/Mountain","US/Arizona","US/Pacific","US/Alaska","US/Hawaii"];NECS.initializeApplication=function(){Ext.BLANK_IMAGE_URL="/include/extjs/images/default/s.gif";Ext.QuickTips.init();Ext.EventManager.on(window,"beforeunload",function(){gIgnoreRpcErrors=true})};var itemInfoWin;
function displayItemInfo(a){itemInfoWin||(itemInfoWin=new NECS.window.ItemInfoWindow);itemInfoWin.showForItem(a)}
function inputGridMovement(a,b,c,d){switch(b){case 9:case 13:case 38:case 40:if(a.shiftKey||b==38){if(typeof window.gcb_RewindEditor=="function")if(!gcb_RewindEditor.call(this,NECS.util.getEventTarget(a).id))return false}else if(typeof window.gcb_AdvanceEditor=="function")if(!gcb_AdvanceEditor.call(this,NECS.util.getEventTarget(a).id))return false;if(c&&c.getSelectionModel){sm=c.getSelectionModel();if(a.shiftKey||b==38){if(sm.hasPrevious())sm.selectRow(sm.last-1,false);else{NECS.util.getEventTarget(a).blur();
sm.selectFirstRow()}typeof window.gcb_GridSelectionChange=="function"&&gcb_GridSelectionChange.call(this,sm.getSelected(),false)}else{sm.hasNext()?sm.selectRow(sm.last+1,false):NECS.util.getEventTarget(a).blur();typeof window.gcb_GridSelectionChange=="function"&&gcb_GridSelectionChange.call(this,sm.getSelected(),true)}return false}break}return true}
function inputItemNoFilter(a,b,c){var d;d=window.event?a.keyCode:a.which;switch(d){case 8:case 37:case 39:case 46:return true}if(!inputGridMovement(a,d,b,c))return false;if(NECS.util.getEventTarget(a).value.length>=8)return false;return true}function calcExtAmount(a,b,c,d,e){return e=="LB."?b*a:d?b*c*a:b*a}function inputTextFilter(a,b){if(b&&b.disabled)return false;return inputGridMovement(a,window.event?a.keyCode:a.which,b)}
function inputQtyFilter(a,b,c){if(b&&b.disabled)return false;var d;d=window.event?a.keyCode:a.which;if(!inputGridMovement(a,d,b))return false;switch(d){case 190:case 110:if(!c)return false;case 8:case 37:case 39:case 46:return true}if(d>=48&&d<=59||d>=96&&d<=105)return true;return false}
function urlencode(a){a=escape(a);a=a.replace(/\+/g,"%2B");a=a.replace(/\%20/g,"+");a=a.replace(/\*/g,"%2A");a=a.replace(/\//g,"%2F");a=a.replace(/\\/g,"%5C");a=a.replace(/@/g,"%40");return a=a.replace(/#/g,"%23")}
NECS.util={trim:function(a){return a.replace(/^\s+|\s+$/g,"")},getEventTarget:function(a){return Ext.isIE?a.srcElement:a.target},enforceCreditHold:function(){var a=NECS.application.Customer.CreditHold&&NECS.application.Options.EnforceCrHold;if(a&&NECS.application.Salesperson)NECS.application.Options.SpEnforceCrHold||(a=false);return a},showCreditHoldMsg:function(){Ext.state.Manager.setProvider(new Ext.state.CookieProvider);Ext.state.Manager.get("HideCrHoldMsg")||(NECS.application.Salesperson&&!NECS.application.Options.SpEnforceCrHold?
Ext.Msg.show({title:"Account On Credit Hold",msg:"This customers account is currently on credit hold.",minWidth:200,modal:true,icon:Ext.Msg.WARNING,buttons:Ext.Msg.OK}):Ext.Msg.show({title:"Account On Credit Hold",msg:NECS.application.Salesperson?"New orders cannot be created since this customer account has been placed on credit hold.":"New orders cannot be created since your account has been placed on credit hold.",minWidth:200,modal:true,icon:Ext.Msg.WARNING,buttons:Ext.Msg.OK}));Ext.state.Manager.set("HideCrHoldMsg",
true)},ClearCrHoldMsgState:function(){Ext.state.Manager.setProvider(new Ext.state.CookieProvider);Ext.state.Manager.set("HideCrHoldMsg",false)},DisplayError:function(a,b,c,d,e){if(!gIgnoreRpcErrors){b=b?b:"Error";Ext.Msg.show({title:b,msg:a,minWidth:200,modal:true,icon:Ext.Msg.INFO,buttons:Ext.Msg.OK,fn:function(){if(c)window.location=c;d&&d.call(e)}})}},DisplayInfo:function(a,b,c,d,e){Ext.Msg.show({title:b,msg:a,minWidth:200,modal:true,icon:Ext.Msg.INFO,buttons:Ext.Msg.OK,fn:function(){if(c)window.location=
c;d&&d.call(e)}})},DisplayWarning:function(a,b,c,d,e){Ext.Msg.show({title:b,msg:a,minWidth:200,modal:true,icon:Ext.Msg.WARNING,buttons:Ext.Msg.OK,fn:function(){if(c)window.location=c;d&&d.call(e)}})},IsCatchweight:function(a){if(a){var b=a.calc_weight;return b=(b=(b=b&&a.unit.trim()!="LB.")&&a.avg_weight!=0)&&a.cnst_weight==0}else return false},clone:function(a){if(!a||"object"!==typeof a)return a;var b="[object Array]"===Object.prototype.toString.call(a)?[]:{},c,d;for(c in a)if(a.hasOwnProperty(c)){d=
a[c];b[c]=d&&"object"===typeof d?NECS.util.clone(d):d}return b},calculatePageTop:function(){var a;if(a=Ext.get("menu"))return a.getBorderWidth("tb")+a.getTop()+a.getHeight();return 0},nl2br:function(a){a=escape(a);var b;if(a.indexOf("%0D%0A")>-1)b=/%0D%0A/g;else if(a.indexOf("%0A")>-1)b=/%0A/g;else if(a.indexOf("%0D")>-1)b=/%0D/g;return b?unescape(a.replace(b,"<br />")):unescape(a)},checkMinMaxQty:function(a,b){if(NECS.application.Options&&NECS.application.Options.ShowMinMaxWarn){checkQty=parseFloat(a);
if(a==0)return false;checkMin=parseFloat(b.data.warn_min_qty);checkMax=parseFloat(b.data.warn_max_qty);var c;if(checkMin!=0)c="Minimum Qty: "+checkMin;if(checkMax!=0){if(checkMin!=0)c+=" / ";c+="Maximum Qty: "+checkMax}if(checkMin!=0&&checkQty<checkMin){a=checkQty+" is below the minimum recommended quantity for this item.<br  />"+c;b.data.status|=NECS.IS_WARNMINMAX;return a}else if(checkMax!=0&&checkQty>checkMax){a=checkQty+" is above the maximum recommended quantity for this item.<br  />"+c;b.data.status|=
NECS.IS_WARNMINMAX;return a}}b.data.status&=~NECS.IS_WARNMINMAX;return false},ShowImage:function(a){a&&a.trim()!=""&&(new NECS.window.ImageWindow).showForImage(a)},parseFloat:function(a,b){if(typeof a==="string"&&a.trim()==="")return b===undefined?0:b;if(typeof a==="string")a-=0;if(isNaN(a))return b===undefined?0:b;return a},translatePrice:function(a){if(a.data){manualPrice=a.data.manual_price;price=a.data.price;promoAmount=a.data.promo_amount||0}else{manualPrice=a.manual_price;price=a.price;promoAmount=
a.promo_amount||0}price=manualPrice||price;price-=promoAmount;return price}};Date.prototype.setISO8601=function(a){a=a.match(/([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})([+-])([0-9]{2}):([0-9]{2})/);var b=0,c=new Date(a[1],0,1);a[2]&&c.setMonth(a[2]-1);a[3]&&c.setDate(a[3]);a[4]&&c.setHours(a[4]);a[5]&&c.setMinutes(a[5]);a[6]&&c.setSeconds(a[6]);if(a[7]){b=Number(a[8])*60+Number(a[9]);b*=a[7]=="-"?1:-1}b-=c.getTimezoneOffset();time=Number(c)+b*60*1E3;this.setTime(Number(time))};
NECS.grid.columns.dummy={Blank:{id:"blank",header:"Dummy Field",fixed:true,width:50}};NECS.grid.columns.guide={Default:{id:"is_default",dataIndex:"is_default",header:"Default",fixed:true,width:50,menuDisabled:true,sortable:false,align:"center",renderer:function(a){return a?"Yes":"No"}},Name:{id:"name",dataIndex:"name",header:"Name",fixed:false,width:250,menuDisabled:true,sortable:true},TotalItems:{id:"total-items",dataIndex:"total_items",header:"Items",fixed:false,width:30,menuDisabled:true,sortable:false}};
NECS.grid.columns.classes={Menu:{id:"menu",dataIndex:"none",header:"&nbsp;",fixed:true,width:30,hideable:false,menuDisabled:true,sortable:false,renderer:function(a,b,c){return'<div class="clickable status-item-add" id="__status'+c.id+'">'}},Class:{id:"class",dataIndex:"class",header:"Class",fixed:true,width:200,menuDisabled:true,sortable:true}};
NECS.grid.columns.lots={Menu:{id:"menu",dataIndex:"none",header:"&nbsp;",fixed:true,width:30,hideable:false,menuDisabled:true,sortable:false,renderer:function(a,b,c){return'<div class="clickable status-item-add" id="__status'+c.id+'">'}},LotNo:{id:"lotno",dataIndex:"lot_no",header:"Lot Number",fixed:true,width:200,menuDisabled:true,sortable:true}};
NECS.grid.columns.brands={Menu:{id:"menu",dataIndex:"none",header:"&nbsp;",fixed:true,width:30,hideable:false,menuDisabled:true,sortable:false,renderer:function(a,b,c){return'<div class="clickable status-item-add" id="__status'+c.id+'">'}},Brand:{id:"brand",dataIndex:"brand",header:"Brand",fixed:true,width:200,menuDisabled:true,sortable:true}};
NECS.grid.columns.salesperson={SalesNo:{id:"salesno",dataIndex:"sales_no",header:"Sales #",width:80,fixed:true,menuDisabled:true,sortable:true},Name:{id:"name",dataIndex:"name",header:"Name",width:120,fixed:true,menuDisabled:true,sortable:true},Address:{id:"address",dataIndex:"address",header:"Address",width:240,menuDisabled:true,sortable:true},City:{id:"city",dataIndex:"city",header:"City",width:115,menuDisabled:true,sortable:true},State:{id:"state",dataIndex:"state",header:"State",width:45,menuDisabled:true,
sortable:true},Zip:{id:"zip",dataIndex:"zip",header:"Zip",width:60,menuDisabled:true,sortable:true},Phone:{id:"phone",dataIndex:"phone",header:"Phone",width:80,menuDisabled:true,sortable:true},Fax:{id:"fax",dataIndex:"fax",header:"Fax",width:80,menuDisabled:true,sortable:true},Username:{id:"login",dataIndex:"username",header:"Login Name",width:80,menuDisabled:true,sortable:true}};
NECS.grid.columns.customer={Menu:{id:"menu",dataIndex:"none",header:"&nbsp;",fixed:true,width:30,hideable:false,menuDisabled:true,sortable:false,renderer:function(a,b,c){return'<div class="clickable status-item-add" id="__status'+c.id+'">'}},CustNo:{id:"custno",dataIndex:"cust_no",header:"Cust #",width:80,fixed:true,menuDisabled:true,sortable:true},Company:{id:"company",dataIndex:"company",header:"Company Name",width:240,menuDisabled:true,sortable:true},Address1:{id:"address1",dataIndex:"address1",
header:"Address 1",width:240,menuDisabled:true,sortable:true},City:{id:"city",dataIndex:"city",header:"City",width:115,menuDisabled:true,sortable:true},State:{id:"state",dataIndex:"state",header:"State",width:45,menuDisabled:true,sortable:true},Zip:{id:"zip",dataIndex:"zip",header:"Zip",width:60,menuDisabled:true,sortable:true},Phone:{id:"phone",dataIndex:"phone",header:"Phone",width:95,menuDisabled:true,sortable:true},Username:{id:"login",dataIndex:"username",header:"Login Name",width:80,menuDisabled:true,
sortable:true},CallTime:{id:"call_time",dataIndex:"call_time",header:"Call Time",width:65,menuDisabled:true,sortable:true},LastOrderDate:{id:"ldate",dataIndex:"ldate",header:"Last Order",width:75,menuDisabled:true,sortable:true}};
NECS.grid.columns.item={Menu:{id:"menu",dataIndex:"none",header:"&nbsp;",fixed:true,width:30,hideable:false,menuDisabled:false,sortable:false,renderer:function(a,b,c){b=a="";a=c.data.qty_ord>0?"status-item-cart":"status-item-add";var d=NECS.util.checkMinMaxQty(c.data.qty_ord,c);if(d){a="status-item-warn";b="ext:qtip='"+d+"'"}return"<div "+b+' class="clickable '+a+'" id="__status'+c.data.item_no+'">'}},ItemNoEntry:{id:"itemno-edit",dataIndex:"item_no",header:"Item #",width:90,menuDisabled:true,hideable:false,
fixed:true,dragable:false,sortable:false,renderer:function(a,b,c){b="";var d;d="necs-input-itemno x-form-field x-form-text x-form-num-field";if(c.data.tag=="VALID")b="readonly";else d+=" x-form-focus";return'<input id="__editorItemNo-'+c.id+'" size="2" type="text" '+b+' style="" class="'+d+'" value="'+a+'" onfocus="this.select();" onkeydown="return gcb_EditorItemNoKeydown(event);" onchange="gcb_EditorItemNoChange(\''+c.id+"', this.value)\">"}},Image:{id:"image",dataIndex:"image_file",header:"Image",
fixed:false,width:65,menuDisabled:true,sortable:false,renderer:function(a,b,c){return a&&a.trim()!=""?'<img style="cursor: pointer;" onclick="NECS.util.ShowImage(\''+(NECS.application.ImgJumboUri+a)+'\');" src="'+NECS.application.ImgSmallUri+a+'" alt="'+c.data.description1+'" />':'<img src="'+NECS.application.CommonUri+'images/no-image-small.png" alt="'+c.data.description1+'" />'}},ItemNo:{id:"item",dataIndex:"item_no",header:"Item #",width:60,fixed:false,menuDisabled:true,sortable:true},Descrip:{id:"description1",
dataIndex:"description1",header:"Description",width:222,menuDisabled:true,sortable:true,renderer:function(a,b,c){b="";if(c.data.tag=="INVALID")return'<span class="necs-inline-error">'+a+"</span>";if(NECS.util.trim(a)!=""){b+='<div style="float: left;"><a href="javascript:displayItemInfo(\''+c.get("item_no")+"')\">"+a+"</a></div>";if(NECS.application.Options&&NECS.application.Options.ShowWebLink){a=c.data.weblink?c.data.weblink.trim():"";var d=NECS.application.Options.AltWeblinkIcon?"icon-weblink-mod":
"icon-world-link";if(a!="")b+='<a href="'+a+'" target="_blank"><div style="float: right; margin-right: 5px;" class="'+d+'"></div></a>'}b+='<div style="clear: both;"></div>';if(NECS.application.Options){if(NECS.application.Options.ShowDescrip2&&c.data.description2.trim()!="")b+='<div style="width: 90%; line-height: 1.25em">'+c.data.description2.trim()+"</div>";if(NECS.application.Options.ShowDescrip3&&c.data.description3.trim()!="")b+='<div style="width: 90%; line-height: 1.25em">'+c.data.description3.trim()+
"</div>";if(NECS.application.Options.ShowDescrip4&&c.data.description4.trim()!="")b+='<div style="width: 90%; line-height: 1.25em">'+c.data.description4.trim()+"</div>";if(NECS.application.Options.ShowSpcInst){a="";d=c.data.user_description2||"";if(this.readOnly||c.data.qty_ord==0&&d.trim()=="")a='disabled="disabled"';b+="<div><input "+a+' maxlength="35"onclick="if(!this.disabled){gcb_EditorSpcInstFocus();}" onchange="gcb_EditorSpcInstChange(\''+c.get("item_no")+'\', this.value);" onkeydown="return gcb_EditorTextKeydown(event);" value="'+
(c.get("user_description2")||"")+'" id="__editorSpcInst-'+c.id+'" class="x-form-field x-form-text" type="text" value="" /></div>'}}return b}return""}},Brand:{id:"brand",dataIndex:"brand",header:"Brand",width:85,menuDisabled:true,sortable:true},Class:{id:"class",dataIndex:"class",header:"Class",width:85,menuDisabled:true,sortable:true},Size:{id:"size",dataIndex:"size",header:"Pack Size",width:80,menuDisabled:true,sortable:true},UnitMS:{id:"unitms",dataIndex:"unit",header:"Unit",width:45,menuDisabled:true,
sortable:true},Weight:{id:"weight",dataIndex:"weight",header:"Weight",width:60,menuDisabled:true,renderer:function(a,b,c){return a==0?"":NECS.util.IsCatchweight(c.data)?a+'<span style="color:red">*</span>':a}},BaseCost:{id:"basecost",dataIndex:"cost_base",header:"Base Cost",width:65,fixed:true,menuDisabled:true,renderer:function(a){return Ext.util.Format.usMoney(a)}},MarkupPct:{id:"markup-pct",dataIndex:"markup_pct",header:"%",width:45,fixed:true,menuDisabled:true,renderer:function(a){var b=a>0?"blue":
"red";if(a>999.99)b="purple";return'<span style="cursor: pointer; color: '+b+'; text-decoration: underline;">'+Ext.util.Format.number(a,"000.00")+"</span>"}},Price:{id:"price",dataIndex:"price",header:"Unit Price",width:65,fixed:true,menuDisabled:true,renderer:function(a,b,c){b=a="";a=NECS.util.translatePrice(c);if(c&&c.data.manual_price)if(NECS.application.Options&&NECS.application.Options.SpChangePrices)b="color: green !important; font-weight: bold;";if(NECS.application.Options&&NECS.application.Options.SpChangePrices)b+=
"cursor: pointer; color: blue; text-decoration: underline;";return a=c&&(c.data.price_type==NECS.PT_SALE||c.data.break_avail||c.data.promo_avail)&&!c.data.manual_price?'<div style="float:left;"><div ext:qtip="Click to view additional sale information." class="icon-sale" style="float: left"></div><span style="'+b+'">'+Ext.util.Format.usMoney(a)+"</span></div>":'<span style="'+b+'">'+Ext.util.Format.usMoney(a)+"</span>"}},QtyOrd:{id:"qtyord",dataIndex:"qty_ord",header:"Qty",width:40,fixed:true,menuDisabled:true,
hideable:false,align:"center",renderer:function(a){if(isNaN(a))a=0;return Ext.util.Format.number(a,"?0.00?")}},QtyShip:{id:"qtyship",dataIndex:"qty_ship",header:"Qty Ship",width:55,fixed:true,align:"center",menuDisabled:true,hideable:false,renderer:function(a){if(isNaN(a))a=0;return a==9999.9999?"N/A":Ext.util.Format.number(a,"?0.00?")}},WeightShip:{id:"weightship",dataIndex:"weight_ship",header:"Wgt. Ship",width:60,fixed:true,menuDisabled:true,hideable:false,renderer:function(a){if(isNaN(a))a=0;
return a==9999.9999||a==0?"N/A":Ext.util.Format.number(a,"?0.0000?")}},QtyOrdSpinner:{id:"qtyord-arrows",dataIndex:"qty_ord",header:"Qty",width:65,menuDisabled:true,hideable:false,fixed:true,dragable:false,renderer:function(a,b,c){b="";if(Ext.isIE)b="margin-top: 3px;";else if(Ext.isWebKit)b="margin-top: 1px;";return c.data.tag=="INVALID"?'<div class="necs-spinner" style="'+b+'"><input id="__editorQtyOrd-'+c.id+'" disabled size="2" type="text" class="x-form-field x-form-text x-form-num-field" value="'+
a+'" "><div class="necs-spinner-buttons"><div class="necs-spinner-up"></div><div class="necs-spinner-down"></div></div></div>':'<div class="necs-spinner" style="'+b+'"><input id="__editorQtyOrd-'+c.id+'" size="2" type="text" class="x-form-field x-form-text x-form-num-field x-form-focus" value="'+a+'"  onfocus="this.select();" onkeydown="return gcb_EditorQtyOrdKeydown(event);" onchange="this.value=gcb_EditorQtyOrdChange(\''+c.id+'\', this.value)"><div class="necs-spinner-buttons"><div class="necs-spinner-up" onclick="gcb_EditorQtyIncrement(\''+
c.id+"', '__editorQtyOrd-"+c.id+'\');"></div><div class="necs-spinner-down" onclick="gcb_EditorQtyDecrement(\''+c.id+"', '__editorQtyOrd-"+c.id+"');\"></div></div></div>"}},ExtAmount:{id:"extamt",dataIndex:"ext_amount",header:"Ext. Amt",width:75,menuDisabled:true,renderer:function(a,b,c){if(c&&a!=0&&(c.data.dot_dep_pct||0)){b.attr='ext:qtip="Extended Amount represents<br />item deposit amount."';return Ext.util.Format.usMoney(a)+"D"}else return Ext.util.Format.usMoney(a)}},GuideCategory:{id:"guidecategory",
dataIndex:"category",header:"Category",width:75,hidden:true,menuDisabled:true,editor:new Ext.form.ComboBox({typeAhead:true,tiggerAction:"all",lazyRender:true})},Sequence:{id:"sequence",dataIndex:"sequence",header:"Seq.",width:50,menuDisabled:true,hideable:true,sortable:true,hidden:true,renderer:function(a){if(a=="ZZZ")return"";return a}},SequenceEdit:{id:"sequence-edit",dataIndex:"sequence",header:"Seq.",width:65,menuDisabled:true,hideable:false,fixed:true,renderer:function(a,b,c,d){return'<input id="__sequence'+
d+'" class="x-form-field x-form-text x-form-num-field x-form-focus" size="2" type="text" value="'+a+'"  onfocus="this.select();" onkeydown="return gcb_EditorSequenceKeydown(event);" onchange="gcb_EditorSequenceChange(\''+c.id+"',this.value);\" />"}},OnHand:{id:"onhand",dataIndex:"on_hand",header:"Qty Avail.",width:75,menuDisabled:true,hideable:true,align:"center",hidden:true,renderer:function(a){return a}},LastPrice:{id:"lastprice",dataIndex:"last_price",header:"Last Price",width:85,menuDisabled:true,
hideable:true,sortable:false,align:"right",hidden:true,renderer:function(a){return a==""?a:Ext.util.Format.usMoney(a)}},LastQty:{id:"lastqty",dataIndex:"last_qty",header:"Last Qty",width:75,menuDisabled:true,hideable:true,sortable:false,align:"center",hidden:true},LastDate:{id:"lastdate",dataIndex:"last_date",header:"Last Date",width:80,menuDisabled:true,hideable:true,align:"left",sortable:false,hidden:true},UPC:{id:"upc",dataIndex:"upc",header:"UPC",width:105,menuDisabled:true,sortable:true,hideable:true,
hidden:true}};
NECS.grid.columns.order={Status:{id:"order-status",header:"Status",width:25,hideable:false,menuDisabled:true,sortable:true,dragable:false,renderer:function(a,b,c){var d;a="Open";d="This order has not yet been completed and will not be trasmitted to the distributor.";if(c.data.completed){a="Pending";d="This order has been completed and is waiting to be picked up by the distributor."}if(c.data.completed&&c.data.transmitted){a="Transmitted";d="This order has been sent to the distributor but it has not yet been confirmed."}if(c.data.completed&&c.data.transmitted&&
c.data.confirmed){a="Received";d="The distributor has received this order."}b.attr='ext:qtip="'+d+'"';return a}},CustNo:{id:"custno",dataIndex:"cust_no",header:"Cust #",fixed:true,width:60,hideable:false,menuDisabled:true,sortable:true,dragable:false},OrderId:{id:"order-id",dataIndex:"order_id",header:"Order Id",fixed:true,width:35,hideable:false,menuDisabled:true,sortable:true,dragable:false},EstTotal:{id:"est-total",dataIndex:"total",header:"Total",width:30,menuDisabled:true,sortable:true,dragable:false,
renderer:function(a,b,c){return c.data.finalized?Ext.util.Format.usMoney(a):Ext.util.Format.usMoney(a)+" (Est)"}},DeliveryDate:{id:"delivery-date",dataIndex:"delivery_date",header:"Delivery Date",width:38,menuDisabled:true,sortable:true,dragable:false,renderer:function(a,b,c){if(c.data.completed&&c.data.transmitted&&c.data.confirmed)return a;return a+" (Requested)"}},Completed:{id:"completed",dataIndex:"completed",header:"Completed",width:40,menuDisabled:true,sortable:true,dragable:false},Created:{id:"created",
dataIndex:"created",header:"Created",width:40,menuDisabled:true,sortable:true,dragable:false},Transmitted:{id:"transmitted",dataIndex:"transmitted",header:"Transmitted",width:40,menuDisabled:true,sortable:true,dragable:false},Confirmed:{id:"confirmed",dataIndex:"confirmed",header:"Confirmed",width:40,menuDisabled:true,sortable:true,dragable:false},OrderNo:{id:"order-no",dataIndex:"order_no",header:"Order #",width:20,menuDisabled:true,sortable:true,dragable:false,renderer:function(a){return a&&a.trim()==
""?"N/A":a}},InvoiceNo:{id:"invoice-no",dataIndex:"invoice_no",header:"Invoice #",width:20,menuDisabled:true,sortable:true,dragable:false,renderer:function(a){return a&&a.trim()==""?"[Pending]":a}},PurchNo:{id:"purch-no",dataIndex:"purch_no",header:"P.O. #",width:20,menuDisabled:true,sortable:true,dragable:false},Comments:{id:"comments",dataIndex:"comments",header:"Comments",width:30,menuDisabled:true,sortable:false,dragable:false},SalesNo:{id:"salesno",dataIndex:"sales_no",header:"Salesperson",width:20,
menuDisabled:true,sortable:true,dragable:false},ScannedInvoice:{id:"scannedinvoice",dataIndex:"invoice_scan",width:10,header:"Scan",menuDisabled:true,sortable:true,dragable:false,renderer:function(a){return a&&a.trim()!=""?'<a target="_blank" href="'+NECS.application.LocalUri+"images/invoices/"+a+'"><div class="icon-pdf"></div></a>':""}}};
NECS.grid.columns.paymentHistory={InvoiceDate:{id:"invoice-date",dataIndex:"invoice_date",header:"Inv Date",width:30,menuDisabled:true,sortable:true},InvoiceNo:{id:"invoice-no",dataIndex:"invoice_no",header:"Inv No",width:30,menuDisabled:true,sortable:true,dragable:false},InvoiceTotal:{id:"invoice-amount",dataIndex:"invoice_total",header:"Inv Amt",width:30,menuDisabled:true,sortable:false,dragable:false,renderer:Ext.util.Format.usMoney},PurchNo:{id:"purchno",dataIndex:"PurchNo",header:"Purch No",
width:30,menuDisabled:true,sortable:false,dragable:false},InvoiceBalance:{id:"invoice-balance",dataIndex:"invoice_balance",header:"Net Due",width:30,menuDisabled:true,sortable:false,dragable:false,renderer:Ext.util.Format.usMoney},AmountPaid:{id:"amount-paid",dataIndex:"amount_paid",header:"Payment",width:30,menuDisabled:true,sortable:false,dragable:false,renderer:Ext.util.Format.usMoney},Credit:{id:"credit",dataIndex:"credit",header:"Cred/Disc",width:30,menuDisabled:true,sortable:false,dragable:false,
renderer:Ext.util.Format.usMoney},BalanceForward:{id:"bal-forward",dataIndex:"balance_forward",header:"Bal Fwd",width:30,menuDisabled:true,sortable:false,dragable:false,renderer:Ext.util.Format.usMoney},DatePaid:{id:"date-paid",dataIndex:"date_paid",header:"Last Pmt",width:30,menuDisabled:true,sortable:false,dragable:false},RefNo:{id:"refno",dataIndex:"ref_no",header:"Ref No",width:30,menuDisabled:true,sortable:false,dragable:false},Status:{id:"status",dataIndex:"status",header:"Stat",width:10,menuDisabled:true,
sortable:false,dragable:false,renderer:function(a,b,c){var d=a.trim();if(d!=""){var e="";if(d=="NE")e=c.data.InvoiceTotal<0?"(Non-Extended) Credit Memo has not been finalized by the distributor.":"(Non-Extended) Invoice has not been finalized by the distributor.";if(d=="CM")e="Credit Memo";if(d=="OP")e="Overpayment";if(d=="BC")e="Bounced Check";if(d=="FC")e="Finance Charge";if(d=="CF")e="Bounced Check Fee";if(e!="")b.attr='ext:qtip="'+e+'"'}return a}},ScannedInvoice:{id:"scannedinvoice",dataIndex:"invoice_scan",
width:12,header:"Scan",menuDisabled:true,sortable:false,dragable:false,renderer:function(a){return a&&a.trim()!=""?'<a target="_blank" href="'+NECS.application.LocalUri+"images/invoices/"+a+'"><div class="icon-pdf"></div></a>':""}}};
NECS.grid.columns.message={Subject:{id:"subject",dataIndex:"subject",header:"Subject",width:200,menuDisabled:true,sortable:true,dragable:false},Body:{id:"body",dataIndex:"body",header:"Message",width:300,menuDisabled:true,sortable:false,dragable:false},Posted:{id:"posted",dataIndex:"posted",header:"Posted",width:150,menuDisabled:true,sortable:true,dragable:false}};
NECS.grid.columns.ad={Title:{id:"title",dataIndex:"title",header:"Title",width:350,menuDisabled:true,sortable:true,dragable:false},AdDate:{id:"ad_date",dataIndex:"ad_date",header:"Date",width:300,menuDisabled:true,sortable:false,dragable:false}};NECS.grid.RowSelectionModel=function(a){NECS.grid.RowSelectionModel.superclass.constructor.call(this,a)};
Ext.extend(NECS.grid.RowSelectionModel,Ext.grid.RowSelectionModel,{initEvents:function(){!this.grid.enableDragDrop&&!this.grid.enableDrag?this.grid.on("rowmousedown",this.handleMouseDown,this):this.grid.on("rowclick",function(b,c,d){if(d.button===0&&!d.shiftKey&&!d.ctrlKey){this.selectRow(c,false);b.view.focusRow(c)}},this);var a=this.grid.view;a.on("refresh",this.onRefresh,this);a.on("rowupdated",this.onRowUpdated,this);a.on("rowremoved",this.onRemove,this)}});
NECS.grid.Editors=function(a){Ext.apply(this,a);NECS.grid.Editors.superclass.constructor.call(this);this.initializeItems()};
Ext.extend(NECS.grid.Editors,Ext.Component,{items:[false],elMap:[],nameMap:[],curEditor:0,initializeItems:function(){Ext.each(this.items,function(a){this.elMap.push(a.inputIdPrefix);this.nameMap.push(a.name)},this)},parseControlId:function(a){var b={};b.sourcePrefix=a.split("-")[0];b.recordId=a.split("-")[1];a=this.elMap.indexOf(b.sourcePrefix);b.name=a?this.nameMap[a]:"";return b},getNext:function(a,b,c){a=this.parseControlId(a);this.curEditor=this.elMap.indexOf(a.sourcePrefix);if(++this.curEditor>=
this.items.length){this.fireEvent("editoradvancerow");return false}if(b){c=c?c:this;if(!b.call(c,a,this.items[this.curEditor]))return false}return Ext.get(this.items[this.curEditor].inputIdPrefix+"-"+a.recordId)},getPrevious:function(a,b,c){a=this.parseControlId(a);this.curEditor=this.elMap.indexOf(a.sourcePrefix);if(--this.curEditor<0){this.fireEvent("rewindrow");return false}if(b){c=c?c:this;if(!b.call(c,a,this.items[this.curEditor]))return false}return Ext.get(this.items[this.curEditor].inputIdPrefix+
"-"+a.recordId)},getFirst:function(a){this.curEditor=0;return Ext.get(this.items[this.curEditor].inputIdPrefix+"-"+a)},getLast:function(a,b,c){this.curEditor=this.items.length-1;if(b){c=c?c:this;var d=false;for(this.curEditor=this.items.length;!d&&this.curEditor>0;){--this.curEditor;d=b.call(c,a,this.items[this.curEditor])}if(this.curEditor<0)return false}return Ext.get(this.items[this.curEditor].inputIdPrefix+"-"+a)},get:function(a,b){fieldIdx=this.nameMap.indexOf(a);if(fieldIdx!=-1)return Ext.get(this.items[fieldIdx].inputIdPrefix+
"-"+b);return null},getValue:function(a,b){a=this.nameMap.indexOf(a);if(a!=-1)if(b=Ext.fly(this.items[a].inputIdPrefix+"-"+b))return b.dom.value;return null}});
NECS.grid.GridPanel=function(a){NECS.grid.GridPanel.superclass.constructor.call(this,a);this.getColumnModel().on("columnmoved",this.updateColumnConfig,this);this.getColumnModel().on("hiddenchange",this.updateColumnConfig,this);this.getSelectionModel().on("rowdeselect",function(b,c){if(!this.app)return false;if(this.enableFlyout&&this.app.Options&&this.app.Options.ShowPrices)if(b=Ext.get("__flyout"+c))b.dom.style.display="none";return true},this);this.getSelectionModel().on("beforerowselect",function(b,
c,d,e){if(e)if(this.app)if(this.enableFlyout&&this.app.Options&&this.app.Options.ShowPrices)if(b=Ext.get("__flyout"+c))b.dom.style.display="block";else this.createFlyout(c,e)},this)};
Ext.extend(NECS.grid.GridPanel,Ext.grid.GridPanel,{ignoreConfigUpdate:false,columnConfigPrefId:-1,enableFlyout:true,flyout:null,flyoutElStr:"__flyout",setColumnConfig:function(a){if(a){var b=0,c,d,e;e=this.getColumnModel();this.ignoreConfigUpdate=true;for(d in a){c=e.getIndexById(d);if(c!=-1){c!=b&&e.moveColumn(c,b);c>0&&d!="search-qtyord-arrows"&&d!="qtyord-arrows"&&e.setHidden(b,a[d].hidden);++b}}this.ignoreConfigUpdate=false}},getColumnConfig:function(){if(cm=this.getColumnModel()){var a,b;config=
{};a=cm.getColumnCount();for(b=0;b<a;b++){config[cm.getColumnId(b)]={};config[cm.getColumnId(b)].hidden=cm.isHidden(b)==true}}return config},updateColumnConfig:function(){if(!(this.columnConfigPrefId==-1||this.ignoreConfigUpdate)){var a=new NECS.rpc.JSON.Request("updatePreference",[this.columnConfigPrefId,Ext.util.JSON.encode(this.getColumnConfig())],1,null,this);NECS.rpc.JSON.call(this.app.RpcUtilityUri,a)}},setCanConfigure:function(a){var b,c;b=this.getEl();(c=this.getColumnModel().getColumnById("menu"))||
(c=this.getColumnModel().getColumnById("search-menu"));if(a){if(c)c.menuDisabled=false;b.addClass("necs-grid-configurable")}else{c.menuDisabled=true;b.removeClass("necs-grid-configurable");a=this.getColumnModel();for(i=0;i<a.getColumnCount();i++)a.getColumnById(a.getColumnId(i)).dragable=false}},createFlyout:function(a,b){if(this.app.Options&&this.app.Options.ShowPrices){var c=Ext.util.Format.trim(b.data.dot_type||""),d=false;d=(d=c=="S")||c=="D";if(b.data.price_type==NECS.PT_SALE)b.data.reg_price<
b.data.price?this.setFlyout(a,'<div class="flyout-block">On sale through '+b.data.sale_end+"</div>"):this.setFlyout(a,'<div class="flyout-block">On sale through '+b.data.sale_end+' - <span style="font-weight: bold;">Regular Price:</span> '+Ext.util.Format.usMoney(b.data.reg_price)+"</div>");else if(d||b.data.break_avail||b.data.promo_avail)this.loadPromotionInfo(b,a)}},setFlyout:function(a,b,c){var d,e;c||(c="flyout-warning");if(d=Ext.get(this.getView().getRow(a))){(e=Ext.get(this.flyoutElStr+a))&&
e.remove();e=d.createChild({id:this.flyoutElStr+a});e.setVisibilityMode("display");e.addClass("flyout");e.addClass(c);e.dom.innerHTML=b;return e}return null},loadPromotionInfo:function(a,b){var c=Ext.get(this.getView().getRow(b)),d=false;if(c){d=Ext.get(this.flyoutElStr+b);if(!d){d=c.createChild({id:this.flyoutElStr+b});d.addClass("flyout");d.addClass("flyout-warning");d.dom.innerHTML='<div class="flyout-block">Loading additional item information.</div>';a=new NECS.rpc.JSON.Request("getItemPromotionInfo",
[a.data.item_no,a.data.promo_avail,a.data.break_avail],1,function(e){d.dom.innerHTML=e.result||"No additional information is available."},this);NECS.rpc.JSON.call(NECS.application.RpcOrderUri,a)}}}});
NECS.data.fields={SpecialClasses:[{name:"value",type:"string"},{name:"name",type:"string"}],Special:[{name:"item_no",type:"string"},{name:"description1",type:"string"},{name:"sale_start",type:"string"},{name:"sale_end",type:"string"},{name:"note",type:"string"},{name:"exclude_from_web",type:"boolean"},{name:"image_file",type:"string"},{name:"brand",type:"string"},{name:"class",type:"string"},{name:"size",type:"string"},{name:"unit",type:"string"},{name:"weight",type:"float"},{name:"price",type:"float"},
{name:"qty_ord",type:"float"},{name:"calc_weight",type:"int"}],Customer:[{name:"cust_no",type:"string"},{name:"bill_to",type:"string"},{name:"sp_cust_no",type:"string"},{name:"sales_no",type:"string"},{name:"account_id",type:"float"},{name:"company",type:"string"},{name:"address1",type:"string"},{name:"address2",type:"string"},{name:"address3",type:"string"},{name:"address4",type:"string"},{name:"city",type:"string"},{name:"state",type:"string"},{name:"zip",type:"string"},{name:"phone",type:"string"},
{name:"fax",type:"string"},{name:"username",type:"string"},{name:"call_time",type:"string"},{name:"ldate",type:"string"}],OrderItem:[{name:"item_no",type:"string"},{name:"description1",type:"string"},{name:"description2",type:"string"},{name:"description3",type:"string"},{name:"description4",type:"string"},{name:"brand",type:"string"},{name:"class",type:"string"},{name:"size",type:"string"},{name:"unit",type:"string"},{name:"calc_weight",type:"float"},{name:"weight",type:"string"},{name:"price",type:"float"},
{name:"manual_price",type:"string"},{name:"qty_ord",type:"float"},{name:"avg_weight",type:"float"},{name:"cnst_weight",type:"float"},{name:"on_hand",type:"float"},{name:"image_file",type:"string"},{name:"sequence",type:"string",sortType:"asInt"},{name:"ext_amount",type:"float"},{name:"category",type:"string"},{name:"price_type",type:"float"},{name:"break_avail",type:"boolean"},{name:"reg_price",type:"float"},{name:"sale_start",type:"string"},{name:"sale_end",type:"string"},{name:"tag",type:"string"},
{name:"last_price",type:"float"},{name:"last_qty",type:"int"},{name:"last_date",type:"string"},{name:"min_price",type:"float"},{name:"cost_base",type:"float"},{name:"markup_pct",type:"float"},{name:"checked",type:"boolean"},{name:"warn_min_qty",type:"float"},{name:"warn_max_qty",type:"float"},{name:"status",type:"int"},{name:"promo_avail",type:"boolean"},{name:"promo_amount",type:"float"},{name:"dot_dep_pct",type:"float"},{name:"upc",type:"string"},{name:"dot_type",type:"string"},{name:"weblink",
type:"string"},{name:"user_description1",type:"auto",defaultValue:null},{name:"user_description2",type:"auto",defaultValue:null},{name:"user_description3",type:"auto",defaultValue:null},{name:"user_description4",type:"auto",defaultValue:null}],CompletedOrderItem:[{name:"item_no",type:"string"},{name:"description1",type:"string"},{name:"description2",type:"string"},{name:"description3",type:"string"},{name:"description4",type:"string"},{name:"class",type:"string"},{name:"brand",type:"string"},{name:"unit",
type:"string"},{name:"size",type:"string"},{name:"track_weight",type:"boolean"},{name:"calc_weight",type:"boolean"},{name:"avg_weight",type:"float"},{name:"price",type:"float"},{name:"qty_ord",type:"float"},{name:"qty_ship",type:"float"},{name:"weight_ship",type:"float"},{name:"ext_amount",type:"float"},{name:"image_file",type:"string"},{name:"status",type:"int"}],OrderHeader:[{name:"order_id",type:"string"},{name:"cust_no",type:"string"},{name:"sales_no",type:"string"},{name:"total",type:"float"},
{name:"delivery_date",type:"string"},{name:"created",type:"string"},{name:"completed",type:"string"},{name:"transmitted",type:"string"},{name:"confirmed",type:"string"},{name:"order_no",type:"string"},{name:"invoice_no",type:"string"},{name:"purch_no",type:"string"},{name:"comments",type:"string"},{name:"invoice_scan",type:"string"},{name:"finalized",type:"boolean"},{name:"IsCompleted",type:"boolean"},{name:"NoScan",type:"boolean"},{name:"NoCancel",type:"boolean"},{name:"RowActionImageClass",type:"string"}],
Class:[{name:"class",type:"string"},{name:"image_file",type:"string"},{name:"total_items",type:"int"}],SaleItem:[{name:"ItemNo",type:"string"},{name:"Description1",type:"string"},{name:"Brand",type:"string"},{name:"Class",type:"string"},{name:"Size",type:"string"},{name:"UnitMS",type:"string"},{name:"Weight",type:"float"},{name:"Price",type:"float"},{name:"QtyOrd",type:"float"},{name:"ImageFile",type:"string"},{name:"SalePrice",type:"string"},{name:"SaleStart",type:"string"},{name:"SaleEnd",type:"string"}],
Guide:[{name:"guide_id",type:"string"},{name:"name",type:"string"},{name:"is_default",type:"boolean"},{name:"total_items",type:"int",sortType:"asInt"}],GuideList:[{name:"guide_id",type:"string"},{name:"name",type:"string"},{name:"is_default",type:"boolean"}],GuideCategoryList:[{name:"category",type:"string"}],PaymentHistory:[{name:"invoice_no",type:"string"},{name:"invoice_date",type:"string",sortType:"asDate"},{name:"invoice_total",type:"float"},{name:"invoice_balance",type:"float"},{name:"status",
type:"string"},{name:"purch_no",type:"string"},{name:"credit",type:"float"},{name:"amount_paid",type:"float"},{name:"date_paid",type:"string",sortType:"asDate"},{name:"ref_no",type:"string"},{name:"balance_forward",type:"float"},{name:"invoice_scan",type:"string"}],OpenInvoices:[{name:"InvoiceNo",type:"string"},{name:"InvoiceDate",type:"string"},{name:"InvoiceTotal",type:"float"},{name:"InvoiceBalance",type:"float"}],Payments:[{name:"DatePaid",type:"string"},{name:"AmountPaid",type:"float"},{name:"RefNo",
type:"string"}],Salesperson:[{name:"account_id",type:"integer"},{name:"username",type:"string"},{name:"sales_no",type:"string"},{name:"name",type:"string"},{name:"address",type:"string"},{name:"city",type:"string"},{name:"state",type:"string"},{name:"zip",type:"string"},{name:"phone",type:"string"},{name:"fax",type:"string"}],CustomerLocations:[{name:"cust_no",type:"string"},{name:"company",type:"string"}],Classes:[{name:"class",type:"string"}],Brands:[{name:"brand",type:"string"}],Lots:[{name:"lot_no",
type:"string"}],ReportConfiguration:[{name:"report_configuration_id",type:"int",sortType:"asInt"},{name:"name",type:"string"}],Message:[{name:"message_id",type:"int",sortType:"asInt"},{name:"subject",type:"string"},{name:"body",type:"string"},{name:"posted",type:"string",sortType:"asDate"},{name:"recipient_type",type:"int"},{name:"customer_account_id",type:"float"},{name:"salesperson_account_id",type:"int"},{name:"industry_code",type:"string"},{name:"territory",type:"string"},{name:"email",type:"int"}],
Ad:[{name:"ad_id",type:"int",sortType:"asInt"},{name:"title",type:"string"},{name:"ad_date",type:"string",sortType:"asDate"},{name:"link_type",type:"string"},{name:"link_id",type:"string"},{name:"image",type:"string"},{name:"industry_code",type:"string"}],IndustryCode:[{name:"industry_code",type:"string"}],Territory:[{name:"territory",type:"string"}],Theme:[{name:"ThemeId",type:"int"},{name:"CssSuffix",type:"string"},{name:"Description",type:"string"}],PriceList:[{name:"item_no",type:"string"},{name:"level",
type:"int",sortType:"asInt"},{name:"name",type:"string"},{name:"price",type:"float"},{name:"sale_price",type:"float"},{name:"sale_start",type:"string"},{name:"sale_end",type:"string"},{name:"future_price",type:"float"},{name:"future_start",type:"string"}],ItemTag:[{name:"tag_id",type:"string"},{name:"tag",type:"string"}],Prospect:[{name:"prospect_no",type:"int",sortType:"asInt"},{name:"sales_no",type:"string"},{name:"cust_no",type:"string"},{name:"price_level",type:"int"},{name:"company_name",type:"string"},
{name:"address1",type:"string"},{name:"address2",type:"string"},{name:"city",type:"string"},{name:"state",type:"string"},{name:"zip",type:"string"},{name:"phone",type:"string"},{name:"fax",type:"string"},{name:"contact",type:"string"},{name:"email",type:"string"},{name:"notes",type:"string"},{name:"status",type:"int"},{name:"created",type:"string"},{name:"updated",type:"string"},{name:"converted",type:"string"},{name:"convert_error",type:"string"}],Account:[{name:"account_id",type:"int"},{name:"username",
type:"string"},{name:"email",type:"string"},{name:"timezone",type:"string"},{name:"disabled",type:"boolean"}]};
NECS.data.records={Customer:new Ext.data.Record.create(NECS.data.fields.Customer),OrderItem:new Ext.data.Record.create(NECS.data.fields.OrderItem),OrderHeader:new Ext.data.Record.create(NECS.data.fields.OrderHeader),Class:new Ext.data.Record.create(NECS.data.fields.Class),SaleItem:new Ext.data.Record.create(NECS.data.fields.SaleItem),GuideList:new Ext.data.Record.create(NECS.data.fields.GuideList),PaymentHistory:new Ext.data.Record.create(NECS.data.fields.PaymentHistory),Salesperson:new Ext.data.Record.create(NECS.data.fields.Salesperson),
CustomerLocations:new Ext.data.Record.create(NECS.data.fields.CustomerLocations),Classes:new Ext.data.Record.create(NECS.data.fields.Classes),Brands:new Ext.data.Record.create(NECS.data.fields.Brands)};
NECS.grid.StandardOrderGrid=function(a,b){this.app=b;this.ShowSpcInst=NECS.application.Options&&NECS.application.Options.ShowSpcInst;b=[{name:"QtyOrd",inputIdPrefix:"__editorQtyOrd"}];this.ShowSpcInst&&b.push({name:"SpcInst",inputIdPrefix:"__editorSpcInst"});this.editors=new NECS.grid.Editors({items:b});this.columnConfigPrefId=NECS.pref.COLS_STANDARD;Ext.apply(this,a);this.proxyStandard=new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcOrderUri}),new NECS.rpc.JSON.Request("getOrderGuide",
[],1));this.emptyMsg="There are no items assigned to this order guide.";if(this.app.Options&&this.app.Options.GroupMode==0){this.defGroupField="";this.defSort="sequence"}else{this.defGroupField="class";this.defSort="@DEFAULT@"}if(a.mode=="order")this.store=new Ext.data.GroupingStore({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcOrderUri}),new NECS.rpc.JSON.Request("getOrderItems",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"item_no"},NECS.data.records.OrderItem)});
else if(a.mode=="view")this.store=new Ext.data.GroupingStore({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcOrderUri}),new NECS.rpc.JSON.Request("getCompletedOrderItems",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"item_no"},new Ext.data.Record.create(NECS.data.fields.CompletedOrderItem))});else if(a.mode=="specials"){this.store=new Ext.data.GroupingStore({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:NECS.application.RpcCatalogUri}),new NECS.rpc.JSON.Request("getSaleItems",
[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"item_no"},NECS.data.records.OrderItem),sortInfo:{field:"item_no",direction:"ASC"},remoteSort:true,groupField:this.defGroupField});this.emptyMsg="There are currently no specials being offered.."}else this.store=new Ext.data.GroupingStore({proxy:this.proxyStandard,reader:new NECS.data.JsonRpcReader({root:"data",id:"item_no",totalProperty:"total"},NECS.data.records.OrderItem),sortInfo:{field:this.defSort,direction:"ASC"},remoteSort:true,groupField:this.defGroupField});
this.store.sort=this.store.sort.createInterceptor(function(){if(this.lastOptions&&this.lastOptions.params)this.lastOptions.params.start=0;return true});this.store.on("load",function(){if(this.ShowSpcInst)if(destIdx=this.getColumnModel().getIndexById("description1")){newSize=this.getColumnModel().getColumnWidth(destIdx);for(var c,d,e=0;e<this.store.getCount();e++){c=this.store.getAt(e);if(d=Ext.fly("__editorSpcInst-"+c.id)){d.setWidth(newSize-15);d.addClassOnFocus("x-form-focus")}}}c=null;e=-1;if(this.restoreRecordId){e=
this.store.indexOfId(this.restoreRecordId);if(e!=-1){this.getSelectionModel().selectRow(e);c=this.getSelectionModel().getSelected()}}if(!this.restoreRecordId||e==-1){this.getSelectionModel().selectFirstRow();this.view.scrollToTop();c=this.store.getAt(0)}this.restoreRecordId=null;if(c)(d=this.editors.getFirst(c.id))&&setTimeout(function(){d.focus()},50);this.callbacks&&this.callbacks.onStoreLoaded&&this.callbacks.onStoreLoaded.call(this.callbacks.scope,this.store)},this);columnInfo=a.mode=="view"?
NECS.grid.getDefaultColumns(NECS.grid.ID_ORD_VIEW,this.app):NECS.grid.getDefaultColumns(NECS.grid.ID_STANDARD,this.app);this.columns=columnInfo.active;cols=columnInfo.available;this.callbacks&&this.callbacks.onInitializeColumns&&this.callbacks.onInitializeColumns.call(this.callbacks.scope,cols,this.columns);b=new Ext.PagingToolbar({store:this.store,pageSize:100,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});b.on("render",function(c){c.insert(11,new Ext.Toolbar.Separator);
c.insertButton(12,new Ext.Toolbar.TextItem({text:'<span style="color: red;">* Indicates average weight.</span>'}))});NECS.grid.StandardOrderGrid.superclass.constructor.call(this,{id:"order-guide-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,header:false,border:false,loadMask:{msg:"Loading order guide ..."},listeners:{scope:this,rowclick:function(c,d){if(this.autoFocus)(c=this.editors.getFirst(this.store.getAt(d).id))&&c.focus();this.autoFocus=true}},sm:new NECS.grid.RowSelectionModel({singleSelect:false,
preventGridViewFocus:true}),bbar:b,view:new Ext.grid.GroupingView({enableGroupingMenu:false,hideGroupedColumn:true,enableNoGroups:true,forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">'+this.emptyMsg+"</div>",deferEmptyText:true,scrollOffset:16,getRowClass:function(c){if(NECS.application.Salesperson){c=c.data.dot_type||"";if(c=="S")return"gr-dot-special";if(c=="D")return"gr-dot-drop"}return""}})});if(a.mode=="view"||a.mode=="order")b.setVisible(false);
this.on("render",function(){this.setCanConfigure(this.app.Options&&this.app.Options.ConfigGridStandard)},this);this.on("columnresize",function(c,d){if(this.ShowSpcInst){destIdx=this.getColumnModel().getIndexById("description1");if(c==destIdx){var e;for(c=0;c<this.store.getCount();c++){e=this.store.getAt(c);(e=Ext.fly("__editorSpcInst-"+e.id))&&e.setWidth(d-15)}}}},this)};
Ext.extend(NECS.grid.StandardOrderGrid,NECS.grid.GridPanel,{proxyStandard:null,proxySearch:null,autoFocus:true,setAutoFocus:function(a){this.autoFocus=a},setStandardMode:function(){this.store.proxy=this.proxyStandard},setSearchMode:function(){if(!this.proxySearch)this.proxySearch=new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcSearchUri}),new NECS.rpc.JSON.Request("getItemSearch",[],1));this.store.proxy=this.proxySearch},clearSearch:function(a,b,c){this.setStandardMode();this.store.lastOpions=
{};this.store.baseParams={};this.store.sortInfo={field:c?c:this.defSort,direction:"ASC"};b||this.store.load({params:{guideId:a,start:0,limit:this.app.ResultsPerPage}})},performSearch:function(a,b,c){this.setSearchMode();var d=a;if(d=="SM_FULLTEXT"){d="item_no";mode=NECS.SM_FULLTEXT}else mode=NECS.SM_CONTAINS;this.store.lastOptions={};this.store.baseParams={};this.store.sortInfo={field:d,direction:"ASC"};this.store.load({params:{start:0,limit:this.app.ResultsPerPage,sort:d,dir:"ASC",queryCol:a,query:b,
queryClass:null,mode:mode,guideId:c}})},advanceEditor:function(a){if(destEl=this.editors.getNext(a,function(b,c){if(c.name=="SpcInst"&&this.editors.getValue("QtyOrd",b.recordId)==0)return false;return true},this)){destEl.dom.readOnly=false;destEl.dom.disabled=false;destEl.focus();return false}return true},rewindEditor:function(a){if(destEl=this.editors.getPrevious(a,function(b,c){if(c.name=="SpcInst"&&this.editors.getValue("QtyOrd",b.recordId)==0)return false;return true},this)){destEl.focus();return false}return true},
selectionChanged:function(a,b){(destEl=b?this.editors.getFirst(a.id):this.editors.getLast(a.id,function(c,d){if(d.name=="SpcInst"&&this.editors.getValue("QtyOrd",c)==0)return false;return true},this))&&destEl.focus()}});
NECS.grid.SearchGrid=function(a,b){this.app=b;this.columnConfigPrefId=NECS.pref.COLS_SEARCH;Ext.apply(this,a);b=[{name:"QtyOrd",inputIdPrefix:"__editorQtyOrd"}];NECS.application.Options&&NECS.application.Options.ShowSpcInst&&b.push({name:"SpcInst",inputIdPrefix:"__editorSpcInst"});this.editors=new NECS.grid.Editors({items:b});this.addEvents("columnsloaded");this.store=new Ext.data.GroupingStore({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcSearchUri}),new NECS.rpc.JSON.Request("getItemSearch",
[],1)),reader:new NECS.data.JsonRpcReader({root:"data",totalProperty:"total",id:"item_no"},NECS.data.records.OrderItem),remoteSort:true,sortInfo:this.sortInfo,groupField:this.groupField});this.store.sort=this.store.sort.createInterceptor(function(){if(this.lastOptions.params)this.lastOptions.params.start=0;this.groupField="";return true});this.store.on("load",function(){if(NECS.application.Options&&NECS.application.Options.ShowSpcInst){if(destIdx=this.getColumnModel().getIndexById("search-description1")){newSize=
this.getColumnModel().getColumnWidth(destIdx);for(var c,d,e=0;e<this.store.getCount();e++){c=this.store.getAt(e);if(d=Ext.fly("__editorSpcInst-"+c.id)){d.setWidth(newSize-15);d.addClassOnFocus("x-form-focus")}c.set("Checked",this.checkList.indexOf(c.data.item_no)<0?false:true)}}}else if(this.checkList.length>0)for(e=0;e<this.store.getCount();e++){c=this.store.getAt(e);c.set("Checked",this.checkList.indexOf(c.data.item_no)<0?false:true)}this.getSelectionModel().selectFirstRow();this.view.scrollToTop();
if(c=this.store.getAt(0))(d=this.editors.getFirst(c.id))&&setTimeout(function(){d.focus()},50)},this);columnInfo=a.distributor?NECS.grid.getDefaultColumns(NECS.grid.ID_DIST_SEARCH,this.app):a.missing?NECS.grid.getDefaultColumns(NECS.grid.ID_ORD_MISSING,this.app):NECS.grid.getDefaultColumns(NECS.grid.ID_SEARCH,this.app);this.columns=columnInfo.active;cols=columnInfo.available;this.callbacks&&this.callbacks.onInitializeColumns&&this.callbacks.onInitializeColumns.call(this,cols,this.columns);this.checkColumn=
new Ext.grid.CheckColumn({id:"search-menu",header:"&nbsp;",dataIndex:"Checked",width:30,fixed:true,width:30,hideable:false,sortable:false});this.checkColumn.on("checked",function(c,d,e,f){if(e)this.checkList.indexOf(f.data.item_no)<0&&this.checkList.push(f.data.item_no);else this.checkList.remove(f.data.item_no)},this);if(a.useCheckSelection){this.columns.shift();this.columns.unshift(this.checkColumn)}b=new Ext.PagingToolbar({store:this.store,pageSize:this.app.ResultsPerPage,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",
emptyMsg:"No items to display"});NECS.grid.SearchGrid.superclass.constructor.call(this,{id:"search-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,autoHeight:false,header:false,border:false,clicksToEdit:"auto",loadMask:{msg:"Performing search ..."},listeners:{scope:this,rowclick:function(c,d){if(this.autoFocus)if(c=this.store.getAt(d))(c=this.editors.getFirst(c.id))&&c.focus();this.autoFocus=true}},sm:new NECS.grid.RowSelectionModel({singleSelect:false,preventGridViewFocus:true}),bbar:b,view:new Ext.grid.GroupingView({enableGroupingMenu:false,
hideGroupedColumn:true,enableNoGroups:true,forceFit:true,emptyText:a.missing?"":'<div align="center" style="color: #363636; font-weight: bold; !important">No items matched the search criteria.</div>',deferEmptyText:true,scrollOffset:12,getRowClass:function(c){if(NECS.application.Salesperson){c=c.data.dot_type||"";if(c=="S")return"gr-dot-special";if(c=="D")return"gr-dot-drop"}return""}}),plugins:[this.checkColumn]});this.on("columnresize",function(c,d){if(NECS.application.Options&&NECS.application.Options.ShowSpcInst){destIdx=
this.getColumnModel().getIndexById("search-description1");if(c==destIdx){var e;for(c=0;c<this.store.getCount();c++){e=this.store.getAt(c);(e=Ext.fly("__editorSpcInst-"+e.id))&&e.setWidth(d-15)}}}},this);this.app.Options&&this.setCanConfigure(this.app.Options.ConfigGridSearch);b.insert(11,new Ext.Toolbar.Separator);b.insertButton(12,new Ext.Toolbar.TextItem({text:'<span style="color: red;">* Indicates average weight.</span>'}))};
Ext.extend(NECS.grid.SearchGrid,NECS.grid.GridPanel,{autoFocus:true,checkList:[],setAutoFocus:function(a){this.autoFocus=a},execute:function(a,b,c,d,e){var f=a;d||(d=null);e||(e=null);if(f=="SM_FULLTEXT")f="item_no";this.store.lastOptions={};this.store.baseParams={};this.store.sortInfo={field:f,direction:"ASC"};this.store.groupBy(c);this.store.load({params:{start:0,limit:this.app.ResultsPerPage,sort:f,dir:"ASC",queryCol:a,query:b,queryClass:d,mode:NECS.SM_CONTAINS,guideId:null,tag:e}})},advanceEditor:function(a){if(destEl=
this.editors.getNext(a,function(b,c){if(c.name=="SpcInst"&&this.editors.getValue("QtyOrd",b.recordId)==0)return false;return true},this)){destEl.dom.readOnly=false;destEl.dom.disabled=false;destEl.focus();return false}return true},rewindEditor:function(a){if(destEl=this.editors.getPrevious(a,function(b,c){if(c.name=="SpcInst"&&this.editors.getValue("QtyOrd",b.recordId)==0)return false;return true},this)){destEl.focus();return false}return true},selectionChanged:function(a,b){(destEl=b?this.editors.getFirst(a.id):
this.editors.getLast(a.id,function(c,d){if(d.name=="SpcInst"&&this.editors.getValue("QtyOrd",c)==0)return false;return true},this))&&destEl.focus()}});NECS.panel.CartPanel=function(a,b){this.app=b;a=Ext.apply({autoEl:"div"},a);NECS.panel.CartPanel.superclass.constructor.call(this,a);this.initializeComponent()};
Ext.extend(NECS.panel.CartPanel,Ext.Container,{btCancel:null,btComplete:null,edDeliveryDate:null,cartPanel:null,errMsg:null,toolEl:null,total:0,store:null,view:null,initializeComponent:function(){this.initializeControls();this.initializeDate();this.initializeCart()},initializeControls:function(){this.edDeliveryDate=new Ext.form.DateField({fieldLabel:"Requested Delivery Date ",name:"DeliveryDate",cls:"disabled-input",width:90,allowBlank:false,editable:false,calendarAlign:"br-tr?",listeners:{scope:this,
select:function(a){a.fireEvent("change",a,a.getValue(),a.startValue)},change:function(a,b,c){this.fireEvent("deliverydatechanged",a,b,c);return true},specialkey:function(a,b){b.getKey()==b.ENTER&&a.blur()}}});this.btComplete=new Ext.Toolbar.Button({text:"Complete",tooltip:"Complete this order and proceed to checkout",ctCls:"necs-btn-green",disabled:true,listeners:{click:{scope:this,fn:function(){this.fireEvent("completeClick")}}}});this.btCancel=new Ext.Toolbar.Button({text:"Cancel",tooltip:"Cancel this order",
ctCls:"necs-btn-red",disabled:true,listeners:{click:{scope:this,fn:function(){this.fireEvent("cancelClick")}}}});this.btComment=new Ext.Toolbar.Button({text:"Edit Comment",enableToggle:true,ctCls:"necs-btn-yellow",tooltip:"Edit comments for this order.",disabled:false,listeners:{scope:this,click:function(){this.fireEvent("commentClick")}}})},initializeDate:function(){var a;if(a=this.getEl()){this.toolEl=a.createChild();new Ext.Toolbar({renderTo:this.toolEl,ctCls:"necs-toolbar",listeners:{scope:this,
render:function(b){if(NECS.application.Options.CanChgDlvDate){b.addText("&nbsp;Requested Delivery Date:");b.add(this.edDeliveryDate)}else if(NECS.application.Options.ShowPrices){b.addText("&nbsp;Prices estimated for:");b.add(this.edDeliveryDate);this.edDeliveryDate.setDisabled(true)}}}})}else alert("NECS.CartPanel: Unable to find root element for myself.")},initializeCart:function(){var a;this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcOrderUri}),
new NECS.rpc.JSON.Request("getCartItems",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"item_no"},NECS.data.records.OrderItem)});if(this.app.Options.ShowPrices){priceText=this.app.Options.SpChangePrices?'<div style="float: left; width: 90px;" onclick="gcb_CartStartEditPrice(this, \'{item_no}\');"><div style="float: left; width: 40px; cursor: pointer; color: blue; text-decoration: underline; text-align: right">{[this.price(values)]}/</div>':'<div style="float: left; width: 90px;"><div style="float: left; width: 40px; text-align: right">{[this.price(values)]}/</div>';
a=new Ext.XTemplate('<tpl for=".">','<div class="item" style="clear: both; padding: 2px; line-height: 20px; height: 48px;">',"<div>({item_no})</span> {description1:ellipsis(25)}</div>",'<div {[this.statusTip(values)]} id="__statusReview{item_no}" class="{[this.statusCls(values)]}" style="float: left; width: 16px; margin: 3px; margin-left: 0;" onclick="gcb_EditorQtyOrdChange(\'{item_no}\', 0);"></div>','<div class="x-spinner" style="float: left;">','<input id="__reviewEditor{item_no}" onkeydown="return gcb_EditorQtyOrdKeydown(event);" onfocus="this.select();" style="height: 18px;  font-size: 11px;" class="x-form-field x-form-text x-form-num-field x-form-focus" type="text" size="2" value="{qty_ord}" onchange="gcb_EditorQtyOrdChange(\'{item_no}\', this.value);" />',
'<div class="x-spinner-buttons">',"<div class=\"x-spinner-up\" onclick=\"gcb_EditorQtyIncrement('{item_no}', '__reviewEditor{item_no}');\"></div>","<div class=\"x-spinner-down\" onclick=\"gcb_EditorQtyDecrement('{item_no}', '__reviewEditor{item_no}');\"></div>","</div></div>"+priceText+'<div style="float: left; width: 50px; text-align: left">{[this.adjustedUnitMS(values)]}</div>',"</div>",'<div style="float: right;">{[this.extAmount(values)]}</div>',"</div>","</tpl>",{statusCls:function(b){return NECS.util.checkMinMaxQty(b.qty_ord,
{data:b})?"status-item-warn":"status-item-remove"},statusTip:function(b){return(b=NECS.util.checkMinMaxQty(b.qty_ord,{data:b}))?"ext:qtip='"+b+"'":""},price:function(b){var c=NECS.util.translatePrice(b);return b.manual_price&&NECS.application.Options.SpChangePrices?"<span style='color:green; font-weight: bold;'>"+Ext.util.Format.usMoney(c)+"</span>":Ext.util.Format.usMoney(c)},extAmount:function(b){return b.dot_dep_pct?'<span ext:qtip="Extended Amount represents<br />item deposit amount.">'+Ext.util.Format.usMoney(b.ext_amount)+
"D</span>":Ext.util.Format.usMoney(b.ext_amount)},adjustedUnitMS:function(b){return b.calc_weight==1?"LB.":b.unit}})}else a=new Ext.XTemplate('<tpl for=".">','<div class="item" style="clear: both; padding: 2px; line-height: 20px; height: 48px;">',"<div>({item_no}) {description1:ellipsis(25)}</div>",'<div {[this.statusTip(values)]} id="__statusReview{item_no}" class="{[this.statusCls(values)]}" style="float: left; width: 16px; margin: 3px; margin-left: 0;" onclick="gcb_EditorQtyOrdChange(\'{item_no}\', 0);"></div>',
'<div class="x-spinner" style="float: left;">','<input id="__reviewEditor{item_no}" onkeydown="return gcb_EditorQtyOrdKeydown(event);" onfocus="this.select();" style="height: 18px;  font-size: 11px;" class="x-form-field x-form-text x-form-num-field x-form-focus" type="text" size="2" value="{qty_ord}" onchange="gcb_EditorQtyOrdChange(\'{item_no}\', this.value);" />','<div class="x-spinner-buttons">',"<div class=\"x-spinner-up\" onclick=\"gcb_EditorQtyIncrement('{item_no}', '__reviewEditor{item_no}');\"></div>",
"<div class=\"x-spinner-down\" onclick=\"gcb_EditorQtyDecrement('{item_no}', '__reviewEditor{item_no}');\"></div>","</div></div>","</div>","</tpl>",{statusCls:function(b){return NECS.util.checkMinMaxQty(b.qty_ord,{data:b})?"status-item-warn":"status-item-remove"},statusTip:function(b){return(b=NECS.util.checkMinMaxQty(b.qty_ord,{data:b}))?"ext:qtip='"+b+"'":""}});this.view=new Ext.DataView({store:this.store,loadMask:true,layout:"fit",tpl:a,itemSelector:"div.item",emptyText:"<br /><center>There are no items on your order.</center>"});
rootEl=this.getEl();this.cartInfo=new Ext.BoxComponent({id:"cart-case-count",cls:"info-header",html:""});this.cartInfo.setVisible(NECS.application.Options&&NECS.application.Options.ShowCaseCount||NECS.application.Options&&NECS.application.Options.ShowGP);this.errMsg=new Ext.BoxComponent({id:"cart-error-box"});this.errMsg.setVisible(false);this.weightErrMsg=new Ext.BoxComponent({id:"cart-wgt-error-box"});this.weightErrMsg.setVisible(false);this.toolbar=new Ext.Toolbar({items:[this.btComment,new Ext.Toolbar.Fill,
this.btComplete,new Ext.Toolbar.Spacer,this.btCancel]});this.cartPanel=new Ext.Panel({renderTo:rootEl.createChild({tag:"div"}),id:"cart-panel",ctCls:"border-left",title:"Order Review",collapsible:false,autoWidth:true,border:false,autoScroll:true,items:[this.cartInfo,this.toolbar,this.errMsg,this.weightErrMsg,this.view]})},getTotal:function(){return this.total},getTotalWeight:function(){return this.totalWeight},updateTotal:function(a){if(this.app.Options.ShowPrices){var b=0,c=0,d=0,e;for(i=0;i<this.store.getCount();i++){e=
this.store.getAt(i);b+=e.data.ext_amount;c+=parseFloat(e.data.qty_ord);d+=parseFloat(e.data.qty_ord)*(parseFloat(e.data.weight)||0)}this.total=b;this.totalWeight=d;this.cartPanel.setTitle("Estimated Total: "+Ext.util.Format.usMoney(b));d=[];if(NECS.application.Options){NECS.application.Options.ShowCaseCount&&d.push("Total Cases: "+c);if(NECS.application.Options)if(NECS.application.Options.MinOrderWeight!=0||NECS.application.Options.MaxOrderWeight!=0)d.push("Total Weight: "+Ext.util.Format.number(this.totalWeight||
0,"0,0.00")+" lbs.");if(a&&NECS.application.Options.ShowGP){b=a.Total||0;a=b-(a.dot_dep_total||0)-(a.cost_base||0)||0;b=a/b*100;c="";if(a<0)c="color: red;";d.push('<span id="ed-cart-gp" style="'+c+'">GP: $'+Ext.util.Format.number(a||0,"0,0.00")+" / "+Ext.util.Format.number(b||0,"0.00")+"%</span>")}}this.cartInfo.update(d.join("<br />"))}},setTotalState:function(a,b){if(a)this.errMsg.setVisible(false);else{this.cartPanel.setTitle('<span style="color: red;">Estimated Total: '+Ext.util.Format.usMoney(this.total)+
"</span>");this.errMsg.setVisible(true);this.errMsg.update(b)}},setWeightTotalState:function(a,b){if(a)this.weightErrMsg.setVisible(false);else{this.cartPanel.setTitle('<span style="color: red;">Estimated Total: '+Ext.util.Format.usMoney(this.total)+"</span>");this.weightErrMsg.setVisible(true);this.weightErrMsg.update(b)}},updateState:function(a){this.updateTotal(a);if(this.store.getCount()>0){this.btComplete.setDisabled(false);this.btCancel.setDisabled(false)}else{this.btComplete.setDisabled(true);
a?this.btCancel.setDisabled(a.DeliveryDate==null):this.btCancel.setDisabled(true);this.store.removeAll()}},setDeliveryDate:function(a){this.edDeliveryDate.setValue(a.clearTime());this.edDeliveryDate.clearInvalid()},setMinDeliveryDate:function(a){this.edDeliveryDate.setMinValue(a.clearTime())},setMaxDeliveryDate:function(a){this.edDeliveryDate.setMaxValue(a.clearTime())},setRouteDays:function(a){a&&this.edDeliveryDate.setDisabledDays(a)},_setHeight:function(a){this.setHeight(a);this.cartPanel.setHeight(a-
this.toolEl.getHeight())}});NECS.rpc.JSON.Request=function(a,b,c,d,e){this.request={};this.request.jsonrpc="2.0";this.request.method=a;if(b!=null&&b.length)this.request.params=b;if(c)this.request.id=c;if(d)this.callback=d;this.scope=e?e:this};
NECS.rpc.JSON.Request.prototype={request:null,callback:null,setParams:function(a){this.request.params=a},updateExistingParams:function(a){if(!this.request.params)this.request.params={};for(var b in a)if(this.request.params[b]!="undefined")this.request.params[b]=a[b]},updateParams:function(a){if(!this.request.params)this.request.params={};for(var b in a)this.request.params[b]=a[b]},toJSON:function(){return Ext.util.JSON.encode(this.request)},toString:function(){return this.toJSON()}};
NECS.rpc.JSON.call=function(a,b){(new Ext.data.Connection).request({url:a,method:"POST",jsonData:b.toJSON(),success:function(c){b.callback&&b.callback.call(b.scope,Ext.util.JSON.decode(c.responseText))},failure:function(c){gIgnoreRpcErrors||Ext.MessageBox.show({buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR,msg:"An error has occured while attempting to process a background request.<br /><br />Details of the errror follow:<br />"+Ext.util.JSON.encode(c),title:"Application Error"})}})};
NECS.data.JsonRpcProxy=function(a,b){NECS.data.JsonRpcProxy.superclass.constructor.call(this);this.conn=a;this.requestObj=b};
Ext.extend(NECS.data.JsonRpcProxy,Ext.data.DataProxy,{load:function(a,b,c,d,e){this.requestObj.updateParams(a);this.conn.request({params:{},jsonData:this.requestObj.toJSON(),request:{callback:c,scope:d,arg:e},reader:b,callback:this.loadResponse,scope:this})},loadResponse:function(a,b,c){delete this.activeRequest;if(b){var d;try{d=a.reader.read(c)}catch(e){this.fireEvent("loadexception",this,a,c,e);a.request.callback.call(a.request.scope,null,a.request.arg,false);return}this.fireEvent("load",this,
a,a.request.arg);a.request.callback.call(a.request.scope,d,a.request.arg,true);typeof this.requestObj.callback=="function"&&this.requestObj.callback.call(this.requestObj.scope,Ext.util.JSON.decode(c.responseText))}else{this.fireEvent("loadexception",this,a,c);a.request.callback.call(a.request.scope,null,a.request.arg,false)}},update:function(){},updateResponse:function(){}});NECS.data.JsonRpcReader=function(a,b){a=a||{};NECS.data.JsonRpcReader.superclass.constructor.call(this,a,b||a.fields)};
Ext.extend(NECS.data.JsonRpcReader,Ext.data.JsonReader,{read:function(a){a=eval("("+a.responseText+")");if(!a)throw{message:"JsonRpcReader.read: Json object not found"};return this.readRecords(a.result)}});
NECS.window.ItemInfoWindow=function(a){a||(a={});Ext.apply(a,{layout:"fit",cls:"necs-item-info-window",title:"Product Information",minWidth:530,width:530,height:380,closeAction:"hide",plain:true,modal:true,resizable:false,listeners:{scope:this,show:function(){if(this.form&&this.renderForm){this.setHeight(this.formHeight+this.getFrameHeight());this.center();this.form.setHeight(this.body.getHeight()-2);this.body.update("");this.form.render(this.body)}}},buttonAlign:"center",buttons:[{text:"Close",scope:this,
handler:function(){this.hide()}}]});NECS.window.ItemInfoWindow.superclass.constructor.call(this,a)};
Ext.extend(NECS.window.ItemInfoWindow,Ext.Window,{form:null,itemNo:null,mask:null,renderForm:true,createForm:function(a){xOffset=10;yOffset=3;yStep=25;yPos=10;labelWidth=60;items=[];labelSkel=[];fieldSkel=[];options={};this.form&&delete this.form;if(NECS.application.Options)options=NECS.application.Options;if(a.image_file!==""){xOffset+=180;var b="",c="";b=NECS.application.ImgJumboUri+a.image_file;c=a.item_no+" - "+a.description1;c=c.replace('"',"&quot;");c.replace("'","\\'");items=[{x:10,y:yPos,
xtype:"label",html:'<div style="width:160px; height: 140px;" align="center"><img style="cursor: pointer;" onclick="NECS.util.ShowImage(\''+b+'\');" src="'+NECS.application.ImgLargeUri+"/"+a.image_file+'" /></div>'}]}if(options.ShowDescrip2&&a.description2.trim()!=""){labelSkel[labelSkel.length]={xtype:"label",text:"Desc 2"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:a.description2}}if(options.ShowDescrip3&&a.description3.trim()!=""){labelSkel[labelSkel.length]=
{xtype:"label",text:"Desc 3"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:a.description3}}if(options.ShowDescrip4&&a.description4.trim()!=""){labelSkel[labelSkel.length]={xtype:"label",text:"Desc 4"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:a.description4}}if(options.ShowOnHand){labelSkel[labelSkel.length]={xtype:"label",text:"On Hand"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:a.on_hand+
"  (Last updated at "+a.last_upd_invt+")"}}labelSkel[labelSkel.length]={xtype:"label",text:"Unit Meas."};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:a.unit};labelSkel[labelSkel.length]={xtype:"label",text:"Pack"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:a.size};b=a.weight;if(b!=""){if(NECS.util.IsCatchweight(a))b+=" (Average)";labelSkel[labelSkel.length]={xtype:"label",text:"Weight"};fieldSkel[fieldSkel.length]={xtype:"textfield",
readOnly:true,anchor:"100%",value:b}}labelSkel[labelSkel.length]={xtype:"label",text:"Class"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:a["class"]};if(options.ShowBrand){labelSkel[labelSkel.length]={xtype:"label",text:"Brand"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:a.brand}}if(a.upc.trim()!=""){labelSkel[labelSkel.length]={xtype:"label",text:"UPC"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",
value:a.upc}}if(options.ShowWebLink&&a.weblink!=""){labelSkel[labelSkel.length]={xtype:"label",text:"Weblink"};fieldSkel[fieldSkel.length]={xtype:"label",readOnly:true,anchor:"100%",html:'<a href="'+a.weblink+'" target="_blank">(click to view more product information)</a>'}}if(options.ShowItemLastInfo){var d;d=Ext.util.Format.usMoney(a.last_price);d=d=="$0.00"?false:d;c=a.LastQty==0?false:a.last_qty;b=a.LastDate==""?false:a.last_date;if(d){labelSkel[labelSkel.length]={xtype:"label",text:"Last Price"};
fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:d}}if(c){labelSkel[labelSkel.length]={xtype:"label",text:"Last Qty"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:c}}if(b){labelSkel[labelSkel.length]={xtype:"label",text:"Last Date"};fieldSkel[fieldSkel.length]={xtype:"textfield",readOnly:true,anchor:"100%",value:b}}}b=[];c=null;for(i=0;i<labelSkel.length;i++){c=Ext.apply(labelSkel[i],{x:xOffset,y:yPos+yOffset});b[b.length]=c;c=Ext.apply(fieldSkel[i],
{x:xOffset+labelWidth,y:yPos});b[b.length]=c;yPos+=yStep}this.formHeight=0;if(a.image_file!==""&&yPos<180)yPos=180;if(a.note&&a.note.trim()!=""){b[b.length]={x:10,y:yPos,xtype:"textarea",readOnly:true,anchor:"100% 100%",value:a.note};this.formHeight+=100}this.formHeight+=yPos+yStep/2+22;items=items.concat(b);this.form=new Ext.FormPanel({layout:"absolute",border:false,bodyStyle:"padding: 5px",tbar:new Ext.Toolbar({ctCls:"necs-toolbar",items:[{xtype:"label",text:"Item #"+a.item_no+" - "+a.description1}]}),
items:items});this.renderForm=true},showForItem:function(a){this.loadMask&&delete this.loadMask;this.loadMask=new Ext.LoadMask(Ext.getBody(),{msg:"Fetching product information ..."});this.loadMask.show();if(this.itemNo!==a){var b=new NECS.rpc.JSON.Request("getItemInfo",[a],1,function(c){this.loadMask&&this.loadMask.hide();if(c.error||!c.result)NECS.util.DisplayError('An error occured while attemping to fetch product information for item "'+a+'"',"Error Fetching Data");else if(c.result.success){this.itemNo=
a;this.createForm(c.result.data);this.show()}else NECS.util.DisplayError("The requested product information was not found in the database.")},this);NECS.rpc.JSON.call(NECS.application.RpcOrderUri,b)}else{this.loadMask&&this.loadMask.hide();this.renderForm=false;this.show()}}});
NECS.window.PriceInfoWindow=function(a){a||(a={});Ext.apply(a,{layout:"fit",cls:"necs-item-info-window",title:"Item Price Information",minWidth:530,width:530,height:380,closeAction:"hide",plain:true,modal:true,resizable:false,listeners:{scope:this,show:function(){if(this.form&&this.renderForm){this.center();this.form.setHeight(this.body.getHeight()-2);this.body.update("");this.form.render(this.body);this.gPrices.setHeight(this.body.getHeight()-this.gridHeightAdjust);this.gPrices.store.load()}}},buttonAlign:"center",
buttons:[{text:"Close",scope:this,handler:function(){this.hide()}}]});NECS.window.PriceInfoWindow.superclass.constructor.call(this,a)};
Ext.extend(NECS.window.PriceInfoWindow,Ext.Window,{form:null,itemNo:null,mask:null,renderForm:true,createForm:function(a){var b={};this.form&&delete this.form;if(NECS.application.Options)b=NECS.application.Options;this.gPrices=new NECS.grid.GridPanel({id:"level-price-grid",ctCls:"necs-grid",anchor:"100% 95%",loadMask:{msg:"Please wait. Loading ..."},cm:new Ext.grid.ColumnModel([{id:"level",dataIndex:"level",header:"Level",width:65,menuDisabled:true,sortable:true},{id:"price",dataIndex:"price",header:"Price",
width:65,menuDisabled:true,sortable:true,renderer:Ext.util.Format.usMoney},{id:"sale-price",dataIndex:"sale_price",header:"Sale Price",width:65,menuDisabled:true,sortable:true,renderer:function(c){c=Ext.util.Format.usMoney(c);if(c=="$0.00")c="";return c}},{id:"sale-start",dataIndex:"sale_start",header:"Sale Start",width:65,menuDisabled:true,sortable:false},{id:"sale-end",dataIndex:"sale_end",header:"Sale End",width:65,menuDisabled:true,sortable:false},{id:"future-price",dataIndex:"future_price",header:"Future Price",
width:65,menuDisabled:true,sortable:false,renderer:function(c){c=Ext.util.Format.usMoney(c);if(c=="$0.00")c="";return c}},{id:"future-start",dataIndex:"future_start",header:"Future Start",width:65,menuDisabled:true,sortable:false}]),sm:new Ext.grid.RowSelectionModel({singleSelect:false,moveEditorOnEnter:true}),store:new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:NECS.application.RpcUri+"/utility"}),new NECS.rpc.JSON.Request("getItemLevelPrices",[a.item_no],1)),reader:new NECS.data.JsonRpcReader({root:"data",
id:"Level"},new Ext.data.Record.create(NECS.data.fields.PriceList))}),viewConfig:{autoFill:true,forceFit:true}});if(!a.min_price||isNaN(a.min_price))a.min_price=0;lastPrice=Ext.util.Format.usMoney(a.last_price);lastPrice=lastPrice=="$0.00"?"N/A":lastPrice;lastQty=a.last_qty==0?"N/A":a.last_qty;lastDate=a.last_date==""?"N/A":a.last_date;items=[{layout:"column",border:false,items:[{columnWidth:".25",layout:"form",border:false,items:[{xtype:"textfield",name:"min-price",fieldLabel:"Min. Price",readOnly:true,
anchor:"95%",value:Ext.util.Format.usMoney(a.min_price)}]},{columnWidth:".25",layout:"form",border:false,items:[{xtype:"textfield",name:"last-price",fieldLabel:"Last Price",readOnly:true,anchor:"95%",value:lastPrice}]},{columnWidth:".22",layout:"form",border:false,items:[{xtype:"textfield",name:"last-qty",fieldLabel:"Last Qty",readOnly:true,anchor:"90%",value:lastQty}]},{columnWidth:".28",layout:"form",border:false,items:[{xtype:"textfield",align:"right",name:"last-date",fieldLabel:"Last Date",readOnly:true,
anchor:"100%",value:lastDate}]}]},this.gPrices];this.form=new Ext.FormPanel({border:false,bodyStyle:"padding: 5px",labelWidth:60,tbar:new Ext.Toolbar({ctCls:"necs-toolbar",items:[{xtype:"label",text:"Item #"+a.item_no+" - "+a.description1}]}),items:items});this.renderForm=true},showForItemRecord:function(a){if(a){this.createForm(a.data);this.show()}},showForItem:function(a){this.loadMask&&delete this.loadMask;this.loadMask=new Ext.LoadMask(Ext.getBody(),{msg:"Fetching product information ..."});this.loadMask.show();
if(this.itemNo!==a){var b=new NECS.rpc.JSON.Request("getItemInfo",[a],1,function(c){this.loadMask&&this.loadMask.hide();if(c.error||!c.result)NECS.util.DisplayError('An error occured while attemping to fetch product information for item "'+a+'"',"Error Fetching Data");else if(c.result.success){this.itemNo=a;this.createForm(c.result.data);this.show()}else NECS.util.DisplayError("The requested product information was not found in the database.")},this);NECS.rpc.JSON.call(NECS.application.RpcUri+"/order",
b)}else{this.loadMask&&this.loadMask.hide();this.renderForm=false;this.show()}}});
NECS.window.CheckPromptWindow=function(a){a||(a={});Ext.apply(a,{layout:"fit",minWidth:340,width:340,height:160,closeAction:"hide",plain:true,modal:true,resizable:false,listeners:{scope:this,show:function(){if(this.form&&this.renderForm){this.center();this.form.setHeight(this.body.getHeight()-2);this.body.update("");this.form.render(this.body)}}},buttonAlign:"center",buttons:[{text:"OK",scope:this,handler:function(){this.doSave()}},{text:"Cancel",scope:this,handler:function(){this.hide()}}]});NECS.window.CheckPromptWindow.superclass.constructor.call(this,
a)};
Ext.extend(NECS.window.CheckPromptWindow,Ext.Window,{form:null,itemNo:null,mask:null,cb:null,cbScope:null,renderForm:true,createForm:function(a,b){this.form&&delete this.form;items=[{xtype:"label",html:this.promptText,x:10,y:10},{xtype:"textfield",x:10,y:30,id:"edCheckPromptText",name:"CheckPromptText",fieldLabel:"",anchor:"99%",value:a},{xtype:"checkbox",x:15,y:60,id:"edCheckPromptCheck",name:"CheckPromptCheck",value:"",checked:b},{xtype:"label",html:this.checkboxText,x:35,y:65}];this.form=new Ext.FormPanel({border:false,bodyStyle:"padding: 5px",
labelWidth:60,layout:"absolute",items:items});this.renderForm=true},show:function(){this.createForm();NECS.window.CheckPromptWindow.superclass.show.call(this)},prompt:function(a,b,c,d){this.createForm(a,b);this.cb=c;this.cbScope=d;NECS.window.CheckPromptWindow.superclass.show.call(this)},doSave:function(){typeof this.cb=="function"&&this.cb.call(this.cbScope,"ok",Ext.getCmp("edCheckPromptText").getValue(),Ext.getCmp("edCheckPromptCheck").getValue());this.hide()}});
NECS.window.ImageWindow=function(a){a||(a={});Ext.apply(a,{layout:"fit",width:100,height:100,closeAction:"close",plain:true,modal:true,resizable:false,listeners:{scope:this,show:function(){this.body.on("click",function(){this.hide()},this);var b=new Image,c=this;b.onload=function(){c.setHeight(Math.min(580,b.height+30));c.setWidth(Math.min(565,b.width+15));c.body.update('<div><img style="cursor: pointer;" src="'+b.src+'" /></div>');c.center()};b.src=this.imageUrl}}});NECS.window.ImageWindow.superclass.constructor.call(this,
a)};Ext.extend(NECS.window.ImageWindow,Ext.Window,{imageUrl:"",showForImage:function(a){if(a&&a.trim()!=""){this.imageUrl=a;NECS.window.CheckPromptWindow.superclass.show.call(this)}}});
NECS.grid.CustomerGridPanel=function(a,b){this.app=b;Ext.apply(this,a);b=a.callList?new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcUri+"/salesperson"}),new NECS.rpc.JSON.Request("getCallList",[],1)):new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcCustomerUri}),new NECS.rpc.JSON.Request("getCustomers",[],1));this.store=new Ext.data.Store({proxy:b,reader:new NECS.data.JsonRpcReader({root:"data",totalProperty:"totalResults",id:"cust_no"},NECS.data.records.Customer),
remoteSort:true});this.store.sort=this.store.sort.createInterceptor(function(){if(this.lastOptions.params)this.lastOptions.params.start=0;return true});b=NECS.grid.columns.customer;if(this.spMode){this.action=new Ext.ux.grid.RowActions({header:"&nbsp;",id:"menu",autoWidth:false,width:29,hideMode:"display",keepSelection:true,fixed:true,menuDisabled:false,actions:[{iconCls:"icon-customer-view",tooltip:"Load Customer"}]});this.columns=[this.action];if(a.callList){this.columns.push(b.CallTime);this.columns.push(b.LastOrderDate)}this.columns.push(b.CustNo);
this.columns.push(b.Company);this.columns.push(b.Address1);this.columns.push(b.City);if(!a.callList){this.columns.push(b.State);this.columns.push(b.Zip)}this.columns.push(b.Phone)}else{this.action=new Ext.ux.grid.RowActions({header:"&nbsp;",id:"menu",autoWidth:false,width:29,hideMode:"display",keepSelection:true,fixed:true,menuDisabled:false,actions:[{iconCls:"icon-customer-edit",tooltip:"Edit Customer"}]});this.columns=[this.action,b.CustNo,b.Username,b.Company,b.Address1,b.City,b.State,b.Zip,b.Phone]}b=
new Ext.PagingToolbar({store:this.store,pageSize:100,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});NECS.grid.SearchGrid.superclass.constructor.call(this,{id:"customer-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,autoHeight:false,titleCollapse:a.titleCollapse||false,header:a.header||false,border:a.border||false,loadMask:{msg:"Please wait. Loading ..."},sm:new Ext.grid.RowSelectionModel({singleSelect:false,moveEditorOnEnter:true}),bbar:b,viewConfig:{stripeRows:true,
forceFit:true,emptyText:this.callList?'<div align="center" style="color: #363636; font-weight: bold; !important">There are no customers on the call list for today.</div>':'<div align="center" style="color: #363636; font-weight: bold; !important">There are no customers that match the search criteria.</div>',deferEmptyText:true,scrollOffset:12},plugins:[this.action]});if(b.loading){b.loading.hideParent=true;b.loading.hide()}b.show();this.on("rowdblclick",function(c,d){this.fireEvent("load",this.store.getAt(d),
d)},this);this.action.on("action",function(c,d,e,f){if(e=="icon-customer-edit"||e=="icon-customer-view")this.fireEvent("load",d,f)},this)};Ext.extend(NECS.grid.CustomerGridPanel,NECS.grid.GridPanel);
NECS.form.SearchField=Ext.extend(Ext.form.TwinTriggerField,{initComponent:function(){NECS.form.SearchField.superclass.initComponent.call(this);this.on("specialkey",function(a,b){b.getKey()==b.ENTER&&this.onTrigger2Click()},this)},ctCls:"",validationEvent:false,validateOnBlur:false,trigger1Class:"x-form-clear-trigger",trigger2Class:"x-form-search-trigger",hideTrigger1:true,width:180,hasSearch:false,paramName:"query",setParam:function(a,b){this.store.baseParams=this.store.baseParams||{};this.store.baseParams[a]=
b},reset:function(){if(this.store){this.store.baseParams=this.store.baseParams||{};this.store.baseParams[this.paramName]=""}this.triggers[0].hide();this.hasSearch=false;this.setValue("")},onTrigger1Click:function(){if(this.hasSearch)if(this.store){this.el.dom.value="";this.store.baseParams=this.store.baseParams||{};this.store.baseParams[this.paramName]="";this.store.reload({params:{start:0}})}else this.fireEvent("clear",this);this.triggers[0].hide();this.hasSearch=false;this.setValue("");this.triggerBlur()},
onTrigger2Click:function(){var a=this.getRawValue().trim();if(a!=""){if(this.store){a=this.getRawValue();if(a.length<1){this.onTrigger1Click();return}this.store.baseParams=this.store.baseParams||{};this.store.baseParams[this.paramName]=a;this.store.reload({params:{start:0}})}else this.fireEvent("search",this,a);this.hasSearch=true;this.triggers[0].show();this.triggerBlur()}else if(this.hasSearch){this.onTrigger1Click();this.blur()}}});Ext.reg("necs-searchfield",NECS.form.SearchField);
NECS.form.Action.JsonRpcSubmit=Ext.extend(Ext.form.Action.Submit,{type:"JsonRpcSubmit",run:function(){var a=this.options,b=this.getMethod(),c=b=="POST";if(a.clientValidation===false||this.form.isValid())Ext.Ajax.request(Ext.apply(this.createCallback(),{url:this.getUrl(!c),method:b,params:c?this.getParams():null,isUpload:this.form.fileUpload}));else if(a.clientValidation!==false){this.failureType=Ext.form.Action.CLIENT_INVALID;this.form.afterAction(this,false)}},getParams:function(){if(!this.form.jsonData)this.form.jsonData=
{};Ext.util.JSON.encode(Ext.apply(this.form.jsonData,this.form.getValues(false)));this.form.request.setParams(Ext.apply({data:this.form.getValues(false)},NECS.form.Action.JsonRpcSubmit.superclass.getParams.apply(this,arguments)));return this.form.request.toJSON()},handleResponse:function(a){a=NECS.form.Action.JsonRpcSubmit.superclass.handleResponse.call(this,a);return a.result}});Ext.form.Action.ACTION_TYPES.JsonRpcSubmit=NECS.form.Action.JsonRpcSubmit;
NECS.form.JsonRpcForm=Ext.extend(Ext.form.BasicForm,{afterAction:function(a,b){if(a.type=="load")this.jsonData=a.result.data;if(a.type=="JsonRpcSubmit")b=a.result&&a.result.success;NECS.form.JsonRpcForm.superclass.afterAction.call(this,a,b)},submit:function(a){this.doAction("JsonRpcSubmit",a);return this}});NECS.form.JsonRpcFormPanel=Ext.extend(Ext.FormPanel,{createForm:function(){delete this.initialConfig.listeners;return new NECS.form.JsonRpcForm(null,this.initialConfig)}});
NECS.form.NumberTriggerField=Ext.extend(Ext.form.TriggerField,{fieldClass:"x-form-field x-form-num-field",allowDecimals:true,decimalSeparator:".",decimalPrecision:2,allowNegative:true,minValue:Number.NEGATIVE_INFINITY,maxValue:Number.MAX_VALUE,minText:"The minimum value for this field is {0}",maxText:"The maximum value for this field is {0}",nanText:"{0} is not a valid number",baseChars:"0123456789",initEvents:function(){var a=this.baseChars+"";if(this.allowDecimals)a+=this.decimalSeparator;if(this.allowNegative)a+=
"-";this.maskRe=new RegExp("["+Ext.escapeRe(a)+"]");Ext.form.NumberField.superclass.initEvents.call(this)},getErrors:function(a){var b=Ext.form.NumberField.superclass.getErrors.apply(this,arguments);a=a||this.processValue(this.getRawValue());if(a.length<1)return b;a=String(a).replace(this.decimalSeparator,".");isNaN(a)&&b.push(String.format(this.nanText,a));var c=this.parseValue(a);c<this.minValue&&b.push(String.format(this.minText,this.minValue));c>this.maxValue&&b.push(String.format(this.maxText,
this.maxValue));return b},getValue:function(){return this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)))},setValue:function(a){a=Ext.isNumber(a)?a:parseFloat(String(a).replace(this.decimalSeparator,"."));a=isNaN(a)?"":String(a).replace(".",this.decimalSeparator);a=parseFloat(a).toFixed(this.decimalPrecision);return Ext.form.NumberField.superclass.setValue.call(this,a)},setMinValue:function(a){this.minValue=Ext.num(a,Number.NEGATIVE_INFINITY)},setMaxValue:function(a){this.maxValue=
Ext.num(a,Number.MAX_VALUE)},parseValue:function(a){a=parseFloat(String(a).replace(this.decimalSeparator,"."));return isNaN(a)?"":a},fixPrecision:function(a){var b=isNaN(a);if(!this.allowDecimals||this.decimalPrecision==-1||b||!a)return b?"":a;return parseFloat(parseFloat(a).toFixed(this.decimalPrecision))},beforeBlur:function(){var a=this.parseValue(this.getRawValue());Ext.isEmpty(a)||this.setValue(this.fixPrecision(a))},onTriggerClick:function(){this.fireEvent("triggerclick")}});
var globalPriceInfoWin=null;NECS.form.PriceEditField=function(a){this.addEvents("pricechange");this.listeners=a.listeners;NECS.form.PriceEditField.superclass.constructor.call(this,a);this.initializeFields()};
Ext.extend(NECS.form.PriceEditField,Ext.util.Observable,{edPriceField:null,editRec:null,ownerCt:null,tmpPrice:null,initializeFields:function(){var a=new NECS.form.NumberTriggerField({triggerClass:"necs-price-lookup-trigger",listeners:{scope:this,specialkey:function(b,c){c.getKey()==c.TAB&&this.edPriceField.completeEdit()}}});a.on("triggerclick",function(){if(!globalPriceInfoWin){globalPriceInfoWin=new NECS.window.PriceInfoWindow;globalPriceInfoWin.on("hide",function(){this.edPriceField.startEdit(this.ownerCt,
this.tmpPrice);this.tmpPrice=null},this)}this.tmpPrice=this.edPriceField.getValue();this.edPriceField.cancelEdit();this.editRec.data.last_date?globalPriceInfoWin.showForItemRecord(this.editRec):globalPriceInfoWin.showForItem(this.editRec.data.item_no)},this);this.edPriceField=new Ext.grid.GridEditor(a,{id:"flt-prc-edit",cls:"necs-floating-editor",listeners:{scope:this,complete:function(b,c,d){if(c!=d)if(c<=0)NECS.util.DisplayError("Price must be greater than $0.00","Invalid Price",null,function(){if(isNaN(c)||
c.trim&&c.trim()=="")c=0;this.edPriceField.startEdit(this.ownerCt,c)},this);else{if(NECS.application.Options&&this.editRec.data.cost_base>c)if(NECS.application.Options.AllowBelowCost=="WARN")NECS.util.DisplayWarning("Unit Price of "+Ext.util.Format.usMoney(c)+" is below the item's base cost of "+Ext.util.Format.usMoney(this.editRec.data.cost_base),"Unit Price is below Base Cost");else if(NECS.application.Options.AllowBelowCost=="NO"){NECS.util.DisplayWarning("Unit Price of "+Ext.util.Format.usMoney(c)+
" is not allowed to be below the item's base cost of "+Ext.util.Format.usMoney(this.editRec.data.cost_base),"Unit Price is below Base Cost");return false}this.fireEvent("pricechange",this.editRec,c);this.editRec=null}}}})},startEdit:function(a,b,c,d){if(b&&(b.data.qty_ord>0||d)){this.editRec=b;this.ownerCt=a;if(d=Ext.fly("flt-prc-edit")){d.removeClass("necs-floating-editor");d.removeClass("necs-floating-editor-cart");d.addClass(c?"necs-floating-editor-cart":"necs-floating-editor")}else this.edPriceField.cls=
c?"necs-floating-editor-cart":"necs-floating-editor";this.edPriceField.startEdit(a,NECS.util.translatePrice(b))}},restartEdit:function(a){this.ownerCt&&this.edPriceField.startEdit(this.ownerCt,a)}});NECS.form.PctEditField=function(a){this.addEvents("pctchange");this.listeners=a.listeners;NECS.form.PctEditField.superclass.constructor.call(this,a);this.initializeFields()};
Ext.extend(NECS.form.PctEditField,Ext.util.Observable,{edPctField:null,editRec:null,ownerCt:null,tmpPct:null,initializeFields:function(){var a=new Ext.form.NumberField({listeners:{scope:this,specialkey:function(b,c){c.getKey()==c.TAB&&this.edPctField.completeEdit()}}});this.edPctField=new Ext.grid.GridEditor(a,{id:"flt-pct-edit",cls:"necs-floating-editor",listeners:{scope:this,complete:function(b,c,d){if(c!=d)if(c<0)NECS.util.DisplayError("Percentage must be greater than zero.","Invalid Percentage",
null,function(){if(isNaN(c)||c.trim&&c.trim()=="")c=0;this.edPctField.startEdit(this.ownerCt,c)},this);else if(c>=1E3)NECS.util.DisplayError("Percentage cannot exceed 999.99%","Invalid Percentage",null,function(){this.edPctField.startEdit(this.ownerCt,c)},this);else{this.fireEvent("change",this.editRec,c);this.editRec=null}}}})},startEdit:function(a,b,c,d){if(b&&(b.data.qty_ord>0||d)){this.editRec=b;this.ownerCt=a;this.edPctField.startEdit(a,b.data.markup_pct)}},restartEdit:function(a){this.ownerCt&&
this.edPctField.startEdit(this.ownerCt,a)}});
NECS.panel.CatalogClassPanel=function(a){Ext.apply(this,a);this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:NECS.application.RpcUri+"/catalog"}),new NECS.rpc.JSON.Request("getClassList",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"class",totalProperty:"totalResults"},NECS.data.records.Class)});this.customItemTemplate=NECS.application.Options.ShowClassImg?new Ext.XTemplate('<div id="catalog-item-container"><tpl for=".">','<div class="item">',
'<div class="image"><a href="{[this.getUrl(values["class"])]}">{[this.renderImgTag(values["image_file"])]}</a></div>','<div class="class-name"><a href="{[this.getUrl(values["class"])]}">{class} ({total_items})</a></div>',"</div>","</tpl></div>",{renderImgTag:function(b){if(b.trim()=="")return'<img src="'+NECS.application.CommonUri+'/images/no-image-large.png" alt="" border="0" />';return'<img src="'+NECS.application.ImgLargeUri+b+'" alt="" border="0" />'},getUrl:function(b){return NECS.application.BaseUri+
"customer/catalog/class/"+urlencode(b)}}):new Ext.XTemplate('<div id="catalog-item-container"><tpl for=".">','<a href="{[this.getUrl(values["class"])]}"><div class="item item-no-image">','<div class="class-name">{class} ({total_items})</div>',"</div></a>",'</tpl><div style="clear: both;"></div></div>',{getUrl:function(b){return NECS.application.BaseUri+"customer/catalog/class/"+urlencode(b)}});this.view=new Ext.DataView({store:this.store,id:"catalog-class-panel",tpl:this.customItemTemplate,itemSelector:"div.catalog-class-panel-item",
emptyText:'<div align="center" style="margin-top: 10px; font-weight: bold; color: #333333;">There are no classes defined that match the search criteria.</div>'});a=new Ext.PagingToolbar({store:this.store,pageSize:this.itemsPerPage,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:""});new Ext.LoadMask(this.renderTo,{msg:"Loading ...",store:this.storeGridPanel});NECS.panel.CatalogClassPanel.superclass.constructor.call(this,{id:"catalog-panel",collapsible:false,animCollapse:false,items:this.view,
autoScroll:true,height:300,border:false,autoWidth:true,bbar:a});a.insert(11,new Ext.Toolbar.Separator);a.insertButton(12,new Ext.Toolbar.TextItem({text:'<span style="color: red;">* Indicates average weight.</span>'}))};Ext.extend(NECS.panel.CatalogClassPanel,Ext.Panel);NECS.panel.ColumnSelectionPanel=function(a,b){this.app=b;Ext.apply(this,a);this.initialize(a.columnDefinition);NECS.panel.ColumnSelectionPanel.superclass.constructor.call(this)};
Ext.extend(NECS.panel.ColumnSelectionPanel,Ext.Component,{gridUnused:null,gridActive:null,paControls:null,btUp:null,btDown:null,btAdd:null,btRemove:null,render:function(){this.gridUnused.render(this.gridUnusedRenderTo);this.gridActive.render(this.gridActiveRenderTo);this.paControls.render(this.controlsRenderTo);this.initializeDragDrop()},initialize:function(a){var b;b=new Ext.data.JsonStore({fields:a.recordFields,data:a.getUnusedColRecords(),sortInfo:{field:"descr",dir:"ASC"}});this.gridUnused=new Ext.grid.GridPanel({ddGroup:"ddGroupActive",
ctCls:"necs-column-grid",store:b,columns:a.recordCols,width:300,height:200,sm:new Ext.grid.RowSelectionModel({singleSelect:false}),viewConfig:{forceFit:true,autoFill:true}});this.gridUnused.on("render",function(c){c.view.dragZone=new Ext.grid.GridDragZone(c,{ddGroup:"ddGroupActive",onInitDrag:function(){var d="";Ext.each(this.dragData.selections,function(e){d+='<div class="dd-custom-field">'+e.data.descr+"</div>"});this.ddel.innerHTML=d;this.proxy.update(this.ddel)}})});b=new Ext.data.JsonStore({fields:a.recordFields,
data:a.getActiveColRecords()});this.gridActive=new Ext.grid.GridPanel({ddGroup:"ddGroupUnused",ctCls:"necs-column-grid",store:b,columns:a.recordCols,width:300,height:200,sm:new Ext.grid.RowSelectionModel({singleSelect:false}),viewConfig:{autoFill:true,forceFit:true},plugins:[new Ext.ux.dd.GridDragDropRowOrder({copy:false,scrollable:true})]});this.gridActive.on("render",function(c){c.view.dragZone=new Ext.grid.GridDragZone(c,{ddGroup:"ddGroupUnused",onInitDrag:function(){var d="";Ext.each(this.dragData.selections,
function(e){d+='<div class="dd-custom-field">'+e.data.descr+"</div>"});this.ddel.innerHTML=d;this.proxy.update(this.ddel)}})});this.btUp=new Ext.Button({scope:this,iconCls:"icon-row-up",tooltip:"Move up",handler:function(){this.shiftColumnUp()}});this.btDown=new Ext.Button({scope:this,iconCls:"icon-row-down",tooltip:"Move down",handler:function(){this.shiftColumnDown()}});this.btAdd=new Ext.Button({scope:this,iconCls:"icon-row-add",tooltip:"Add selected Column",handler:function(){this.addSelectedColumns()}});
this.btRemove=new Ext.Button({scope:this,iconCls:"icon-row-remove",tooltip:"Remove selected Column",handler:function(){this.removeSelectedColumns()}});this.paControls=new Ext.Panel({region:"center",cls:"control-vert-panel",width:50,height:200,bodyStyle:"padding: 5px",border:false,items:[this.btUp,this.btDown,this.btAdd,this.btRemove]})},shiftColumnDown:function(){var a=this.gridActive.getSelectionModel(),b=this.gridActive.getStore();if(a.hasSelection()){var c=a.getSelected(),d=b.indexOf(c);if(d<b.getCount()-
1){b.remove(c);b.insert(++d,c);a.selectRow(d)}}},shiftColumnUp:function(){var a=this.gridActive.getSelectionModel(),b=this.gridActive.getStore();if(a.hasSelection()){var c=a.getSelected(),d=b.indexOf(c);if(d>0){b.remove(c);b.insert(--d,c);a.selectRow(d)}}},addSelectedColumns:function(){var a=this.gridUnused.getSelectionModel();if(a.hasSelection()){var b=a.getSelections();Ext.each(b,function(c){this.gridActive.store.add(c);this.gridUnused.store.remove(c)},this);a.selectRow(0);this.gridActive.getSelectionModel().selectRow(0)}},
removeSelectedColumns:function(){var a=this.gridActive.getSelectionModel();if(a.hasSelection()){var b=a.getSelections();Ext.each(b,function(c){this.gridUnused.store.add(c);this.gridActive.store.remove(c)},this);a.selectRow(0);this.gridUnused.store.sort("descr","ASC");this.gridUnused.getSelectionModel().selectRow(0)}},initializeDragDrop:function(){gridUnused=this.gridUnused;gridActive=this.gridActive;var a=this.gridActive.getView().el.dom.childNodes[0].childNodes[1];new Ext.dd.DropTarget(a,{ddGroup:"ddGroupActive",
copy:true,scope:this,notifyDrop:function(b,c){function d(j){if(gridActive.store.find("field",j.data.field)==-1){gridActive.store.insert(insertPosition++,j);b.grid.store.remove(j)}}var e=Ext.lib.Event.getTarget(c);e=gridActive.getView().findRowIndex(e);insertPosition=0;if(e){var f=gridActive.getView().getRow(e),h=(new Ext.Element(f)).getY()-gridActive.getView().scroller.dom.scrollTop;f=f.offsetHeight;insertPosition=c.getPageY()-h-f/2>0?e+1:e}Ext.each(b.dragData.selections,d);return true}});a=this.gridUnused.getView().el.dom.childNodes[0].childNodes[1];
new Ext.dd.DropTarget(a,{ddGroup:"ddGroupUnused",copy:true,scope:this,notifyDrop:function(b){function c(d){if(gridUnused.store.find("field",d.data.field)==-1){gridUnused.store.add(d);b.grid.store.remove(d)}}Ext.each(b.dragData.selections,c);gridUnused.store.sort("descr","ASC");return true}})},updateColumnDefinition:function(){var a=[];this.gridActive.store.each(function(b){a[a.length++]=b.data.field});this.columnDefinition.setActiveCols(a)},reloadColumnSettings:function(a){this.gridActive.store.removeAll();
this.gridUnused.store.removeAll();this.gridActive.store.loadData(a.getActiveColRecords());this.gridUnused.store.loadData(a.getUnusedColRecords());this.gridUnused.store.sort()}});Ext.namespace("Ext.ux.dd");
Ext.ux.dd.GridDragDropRowOrder=Ext.extend(Ext.util.Observable,{copy:false,scrollable:false,constructor:function(a){a&&Ext.apply(this,a);this.addEvents({beforerowmove:true,afterrowmove:true,beforerowcopy:true,afterrowcopy:true});Ext.ux.dd.GridDragDropRowOrder.superclass.constructor.call(this)},init:function(a){this.grid=a;a.enableDragDrop=true;a.on({render:{fn:this.onGridRender,scope:this,single:true}})},onGridRender:function(a){var b=this;this.target=new Ext.dd.DropTarget(a.getEl(),{ddGroup:a.ddGroup||
"GridDD",grid:a,gridDropTarget:this,notifyDrop:function(c,d,e){if(this.currentRowEl){this.currentRowEl.removeClass("grid-row-insert-below");this.currentRowEl.removeClass("grid-row-insert-above")}c=Ext.lib.Event.getTarget(d);c=this.grid.getView().findRowIndex(c);if(c===false||c==e.rowIndex)return false;if(this.gridDropTarget.fireEvent(b.copy?"beforerowcopy":"beforerowmove",this.gridDropTarget,e.rowIndex,c,e.selections,123)===false)return false;d=this.grid.getStore();var f=[],h=d.data.keys;for(var j in h)for(var g=
0;g<e.selections.length;g++)if(h[j]==e.selections[g].id){if(c==j)return false;f.push(e.selections[g])}c>e.rowIndex&&this.rowPosition<0&&c--;c<e.rowIndex&&this.rowPosition>0&&c++;if(c>e.rowIndex&&e.selections.length>1)c-=e.selections.length-1;if(c==e.rowIndex)return false;if(!b.copy)for(g=0;g<e.selections.length;g++)d.remove(d.getById(e.selections[g].id));for(g=f.length-1;g>=0;g--)d.insert(c,f[g]);(j=this.grid.getSelectionModel())&&j.selectRecords(e.selections);this.gridDropTarget.fireEvent(b.copy?
"afterrowcopy":"afterrowmove",this.gridDropTarget,e.rowIndex,c,e.selections);return true},notifyOver:function(c,d,e){c=Ext.lib.Event.getTarget(d);c=this.grid.getView().findRowIndex(c);var f=this.grid.getStore().data.keys;for(var h in f)for(var j=0;j<e.selections.length;j++)if(f[h]==e.selections[j].id)if(c==h){if(this.currentRowEl){this.currentRowEl.removeClass("grid-row-insert-below");this.currentRowEl.removeClass("grid-row-insert-above")}return this.dropNotAllowed}if(c<0||c===false){this.currentRowEl&&
this.currentRowEl.removeClass("grid-row-insert-above");return this.dropNotAllowed}try{var g=this.grid.getView().getRow(c),m=(new Ext.Element(g)).getY()-this.grid.getView().scroller.dom.scrollTop,k=g.offsetHeight;this.rowPosition=d.getPageY()-m-k/2;if(this.currentRowEl){this.currentRowEl.removeClass("grid-row-insert-below");this.currentRowEl.removeClass("grid-row-insert-above")}if(this.rowPosition>0){this.currentRowEl=new Ext.Element(g);this.currentRowEl.addClass("grid-row-insert-above")}else if(c-
1>=0){var l=this.grid.getView().getRow(c-1);this.currentRowEl=new Ext.Element(l);this.currentRowEl.addClass("grid-row-insert-below")}else this.currentRowEl.addClass("grid-row-insert-above")}catch(n){c=false}return c===false?this.dropNotAllowed:this.dropAllowed},notifyOut:function(){if(this.currentRowEl){this.currentRowEl.removeClass("grid-row-insert-above");this.currentRowEl.removeClass("grid-row-insert-below")}}});this.targetCfg&&Ext.apply(this.target,this.targetCfg);if(this.scrollable){Ext.dd.ScrollManager.register(a.getView().getEditorParent());
a.on({beforedestroy:this.onBeforeDestroy,scope:this,single:true})}},getTarget:function(){return this.target},getGrid:function(){return this.grid},getCopy:function(){return this.copy?true:false},setCopy:function(a){this.copy=a?true:false},onBeforeDestroy:function(a){Ext.dd.ScrollManager.unregister(a.getView().getEditorParent())}});NECS.panel.SearchPanel=function(a){Ext.apply(this,a);NECS.panel.SearchPanel.superclass.constructor.call(this,{ctCls:"necs-toolbar",listeners:{scope:this,render:function(){this.onRenderEvent()}}})};
Ext.extend(NECS.panel.SearchPanel,Ext.Toolbar,{edSearchMode:null,edSearchValue:null,laSearch:null,cbAll:null,btSearch:null,btClear:null,visCheckAll:true,visMode:true,onRenderEvent:function(){this.initializeControls()},initializeControls:function(){var a=[["SM_FULLTEXT","Item Descriptions"],["class","Class"]];NECS.application.Options&&NECS.application.Options.ShowBrand&&a.push(["brand","Brand"]);a.push(["upc","UPC Code"]);a.push(["item_no","Item Number"]);this.edSearchMode=new Ext.form.ComboBox({width:120,
ctCls:"xtb-calc",store:a,fieldLabel:"Search",typeAhead:false,selectOnFocus:true,forceSelection:true,editable:false,triggerAction:"all",value:"SM_FULLTEXT"});this.laSearch=new Ext.Toolbar.TextItem({text:"Search:"});this.edSearch=new NECS.form.SearchField({emptyText:"Enter search keywords",width:255});this.edSearch.on("clear",function(){this.fireEvent("clearsearch",this)},this);this.edSearch.on("search",function(b,c){this.fireEvent("executesearch",this,this.edSearchMode.getValue(),c,this.cbAll.getValue())},
this);this.cbAll=new Ext.form.Checkbox({boxLabel:"Search All Items",ctCls:"xtb-calc"});if(this.handler&&this.handler.beforetoolbarinit){a=this.handler.scope||this;this.handler.beforetoolbarinit.call(a,this)}this.fireEvent("beforetoolbarinit",this,this);this.add(this.laSearch);this.addField(this.edSearchMode);this.addField(this.edSearch);this.addField(this.cbAll);if(this.handler&&this.handler.aftertoolbarinit){a=this.handler.scope||this;this.handler.aftertoolbarinit.call(a,this)}this.fireEvent("aftertoolbarinit",
this,this)},adjustLayout:function(a){var b,c;b=0;var d=Ext.query(".xtb-calc");for(i=0;i<d.length;i++){c=Ext.get(d[i].id);b+=c.getWidth();b+=c.getPadding("lr")}this.items.each(function(e){if((c=Ext.fly(e.id))&&(c.hasClass("xtb-spacer")||c.hasClass("xtb-sep")||c.hasClass("xtb-text"))){b+=c.getWidth();b+=c.getPadding("lr")}});b+=16;Ext.isIE8||this.edSearch.setWidth(a-b)},clearSearch:function(){this.edSearch.reset()},setSearchClasses:function(){this.edSearchMode.setValue("Class");this.edSearchMode.setVisible(false);
this.visMode=false},showAllItemsField:function(){this.cbAll.setVisible(true);this.visCheckAll=true},hideAllItemsField:function(){this.cbAll.setVisible(false);this.visCheckAll=false},lockAllItemsField:function(a){this.cbAll.setValue(a);this.cbAll.disable()}});
NECS.grid.GuideEditGrid=function(a,b){this.app=b;this.gridColPrefId=4;Ext.apply(this,a);this.initializeDataStore();this.initializeColumnModel();a=new Ext.PagingToolbar({store:this.store,pageSize:100,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});NECS.grid.GuideEditGrid.superclass.constructor.call(this,{id:"order-guide-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,autoHeight:false,header:false,border:false,enableFlyout:false,clicksToEdit:"auto",loadMask:{msg:"Loading order guide ..."},
sm:new NECS.grid.RowSelectionModel({singleSelect:false,listeners:{rowselect:function(c,d){var e=document.getElementById("__sequence"+d);e&&setTimeout(function(){e.focus&&e.focus()},50);return false},rowdeselect:function(c,d){(c=document.getElementById("__sequence"+d))&&c.blur();return false}}}),bbar:a,view:new Ext.grid.GroupingView({groupTextTpl:"{text}",interceptMouse:Ext.emptyFn,enableGroupingMenu:false,hideGroupedColumn:true,enableNoGroups:true,forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There are no items currently in this order guide.</div>',
deferEmptyText:true,scrollOffset:12})});this.on("click",function(c){this.catListEl.isVisible&&this.catListEl.setVisible(false);if(c.getTarget(".clickable")){c=c.getTarget();var d=this.getView().findRowIndex(c),e=this.getStore().getAt(d);switch(c.className.split("-")[2]){case "remove":this.fireEvent("removeguideitem",this,d,e);break}}},this);this.view.on("rowupdated",function(c,d,e){this.bindCategoryListEvents(e.id)},this);this.view.on("refresh",function(){var c,d;for(i=0;i<this.store.getCount();i++){c=
this.store.getAt(i);this.bindCategoryListEvents(c.id);d=c.get("GuideCategory");if(d!=c.data.Class)if(this.catStore.indexOfId(d)==-1){c=new this.CategoryListRecord({GuideCategory:d});c.id=d;c.data.GuideCategory=d;this.catStore.add(c)}}},this);this.setCanConfigure(false);a.insert(11,new Ext.Toolbar.Separator);a.insertButton(12,new Ext.Toolbar.TextItem({text:'<span style="color: red;">* Indicates average weight.</span>'}));this.addEvents("removeguideitem")};
Ext.extend(NECS.grid.GuideEditGrid,NECS.grid.GridPanel,{catListEl:null,catListAnchor:"",catStore:null,CategoryListRecord:null,autoSort:false,initializeDataStore:function(){this.store=new Ext.data.GroupingStore({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcGuideUri,listeners:{scope:this,requestcomplete:function(a,b){this.fireEvent("loadrequestcomplete",a,Ext.util.JSON.decode(b.responseText))}}}),new NECS.rpc.JSON.Request("getCustomerGuide",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",
id:"ItemNo",totalProperty:"total"},NECS.data.records.OrderItem),sortInfo:{field:"Sequence",direction:"ASC"},remoteSort:false,groupField:"GuideCategory",baseParams:{id:null}});this.store.sort=this.store.sort.createInterceptor(function(){if(this.lastOptions&&this.lastOptions.params)this.lastOptions.params.start=0;this.groupField="";return true})},initializeColumnModel:function(){var a=NECS.grid.columns.item;a.Menu.renderer=function(b,c,d){return'<div class="clickable status-item-remove" id="__remove'+
d.data.item_no+'">'};for(col in a)col.sortable=false;a.ExtAmount.hidden=true;this.initializeCategoryList();a.CategorySelect={id:"category-edit",dataIndex:"",header:"Category",width:160,menuDisabled:true,hideable:false,fixed:true,sortable:false,renderer:function(b,c,d){b="__category-trigger"+d.id;c="__category-input"+d.id;(el=Ext.get(b))&&el.removeAllListeners();(el=Ext.get(c))&&el.removeAllListeners();d='<div id="__category-field'+d.id+'" class="necs-category-field x-form-field-wrap"><div id="'+c+
'" class="necs-category-input x-form-field x-form-text x-form-focus">'+d.data.GuideCategory+"</div>";fix=Ext.isIE?"position: relative; top: -2px;":Ext.isWebKit?"height: 21px;":"";d+='<img style="'+fix+'" id="'+b+'" + src="/include/extjs/images/default/s.gif" class="necs-trigger-hack x-form-trigger x-form-trigger-over"></div></div>';return d}};this.columns=[a.Menu,a.SequenceEdit,a.CategorySelect,a.GuideCategory,a.ItemNo,a.Descrip,a.Class,a.Brand,a.Size,a.UnitMS,a.Weight];a.CategorySelect.draggable=
false},bindCategoryListEvents:function(a){var b;b="__category-trigger"+a;a="__category-input"+a;if(el=Ext.get(b)){el.removeAllListeners();el.addClassOnClick("x-form-trigger-click");el.on("click",this.showCategoryList,this)}if(el=Ext.get(a)){el.removeAllListeners();el.on("click",this.showCategoryList,this)}},clearCategoryListEvents:function(){var a,b;a="__category-trigger"+rec.id;b="__category-input"+rec.id;(el=Ext.get(a))&&el.removeAllListeners();(el=Ext.get(b))&&el.removeAllListeners()},initializeCategoryList:function(){var a;
this.catListEl=Ext.get(document.body).createChild();this.catListEl.addClass("necs-category-list-float");this.catListEl.setVisible(false);this.CategoryListRecord=new Ext.data.Record.create(NECS.data.fields.GuideCategoryList);this.catStore=new Ext.data.Store({reader:new Ext.data.ArrayReader({id:"GuideCategory"},this.CategoryListRecord)});this.addNewCategory("[USE ITEM CLASS]");a=new Ext.XTemplate('<tpl for=".">','<div class="item x-combo-list-item x-combo-noedit">',"{GuideCategory}","</div>","</tpl>");
(new Ext.DataView({id:"category-list",store:this.catStore,layout:"fit",tpl:a,itemSelector:"div.item",emptyText:"DEFAULT",listeners:{scope:this,click:function(b,c){b=b.store.getAt(c);c=b.get("GuideCategory");b=this.getSelectionModel().getSelected();c=="[USE ITEM CLASS]"?b.set("GuideCategory",b.get("Class")):b.set("GuideCategory",c);this.catListEl.setVisible(false);this.autoSort&&this.resort()}}})).render(this.catListEl)},showCategoryList:function(a){var b,c;c=a.getTarget();if(c.id){b=c.id.split("__category-trigger")[1];
b=Ext.get("__category-field"+b);if(!b){b=c.id.split("__category-input")[1];b=Ext.get("__category-field"+b)}}if(b)if(this.catListEl.isVisible()&&this.catListAnchor==b.dom.id)this.catListEl.setVisible(false);else{this.catListAnchor=b.dom.id;listHeight=Math.min(21*this.catStore.getCount(),210)+2;this.catListEl.setHeight(listHeight);c=Ext.lib.Dom.getViewportHeight();listY=b.getTop();listY+=b.getHeight();listY+=b.getBorderWidth("tb");if(listY+listHeight>c)if(Ext.isIE){this.catListEl.setTop(b.getTop()-
listHeight-3);this.catListEl.setLeft(b.getLeft()-2)}else{this.catListEl.setTop(b.getTop()-listHeight+1);this.catListEl.setLeft(b.getLeft())}else if(Ext.isIE7){this.catListEl.setTop(listY-3);this.catListEl.setLeft(b.getLeft()-2)}else{this.catListEl.setTop(listY);this.catListEl.setLeft(b.getLeft())}this.catListEl.setWidth(b.getWidth()-b.getBorderWidth("lr"));this.catListEl.setVisible(true);a.stopEvent()}},addNewCategory:function(a){a=a.toUpperCase();if(a.trim()!="")if(this.catStore.indexOfId(a)==-1){listRec=
new this.CategoryListRecord({GuideCategory:a});listRec.id=a;listRec.data.GuideCategory=a;this.catStore.add(listRec);return true}else NECS.util.DisplayError('The category "'+a+'" is already in use.');else NECS.util.DisplayInfo("Please enter a category name");return false},resort:function(){var a;a=this.getSelectionModel().getSelected();this.getSelectionModel().clearSelections();this.store.sortByFields([{field:"GuideCategory",direction:"ASC"},{field:"Sequence",direction:"ASC"}]);a=this.store.indexOf(a);
this.getSelectionModel().selectRow(a)},load:function(a){this.store.baseParams.id=a;this.store.load()},remoteItem:function(a){alert(a)}});
NECS.grid.QuickEntryGrid=function(a,b){this.app=b;this.columnConfigPrefId=NECS.pref.COLS_QUICK;Ext.apply(this,a);a=[{name:"ItemNo",inputIdPrefix:"__editorItemNo"},{name:"QtyOrd",inputIdPrefix:"__editorQtyOrd"}];NECS.application.Options.ShowSpcInst&&a.push({name:"SpcInst",inputIdPrefix:"__editorSpcInst"});this.editors=new NECS.grid.Editors({items:a});this.store=new Ext.data.Store({proxy:new Ext.data.MemoryProxy({}),reader:new Ext.data.ArrayReader({id:"item_no"},NECS.data.records.OrderItem)});this.store.on("load",
function(){this.addEntryRecord()},this);this.initializeColumnModel();a=new Ext.PagingToolbar({store:this.store,pageSize:100,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});NECS.grid.QuickEntryGrid.superclass.constructor.call(this,{id:"order-guide-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,autoHeight:false,header:false,border:false,loadMask:{msg:"Loading order guide ..."},sm:new NECS.grid.RowSelectionModel({singleSelect:false,preventGridViewFocus:true,
listeners:{scope:this,rowselect:function(c,d,e){this.activeRec=e;return false}}}),bbar:a,deferRowRender:false,viewConfig:{interceptMouse:Ext.emptyFn,enableGroupingMenu:false,hideGroupedColumn:true,enableNoGroups:true,forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There are no items available to order.</div>',deferEmptyText:true,scrollOffset:12,getRowClass:function(c){if(NECS.application.Salesperson){c=c.data.dot_type||"";if(c=="S")return"gr-dot-special";
if(c=="D")return"gr-dot-drop"}return""}}});this.on("columnresize",function(c,d){if(NECS.application.Options.ShowSpcInst){destIdx=this.getColumnModel().getIndexById("description1");if(c==destIdx){var e;for(c=0;c<this.store.getCount();c++){e=this.store.getAt(c);(e=Ext.fly("__editorSpcInst-"+e.id))&&e.setWidth(d-15)}}}},this);this.setCanConfigure(this.app.Options.ConfigGridQuick)};
Ext.extend(NECS.grid.QuickEntryGrid,NECS.grid.GridPanel,{initializeColumnModel:function(){columnInfo=NECS.grid.getDefaultColumns(NECS.grid.ID_QUICK,this.app,true);this.columns=columnInfo.active;cols=columnInfo.available;this.editors.on("editoradvancerow",function(){this.getSelectionModel().hasNext()||this.addEntryRecord()},this)},addItem:function(a){if(a.trim()!="")if(!this.hasItem(a)){this.disable();var b=new NECS.rpc.JSON.Request("getItemInfo",[a,true],1,function(c){if(c.error||!c.result)alert("CancelOrder: Server Communication Error.");
else if(c.result.success){this.enable();this.updateEntryRecord(c.result.data)}else{this.enable();this.invalidateEntryRecord(a)}},this);NECS.rpc.JSON.call(NECS.application.RpcOrderUri,b)}},hasItem:function(a){a=a.toUpperCase();if(this.store.indexOfId(a)!=-1){this.invalidateEntryRecord(a,"*** ITEM PREVIOUSLY ENTERED ***");return true}return false},addEntryRecord:function(){var a;a=new NECS.data.records.OrderItem({});for(field in NECS.data.fields.OrderItem)a.set(NECS.data.fields.OrderItem[field].name,
"");this.getSelectionModel().clearSelections();a.id=this.store.getCount();a.set("tag","INVALID");this.store.add(a);this.activeRec=a;this.getSelectionModel().selectLastRow();var b=this.editors.getFirst(a.id);b&&setTimeout(function(){b.focus()},50)},updateEntryRecord:function(a){var b,c;b=this.activeRec.copy();c=this.store.indexOf(this.activeRec);for(field in a)b.set(field,a[field]);a=a.item_no.trim();b.id=a.toUpperCase();b.set("tag","VALID");this.store.remove(this.activeRec);this.store.insert(c,b);
this.activeRec=b;this.getSelectionModel().selectRow(c);this.createFlyout(c,b);if(NECS.application.Options.ShowSpcInst)if(destIdx=this.getColumnModel().getIndexById("description1")){newSize=this.getColumnModel().getColumnWidth(destIdx);if(d=Ext.fly("__editorSpcInst-"+b.id)){d.setWidth(newSize-15);d.addClassOnFocus("x-form-focus")}}var d=this.editors.get("QtyOrd",b.id);d.dom.disabled=false;d&&setTimeout(function(){d.focus()},50)},invalidateEntryRecord:function(a,b){for(field in NECS.data.fields.OrderItem)this.activeRec.set(NECS.data.fields.OrderItem[field].name,
"");this.activeRec.set("item_no",a);this.activeRec.set("tag","INVALID");b?this.activeRec.set("description1",b):this.activeRec.set("description1","*** ITEM NOT FOUND ***");a=this.editors.getFirst(this.activeRec.id);a.dom.disabled=false;a&&a.focus()},advanceEditor:function(a){if(destEl=this.editors.getNext(a,function(b,c){if(c.name=="QtyOrd"&&this.activeRec.get("tag")=="INVALID"){this.addItem(this.editors.getValue("ItemNo",b.recordId));return false}if(c.name=="SpcInst"&&this.editors.getValue("QtyOrd",
b.recordId)==0){this.editors.fireEvent("editoradvancerow");return false}return true},this)){this.activeEditor=destEl;destEl.dom.readOnly=false;destEl.dom.disabled=false;destEl.focus();return false}return true},rewindEditor:function(a){if(destEl=this.editors.getPrevious(a,function(b,c){if(c.name=="ItemNo"&&this.activeRec.get("tag")=="VALID")return false;if(c.name=="SpcInst"&&this.editors.getValue("QtyORd",b.recordId)==0)return false;return true},this)){this.activeEditor=destEl;destEl.focus();return false}return true},
selectionChanged:function(a,b){if(destEl=b?a.data.tag!="VALID"?this.editors.getFirst(a.id):this.editors.get("QtyOrd",a.id):this.editors.getLast(a.id,function(c,d){if(d.name=="SpcInst"&&this.editors.getValue("QtyOrd",c)==0)return false;return true},this)){this.activeEditor=destEl;destEl.focus()}},refocusEditor:function(){if(this.activeEditor){this.activeEditor.dom.focus();this.activeRec=this.store.getById(this.activeEditor.id.split("-")[1])}}});Ext.namespace("NECS.panel");
NECS.panel.RecentOrdersPanel=function(a,b){this.app=b;Ext.apply(this,a);this.nextDeliveryDate=this.nextDeliveryDate?this.nextDeliveryDate:this.app.Customer.NextDeliveryDate;this.noRouteDays=this.noRouteDays?this.noRouteDays:[];this.maxOrderDate=this.app.Options&&this.app.Options.MaxOrderDays?new Date.parseDate(this.app.Customer.MaxOrderDate,"Y-m-d"):null;this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcOrderUri}),new NECS.rpc.JSON.Request("getOnlineOrders",
[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"order_id"},NECS.data.records.OrderHeader),sortInfo:{field:"created",direction:"DESC"},remoteSort:true});this.action=new Ext.ux.grid.RowActions({header:"&nbsp;",id:"action",autoWidth:false,width:44,hideMode:"display",keepSelection:true,fixed:true,actions:[{iconIndex:"RowActionImageClass",iconCls:"",tooltip:"Edit/View Order"}]});this.app.Options.ShowInvoiceScans&&this.action.actions.push({hideIndex:"NoScan",iconCls:"icon-pdf",tooltip:"View Scanned Invoice"});
cols=NECS.grid.columns.order;this.columns=[this.action,cols.Status,cols.DeliveryDate];this.app.Options.ShowPrices&&this.columns.push(cols.EstTotal);this.columns.push(cols.OrderNo,cols.InvoiceNo,cols.PurchNo,cols.SalesNo,cols.Created);NECS.panel.RecentOrdersPanel.superclass.constructor.call(this,{id:"recent-order-panel",ctCls:"necs-grid",stripeRows:true,height:350,title:"Orders",loadMask:{msg:"Loading order history ...."},sm:new Ext.grid.RowSelectionModel({singleSelect:true}),tbar:new Ext.Toolbar({ctCls:"necs-toolbar",
align:"center",items:[{xtype:"label",html:NECS.application.Options.CanChgDlvDate?"&nbsp;&nbsp;Start a new order with a requested delivery date of &nbsp;":""},{xtype:"datefield",id:"edDeliveryDate",name:"edDeliveryDate",width:110,allowBlank:false,editable:false,cls:"disabled-input",minValue:this.nextDeliveryDate.clearTime(),maxValue:this.maxOrderDate,value:this.nextDeliveryDate.clearTime(),disabledDays:this.noRouteDays,hidden:!NECS.application.Options.CanChgDlvDate,disabled:NECS.util.enforceCreditHold()},
{xtype:"tbspacer"},{xtype:"button",name:"btCreateOrder",text:"Create New Order",scope:this,handler:function(c){c.disable();this.createNewOrder()},disabled:NECS.util.enforceCreditHold()},{xtype:"tbfill"}]}),bbar:new Ext.PagingToolbar({store:this.store,pageSize:this.app.ResultsPerPage,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"}),viewConfig:{forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There are no online orders in the system.</div>',
deferEmptyText:false,getRowClass:function(c){if(!c.data.completed)return"row-order-open";return c.data.sales_no!==""?"row-salesperson":"row-customer"}},plugins:[this.action]});this.on("rowdblclick",function(c,d){c=this.store.getAt(d);if(c.data.NoCancel)this.fireEvent("view",c,d);else{if(NECS.util.enforceCreditHold()){Ext.Msg.show({title:"Account On Credit Hold",msg:NECS.application.Salesperson?"Orders cannot be edited since this customer account has been placed on credit hold.":"Orders cannot be edited since your account has been placed on credit hold.",
minWidth:200,modal:true,icon:Ext.Msg.WARNING,buttons:Ext.Msg.OK});return false}this.fireEvent("edit",c,d)}},this);this.action.on("action",function(c,d,e,f){if(e=="icon-order-view")this.fireEvent("view",d,f);else if(e=="icon-order-edit"){if(NECS.util.enforceCreditHold()){Ext.Msg.show({title:"Account On Credit Hold",msg:NECS.application.Salesperson?"Orders cannot be edited since this customer account has been placed on credit hold.":"Orders cannot be edited since your account has been placed on credit hold.",
minWidth:200,modal:true,icon:Ext.Msg.WARNING,buttons:Ext.Msg.OK});return false}this.fireEvent("edit",d,f)}else if(e=="icon-order-delete")this.fireEvent("delete",d,f);else e=="icon-pdf"&&this.fireEvent("viewscan",d,f)},this)};
Ext.extend(NECS.panel.RecentOrdersPanel,NECS.grid.GridPanel,{createNewOrder:function(){if(!NECS.util.enforceCreditHold()){var a={OrderId:null,SalesNo:null,OrderNo:"",CustNo:"",Total:0,DeliveryDate:null,PurchNo:"",Comments:"",ForceNewOrder:true};a.CustNo=NECS.application.Customer.CustNo;if(NECS.application.Salesperson)a.SalesNo=NECS.application.Salesperson.SalesNo;a.DeliveryDate=Ext.get("edDeliveryDate").getValue();a=new NECS.rpc.JSON.Request("updateOrderHeader",[a],1,function(b){if(b.error||!b.result)NECS.util.DisplayError("An error occured while attempting to communicate with the server.",
"Order Creation Failed");else if(b.result.success&&b.result.header)window.location=NECS.application.BaseUri+"customer/order";else NECS.util.DisplayError("An error occured while attempting to create a new order.","Order Creation Failed")},this);NECS.rpc.JSON.call(NECS.application.RpcOrderUri,a)}},load:function(){this.store.load({params:{start:0,limit:this.app.ResultsPerPage,sort:"created",dir:"DESC"}})}});Ext.namespace("NECS.panel");
NECS.panel.AccountInquiryPanel=function(a,b){this.app=b;Ext.apply(this,a);this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcCustomerUri}),new NECS.rpc.JSON.Request("getCustomerAR",[],1,function(c){this.setTitle("Account Overview - Open Balance: "+Ext.util.Format.usMoney(c.result.balance))},this)),reader:new NECS.data.JsonRpcReader({root:"data",id:"invoice_no"},NECS.data.records.PaymentHistory),remoteSort:true,sortInfo:{field:"invoice_date",direction:"ASC"}});
this.store.on("load",function(){},this);this.store.sort=this.store.sort.createInterceptor(function(){if(this.lastOptions.params)this.lastOptions.params.start=0;return true});columnInfo=NECS.grid.getDefaultColumns(NECS.grid.ID_AR_HISTORY,this.app);this.columns=columnInfo.active;NECS.panel.AccountInquiryPanel.superclass.constructor.call(this,{id:"payment-history-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,autoHeight:false,height:200,collapsible:true,titleCollapse:true,collapsed:true,loadMask:{msg:"Please wait. Loading ..."},
sm:new Ext.grid.RowSelectionModel({singleSelect:false,moveEditorOnEnter:true}),viewConfig:{forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There is no payment history data available at this time.</div>',deferEmptyText:true,scrollOffset:12}})};Ext.extend(NECS.panel.AccountInquiryPanel,Ext.grid.GridPanel);
NECS.grid.LocationListGrid=function(a,b){this.app=b;Ext.apply(this,a);this.initializeStore();a=new Ext.grid.CheckboxSelectionModel;NECS.grid.LocationListGrid.superclass.constructor.call(this,{loadMask:true,cls:"necs-grid",view:new Ext.grid.GridView({forceFit:true}),sm:a,cm:new Ext.grid.ColumnModel([a,NECS.grid.columns.customer.CustNo,NECS.grid.columns.customer.Company])});NECS.grid.columns.customer.Menu.menuDisabled=true;this.hookEvents()};
Ext.extend(NECS.grid.LocationListGrid,Ext.grid.GridPanel,{loaded:false,initializeStore:function(){this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcCustomerUri}),new NECS.rpc.JSON.Request("getCustomerBillToLocations",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"cust_no",totalProperty:"total"},NECS.data.records.CustomerLocations),sortInfo:{field:"cust_no",direction:"ASC"},remoteSort:true})},hookEvents:function(){},load:function(a){if(!this.loaded||
a){this.loaded=true;this.store.load({params:{start:0,limit:50,CustNo:this.app.Customer.CustNo,sort:"cust_no",dir:"ASC",query:null}})}}});NECS.grid.PropertyRecord=Ext.data.Record.create([{name:"system_option_id",type:"int",sortType:"asInt"},{name:"title",type:"string"},{name:"data_type",type:"string"},{name:"category",type:"string"},{name:"description",type:"string"},{name:"sequence",type:"int",sortType:"asInt"},"value"]);
NECS.grid.PropertyStore=function(a,b,c){this.grid=a;a=c=="account"?new NECS.rpc.JSON.Request("getAccountOptions",[],1):new NECS.rpc.JSON.Request("getOptionDefaults",[],1);this.store=new Ext.data.GroupingStore({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:NECS.application.RpcUtilityUri}),a),reader:new NECS.data.JsonRpcReader({root:"data",id:"system_option_id"},NECS.grid.PropertyRecord),groupField:"category"});this.store.on("update",this.onUpdate,this);b&&this.setSource(b);NECS.grid.PropertyStore.superclass.constructor.call(this)};
Ext.extend(NECS.grid.PropertyStore,Ext.util.Observable,{setSource:function(a){this.source=a;this.store.removeAll();var b=[];for(var c in a)this.isEditableValue(a[c])&&b.push(new NECS.grid.PropertyRecord({name:c,value:a[c]},c));this.store.loadRecords({records:b},{},true)},onUpdate:function(a,b,c){if(c==Ext.data.Record.EDIT){a=b.data.value;c=b.modified.value;if(this.grid.fireEvent("beforepropertychange",this.source,b.id,a,c)!==false){b.commit();this.grid.fireEvent("propertychange",this.source,b.id,
a,c,b)}else b.reject()}},getProperty:function(a){return this.store.getAt(a)},isEditableValue:function(a){if(Ext.isDate(a))return true;else if(typeof a=="object"||typeof a=="function")return false;return true},setValue:function(a,b){this.source[a]=b;this.store.getById(a).set("value",b)},getSource:function(){return this.source},load:function(a){this.store.load(a)}});
NECS.grid.PropertyColumnModel=function(a,b){this.grid=a;a=Ext.grid;a.PropertyColumnModel.superclass.constructor.call(this,[{header:"Option Description",width:80,sortable:false,dataIndex:"title",id:"Title",menuDisabled:true},{header:"Current Setting",width:30,resizable:false,dataIndex:"value",id:"Value",menuDisabled:true},{header:"",width:75,dataIndex:"nothing",resizable:false,menuDisabled:true},{header:"Category",width:50,hidden:true,sortable:false,dataIndex:"category",id:"Category",menuDisabled:true}]);
this.store=b;b=Ext.form;var c=new Ext.data.SimpleStore({fields:["value","display"],data:[[true,"Yes"],[false,"No"]]});c=new Ext.form.ComboBox({allowBlank:false,store:c,typeAhead:true,displayField:"display",valueField:"value",mode:"local",triggerAction:"all",selectOnFocus:true,forceSelection:true,editable:false,listeners:{scope:this,select:function(){this.grid.getSelectionModel().clearSelections();this.grid.stopEditing()}}});var d=new Ext.form.ComboBox({store:{proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:NECS.application.RpcUri+
"/salesperson"}),new NECS.rpc.JSON.Request("getEnabledSalespeople",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"sales_no"},new Ext.data.Record.create([{name:"sales_no",type:"string"},{name:"name",type:"string"}])),listeners:{scope:this,load:function(h){var j=new new Ext.data.Record.create([{name:"sales_no",type:"string"},{name:"name",type:"string"}]);j.data.sales_no="";j.data.name="Leave Unassigned";h.insert(0,j)}}},typeAhead:true,lazyInit:true,selectOnFocus:true,triggerAction:"all",
editable:false,valueField:"sales_no",displayField:"sales_no",tpl:'<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold;">{sales_no}</span> {name}</div></tpl>',listeners:{scope:this,select:function(){this.grid.getSelectionModel().clearSelections();this.grid.stopEditing()}}}),e=new Ext.form.ComboBox({allowBlank:false,store:new Ext.data.SimpleStore({fields:["value","display"],data:[[0,"None"],[1,"Class"]]}),typeAhead:true,displayField:"display",valueField:"value",mode:"local",triggerAction:"all",
selectOnFocus:true,forceSelection:true,editable:false,listeners:{scope:this,select:function(){this.grid.getSelectionModel().clearSelections();this.grid.stopEditing()}}}),f=new Ext.form.ComboBox({allowBlank:false,store:new Ext.data.SimpleStore({fields:["value","display"],data:[["item_no","Item #"],["description1","Description"],["brand","Brand"],["class","Class"],["unit","Unit MS."]]}),typeAhead:true,displayField:"display",valueField:"value",mode:"local",triggerAction:"all",selectOnFocus:true,forceSelection:true,
editable:false,listeners:{scope:this,select:function(){this.grid.getSelectionModel().clearSelections();this.grid.stopEditing()}}});yesNoWarn=new Ext.form.ComboBox({allowBlank:false,store:new Ext.data.SimpleStore({fields:["value","display"],data:[["YES","Yes"],["WARN","Display Warning"],["NO","No"]]}),typeAhead:true,displayField:"display",valueField:"value",mode:"local",triggerAction:"all",selectOnFocus:true,forceSelection:true,editable:false,listeners:{scope:this,select:function(){this.grid.getSelectionModel().clearSelections();
this.grid.stopEditing()}}});this.editors={time:new a.GridEditor(new b.TimeField({selectOnFocus:true,listeners:{scope:this,select:function(){this.grid.stopEditing()}}})),date:new a.GridEditor(new b.DateField({selectOnFocus:true})),string:new a.GridEditor(new b.TextField({selectOnFocus:true})),number:new a.GridEditor(new b.NumberField({selectOnFocus:true,style:"text-align:left;"})),currency:new a.GridEditor(new b.NumberField({selectOnFocus:true,style:"text-align:left;",allowNegative:false,decimalPrecision:2})),
"boolean":new a.GridEditor(c),salesno:new a.GridEditor(d),groupmode:new a.GridEditor(e),websortcol:new a.GridEditor(f),yesnowarn:new a.GridEditor(yesNoWarn)};this.renderCellDelegate=this.renderCell.createDelegate(this);this.renderPropDelegate=this.renderProp.createDelegate(this)};
Ext.extend(NECS.grid.PropertyColumnModel,Ext.grid.ColumnModel,{nameText:"Name",valueText:"Value",dateFormat:"m/j/Y",curType:null,renderDate:function(a){return a.dateFormat(this.dateFormat)},renderBool:function(a){return a?"Yes":"No"},isCellEditable:function(a){return a==1},getRenderer:function(a){return a==1?this.renderCellDelegate:this.renderPropDelegate},renderProp:function(a){return this.getPropertyName(a)},renderCell:function(a,b,c){b=a;switch(c.data.data_type){case "D":b=this.renderDate(a);break;
case "B":b=this.renderBool(a);break;case "C":b=Ext.util.Format.usMoney(a);break}if(c.data.system_option_id==36)switch(a){case 0:b="None";break;case 1:b="Class";break}if(c.data.system_option_id==40){b=this.editors.websortcol.field.store.find("value",a);if(b!=-1){r=this.editors.websortcol.field.store.getAt(b);b=r.data.display}else b=""}if(c.data.system_option_id==38){b=this.editors.yesnowarn.field.store.find("value",a);if(b!=-1){r=this.editors.yesnowarn.field.store.getAt(b);b=r.data.display}else b=
""}return Ext.util.Format.htmlEncode(b)},getPropertyName:function(a){var b=this.grid.propertyNames;return b&&b[a]?b[a]:a},getCellEditor:function(a,b){a=this.store.getProperty(b);b=a.data.data_type;if(b=="S"&&a.data.system_option_id==34)return this.editors.salesno;if(a.data.system_option_id==36)return this.editors.groupmode;if(a.data.system_option_id==40)return this.editors.websortcol;if(a.data.system_option_id==38)return this.editors.yesnowarn;switch(b){case "B":return this.editors["boolean"];case "I":return this.editors.number;
case "T":return this.editors.time;case "C":return this.editors.currency;default:return this.editors.string}}});
NECS.grid.PropertyGrid=Ext.extend(Ext.grid.EditorGridPanel,{enableColumnMove:false,stripeRows:false,trackMouseOver:false,clicksToEdit:1,enableHdMenu:false,loadMask:{msg:"Loading ..."},mode:"global",initComponent:function(){this.customEditors=this.customEditors||{};this.lastEditRow=null;mode=this.mode||"global";this.propStore=store=new NECS.grid.PropertyStore(this,null,mode);var a=new NECS.grid.PropertyColumnModel(this,store);store.store.sort("sequence","ASC");this.addEvents("beforepropertychange",
"propertychange");this.cm=a;this.ds=store.store;NECS.grid.PropertyGrid.superclass.initComponent.call(this);this.selModel.on("beforecellselect",function(b,c,d){if(d===0){this.startEditing.defer(200,this,[c,1]);return false}return true},this)},onRender:function(){NECS.grid.PropertyGrid.superclass.onRender.apply(this,arguments);this.getGridEl().addClass("x-props-grid")},afterRender:function(){NECS.grid.PropertyGrid.superclass.afterRender.apply(this,arguments);this.source&&this.setSource(this.source)},
setSource:function(a){this.propStore.setSource(a)},getSource:function(){return this.propStore.getSource()},load:function(a){this.propStore.load(a)}});Ext.reg("propertygrid",NECS.grid.PropertyGrid);var globalLoadMask=null;NECS.grid.ColumnConfigGrid=function(a,b){this.app=b;this.store=new Ext.data.SimpleStore({fields:["Blank"]});this.columns=[NECS.grid.columns.dummy.Blank];a.ctCls="necs-grid-configurable";NECS.grid.ColumnConfigGrid.superclass.constructor.call(this,a)};
Ext.extend(NECS.grid.ColumnConfigGrid,NECS.grid.GridPanel,{loadMask:null,setColumnsForGrid:function(a,b){var c;globalLoadMask=new Ext.LoadMask(Ext.getBody(),{msg:"Loading column configuration .."});globalLoadMask.show();if(b){c="getPreferenceByAccount";b=[b,a]}else{c="getPreferenceDefault";b=[a]}c=new NECS.rpc.JSON.Request(c,b,1,function(d){if(d.error||!d.result)alert("CancelOrder: Server Communication Error.");else{if(d.result.success){var e;e=NECS.grid.getDefaultColumns(a,this.app,true);this.getColumnModel().setConfig(e.active);
this.reconfigure(this.store,this.getColumnModel());(d=d.result.data)&&this.setColumnConfig(Ext.util.JSON.decode(d.value))}else NECS.util.DisplayError(d.result.message,"Error loading grid defaults.");globalLoadMask.hide();delete globalLoadMask}},this);NECS.rpc.JSON.call(NECS.application.RpcUtilityUri,c)}});
NECS.grid.SalespersonGrid=function(a,b){this.app=b;Ext.apply(this,a);this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcSalespersonUri}),new NECS.rpc.JSON.Request("getSalespeople",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",totalProperty:"totalResults",id:"SalesNo"},NECS.data.records.Salesperson),remoteSort:true});this.store.sort=this.store.sort.createInterceptor(function(){if(this.lastOptions.params)this.lastOptions.params.start=0;
return true});this.action=new Ext.ux.grid.RowActions({header:"&nbsp;",id:"menu",autoWidth:false,width:29,hideMode:"display",keepSelection:true,menuDisabled:false,fixed:true,actions:[{iconCls:"icon-salesperson-edit",tooltip:"Edit Salesperson"}]});a=NECS.grid.columns.salesperson;this.columns=[this.action,a.SalesNo,a.Username,a.Name,a.Address,a.City,a.State,a.Zip,a.Phone,a.Fax];a=new Ext.PagingToolbar({store:this.store,pageSize:100,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});
NECS.grid.SearchGrid.superclass.constructor.call(this,{id:"salesperson-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,autoHeight:false,header:false,border:false,loadMask:{msg:"Please wait. Loading ..."},sm:new Ext.grid.RowSelectionModel({singleSelect:false,moveEditorOnEnter:true}),bbar:a,viewConfig:{stripeRows:true,forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There are no salespeople that match the search criteria.</div>',deferEmptyText:true,
scrollOffset:12},plugins:[this.action]});if(a.loading){a.loading.hideParent=true;a.loading.hide()}a.show();this.on("rowdblclick",function(c,d){this.fireEvent("load",this.store.getAt(d),d)},this);this.action.on("action",function(c,d,e,f){e=="icon-salesperson-edit"&&this.fireEvent("load",d,f)},this)};Ext.extend(NECS.grid.SalespersonGrid,NECS.grid.GridPanel);
NECS.grid.ClassSearchGrid=function(a,b){this.app=b;Ext.apply(this,a);this.initializeStore();tbPager=new Ext.PagingToolbar({store:this.store,pageSize:50,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});a=new Ext.Toolbar;NECS.grid.ClassSearchGrid.superclass.constructor.call(this,{height:200,loadMask:true,tbar:a,bbar:tbPager,cm:new Ext.grid.ColumnModel([NECS.grid.columns.classes.Menu,NECS.grid.columns.classes.Class])});this.setupToolbar(a);this.hookEvents()};
Ext.extend(NECS.grid.ClassSearchGrid,Ext.grid.GridPanel,{edSearch:null,loaded:false,setupToolbar:function(a){this.edSearch=new NECS.form.SearchField({emptyText:"Enter search keywords",width:378});this.edSearch.on("clear",function(){this.store.lastOptions={};this.store.baseParams={};this.store.sortInfo={field:"class",direction:"ASC"};this.store.load({params:{start:0,limit:50,sort:"class",dir:"ASC",query:null}})},this);this.edSearch.on("search",function(b,c){this.store.lastOptions={};this.store.baseParams=
{};this.store.sortInfo={field:"class",direction:"ASC"};this.store.load({params:{start:0,limit:50,sort:"class",dir:"ASC",query:c}})},this);a.add(this.edSearch)},initializeStore:function(){this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcUtilityUri}),new NECS.rpc.JSON.Request("getClasses",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"class",totalProperty:"totalResults"},NECS.data.records.Classes),sortInfo:{field:"class",direction:"ASC"},
remoteSort:true})},hookEvents:function(){this.on("rowdblclick",function(a,b){(a=this.store.getAt(b))&&this.fireEvent("dataselected",this,a.data["class"])},this);this.on("click",function(a){var b;if(a.getTarget(".clickable")){a=a.getTarget();b=this.getView();b=b.findRowIndex(a);a=a.className.split("-")[2];switch(a){case "add":a=this.store.getAt(b);this.fireEvent("dataselected",this,a.data["class"]);break}}},this)},load:function(a){if(!this.loaded||a){this.loaded=true;this.store.load({params:{start:0,
limit:50,sort:"class",dir:"ASC",query:null}})}}});
NECS.grid.BrandSearchGrid=function(a,b){this.app=b;Ext.apply(this,a);this.initializeStore();tbPager=new Ext.PagingToolbar({store:this.store,pageSize:50,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});a=new Ext.Toolbar;NECS.grid.BrandSearchGrid.superclass.constructor.call(this,{loadMask:true,tbar:a,bbar:tbPager,view:new Ext.grid.GridView({forceFit:true}),cm:new Ext.grid.ColumnModel([NECS.grid.columns.brands.Menu,NECS.grid.columns.brands.Brand])});this.setupToolbar(a);
this.hookEvents()};
Ext.extend(NECS.grid.BrandSearchGrid,Ext.grid.GridPanel,{edSearch:null,loaded:false,setupToolbar:function(a){this.edSearch=new NECS.form.SearchField({emptyText:"Enter search keywords",width:378});this.edSearch.on("clear",function(){this.store.lastOptions={};this.store.baseParams={};this.store.sortInfo={field:"brand",direction:"ASC"};this.store.load({params:{start:0,limit:50,sort:"brand",dir:"ASC",query:null,CustNo:null}})},this);this.edSearch.on("search",function(b,c){this.store.lastOptions={};this.store.baseParams=
{};this.store.sortInfo={field:"brand",direction:"ASC"};this.store.load({params:{start:0,limit:50,sort:"brand",dir:"ASC",query:c,CustNo:null}})},this);a.add(this.edSearch)},initializeStore:function(){this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcUtilityUri}),new NECS.rpc.JSON.Request("getBrands",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"brand",totalProperty:"totalResults"},NECS.data.records.Brands),sortInfo:{field:"brand",
direction:"ASC"},remoteSort:true})},hookEvents:function(){this.on("rowdblclick",function(a,b){(a=this.store.getAt(b))&&this.fireEvent("dataselected",this,a.data.brand)},this);this.on("click",function(a){var b;if(a.getTarget(".clickable")){a=a.getTarget();b=this.getView();b=b.findRowIndex(a);a=a.className.split("-")[2];switch(a){case "add":a=this.store.getAt(b);this.fireEvent("dataselected",this,a.data.brand);break}}},this)},load:function(a){if(!this.loaded||a){this.loaded=true;this.store.load({params:{start:0,
limit:50,sort:"brand",dir:"ASC",query:null,CustNo:null}})}}});
NECS.grid.LotSearchGrid=function(a,b){this.app=b;Ext.apply(this,a);this.initializeStore();tbPager=new Ext.PagingToolbar({store:this.store,pageSize:50,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});a=new Ext.Toolbar;NECS.grid.LotSearchGrid.superclass.constructor.call(this,{loadMask:true,tbar:a,bbar:tbPager,view:new Ext.grid.GridView({forceFit:true}),cm:new Ext.grid.ColumnModel([NECS.grid.columns.lots.Menu,NECS.grid.columns.lots.LotNo])});this.setupToolbar(a);
this.hookEvents()};
Ext.extend(NECS.grid.LotSearchGrid,Ext.grid.GridPanel,{edSearch:null,loaded:false,setupToolbar:function(a){this.edSearch=new NECS.form.SearchField({emptyText:"Enter search keywords",width:378});this.edSearch.on("clear",function(){this.store.lastOptions={};this.store.baseParams={};this.store.sortInfo={field:"lot_no",direction:"ASC"};this.store.load({params:{start:0,limit:50,sort:"lot_no",dir:"ASC",query:null,CustNo:null}})},this);this.edSearch.on("search",function(b,c){this.store.lastOptions={};this.store.baseParams=
{};this.store.sortInfo={field:"lot_no",direction:"ASC"};this.store.load({params:{start:0,limit:50,sort:"lot_no",dir:"ASC",query:c,CustNo:null}})},this);a.add(this.edSearch)},initializeStore:function(){this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcUtilityUri}),new NECS.rpc.JSON.Request("getLots",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"lot_no",totalProperty:"totalResults"},new Ext.data.Record.create(NECS.data.fields.Lots)),
sortInfo:{field:"lot_no",direction:"ASC"},remoteSort:true})},hookEvents:function(){this.on("rowdblclick",function(a,b){(a=this.store.getAt(b))&&this.fireEvent("dataselected",this,a.data.lot_no)},this);this.on("click",function(a){var b;if(a.getTarget(".clickable")){a=a.getTarget();b=this.getView();b=b.findRowIndex(a);a=a.className.split("-")[2];switch(a){case "add":a=this.store.getAt(b);this.fireEvent("dataselected",this,a.data.lot_no);break}}},this)},load:function(a){if(!this.loaded||a){this.loaded=
true;this.store.load({params:{start:0,limit:50,sort:"lot_no",dir:"ASC",query:null,CustNo:null}})}}});
NECS.grid.MessageGrid=function(a,b){this.app=b;Ext.apply(this,a);a=this.accountMode?new NECS.rpc.JSON.Request("getAccountMessages",[],1):new NECS.rpc.JSON.Request("getMessages",[],1);this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcMessageUri}),a),reader:new NECS.data.JsonRpcReader({root:"data",totalProperty:"totalResults",id:"message_id"},new Ext.data.Record.create(NECS.data.fields.Message)),remoteSort:true});this.store.sort=this.store.sort.createInterceptor(function(){if(this.lastOptions.params)this.lastOptions.params.start=
0;return true});a=NECS.grid.columns.message;this.action=this.accountMode?new Ext.ux.grid.RowActions({header:"&nbsp;",id:"action",autoWidth:true,hideMode:"display",keepSelection:true,fixed:true,actions:[{iconCls:"icon-msg-view",tooltip:"View Message"}]}):new Ext.ux.grid.RowActions({header:"&nbsp;",id:"action",autoWidth:true,hideMode:"display",keepSelection:true,fixed:true,actions:[{iconCls:"icon-msg-edit",tooltip:"Edit Message"},{iconCls:"icon-msg-delete",tooltip:"Delete Message"}]});this.columns=
[this.action,a.Subject,a.Body,a.Posted];NECS.grid.SearchGrid.superclass.constructor.call(this,{id:"message-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,autoHeight:false,header:this.header?this.header:false,border:this.border?this.border:false,loadMask:{msg:"Please wait. Loading ..."},sm:new Ext.grid.RowSelectionModel({singleSelect:false,moveEditorOnEnter:true}),bbar:new Ext.PagingToolbar({store:this.store,pageSize:20,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"}),
viewConfig:{stripeRows:true,forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There are no messages.</div>',deferEmptyText:true,scrollOffset:12},plugins:[this.action]});this.on("rowdblclick",function(c,d){c=this.store.getAt(d);this.accountMode?this.fireEvent("view",c,d):this.fireEvent("edit",c,d)},this);this.action.on("action",function(c,d,e,f){if(e=="icon-msg-view")this.fireEvent("view",d,f);else if(e=="icon-msg-edit")this.fireEvent("edit",d,f);else e==
"icon-msg-delete"&&this.fireEvent("delete",d,f)},this)};Ext.extend(NECS.grid.MessageGrid,NECS.grid.GridPanel);Ext.namespace("NECS.panel");var GRAPH_PERIOD_DAILY=0,GRAPH_PERIOD_WEEKLY=1,GRAPH_PERIOD_MONTHLY=2;
NECS.panel.SalesGraphPanel=function(a){Ext.apply(this,a);this.graphMargin=this.graphMargin?this.graphMargin:5;this.width=this.width?this.width:720;this.height=this.height?this.height:250;this.elGraph=Ext.getBody().createChild({tag:"div",id:"graph-placeholder"});NECS.panel.SalesGraphPanel.superclass.constructor.call(this,{border:true,tbar:new Ext.Toolbar({ctCls:"necs-toolbar"}),contentEl:this.elGraph,listeners:{scope:this,render:function(){this.initializeToolbar();this.initializeGraphOptions();this.initializeGraph();
this.resizeGraph();this.fetchGraphData()}}})};
Ext.extend(NECS.panel.SalesGraphPanel,Ext.Panel,{elGraph:null,graphData:null,edPeriod:null,edDuration:null,edStartDate:null,laDuration:null,btUpdate:null,chartRendered:false,dsDays:null,dsWeekMonth:null,initializeToolbar:function(){this.dsDays=[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7]];this.dsWeekMonth=[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9],[10,10],[11,11],[12,12]];var a=this.getTopToolbar();if(a){this.edPeriod=new Ext.form.ComboBox({width:70,store:[[GRAPH_PERIOD_DAILY,"Daily"],[GRAPH_PERIOD_WEEKLY,
"Weekly"],[GRAPH_PERIOD_MONTHLY,"Monthly"]],typeAhead:false,selectOnFocus:true,forceSelection:true,editable:false,triggerAction:"all",value:GRAPH_PERIOD_DAILY});this.edPeriod.on("select",function(b){b=b.getValue();if(b==GRAPH_PERIOD_DAILY){this.laDuration.setText("Days:");this.edDuration.store.loadData(this.dsDays,false);this.edDuration.setValue(7)}else if(b==GRAPH_PERIOD_WEEKLY){this.laDuration.setText("Weeks:");this.edDuration.store.loadData(this.dsWeekMonth,false);this.edDuration.setValue(12)}else if(b==
GRAPH_PERIOD_MONTHLY){this.laDuration.setText("Months:");this.edDuration.store.loadData(this.dsWeekMonth,false);this.edDuration.setValue(12)}},this);this.edDuration=new Ext.form.ComboBox({width:45,store:this.dsDays,typeAhead:true,selectOnFocus:true,forceSelection:true,editable:true,triggerAction:"all",value:12});this.laDuration=new Ext.form.Label({text:"Days:"});this.edStartDate=new Ext.form.DateField;this.btUpdate=new Ext.Button({text:"Update",scope:this,handler:function(){this.fetchGraphData()}});
a.addText("Period");a.addSpacer();a.add(this.edPeriod);a.addSpacer();a.addText("Start Date: ");a.addSpacer();a.add(this.edStartDate);a.addSpacer();a.add(this.laDuration);a.addSpacer();a.add(this.edDuration);a.addFill();a.add(this.btUpdate);new Ext.KeyNav(a.getEl(),{enter:function(){this.fetchGraphData()},scope:this})}},initializeGraphOptions:function(){this.edPeriod.setValue(GRAPH_PERIOD_DAILY);this.edDuration.setValue(7);var a=new Date;a.setDate(a.getDate()-8);this.edStartDate.setValue(a)},resizeGraph:function(){var a=
0;a+=this.getFrameHeight();a+=this.getTopToolbar().getSize().height;a+=this.graphMargin*2;this.elGraph.dom.style.height=this.height-a+"px";a=0+this.getFrameWidth();a+=this.graphMargin*2;this.elGraph.dom.style.width=this.width-a+"px"},initializeGraph:function(){var a=0,b;a+=this.getFrameHeight();a+=this.getTopToolbar().getSize().height;b=this.height-a;a=0+this.getFrameWidth();a=this.width-a;this.elGraph.dom.style.width=a+"px";this.elGraph.dom.style.height=b+"px";this.chart=new FusionCharts("/include/charts/FCF_MSColumn3D.swf",
"fusionChart",a-2,b+15);this.chart.setTransparent(true)},updateGraphData:function(a){if(this.chartRendered)updateChartXML("fusionChart",a);else{this.chart.setDataXML(a);this.chart.render("graph-placeholder");this.chartRendered=true}},fetchGraphData:function(){var a,b,c,d;c=this.edPeriod.getValue();if(this.salesNo){if(c==GRAPH_PERIOD_DAILY)b="getDailySalesBySalesNo";else if(c==GRAPH_PERIOD_WEEKLY)b="getWeeklySalesBySalesNo";else if(c==GRAPH_PERIOD_MONTHLY)b="getMonthlySalesBySalesNo";a=[this.salesNo,
this.edStartDate.getValue(),this.edDuration.getValue(),true]}else{a=[this.edStartDate.getValue(),this.edDuration.getValue(),true];if(c==GRAPH_PERIOD_DAILY)b="getDailySales";else if(c==GRAPH_PERIOD_WEEKLY)b="getWeeklySales";else if(c==GRAPH_PERIOD_MONTHLY)b="getMonthlySales"}d=new Ext.LoadMask(this.getTopToolbar().getEl(),{msg:"Fetching graph data ..."});request=new NECS.rpc.JSON.Request(b,a,1,function(e){if(e.error||!e.result){NECS.util.DisplayError("An error occured while attempting to load the graph data.");
d.hide()}if(e.result.success){this.updateGraphData(e.result.data);d.hide()}else{d.hide();e.result.message?NECS.util.DisplayError(e.result.message):NECS.util.DisplayError("An error occured while attempting to contact the server. Please try again.")}delete d},this);d.show();this.salesNo?NECS.rpc.JSON.call(NECS.application.RpcSalespersonUri,request):NECS.rpc.JSON.call(NECS.application.RpcUri+"/charts",request)}});Ext.namespace("NECS.panel");
var CHART_PIE_3D="/include/charts/FCF_Pie3D.swf",CHART_BAR_MS_3D="/include/charts/FCF_MSColumn3D.swf",CHART_AREA_MS_2D="/include/charts/FCF_MSArea2D.swf";
NECS.panel.DateRangeChartPanel=function(a){Ext.apply(this,a);this.graphMargin=this.graphMargin?this.graphMargin:5;this.fushionChartId=Ext.id();this.elGraph=Ext.getBody().createChild({tag:"div",id:Ext.id()});if(!this.startDate){a=new Date;a.setDate(a.getDate()-8);this.startDate=a}if(!this.endDate){a=this.startDate;a.setDate(this.startDate.getDate()+7);this.endDate=a}NECS.panel.DateRangeChartPanel.superclass.constructor.call(this,{border:true,tbar:new Ext.Toolbar({ctCls:"necs-toolbar"}),contentEl:this.elGraph,
listeners:{scope:this,render:function(){this.initializeToolbar();this.initializeGraph();this.fetchGraphData()}}})};
Ext.extend(NECS.panel.DateRangeChartPanel,Ext.Panel,{elGraph:null,edStartDate:null,edEndDate:null,btUpdate:null,chartRendered:false,chartData:null,initializeToolbar:function(){var a=this.getTopToolbar();if(a){this.edStartDate=new Ext.form.DateField;this.edEndDate=new Ext.form.DateField;this.edStartDate.setValue(this.startDate);this.edEndDate.setValue(this.endDate);this.btUpdate=new Ext.Button({text:"Update",scope:this,handler:function(){this.fetchGraphData()}});a.addText("Start Date: ");a.addSpacer();
a.add(this.edStartDate);a.addSpacer();a.addText("End Date: ");a.addSpacer();a.add(this.edEndDate);a.addSpacer();typeof this.postToolbarInit=="function"&&this.postToolbarInit(a);a.addFill();a.add(this.btUpdate);new Ext.KeyNav(a.getEl(),{enter:function(){this.fetchGraphData()},scope:this})}},initializeGraph:function(){var a=0,b;a+=this.getFrameHeight();a+=this.getTopToolbar().getSize().height;b=this.height-a;a=0+this.getFrameWidth();a=this.width-a;this.elGraph.dom.style.width=a+"px";this.elGraph.dom.style.height=
b+"px";this.chartType||alert("Chart type has not been set");this.chart=new FusionCharts(this.chartType,this.fushionChartId,a-2,b+15);this.chart.setTransparent(true)},updateGraphData:function(a){this.chartData=a;if(this.chartRendered)updateChartXML(this.fushionChartId,a);else{this.chart.setDataXML(a);this.chart.render(this.elGraph.dom.id);this.chartRendered=true}},swapChartType:function(a){this.chartType=a;this.initializeGraph();this.chartRendered=false;this.updateGraphData(this.chartData)},fetchGraphData:function(){alert("Fetch graph data must be implemented in sub-classes.")}});
NECS.grid.AdsGrid=function(a,b){this.app=b;Ext.apply(this,a);a=new NECS.rpc.JSON.Request("getAds",[],1);this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcUtilityUri}),a),reader:new NECS.data.JsonRpcReader({root:"data",totalProperty:"totalResults",id:"ad_id"},new Ext.data.Record.create(NECS.data.fields.Ad)),remoteSort:false});this.store.sort=this.store.sort.createInterceptor(function(){if(this.lastOptions.params)this.lastOptions.params.start=0;
return true});a=NECS.grid.columns.ad;this.action=new Ext.ux.grid.RowActions({header:"&nbsp;",id:"action",autoWidth:true,hideMode:"display",keepSelection:true,fixed:true,actions:[{iconCls:"icon-msg-edit",tooltip:"Edit Message"},{iconCls:"icon-msg-delete",tooltip:"Delete Message"}]});this.columns=[this.action,a.Title,a.AdDate];NECS.grid.SearchGrid.superclass.constructor.call(this,{id:"ad-grid",cls:"necs-grid",stripeRows:true,autoWidth:true,autoHeight:false,header:this.header?this.header:false,border:this.border?
this.border:false,loadMask:{msg:"Please wait. Loading ..."},sm:new Ext.grid.RowSelectionModel({singleSelect:false,moveEditorOnEnter:true}),bbar:new Ext.PagingToolbar({store:this.store,pageSize:20,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"}),viewConfig:{stripeRows:true,forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There are no advertisements.</div>',deferEmptyText:true,scrollOffset:12},plugins:[this.action]});
this.on("rowdblclick",function(c,d){this.fireEvent("edit",this.store.getAt(d),d)},this);this.action.on("action",function(c,d,e,f){if(e=="icon-msg-view")this.fireEvent("view",d,f);else if(e=="icon-msg-edit")this.fireEvent("edit",d,f);else e=="icon-msg-delete"&&this.fireEvent("delete",d,f)},this)};Ext.extend(NECS.grid.AdsGrid,NECS.grid.GridPanel);Ext.namespace("NECS.panel");NECS.panel.SalesSourceChartPanel=function(a){Ext.apply(this,a);this.chartType=CHART_PIE_3D;NECS.panel.SalesSourceChartPanel.superclass.constructor.call(this)};
Ext.extend(NECS.panel.SalesSourceChartPanel,NECS.panel.DateRangeChartPanel,{fetchGraphData:function(){var a;a=[this.edStartDate.getValue(),this.edEndDate.getValue(),true];var b=new Ext.LoadMask(this.getTopToolbar().getEl(),{msg:"Fetching graph data ..."});request=new NECS.rpc.JSON.Request("getTotalSalesBySource",a,1,function(c){if(c.error||!c.result){NECS.util.DisplayError("An error occured while attempting to load the graph data.");b.hide()}if(c.result.success){this.updateGraphData(c.result.data);
b.hide()}else{b.hide();NECS.util.DisplayError("An error occured while attempting to contact the server. Please try again.")}delete b},this);b.show();NECS.rpc.JSON.call(NECS.application.RpcUri+"/charts",request)}});Ext.namespace("NECS.panel");
NECS.panel.EmailTemplateTreePanel=function(a){Ext.apply(this,a);NECS.panel.EmailTemplateTreePanel.superclass.constructor.call(this,{rootVisible:false,lines:false,autoScroll:true,root:new Ext.tree.TreeNode("Editable Content"),collapseFirst:false});this.getSelectionModel().on({beforeselect:function(){},selectionchange:function(b,c){c&&c.attributes.cls!="site-content-root-node"&&this.fireEvent("contentselect",c.attributes)},scope:this});this.addEvents({contentselect:true})};
Ext.extend(NECS.panel.EmailTemplateTreePanel,Ext.tree.TreePanel,{rootNodes:[],addPage:function(a,b,c){if(this.rootNodes[a])node=this.rootNodes[a];else{node=this.root.appendChild(new Ext.tree.TreeNode({text:a,iconCls:"icon-folder-email",cls:"site-content-root-node",expanded:true}));this.rootNodes[a]=node}node.appendChild(new Ext.tree.TreeNode({iconCls:"icon-email",cls:"site-content-node",id:c,text:b}))}});Ext.namespace("NECS.chart");NECS.chart.FUSION_PIE3D="/include/charts/FCF_Pie3D.swf";
NECS.chart.FUSION_BAR3D_MS="/include/charts/FCF_MSColumn3D.swf";NECS.chart.FUSION_AREA2D_MS="/include/charts/FCF_MSArea2D.swf";NECS.chart.Options=function(){this.parameters={}};NECS.chart.prototype={startDate:null,endDate:null,parameters:{}};NECS.chart.ChartDefinition=function(a){Ext.apply(this,a);this.title||alert("A chart title is required.");this.type||alert("A chart type is required.");NECS.chart.ChartDefinition.superclass.constructor.call(this);this.addEvents({chartdataloaded:true})};
Ext.extend(NECS.chart.ChartDefinition,Ext.util.Observable,{title:null,type:null,load:function(){alert("Abstract method must be implemented in child.")},setTitle:function(a){this.title=a},getTitle:function(){return this.title},setType:function(a){this.type=a},getType:function(){return this.type}});NECS.chart.Top10CustomerSales=function(a){Ext.apply(this,a);NECS.chart.Top10CustomerSales.superclass.constructor.call(this)};
Ext.extend(NECS.chart.Top10CustomerSales,NECS.chart.ChartDefinition,{load:function(a,b){if(!a.parameters.source)a.parameters.source=null;request=new NECS.rpc.JSON.Request("getTop10CustomerSales",[a.startDate,a.endDate,a.parameters.source,true],1,function(c){if(c.error||!c.result){b&&b.hide();NECS.util.DisplayError("An error occured while attempting to load the graph data.")}if(c.result.success){b&&b.hide();this.fireEvent("chartdataloaded",c.result.data)}else{b&&b.hide();c.result.message?NECS.util.DisplayError(c.result.message,
"Chart Load Error"):NECS.util.DisplayError("An error unknown occured while attempting to contact the server. Please try again.")}},this);b&&b.show();NECS.rpc.JSON.call(NECS.application.RpcUri+"/charts",request)}});NECS.chart.Top10SalespersonSales=function(a){Ext.apply(this,a);NECS.chart.Top10SalespersonSales.superclass.constructor.call(this)};
Ext.extend(NECS.chart.Top10SalespersonSales,NECS.chart.ChartDefinition,{load:function(a,b){if(!a.parameters.source)a.parameters.source=null;request=new NECS.rpc.JSON.Request("getTop10SalespersonSales",[a.startDate,a.endDate,a.parameters.source,true],1,function(c){if(c.error||!c.result){b&&b.hide();NECS.util.DisplayError("An error occured while attempting to load the graph data.")}if(c.result.success){b&&b.hide();this.fireEvent("chartdataloaded",c.result.data)}else{b&&b.hide();NECS.util.DisplayError("An error occured while attempting to contact the server. Please try again.")}},
this);b&&b.show();NECS.rpc.JSON.call(NECS.application.RpcUri+"/charts",request)}});
NECS.chart.FusionChartPanel=function(a){Ext.apply(this,a);this.title=this.title?this.title:"Charts";if(this.charts){if(this.defaultChart>=0&&this.defaultChart<this.charts.length){this.activeChart=this.charts[this.defaultChart];this.title=this.activeChart.getTitle()}Ext.each(this.charts,function(b){b.on("chartdataloaded",this.onChartDataLoaded,this)},this)}else alert("A list of charts to be managed by this panel is required. Charts will not be available.");this.fusionChartId=Ext.id();this.options=
new NECS.chart.Options;if(this.startDate){this.options.startDate=this.startDate;delete this.startDate}else{a=new Date;a.setDate(a.getDate()-8);this.options.startDate=a}if(this.endDate){this.options.endDate=this.endDate;delete this.endDate}else{a=this.options.startDate;a.setDate(a.getDate()+7);this.options.endDate=a}NECS.chart.FusionChartPanel.superclass.constructor.call(this,{autoEl:{},border:true,tbar:new Ext.Toolbar,layout:"fit",listeners:{scope:this,afterlayout:function(){this.onAfterLayout()},
render:function(){this.onRendered()}}})};
Ext.extend(NECS.chart.FusionChartPanel,Ext.Panel,{chartEl:null,charts:null,defaultChart:0,options:null,activeChart:null,chartRendered:false,loadMask:null,edChartList:null,edStartDate:null,edEndDate:null,edSource:null,btUpdate:null,onRendered:function(){this.renderToolbar()},onAfterLayout:function(){this.update()},renderToolbar:function(){var a=this.getTopToolbar();if(a){var b=[];Ext.each(this.charts,function(c,d){b[b.length]=[d,c.getTitle()]},this);this.edChartList=new Ext.form.ComboBox({width:160,
store:b,typeAhead:false,selectOnFocus:true,forceSelection:true,editable:false,triggerAction:"all",value:this.defaultChart});this.edChartList.on("select",function(){this.onChartChanged()},this);this.edStartDate=new Ext.form.DateField({value:this.options.startDate});this.edEndDate=new Ext.form.DateField({value:this.options.endDate});this.edSource=new Ext.form.ComboBox({width:80,store:[[null,"All"],["NET","entree.NET"]],typeAhead:false,selectOnFocus:true,forceSelection:true,editable:false,triggerAction:"all",
value:null});this.btUpdate=new Ext.Button({text:"Update",scope:this,handler:function(){this.update()}});new Ext.KeyNav(a.getEl(),{enter:function(){this.update()},scope:this});a.add(this.edChartList);a.addSeparator();a.addText("Start Date:");a.addSpacer();a.add(this.edStartDate);a.addSpacer();a.addText("End Date:");a.addSpacer();a.add(this.edEndDate);a.addSpacer();a.addText("Source:");a.addSpacer();a.add(this.edSource);a.addFill();a.add(this.btUpdate)}else alert("Toolbar is missing for chart option controls.")},
prepareFusionChart:function(){this.chart&&delete this.chart;this.chart=new FusionCharts(this.activeChart.getType(),this.fusionChartId,this.body.getWidth(),this.body.getHeight());this.chart.setTransparent(true)},update:function(){this.options.startDate=this.edStartDate.getValue();this.options.endDate=this.edEndDate.getValue();this.options.parameters={source:this.edSource.getValue()};if(!this.loadMask)this.loadMask=new Ext.LoadMask(this.getTopToolbar().getEl(),{msg:"Loading chart data ..."});this.activeChart.load(this.options,
this.loadMask)},onChartDataLoaded:function(a){if(this.chartRendered)updateChartXML(this.fusionChartId,a);else{this.prepareFusionChart();this.chart.setDataXML(a);this.chart.render(this.body.dom.id);this.chartRendered=true}},setActiveChart:function(a){this.activeChart=a;this.setTitle(this.activeChart.getTitle())},onChartChanged:function(){var a=this.edChartList.getValue();if(this.activeChart!=this.charts[a]){if(this.activeChart.getType()!=this.charts[a].getType())this.chartRendered=false;this.setActiveChart(this.charts[a]);
this.update()}}});
NECS.grid.LocationSearchGrid=function(a,b){this.app=b;Ext.apply(this,a);this.initializeStore();tbPager=new Ext.PagingToolbar({store:this.store,pageSize:50,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"});a=new Ext.Toolbar;NECS.grid.LocationSearchGrid.superclass.constructor.call(this,{loadMask:true,tbar:a,bbar:tbPager,view:new Ext.grid.GridView({forceFit:true}),cm:new Ext.grid.ColumnModel([NECS.grid.columns.customer.Menu,NECS.grid.columns.customer.CustNo,NECS.grid.columns.customer.Company])});
NECS.grid.columns.customer.Menu.menuDisabled=true;NECS.grid.columns.customer.Menu.renderer=function(c,d,e){return'<div class="clickable status-item-add" id="__status'+e.id+'">'};this.setupToolbar(a);this.hookEvents()};
Ext.extend(NECS.grid.LocationSearchGrid,Ext.grid.GridPanel,{edSearch:null,loaded:false,setupToolbar:function(a){this.edSearch=new NECS.form.SearchField({emptyText:"Enter search keywords",width:378});this.edSearch.on("clear",function(){this.store.lastOptions={};this.store.baseParams={};this.store.sortInfo={field:"cust_no",direction:"ASC"};this.store.load({params:{start:0,limit:10,CustNo:this.app.Customer.CustNo,sort:"cust_no",dir:"ASC",query:null}})},this);this.edSearch.on("search",function(b,c){this.store.lastOptions=
{};this.store.baseParams={};this.store.sortInfo={field:"cust_no",direction:"ASC"};this.store.load({params:{start:0,limit:50,CustNo:this.app.Customer.CustNo,sort:"cust_no",dir:"ASC",query:c}})},this);a.add(this.edSearch)},initializeStore:function(){this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcCustomerUri}),new NECS.rpc.JSON.Request("getCustomerBillToLocations",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"cust_no",totalProperty:"total"},
NECS.data.records.CustomerLocations),sortInfo:{field:"cust_no",direction:"ASC"},remoteSort:true})},hookEvents:function(){this.on("rowdblclick",function(a,b){(a=this.store.getAt(b))&&this.fireEvent("dataselected",this,a.data.cust_no)},this);this.on("click",function(a){var b;if(a.getTarget(".clickable")){a=a.getTarget();b=this.getView();b=b.findRowIndex(a);a=a.className.split("-")[2];switch(a){case "add":a=this.store.getAt(b);this.fireEvent("dataselected",this,a.data.cust_no);break}}},this)},load:function(a){if(!this.loaded||
a){this.loaded=true;this.store.load({params:{start:0,limit:50,CustNo:this.app.Customer.CustNo,sort:"cust_no",dir:"ASC",query:null}})}}});
NECS.panel.DistributorOrderPanel=function(a){Ext.apply(this,a);this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:NECS.application.RpcOrderUri}),new NECS.rpc.JSON.Request("getOnlineOrders",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"order_id",totalProperty:"total"},NECS.data.records.OrderHeader),sortInfo:{field:"created",direction:"DESC"},remoteSort:true});this.action=new Ext.ux.grid.RowActions({header:"&nbsp;",id:"action",autoWidth:true,hideMode:"display",
keepSelection:true,fixed:true,actions:[{iconIndex:"RowActionImageClass",iconCls:"",tooltip:"View Order"}]});cols=NECS.grid.columns.order;this.columns=[this.action,cols.CustNo,cols.Status,cols.DeliveryDate,cols.EstTotal,cols.OrderNo,cols.InvoiceNo,cols.PurchNo,cols.SalesNo,cols.Created,cols.Completed,cols.Confirmed];NECS.panel.DistributorOrderPanel.superclass.constructor.call(this,{id:"recent-order-panel",ctCls:"necs-grid",stripeRows:true,height:250,title:"Orders",loadMask:{msg:"Loading order history ...."},
sm:new Ext.grid.RowSelectionModel({singleSelect:true}),bbar:new Ext.PagingToolbar({store:this.store,pageSize:NECS.application.ResultsPerPage,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"}),viewConfig:{forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There are no online orders in the system.</div>',deferEmptyText:false,getRowClass:function(b){if(!b.data.completed)return"row-order-open";return b.data.sales_no!==
""?"row-salesperson":"row-customer"}},plugins:[this.action]});this.on("rowdblclick",function(b,c){this.fireEvent("view",this.store.getAt(c),c)},this);this.action.on("action",function(b,c,d,e){if(d=="icon-order-view")this.fireEvent("view",c,e);else d=="icon-pdf"&&this.fireEvent("viewscan",c,e)},this)};Ext.extend(NECS.panel.DistributorOrderPanel,NECS.grid.GridPanel,{load:function(){this.store.load({params:{start:0,limit:NECS.application.ResultsPerPage,sort:"created",dir:"DESC"}})}});
NECS.report.ReportColumnDefinition=function(){this.columns=[];this.active=[];this.recordFields=[{name:"table",type:"string"},{name:"field",type:"string"},{name:"descr",type:"string"},{name:"type",type:"string"},{name:"length",type:"string"},{name:"decimals",type:"string"}];this.recordCols=[{header:"Field",dataIndex:"descr",menuDisabled:true,sortable:false,width:30}]};
NECS.report.ReportColumnDefinition.prototype={columns:null,active:null,setColumns:function(a){for(col in a)this.columns[this.columns.length]={field:a[col].field,descr:a[col].descr}},add:function(a,b,c,d,e,f){this.columns[this.columns.length]={table:a,field:b,descr:c,type:d,length:e,decimals:f}},setActiveCols:function(a){this.active=[];Ext.each(a,function(b){this.active[this.active.length]=b},this)},getUnusedColRecords:function(){var a=[];Ext.each(this.columns,function(b){if(this.active.indexOf(b.field)===
-1)a[a.length]=b},this);return a},getActiveColRecords:function(){var a=[];Ext.each(this.active,function(b){Ext.each(this.columns,function(c){if(c.field===b)a[a.length]=c})},this);return a}};NECS.page.layout.CenterEast=function(a,b){this.app=a;this.config=Ext.apply(b,this.config);NECS.page.layout.CenterEast.superclass.constructor.call(this,b)};
Ext.extend(NECS.page.layout.CenterEast,Ext.Component,{app:null,config:{layoutEl:"layout",layoutCenterEl:"center",layoutEastEl:"east",pageTop:0},layout:null,initializePage:function(){this.initializeLayout()},initializeLayout:function(){var a;if(a=Ext.get(this.config.layoutEl)){this.layout=new Ext.Container({autoEl:{},renderTo:a,height:Ext.lib.Dom.getViewportHeight()-this.config.pageTop,layout:"border",items:[{id:"layout-center",region:"center",border:false,contentEl:this.config.layoutCenterEl},{id:"layout-east",
region:"east",width:230,maxSize:400,minSize:230,split:false,border:false,layout:"fit",contentEl:this.config.layoutEastEl}]});Ext.EventManager.onWindowResize(this.resizePage,this)}else alert('Root element "'+this.config.layoutEl+'" for layout does not exist.')},resizePage:function(){var a,b,c,d;a=Ext.lib.Dom.getViewportHeight();b=Ext.lib.Dom.getViewportWidth();c=Ext.fly("menu");offset=c.getTop()+c.getHeight();this.layout.setHeight(a-offset);this.layout.doLayout();c=Ext.fly("layout-center").getBox();
d=Ext.fly("layout-east").getBox();Ext.get("center").setHeight(Ext.get("layout-center").getComputedHeight());return{width:b,height:a,viewport:{width:b,height:a},center:{width:c.width,height:c.height},east:{width:d.width,height:a-offset}}}});NECS.page.layout.CenterWest=function(a,b){this.app=a;this.config=Ext.apply(this.config,b);NECS.page.layout.CenterWest.superclass.constructor.call(this,b)};
Ext.extend(NECS.page.layout.CenterWest,Ext.Component,{app:null,config:{layoutEl:"layout",layoutCenterEl:"center",layoutWestEl:"west",pageTop:0},layout:null,initializePage:function(){this.initializeLayout()},initializeLayout:function(){var a;if(a=Ext.get(this.config.layoutEl)){this.layout=new Ext.Container({autoEl:{},renderTo:a,height:Ext.lib.Dom.getViewportHeight()-this.config.pageTop,layout:"border",items:[{id:"layout-west",region:"west",width:70,maxSize:200,minSize:200,split:false,border:false,
layout:"fit",contentEl:this.config.layoutWestEl},{id:"layout-center",region:"center",border:false,contentEl:this.config.layoutCenterEl}]});Ext.EventManager.onWindowResize(this.resizePage,this)}else alert('Root element "'+this.config.layoutEl+'" for layout does not exist.')},resizePage:function(){var a,b;a=Ext.lib.Dom.getViewportHeight();b=Ext.lib.Dom.getViewportWidth();if(Ext.isIE7)a+=2;this.layout.setHeight(a-this.config.pageTop);this.layout.doLayout();Ext.get("center").setHeight(Ext.get("layout-center").getComputedHeight());
return{width:b,height:a}}});NECS.page.layout.Center=function(a,b){this.app=a;this.config=Ext.apply(this.config,b);this.config.autoScroll=this.config.autoScroll?this.config.autoScroll:false;NECS.page.layout.Center.superclass.constructor.call(this,b)};
Ext.extend(NECS.page.layout.Center,Ext.Component,{app:null,config:{layoutEl:"layout",layoutCenterEl:"center",pageTop:null},layout:null,initializePage:function(){this.initializeLayout()},initializeLayout:function(){var a;a=Ext.get(this.config.layoutEl);this.config.pageTop=this.config.pageTop?this.config.pageTop:NECS.util.calculatePageTop();if(a){this.layout=new Ext.Container({autoEl:{},renderTo:a,height:Ext.lib.Dom.getViewportHeight()-this.config.pageTop,layout:"border",items:{autoScroll:this.config.autoScroll,
id:"layout-center",region:"center",border:false,contentEl:this.config.layoutCenterEl}});Ext.get(this.config.layoutCenterEl).addClass("border-right");Ext.EventManager.onWindowResize(this.resizePage,this)}else alert('Root element "'+this.config.layoutEl+'" for layout does not exist.')},resizePage:function(){var a,b;a=Ext.lib.Dom.getViewportHeight();b=Ext.lib.Dom.getViewportWidth();if(Ext.isIE7)a+=2;this.layout.setHeight(a-this.config.pageTop);this.layout.doLayout();Ext.get("center").setHeight(Ext.get("layout-center").getComputedHeight());
return{width:b,height:a}}});var STATE_ADD=0,STATE_CART=1,STATE_WORK=2,STATE_WARN=4,UPD_UNKNOWN=0,UPD_QTY=1,UPD_SPC_INST=2,UPD_PRICE=3,UPD_PCT=4;
NECS.page.common.OrderEntry=function(a,b){b=Ext.apply({gridEl:"grid",cartEl:"cart",resultsPerPage:100},b);NECS.page.common.OrderEntry.superclass.constructor.call(this,a,b);this.on("minorderamount",this.onMinOrderAmount,this);this.on("maxorderamount",this.onMaxOrderAmount,this);this.on("minorderweight",this.onMinOrderWeight,this);this.on("maxorderweight",this.onMaxOrderWeight,this)};
Ext.extend(NECS.page.common.OrderEntry,NECS.page.layout.CenterEast,{grid:null,cart:null,updateList:{},minAmountOK:true,maxAmountOK:true,minWeightOK:true,maxWeightOK:true,order:{OrderId:null,SalesNo:null,OrderNo:"",CustNo:"",Total:0,DeliveryDate:null,PurchNo:"",Comment:"",InvoiceNo:"",Finalized:false},maxOrderDate:null,commentVisible:false,edComment:null,kludgePriceUpdate:false,initializePage:function(){NECS.page.common.OrderEntry.superclass.initializePage.call(this);this.order.CustNo=this.app.Customer.CustNo;
if(this.app.Salesperson)this.order.SalesNo=this.app.Salesperson.SalesNo;this.order.DeliveryDate=this.app.Customer.NextDeliveryDate;this.maxOrderDate=this.app.Options&&this.app.Options.MaxOrderDays?new Date.parseDate(this.app.Customer.MaxOrderDate,"Y-m-d"):null;Ext.state.Manager.setProvider(new Ext.state.CookieProvider);this.commentVisible=Ext.state.Manager.get("invoiceCommentsVisible");this.initializeCart()},postInitialize:function(){if(this.grid){this.edPrice=NECS.application.Options&&NECS.application.Options.SpChangePrices?
new NECS.form.PriceEditField({listeners:{scope:this,pricechange:function(a,b){this.updateItemPrice(a.id,b)}}}):false;if((this.edPct=NECS.application.Options&&NECS.application.Options.SpUseMarkupPct?new NECS.form.PctEditField({listeners:{scope:this,change:function(a,b){this.updateItemPriceByPct(a.id,b)}}}):false)||this.edPrice)this.grid.on("cellclick",function(a,b,c,d){this.onCellClickEvent(a,b,c,d)},this)}},resizePage:function(){var a;a=NECS.page.common.OrderEntry.superclass.resizePage.call(this);
if(this.grid){var b=this.grid.getBottomToolbar();b=b?b.getHeight():0;var c=0;if(this.edComment&&this.commentVisible){c=a.center.height/3;this.setCommentVisible(true);this.edComment.setWidth(a.center.width);Ext.isGecko?this.edComment.setHeight(c-1):this.edComment.setHeight(c)}this.grid.setSize(a.center.width,a.center.height-(b+2)-c)}this.searchPanel&&this.searchPanel.adjustLayout(a.center.width);this.cart._setHeight(a.east.height);return a},initializeCart:function(){this.cart=new NECS.panel.CartPanel({renderTo:this.config.cartEl},
NECS.application);this.cart.render();this.cart.setRouteDays(NECS.application.Customer.NoRouteDays);this.cart.on("completeClick",function(){window.location=NECS.application.BaseUri+"customer/order/complete"});this.cart.on("cancelClick",function(){Ext.MessageBox.show({closable:false,buttons:Ext.MessageBox.YESNO,icon:Ext.Msg.WARNING,msg:"Cancel the current order?",title:"Confirm Cancel Order",scope:this,fn:function(b){b=="yes"&&this.cancelOrder()}})},this);this.cart.on("deliverydatechanged",function(b,
c){this.order.DeliveryDate=c.format("Y-m-d");this.app.Options.ShowPrices&&this.cart.store.getCount()>0?Ext.Msg.show({title:"Notice",msg:"Changing the delivery date may affect pricing. Please be sure to review your order before submitting.",minWidth:200,modal:true,icon:Ext.Msg.INFO,buttons:Ext.Msg.OK,scope:this,fn:function(){this.updateOrderHeader(true)}}):this.updateOrderHeader()},this);this.cart.on("commentClick",function(){this.toggleComment()},this);var a=function(){this.cart.updateState(this.order);
this.checkOrderAmount(this.cart.getTotal(),this.cart.getTotalWeight())};this.cart.store.on("load",a,this);this.cart.store.on("add",a,this);this.cart.store.on("remove",a,this)},getGrid:function(){return this.grid},loadCart:function(){var a=new Ext.LoadMask(this.cart.getEl(),{msg:"Loading ..."});a.show();var b=new NECS.rpc.JSON.Request("getWorkingOrderHeader",[],1,function(c){a.hide();delete a;if(c.result&&c.result.success){if(c.result.header.OrderId){this.cart.store.load();var d=new Date.parseDate(c.result.header.DeliveryDate,
"Y-m-d");this.order.OrderId=c.result.header.OrderId;this.order.Total=c.result.header.Total;this.order.OrderNo=c.result.header.OrderNo;this.order.DeliveryDate=d;this.order.PurchNo=c.result.header.PurchNo;this.order.Comment=c.result.header.Comment;this.order.route=c.result.header.route;this.order.stop=c.result.header.stop;this.order.cost_base=c.result.header.cost_base||0;this.order.dot_dep_total=c.result.header.dot_dep_total||0;if(d<NECS.application.Customer.NextDeliveryDate.clearTime()){d=NECS.application.Customer.NextDeliveryDate.clearTime();
this.order.DeliveryDate=d;NECS.util.DisplayInfo("The requested delivery date on this order is in the past. It has been changed to the next available delivery date.");this.updateOrderHeader(false)}this.edComment&&this.edComment.setValue(this.order.Comment)}else this.cart.store.removeAll();if(this.cart){this.cart.setMinDeliveryDate(this.app.Customer.NextDeliveryDate);this.maxOrderDate&&this.cart.setMaxDeliveryDate(this.maxOrderDate);this.cart.setDeliveryDate(this.order.DeliveryDate)}}else NECS.util.DisplayError("An error has occured while attempting to fetch order information.")},
this);NECS.rpc.JSON.call(NECS.application.RpcOrderUri,b)},updateOrderHeader:function(a){var b=new NECS.rpc.JSON.Request("updateOrderHeader",[this.order],1,function(c){if(c.error||!c.result)alert("updateorder: Server Communication Error.");else{if(c.result.success&&c.result.header){this.updateOrderHeaderFromResponse(c.result.header);this.cart&&this.cart.updateState(this.order)}else NECS.util.DisplayError(c.result.message);if(a){this.grid&&this.grid.store.reload();this.cart&&this.cart.store.reload()}}},
this);NECS.rpc.JSON.call(NECS.application.RpcOrderUri,b)},updateOrderHeaderFromResponse:function(a){this.order.CustNo=a.CustNo;this.order.SalesNo=a.SalesNo;this.order.OrderId=a.OrderId;this.order.DeliveryDate=new Date.parseDate(a.DeliveryDate,"Y-m-d");this.order.PurchNo=a.PurchNo.trim();if(a.Comment)this.order.Comment=a.Comment.trim();this.order.Total=a.Total;this.order.OrderNo=a.OrderNo;this.order.InvoiceNo=a.InvoiceNo;this.order.Finalized=a.Finalized;this.order.cost_base=a.cost_base;this.order.dot_dep_total=
a.dot_dep_total},cancelOrder:function(){var a;(new Ext.LoadMask(Ext.getBody(),{msg:"Canceling Order ..."})).show();a=new NECS.rpc.JSON.Request("cancelOrder",[this.order],1,function(b){if(b.error||!b.result)alert("CancelOrder: Server Communication Error.");else if(b.result.success)window.location=this.app.BaseUri+"customer";else NECS.util.DisplayError(b.result.message)},this);NECS.rpc.JSON.call(NECS.application.RpcOrderUri,a)},setupCommentField:function(a){a=a.createChild();this.edComment=new Ext.form.TextArea({renderTo:a,
width:300,height:90,deferEmptyText:true,emptyText:"Type here to enter comments to be included with the order.",visible:false,enableKeyEvents:true,listeners:{scope:this,keypress:function(){function b(c){c.commentUpdTimer=setTimeout(function(){c.order.Comment=c.edComment.getValue();c.updateOrderHeader(false)},1E3)}this.commentUpdTimer&&clearTimeout(this.commentUpdTimer);b(this)}}})},setCommentVisible:function(a){var b=this.grid.getBox(),c=Ext.fly("layout-center").getBox().height/3;Ext.isGecko&&--c;
if(a){this.grid.setHeight(b.height-c);this.edComment.setVisible(true);b=Ext.get("layout-center").getBox();this.edComment.setWidth(b.width);this.edComment.setHeight(c);this.commentVisible=true;this.cart.btComment.setText("Hide Comment")}else{this.edComment.setVisible(false);this.grid.setHeight(b.height+c);this.commentVisible=false;this.cart.btComment.setText("Edit Comment")}Ext.state.Manager.set("invoiceCommentsVisible",this.edComment.isVisible())},toggleComment:function(){if(this.grid){if(Ext.isGecko&&
!this.noCommentReloadKludge){if(this.grid.getSelectionModel)this.grid.restoreRecordId=this.grid.getSelectionModel().getSelected().id;this.grid.store.removeAll()}this.grid.suspendEvents();this.grid.view.suspendEvents();this.grid.store.suspendEvents();this.setCommentVisible(!this.commentVisible);this.commentVisible&&this.edComment.focus();this.grid.resumeEvents();this.grid.view.resumeEvents();this.grid.store.resumeEvents();Ext.isGecko&&!this.noCommentReloadKludge&&this.grid.store.load()}},onCellClickEvent:function(a,
b,c){if(this.edPrice){var d=a.getColumnModel().getDataIndex(c);if(d=="price"){a.getColumnModel().getColumnWidth(c);a.view.ensureVisible(b,c,true);v=a.store.getAt(b);this.edPrice.startEdit(a.view.getCell(b,c).firstChild,v)}}if(this.edPct){d=a.getColumnModel().getDataIndex(c);if(d=="markup_pct"){a.getColumnModel().getColumnWidth(c);a.view.ensureVisible(b,c,true);v=a.store.getAt(b);this.edPct.startEdit(a.view.getCell(b,c).firstChild,v)}}},onMinOrderAmount:function(a,b,c){this.cart&&typeof this.cart.setTotalState==
"function"&&this.cart.setTotalState(a,"Min. Order Amount: "+Ext.util.Format.usMoney(c))},onMaxOrderAmount:function(a,b,c){this.cart&&typeof this.cart.setTotalState=="function"&&this.cart.setTotalState(a,"Max. Order Amount: "+Ext.util.Format.usMoney(c))},onMinOrderWeight:function(a,b,c){if(this.cart&&typeof this.cart.setWeightTotalState=="function")this.cart.setWeightTotalState(a,"Min. Order Weight: "+Ext.util.Format.number(c||0,"0,0.00")+"lbs.")},onMaxOrderWeight:function(a,b,c){if(this.cart&&typeof this.cart.setWeightTotalState==
"function")this.cart.setWeightTotalState(a,"Max. Order Weight: "+Ext.util.Format.number(c||0,"0,0.00")+"lbs.")},updateTotal:function(){if(this.cart){this.cart.updateState(this.order);this.checkOrderAmount(this.cart.getTotal(),this.cart.getTotalWeight())}},cartStartEditPrice:function(a,b){b=this.cart.store.getById(b);this.edPrice.startEdit(a,b,true)},updateIndicatorState:function(a,b,c){var d=document.getElementById("__status"+a);a=document.getElementById("__statusReview"+a);var e="",f="";if(d||a){switch(b){case 0:f=
e="clickable status-item-add";break;case 1:e="clickable status-item-cart";f="clickable status-item-remove";break;case 2:f=e="clickable status-item-work";break;case STATE_WARN:f=e="clickable status-item-warn";break;default:}if(d){d.setAttribute("class",e);d.className=e}if(a){a.setAttribute("class",f);a.className=f}if(c&&c!=""){d&&d.setAttribute("ext:qtip",c);a&&a.setAttribute("ext:qtip",c)}else{d&&d.removeAttribute("ext:qtip");a&&a.removeAttribute("ext:qtip")}}},checkMinMaxWarning:function(a,b,c){if(b=
NECS.util.checkMinMaxQty(b,c)){this.kludgePriceUpdate||NECS.util.DisplayWarning(b,"Warning",null,function(){if(this.grid){var d=Ext.fly("__editorQtyOrd-"+c.id);d&&d.focus()}},this);this.updateIndicatorState(a,STATE_WARN,b);this.kludgePriceUpdate=false}},checkOrderAmount:function(a,b){var c=parseFloat(this.app.Options.MinOrderAmount),d=parseFloat(this.app.Options.MaxOrderAmount),e=parseFloat(this.app.Options.MinOrderWeight),f=parseFloat(this.app.Options.MaxOrderWeight),h=false;a=parseFloat(a);if(this.app.Options.ShowPrices){if(c!=
0){this.minAmountOK=h=a>=c;this.fireEvent("minorderamount",this.minAmountOK,a,this.app.Options.MinOrderAmount)}if(this.minAmountOK&&d!=0){this.maxAmountOK=h=a<=d;this.fireEvent("maxorderamount",this.maxAmountOK,a,this.app.Options.MaxOrderAmount)}}if(e!=0){this.minWeightOK=b>=e;this.fireEvent("minorderweight",this.minWeightOK,b,e);if(!this.minWeightOK)return}else this.minWeightOK=true;if(this.minWeightOK&&f!=0){this.maxWeightOK=b<=f;this.fireEvent("maxorderweight",this.maxWeightOK,b,f)}else this.maxWeightOK=
true},getRecordById:function(a){var b;if(this.grid)b=this.grid.store.getById(a);if(!b&&this.cart)b=this.cart.store.getById(a);return b?b:false},getUpdateObject:function(a){a=this.getRecordById(a);if(!a)return false;return{id:a.id,type:UPD_UNKNOWN,item_no:a.data.item_no,qty:NECS.util.parseFloat(a.data.qty_ord,0),price:a.data.price,manual_price:NECS.util.parseFloat(a.data.manual_price,null),markup_pct:NECS.util.parseFloat(a.data.markup_pct,null),promo_amount:NECS.util.parseFloat(a.data.promo_amount,
0),cost_base:NECS.util.parseFloat(a.data.cost_base,0),user_description1:a.data.user_description1,user_description2:a.data.user_description2,user_description3:a.data.user_description3,user_description4:a.data.user_description4}},updateOrderItem:function(a){var b;b=new NECS.rpc.JSON.Request("updateOrderItem",[{ItemNo:a.item_no,Price:a.price,ManualPrice:a.manual_price,QtyOrd:a.qty,MarkupPct:a.markup_pct,Cost:a.cost_base,user_description1:a.user_description1,user_description2:a.user_description2,user_description3:a.user_description3,
user_description4:a.user_description4,SkipPctCalc:a.type!==UPD_PRICE}],1,function(c){if(c.error||!c.result){NECS.util.DisplayError("An error occured while attempting to contact the server.","Server Connection Error");alert("updateorder: Server Communication Error.")}else{if(c.result.success){var d,e,f,h=a.id,j=null,g=c.result.itemInfo;if(this.grid){d=this.grid.store.getById(h);f=this.grid.store.indexOf(d);j=this.getUpdateObject(d);this.grid.store.suspendEvents()}if(this.cart){e=this.cart.store.getById(h);
j||(j=this.getUpdateObject(d))}if(c.result.data&&c.result.data.length>0){this.order.Total=c.result.data[0].order_total||0;this.order.cost_base=c.result.data[0].order_cost||0;this.order.dot_dep_total=c.result.data[0].order_dot_dep_total||0}if(a.qty==0){if(d){d.set("qty_ord",0);d.set("ext_amount",0);d.set("price",g.Price);d.set("promo_amount",g.PromoAmount);d.set("manual_price",g.ManualPrice);d.set("ext_amount",g.ExtAmount);d.set("markup_pct",g.MarkupPct);d.set("user_description1",g.user_description1);
d.set("user_description2",g.user_description2);d.set("user_description3",g.user_description3);d.set("user_description4",g.user_description4);if(l=Ext.fly("__editorSpcInst-"+h))l.dom.value=""}e&&this.cart.store.remove(e)}else{if(d){d.set("qty_ord",a.qty);d.set("price",g.Price);d.set("promo_amount",g.PromoAmount);d.set("manual_price",g.ManualPrice);d.set("ext_amount",g.ExtAmount);d.set("markup_pct",g.MarkupPct);d.set("user_description1",g.user_description1);d.set("user_description2",g.user_description2);
d.set("user_description3",g.user_description3);d.set("user_description4",g.user_description4)}if(e){e.set("qty_ord",a.qty);e.set("price",g.Price);e.set("promo_amount",g.PromoAmount);e.set("manual_price",g.ManualPrice);e.set("ext_amount",g.ExtAmount);e.set("markup_pct",g.MarkupPct);e.set("user_description1",g.user_description1);e.set("user_description2",g.user_description2);e.set("user_description3",g.user_description3);e.set("user_description4",g.user_description4)}else this.cart&&this.cart.store.insert(0,
d.copy())}this.grid&&this.grid.store.resumeEvents();if(this.grid&&d)if(this.grid.getColumnModel){var m=this.grid.getColumnModel(),k=null;l=null;k=-1;k=m.getIndexById("extamt");if(k==-1)k=m.getIndexById("search-extamt");if(k!=-1){l=this.grid.view.getCell(f,k);k=m.getRenderer(k);l.firstChild.innerHTML=k(d.data.ext_amount,l,d)}k=m.getIndexById("price");if(k==-1)k=m.getIndexById("search-price");if(k!=-1){l=this.grid.view.getCell(f,k);k=m.getRenderer(k);l.firstChild.innerHTML=k(NECS.util.translatePrice(d),
null,d)}k=m.getIndexById("markup-pct");if(k==-1)k=m.getIndexById("search-markup-pct");if(k!=-1){l=this.grid.view.getCell(f,k);k=m.getRenderer(k);f=k(d.data.markup_pct,null,d);l.firstChild.innerHTML=f}var l=document.getElementById("__editorQtyOrd-"+h);if(l)l.value=d.data.qty_ord;if(l=Ext.fly("__editorSpcInst-"+h))l.dom.disabled=d.data.qty_ord==0}else if(l=document.getElementById("__editorQtyOrd-"+h))l.value=d.data.qty_ord;if(!this.order.OrderId&&c.result.header)this.order.OrderId=c.result.header.OrderId}else c.result.message?
NECS.util.DisplayError(c.result.message,"Update Item"):NECS.util.DisplayError("An error has occured while attempting to update this order item.","Order Update Failed");a.qty>0?this.updateIndicatorState(a.id,STATE_CART):this.updateIndicatorState(a.id,STATE_ADD);if(d)this.checkMinMaxWarning(h,a.qty,d);else e&&this.checkMinMaxWarning(h,a.qty,e);if(g){c=NECS.util.parseFloat(g.PromoAmount,0);g.ManualPrice&&c!==0&&c!==j.promo_amount&&NECS.util.DisplayWarning("The price for this item has been adjusted to include a "+
Ext.util.Format.usMoney(c)+" promotion.","Promotion Applied")}this.updateTotal();this.fireEvent("updatecomplete")}},this);this.updateIndicatorState(a.id,STATE_WORK);NECS.rpc.JSON.call(NECS.application.RpcOrderUri,b)},updateItemQty:function(a,b){if(b===undefined)if(this.updateList[a]&&this.updateList[a].qty>-1){b=this.updateList[a].qty;delete this.updateList[a]}else throw'updateItemQty: No quantity specified for quantity update to "'+a+'"';else if(this.updateList[a]){clearTimeout(this.updateList[a].timer_id);
delete this.updateList[a]}var c=this.getUpdateObject(a);if(!c)throw'updateItemQty: Failed to find data record for item "'+a+'"';c.type=UPD_QTY;c.qty=NECS.util.parseFloat(b,0);this.updateOrderItem(c);return c.qty},incrementItemQty:function(a,b){b=document.getElementById(b);var c=++b.value;this.updateIndicatorState(a,STATE_WORK);this.delayUpdateItemQty(a,c);b.focus()},decrementItemQty:function(a,b){b=document.getElementById(b);var c=b.value;c=Math.max(0,--c);b.value=c;this.updateIndicatorState(a,STATE_WORK);
this.delayUpdateItemQty(a,c);b.focus()},delayUpdateItemQty:function(a,b){this.updateList[a]||(this.updateList[a]={qty:b,timer_id:-1});clearTimeout(this.updateList[a].timer_id);this.updateList[a].qty=b;var c=this;this.updateList[a].timer_id=setTimeout(function(){c.updateItemQty(a)},650)},updateItemSpcInst:function(a,b){var c=this.getUpdateObject(a);this.getRecordById(a);if(!c)throw'updateItemSpcInst: Failed to find data record for item "'+a+'"';c.type=UPD_SPC_INST;if(b!==null)c.user_description2=(b||
"").trim()==""?null:b;this.updateOrderItem(c)},updateItemPrice:function(a,b){var c=this.getUpdateObject(a);if(!c)throw'updateItemPrice: Failed to find data record for item "'+a+'"';c.type=UPD_PRICE;c.manual_price=NECS.util.parseFloat(b,null);this.kludgePriceUpdate=true;this.updateOrderItem(c)},updateItemPriceByPct:function(a,b){var c=this.getUpdateObject(a);if(!c)throw'updateItemPriceByPct: Failed to find data record for item "'+a+'"';if(NECS.util.parseFloat(c.cost_base,0)===0)NECS.util.DisplayWarning("This calculation cannot be perform since the item does not have a valid base cost.",
"Price Update Error");else{c.type=UPD_PCT;c.markup_pct=NECS.util.parseFloat(b,c.markup_pct);a=new NECS.rpc.JSON.Request("calcPriceSpecial",[c.item_no,c.markup_pct],1,function(d){if(d.error||!d.result)NECS.util.DisplayError("An error occured while attempting to contact the server.","Server Communication Error");else if(d.result.success){if(d.result.data.Message!=""){c.markup_pct=d.result.data.MarkupPct;NECS.util.DisplayWarning(d.result.data.Message,"Percentage Modified")}c.manual_price=NECS.util.parseFloat(d.result.data.Price,
null);this.updateOrderItem(c)}else NECS.util.DisplayError(d.result.message,"Server Communication Error")},this);NECS.rpc.JSON.call(NECS.application.RpcUri+"/order",a)}}});NECS.page.common.DistributorSettings=function(a,b){b=Ext.apply({subMenuEl:"sub-menu"},b);NECS.page.common.DistributorSettings.superclass.constructor.call(this,a,b)};
Ext.extend(NECS.page.common.DistributorSettings,NECS.page.layout.CenterWest,{accountId:null,customer:null,salesperson:null,subMenuEl:null,initializePage:function(){NECS.page.common.DistributorSettings.superclass.initializePage.call(this);this.initializeSubMenu()},resizePage:function(){var a;a=NECS.page.common.DistributorSettings.superclass.resizePage.call(this);this.subMenuEl.setHeight(a.height);return a},initializeSubMenu:function(){var a,b;a=Ext.get(this.config.subMenuEl);b=false;if((this.customer||
this.salesperson)&&!this.accountId)b=true;if(a){this.subMenuEl=a.createChild();Ext.isIE7&&Ext.getCmp("layout-west").setWidth(85);new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">General</div>',iconCls:"icon-home-24",iconAlign:"top",autoWidth:false,height:50,width:Ext.isIE7?66:50,listeners:{scope:this,click:function(){this.buttonClick("home")}}});this.btOptions=new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",
text:'<div style="padding-top: 5px">Options</div>',iconCls:"icon-options-24",iconAlign:"top",height:50,width:Ext.isIE7?66:50,disabled:b,listeners:{scope:this,click:function(){this.buttonClick("options")}}});this.btOptions=new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">Ads</div>',iconCls:"icon-slider-24",iconAlign:"top",height:50,width:Ext.isIE7?66:50,disabled:b,listeners:{scope:this,click:function(){this.buttonClick("ads")}}});
if(this.hasEOPModule||this.hasOrderModule){if(this.hasOrderModule)this.btGrids=new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px;">Grids</div>',iconCls:"icon-grid-24",iconAlign:"top",height:50,width:Ext.isIE7?66:50,disabled:b,listeners:{scope:this,click:function(){this.buttonClick("grid")}}});if(!this.customer&&!this.salesperson){new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">Email</div>',
iconCls:"icon-mail-24",iconAlign:"top",height:50,width:Ext.isIE7?66:50,listeners:{scope:this,click:function(){this.buttonClick("email")}}});if(this.hasEOPModule)new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">EOP</div>',iconCls:"icon-tablet-24",iconAlign:"top",height:50,width:Ext.isIE7?66:50,listeners:{scope:this,click:function(){this.buttonClick("tablet")}}})}}}else alert('Root element "'+this.config.subMenuEl+'" for page menu does not exist.')},
buttonClick:function(a){if(this.customer){if(a=="options")window.location=this.app.BaseUri+"distributor/customer/options/"+urlencode(this.customer.custNo);if(a=="grid")window.location=this.app.BaseUri+"distributor/customer/grids/"+urlencode(this.customer.custNo);if(a=="home")window.location=this.app.BaseUri+"distributor/customer/view/"+urlencode(this.customer.custNo)}else if(this.salesperson){if(a=="options")window.location=this.app.BaseUri+"distributor/salesperson/options/"+urlencode(this.salesperson.salesNo);
if(a=="grid")window.location=this.app.BaseUri+"distributor/salesperson/grids/"+urlencode(this.salesperson.salesNo);if(a=="home")window.location=this.app.BaseUri+"distributor/salesperson/view/"+urlencode(this.salesperson.salesNo)}else{if(a=="options")window.location=this.app.BaseUri+"distributor/settings/options";if(a=="ads")window.location=this.app.BaseUri+"distributor/settings/ads";if(a=="grid")window.location=this.app.BaseUri+"distributor/settings/grids";if(a=="home")window.location=this.app.BaseUri+
"distributor/settings";if(a=="email")window.location=this.app.BaseUri+"distributor/settings/email";if(a=="tablet")window.location=this.app.BaseUri+"distributor/settings/tablet"}},setCustomerInfo:function(a){this.customer=a;this.accountId=a.accountId},setSalespersonInfo:function(a){this.salesperson=a;this.accountId=a.accountId}});
var RPT_FRM_NONE=32,RPT_FRM_HTML=1,RPT_FRM_PDF_P=2,RPT_FRM_PDF_L=4,RPT_FRM_XLS_97=8,RPT_FRM_XLS_07=16,RPT_FRM_ALL=65535,RPT_INVOICEDETAIL=1,RPT_INVOICESUMMARY=2,RPT_ORDERGUIDE=3,RPT_CONSUMPTION=4,RPT_INVTWORKSHEET=5,RPT_OPENBALANCES=6,RPT_SCANNEDINVOICES=7,RPT_PROSPECTGUIDE=8,RPT_PROSPECTLIST=9;NECS.page.common.Report=function(a,b){b=Ext.apply({innerLayout:"inner-layout"},b);NECS.page.common.Report.superclass.constructor.call(this,a,b)};
Ext.extend(NECS.page.common.Report,NECS.page.layout.Center,{layoutCenterEl:null,innerLayoutEl:null,activeConfigName:"",module:"customer",setModule:function(a){this.module=a},initializePage:function(){NECS.page.common.Report.superclass.initializePage.call(this);this.layoutCenterEl=Ext.get("layout-center");this.innerLayoutEl=Ext.get(this.config.innerLayout);this.initializeStores();this.initializeContainer()},resizePage:function(){var a,b;a=NECS.page.common.Report.superclass.resizePage.call(this);b=
this.layoutCenterEl.getComputedWidth();this.innerLayoutEl.setSize(b-12,this.layoutCenterEl.getComputedHeight()-10);this.container.getEl().dom.style.marginLeft=(b-this.container.width)/2+"px";this.container.setHeight(this.layoutCenterEl.getComputedHeight()-30);return a},initializeStores:function(){if(this.module=="customer"){this.reportList=[[RPT_INVOICESUMMARY,"Invoice Summary"],[RPT_INVOICEDETAIL,"Invoice Detail"],[RPT_ORDERGUIDE,"Order Guide / Product Listing"],[RPT_CONSUMPTION,"Item Consumption"],
[RPT_INVTWORKSHEET,"Inventory Worksheet"]];this.app.Options.ShowAR&&this.reportList.push([RPT_OPENBALANCES,"Open Balances"]);this.app.Options.ShowInvoiceScans&&this.reportList.push([RPT_SCANNEDINVOICES,"Scanned Invoices"])}else if(this.module=="salesperson"||this.module=="distributor")if(this.app.Options.ShowProspects)this.reportList=[[RPT_PROSPECTGUIDE,"Prospect Guide"],[RPT_PROSPECTLIST,"Prospect Listing"]];this.outputFormats=[];if(this.reportFormats&RPT_FRM_HTML)this.outputFormats[this.outputFormats.length++]=
[RPT_FRM_HTML,"Browser Window"];if(this.reportFormats&RPT_FRM_PDF_P)this.outputFormats[this.outputFormats.length++]=[RPT_FRM_PDF_P,"PDF (Portrait)"];if(this.reportFormats&RPT_FRM_PDF_L)this.outputFormats[this.outputFormats.length++]=[RPT_FRM_PDF_L,"PDF (Landscape)"];if(this.reportFormats&RPT_FRM_XLS_97)this.outputFormats[this.outputFormats.length++]=[RPT_FRM_XLS_97,"Excel 97 (.xls)"];if(this.reportFormats&RPT_FRM_XLS_07)this.outputFormats[this.outputFormats.length++]=[RPT_FRM_XLS_07,"Excel 2007 (.xlsx)"]},
initializeContainer:function(){this.edReportList=new Ext.form.ComboBox({width:250,forceSelection:true,triggerAction:"all",editable:false,selectOnFocus:true,emptyText:"Select a report",store:this.reportList,listeners:{scope:this,select:function(a,b){this.onReportSelected(b)}}});this.reportId&&this.edReportList.setValue(this.reportId);this.edOutputFormat=new Ext.form.ComboBox({width:120,forceSelection:true,triggerAction:"all",editable:false,selectOnFocus:true,emptyText:"Format",store:this.outputFormats});
this.laOutputFormat=new Ext.form.Label({text:"Format:"});this.edOutputFormat.setValue(RPT_FRM_HTML);this.dsReportConfig=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:this.app.RpcUtilityUri}),new NECS.rpc.JSON.Request("getReportConfigurations",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"report_configuration_id"},new Ext.data.Record.create(NECS.data.fields.ReportConfiguration)),remoteSort:false,sortInfo:{field:"report_configuration_id",direction:"ASC"}});
this.edReportConfig=new Ext.form.ComboBox({width:250,forceSelection:true,triggerAction:"all",mode:"local",editable:false,selectOnFocus:true,emptyText:"Select a configuration",valueField:"report_configuration_id",displayField:"name",store:this.dsReportConfig,listeners:{scope:this,select:function(a,b){this.onLoadConfiguration(b)}}});this.laReportConfig=new Ext.form.Label({text:"Configuration:"});this.btSaveConfig=new Ext.Button({text:"Save Configuration",iconCls:"icon-accept",tooltip:"Save this report configuration for future use",
scope:this,handler:function(){this.onSaveConfiguration()}});this.edConfigName=new Ext.form.TextField({width:200});this.btRunReport=new Ext.Button({text:"Run Report",tooltip:"Run this report with the current configuration",cls:"necs-btn-green",scope:this,handler:function(){this.onRunReport()}});this.tbTop=new Ext.Toolbar({ctCls:"necs-toolbar",listeners:{scope:this,render:function(a){a.addSpacer();a.addText("Select a report:");a.addSpacer();a.add(this.edReportList);a.addFill();a.add(this.laReportConfig);
a.addSpacer();a.add(this.edReportConfig);a.addSpacer()}}});this.tbBot=new Ext.Toolbar({ctCls:"necs-toolbar",listeners:{scope:this,render:function(a){a.addSpacer();a.add(this.edConfigName);a.addSpacer();a.add(this.btSaveConfig);a.addFill();if(this.reportFormats!=RPT_FRM_NONE){a.add(this.laOutputFormat);a.addSpacer();a.add(this.edOutputFormat);a.addSpacer()}a.add(this.btRunReport);a.addSpacer()}}});this.container=new Ext.Panel({title:"Reports",renderTo:this.innerLayoutEl,contentEl:this.config.contentEl,
width:920,frame:true,border:true,autoScroll:true,tbar:this.tbTop,bbar:this.tbBot})},setReportId:function(a,b){this.reportId=a;this.reportFormats=b},setConfigVisible:function(a){if(a){this.edReportConfig.show();this.laReportConfig.show()}else{this.edReportConfig.hide();this.laReportConfig.hide()}},setSaveConfigVisible:function(a){if(a){this.edConfigName.show();this.btSaveConfig.show()}else{this.edConfigName.hide();this.btSaveConfig.hide()}},setRunVisible:function(a){if(a){this.laOutputFormat.show();
this.edOutputFormat.show();this.btRunReport.show()}else{this.laOutputFormat.hide();this.edOutputFormat.hide();this.btRunReport.hide()}},getReportSettings:function(){return 3735928559},loadReportSettings:function(){},loadReportConfigs:function(){if(this.reportId){this.edReportConfig.store.load({params:{reportId:this.reportId,accountId:this.app.AccountId}});this.edReportConfig.setValue(this.defaultConfigName)}},onRunReport:function(){NECS.util.DisplayError("Run report method has not been implemented by this report. =(")},
onReportSelected:function(a){mask=new Ext.LoadMask(Ext.getBody(),{msg:"Loading "+a.data.field2+" report ..."});mask.show();window.location=this.app.BaseUri+this.module+"/report/setup/"+urlencode(a.data.field1)},onLoadConfiguration:function(a){this.mask=new Ext.LoadMask(Ext.getBody(),{msg:"Loading configuration "+a.data.name+" ..."});this.mask.show();a=new NECS.rpc.JSON.Request("getReportConfiguration",[a.data.report_configuration_id],1,function(b){if(b.error||!b.result)alert("complete: Server Communication Error.");
else if(b.result.success){this.configId=b.result.data.report_configuration_id;this.edConfigName.setValue(b.result.data.name);this.activeConfigName=b.result.data.name;this.loadReportSettings(Ext.util.JSON.decode(b.result.data.value));this.btSaveConfig.setDisabled(b.result.data.account_id==null);this.mask.hide();delete this.mask}else NECS.util.DisplayError(b.result.message)},this);this.mask.show();NECS.rpc.JSON.call(this.app.RpcUtilityUri,a)},onSaveConfiguration:function(){var a,b;if(a=this.edConfigName.getValue().trim())if(a==
this.defaultConfigName)NECS.util.DisplayError("This configuration name has been reserved. Please choose a different name.");else{b=this.getReportSettings();if(b==3735928559)NECS.util.DisplayError("Report settings method has not been implemented by this report.");else{delete b.StartDate;delete b.EndDate;var c=new Ext.LoadMask(Ext.getBody(),{msg:"Saving report configuration ..."});if(!this.configId)this.configId=null;b=[this.configId,this.reportId,this.app.AccountId,a,Ext.util.JSON.encode(b)];b=new NECS.rpc.JSON.Request("updateReportConfiguration",
b,1,function(d){if(d.error||!d.result)alert("complete: Server Communication Error.");else if(d.result.success){this.configId!=d.result.data.configId&&this.dsReportConfig.add(new new Ext.data.Record.create(NECS.data.fields.ReportConfiguration)({ReportConfigurationId:d.result.data.configId,Name:a}));this.configId=d.result.data.configId;c.hide()}else NECS.util.DisplayError(d.result.message)},this);c.show();NECS.rpc.JSON.call(this.app.RpcUtilityUri,b)}}else NECS.util.DisplayError("Please enter a name to save this report configuration as.")}});
Ext.namespace("NECS.page.distributor.common");NECS.page.distributor.common.Website=function(a,b){b=Ext.apply({subMenuEl:"sub-menu"},b);NECS.page.distributor.common.Website.superclass.constructor.call(this,a,b)};
Ext.extend(NECS.page.distributor.common.Website,NECS.page.layout.CenterWest,{accountId:null,customer:null,salesperson:null,subMenuEl:null,initializePage:function(){NECS.page.distributor.common.Website.superclass.initializePage.call(this);this.initializeSubMenu()},resizePage:function(){var a;a=NECS.page.distributor.common.Website.superclass.resizePage.call(this);this.subMenuEl.setHeight(a.height);return a},initializeSubMenu:function(){var a;a=Ext.get(this.config.subMenuEl);Ext.isIE7&&Ext.getCmp("layout-west").setWidth(85);
if(a){this.subMenuEl=a.createChild();new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">Content</div>',iconCls:"icon-content-24",iconAlign:"top",height:50,width:Ext.isIE7?64:50,boxMaxWidth:50,boxMinWidth:50,listeners:{scope:this,click:function(){this.buttonClick("content")}}});new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">Colors</div>',iconCls:"icon-palette-24",
iconAlign:"top",height:50,width:Ext.isIE7?64:50,listeners:{scope:this,click:function(){this.buttonClick("colors")}}});new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">Banner</div>',iconCls:"icon-slider-24",iconAlign:"top",height:50,width:Ext.isIE7?64:50,boxMaxWidth:50,boxMinWidth:50,listeners:{scope:this,click:function(){this.buttonClick("slider")}}});new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",
text:'<div style="padding-top: 5px">Social</div>',iconCls:"icon-social-24",iconAlign:"top",height:50,width:Ext.isIE7?64:50,boxMaxWidth:50,boxMinWidth:50,listeners:{scope:this,click:function(){this.buttonClick("api")}}});new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">&nbsp; BG &nbsp;</div>',iconCls:"icon-slider-24",iconAlign:"top",height:50,width:Ext.isIE7?64:50,boxMaxWidth:50,boxMinWidth:50,listeners:{scope:this,click:function(){this.buttonClick("bgeditor")}}});
new Ext.Button({renderTo:this.subMenuEl.createChild(),style:"margin-bottom: 5px",text:'<div style="padding-top: 5px">Email List</div>',iconCls:"icon-slider-24",iconAlign:"top",height:50,width:Ext.isIE7?64:50,boxMaxWidth:50,boxMinWidth:50,listeners:{scope:this,click:function(){this.buttonClick("emailwidget")}}})}else alert('Root element "'+this.config.subMenuEl+'" for page menu does not exist.')},buttonClick:function(a){if(a=="content")window.location=this.app.BaseUri+"distributor/site/content";if(a==
"colors")window.location=this.app.BaseUri+"distributor/site/colors";if(a=="slider")window.location=this.app.BaseUri+"distributor/site/slider";if(a=="api")window.location=this.app.BaseUri+"distributor/site/api";if(a=="bgeditor")window.location=this.app.BaseUri+"distributor/site/bgeditor";if(a=="emailwidget")window.location=this.app.BaseUri+"distributor/site/emailwidget"}});Ext.namespace("NECS.panel");
NECS.panel.SiteContentTreePanel=function(a){Ext.apply(this,a);NECS.panel.SiteContentTreePanel.superclass.constructor.call(this,{rootVisible:false,lines:false,autoScroll:true,root:new Ext.tree.TreeNode("Editable Content"),collapseFirst:false});this.getSelectionModel().on({beforeselect:function(){},selectionchange:function(b,c){c&&c.childNodes.length==0&&this.fireEvent("contentselect",c.attributes)},scope:this});this.addEvents({contentselect:true})};
Ext.extend(NECS.panel.SiteContentTreePanel,Ext.tree.TreePanel,{initialize:function(a){var b="",c;Ext.each(a,function(d){if(d.display_category!=b){b=d.display_category;c=this.root.appendChild(new Ext.tree.TreeNode({text:d.display_category,iconCls:"icon-folder",cls:"site-content-root-node",expanded:true}))}c.appendChild(new Ext.tree.TreeNode({iconCls:d.icon_cls,cls:"site-content-node",id:d.tag,text:d.link_title}))},this)}});Ext.namespace("NECS.panel");
NECS.panel.SiteContentEditPanel=function(a){Ext.apply(this,a);this.paTabs=new Ext.TabPanel({deferredRender:false,border:false});NECS.panel.SiteContentEditPanel.superclass.constructor.call(this,{items:[this.paTabs],border:false});this.on("render",function(){this.initializeToolbar();this.initializeTabPanel()},this)};
Ext.extend(NECS.panel.SiteContentEditPanel,Ext.Panel,{editRecord:null,btSave:null,tbContent:null,tbPhoto:null,laAlert:null,initializeToolbar:function(){var a=this.getTopToolbar();if(a){this.btSave=new Ext.Button({text:"Save Changes",tooltip:"Save Changes Made",scope:this,handler:function(){this.editRecord.Content=this.edContent.getValue();this.fireEvent("save",this.editRecord);this.clearDirty()}});a.add(this.btSave);a.addSpacer()}},initializeTabPanel:function(){this.edContent=new Ext.form.HtmlEditor({ctCls:"no-border",
listeners:{scope:this,keypressed:function(){this.setDirty()}}});this.tbContent=new Ext.Panel({title:"Content",layout:"fit",tabTip:"Click here to add or change content on this page",items:[this.edContent]});this.paTabs.add(this.tbContent);this.paTabs.setActiveTab(this.tbContent);this.tbPhoto=new Ext.Panel({title:"Photo",tabTip:"Click here to add or change an image on this page",border:false});this.frmFile=new Ext.form.FormPanel({baseCls:"x-plain",defaultType:"textfield",layout:"absolute",height:280,
fileUpload:true,items:[{x:5,y:5,xtype:"label",html:'<div style="border: 2px solid #cccccc; width: 250px; height: 250px;"><img id="content-image" src="" /></div>'},{x:290,y:15,xtype:"label",html:'Select a photo from one of the "Stock Photos" provided below or upload your own image. Supported image formats are JPEG, GIF and PNG.<br /><br />'},{x:290,y:60,xtype:"fileuploadfield",id:"PageImage",name:"PageImage",emptyText:"Select an image"},{xtype:"container",x:290,y:90,autoEl:{},items:{xtype:"button",
text:"Upload",scope:this,handler:function(){this.uploadImage()}}},{xtype:"hidden",id:"PageTag",name:"PageTag"}]});this.tbPhoto.add(this.frmFile);this.paStockImages=new NECS.panel.StockImagePanel({title:"Stock Photos",height:180,layout:"fit",autoScroll:true});this.paStockImages.load();this.tbPhoto.add(this.paStockImages);this.paTabs.add(this.tbPhoto);this.tbPhoto.on("activate",function(){this.frmFile.getForm().findField("PageImage").setWidth(350);var a=this.tbPhoto.getInnerHeight();a!=0&&this.paStockImages.setHeight(a-
this.frmFile.height)},this);Ext.EventManager.onWindowResize(function(){var a=this.tbPhoto.getInnerHeight();a!=0&&this.paStockImages.setHeight(a-this.frmFile.height)},this)},getRecord:function(){this.editRecord.Content=this.edContent.getValue();return this.editRecord},setContent:function(a){this.edContent.setValue("");this.editRecord=null;this.clearDirty();if(a){this.editRecord=a;this.edContent.setValue(a.Content);this.frmFile.getForm().findField("PageImage").setValue("");if(a.AllowImage){this.paTabs.unhideTabStripItem(this.tbPhoto);
var b=Ext.get("content-image");if(b)b.dom.src=a.Image}else this.paTabs.hideTabStripItem(this.tbPhoto);this.clearDirty();this.paTabs.setActiveTab(this.tbContent)}},uploadImage:function(){if(this.editRecord){var a;a=this.frmFile.getForm().findField("PageImage");if(a.getValue().trim()=="")NECS.util.DisplayInfo("Please select an image to upload.");else{a=this.frmFile.getForm().findField("PageTag");a.setValue(this.editRecord.Tag);this.frmFile.getForm().submit({url:NECS.application.BaseUri+"distributor/site/upload",
scope:this,success:function(b,c){b=Ext.util.JSON.decode(c.response.responseText);if(b.success){c=Ext.get("content-image");c.dom.src="";c.dom.src=b.Image+"?"+(new Date).getTime();this.editRecord.Image=b.Image;this.setDirty(true)}else NECS.util.DisplayError(b.message,"Image Upload Failed")},failure:function(b,c){b=Ext.util.JSON.decode(c.response.responseText);NECS.util.DisplayError(b.message,"Image Upload Failed")}})}}},selectStockPhoto:function(a){this.editRecord.Image=a;var b=Ext.get("content-image");
b.dom.src="";b.dom.src=a+"?"+(new Date).getTime();this.setDirty()},isDirty:function(){return this.isDirty},setDirty:function(){this.isDirty=true},clearDirty:function(){this.isDirty=false}});Ext.namespace("NECS.panel");NECS.panel.StockImagePanel=function(a){Ext.apply(this,a);this.initializeStore();this.initializeDataView();NECS.panel.StockImagePanel.superclass.constructor.call(this,{items:[this.dataView]})};
Ext.extend(NECS.panel.StockImagePanel,Ext.Panel,{isLoaded:false,initializeStore:function(){this.dsImages=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:NECS.application.RpcSiteUri}),new NECS.rpc.JSON.Request("getStockImageList",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"Image"},new Ext.data.Record.create([{name:"Image",type:"string"}]))})},initializeDataView:function(){this.template=new Ext.XTemplate('<div id="stockimagepanel-container">','<tpl for=".">',
'<div style="margin:5px; float: left; cursor: pointer;" onclick="gcb_SelectStockImage(\'{Image}\');">','<img width="150" height="150" src="{Image}" />',"</div>","</tpl>","</div>");this.dataView=new Ext.DataView({id:"stock-image-panel",store:this.dsImages,tpl:this.template,itemSelector:"div.stock-photo"})},load:function(){this.isLoaded||this.dsImages.load();this.isLoaded=true}});Ext.namespace("NECS.panel");
NECS.panel.AccountSettingsPanel=function(a){Ext.apply(this,a);NECS.panel.AccountSettingsPanel.superclass.constructor.call(this,{title:"Account Settings",autoScroll:true,border:true,animCollapse:false,collapsed:true,collapsible:true,titleCollapse:true,bbar:new Ext.Toolbar({ctCls:"necs-toolbar",items:[{xtype:"tbfill"},{xtype:"button",text:"Update Account",scope:this,handler:function(){this.updateAccount()}}]}),listeners:{scope:this,render:function(){this.initializeForm()}}})};
Ext.extend(NECS.panel.AccountSettingsPanel,Ext.Panel,{initializeForm:function(){if(this.accountInfo)this.form=new Ext.FormPanel({border:false,renderTo:this.body,cls:"pad20-form-group",items:[{xtype:"formgroup",title:"Password",autoHeight:true,defaultType:"textfield",layout:"form",items:[{name:"password",inputType:"password",fieldLabel:"Password"},{name:"password-confirm",inputType:"password",fieldLabel:"Password (Again)"}]},{xtype:"formgroup",title:"Timezone",autoHeight:true,defaultType:"textfield",
items:[{xtype:"label",html:"<p>This setting is used to adjust the display dates and times to match your location.<br /></p><br />"},{xtype:"combo",name:"timezone",store:NECS.TimezoneData,typeAhead:true,editable:false,width:250,forceSelection:true,triggerAction:"all",selectOnFocus:true,value:this.accountInfo.timezone}]},{xtype:"formgroup",title:"Date Filtered Standard Order",autoHeight:true,defaultType:"textfield",layout:"form",hidden:!(NECS.application.Options.FltStdOrd||false),labelWidth:300,items:[{xtype:"label",
html:'<p>The "Date Filtered Standard Order" is displayed as an additional guide option when placing an order. This version of the "Standard Order" will only display items that have been purchased in the last number of weeks specified here.<br /></p><br />'},{xtype:"checkbox",name:"dfsoDefault",store:NECS.TimezoneData,fieldLabel:'Use "Date Filtered Standard Order" as default guide',inputValue:"1",checked:(NECS.application.Preferences.dfsoDefault||"0")=="1"},{xtype:"combo",name:"dfsoWeeks",fieldLabel:"Show only items purchased in the last ",
mode:"local",lazyRender:true,triggerAction:"all",store:new Ext.data.ArrayStore({fields:["value","name"],data:[[1,"Week"],[2,"2 weeks"],[3,"3 weeks"],[4,"4 weeks"],[5,"5 weeks"],[6,"6 weeks"],[7,"7 weeks"],[8,"8 weeks"],[9,"9 weeks"],[10,"10 weeks"],[11,"11 weeks"],[12,"12 weeks"]]}),displayField:"name",valueField:"value",typeAhead:true,editable:false,width:250,forceSelection:true,selectOnFocus:true,value:NECS.application.Preferences.dfsoWeeks||6}]},{xtype:"formgroup",title:"Email Notifications",autoHeight:true,
defaultType:"textfield",items:[{xtype:"label",html:"<p>Order and system notifications will be sent to the adresses listed below.<br />You may provide multiple email addresses by separating them with a semicolon. (ex: jim@mycompany.com;mary@mycompany.com)<br /></p><br />"},{xtype:"textfield",name:"email",width:500,value:this.accountInfo.email}]}]});else this.body.update('The "accountInfo" has not been set for this panel; operation disabled.')},updateAccount:function(){var a=this.form.getForm().getValues(),
b=null;if(a.email.trim()=="")NECS.util.DisplayInfo("Please enter at least one email address.");else if(Ext.form.VTypes.multiemail(a.email,this)){if(a.password.trim()!==""){if(a.password!=a["password-confirm"]){NECS.util.DisplayInfo("The passwords you entered did not match.");return}if(a.password.indexOf(" ")>0){NECS.util.DisplayInfo("Passwords cannot contain spaces.");return}b=a.password.trim()}options={accountid:this.accountInfo.accountId,password:b,timezone:a.timezone,emailrcpt:a.email,preferences:{5012:a.dfsoDefault==
"1"?"1":"0",5013:this.form.getForm().findField("dfsoWeeks").getValue()}};var c=new Ext.LoadMask(this.getEl(),{msg:"Saving settings ..."});request=new NECS.rpc.JSON.Request("updateAccountSettings",[options],1,function(d){c.hide();if(d.error||!d.result)NECS.util.DisplayError("An error occured while attempting to save the account settings.");if(d.result.success)NECS.util.DisplayInfo("Account settings updated.","Notice");else d.result.message?NECS.util.DisplayError(d.result.message):NECS.util.DisplayError("An error occured while attempting to contact the server. Please try again.");
delete c},this);c.show();NECS.rpc.JSON.call(NECS.application.RpcUtilityUri,request)}else NECS.util.DisplayInfo('Please enter an email address in the form of "user@domain.com". If specifying multiple addresses separate them with a ";".')}});NECS.grid.ID_STANDARD=NECS.pref.COLS_STANDARD;NECS.grid.ID_DIST_SEARCH=NECS.pref.COLS_DIST_SEARCH;NECS.grid.ID_SEARCH=NECS.pref.COLS_SEARCH;NECS.grid.ID_QUICK=NECS.pref.COLS_QUICK;NECS.grid.ID_AR_HISTORY=NECS.pref.COLS_AR_HISTORY;NECS.grid.ID_ORD_VIEW=NECS.pref.COLS_ORD_VIEW;
NECS.grid.ID_ORD_MISSING=NECS.pref.COLS_ORD_MISSING;
NECS.grid.getDefaultColumns=function(a,b,c){var d;b=b.Options;d={active:null,available:null};if(a==NECS.grid.ID_STANDARD)d=NECS.grid.getDefaultColumns_StandardOrder(b,c);else if(a==NECS.grid.ID_SEARCH)d=NECS.grid.getDefaultColumns_Search(b,c);else if(a==NECS.grid.ID_DIST_SEARCH)d=NECS.grid.getDefaultColumns_DistSearch(b,c);else if(a==NECS.grid.ID_QUICK)d=NECS.grid.getDefaultColumns_Quick(b,c);else if(a==NECS.grid.ID_AR_HISTORY)d=NECS.grid.getDefaultColumns_ArHistory(b,c);else if(a==NECS.grid.ID_ORD_VIEW)d=
NECS.grid.getDefaultColumns_OrderView(b,c);else if(a==NECS.grid.ID_ORD_MISSING)d=NECS.grid.getDefaultColumns_OrderMissing(b,c);return d};
NECS.grid.getDefaultColumns_StandardOrder=function(a,b){var c;c=b?NECS.util.clone(NECS.grid.columns.item):NECS.grid.columns.item;b=[c.Menu];b.push(c.QtyOrdSpinner);if(!a||a.ShowItemImg)b.push(c.Image);b.push(c.ItemNo);if(!a||a.ShowOnHand)b.push(c.OnHand);b.push(c.Descrip);b.push(c.Class);if(!a||a.ShowBrand)b.push(c.Brand);b.push(c.Size);b.push(c.UnitMS);b.push(c.Weight);b.push(c.GuideCategory);b.push(c.Sequence);if(!a||a.ShowPrices){if(a&&a.SpUseMarkupPct){b.push(c.MarkupPct);b.push(c.BaseCost)}b.push(c.Price);
b.push(c.ExtAmount);c.ExtAmount.hidden=true}c.GuideCategory.hidden=true;if(!a||a.ShowItemLastInfo){if(!a||a.ShowPrices)b.push(c.LastPrice);b.push(c.LastQty);b.push(c.LastDate)}b.push(c.UPC);return{active:b,available:c}};
NECS.grid.getDefaultColumns_DistSearch=function(a){var b,c;c=NECS.util.clone(NECS.grid.columns.item);for(i in c)c[i].id="search-"+c[i].id;b=[c.Menu];if(!a||a.ShowItemImg)b.push(c.Image);b.push(c.ItemNo);b.push(c.Descrip);b.push(c.Class);b.push(c.Brand);b.push(c.Size);b.push(c.UnitMS);b.push(c.Weight);c.Price.hidden=true;c.ExtAmount.hidden=true;return{active:b,available:c}};
NECS.grid.getDefaultColumns_Search=function(a){var b,c;c=NECS.util.clone(NECS.grid.columns.item);for(i in c)c[i].id="search-"+c[i].id;b=[c.Menu];b.push(c.QtyOrdSpinner);if(!a||a.ShowItemImg)b.push(c.Image);b.push(c.ItemNo);if(!a||a.ShowOnHand)b.push(c.OnHand);b.push(c.Descrip);b.push(c.Class);if(!a||a.ShowBrand)b.push(c.Brand);b.push(c.Size);b.push(c.UnitMS);b.push(c.Weight);if(!a||a.ShowPrices){if(a&&a.SpUseMarkupPct){b.push(c.MarkupPct);b.push(c.BaseCost)}b.push(c.Price);b.push(c.ExtAmount);c.ExtAmount.hidden=
true}if(!a||a.ShowItemLastInfo){if(!a||a.ShowPrices)b.push(c.LastPrice);b.push(c.LastQty);b.push(c.LastDate)}b.push(c.UPC);return{active:b,available:c}};
NECS.grid.getDefaultColumns_Quick=function(a,b){var c;c=b?NECS.util.clone(NECS.grid.columns.item):NECS.grid.columns.item;b=[c.Menu];b.push(c.ItemNoEntry);b.push(c.QtyOrdSpinner);if(!a||a.ShowItemImg)b.push(c.Image);if(!a||a.ShowOnHand)b.push(c.OnHand);b.push(c.Descrip);b.push(c.Class);if(!a||a.ShowBrand)b.push(c.Brand);b.push(c.Size);b.push(c.UnitMS);b.push(c.Weight);if(!a||a.ShowPrices){if(a&&a.SpUseMarkupPct){b.push(c.MarkupPct);b.push(c.BaseCost)}b.push(c.Price);b.push(c.ExtAmount)}if(!a||a.ShowItemLastInfo){if(!a||
a.ShowPrices)b.push(c.LastPrice);b.push(c.LastQty);b.push(c.LastDate)}b.push(c.UPC);c.ExtAmount.hidden=true;for(col in c)c[col].sortable=false;return{active:b,available:c}};
NECS.grid.getDefaultColumns_ArHistory=function(a,b){var c;c=b?NECS.util.clone(NECS.grid.columns.paymentHistory):NECS.grid.columns.paymentHistory;b=[c.InvoiceDate,c.InvoiceNo,c.Status,c.InvoiceTotal,c.AmountPaid,c.Credit,c.InvoiceBalance,c.BalanceForward,c.DatePaid,c.RefNo];if(!a||a.ShowInvoiceScans)b.push(c.ScannedInvoice);return{active:b,available:c}};
NECS.grid.getDefaultColumns_OrderView=function(a,b){var c;c=b?NECS.util.clone(NECS.grid.columns.item):NECS.grid.columns.item;b=[c.Menu];if(!a||a.ShowItemImg)b.push(c.Image);b.push(c.ItemNo);b.push(c.Descrip);b.push(c.Class);if(!a||a.ShowBrand)b.push(c.Brand);b.push(c.Size);b.push(c.UnitMS);b.push(c.QtyOrd);b.push(c.QtyShip);b.push(c.WeightShip);if(!a||a.ShowPrices){b.push(c.Price);b.push(c.ExtAmount)}return{active:b,available:c}};
NECS.grid.getDefaultColumns_OrderMissing=function(a,b){var c=[];b=b?NECS.util.clone(NECS.grid.columns.item):NECS.grid.columns.item;for(i in b)b[i].id="search-"+b[i].id;c.push(b.QtyOrdSpinner);c.push(b.ItemNo);c.push(b.Descrip);c.push(b.Class);if(!a||a.ShowBrand)c.push(b.Brand);c.push(b.Size);c.push(b.UnitMS);c.push(b.Weight);if(!a||a.ShowPrices){if(a&&a.SpUseMarkupPct){c.push(b.MarkupPct);c.push(b.BaseCost)}c.push(b.Price);c.push(b.ExtAmount);b.ExtAmount.hidden=true}return{active:c,available:b}};
Ext.namespace("NECS.menu");NECS.menu.TabMenu=function(a){Ext.apply(this,a);NECS.menu.TabMenu.superclass.constructor.call(this)};
Ext.extend(NECS.menu.TabMenu,Ext.Component,{strip:null,activeTab:null,onRender:function(a,b){NECS.menu.TabMenu.superclass.onRender.call(this,a,b);this.strip=a.createChild({tag:"ul"});this.strip.addClass("x-tab-strip");this.strip.addClass("x-tab-strip-top");this.strip.addClass("necs-tab-strip");var c=new Ext.Template('<li id="{id}" class="{activeCls}">','<a class="x-tab-right href="#">','<em class="x-tab-left">','<span class="x-tab-strip-inner">','<span class="x-tab-strip-text"><span class="x-tabs-text">{title}</span>',
"</span>","</span>","</em>","</a>","</li>"),d,e;Ext.each(this.items,function(f){e=f.id==this.activeTab?"x-tab-strip-active":"";d=c.append(this.strip,{id:f.id,title:f.title,activeCls:e});f.disabled?Ext.fly(d).addClass("x-tab-strip-disabled"):Ext.fly(d).addClassOnOver("x-tab-strip-over")},this);this.strip.on("mousedown",this.onMouseDown,this)},onMouseDown:function(a){if(a.button==0){a.preventDefault();a=a.getTarget("li");this.fireEvent("tabclick",this,a);if(a&&a.id!=this.activeTab)if(!Ext.fly(a).hasClass("x-tab-strip-disabled")){this.activeTab&&
Ext.fly(this.activeTab).removeClass("x-tab-strip-active");Ext.fly(a).addClass("x-tab-strip-active");this.activeTab=a.id;this.fireEvent("tabchange",this,a)}}}});
NECS.panel.OnlineOrderPanel=Ext.extend(NECS.grid.GridPanel,{initComponent:function(){this.store=new Ext.data.Store({proxy:new NECS.data.JsonRpcProxy(new Ext.data.Connection({url:NECS.application.RpcOrderUri}),new NECS.rpc.JSON.Request("getFilteredOnlineOrders",[],1)),reader:new NECS.data.JsonRpcReader({root:"data",id:"order_id",totalProperty:"total"},NECS.data.records.OrderHeader),sortInfo:{field:"created",direction:"DESC"},remoteSort:true});this.action=new Ext.ux.grid.RowActions({header:"&nbsp;",
id:"action",autoWidth:true,hideMode:"display",keepSelection:true,fixed:true,actions:[{iconIndex:"RowActionImageClass",iconCls:"",tooltip:"View Order"}]});cols=NECS.grid.columns.order;this.columns=[this.action,cols.CustNo,cols.Status,cols.DeliveryDate,cols.EstTotal,cols.OrderNo,cols.InvoiceNo,cols.PurchNo,cols.SalesNo,cols.Created,cols.Completed,cols.Confirmed];Ext.apply(this,{id:"recent-order-panel",ctCls:"necs-grid",stripeRows:true,height:250,title:"Orders",loadMask:{msg:"Loading order history ...."},
sm:new Ext.grid.RowSelectionModel({singleSelect:true}),bbar:new Ext.PagingToolbar({store:this.store,pageSize:NECS.application.ResultsPerPage,displayInfo:true,displayMsg:"Items {0} - {1} of {2}",emptyMsg:"No items to display"}),viewConfig:{forceFit:true,emptyText:'<div align="center" style="color: #363636; font-weight: bold; !important">There are no online orders in the system.</div>',deferEmptyText:false,getRowClass:function(a){if(!a.data.completed)return"row-order-open";return a.data.sales_no!==
""?"row-salesperson":"row-customer"}},plugins:[this.action]});NECS.panel.OnlineOrderPanel.superclass.initComponent.call(this);this.on("rowdblclick",function(a,b){a=this.store.getAt(b);a.get("completed").trim()!==""?this.fireEvent("view",a,b):this.fireEvent("edit",a,b)},this);this.action.on("action",function(a,b,c,d){if(c=="icon-order-view")this.fireEvent("view",b,d);else c=="icon-order-edit"&&this.fireEvent("edit",b,d)},this)},load:function(){this.store.load({params:{start:0,limit:NECS.application.ResultsPerPage,
sort:"created",dir:"DESC",filter:[]}})}});Ext.ns("Ext.ux.grid");if("function"!==typeof RegExp.escape)RegExp.escape=function(a){if("string"!==typeof a)return a;return a.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g,"\\$1")};Ext.ux.grid.RowActions=function(a){Ext.apply(this,a);this.addEvents("beforeaction","action","beforegroupaction","groupaction");Ext.ux.grid.RowActions.superclass.constructor.call(this)};
Ext.extend(Ext.ux.grid.RowActions,Ext.util.Observable,{actionEvent:"click",autoWidth:true,dataIndex:"",editable:false,header:"",isColumn:true,keepSelection:false,menuDisabled:true,sortable:false,tplGroup:'<tpl for="actions"><div class="ux-grow-action-item<tpl if="\'right\'===align"> ux-action-right</tpl> {cls}" style="{style}" qtip="{qtip}">{text}</div></tpl>',tplRow:'<div class="ux-row-action"><tpl for="actions"><div class="ux-row-action-item {cls} <tpl if="text">ux-row-action-text</tpl>" style="{hide}{style}" qtip="{qtip}"><tpl if="text"><span qtip="{qtip}">{text}</span></tpl></div></tpl></div>',
hideMode:"visibility",widthIntercept:4,widthSlope:21,init:function(a){this.grid=a;this.id=this.id||Ext.id();var b=a.getColumnModel().lookup;delete b[undefined];b[this.id]=this;if(!this.tpl)this.tpl=this.processActions(this.actions);if(this.autoWidth){this.width=this.widthSlope*this.actions.length+this.widthIntercept;this.fixed=true}var c=a.getView(),d={scope:this};d[this.actionEvent]=this.onClick;a.afterRender=a.afterRender.createSequence(function(){c.mainBody.on(d);a.on("destroy",this.purgeListeners,
this)},this);if(!this.renderer)this.renderer=function(e,f,h,j,g,m){f.css+=(f.css?" ":"")+"ux-row-action-cell";return this.tpl.apply(this.getData(e,f,h,j,g,m))}.createDelegate(this);if(c.groupTextTpl&&this.groupActions){c.interceptMouse=c.interceptMouse.createInterceptor(function(e){if(e.getTarget(".ux-grow-action-item"))return false});c.groupTextTpl='<div class="ux-grow-action-text">'+c.groupTextTpl+"</div>"+this.processActions(this.groupActions,this.tplGroup).apply()}if(true===this.keepSelection)a.processEvent=
a.processEvent.createInterceptor(function(e,f){if("mousedown"===e)return!this.getAction(f)},this)},getData:function(a,b,c){return c.data||{}},processActions:function(a,b){var c=[];Ext.each(a,function(d){if(d.iconCls&&"function"===typeof(d.callback||d.cb)){this.callbacks=this.callbacks||{};this.callbacks[d.iconCls]=d.callback||d.cb}c.push({cls:d.iconIndex?"{"+d.iconIndex+"}":d.iconCls?d.iconCls:"",qtip:d.qtipIndex?"{"+d.qtipIndex+"}":d.tooltip||d.qtip?d.tooltip||d.qtip:"",text:d.textIndex?"{"+d.textIndex+
"}":d.text?d.text:"",hide:d.hideIndex?'<tpl if="'+d.hideIndex+'">'+("display"===this.hideMode?"display:none":"visibility:hidden")+";</tpl>":d.hide?"display"===this.hideMode?"display:none":"visibility:hidden;":"",align:d.align||"right",style:d.style?d.style:""})},this);a=new Ext.XTemplate(b||this.tplRow);return new Ext.XTemplate(a.apply({actions:c}))},getAction:function(a){var b=false;if(a=a.getTarget(".ux-row-action-item"))if(b=a.className.replace(/ux-row-action-item /,"")){b=b.replace(/ ux-row-action-text/,
"");b=b.trim()}return b},onClick:function(a,b){var c=this.grid.getView(),d=a.getTarget(".x-grid3-row"),e=c.findCellIndex(b.parentNode.parentNode),f=this.getAction(a);if(false!==d&&false!==e&&false!==f){var h=this.grid.store.getAt(d.rowIndex);this.callbacks&&"function"===typeof this.callbacks[f]&&this.callbacks[f](this.grid,h,f,d.rowIndex,e);if(true!==this.eventsSuspended&&false===this.fireEvent("beforeaction",this.grid,h,f,d.rowIndex,e))return;else true!==this.eventsSuspended&&this.fireEvent("action",
this.grid,h,f,d.rowIndex,e)}if(t=a.getTarget(".ux-grow-action-item")){a=(f=c.findGroup(b))?f.id.replace(/ext-gen[0-9]+-gp-/,""):null;var j;if(a){var g=new RegExp(RegExp.escape(a));j=(j=this.grid.store.queryBy(function(m){return m._groupId.match(g)}))?j.items:[]}f=t.className.replace(/ux-grow-action-item (ux-action-right )*/,"");"function"===typeof this.callbacks[f]&&this.callbacks[f](this.grid,j,f,a);if(true!==this.eventsSuspended&&false===this.fireEvent("beforegroupaction",this.grid,j,f,a))return false;
this.fireEvent("groupaction",this.grid,j,f,a)}}});Ext.reg("rowactions",Ext.ux.grid.RowActions);if(typeof Range!=="undefined"&&typeof Range.prototype.createContextualFragment=="undefined")Range.prototype.createContextualFragment=function(a){var b=this.startContainer.ownerDocument,c=b.createElement("div");c.innerHTML=a;for(a=b.createDocumentFragment();b=c.firstChild;)a.appendChild(b);return a};
Ext.override(Ext.grid.HeaderDragZone,{getDragData:function(a){if((a=this.view.findHeaderCell(Ext.lib.Event.getTarget(a)))&&this.grid.colModel.config[this.view.getCellIndex(a)].dragable!==false)return{ddel:a.firstChild,header:a};return false}});Ext.override(Ext.tree.DefaultSelectionModel,{init:function(a){this.tree=a;a.mon(a.getTreeEl(),"keydown",this.onKeyDown,this);a.on("click",this.onNodeClick,this)},onNodeClick:function(a){this.select(a)}});
Ext.override(Ext.CompositeElement,{getTextWidth:function(){var a,b,c=this.elements,d=0;for(a=0;b=Ext.get(c[a]);a++)d=Math.max(d,b.getTextWidth.apply(b,arguments));return d}});
Ext.override(Ext.grid.GridPanel,{autoSizeColumns:function(){this.colModel.suspendEvents();for(var a=0;a<this.colModel.getColumnCount();a++)this.autoSizeColumn(a);this.colModel.resumeEvents();this.view.refresh(true)},autoSizeColumn:function(a){var b=this.view.el.select("td.x-grid3-td-"+this.colModel.getColumnId(a)+" div:first-child");if(b){b=b.getTextWidth()+Ext.get(b.elements[0]).getFrameWidth("lr")+2;this.colModel.setColumnWidth(a,b);return b}}});
Ext.apply(Ext.form.VTypes,{multiemail:function(a){a=a.split(";");var b=true;Ext.each(a,function(c){if(!this.email(c))return b=false},this);return b},multiemailText:'This field should be an e-mail address, or a list of email addresses separated by semicolons(;) in the format "user@domain.com;test@test.com"',multiemailMask:/[a-z0-9_.-@;]/i});
Ext.override(Ext.grid.RowSelectionModel,{handleMouseDown:function(a,b,c){if(!(c.button!==0||this.isLocked())){a=this.grid.getView();if(c.shiftKey&&!this.singleSelect&&this.last!==false){var d=this.last;this.selectRange(d,b,c.ctrlKey);this.last=d;this.preventGridViewFocus||a.focusRow(b)}else{d=this.isSelected(b);if(c.ctrlKey&&d)this.deselectRow(b);else if(!d||this.getCount()>1){this.selectRow(b,c.ctrlKey||c.shiftKey);this.preventGridViewFocus||a.focusRow(b)}}}}});
Ext.override(Ext.form.HtmlEditor,{initEditor:function(){try{var a=this.getEditorBody(),b=this.el.getStyles("font-size","font-family","background-image","background-repeat");b["background-attachment"]="fixed";a.bgProperties="fixed";Ext.DomHelper.applyStyles(a,b);if(this.doc)try{Ext.EventManager.removeAll(this.doc)}catch(c){}this.doc=this.getDoc();Ext.EventManager.on(this.doc,{mousedown:this.onEditorEvent,dblclick:this.onEditorEvent,click:this.onEditorEvent,keyup:this.onEditorEvent,buffer:100,scope:this});
if(Ext.isGecko){Ext.EventManager.on(this.doc,"keypress",this.applyCommand,this);Ext.EventManager.on(this.doc,"keypress",function(){this.fireEvent("keypressed")},this)}else{Ext.EventManager.on(this.doc,"keydown",this.fixKeys,this);Ext.EventManager.on(this.doc,"keydown",function(){this.fireEvent("keypressed")},this)}this.initialized=true;this.fireEvent("initialize",this);this.doc.editorInitialized=true;this.pushValue()}catch(d){}}});
Ext.override(Ext.ToolTip,{adjustPosition:function(a,b){var c=Ext.get(document.body),d=c.getScroll(),e=c.getWidth()-5,f=c.getHeight()-5;c=d.left+5;e=d.left+e;var h=d.top+5;d=d.top+f;f=this.body.getTextWidth();if(this.title)f=Math.max(f,this.header.child("span").getTextWidth(this.title));f+=this.getFrameWidth()+(this.closable?20:0)+this.body.getPadding("lr");var j=this.getInnerHeight()+this.getFrameHeight()+this.body.getPadding("tb");if(a+f>e)a=e-f;if(b+j>d)b=d-j;if(a<c)a=c;if(b<h)b=h;c=this.targetXY[1];
e=this.getSize().height;if(this.constrainPosition&&b<=c&&b+e>=c)b=c-e-5;return{x:a,y:b}}});Ext.override(Ext.Component,{stateful:false});
Ext.override(Ext.data.Store,{sortByFields:function(a){for(var b=[],c=0;c<a.length;c++){if(typeof a[c]=="string")a[c]={field:a[c],direction:"ASC"};b.push(this.fields.get(a[c].field).sortType)}c=function(d,e){for(var f,h=0;!f&&h<a.length;h++){f=b[h](d.data[a[h].field]);var j=b[h](e.data[a[h].field]);f=f>j?1:f<j?-1:0;if(a[h].direction=="DESC")f=-f}return f};this.data.sort("ASC",c);this.snapshot&&this.snapshot!=this.data&&this.snapshot.sort("ASC",c);this.fireEvent("datachanged",this)}});Ext.ns("Ext.ux.grid");
Ext.ux.grid.CheckColumn=function(a){Ext.apply(this,a);if(!this.id)this.id=Ext.id();this.renderer=this.renderer.createDelegate(this)};
Ext.ux.grid.CheckColumn.prototype={init:function(a){this.grid=a;this.grid.on("render",function(){this.grid.getView().mainBody.on("mousedown",this.onMouseDown,this)},this)},onMouseDown:function(a,b){if(Ext.fly(b).hasClass(this.createId())){a.stopEvent();a=this.grid.getView().findRowIndex(b);b=this.grid.store.getAt(a);b.set(this.dataIndex,!b.data[this.dataIndex]);typeof this.onCheck=="function"&&this.onCheck.call(this,b.data[this.dataIndex],b,a)}},renderer:function(a,b){b.css+=" x-grid3-check-col-td";
return String.format('<div class="x-grid3-check-col{0} {1}">&#160;</div>',a?"-on":"",this.createId())},createId:function(){return"x-grid3-cc-"+this.id}};Ext.preg("checkcolumn",Ext.ux.grid.CheckColumn);
Ext.grid.CheckColumn=function(a){this.addEvents({click:true});Ext.grid.CheckColumn.superclass.constructor.call(this);Ext.apply(this,a,{init:function(b){this.grid=b;this.grid.on("render",function(){this.grid.getView().mainBody.on("mousedown",this.onMouseDown,this)},this)},onMouseDown:function(b,c){if(c.className&&c.className.indexOf("x-grid3-cc-"+this.id)!=-1){b.stopEvent();c=this.grid.getView().findRowIndex(c);var d=this.grid.store.getAt(c),e=d.data[this.dataIndex];e=e?true:false;d.set(this.dataIndex,
!e);this.fireEvent("checked",this,b,d.data[this.dataIndex],d,c)}},renderer:function(b,c){c.css+=" x-grid3-check-col-td";return'<div class="x-grid3-check-col'+(b?"-on":"")+" x-grid3-cc-"+this.id+'"> </div>'}});if(!this.id)this.id=Ext.id();this.renderer=this.renderer.createDelegate(this)};Ext.extend(Ext.grid.CheckColumn,Ext.util.Observable);

