/*
 * Profile scripts 0.1
 * Copyright(c) 2008, Conduit IT.
 * 
 */


Ext.QuickTips.init();Ext.form.Field.prototype.msgTarget="side";Ext.namespace("profiles","profiles.tab","profiles.comps");
profiles.Application=Ext.extend(Ext.Panel,{autoHeight:true,border:false,active_tab:0,url:"json.php?target=user&area=C",redirect_url:"",payInvoiceUrl:"",orderTabConfig:false,user_type:"customer",mode:"add",validation_style:"side",initComponent:function(){this.items=[{xtype:"profiles.TabPanel",activateTab:this.active_tab,user_type:this.user_type,mode:this.mode,validation_style:this.validation_style,redirect_url:this.redirect_url,payInvoiceUrl:this.payInvoiceUrl,orderTabConfig:this.orderTabConfig}];profiles.Application.superclass.initComponent.call(this);},initEvents:function(){profiles.Application.superclass.initEvents.call(this);}});Ext.reg("profiles.Application",profiles.Application);
profiles.TabPanel=Ext.extend(Ext.TabPanel,{activeTab:0,activateTab:0,autoHeight:true,plain:true,layoutOnTabChange:true,deferredRender:true,defaults:{autoScroll:false,autoHeight:true},url:"json.php?target=user&area=C",order_url:"json.php?target=order&area=C",redirect_url:"",payInvoiceUrl:"",orderTabConfig:false,user_type:"customer",mode:"add",validation_style:"side",_tabMgr:{},__tabIdRefs:{"my_equipment":"profile_my_equipment_tab","customer_info":"profile_customer_info_tab","customer_logo":"profile_customer_logo_tab","address_book":"profile_address_book_tab","password":"profile_password","bookmarks":"profile_bookmark_tab"},initComponent:function(){this._tabMgr={};var _1=[];this._tabMgr["profile_customer_info"]=true;var _2=ProfileCustomerInfoLang.message.headerText;if(this.user_type=="dealer"){_2=ProfileCustomerInfoLang.message.dealerHeaderText;}
if(this._validHeaderText(_2)){_1.push({xtype:"panel",border:false,cls:"wse-custtxt-hld",html:"<div class=\"wse-custtxt\"><div class=\"wse-contentblock\">"+_2+"</div></div>"});}
_1.push({xtype:"profiles.tab.customerInfo",id:this.id+"-customer-form",validation_style:this.validation_style,user_type:this.user_type,mode:this.mode,redirect_url:this.redirect_url,cls:"wse-tab-cont wse-tab-cont-info"});this.items=[{xtype:"panel",id:"profile_customer_info_tab",cls:"wse-tab wse-tab-info",border:false,title:ProfileMainLang.title.infoTab,items:_1}];profiles.TabPanel.superclass.initComponent.call(this);},initEvents:function(){this.on("afterlayout",this.initializeTabs,this,{single:true,delay:250});profiles.TabPanel.superclass.initEvents.call(this);},initializeTabs:function(){Ext.getCmp(this.id+"-customer-form").initializeForm();if(this.mode=="update"){if(AccountConfig.limited_access=="Y"&&AccountConfig.show_my_equipment=="Y"){this.addTab("profile_my_equipment_tab",true);this.setActiveTab("profile_my_equipment_tab");this.hideTabStripItem("profile_customer_info_tab");}else{if(AccountConfig.profile_child_accounts_enable=="Y"){this.addTab("profile_child_accounts_tab");}
if(AccountConfig.profile_customer_logo_enable=="Y"){this.addTab("profile_customer_logo_tab");}
if(AccountConfig.profile_address_book_enable!="N"){this.addTab("profile_address_book_tab");}
this.addTab("profile_password");if(AccountConfig.profile_bookmark_enable=="Y"){this.addTab("profile_bookmark_tab");}
if(AccountConfig.show_my_equipment=="Y"){this.addTab("profile_my_equipment_tab");}
if(AccountConfig.show_rebates_tab=="Y"){this.addTab("profile_my_rebates");}
if(this.activateTab!=0){this.setActiveTab(this._getInitTab());this.on("tabchange",this.forceTabLayout,this);}
this.attemptAddOrderTypeTabs();}}},forceTabLayout:function(_3,_4){if(_4.id==this.activeTab.id){switch(_4.id){case"profile_customer_info_tab":Ext.getCmp(this.id+"-customer-form").forceLayout();break;default:break;}}},addTab:function(_5,_6){if(!this._tabMgr[_5]){this._tabMgr[_5]=true;switch(_5){case"profile_child_accounts_tab":this._validateAddTab("profiles.tab.childAccounts",_5,ProfileMainLang.title.childAccounts,ProfileChildAccountLang.message.headerText,_6,"chldAcct");break;case"profile_customer_logo_tab":this._validateAddTab("profiles.tab.customerLogo",_5,ProfileMainLang.title.customerLogo,ProfileCustomerLogoLang.message.headerText,_6,"cstLogo");break;case"profile_address_book_tab":this._validateAddTab("profiles.tab.addressBook",_5,ProfileMainLang.title.addressBook,ProfileAddressBookLang.message.headerText,_6,"addrbk");break;case"profile_password":this._validateAddTab("profiles.tab.password",_5,ProfileMainLang.title.password,ProfilePasswordLang.message.headerText,_6,"pswd");break;case"profile_bookmark_tab":this._validateAddTab("profiles.tab.myBookmarks",_5,ProfileMainLang.title.myBookmarks,ProfileMyBookmarksLang.message.headerText,_6,"bkmrk");break;case"profile_my_equipment_tab":this._validateAddTab("profiles.tab.myEquipment",_5,ProfileMainLang.title.myEquipment,ProfileMyEquipmentLang.message.headerText,_6,"myeqp");break;case"profile_my_rebates":this._validateAddTab("profiles.tab.myRebates",_5,ProfileMainLang.title.myRebates,ProfileMyRebatesLang.message.headerText,_6,"myrbt");break;default:break;}}},_validateAddTab:function(_7,_8,_9,_a,_b,_c){var _d=[];if(this._validHeaderText(_a)){_d.push({xtype:"panel",cls:"wse-custtxt-hld",border:false,html:"<div class=\"wse-custtxt\"><div class=\"wse-contentblock\">"+_a+"</div></div>"});}
_d.push({xtype:_7,autoHeight:true,cls:"wse-tab-cont wse-tab-cont-"+_c});if(_b){this.insert(0,{xtype:"panel",id:_8,border:false,title:_9,items:_d});}else{this.add({xtype:"panel",cls:"wse-tab wse-tab-"+_c,id:_8,border:false,title:_9,items:_d});}},_validHeaderText:function(_e){if(_e&&_e.trim()!="<br />"&&_e.trim()!="<br />"){return true;}
return false;},attemptAddOrderTypeTabs:function(){if(this.orderTabConfig){this._handleAttemptAddOrderTypeTabs(this.orderTabConfig);}else{Ext.Ajax.request({url:this.order_url+"&method=getAccountDisplayOrderTypes",scope:this,callback:this.handleAttemptAddOrderTypeTabs});}},handleAttemptAddOrderTypeTabs:function(_f,_10,_11){responseText=Ext.util.JSON.decode(_11.responseText);this._handleAttemptAddOrderTypeTabs(responseText);},_handleAttemptAddOrderTypeTabs:function(_12){for(var i in _12.data){if(_12.data[i].code&&_12.data[i].columns.length){var _14=[];if(this._validHeaderText(_12.data[i].tab_text)){_14.push({xtype:"panel",cls:"wse-custtxt-hld",border:false,html:"<div class=\"wse-custtxt\"><div class=\"wse-contentblock\">"+_12.data[i].tab_text+"</div></div>"});}
_14.push({xtype:"profiles.tab.orderTypeDisplay",autoHeight:true,cls:"wse-tab-cont wse-tab-cont-ordrs",orderType:_12.data[i].code,usePicklistFunctionality:_12.data[i].use_picklist_functionality,allow_export:_12.data[i].allow_export=="Y"?true:false,allow_pagination:_12.data[i].allow_pagination=="Y"?true:false,max_export_size:_12.data[i].max_export_size,pagination_size:_12.data[i].pagination_size,allow_page_size_combo:_12.data[i].allow_page_size_combo=="Y"?true:false,allow_open_date_search:_12.data[i].allow_open_date_search=="Y"?true:false,storeFields:(Ext.isArray(_12.data[i].store_fields)?_12.data[i].store_fields:[]),avail_columns:_12.data[i].columns,avail_search_fields:_12.data[i].search_fields,orderSelectOption:_12.data[i].open_detail_option,defaultPaymentStatusId:_12.data[i].default_payment_status_id,allowPayInvoices:((this.payInvoiceUrl&&_12.data[i].allow_pay_invoices=="Y")?true:false),excludeZeroPayInvoices:((_12.data[i].exclude_zero_total_outstanding=="Y")?true:false),payInvoiceLimitField:_12.data[i].pay_invoices_same_order_map_field,payInvoiceUrl:this.payInvoiceUrl,searchPanelTitle:_12.data[i].search_panel_title,remoteSort:(_12.data[i].remote_sort=="Y"?true:false),defaultSort:(_12.data[i].default_sort?_12.data[i].default_sort:false),lineItemDisplayIncluded:((_12.data[i].include_line_item_display=="Y")?true:false),doNotAutoload:(_12.data[i].do_not_autoload_grid=="Y"?true:false),displayTotal:(_12.data[i].display_total=="Y"?true:false)});this.add({xtype:"panel",cls:"wse-tab wse-tab-ordrs",id:_12.data[i].code,border:false,title:_12.data[i].tab_title,items:_14});}}
var pnl=this._getInitTab();if(pnl){this.setActiveTab(pnl);}},_getInitTab:function(){if(this.activateTab){var pnl,id=this.activateTab;if(this.__tabIdRefs[id]){id=this.__tabIdRefs[id];}
pnl=this.findById(id);if(!pnl){}
if(pnl){this.activateTab=0;return pnl;}}
return 0;}});Ext.reg("profiles.TabPanel",profiles.TabPanel);
profiles.tab.customerInfo=Ext.extend(Ext.Panel,{autoHeight:true,frame:false,border:false,user_type:"customer",mode:"add",validation_style:"side",redirect_url:"",cls:"wse-tab-cont wse-tab-cont-info",initComponent:function(){this.items=[{id:this.id+"-form",xtype:"profiles.comps.addressForm",validation_style:this.validation_style,user_type:this.user_type,mode:this.mode,redirect_url:this.redirect_url,cls:this.cls,listeners:{"saveSuccessful":{fn:this.saveSuccess,scope:this}}}];profiles.tab.customerInfo.superclass.initComponent.call(this);},initEvents:function(){profiles.tab.customerInfo.superclass.initEvents.call(this);},initializeForm:function(){Ext.getCmp(this.id+"-form").initializeForm();},saveSuccess:function(){return;}});Ext.reg("profiles.tab.customerInfo",profiles.tab.customerInfo);
profiles.tab.childAccounts=Ext.extend(Ext.Panel,{autoHeight:true,border:false,gridHeight:200,_columnWidth:0.47,componentWidth:210,bodyStyle:"padding: 20px 20px 0 20px",labelAlign:"left",buttonAlign:"left",validation_style:"side",url:"json.php?target=user",children_store_method:"&method=getAccountChildren",_showDataMappings:false,_showMemberships:false,eventCompleteCount:0,eventFireCount:0,initComponent:function(){this.childrenStore=new Ext.data.JsonStore({url:this.url+this.children_store_method,root:"data",autoLoad:true,fields:["user_id","membership_id","company","name","user_login","cit_account_number","email","phone","last_login"]});this.eventFireCount++;var _1=[{id:this.id+"-update-form",columnWidth:this._columnWidth,xtype:"profiles.comps.addressForm",validation_style:this.validation_style,user_type:"customer",mode:"update",componentWidth:this.componentWidth,redirectOnSave:false,requireNewAccountTermsCheck:false,childAccount:true,listeners:{"saveInitiated":{fn:this.updateSaveInitiated,scope:this},"saveSuccessful":{fn:this.updateSaveSuccess,scope:this}}}];var _2=[];if(AccountConfig.profile_child_accounts_enable_data_mappings=="Y"){this.eventFireCount++;this._showDataMappings=true;_2.push({id:this.id+"-data-mapping-form",childAccount:true,xtype:"profiles.comps.dataMappingForm",listeners:{"saveSuccessful":{fn:this.updateSaveSuccess,scope:this}}});}
if(AccountConfig.profile_child_accounts_enable_membership=="Y"){this.eventFireCount++;this._showMemberships=true;_2.push({id:this.id+"-membership-form",childAccount:true,xtype:"profiles.comps.membershipForm",listeners:{"saveSuccessful":{fn:this.updateSaveSuccess,scope:this}}});}
if(_2.length>=1){_1.push({xtype:"panel",border:false,columnWidth:this._columnWidth,items:_2});}
this.items=[{xtype:"grid",id:this.id+"-children-grid",cls:"ws-account-grid",height:this.gridHeight,store:this.childrenStore,autoExpandColumn:"user_login",enableColumnMove:false,enableHdMenu:false,width:"100%",columns:[{header:ProfileCustomerInfoLang.label.userName,dataIndex:"user_login",id:this.id+"-child-user-login",width:this.dealerColumnWidth,hidden:(AccountConfig.email_as_login=="Y")?true:false},{header:ProfileCustomerInfoLang.label.name,dataIndex:"name",id:this.id+"-child-name"},{header:ProfileCustomerInfoLang.label.company,dataIndex:"company"},{header:ProfileCustomerInfoLang.label.email,dataIndex:"email",id:this.id+"-child-email"},{header:ProfileCustomerInfoLang.label.phone,dataIndex:"phone"},{header:ProfileCustomerInfoLang.label.lastLogin,dataIndex:"last_login"}],viewConfig:{emptyText:ProfileCustomerInfoLang.message.childAccountsEmpty,forceFit:true},sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:this._updateHandler.createDelegate(this)}})},{xtype:"panel",id:this.id+"-btn-panel",border:false,height:35,cls:"ws-account-btn-bar",items:[{xtype:"button",text:ProfileCustomerInfoLang.button.addNew,cls:"wse-xbtn wse-xbtn-save",id:this.id+"-add-new-btn",handler:this._addNewHandler,scope:this}]},{xtype:"panel",id:this.id+"-create-wrapper",layout:"column",hidden:true,items:[{id:this.id+"-create-form",columnWidth:this._columnWidth,xtype:"profiles.comps.addressForm",validation_style:this.validation_style,user_type:"customer",mode:"add",componentWidth:this.componentWidth,redirectOnSave:true,redirectActive:"profile_child_accounts_tab",requireNewAccountTermsCheck:false,childAccount:true,listeners:{"saveSuccessful":{fn:this.addSaveSuccess,scope:this}}},{id:this.id+"-create-child-disclaimer",bodyStyle:this.bodyStyle,columnWidth:this._columnWidth,xtype:"panel",border:false,html:ProfileChildAccountLang.message.addAccountDisclaimer}]},{xtype:"panel",id:this.id+"-update-wrapper",layout:"column",hidden:true,items:_1}];profiles.tab.childAccounts.superclass.initComponent.call(this);},initEvents:function(){profiles.tab.childAccounts.superclass.initEvents.call(this);},_addNewHandler:function(){Ext.getCmp(this.id+"-add-new-btn").hide();Ext.getCmp(this.id+"-update-wrapper").hide();Ext.getCmp(this.id+"-create-wrapper").show();Ext.getCmp(this.id+"-create-form").initializeForm();try{this.doLayout();}
catch(e){}},_updateHandler:function(sm,_4,_5){Ext.getCmp(this.id+"-add-new-btn").show();Ext.getCmp(this.id+"-create-wrapper").hide();Ext.getCmp(this.id+"-update-wrapper").show();Ext.getCmp(this.id+"-update-form").initializeForm(_5.data.user_id);if(this._showDataMappings){Ext.getCmp(this.id+"-data-mapping-form").initializeForm(_5.data.user_id);}
if(this._showMemberships){Ext.getCmp(this.id+"-membership-form").initializeForm(_5.data.user_id,_5.data.membership_id);}
this.doLayout();},addSaveSuccess:function(_6){var _7=Ext.getCmp(this.id+"-children-grid").store;_7.reload();var _8=new RegExp("^"+_6+"$");var _9=_7.find("user_id",_8,0,false,false);if(_9>-1){this._updateHandler(false,false,_7.getAt(_9));}else{this._addNewHandler();}},updateSaveInitiated:function(){if(this._showDataMappings){Ext.getCmp(this.id+"-data-mapping-form").saveForm();}
if(this._showMemberships){Ext.getCmp(this.id+"-membership-form").saveForm();}},updateSaveSuccess:function(){this.eventCompleteCount++;if(this.eventCompleteCount>=this.eventFireCount){this.eventCompleteCount=0;Ext.getCmp(this.id+"-children-grid").store.reload();}
return;}});Ext.reg("profiles.tab.childAccounts",profiles.tab.childAccounts);
profiles.tab.addressBook=Ext.extend(Ext.Panel,{autoHeight:true,autoScroll:true,border:false,url:"json.php?target=user_profile&area=C",_window:null,initComponent:function(){this.profile_store=new Ext.data.JsonStore({url:this.url+"&method=profileList",root:"data",fields:[{name:"profile_id"},{name:"profile_name"},{name:"company"},{name:"firstname"},{name:"lastname"},{name:"address_1"},{name:"address_2"},{name:"city"},{name:"state"},{name:"zip"},{name:"country"},{name:"phone"},{name:"dflt_billing"},{name:"dflt_shipping"}],autoLoad:true});xTemplateHtml="<div class=\"wse-boxes\">"+"<tpl for=\".\">"+"<div class=\"address_badge wse-box\">"+"<div class=\"address_area wse-addrs\">"+"<h3>{profile_name}</h3><p>"+"<tpl if=\"company\">{company}<br /></tpl>"+"<tpl if=\"firstname\">{firstname} {lastname}<br /></tpl>"+"<tpl if=\"address_1\">{address_1}<br /></tpl>"+"<tpl if=\"address_2\">{address_2}<br /></tpl>"+"<tpl if=\"city\">{city}, {state} {zip}<br /></tpl>"+"<tpl if=\"phone\">Phone: {phone}<br /></tpl>"+"<br />"+"<span class=\"wse-deflt-hld\">"+"<tpl if=\"dflt_billing == 1\"><span class=\"wse-deflt\">"+ProfileAddressBookLang.label.defaultBilling+"</span><br /></tpl>"+"<tpl if=\"dflt_shipping == 1\"><span class=\"wse-deflt\">"+ProfileAddressBookLang.label.defaultShipping+"</span><br /></tpl>"+"</span></p>"+"</div><div class=\"profiles-stdbutton wse-btn\">";if(AccountConfig.profile_address_book_allow_delete!="N"){xTemplateHtml+="<div class=\"buttonHolder wse-wrap-btn\" onclick=\"Ext.getCmp('"+this.id+"').deleteAddressHandler({profile_id}); return false;\"><div class=\"topCap wse-tcap\"></div><span>"+ProfileAddressBookLang.button.delete_text+"</span><div class=\"bottomCap wse-bcap\"></div></div>";}
if(AccountConfig.profile_address_book_allow_edit!="N"){xTemplateHtml+="<div class=\"buttonHolder wse-wrap-btn\" onclick=\"Ext.getCmp('"+this.id+"').editAddressHandler({profile_id}); return false;\"><div class=\"topCap wse-tcap\"></div><span>"+ProfileAddressBookLang.button.edit+"</span><div class=\"bottomCap wse-bcap\"></div></div>";}
xTemplateHtml+="</div>"+"</div>"+"</tpl>"+"</div>";this.profileTpl=new Ext.XTemplate(xTemplateHtml);this.items=[{xtype:"dataview",tpl:this.profileTpl,cls:"wse-addrsdv",store:this.profile_store,autoHeight:true,itemSelector:"div.search-item"}];if(AccountConfig.profile_address_book_allow_create=="Y"){this.tbar=[{xtype:"button",text:ProfileAddressBookLang.button.createNewAddress,handler:this.addAddressHandler,scope:this}];}
profiles.tab.addressBook.superclass.initComponent.call(this);},initEvents:function(){profiles.tab.addressBook.superclass.initEvents.call(this);},_reloadStore:function(){this.profile_store.reload();},addAddressHandler:function(){this.editAddressHandler(0);},editAddressHandler:function(_1){if(!this._window){this._window=new profiles.tab.addressBookWindow({listeners:{"addressUpdated":{fn:this._reloadStore,scope:this}}});}
var _2=ProfileAddressBookLang.title.newAddress;if(_1){_2=ProfileAddressBookLang.title.editAddress;var _3=this.profile_store.find("profile_id",_1,false,true);if(_3>=0){this._window.setValues(this.profile_store.getAt(_3));}}else{this._window.clearValues();}
this._window.setTitle(_2);this._window.show();},deleteAddressHandler:function(_4){Ext.Msg.show({title:ProfileAddressBookLang.title.deleteAddress,msg:ProfileAddressBookLang.message.deleteAddress,buttons:Ext.Msg.YESNO,fn:this._deleteAddressConfirmHandler.createDelegate(this,[_4],true),scope:this,icon:Ext.MessageBox.QUESTION});},_deleteAddressConfirmHandler:function(_5,_6,_7,_8){if(_5=="yes"){Ext.Ajax.request({url:this.url+"&method=delete&profile_id="+_8,callback:this._reloadStore,scope:this});}}});Ext.reg("profiles.tab.addressBook",profiles.tab.addressBook);
profiles.tab.addressBookWindow=Ext.extend(Ext.Window,{width:600,modal:true,shadow:false,autoScroll:true,autoHeight:true,buttonAlign:"left",labelAlign:"left",closeAction:"hide",url:"json.php?target=user_profile&area=C",save_method:"&method=save",initComponent:function(){this.items=[{xtype:"form",frame:false,border:false,labelWidth:130,bodyStyle:"padding: 20px 20px 0 20px; text-align: left;",buttonAlign:this.buttonAlign,labelAlign:this.labelAlign,items:[{xtype:"fieldset",title:ProfileAddressEditLang.title.contactInfo,collapsible:false,autoHeight:true,defaults:{width:230},defaultType:"textfield",items:[{name:"data[profile_id]",id:this.id+"-profile-id",xtype:"hidden"},{name:"data[x_field_list]",id:this.id+"-x-field-list",xtype:"hidden",value:"dflt_billing,dflt_shipping"},{fieldLabel:ProfileAddressEditLang.label.locationName,id:this.id+"-profile-name",name:"data[profile_name]",allowBlank:false},{fieldLabel:ProfileAddressEditLang.label.firstName,id:this.id+"-firstname",name:"data[firstname]",allowBlank:AccountConfig.allow_blank_edit_account_fields.firstname,validator:this.validateInput.createDelegate(this,AccountConfig.allow_blank_edit_account_fields.firstname,true)},{fieldLabel:ProfileAddressEditLang.label.lastName,id:this.id+"-lastname",name:"data[lastname]",allowBlank:AccountConfig.allow_blank_edit_account_fields.lastname,validator:this.validateInput.createDelegate(this,AccountConfig.allow_blank_edit_account_fields.lastname,true)},{fieldLabel:ProfileAddressEditLang.label.company,id:this.id+"-company",name:"data[company]",validator:this.validateInput.createDelegate(this,true,true)},{fieldLabel:ProfileAddressEditLang.label.address1,id:this.id+"-address",name:"data[address_1]",allowBlank:AccountConfig.allow_blank_edit_account_fields.address,validator:this.validateInput.createDelegate(this,AccountConfig.allow_blank_edit_account_fields.address,true)},{fieldLabel:ProfileAddressEditLang.label.address2,id:this.id+"-address2",name:"data[address_2]",allowBlank:AccountConfig.allow_blank_edit_account_fields.address_2,validator:this.validateInput.createDelegate(this,AccountConfig.allow_blank_edit_account_fields.address_2,true)},{fieldLabel:ProfileAddressEditLang.label.city,id:this.id+"-city",name:"data[city]",allowBlank:AccountConfig.allow_blank_edit_account_fields.city,validator:this.validateInput.createDelegate(this,AccountConfig.allow_blank_edit_account_fields.city,true)},{fieldLabel:ProfileAddressEditLang.label.state,id:this.id+"-state",hiddenName:"data[state]",xtype:"combo",store:webStore.stateList,valueField:"state",displayField:"state",typeAhead:true,mode:"local",triggerAction:"all",emptyText:ProfileAddressEditLang.emptyText.selectState,selectOnFocus:true,forceSelection:false,allowBlank:AccountConfig.allow_blank_edit_account_fields.state},{fieldLabel:ProfileAddressEditLang.label.zipCode,id:this.id+"-zip",name:"data[zip]",allowBlank:AccountConfig.allow_blank_edit_account_fields.zip,validator:this.validateInput.createDelegate(this,AccountConfig.allow_blank_edit_account_fields.zip,true)},{fieldLabel:ProfileAddressEditLang.label.country,hiddenName:"data[country]",id:this.id+"-country",xtype:"combo",store:webStore.countryList,valueField:"abbr",displayField:"country",typeAhead:true,mode:"local",triggerAction:"all",emptyText:ProfileAddressEditLang.emptyText.selectCountry,selectOnFocus:true,forceSelection:false,allowBlank:AccountConfig.allow_blank_edit_account_fields.state,listeners:{"select":{fn:this.updateStateList,scope:this}}},{fieldLabel:ProfileAddressEditLang.label.phone,xtype:"PhoneField",id:this.id+"-phone",name:"data[phone]",allowBlank:AccountConfig.allow_blank_edit_account_fields.phone,validator:this.validateInput.createDelegate(this,AccountConfig.allow_blank_edit_account_fields.phone,true)},{fieldLabel:ProfileAddressEditLang.label.defaultBilling,id:this.id+"-dflt-billing",name:"data[dflt_billing]",boxLabel:" ",xtype:"checkbox",inputValue:1},{fieldLabel:ProfileAddressEditLang.label.defaultShipping,id:this.id+"-dflt-shipping",name:"data[dflt_shipping]",boxLabel:" ",xtype:"checkbox",inputValue:1}]}]}];this.buttons=[{xtype:"button",text:ProfileAddressEditLang.button.save,handler:this.saveAddress,scope:this},{xtype:"button",text:ProfileAddressEditLang.button.close,handler:this.hideWindow,scope:this}];profiles.tab.addressBookWindow.superclass.initComponent.call(this);},initEvents:function(){this.on("show",this.checkForm,this);profiles.tab.addressBookWindow.superclass.initEvents.call(this);},checkForm:function(){this.setWindowProperties();this.getComponent(0).getForm().clearInvalid();},setWindowProperties:function(){var _1=Ext.get(this.id).getCenterXY();this.setPosition(_1[0],_1[1]);},clearValues:function(){try{Ext.getCmp(this.id+"-profile-id").setValue();Ext.getCmp(this.id+"-profile-name").setValue();Ext.getCmp(this.id+"-firstname").setValue();Ext.getCmp(this.id+"-lastname").setValue();Ext.getCmp(this.id+"-company").setValue();Ext.getCmp(this.id+"-address").setValue();Ext.getCmp(this.id+"-address2").setValue();Ext.getCmp(this.id+"-city").setValue();Ext.getCmp(this.id+"-state").setValue();Ext.getCmp(this.id+"-zip").setValue();Ext.getCmp(this.id+"-country").setValue();Ext.getCmp(this.id+"-phone").setValue();Ext.getCmp(this.id+"-dflt-billing").setValue();Ext.getCmp(this.id+"-dflt-shipping").setValue();}
catch(e){}},setValues:function(_2){try{var _3=Ext.getCmp(this.id+"-country");_3.setValue(_2.data.country);this.updateStateList(_3,null,null,_2.data.country);Ext.getCmp(this.id+"-profile-id").setValue(_2.data.profile_id);Ext.getCmp(this.id+"-profile-name").setValue(_2.data.profile_name);Ext.getCmp(this.id+"-firstname").setValue(_2.data.firstname);Ext.getCmp(this.id+"-lastname").setValue(_2.data.lastname);Ext.getCmp(this.id+"-company").setValue(_2.data.company);Ext.getCmp(this.id+"-address").setValue(_2.data.address_1);Ext.getCmp(this.id+"-address2").setValue(_2.data.address_2);Ext.getCmp(this.id+"-city").setValue(_2.data.city);Ext.getCmp(this.id+"-state").setValue(_2.data.state);Ext.getCmp(this.id+"-zip").setValue(_2.data.zip);Ext.getCmp(this.id+"-phone").setValue(_2.data.phone);Ext.getCmp(this.id+"-dflt-billing").setValue(_2.data.dflt_billing);Ext.getCmp(this.id+"-dflt-shipping").setValue(_2.data.dflt_shipping);}
catch(e){}},updateStateList:function(_4,_5,_6,_7){var _8=Ext.getCmp(this.id+"-state");var cc;if(_7){cc=_7;}else{if(_5.data){cc=_5.data.abbr;}}
if(cc){_8.store.reload({params:{country_code:cc},callback:this.updateStateRequired,scope:this});}},updateStateRequired:function(_a,_b,_c){var _d=Ext.getCmp(this.id+"-zip");var _e=Ext.getCmp(this.id+"-state");if(_a.length==0){_d.allowBlank=true;_e.allowBlank=true;_e.setValue();var _f=this.getComponent(0).getForm();_f.clearInvalid();}else{_d.allowBlank=false;_e.allowBlank=false;_e.setValue(_e.getValue());}},validateInput:function(_10,_11){if(_11){return true;}
var _12=_10.trim();if(_12.length==0){return ProfileAddressEditLang.message.requiredField;}
return true;},saveAddress:function(){var _13=this.getComponent(0).getForm();if(_13.isValid()){_13.waitMsgTarget=true;_13.submit({url:this.url+this.save_method,discardUrl:false,success:this.formSuccessHandler,failure:webStore.displayConfirmMessageFromForm,scope:this,waitMsg:ProfileAddressEditLang.mask.saving,timeout:45,scripts:false});}else{webStore.displayMessage(ProfileAddressEditLang.message.require_fields_not_filled,"","error");}},formSuccessHandler:function(_14,_15){this.fireEvent("addressUpdated");this.hideWindow();},hideWindow:function(){this.hide();}});Ext.reg("profiles.tab.addressBookWindow",profiles.tab.addressBookWindow);
profiles.tab.customerLogo=Ext.extend(Ext.FormPanel,{autoHeight:true,autoScroll:true,border:false,bodyStyle:"padding:20px;",buttonAlign:"left",labelWidth:80,fileUpload:true,enctype:"multipart/form-data",url:"json.php?target=user&area=C",deleteMethod:"&method=deleteLogo",loadMethod:"&method=getLogo",saveMethod:"&method=saveLogo",initComponent:function(){this.items=[{xtype:"panelwithhelp",frame:false,border:false,autoWidth:true,items:[{xtype:"hidden",id:this.id+"-image_id",name:"image_id"},{xtype:"hidden",id:this.id+"-pair_id",name:"pair_id"},{xtype:"textfield",inputType:"file",name:"customerLogo[0]",fieldLabel:ProfileCustomerLogoLang.label.logoUpload,allowBlank:false,width:230},{border:false,html:"<div id=\"myAccountCustomerLogoPreview\"></div>"},{border:false,html:ProfileCustomerLogoLang.message.recommended_size}]}];this.buttons=[{text:ProfileCustomerLogoLang.button.saveText,handler:this.submitForm,scope:this},{id:this.id+"-delete_button",text:ProfileCustomerLogoLang.button.deleteText,handler:this.deleteLogo,scope:this,hidden:true}];profiles.tab.customerLogo.superclass.initComponent.call(this);},initEvents:function(){profiles.tab.customerLogo.superclass.initEvents.call(this);},onRender:function(ct,_2){profiles.tab.customerLogo.superclass.onRender.call(this,ct,_2);this.loadForm.defer(250,this);},loadForm:function(){var _3=this.getForm();_3.waitMsgTarget=Ext.get("profile_main");_3.load({url:this.url+this.loadMethod,waitMsg:ProfileCustomerLogoLang.mask.loadingData,success:this._loadHandler.createDelegate(this)});},_loadHandler:function(){this.setImagePanel();},setImagePanel:function(){var _4=Ext.get(this.id+"-image_id").getValue();if(_4>0){Ext.get("myAccountCustomerLogoPreview").update("<img src=\"image.php?object_type=common&image_id="+_4+"\" border=\"0\" />");}else{Ext.get("myAccountCustomerLogoPreview").update("");}
if(_4>0){Ext.getCmp(this.id+"-delete_button").show();}else{Ext.getCmp(this.id+"-delete_button").hide();}},submitForm:function(){this.getForm().submit({url:this.url+this.saveMethod,waitMsg:ProfileCustomerLogoLang.mask.saving,success:this._handleFormSuccess,failure:webStore.displayConfirmMessageFromForm,scope:this});},_handleFormSuccess:function(_5,_6){webStore.displayConfirmMessageFromForm(_5,_6);this.loadForm();},deleteLogo:function(){Ext.Msg.show({title:ProfileCustomerLogoLang.title.deleteLogo,msg:ProfileCustomerLogoLang.message.deleteLogo,buttons:Ext.Msg.YESNO,fn:this._deleteLogoConfirmHandler.createDelegate(this),scope:this,icon:Ext.MessageBox.QUESTION});},_deleteLogoConfirmHandler:function(_7,_8,_9){if(_7=="yes"){Ext.Ajax.request({url:this.url+this.deleteMethod,params:{image_id:Ext.get(this.id+"-image_id").getValue(),pair_id:Ext.get(this.id+"-pair_id").getValue()},success:this._updateLogoIdFromDelete,scope:this});}},_updateLogoIdFromDelete:function(_a,_b,_c){if(_b){Ext.getCmp(this.id+"-image_id").setValue(0);Ext.getCmp(this.id+"-pair_id").setValue(0);this.setImagePanel();}}});Ext.reg("profiles.tab.customerLogo",profiles.tab.customerLogo);
profiles.tab.password=Ext.extend(Ext.form.FormPanel,{frame:false,border:false,labelWidth:110,fieldWidth:230,buttonAlign:"left",validationDelay:50,autoHeight:true,autoScroll:true,border:false,url:"json.php?target=user&area=C",initComponent:function(){this.items=[{xtype:"fieldset",title:ProfilePasswordLang.title.changePassword,collapsible:false,autoHeight:true,items:[{xtype:"profiles.comps.password",bodyStyle:"padding: 20px 20px 0 20px",labelWidth:this.labelWidth,fieldWidth:this.fieldWidth}]}];this.buttons=[{text:ProfilePasswordLang.button.save,handler:this.savePassword,cls:"wse-xbtn wse-xbtn-save",scope:this}];profiles.tab.password.superclass.initComponent.call(this);},initEvents:function(){profiles.tab.password.superclass.initEvents.call(this);},savePassword:function(){var _1=this.getForm();if(!_1.isValid()){return;}else{_1.waitMsgTarget=Ext.get("profile_main");_1.submit({url:this.url+"&method=save",success:webStore.displayConfirmMessageFromForm,waitMsg:ProfilePasswordLang.mask.saving});}}});Ext.reg("profiles.tab.password",profiles.tab.password);
profiles.tab.orderHistory=Ext.extend(Ext.Panel,{autoHeight:true,autoScroll:true,border:false,url:"json.php?target=order&area=C",common_url:"json.php?area=C&target=common",_window:null,pagingToolbarWidth:820,limit:10,initComponent:function(){this.orderList=new Ext.data.JsonStore({url:this.url+"&method=orderList",root:"data",totalProperty:"numFound",fields:[{name:"order_id"},{name:"status"},{name:"status_code"},{name:"date"},{name:"total"},{name:"external_order_id"}],autoLoad:true,baseParams:{limit:this.limit}});this.sm=new Ext.grid.RowSelectionModel({singleSelect:true});this.ptoolbar=new Ext.PagingToolbar({store:this.orderList,width:this.pagingToolbarWidth,pageSize:this.limit,displayInfo:true});this.items=[{xtype:"profiles.tab.orderHistorySearch",lang:ProfileOrderHistorySearchLang,listeners:{searchPerformed:this.handleSearch.createDelegate(this),clearSearch:this.handleClearSearch.createDelegate(this)}},{xtype:"grid",store:this.orderList,enableHdMenu:false,viewConfig:{autoFill:true},columns:[{header:ProfileOrderHistoryLang.label.orderNum,dataIndex:"order_id",id:"order_id",sortable:true},{header:ProfileOrderHistoryLang.label.externalOrderNum,dataIndex:"external_order_id",id:"external_order_id",sortable:true},{header:ProfileOrderHistoryLang.label.status,dataIndex:"status",sortable:true,id:"status",renderer:this.statusCellRenderer.createDelegate(this)},{header:ProfileOrderHistoryLang.label.date,dataIndex:"date",sortable:true,id:"date"},{header:ProfileOrderHistoryLang.label.total,dataIndex:"total",sortable:true,id:"total"}],sm:this.sm,height:575,autoScroll:true,border:false,stripeRows:true,bbar:this.ptoolbar}];profiles.tab.orderHistory.superclass.initComponent.call(this);},initEvents:function(){this.sm.on("rowselect",this.selectOrder,this);profiles.tab.orderHistory.superclass.initEvents.call(this);},selectOrder:function(sm,_2,_3){if(_3){window.location.href="order-"+_3.get("order_id")+".html";}},statusCellRenderer:function(_4,_5,_6){if(_6&&_6.data&&_6.data.status_code){_4="<span class=\"wse-status-"+_6.data.status_code+"\">"+_4+"</span>";}
return _4;},handleSearch:function(_7){this.orderList.baseParams={query:Ext.util.JSON.encode(_7)};this.orderList.load();},handleClearSearch:function(){this.orderList.baseParams={};this.orderList.load();}});Ext.reg("profiles.tab.orderHistory",profiles.tab.orderHistory);
profiles.tab.myEquipment=Ext.extend(Ext.Panel,{equipDisplayLim:10,autoHeight:true,autoScroll:false,border:false,url:"json.php?target=epc_b2c_gateway&area=C",machine_id:"",equip_id:"",limit:10,namespace:{"code":"epc","separator":"::","allowNoNamespace":true},tokenKeys:{"machineId":"mc","modelId":"md","manualRevId":"mr"},tokenPages:{"search":"parts-search.html#"},initComponent:function(){this.machinesStore=new Ext.data.JsonStore({autoLoad:false,root:"results",totalProperty:"total",id:"my_machine_id",url:this.url,baseParams:{delete_id:0,limit:this.limit,method:"getMyEquipList",include_mappings_list:true},fields:["my_machine_id","user_id","equip_name","description","equip_id","ses_model_id","ses_machine_id","ses_manual_revision_id","selected","generics","generic_group"]});this.searchStore=new Ext.data.JsonStore({autoLoad:false,url:"json.php?target=epc_b2c_gateway&method=getEquipmentSearchFields",root:"data",fields:["value","label"]});this.tpl=new Ext.XTemplate("<tpl for=\".\">","<div class=\"wse-equip\">","<div class=\"wse-fld\">","<input type=\"text\" size=\"40\" name=\"name_field\" value=\"{equip_name}\" onChange=\"Ext.getCmp('"+this.id+"').renameEquipment(this.value, {my_machine_id}); return false;\" />","</div>","<tpl if=\"values.generic_group && values.generic_group.length &gt; 1\">","<tpl for=\"generic_group\">","<ul class=\"wse-column-group wse-column-group-{[xindex]}\">","<tpl for=\".\">","<li><span class=\"wse-lbl\">{label}:&nbsp;</span><span class=\"wse-val\">{value}</span></li>","</tpl>","</ul>","</tpl>","</tpl>","<tpl if=\"values.generics && (!values.generic_group || values.generic_group.length == 1)\">","<ul>","<tpl for=\"generics\">","<li><span class=\"wse-lbl\">{label}</span>: <span class=\"wse-val\">{value}</span></li>","</tpl>","</ul>","</tpl>","<ul>","<li class=\"wse-viewparts\"><a href=\"\" onclick=\"Ext.getCmp('"+this.id+"').genEpcURL('{ses_machine_id}', '{ses_model_id}', '{ses_manual_revision_id}'); return false;\">"+ProfileMyEquipmentLang.link.view+"</a></li>","<li class=\"wse-remove-equip\"><a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').removeEquip({my_machine_id},{equip_id}); return false;\">"+ProfileMyEquipmentLang.link.remove+"</a></li>","<tpl if=\"!this.currentHidden(selected)\">","<tpl if=\"selected &lt; 1\">","<li class=\"wse-make-current\"><a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').makeEquipCurrent({equip_id}); return false;\">"+ProfileMyEquipmentLang.link.select+"</a></li>","</tpl>","<tpl if=\"selected &gt; 0\">","<li>"+ProfileMyEquipmentLang.link.current_selection+"</li>","</tpl>","</tpl>","</ul>","<hr />","</div>","</tpl>",{currentHidden:function(_1){return _1=="hide";}});this.view=new Ext.DataView({id:this.id+"-equip-view",tpl:this.tpl,store:this.machinesStore,itemSelector:"div.wse-equip",autoHeight:true,autoWidth:true});this.searchCombo=new Ext.form.ComboBox({store:this.searchStore,id:this.id+"-search-combo",triggerAction:"all",valueField:"value",displayField:"label",emptyText:ProfileMyEquipmentLang.emptyText.search,mode:"local",width:100});this.tbar=[this.searchCombo,"&nbsp;",{xtype:"textfield",width:200,id:this.id+"-search-term"},"&nbsp;",{xtype:"button",text:ProfileMyEquipmentLang.button.search,handler:this.performSearch,scope:this},{xtype:"button",text:ProfileMyEquipmentLang.button.clear,handler:this.clearSearch,scope:this},{xtype:"tbfill"},{xtype:"button",text:ProfileMyEquipmentLang.button.add_new_equip,handler:this.addEquipment,scope:this}];this.bbar=new Ext.PagingToolbar({store:this.machinesStore,autoWidth:true,pageSize:this.limit,displayInfo:true});this.items=[{xtype:"panel",border:false,height:500,items:[this.view],autoScroll:true}];profiles.tab.myEquipment.superclass.initComponent.call(this);},initEvents:function(){profiles.tab.myEquipment.superclass.initEvents.call(this);},afterRender:function(){profiles.tab.myEquipment.superclass.afterRender.call(this);this.machinesStore.load.defer(100,this.machinesStore);this.searchStore.load.defer(200,this.searchStore);},_loadForm:function(){Ext.getCmp(this.id+"-preferences-form").load({url:this.url+"&method=getEquipmentDisplayLimit"});},_reloadStore:function(){this.machinesStore.reload();},format_title:function(_2,_3,_4){return"<span width=\"180\" ext:qtip=\""+_2+"\">"+_2+"</span>";},format_description:function(_5,_6,_7){if(_5){return"<span width=\"180\" ext:qtip=\""+_5+"\">"+_5+"</span>";}else{return"";}},format_buttons:function(_8,_9,_a){return"<div id=\"buttons_"+_8+"\">"+"<a href=\"#\" ext:qtip=\""+ProfileMyEquipmentLang.title.editName+"\" onclick=\"Ext.getCmp('"+this.id+"').editMachine('"+_a.data.my_machine_id+"')\">"+ProfileMyEquipmentLang.button.edit+"</a>&nbsp;&nbsp;"+"<a href=\"#\" ext:qtip=\""+ProfileMyEquipmentLang.message.deleteFromList+"\" onclick=\"Ext.getCmp('"+this.id+"').deleteMachine('"+_a.data.my_machine_id+"', '"+_a.data.title+"')\">"+ProfileMyEquipmentLang.button.deleteBtn+"</a></div>";},sendEquipmentDisplayLimit:function(){var _b=Ext.getCmp(this.id+"-preferences-form").getForm();_b.waitMsgTarget=true;_b.submit({url:this.url+"&method=editEquipmentDisplayLimit",clientValidation:false,scope:this,discardUrl:false,nocache:false,waitMsg:ProfileMyEquipmentLang.mask.submitting,timeout:45,scripts:false});},editMachine:function(_c){var _d=this.machinesStore.getById(_c);if(_d){var _e=new Ext.Window({title:ProfileMyEquipmentLang.title.editName,width:300,modal:true,id:"machine-edit-form-win",items:[{xtype:"form",id:"machine-edit-form",labelWidth:75,labelAlign:"right",bodyStyle:"padding: 5px",items:[{xtype:"hidden",value:_c,name:"my_machine_id"},{xtype:"textarea",value:_d.data.title,name:"name",fieldLabel:ProfileMyEquipmentLang.label.name,anchor:"95%"}],buttons:[{text:ProfileMyEquipmentLang.button.save,handler:this.sendEditMachineInfo,scope:this}]}]});_e.show();}},sendEditMachineInfo:function(){var _f=Ext.getCmp("machine-edit-form").getForm();_f.waitMsgTarget=true;_f.submit({url:this.url+"&method=editMachineName",success:this._editMachineCallback.createDelegate(this),failure:this._editMachineCallback.createDelegate(this),clientValidation:false,scope:this,discardUrl:false,nocache:false,waitMsg:ProfileMyEquipmentLang.mask.submitting,timeout:45,scripts:false});},_editMachineCallback:function(){this._reloadStore();Ext.getCmp("machine-edit-form-win").close();},deleteMachine:function(mmi,_11){Ext.Msg.show({title:ProfileMyEquipmentLang.title.deleteQuestion,msg:ProfileMyEquipmentLang.message.deleteEquipment.replace("[1]",_11),buttons:Ext.Msg.YESNO,fn:this._deleteMachineConfirmHandler.createDelegate(this,[mmi],true),scope:this,maxWidth:250,icon:Ext.MessageBox.QUESTION});},_deleteMachineConfirmHandler:function(btn,_13,obj,mmi){if(btn=="yes"){Ext.Ajax.request({url:this.url+"&method=deleteMachine&my_machine_id="+mmi,callback:this._reloadStore.createDelegate(this),scope:this});}},makeEquipCurrent:function(id){Ext.Ajax.request({method:"POST",url:"json.php?target=epc_b2c_gateway",params:{method:"changeEquipmentSelection","data[equip_id]":id},scope:this});this.clearSearch();},removeEquip:function(_17,_18){this.machine_id=_17;this.equip_id=_18;Ext.Msg.show({title:ProfileMyEquipmentLang.message.title,msg:ProfileMyEquipmentLang.message.deleteItem,buttons:Ext.Msg.YESNO,fn:this.checkDelete,animEl:"elId",icon:Ext.MessageBox.QUESTION,scope:this});},checkDelete:function(_19){if(_19=="yes"){Ext.Ajax.request({method:"POST",url:"json.php?target=epc_b2c_gateway",params:{method:"deleteEquipmentSelection","data[my_machine_id]":this.machine_id},callback:this._handleDeleteEquipmentSelection,scope:this});}else{return false;}},_handleDeleteEquipmentSelection:function(_1a,_1b,_1c){var _1d=Ext.util.JSON.decode(_1c.responseText);if(_1d.success){this.machine_id="";this.equip_id="";this.clearSearch();}},_updateFinish:function(_1e,_1f){window.location.reload();},addEquipment:function(){openEquipSelectPanel(this,"topmenu-equipselect-hld","li.ws-lnk-equip","ws-lnk-equip-on");},renameEquipment:function(_20,id){Ext.Ajax.request({method:"POST",url:"json.php?target=epc_b2c_gateway",params:{method:"renameEquipmentSelection","data[value]":_20,"data[id]":id},scope:this});},performSearch:function(){var _22=Ext.getCmp(this.id+"-search-combo").getValue();var _23=Ext.getCmp(this.id+"-search-term").getValue();var _24=Ext.getCmp(this.id+"-equip-view").store;if(_22==""){Ext.Msg.show({title:ProfileMyEquipmentLang.message.title_search,msg:ProfileMyEquipmentLang.message.select_field,buttons:Ext.Msg.OK});}else{if(_23!=null&&_22!=null){_24.baseParams["search_term"]=_23;_24.baseParams["search_column"]=_22;_24.load({params:{start:0}});}}},clearSearch:function(){Ext.getCmp(this.id+"-search-term").setValue();Ext.getCmp(this.id+"-search-combo").reset();var _25=Ext.getCmp(this.id+"-equip-view").store;_25.baseParams["search_term"]="";_25.baseParams["search_column"]="";_25.load({params:{start:0}});},genEpcURL:function(_26,_27,_28){var _29=this.tokenKeys;var _2a=this.tokenPages;var ns=this.namespace;var _2c="";if(_26&&_26!="0"){_2c+=_29["machineId"]+_26;}
if(_27&&_27!="0"){_2c+=_29["modelId"]+_27;}
if(_28&&_28!="0"){_2c+=_29["manualRevId"]+_28;}
var url=_2a["search"]+ns["code"]+ns["separator"]+_2c;window.location.href=url;}});Ext.reg("profiles.tab.myEquipment",profiles.tab.myEquipment);
profiles.tab.myBookmarks=Ext.extend(Ext.FormPanel,{autoHeight:true,autoScroll:true,border:false,url:"json.php?area=C&target=bookmarks_gateway",common_url:"json.php?area=C&target=common",renameBookmarkMethod:"&method=renameBookmark",deleteMethod:"&method=deleteBookmark",_window:null,bookmark_id:"",limit:10,urlMethod:"&method=createURL",initComponent:function(){this.bookmarkList=new Ext.data.JsonStore({url:this.url+"&method=listBookmarks",root:"data",totalProperty:"numFound",fields:[{name:"bookmark_id"},{name:"name"},{name:"bm_name"},{name:"bookmark_namespace_id"},{name:"rename"},{name:"delete"},{name:"go"},{name:"obj_handle"},{name:"label"},{name:"obj_id"},{name:"obj_value"},{name:"ns_name"}],autoLoad:true,remoteSort:true,sortInfo:{field:"bm_name",direction:"ASC"},baseParams:{limit:this.limit}});this.paginationStore=new Ext.data.JsonStore({url:this.common_url+"&method=getPagesizes",root:"data",fields:["pagesize"],autoLoad:true});this.filterStore=new Ext.data.JsonStore({url:this.url+"&method=getBookmarkNamespaceTypes",root:"data",fields:["value","label"],autoLoad:false});this.sm=new Ext.grid.RowSelectionModel({singleSelect:true});this.ptoolbar=new Ext.PagingToolbar({store:this.bookmarkList,autoWidth:true,pageSize:this.limit,displayInfo:true});this.pagingCombo=new Ext.form.ComboBox({store:this.paginationStore,width:50,emptyText:this.limit,displayField:"pagesize",typeAhead:false,mode:"local",triggerAction:"all",listeners:{"select":{fn:this.setPageSize,scope:this}}});this.filterCombo=new Ext.form.ComboBox({store:this.filterStore,valueField:"value",displayField:"label",mode:"local",triggerAction:"all",listeners:{"select":{fn:this.filterGrid,scope:this}}});this.items=[{xtype:"grid",id:this.id+"-bookmark_grid",store:this.bookmarkList,height:480,enableHdMenu:false,viewConfig:{autoFill:true,emptyText:ProfileMyBookmarksLang.label.empty},columns:[{header:ProfileMyBookmarksLang.label.nsType,width:25,dataIndex:"ns_name",id:"bookmark_namespace_name",sortable:true,renderer:this.bookmark_link.createDelegate(this)},{header:ProfileMyBookmarksLang.label.bookmarkName,width:50,dataIndex:"bm_name",id:"bookmark_name",sortable:true,renderer:this.bookmark_link.createDelegate(this)},{header:"",width:30,dataIndex:"rename",sortable:false,id:this.id+"-rename",renderer:this.rename_link.createDelegate(this)},{header:"",width:30,dataIndex:"delete",sortable:false,id:"delete",renderer:this.delete_link.createDelegate(this)},{header:"",width:15,dataIndex:"go",sortable:false,id:"go",renderer:this.bookmark_link.createDelegate(this)}],sm:this.sm,autoScroll:false,border:false,stripeRows:true,bbar:this.ptoolbar,tbar:[{xtype:"label",text:ProfileMyBookmarksLang.label.comboLabel},":",this.filterCombo,{xtype:"tbfill"},{xtype:"label",text:ProfileMyBookmarksLang.label.page_size},":",this.pagingCombo],listeners:{"editClicked":{fn:this._renameHandler,scope:this}}}];if(!this._window){this._window=new profiles.tab.Bookmark_Window({title:ProfileMyBookmarksLang.window.title,url:this.url,renameMethod:this.renameBookmarkMethod,lang:ProfileMyBookmarksLang.window});this._window.on("refreshTrigger",this.refreshHandler,this);}
profiles.tab.myBookmarks.superclass.initComponent.call(this);},initEvents:function(){this.filterStore.on("load",this.preselectGrid,this);this.filterStore.load();},bookmark_link:function(_1,_2,_3,_4){if(_3&&_3.data){return"<a href=\"javascript: Ext.getCmp('"+this.id+"')._getURL('"+_4+"');\" >"+_1+"</a>";}
return _1;},rename_link:function(_5,_6,_7,_8){if(_7&&_7.data){return"<a href=\"javascript: Ext.getCmp('"+this.id+"')._renameHandler('"+_8+"');\" >"+_5+"</a>";}
return _5;},fireClickEvent:function(id){this.fireEvent("editClicked",id);},delete_link:function(_a,_b,_c,_d){if(_c&&_c.data){_a="<a href=\"javascript: Ext.getCmp('"+this.id+"').delete_prompt('"+_d+"');\" >"+_a+"</a>";}
return _a;},preselectGrid:function(_e,_f,_10){if(_f){this.filterCombo.setValue(_f[0].data.label);}
this.removeListener("load",this.preselectGrid,this);},filterGrid:function(_11,_12,_13){if(_12&&_12.data){this.bookmarkList.baseParams["namespace_id"]=_12.data.value;this.refreshGrid();}},refreshGrid:function(){this.bookmarkList.baseParams["limit"]=this.limit;this.bookmarkList.load();},_renameHandler:function(_14){if(_14||_14==0){var _15=Ext.getCmp(this.id+"-bookmark_grid").store.getAt(_14);this._window.setTitle(ProfileMyBookmarksLang.window.title);this._window.setValues(_15);this._window.show();}},refreshHandler:function(){this.refreshGrid();},delete_prompt:function(_16){if(_16||_16==0){var _17=Ext.getCmp(this.id+"-bookmark_grid").store.getAt(_16);this.bookmark_id=_17.data.bookmark_id;Ext.Msg.show({title:ProfileMyBookmarksLang.window.msg_title,msg:ProfileMyBookmarksLang.window.msg_delete,buttons:Ext.Msg.YESNO,fn:this.checkDelete,animEl:"elId",icon:Ext.MessageBox.QUESTION,scope:this});}},checkDelete:function(_18){if(_18=="yes"){Ext.Ajax.request({url:this.url+this.deleteMethod,params:{id:this.bookmark_id}});this.bookmark_id="";this.refreshGrid();}else{return false;}},setPageSize:function(_19,_1a,_1b){if(_1a&&_1a.data){this.limit=_1a.data.pagesize;this.ptoolbar.pageSize=this.limit;this.refreshGrid();}},_getURL:function(_1c){if(_1c||_1c==0){var _1d=Ext.getCmp(this.id+"-bookmark_grid").store.getAt(_1c);Ext.Ajax.request({url:this.url+this.urlMethod,params:{bookmark_id:_1d.data.bookmark_id,obj_value:_1d.data.obj_value,obj_handle:_1d.data.obj_handle,obj_id:_1d.data.obj_id,label:_1d.data.label},success:function(_1e,_1f){_1e=Ext.util.JSON.decode(_1e.responseText);if(_1e&&_1e.url){window.location.href=_1e.url;}}});}}});Ext.reg("profiles.tab.myBookmarks",profiles.tab.myBookmarks);
profiles.tab.myRebates=Ext.extend(Ext.Panel,{autoHeight:true,autoScroll:true,border:false,url:"json.php?target=rebate_gateway",_window:null,pagingToolbarWidth:820,limit:10,initComponent:function(){this.items=[{id:this.id+"-users_rebates-grid",xtype:"dynamicgridpanel",bodyStyle:"width:99.5%;",url:this.url,method:"&method=getUsersRebates",loadOnActivate:true,remoteSort:true,includeAdd:false,includeDelete:false,includeRefresh:true,includeDownload:false,includeFilter:false,includePagination:true,fireSelectionEvents:false,checkSelection:false,fields:["rebate_name","code","rebate_code","status_name","submitted_date_formatted"],columns:[{header:ProfileMyRebatesLang.label.rebate_name,dataIndex:"rebate_name",sortable:true,columnWidth:0.25},{header:ProfileMyRebatesLang.label.rebate_code,dataIndex:"code",addRenderer:true,rendererType:"userRebateCode",sortable:true,columnWidth:0.25},{header:ProfileMyRebatesLang.label.status,dataIndex:"status_name",sortable:true,columnWidth:0.25},{header:ProfileMyRebatesLang.label.date,dataIndex:"submitted_date_formatted",sortable:true,columnWidth:0.25}]}];profiles.tab.myRebates.superclass.initComponent.call(this);},initEvents:function(){Ext.getCmp(this.id+"-users_rebates-grid").refreshGrid();profiles.tab.myRebates.superclass.initEvents.call(this);}});Ext.reg("profiles.tab.myRebates",profiles.tab.myRebates);
profiles.tab.Bookmark_Window=Ext.extend(Ext.Window,{autoScroll:false,modal:true,autoHeight:true,widthSimple:350,fieldWidth:150,positionFieldWidth:100,labelWidth:100,textAreaHeight:150,closeAction:"hide",buttonAlign:"center",flagColorBtmClass:"flags-text-color-panel",lang:{},mode:"",renameMethod:" ",group:" ",initComponent:function(){this.items=[{xtype:"form",bodyCssClass:"flags-window-simple",width:this.widthSimple-15,labelWidth:this.labelWidth,items:[{xtype:"hidden",id:this.id+"-bookmark_id",name:"data[bookmark_id]"},{xtype:"textfield",id:this.id+"-name",name:"data[name]",fieldLabel:this.lang.name_label,width:this.fieldWidth,allowBlank:false}]}];this.buttons=[{xtype:"button",text:this.lang.save,handler:this.saveForm,scope:this},{xtype:"button",text:this.lang.cancel,handler:this.hideWindow,scope:this}];profiles.tab.Bookmark_Window.superclass.initComponent.call(this);},initEvents:function(){this.on("show",this.checkForm,this);profiles.tab.Bookmark_Window.superclass.initEvents.call(this);},checkForm:function(){this.setWindowProperties();this.getComponent(0).getForm().clearInvalid();},clearValues:function(){try{Ext.getCmp(this.id+"-name").setValue();}
catch(e){}},setValues:function(_1){try{Ext.getCmp(this.id+"-name").setValue(_1.data["bm_name"]);Ext.getCmp(this.id+"-bookmark_id").setValue(_1.data["bookmark_id"]);}
catch(e){}},setWindowProperties:function(){this.setWidth(this.widthSimple);var _2=Ext.get(this.id).getCenterXY();this.setPosition(_2[0],_2[1]);},saveForm:function(){var _3=this.getComponent(0).getForm();if(_3.isValid()){_3.waitMsgTarget=true;_3.submit({url:this.url+this.renameMethod,discardUrl:false,success:this.formSuccessHandler,failure:webStore.displayConfirmMessageFromForm,scope:this,waitMsg:this.lang.load,timeout:45,scripts:false});}else{this.requiredFieldsNotFilled();}},formSuccessHandler:function(_4,_5){Ext.Msg.alert(this.lang.msg_title,this.lang.msg_saved);this.fireEvent("refreshTrigger");this.hideWindow();},hideWindow:function(){this.hide();},requiredFieldsNotFilled:function(){webStore.displayRequiredFieldsNotFilledMessage();}});
profiles.tab.orderTypeDisplay=Ext.extend(Ext.Panel,{autoHeight:true,autoScroll:true,border:false,url:"json.php?target=order&area=C",_window:null,orderType:"",usePicklistFunctionality:false,resumeOrAddChoiceWin:null,_loadMask:null,includeSearch:true,no_pagination_size:10,allow_pagination:true,allow_export:true,allow_page_size_combo:true,max_export_size:0,pagination_size:10,allow_open_date_search:true,avail_columns:null,avail_search_fields:null,orderSelectOption:false,allowPayInvoices:false,excludeZeroPayInvoices:false,payInvoiceLimitField:"",defaultPaymentStatusId:"",searchPanelTitle:"",remoteSort:false,defaultSort:false,lineItemDisplayIncluded:false,doNotAutoload:false,displayTotal:false,storeFields:[],payInvoiceUrl:"",initComponent:function(){this.sm=new Ext.grid.RowSelectionModel({singleSelect:true});this.items=[];if(this.includeSearch&&this.avail_search_fields.length){this.searchForm=new profiles.tab.orderHistorySearch({orderType:this.orderType,includeButtons:false,defaultPaymentStatusId:(this.defaultPaymentStatusId||""),allowOpenDateSearch:this.allow_open_date_search,availSearchFields:this.avail_search_fields,title:(this.searchPanelTitle?this.searchPanelTitle:ProfileOrderHistorySearchLang.title),lang:ProfileOrderHistorySearchLang,listeners:{searchPerformed:this.handleSearch.createDelegate(this),clearSearch:this.handleClearSearch.createDelegate(this)}});this.items.push(this.searchForm);}
var _1={};if(this.defaultPaymentStatusId){_1["header[payment_status_id]"]=this.defaultPaymentStatusId;}
this.orderTypeGrid=new profiles.tab.orderTypeGrid({orderType:this.orderType,includePagination:this.allow_pagination,allowExport:this.allow_export,limit:this.pagination_size?this.pagination_size:this.no_pagination_size,includePageSize:this.allow_page_size_combo,exportLimit:this.max_export_size,avail_columns:this.avail_columns,storeFields:this.storeFields,payInvoiceUrl:this.payInvoiceUrl,initQuery:_1,autoHeight:false,height:300,loadMask:true,includeSearchButtons:this.avail_search_fields.length?true:false,allowPayInvoices:this.allowPayInvoices,excludeZeroPayInvoices:this.excludeZeroPayInvoices,payInvoiceLimitField:this.payInvoiceLimitField,orderSelectOption:this.orderSelectOption,remoteSort:this.remoteSort,defaultSort:this.defaultSort,lineItemDisplayIncluded:this.lineItemDisplayIncluded,doNotAutoload:this.doNotAutoload,listeners:{performSearch:this.performSearch.createDelegate(this),clearSearch:this.clearSearch.createDelegate(this),updateTotal:this.updateTotal.createDelegate(this)}});this.items.push(this.orderTypeGrid);if(!this.allowPayInvoices&&this.displayTotal){this.items.push(new Ext.Toolbar({cls:"wse-ordrs-ttl",items:["->","<span class=\"wse-lbl\">"+ProfileOrderTypeDisplayLang.label.total+": $</span>","<span id=\""+this.getId()+"-tval\" class=\"wse-val\">0.00</span>"]}));}
profiles.tab.orderTypeDisplay.superclass.initComponent.call(this);},initEvents:function(){profiles.tab.orderTypeDisplay.superclass.initEvents.call(this);},checkIfLoadNeeded:function(){},performSearch:function(){if(this.searchForm){this.searchForm.handleSearchButton();}},clearSearch:function(){if(this.searchForm){this.searchForm.handleClearSearchButton();}},handleSearch:function(_2){this.orderTypeGrid.performSearch(_2);},handleClearSearch:function(){this.orderTypeGrid.clearSearch();},updateTotal:function(_3){if(this.displayTotal){try{Ext.get(this.getId()+"-tval").update(_3);}
catch(e){}}}});Ext.reg("profiles.tab.orderTypeDisplay",profiles.tab.orderTypeDisplay);
profiles.tab.orderTypeResumeConfirm=Ext.extend(Ext.Window,{width:400,modal:true,shadow:false,autoScroll:true,autoHeight:true,buttonAlign:"center",closeAction:"hide",order_id:0,initComponent:function(){this.items=[{html:ProfileOrderTypeResumeConfirmLang.messages.saved_order_add_or_replace,border:false,frame:false}];this.buttons=[{xtype:"button",text:ProfileOrderTypeResumeConfirmLang.buttons.add,handler:this.addToOrderHandler,scope:this},{xtype:"button",text:ProfileOrderTypeResumeConfirmLang.buttons.replace,handler:this.replaceOrderHandler,scope:this}];profiles.tab.orderTypeResumeConfirm.superclass.initComponent.call(this);},initEvents:function(){this.on("show",this.setWindowProperties,this);profiles.tab.orderTypeResumeConfirm.superclass.initEvents.call(this);},setWindowProperties:function(){var _1=Ext.get(this.id).getCenterXY();this.setPosition(_1[0],_1[1]);},setOrderId:function(_2){this.order_id=_2;},addToOrderHandler:function(){this.fireEvent("orderChoice","addToOrder",this.order_id);},replaceOrderHandler:function(){this.fireEvent("orderChoice","replaceOrder",this.order_id);}});Ext.reg("profiles.tab.orderTypeResumeConfirm",profiles.tab.orderTypeResumeConfirm);
profiles.tab.orderHistorySearch=Ext.extend(Ext.form.FormPanel,{border:false,buttonAlign:"left",url:"json.php?target=order&area=C",statusComboStoreType:"orderStatus_list",shippingLocationStoreType:"shippingLocations_list",billingLocationStoreType:"billingLocations_list",paymentStatusStoretype:"payment_status_list",defaultPaymentStatusId:"",labelAlign:"right",labelWidth:110,fieldWidth:50,orderType:"",includeOrderNum:true,includeExternalOrderNum:true,includeStatus:true,includeShippingLocation:true,includeTotal:true,includeDate:true,includePurchaseOrderNum:true,includeInvoiceNum:true,allowOpenDateSearch:false,includeButtons:true,availSearchFields:null,title:">> Order History Search",lang:{},initComponent:function(){var _1=this._genColumnCfg();var i,cw,l=_1.length;if(l){var _5=[];cw=1/l;for(i=0;i<l;i++){_5.push({xtype:"panel",layout:"form",border:false,columnWidth:cw,items:this._genFieldCfg(_1[i],(l>1?"85%":"55%"))});}
this.items=[{xtype:"panel",border:false,layout:"column",collapsible:false,autoHeight:true,items:_5}];}else{this.items=[{xtype:"panel",border:false,html:"&nbsp;"}];}
if(this.includeButtons){this.buttons=[{xtype:"button",text:this.lang.buttons.search,handler:this.handleSearchButton.createDelegate(this)},{xtype:"button",text:this.lang.buttons.clear_search,handler:this.handleClearSearchButton.createDelegate(this)}];}
profiles.tab.orderHistorySearch.superclass.initComponent.call(this);},_genFieldCfg:function(_6,_7){var _8=[];var _9,i,o,l=_6.length;for(i=0;i<l;i++){o=_6[i];switch(o["field"]){case"order_id":case"external_order_id":case"int_field_1":case"int_field_2":case"int_field_3":case"int_field_4":case"int_field_5":_8.push({xtype:"numberfield",name:o["form_name"],fieldLabel:o["label"],anchor:(_7||"80%"),listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}});break;case"status":if(!(this.statusComboStore=Ext.StoreMgr.lookup(this.statusComboStoreType))){this.statusComboStore=Ext.StoreMgr.add(this.statusComboStoreType,new Ext.data.JsonStore({url:this.url+"&method=getSearchableOrderStatuses",autoLoad:true,root:"data",totalProperty:"numFound",fields:["status","description"],baseParams:{type:this.orderType}}));}
_8.push({xtype:"combo",store:this.statusComboStore,fieldLabel:o["label"],hiddenName:o["form_name"],typeAhead:false,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true,displayField:"description",value:"",valueField:"status",anchor:(_7||"80%")});break;case"shipping_location":if(!(this.shippingLocationStore=Ext.StoreMgr.lookup(this.shippingLocationStoreType))){this.shippingLocationStore=Ext.StoreMgr.add(this.shippingLocationStoreType,new Ext.data.JsonStore({url:this.url+"&method=getShippingLocation",autoLoad:true,root:"data",totalProperty:"numFound",fields:["shipping_id","description"]}));}
_8.push({xtype:"combo",store:this.shippingLocationStore,fieldLabel:o["label"],hiddenName:o["form_name"],typeAhead:false,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true,displayField:"description",valueField:"shipping_id",anchor:(_7||"80%")});break;case"billing_location":if(!(this.billingLocationStore=Ext.StoreMgr.lookup(this.billingLocationStoreType))){this.billingLocationStore=Ext.StoreMgr.add(this.billingLocationStoreType,new Ext.data.JsonStore({url:this.url+"&method=getBillingLocation",autoLoad:true,root:"data",totalProperty:"numFound",fields:["billing_id","description"]}));}
_8.push({xtype:"combo",store:this.billingLocationStore,fieldLabel:o["label"],hiddenName:o["form_name"],typeAhead:false,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true,displayField:"description",valueField:"billing_id",anchor:(_7||"80%")});break;case"order_type":this.orderTypeStore=new Ext.data.JsonStore({url:this.url+"&method=getOrdersOrderTypes",autoLoad:true,root:"data",totalProperty:"numFound",baseParams:{order_type:this.orderType},fields:["order_type_id","name"]});_8.push({xtype:"combo",store:this.orderTypeStore,fieldLabel:o["label"],hiddenName:o["form_name"],typeAhead:false,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true,displayField:"name",valueField:"order_type_id",anchor:(_7||"80%")});break;case"status_code":if(!(this.statusComboStore=Ext.StoreMgr.lookup(this.statusComboStoreType))){this.statusComboStore=Ext.StoreMgr.add(this.statusComboStoreType,new Ext.data.JsonStore({url:this.url+"&method=getSearchableOrderStatuses",autoLoad:true,root:"data",totalProperty:"numFound",fields:["status","description"],baseParams:{type:this.orderType}}));}
_8.push({xtype:"combo",store:this.statusComboStore,fieldLabel:o["label"],hiddenName:o["form_name"],typeAhead:false,mode:"local",value:"",forceSelection:true,triggerAction:"all",selectOnFocus:true,displayField:"status",valueField:"status",anchor:(_7||"80%")});break;case"payment_status_id":var id=Ext.id();var _e=new Ext.data.JsonStore({url:this.url+"&method=getPaymentStatuses",autoLoad:true,root:"data",id:"payment_status_id",baseParams:{"display_is_yes":1,"current_user":1,"order_type":this.orderType},totalProperty:"numFound",fields:["payment_status_id","name"],listeners:{load:{fn:function(_f){try{var cmp=Ext.getCmp(id);var v=cmp.getValue();if(_f.getById(v)){cmp.setValue(v);}else{cmp.setValue("");}}
catch(e){}},single:true}}});_8.push({xtype:"combo",store:_e,id:id,fieldLabel:o["label"],hiddenName:o["form_name"],typeAhead:false,editable:false,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true,displayField:"name",value:this.defaultPaymentStatusId,valueField:"payment_status_id",anchor:(_7||"80%")});break;case"total":_8.push({xtype:"panel",border:false,layout:"column",items:[{layout:"form",border:false,items:[{xtype:"numberfield",name:"header[min_total]",fieldLabel:o["label"],width:70,allowNegative:true,listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}}],width:190},{layout:"form",border:false,items:[{xtype:"box",autoEl:{cn:" - "}}],width:5},{layout:"form",border:false,items:[{xtype:"numberfield",name:"header[max_total]",hideLabel:true,width:70,allowNegative:true,listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}}]}]});break;case"date":var _12={xtype:"radio",boxLabel:this.lang.label.all,fieldLabel:o["label"],name:"date_range",inputValue:"all",checked:true,id:this.id+"-date_range_all",listeners:{"check":{fn:this.handleDateRadioChange,scope:this}}};var _13={xtype:"radio",boxLabel:this.lang.label.choose,hideLabel:true,name:"date_range",inputValue:"limit",id:this.id+"-date_range_limit"};this.dateFromField=new Ext.form.DateField({hideLabel:true,name:"from_date",format:"m/d/Y",width:75});this.dateToField=new Ext.form.DateField({hideLabel:true,name:"to_date",format:"m/d/Y",width:75});if(!this.allowOpenDateSearch){_12.checked=false;_13.checked=true;this.dateFromField.allowBlank=false;this.dateToField.allowBlank=false;var _14=new Date();_14=_14.format("m/d/Y");this.dateFromField.value=_14;this.dateToField.value=_14;}else{_12.checked=true;_13.checked=false;this.dateFromField.disabled=true;this.dateToField.disabled=true;}
_8.push({xtype:"panel",border:false,layout:"column",items:[{layout:"form",border:false,items:_12,width:170},{layout:"form",border:false,items:_13}]},{xtype:"panel",border:false,layout:"column",style:"padding-left:"+(this.labelWidth+5)+"px;",items:[{layout:"form",border:false,items:[this.dateFromField],width:80},{layout:"form",border:false,labelWidth:20,items:[{xtype:"box",autoEl:{cn:" - "}}],width:4},{layout:"form",border:false,items:[this.dateToField]}]});break;default:_8.push({xtype:"textfield",name:o["form_name"],fieldLabel:o["label"],anchor:(_7||"80%"),listeners:{"specialkey":{fn:this.checkForEnter,scope:this}}});break;}}
return _8;},_genColumnCfg:function(){var _15=[];var _16={};var _17=[];if(Ext.isArray(this.availSearchFields)){var n,o,i,l=this.availSearchFields.length;for(i=0;i<l;i++){o=this.availSearchFields[i];if(!this._isValidField(o["field"])){continue;}
n=parseInt(o["column"])||1;o["form_name"]=(o["group"]||"header")+"["+(o["map"]||o["field"])+"]";if(!_16["col"+n]){_15.push(n);_16["col"+n]=[];}
_16["col"+n].push(o);}
_15.sort(function(a,b){return a-b;});l=_15.length;for(i=0;i<l;i++){_17.push(_16["col"+_15[i]]);}}
return _17;},_isValidField:function(_1e){switch(_1e){case"order_id":case"external_order_id":case"int_field_1":case"int_field_2":case"int_field_3":case"int_field_4":case"int_field_5":case"str_field_1":case"str_field_2":case"str_field_3":case"str_field_4":case"str_field_5":case"str_field_6":case"str_field_7":case"str_field_8":case"str_field_9":case"str_field_10":case"str_field_11":case"str_field_12":case"str_field_13":case"purchase_order_number":case"document_number":case"sales_order_number":case"status":case"shipping_location":case"billing_location":case"total":case"date":case"order_type":case"order_title":case"status_code":case"payment_status_id":case"product_code":case"product_name":case"amount":case"price":return true;break;default:return false;break;}},initEvents:function(){profiles.tab.orderHistorySearch.superclass.initEvents.call(this);},checkForEnter:function(f,e){if(e.getKey()==e.ENTER){this.handleSearchButton();}},handleSearchButton:function(){if(this.getForm().isValid()){var _21=this.getForm().getValues();if(!this.allowOpenDateSearch){if(_21["date_range"]!="limit"||Ext.isEmpty(_21["date_range"])||Ext.isEmpty(_21["date_range"])){Ext.Msg.alert(this.lang.messages.error_title,this.lang.messages.date_required_for_search);}else{this.fireEvent("searchPerformed",_21);}}else{this.fireEvent("searchPerformed",_21);}}else{this.getForm().markInvalid();}},handleClearSearchButton:function(){var _22=this.getForm();_22.reset();this.fireEvent("clearSearch");},handleDateRadioChange:function(_23,_24){if((_23.id==this.id+"-date_range_all"&&_24)||(_23.id==this.id+"-date_range_limit"&&!_24)){this.dateFromField.disable();this.dateToField.disable();}else{if((_23.id==this.id+"-date_range_all"&&!_24)||(_23.id==this.id+"-date_range_limit"&&_24)){this.dateFromField.enable();this.dateToField.enable();}}}});Ext.reg("profiles.tab.orderHistorySearch",profiles.tab.orderHistorySearch);
profiles.tab.orderTypeGrid=Ext.extend(Ext.grid.GridPanel,{autoHeight:true,autoScroll:true,border:false,url:"json.php?target=order&area=C",common_url:"json.php?area=C&target=common",downloadMethod:"&method=exportOrdersList",downloadLink:"&method=downloadExportedOrdersList",remoteDetailMethod:"&method=remoteDetail",pageSizeStoreType:"pagination_pagesize",_window:null,orderType:"",initQuery:"",usePicklistFunctionality:false,resumeOrAddChoiceWin:null,_loadMask:null,limit:10,downloadLimit:0,pagingToolbarWidth:650,remoteSort:false,defaultSort:false,doNotAutoload:false,enableHdMenu:false,viewConfig:{autoFill:true},height:575,stripeRows:true,includeSearchButtons:true,includePagination:true,includePageSize:true,allowExport:true,allowPayInvoices:false,excludeZeroPayInvoices:false,payInvoiceLimitField:"",__selectedIds:null,__piLimitFieldVal:null,_invoiceWin:null,__selectionChange:false,lineItemDisplayIncluded:false,_recordId:"order_id",payInvoiceTotalField:"total_outstanding",payInvoiceUrl:"",exportLimit:0,avail_columns:null,col_headers:null,orderSelectOption:false,storeFields:[],_viewLinkLabel:"",initComponent:function(){var _1=[];if(this.allowPayInvoices){this._recordId="order_id";this.sm=new Ext.grid.CheckboxSelectionModel({header:"",renderer:this.checkBoxRender.createDelegate(this),listeners:{beforerowselect:this._isValidCheckSelect.createDelegate(this),rowselect:this._addToSelectIds.createDelegate(this),rowdeselect:this._removeFromSelectIds.createDelegate(this)}});_1.push(this.sm);this.avail_columns.push({field:"view_order",label:"",sortable:false});this.storeFields.push("view_order");switch(this.orderSelectOption){case"download_file":case"download_pdf":case"download":this._viewLinkLabel=ProfileOrderTypeDisplayLang.label.download;break;default:this._viewLinkLabel=ProfileOrderTypeDisplayLang.label.view;break;}}else{this._recordId=(this.lineItemDisplayIncluded)?"order_item_id":"order_id";}
this.viewConfig={autoFill:true,emptyText:ProfileOrderTypeDisplayLang.label.empty};var q;if(this.initQuery){q=Ext.util.JSON.encode(this._prepareSearchQuery(this.initQuery));}
this.store=new Ext.data.JsonStore({url:this.url+"&method=getDisplayOrdersByType",root:"data",id:this._recordId,totalProperty:"numFound",fields:this.storeFields,pruneModifiedRecords:true,remoteSort:this.remoteSort,sortInfo:(this.defaultSort||false),baseParams:{type:this.orderType,limit:this.limit,query:q}});this.col_headers={};for(var i in this.avail_columns){if(this.avail_columns[i].field){var _4=({header:this.avail_columns[i].label,dataIndex:this.avail_columns[i].field,hidden:(this.avail_columns[i].available=="N")?true:false,id:this.avail_columns[i].field,sortable:this.avail_columns[i].sortable=="Y"?true:false});this.col_headers[this.avail_columns[i].field]=this.avail_columns[i].label;switch(this.avail_columns[i].field){case"status":_4.renderer=this.statusCellRenderer.createDelegate(this);break;case"rename_order":_4.renderer=this.renameOrderRenderer.createDelegate(this);_4.width=35;_4.align="center";break;case"resume_order":_4.renderer=this.editOrderRenderer.createDelegate(this);_4.width=50;_4.align="center";break;case"delete_order":_4.renderer=this.deleteOrderRenderer.createDelegate(this);_4.width=30;_4.align="center";break;case"quick_edit":_4.renderer=this.quickEditRenderer.createDelegate(this);_4.width=30;_4.align="center";break;case"view_order":_4.renderer=this.viewOrderRenderer.createDelegate(this);_4.width=30;_4.align="center";break;default:_4.width=30;break;}
_4.css=this.avail_columns[i].field;_1.push(_4);}}
this.cm=new Ext.grid.ColumnModel(_1);this.tbar=[];if(this.includeSearchButtons){this.tbar.push({xtype:"button",text:ProfileOrderTypeDisplayLang.button.search,handler:this.handleSearch.createDelegate(this)});this.tbar.push({xtype:"button",text:ProfileOrderTypeDisplayLang.button.clear_search,handler:this.handleClearSearch.createDelegate(this)});}
if(this.allowPayInvoices){this.tbar.push({xtype:"button",id:this.getId()+"-pi",text:ProfileOrderTypeDisplayLang.button.pay_selected,handler:this.handlePayInvoices.createDelegate(this),disabled:true});}
this.tbar.push({xtype:"tbfill"});if(this.allowExport){this.tbar.push({xtype:"button",text:ProfileOrderTypeDisplayLang.button.export_results,handler:this.handleExport.createDelegate(this)});}
if(this.includePageSize){if(!(this.paginationStore=Ext.StoreMgr.lookup(this.pageSizeStoreType))){this.paginationStore=Ext.StoreMgr.add(this.pageSizeStoreType,new Ext.data.JsonStore({url:this.common_url+"&method=getPagesizes",root:"data",fields:["pagesize"],autoLoad:true}));}
this.tbar.push({xtype:"label",text:ProfileOrderTypeDisplayLang.label.pageSize});this.tbar.push({xtype:"combo",store:this.paginationStore,width:this.pageSizeComboWidth,value:this.limit,listWidth:this.pageSizeComboWidth,displayField:"pagesize",typeAhead:false,mode:"local",triggerAction:"all",listeners:{"select":{fn:this.setPageSize,scope:this}}});}
if(this.includePagination){this.bbar=new Ext.PagingToolbar({store:this.store,pageSize:parseInt(this.limit),displayInfo:true});}
profiles.tab.orderTypeGrid.superclass.initComponent.call(this);},initEvents:function(){if(!this.allowPayInvoices){this.on("cellclick",this.trySelectOrder,this);this.store.on("load",this.updateTotal,this,{buffer:100});}else{this.store.on("load",this._preSelectChecks,this,{buffer:100});}
profiles.tab.orderTypeGrid.superclass.initEvents.call(this);},afterRender:function(){profiles.tab.orderTypeGrid.superclass.afterRender.call(this);if(!this.doNotAutoload){this.store.load.defer(100,this.store);}},trySelectOrder:function(_5,_6,_7,e){var _9=this.getColumnModel().getDataIndex(_7);switch(_9){case"rename_order":case"resume_order":case"delete_order":case"quick_edit":return;break;default:this._viewOrderRecord(_6);break;}},_viewOrderRecord:function(_a){var _b=this.getStore().getAt(_a);if(_b){if(this.orderSelectOption!="none"){switch(this.orderSelectOption){case"window":this.launchInvoiceWindow(_b);break;case"download_file":case"download_pdf":case"download":this.launchRemoteDetailConfirm(_b);break;default:window.location.href="order-"+_b.get("order_id")+".html";break;}}}},_getLabel:function(_c){if(ProfileOrderTypeDisplayLang.label[_c]){return ProfileOrderTypeDisplayLang.label[_c];}else{_c=_c.replace(/_/g," ");_c=this._capitalize(_c);return _c;}},_capitalize:function(_d){return _d.replace(/(^|\s)([a-z])/g,function(m,p1,p2){return p1+p2.toUpperCase();});},launchInvoiceWindow:function(_11){if(_11&&_11.data){var _12=new Ext.XTemplate("<tpl for=\".\">","<div class=\"wse-hd\">","<div class=\"wse-soldto\"><span class=\"wse-lbl\">"+this._getLabel("billing_location")+": </span><span class=\"wse-val\">{company}</span></div>","<div class=\"wse-orddtl\">","<h2>"+ProfileOrderTypeDisplayLang.label.orderDetail+"</h2>","<p><span class=\"wse-lbl\">"+this._getLabel("order_id")+": </span><span class=\"wse-val\">{external_order_id}</span></p>","<p><span class=\"wse-lbl\">"+this._getLabel("purchase_order_number")+": </span><span class=\"wse-val\">{purchase_order_number}</span></p>","<p><span class=\"wse-lbl\">"+this._getLabel("date")+": </span><span class=\"wse-val\">{date}</span></p>","</div>","</div>","<tpl if=\"line_items\">","<div class=\"wse-tbl\">","<table cellspacing=\"0\" summary=\"\">","<thead>","<tr>","<th class=\"ws-th-sku\">"+this._getLabel("product_code")+"</th>","<th class=\"ws-th-name\">"+this._getLabel("product_name")+"</th>","<th class=\"ws-th-status\">"+this._getLabel("status")+"</th>","<th class=\"ws-th-docnum\">"+this._getLabel("document_number")+"</th>","<th class=\"ws-th-qty\">"+this._getLabel("quantity")+"</th>","<th class=\"ws-th-price\">"+this._getLabel("extended_price")+"</th>","</tr>","</thead>","<tpl for=\"line_items\">","<tr>","<td class=\"ws-td-sku\">{product_code}&nbsp;</td>","<td class=\"ws-td-name\">{product_name}&nbsp;</td>","<td class=\"ws-td-status\">{str_field_4}&nbsp;</td>","<td class=\"ws-td-docnum\">{str_field_5}&nbsp;</td>","<td class=\"ws-td-qty\">{amount}&nbsp;</td>","<td class=\"ws-td-price\">{extended_amount}&nbsp;</td>","</tr>","<tr>","<td class=\"ws-td-notes\" colspan=\"7\"><span></span></td>","</tr>","</tpl>","</table>","</div>","</tpl>","<tpl if=\"tracking_numbers\">","<div class=\"wse-tbl-trk\">","<table cellspacing=\"0\" summary=\"\">","<tpl for=\"tracking_numbers\">","<tr>","<td class=\"ws-td-trk-lbl\">","<tpl if=\"xindex == 1\">"+this._getLabel("tracking_numbers")+"</tpl>","</td>","<td class=\"ws-td-trk\">","<tpl if=\"values.tracking_link\">{tracking_link}</tpl>","<tpl if=\"!values.tracking_link\">{tracking_number}</tpl>","<tpl if=\"values.carrier_name\"> ({carrier_name})</tpl>","</td>","</tr>","</tpl>","</table>","</div>","</tpl>","</tpl>");var win=new Ext.Window({height:575,width:900,autoScroll:true,modal:true,cls:"wse-win-ordr",html:"<div class=\"wse-wrap\">"+_12.apply(_11.data)+"</div>"});win.show();}},launchRemoteDetailConfirm:function(_14){Ext.Msg.show({title:ProfileOrderTypeDisplayLang.file_download.confirm_title,msg:ProfileOrderTypeDisplayLang.file_download.confirm_message,buttons:Ext.Msg.YESNO,icon:Ext.Msg.QUESTION,fn:this.launchRemoteDetailConfirmHandler.createDelegate(this,[_14],true),scope:this});},_showLoadMask:function(){try{if(!this._loadMask){this._loadMask=new Ext.LoadMask(Ext.getBody(),{msg:ProfileOrderTypeDisplayLang.file_download.loading});}
this._loadMask.show();}
catch(e){}},_hideLoadMask:function(){try{this._loadMask.hide();}
catch(e){}},launchRemoteDetailConfirmHandler:function(btn,_16,obj,_18){if(btn=="yes"||btn=="YES"){this._showLoadMask();Ext.Ajax.request({url:this.url+this.remoteDetailMethod,params:{order_id:_18.data.order_id},scope:this,callback:this.handleRemoteDetailCallback});}},handleRemoteDetailCallback:function(_19,_1a,_1b){this._hideLoadMask();var _1c=Ext.util.JSON.decode(_1b.responseText);if(_1a&&_1c.callback_url){window.location.href=_1c.callback_url;}
if(!_1a||!_1c.success){webStore.displayConfirmMessageFromAjax(_19,_1a,_1b);}},renameOrderRenderer:function(_1d,_1e,_1f,_20){return"<a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').renameOrder("+_20+"); return false;\">"+ProfileOrderTypeDisplayLang.button.rename+"</a>";},editOrderRenderer:function(_21,_22,_23,_24){return"<a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').resumeOrder("+_24+"); return false;\">"+ProfileOrderTypeDisplayLang.button.resume+"</a>";},quickEditRenderer:function(_25,_26,_27,_28){return"<a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').editPicklist("+_28+"); return false;\">"+ProfileOrderTypeDisplayLang.button.edit+"</a>";},deleteOrderRenderer:function(_29,_2a,_2b,_2c){return"<a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').deletePicklist("+_2c+"); return false;\">"+ProfileOrderTypeDisplayLang.button.delete_picklist+"</a>";},viewOrderRenderer:function(_2d,_2e,_2f,_30){if(_2d=="Y"){return"<a href=\"#\" onclick=\"Ext.getCmp('"+this.id+"').viewOrder("+_30+"); return false;\">"+this._viewLinkLabel+"</a>";}else{return"";}},statusCellRenderer:function(_31,_32,_33){if(_33&&_33.data&&_33.data.status_code){_31="<span class=\"wse-status-"+_33.data.status_code+"\">"+_31+"</span>";}
return _31;},editPicklist:function(row){var _35=this.store.getAt(row);if(_35&&_35.id){Ext.Ajax.request({url:this.url+"&method=editPicklist",params:{order_id:_35.data.order_id},scope:this,callback:this.handleEditPicklistLoad});}},handleEditPicklistLoad:function(_36,_37,_38){var _39=Ext.util.JSON.decode(_38.responseText);if(!_37||!_39.success){webStore.displayConfirmMessageFromAjax(_36,_37,_38);}
if(_39.success){var _3a=new prodQuickAdd.Window({title:ProfileOrderTypeDisplayLang.prodQuickAddAppLang.title,closeAction:"close",lang:ProfileOrderTypeDisplayLang.prodQuickAddAppLang});_3a.show();}},renameOrder:function(row){var _3c=this.store.getAt(row);if(_3c&&_3c.id){this.orderNameWin=new OrderNameWin({title:ProfileOrderTypeDisplayLang.orderNameWin.title,lang:ProfileOrderTypeDisplayLang.orderNameWin,saveAction:"save",order_id:_3c.data.order_id,listeners:{"orderNameSaved":{fn:this.orderNameSaved,scope:this}}});this.orderNameWin.setOrderNameValue(_3c.data.order_title);this.orderNameWin.show();}},orderNameSaved:function(){this.store.load();},deletePicklist:function(row){var _3e=this.store.getAt(row);if(_3e&&_3e.id){Ext.Ajax.request({url:this.url+"&method=deletePicklist",params:{order_id:_3e.data.order_id},scope:this,callback:this.handleDeleteRecord});}},viewOrder:function(row){this._viewOrderRecord(row);},handleDeleteRecord:function(_40,_41,_42){webStore.displayConfirmMessageFromAjax(_40,_41,_42);this.store.load();},resumeOrder:function(row){var _44=this.store.getAt(row);if(_44.data.order_id){if(!this.resumeOrAddChoiceWin){this.resumeOrAddChoiceWin=new profiles.tab.orderTypeResumeConfirm({title:ProfileOrderTypeResumeConfirmLang.title,listeners:{"orderChoice":{fn:this.handleOrderChoice,scope:this}}});}
this.resumeOrAddChoiceWin.setOrderId(_44.data.order_id);this.resumeOrAddChoiceWin.show();}},handleOrderChoice:function(_45,_46){this.showLoadMask();if(_45=="addToOrder"){Ext.Ajax.request({url:this.url+"&method=addSavedOrderToCart",params:{order_id:_46},scope:this,callback:this.handleAddToOrder});}else{if(_45=="replaceOrder"){Ext.Ajax.request({url:this.url+"&method=replaceCartWithSavedOrder",params:{order_id:_46},scope:this,callback:this.handleReplaceOrder});}}
if(this.resumeOrAddChoiceWin){this.resumeOrAddChoiceWin.hide();}},handleAddToOrder:function(_47,_48,_49){this.hideLoadMask();webStore.displayConfirmMessageFromAjax(_47,_48,_49);},handleReplaceOrder:function(_4a,_4b,_4c){this.hideLoadMask();webStore.displayConfirmMessageFromAjax(_4a,_4b,_4c);},showLoadMask:function(){try{if(!this._loadMask){this._loadMask=new Ext.LoadMask(this.getEl(),{msg:ProfileOrderTypeDisplayLang.mask.updating_cart});}
this._loadMask.show();}
catch(e){}},hideLoadMask:function(){try{if(this._loadMask){this._loadMask.hide();}}
catch(e){}},setPageSize:function(_4d,_4e,_4f){if(_4e&&_4e.data){this.limit=_4e.data.pagesize;if(this.ptoolbar){this.ptoolbar.pageSize=this.limit;}
this.refreshHandler();}},refreshHandler:function(){this.store.baseParams["limit"]=this.limit;this.store.load();},handleExport:function(){Ext.MessageBox.show({title:ProfileOrderTypeDisplayLang.download.title,msg:ProfileOrderTypeDisplayLang.download.message,progressText:ProfileOrderTypeDisplayLang.download.progress,width:300,progress:true,closeable:false});this.generateLogDownload(0,"",this.store.baseParams);},generateLogDownload:function(_50,_51,_52){var _53;var _54;var dir;if(_52["query"]){_53=_52["query"];}
if(_52["sort"]){_54=_52["sort"];}
if(_52["dir"]){dir=_52["dir"];}
limit=this.limit;Ext.Ajax.request({url:this.url+this.downloadMethod,success:this.generateLogDownloadSuccessCallback.createDelegate(this,[_50,_52],true),failure:this.generateLogDownloadFailureCallback.createDelegate(this),params:{type:this.orderType,start:_50,limit:limit,sort:_54,dir:dir,query:_53,filepath:_51,export_limit:this.exportLimit},timeout:60000,scope:this});},generateLogDownloadSuccessCallback:function(_56,_57,_58,_59){var _5a=Ext.util.JSON.decode(_56.responseText);if(_5a.percent_complete==100){Ext.MessageBox.hide();this.downloadResults(_5a.filepath);}else{Ext.MessageBox.updateProgress(_5a.percent_complete/100,_5a.percent_complete+"% "+ProfileOrderTypeDisplayLang.message.complete);var _58=_57.params.start,_5b=_57.params.limit;this.generateLogDownload(_58+_5b,_5a.filepath,_59);}},generateLogDownloadFailureCallback:function(_5c,_5d){webStore.displayMessage(ProfileOrderTypeDisplayLang.message.downloadErrorMsg+_5c.statusText,ProfileOrderTypeDisplayLang.message.downloadErrorTitle,"error");},downloadResults:function(_5e){if(_5e){window.open(this.url+this.downloadLink+"&path="+_5e);}},handleSearch:function(){this.fireEvent("performSearch");},handleClearSearch:function(){this.fireEvent("clearSearch");},_prepareSearchQuery:function(_5f){var o={};var l,k="";if(_5f){for(i in _5f){if(i.search("line_item")>-1){k="line_item";}else{k="header";}
if(k){l=i.replace(k,"");l=l.replace("]","");l=l.replace("[","");if(!o[k]){o[k]={};}
o[k][l]=_5f[i];}}}
return o;},performSearch:function(_63){var o=this._prepareSearchQuery(_63);this.store.baseParams.query=Ext.util.JSON.encode(o);this.store.load();},clearSearch:function(){var q="";if(this.initQuery){q=Ext.util.JSON.encode(this._prepareSearchQuery(this.initQuery));}
this.store.baseParams.query=q;if(!this.doNotAutoload){this.store.load();}else{this.store.removeAll();}},updateTotal:function(_66,_67,_68){if(_66&&_66.reader&&_66.reader.jsonData&&_66.reader.jsonData.total){this.fireEvent("updateTotal",_66.reader.jsonData.total);}else{this.fireEvent("updateTotal","0.00");}},checkBoxRender:function(v,p,_6b){if(!this._isPayInvoiceRecord(_6b)){return"&nbsp;";}
if(!this._meetsPayInvoiceLimit(_6b)){return"<div class=\"x-grid3-row-checker wse-faux-check\">&#160;</div>";}
return"<div class=\"x-grid3-row-checker\">&#160;</div>";},_isPayInvoiceRecord:function(_6c){if(!_6c){return false;}
if(_6c.data["payable"]!="Y"){return false;}
if(this.excludeZeroPayInvoices){try{var v=parseFloat(_6c.get(this.payInvoiceTotalField));if(!(v>0)&&!(v<0)){return false;}}
catch(e){return false;}}
return true;},_isValidCheckSelect:function(sm,_6f,ke,_71){if(!this._isPayInvoiceRecord(_71)){return false;}
if(!this._meetsPayInvoiceLimit(_71)){return false;}
return true;},_meetsPayInvoiceLimit:function(_72){if(_72){if(!this.payInvoiceLimitField){return true;}else{var v=_72.get(this.payInvoiceLimitField);if(v){if(!this.__piLimitFieldVal){return true;}
if(v==this.__piLimitFieldVal){return true;}}}}
return false;},_initSelectIds:function(){if(!this.__selectedIds){this.__selectedIds=[];}},_addToSelectIds:function(sm,_75,_76){if(_76&&_76.id){this._initSelectIds();if(this.__selectedIds.indexOf(_76.id)==-1){this.__selectedIds.push(_76.id);this.__selectionChange=true;}
if(this.payInvoiceLimitField&&!this.__piLimitFieldVal){this.__piLimitFieldVal=_76.get(this.payInvoiceLimitField);this.getView().refresh();}
this._updatePayInvoiceFeatures();}},_removeFromSelectIds:function(sm,_78,_79){if(_79&&_79.id){this._initSelectIds();var i=this.__selectedIds.indexOf(_79.id);if(i>=0){this.__selectedIds.splice(i,1);this.__selectionChange=true;}
this._updatePayInvoiceFeatures();}},_updatePayInvoiceFeatures:function(){this._initSelectIds();var n=this.__selectedIds.length;if(!n&&this.__piLimitFieldVal){this.__piLimitFieldVal=null;this.getView().refresh();}
try{Ext.getCmp(this.getId()+"-pi")[n?"enable":"disable"]();}
catch(e){}},_preSelectChecks:function(_7c,_7d){if(this.__selectedIds&&Ext.isArray(_7d)){var _7e=[];var i,l=_7d.length;for(i=0;i<l;i++){if(this.__selectedIds.indexOf(_7d[i].id)>=0){_7e.push(_7d[i]);}}
if(_7e.length){this.getSelectionModel().selectRecords(_7e);}}},handlePayInvoices:function(btn){if(this.__selectedIds){if(!this._invoiceWin){var _82=[];for(var i in this.avail_columns){if(this.avail_columns[i].available=="N"||!this.avail_columns[i].field){continue;}
switch(this.avail_columns[i].field){case"status":case"rename_order":case"resume_order":case"delete_order":case"quick_edit":case"view_order":continue;break;default:_82.push({header:this.avail_columns[i].label,dataIndex:this.avail_columns[i].field,id:this.avail_columns[i].field,sortable:false,width:30});break;}}
this._invoiceWin=new profiles.comps.PayInvoiceWindow({columns:_82,storeFields:this.storeFields,payInvoiceTotalField:this.payInvoiceTotalField,orderType:this.orderType,payInvoiceUrl:this.payInvoiceUrl});}
if(this.__selectionChange){this._invoiceWin.loadOrders(this.__selectedIds);this.__selectionChange=false;}
this._invoiceWin.show();}}});Ext.reg("profiles.tab.orderTypeGrid",profiles.tab.orderTypeGrid);
profiles.comps.addressForm=Ext.extend(Ext.form.FormPanel,{autoHeight:true,_layoutForced:false,frame:false,border:false,componentWidth:230,checkboxAnchor:"99%",labelWidth:130,bodyStyle:"padding: 20px 20px 0 20px",labelAlign:"left",buttonAlign:"left",json_url:"json.php",edit_url:"json.php?target=user&method=edit",save_url:"json.php?target=user&method=save",_userId:0,user_type:"customer",childAccount:false,mode:"add",countryCode:"us",validation_style:"side",redirectOnSave:true,redirectActive:"",redirect_url:"",requireNewAccountTermsCheck:true,_wholesale:{},_customerAccount:{},_formItemGenerated:{"tax_id":false,"wholesale_request":false,"account_number_request":false},_termsWindow:{},initComponent:function(){this.toggleLabelWidth=this.labelWidth-10;webStore.countryList.load();webStore.stateList.load();var _1=[{xtype:"hidden",id:this.id+"-user-id",name:"data[user_id]"}];if(this.childAccount){_1.push({xtype:"hidden",name:"data[childAccount]",value:"Y"});}
if(AccountConfig.email_as_login=="Y"){_1.push(this._generateFormItem("email"));}else{_1.push({xtype:"textfield",id:this.id+"-user-login",fieldLabel:ProfileCustomerInfoLang.label.userName,name:"data[user_login]",width:this.componentWidth,allowBlank:false,msgTarget:this.validation_style,validator:this.validateForQuotes});}
_1.push({xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.firstName,id:this.id+"-firstname",name:"data[firstname]",width:this.componentWidth,allowBlank:false,msgTarget:this.validation_style,validator:this.validateInput.createDelegate(this,false,true)},{xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.lastName,id:this.id+"-lastname",name:"data[lastname]",width:this.componentWidth,allowBlank:false,msgTarget:this.validation_style,validator:this.validateInput.createDelegate(this,false,true)},{xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.company,id:this.id+"-company_field",name:"data[company]",allowBlank:(this.user_type=="dealer")?false:true,width:this.componentWidth,listeners:{"change":{fn:this.updateSiteHandle,scope:this}},validator:this.validateInput.createDelegate(this,true,true)},{fieldLabel:ProfileCustomerInfoLang.label.country,id:this.id+"-signup_country",hiddenName:"data[country]",width:this.componentWidth,xtype:"combo",store:webStore.countryList,valueField:"abbr",displayField:"country",typeAhead:true,mode:"local",triggerAction:"all",emptyText:ProfileCustomerInfoLang.emptyText.selectCountry,selectOnFocus:true,forceSelection:true,allowBlank:false,validator:this.validateForQuotes,msgTarget:this.validation_style,listeners:{"select":{fn:this.updateStateList,scope:this}}},{xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.address1,id:this.id+"-signup_address",name:"data[address_1]",width:this.componentWidth,allowBlank:false,validator:this.validateForQuotes,msgTarget:this.validation_style,validator:this.validateInput.createDelegate(this,false,true)},{xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.address2,id:this.id+"-signup_address2",name:"data[address_2]",width:this.componentWidth,msgTarget:this.validation_style,validator:this.validateForQuotes,validator:this.validateInput.createDelegate(this,true,true)},{xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.city,id:this.id+"-signup_city",name:"data[city]",width:this.componentWidth,allowBlank:false,validator:this.validateForQuotes,msgTarget:this.validation_style,validator:this.validateInput.createDelegate(this,false,true)},{fieldLabel:ProfileCustomerInfoLang.label.state,id:this.id+"-signup_state",hiddenName:"data[state]",width:this.componentWidth,xtype:"combo",store:webStore.stateList,valueField:"state",displayField:"state",typeAhead:true,mode:"local",triggerAction:"all",emptyText:ProfileCustomerInfoLang.emptyText.selectState,selectOnFocus:true,forceSelection:true,msgTarget:this.validation_style,allowBlank:false},{xtype:"textfield",id:this.id+"-signup_zip",fieldLabel:ProfileCustomerInfoLang.label.zipCode,width:this.componentWidth,labelWidth:this.labelWidth,width:this.componentWidth,name:"data[zip]",allowBlank:false,validator:this.validateForQuotes,msgTarget:this.validation_style,validator:this.validateInput.createDelegate(this,false,true)},{xtype:"PhoneField",fieldLabel:ProfileCustomerInfoLang.label.phone,id:this.id+"-phone",name:"data[phone]",width:this.componentWidth,allowBlank:false,msgTarget:this.validation_style},{xtype:"PhoneField",fieldLabel:ProfileCustomerInfoLang.label.fax,id:this.id+"-fax",name:"data[fax]",width:this.componentWidth,msgTarget:this.validation_style});if(AccountConfig.email_as_login!="Y"){_1.push(this._generateFormItem("email"));}
if(this.mode=="add"){if(this.user_type=="dealer"){_1.push({xtype:"hidden",name:"data[dealer_signup]",value:"1"},{xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.dealerNo,name:"data[cit_account_number]",width:this.componentWidth,allowBlank:false,maxLength:32},{xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.url,name:"data[url]",width:this.componentWidth,allowBlank:true},{xtype:"textfield",id:this.id+"-site-handle",fieldLabel:ProfileCustomerInfoLang.label.siteHandle,name:"data[cit_site_handle]",width:this.componentWidth,allowBlank:false,listeners:{"change":{fn:this.updateSiteHandle,scope:this}}},this._generateFormItem("tax_id"));}
_1.push({xtype:"profiles.comps.password",labelWidth:this.labelWidth,fieldWidth:this.componentWidth,passwordLabel:ProfileCustomerInfoLang.label.password,showProgressBar:false});if(AccountConfig.allow_wholesale=="Y"&&this.user_type!="dealer"){_1.push(this._generateFormItem("wholesale_request"));}
if(AccountConfig.allow_customer_account_number=="Y"){_1.push(this._generateFormItem("account_number_request"));}
if(this.requireNewAccountTermsCheck==true){_1.push({xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:ProfileCustomerInfoLang.label.acceptTermsView.replace("[1]","<span class=\"wse-lnk\" style=\"color: #094E81; cursor: pointer;\" onclick=\"openTermsWin(this); return false;\">"+ProfileCustomerInfoLang.button.view+"</a>"),name:"agree_terms_conditions",id:this.id+"-terms-check-box",inputValue:1});}
if(this.user_type=="dealer"){_1.push({xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:ProfileCustomerInfoLang.label.acceptPrivacyView.replace("[1]","<span class=\"wse-lnk\" style=\"color: #094E81; cursor: pointer;\" onclick=\"openPrivacyWin(this); return false;\">"+ProfileCustomerInfoLang.button.view+"</a>"),name:"agree_privacy",id:this.id+"-policy-check-box",inputValue:1,anchor:this.checkboxAnchor},{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:ProfileCustomerInfoLang.label.acceptPaymentView.replace("[1]","<span class=\"wse-lnk\" style=\"color: #094E81; cursor: pointer;\" onclick=\"Ext.getCmp('"+this.id+"').openTermsWindow(this, 'paymentProcess'); return false\">"+ProfileCustomerInfoLang.button.view+"</a>"),name:"agree_payment_process",id:this.id+"-payment-process-check-box",inputValue:1,anchor:this.checkboxAnchor},{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:ProfileCustomerInfoLang.label.acceptRestrictionsView.replace("[1]","<span class=\"wse-lnk\" style=\"color: #094E81; cursor: pointer;\" onclick=\"Ext.getCmp('"+this.id+"').openTermsWindow(this, 'restrictions'); return false;\">"+ProfileCustomerInfoLang.button.view+"</a>"),name:"agree_restrictions",id:this.id+"-restrictions-check-box",inputValue:1,anchor:this.checkboxAnchor},{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:ProfileCustomerInfoLang.label.acceptWsfView.replace("[1]","<span class=\"wse-lnk\" style=\"color: #094E81; cursor: pointer;\" onclick=\"Ext.getCmp('"+this.id+"').openTermsWindow(this, 'webService'); return false;\">"+ProfileCustomerInfoLang.button.view+"</a>"),name:"agree_web_services",id:this.id+"-web_services-check-box",inputValue:1,anchor:this.checkboxAnchor},{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:ProfileCustomerInfoLang.label.acceptQualificationsView.replace("[1]","<span class=\"wse-lnk\" style=\"color: #094E81; cursor: pointer;\" onclick=\"Ext.getCmp('"+this.id+"').openTermsWindow(this, 'qualifications'); return false;\">"+ProfileCustomerInfoLang.button.view+"</a>"),name:"agree_qualifications",id:this.id+"-qualifications-check-box",inputValue:1,anchor:this.checkboxAnchor});}}
_1=this.setAsterisksDisplay(_1);this.items=[{xtype:"fieldset",title:ProfileCustomerInfoLang.title.contactInfo,collapsible:false,id:this.id+"main-contact-fieldset",autoHeight:true,items:_1}];this.buttons=[{xtype:"button",text:ProfileCustomerInfoLang.button.save,disabled:true,hidden:true,cls:"wse-xbtn wse-xbtn-save",id:this.id+"-save-btn",handler:this.saveHandler,scope:this},{xtype:"button",text:ProfileCustomerInfoLang.button.cancel,disabled:true,hidden:true,id:this.id+"-cancel-btn",cls:"wse-xbtn wse-xbtn-minor wse-xbtn-cancel",handler:this.redirectUser,scope:this},{xtype:"button",text:ProfileCustomerInfoLang.button.continueShopping,disabled:true,hidden:true,id:this.id+"-continue-shopping-btn",cls:"wse-xbtn wse-xbtn-minor wse-xbtn-contshop",handler:this.redirectUser,scope:this},{xtype:"button",text:ProfileCustomerInfoLang.button.checkout,disabled:true,hidden:true,id:this.id+"-checkout-btn",cls:"wse-xbtn wse-xbtn-minor wse-xbtn-checkout",handler:this.redirectUser,scope:this}];profiles.comps.addressForm.superclass.initComponent.call(this);},initEvents:function(){profiles.comps.addressForm.superclass.initEvents.call(this);},forceLayout:function(){var _2=this.findByType("combo");for(i in _2){try{_2[i].syncSize();}
catch(e){}}},initializeForm:function(_3){if(this.mode=="update"){this._userId=_3;this.loadForm(_3);}else{this._setAccountNumberDisplay();}
this._setButtonDisplay();if(!this._layoutForced){this.forceLayout();this._layoutForced=true;}},_generateFormItem:function(_4,_5){var _6={};if(_4!="email"&&this._formItemGenerated[_4]===true){return{xtype:"panel",border:false,html:"",height:0};}
_5=(!_5)?false:true;switch(_4){case"email":_6={xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.email,id:this.id+"-email",name:"data[email]",width:this.componentWidth,vtype:"email",allowBlank:false,msgTarget:this.validation_style,validator:this.validateForQuotes,plugins:[Ext.ux.plugins.RemoteValidator],rvOptions:{url:"json.php?target=common&method=validateEmailAddress"}};break;case"tax_id":_6={xtype:"textfield",fieldLabel:ProfileCustomerInfoLang.label.taxId,name:"data[new_gov_tax_id]",allowBlank:_5,width:this.componentWidth};break;case"wholesale_request":_6={xtype:"fieldset",checkboxToggle:true,title:ProfileCustomerInfoLang.title.requestWholesale,autoHeight:true,collapsed:true,labelWidth:this.toggleLabelWidth,items:[this._generateFormItem("tax_id",true)]};break;case"account_number_request":_6={xtype:"fieldset",id:this.id+"-account-number-fieldset",checkboxToggle:true,title:ProfileCustomerInfoLang.title.requestAccountNumber,autoHeight:true,collapsed:true,labelWidth:this.toggleLabelWidth,items:[{xtype:"textfield",id:this.id+"-account-number",fieldLabel:ProfileCustomerInfoLang.label.accountNumber,name:"data[account_number]",allowBlank:true,width:this.componentWidth}]};break;default:return{};break;}
this._formItemGenerated[_4]=true;return _6;},_generateWholesaleDisplay:function(){if(AccountConfig.allow_wholesale=="Y"&&this.user_type=="customer"){var _7=Ext.getCmp(this.id+"main-contact-fieldset");if(this._wholesale["tax_id"]){_7.add({xtype:"fieldset",title:ProfileCustomerInfoLang.title.wholesaleStatus,collapsible:false,autoHeight:true,labelWidth:this.labelWidth,defaults:{width:this.componentWidth},defaultType:"textfield",items:[{fieldLabel:ProfileCustomerInfoLang.label.taxId,name:"data[set_gov_tax_id]",value:this._wholesale["tax_id"],allowBlank:false},{fieldLabel:ProfileCustomerInfoLang.label.requestStatus,name:"data[wholesaler_account_status]",value:this._wholesale["account_status"],disabled:true},{fieldLabel:ProfileCustomerInfoLang.label.dealersNotes,id:"set_wholesaler_status_notes",name:"data[wholesaler_status_notes]",value:this._wholesale["status_notes"],xtype:"textarea",height:100}]});}else{_7.add(this._generateFormItem("wholesale_request"));}
try{_7.doLayout();}
catch(e){}}},_generateAccountNumberDisplay:function(){if(AccountConfig.allow_customer_account_number=="Y"){var _8=Ext.getCmp(this.id+"main-contact-fieldset");if(this._customerAccount["account_number"]){_8.add({xtype:"textfield",id:this.id+"-account-number-status",fieldLabel:ProfileCustomerInfoLang.label.accountNumber,value:this._customerAccount["account_number_status"],width:this.componentWidth,cls:"ws-disabled-textfield",disabled:true});}else{_8.add(this._generateFormItem("account_number_request"));}
try{_8.doLayout();}
catch(e){}
this._setAccountNumberDisplay();}},_setAccountNumberDisplay:function(){if(AccountConfig.allow_customer_account_number=="Y"){var _9=Ext.getCmp(this.id+"-account-number-fieldset");var _a=Ext.getCmp(this.id+"-account-number");var _b=Ext.getCmp(this.id+"-account-number-status");if(_9){if(AccountConfig.dealer_selected=="Y"&&!this._customerAccount["account_number"]){_9.show();_a.enable();}else{_9.hide();_a.disable();}}
if(_b){if(AccountConfig.dealer_selected=="Y"&&this._customerAccount["account_number"]){_b.show();}else{_b.hide();}}}},_setButtonDisplay:function(){var _c=Ext.getCmp(this.id+"-save-btn");var _d=Ext.getCmp(this.id+"-cancel-btn");var _e=Ext.getCmp(this.id+"-continue-shopping-btn");var _f=Ext.getCmp(this.id+"-checkout-btn");switch(this.mode){case"add":if(AccountConfig.customer_info_buttons.save_button_dynamic=="Y"&&this.user_type=="dealer"){_c.setText(ProfileCustomerInfoLang.button.newDealer);}else{_c.setText(ProfileCustomerInfoLang.button.newCustomer);}
this._showBtn(_c);this._hideBtn(_d);this._hideBtn(_e);this._hideBtn(_f);break;case"update":if(this.user_type=="dealer"){this._hideBtn(_c);this._hideBtn(_d);this._hideBtn(_e);this._hideBtn(_f);}else{if(AccountConfig.customer_info_buttons.save_button_dynamic=="Y"){_c.setText(ProfileCustomerInfoLang.button.save);}else{_c.setText(ProfileCustomerInfoLang.button.save);}
this._showBtn(_c);if(AccountConfig.customer_info_buttons.allow_cancel_button=="Y"){this._showBtn(_d);}else{this._hideBtn(_d);}
if(AccountConfig.customer_info_buttons.allow_continue_shopping_button=="Y"){this._showBtn(_e);}else{this._hideBtn(_e);}
if(AccountConfig.customer_info_buttons.allow_checkout_button=="Y"){this._showBtn(_f);}else{this._hideBtn(_f);}}
break;default:break;}},_showBtn:function(el){el.enable();el.show();},_hideBtn:function(el){el.disable();el.hide();},setAsterisksDisplay:function(_12){if(AccountConfig.allow_asterisks=="Y"){var _13=AccountConfig.requiredFieldsString.split(",");var _14;var _15=[];for(i=0;i<_12.length;i++){if(_12[i].xtype!="hidden"){_14="&nbsp;";if((_12[i].xtype=="textfield"&&_12[i].inputType=="password")||_12[i].id==this.id+"-email"||_12[i].id==this.id+"-user-login"){_12[i].allowBlank=false;_14="*";}else{_12[i].allowBlank=true;for(j=0;j<_13.length;j++){if(_12[i].id==this.id+"-"+_13[j]){_14="*";_12[i].allowBlank=false;break;}}}
_15.push({xtype:"asteriskpanel",border:false,asteriskCharacters:_14,items:[_12[i]]});}else{_15.push(_12[i]);}}
return _15;}else{return _12;}},validateForQuotes:function(_16){var _17=_16.indexOf("'");var _18=_16.indexOf("\"");if(_17>-1||_18>-1){return ProfileCustomerInfoLang.message.fieldContainQuote;}
return true;},validateInput:function(_19,_1a){if(_1a){return true;}
var _1b=_19.trim();if(_1b.length==0){return ProfileCustomerInfoLang.message.requiredField;}
return true;},updateSiteHandle:function(_1c){if(this.user_type=="dealer"){Ext.getCmp(this.id+"-site-handle").setValue(this.removeIllegalChars(_1c.getValue()));}},removeQuotes:function(_1d){return _1d.replace(/[\'\"]/g,"");},removeIllegalChars:function(_1e){return _1e.replace(/[^a-zA-Z0-9\_\-]/g,"");},updateStateList:function(_1f,_20,_21,_22){var _23=Ext.getCmp(this.id+"-signup_state");var cc;if(_22){cc=_22;}else{if(_20.data){cc=_20.data.abbr;}}
if(cc){_23.store.reload({params:{country_code:cc},callback:this.updateStateRequired,scope:this});}},updateStateRequired:function(_25,_26,_27){var zip=Ext.getCmp(this.id+"-signup_zip");var _29=Ext.getCmp(this.id+"-signup_state");if(_25.length==0){zip.allowBlank=true;_29.allowBlank=true;_29.setValue();var _2a=this.getForm();_2a.clearInvalid();}else{if(this.allow_asterisks=="Y"){if((this.requiredFieldsString.indexOf("signup_zip")!==-1)||this.requiredFields.length==0){zip.allowBlank=false;}
if((this.requiredFieldsString.indexOf("signup_state")!==-1)||this.requiredFields.length==0){_29.allowBlank=false;}}else{zip.allowBlank=false;_29.allowBlank=false;}}},openTermsWindow:function(_2b,_2c){if(!this._termsWindow[_2c]){var _2d="terms_gateway";var _2e="";var _2f="";var _30=false;switch(_2c){case"paymentProcess":_2e="getPaymentProcessing";_2f="payment_process";_30=true;break;case"restrictions":_2e="getRestrictions";_2f="restrictions";_30=true;break;case"webService":_2e="getWebServiceFee";_2f="web_services_fee";_30=true;break;case"qualifications":_2e="getQualificationsAndRequirements";_2f="qualifications_and_requirements";_30=true;break;default:break;}
if(_30){this._termsWindow[_2c]=new TermsWin({method:_2e,url:this.json_url+"?target="+_2d,print_url:AccountConfig.urls.index_url+"?target=forms&mode=print_view&terms_src="+_2f});}}
try{this._termsWindow[_2c].show(_2b);}
catch(e){}},redirectUser:function(but,_32){var _33=AccountConfig.urls.index_url;switch(but.id){case this.id+"-checkout-btn":_33=AccountConfig.urls.cart_url;break;case this.id+"-cancel-btn":_33=AccountConfig.urls.profile_url;break;default:break;}
window.location.href=_33;},loadForm:function(_34){var _35=this.getForm();_35.waitMsgTarget=Ext.get("profile_main");var _36={user_id:0};if(_34){_36["user_id"]=_34;}
_35.load({url:this.edit_url,params:_36,waitMsg:ProfileCustomerInfoLang.mask.loadingData,success:this.loadHandler.createDelegate(this)});},loadHandler:function(_37,_38){if(_38.result&&_38.result.data){if(AccountConfig.allow_wholesale=="Y"){this._wholesale={"tax_id":_38.result.data["data[gov_tax_id]"],"account_status":_38.result.data["data[wholesaler_account_status]"],"status_notes":_38.result.data["data[wholesaler_status_notes]"]};this._generateWholesaleDisplay();}
if(AccountConfig.allow_customer_account_number=="Y"){this._customerAccount={"account_number":_38.result.data["data[account_number]"],"account_number_status":_38.result.data["data[account_number_status]"]};this._generateAccountNumberDisplay();}
this.updateStateList(null,null,null,_38.result.data["data[country]"]);}},saveHandler:function(but,_3a){var _3b=this.getForm();if(_3b.isValid()){var _3c=true;var _3d;if(this.user_type=="dealer"){_3d=Ext.getCmp(this.id+"-policy-check-box");if(_3d&&!_3d.checked){_3c=false;}
_3d=Ext.getCmp(this.id+"-payment-process-check-box");if(_3d&&!_3d.checked){_3c=false;}
_3d=Ext.getCmp(this.id+"-restrictions-check-box");if(_3d&&!_3d.checked){_3c=false;}
_3d=Ext.getCmp(this.id+"-web-services-check-box");if(_3d&&!_3d.checked){_3c=false;}
_3d=Ext.getCmp(this.id+"-qualifications-check-box");if(_3d&&!_3d.checked){_3c=false;}}
_3d=Ext.getCmp(this.id+"-terms-check-box");if(_3d&&!_3d.checked){_3c=false;}
if(_3c){this.fireEvent("saveInitiated");_3b.waitMsgTarget=Ext.get("profile_main");but.disable();_3b.submit({url:this.save_url,waitMsg:ProfileCustomerInfoLang.mask.saving,success:this.receiveSaveResults.createDelegate(this),failure:this.receiveSaveFailure.createDelegate(this)});}else{Ext.MessageBox.show({title:ProfileCustomerInfoLang.title.error,msg:ProfileCustomerInfoLang.message.errorTerms,buttons:Ext.MessageBox.OK,animEl:_3d.getEl(),modal:false,width:250});}}else{try{if(AccountConfig.allow_asterisks=="Y"){webStore.displayMessage(ProfileCustomerInfoLang.message.requiredFieldsGeneral,ProfileCustomerInfoLang.message.requiredFieldsTitle,"error");}else{var _3e="<div style=\"width: 100%; text-align: center; float: left;\"><ul style=\"list-style-type: square; list-style-position: inside;\">";var _3f=Ext.getCmp(this.id+"main-contact-fieldset");var _40=null;var _41=null;for(i=0;i<_3f.items.length;i++){_40=_3f.items.get(i);if(_40.validator||_40.vtype||(_40.id&&_40.xtype!="progress"&&!_40.allowBlank)){if(_40.fieldLabel&&_40.id){if(!Ext.getCmp(_40.id).isValid()){_3e+="<li>"+_40.fieldLabel+"</li>";}}}}
_3e+="</ul></div>";webStore.displayMessage(ProfileCustomerInfoLang.message.requiredFieldsSubmitAgain+_3e,ProfileCustomerInfoLang.message.requiredFieldsTitle,"error");}}
catch(e){webStore.displayMessage(ProfileCustomerInfoLang.message.requiredFieldsGeneral,ProfileCustomerInfoLang.message.requiredFieldsTitle,"error");}}},receiveSaveResults:function(_42,_43){var _44=0;switch(this.user_type){case"dealer":if(_43.result.confirm_type=="create"){webStore.displayConfirmMessageFromForm(_42,_43);this._hideComponent(this.id+"-new-password");this._hideComponent(this.id+"-retype-password");this._hideComponent(this.id+"-password-strength");this._hideComponent(this.id+"-terms-check-box");this._hideComponent(this.id+"-policy-check-box");this._hideComponent(this.id+"-payment-process-check-box");this._hideComponent(this.id+"-restrictions-check-box");this._hideComponent(this.id+"-web_services-check-box");this._hideComponent(this.id+"-qualifications-check-box");this.mode="update";this._setButtonDisplay();}else{if(_43.result.confirm_type=="update"){webStore.displayConfirmMessageFromForm(_42,_43);this._setButtonDisplay();}}
break;default:if(this.redirectOnSave==false){_43.result.redirect="";}else{if(this.redirectActive){_43.result.redirect+="&active="+this.redirectActive;}}
if(_43.result.confirm_type=="create"){webStore.displayConfirmMessageFromForm(_42,_43);this._hideComponent(this.id+"-new-password");this._hideComponent(this.id+"-retype-password");this._hideComponent(this.id+"-password-strength");this._hideComponent(this.id+"-terms-check-box");this._setButtonDisplay();_44=_43.result.user_id;}else{if(_43.result.confirm_type=="update"){webStore.displayConfirmMessageFromForm(_42,_43);this.fireEvent("saveSuccessful",this.redirect_url);this._setButtonDisplay();this.loadForm(this._userId);_44=this._userId;}}
if(this.redirect_url.length>0){window.location=this.redirect_url;}
break;}
this.fireEvent("saveSuccessful",_44);},receiveSaveFailure:function(_45,_46){webStore.displayConfirmMessageFromForm(_45,_46);Ext.getCmp(this.id+"-save-btn").enable();},_hideComponent:function(id){var _48=Ext.getCmp(id);try{_48.allowBlank=true;_48.disable();_48.hide();}
catch(e){}}});Ext.reg("profiles.comps.addressForm",profiles.comps.addressForm);
profiles.comps.password=Ext.extend(Ext.Panel,{layout:"form",frame:false,border:false,fieldWidth:230,labelWidth:110,validationDelay:50,autoHeight:true,autoScroll:true,passwordLabel:"",showProgressBar:true,url:"json.php?target=user&area=C",initComponent:function(){this.items=[{xtype:"textfield",width:this.fieldWidth,fieldLabel:(this.passwordLabel)?this.passwordLabel:ProfilePasswordLang.label.newPassword,id:this.id+"-new-password",name:"data[new_password]",inputType:"password",allowBlank:false,validationDelay:this.validationDelay,validator:this.validatePassword.createDelegate(this)},{xtype:"textfield",width:this.fieldWidth,fieldLabel:ProfilePasswordLang.label.retypePassword,id:this.id+"-retype-password",name:"data[retype_password]",inputType:"password",allowBlank:false,validationDelay:this.validationDelay,validator:this.validateRetype.createDelegate(this)},{xtype:"progress",width:this.fieldWidth,height:20,id:this.id+"-password-strength",style:"margin: auto auto 10px 115px;",text:ProfilePasswordLang.label.strength,hidden:!this.showProgressBar}];profiles.comps.password.superclass.initComponent.call(this);},initEvents:function(){profiles.comps.password.superclass.initEvents.call(this);},validatePassword:function(_1){if(_1==null||_1==""){return ProfilePasswordLang.message.passwordBlank;}
var _2=_1.length/6;if(_2>1){_2=1;}
Ext.getCmp(this.id+"-password-strength").updateProgress(_2);if(_2>=1){return true;}else{return ProfileCustomerInfoLang.message.passwordTooShort.replace("$X",6);}},validateRetype:function(_3){if(_3==null||_3==""){return ProfilePasswordLang.message.passwordBlank;}
var _4=Ext.getCmp(this.id+"-new-password");var _5=Ext.getCmp(this.id+"-retype-password");if(!_4.getValue()||!_5.getValue()){return ProfilePasswordLang.message.passwordRetypeBlank;}
if(_4.getValue()!=_5.getValue()){return ProfilePasswordLang.message.passwordDoesNotMatch;}
return true;}});Ext.reg("profiles.comps.password",profiles.comps.password);
profiles.comps.dataMappingForm=Ext.extend(Ext.form.FormPanel,{autoHeight:true,frame:false,border:false,componentWidth:230,bodyStyle:"padding: 20px 20px 0 20px",stringMaxLength:255,textMaxLength:4999,labelWidth:100,url:"json.php?target=user",edit_method:"&method=getUserDataMappingValues",save_method:"&method=saveUserDataMappingValues",_userId:0,childAccount:false,validation_style:"side",initComponent:function(){var _1=[{xtype:"hidden",id:this.id+"-user-id",name:"data[user_id]"}];if(this.childAccount){_1.push({xtype:"hidden",name:"data[childAccount]",value:"Y"});}
if(AccountConfig.dataMappings.length>0){this.store=new Ext.data.JsonStore({autoLoad:false,fields:["id","checked"]});this.mappedValuesFieldSet=new Ext.form.FieldSet({xtype:"fieldset",collapsible:false,id:this.id+"data-mapping-fieldset",autoHeight:true});for(var i=0;i<AccountConfig.dataMappings.length;i++){var _3=AccountConfig.dataMappings[i];var _4=this.stringMaxLength;if(_3.search("txt_field_1")>-1){this.mappedValuesFieldSet.add({xtype:"dataview",store:this.store,cls:"x-form-item",fieldLabel:"test",tpl:new Ext.XTemplate("<label class=\"x-form-item-label\">"+AccountConfig.dataMappingsLang.label[_3]+":</label>","<div class=\"x-form-element\">","<tpl for=\".\">","<div>","<input type=\"checkbox\" name=\"data[txt_field_1][{id}]\" value=\"{id}\"","<tpl if=\"values.checked == 'Y'\">checked=\"{checked}\"</tpl>",">&nbsp;{id}</div>","</tpl>","</div><br />"),autoHeight:true,autoWidth:true,itemSelector:"",emptyText:"<label class=\"x-form-item-label\">"+AccountConfig.dataMappingsLang.label[_3]+":</label>"+"<div class=\"x-form-element\">"+AccountConfig.dataMappingsLang.empty["noTxtField1"]+"</div>"});}else{if(_3.search("txt_field")>-1){_4=this.textMaxLength;}
this.mappedValuesFieldSet.add({xtype:"textfield",name:"data["+_3+"]",fieldLabel:AccountConfig.dataMappingsLang.label[_3],width:this.componentWidth,maxLength:_4});}
if(AccountConfig.dataMappingsLang.description[_3]){this.mappedValuesFieldSet.add({xtype:"panel",border:false,bodyStyle:"margin: 0 0 10px "+(this.labelWidth+5)+"px",html:AccountConfig.dataMappingsLang.description[_3]});}}
_1.push(this.mappedValuesFieldSet);}
this.items=_1;profiles.comps.dataMappingForm.superclass.initComponent.call(this);},initEvents:function(){profiles.comps.dataMappingForm.superclass.initEvents.call(this);},initializeForm:function(_5){this._userId=_5;this.loadForm();},loadForm:function(){var _6=this.getForm();var _7={user_id:0};if(this._userId){_7["user_id"]=this._userId;}
_6.load({url:this.url+this.edit_method,params:_7,success:this.loadHandler.createDelegate(this)});},loadHandler:function(_8,_9){Ext.getCmp(this.id+"-user-id").setValue(this._userId);if(this.store){try{var _a=Ext.util.JSON.decode(_9.response.responseText);if(_a.split_data.txt_field_1.length>0){this.store.loadData(_a.split_data.txt_field_1);}else{this.store.removeAll();}}
catch(e){this.store.removeAll();}}},saveForm:function(_b,_c){var _d=this.getForm();if(_d.isValid()){this.fireEvent("saveInitiated");_d.submit({url:this.url+this.save_method,success:this.receiveSaveResults.createDelegate(this),failure:this.receiveSaveFailure.createDelegate(this)});}else{webStore.displayMessage(ProfileCustomerInfoLang.message.requiredFieldsGeneral,ProfileCustomerInfoLang.message.requiredFieldsTitle,"error");}},receiveSaveResults:function(_e,_f){this.fireEvent("saveSuccessful");return;},receiveSaveFailure:function(_10,_11){webStore.displayConfirmMessageFromForm(_10,_11);}});Ext.reg("profiles.comps.dataMappingForm",profiles.comps.dataMappingForm);
profiles.comps.membershipForm=Ext.extend(Ext.form.FormPanel,{autoHeight:true,frame:false,border:false,componentWidth:230,bodyStyle:"padding: 20px 20px 0 20px",labelWidth:100,_membershipStoreType:"memberships",url:"json.php?target=user",edit_method:"&method=getCustomerMemberships",save_method:"&method=saveCustomerMembership",_userId:0,childAccount:false,validation_style:"side",_layoutForced:false,initComponent:function(){if(!(this.membershipStore=Ext.StoreMgr.lookup(this._membershipStoreType))){this.membershipStore=Ext.StoreMgr.add(this._membershipStoreType,new Ext.data.JsonStore({url:this.url+this.edit_method,fields:["membership_id","membership","type","display_message"],root:"data",autoLoad:true}));}
var _1=[{xtype:"hidden",id:this.id+"-user-id",name:"data[user_id]"},{xtype:"combo",id:this.id+"-membership-id",fieldLabel:ProfileCustomerInfoLang.label.membership,hiddenName:"data[membership_id]",width:this.componentWidth,store:this.membershipStore,valueField:"membership_id",displayField:"membership",typeAhead:false,mode:"local",triggerAction:"all",selectOnFocus:true,forceSelection:true,allowBlank:false,listeners:{"select":{fn:this.updateDisplayMessage,scope:this}}},{xtype:"panel",id:this.id+"-membership-message",border:false,html:""}];if(this.childAccount){_1.push({xtype:"hidden",name:"data[childAccount]",value:"Y"});}
this.items=_1;profiles.comps.membershipForm.superclass.initComponent.call(this);},initEvents:function(){profiles.comps.membershipForm.superclass.initEvents.call(this);},forceLayout:function(){var _2=this.findByType("combo");for(i in _2){try{_2[i].syncSize();}
catch(e){}}},initializeForm:function(_3,_4){this._userId=_3;this._membershipId=_4;Ext.getCmp(this.id+"-user-id").setValue(this._userId);Ext.getCmp(this.id+"-membership-id").setValue(this._membershipId);var _5=new RegExp("^"+this._membershipId+"$");this.updateDisplayMessage(false,false,this.membershipStore.find("membership_id",_5,0,false,false));if(!this._layoutForced){this.forceLayout();this._layoutForced=true;}},updateDisplayMessage:function(_6,_7,_8){if(_8>-1&&!_7){_7=this.membershipStore.getAt(_8);}
try{var _9=Ext.get(this.id+"-membership-message");if(_7.data.display_message){_9.update(_7.data.display_message);}else{_9.update("");}
_9.applyStyles("margin: 0 0 10px "+(this.labelWidth+5)+"px");}
catch(e){}},saveForm:function(_a,_b){var _c=this.getForm();if(_c.isValid()){this.fireEvent("saveInitiated");_c.submit({url:this.url+this.save_method,success:this.receiveSaveResults.createDelegate(this),failure:this.receiveSaveFailure.createDelegate(this)});}else{webStore.displayMessage(ProfileCustomerInfoLang.message.requiredFieldsGeneral,ProfileCustomerInfoLang.message.requiredFieldsTitle,"error");}},receiveSaveResults:function(_d,_e){this.fireEvent("saveSuccessful");return;},receiveSaveFailure:function(_f,_10){webStore.displayConfirmMessageFromForm(_f,_10);}});Ext.reg("profiles.comps.membershipForm",profiles.comps.membershipForm);
profiles.comps.PayInvoiceWindow=Ext.extend(Ext.Window,{width:640,height:400,layout:"fit",cls:"wse-payinv-win",shim:true,bodyStyle:"padding:0; margin:0;",buttonAlign:"center",animateTarget:null,animCollapse:false,closable:true,closeAction:"hide",border:false,bodyBorder:false,resizable:false,modal:true,shadow:false,draggable:true,storeFields:[],columns:[],initIds:null,payInvoiceTotalField:"total_outstanding",payInvoiceUrl:"",orderType:"",allowNegativeTotal:true,allowNegativePayments:false,store:null,url:"json.php?target=order&area=C",initComponent:function(){this.store=new Ext.data.JsonStore({url:this.url+"&method=getOrderListByIds",root:"data",totalProperty:"numFound",fields:this.storeFields,pruneModifiedRecords:true,id:"order_id",autoLoad:false,listeners:{load:this._updateAfterLoad.createDelegate(this),beforeload:this._updateBeforeLoad.createDelegate(this)}});this.items=[{xtype:"grid",enableHdMenu:false,border:false,loadMask:{msg:ProfileOrderTypeDisplayLang.mask.loading},viewConfig:{autoFill:true},columns:this.columns,store:this.store,bbar:this._genTotalBar()}];this.bbar=["<span id=\""+this.getId()+"-mval\" class=\"wse-lbl\"></span>","->",{xtype:"button",id:this.getId()+"-btn",text:ProfileOrderTypeDisplayLang.button.continue_payment,disabled:true,handler:this._continuePayment.createDelegate(this)}];profiles.comps.PayInvoiceWindow.superclass.initComponent.call(this);},onRender:function(ct,_2){profiles.comps.PayInvoiceWindow.superclass.onRender.call(this,ct,_2);},afterRender:function(){profiles.comps.PayInvoiceWindow.superclass.afterRender.call(this);if(this.initIds){this.loadOrders(this.initIds);}},loadOrders:function(_3){if(this.rendered){this._loadOrders.defer(250,this,[_3]);}else{this.initIds=_3;}},_loadOrders:function(_4){var s;if(Ext.isArray(_4)){s=_4.join(",");}else{s=_4;}
if(s){this.store.load({params:{order_ids:s}});}
if(this.initIds){this.initIds=null;}},_updateBeforeLoad:function(){this._enableBtn(false);try{Ext.get(this.getId()+"-tval").update("");}
catch(e){}
try{Ext.get(this.getId()+"-mval").update("");}
catch(e){}},_updateAfterLoad:function(){var _t=this._genInvoiceTotal();var _m=ProfileOrderTypeDisplayLang.message.payInvoiceRedirect;if(_t>0||this.allowNegativePayments){this._enableBtn(true);}else{_m=ProfileOrderTypeDisplayLang.message.payInvoiceNegative;this._enableBtn(false);}
try{Ext.get(this.getId()+"-tval").update(_t);}
catch(e){}
try{Ext.get(this.getId()+"-mval").update(_m);}
catch(e){}},_enableBtn:function(_8){try{Ext.getCmp(this.getId()+"-btn")[_8?"enable":"disable"]();}
catch(e){}},_genTotalBar:function(){return new Ext.Toolbar({cls:"wse-payinv-ttl",items:["->","<span class=\"wse-lbl\">"+ProfileOrderTypeDisplayLang.label.payInvoiceTotal+"</span>","<span id=\""+this.getId()+"-tval\" class=\"wse-val\"></span>"]});},_genInvoiceTotal:function(){if(this.store.getCount()&&this.payInvoiceTotalField){var _9=this.store.getRange();var i,n=0,_c=0,l=_9.length;for(i=0;i<l;i++){if(!(n=parseFloat(_9[i].get(this.payInvoiceTotalField)))){n=0;}
_c+=n;}
if(_c<=0&&!this.allowNegativeTotal){_c=0;}
_c=Math.round(_c*100)/100;_c=_c.toString();var _e=_c.indexOf(".");if(_e<0){_c+=".";_e=_c.length-1;}
while(_e+3>_c.length){_c+="0";}
return _c;}
return"";},_continuePayment:function(){if(this.store.getCount()){Ext.Msg.wait(ProfileOrderTypeDisplayLang.message.redirectingRequest);var _f=this.store.collect("order_id");Ext.Ajax.request({url:this.url+"&method=preparePayInvoiceCart",params:{order_ids:_f.join(",",_f),order_type:this.orderType},success:this._finishContinuePayment.createDelegate(this),failure:this._errorContinuePayment.createDelegate(this,[""])});}},_finishContinuePayment:function(_10,_11){try{responseText=Ext.util.JSON.decode(_10.responseText);if(responseText.success){try{window.location.href=this.payInvoiceUrl;}
catch(e){Ext.Msg.hide.defer(10000,Ext.Msg);}}else{this._errorContinuePayment(responseText.message);}}
catch(e){this._errorContinuePayment();}},_errorContinuePayment:function(_12){if(!_12){_12=ProfileOrderTypeDisplayLang.message.cannotPayInvoiceRequest;}
Ext.Msg.hide();Ext.Msg.show({msg:_12,buttons:{ok:ProfileOrderTypeDisplayLang.button.ok}});}});
