const MODAL_ACCOUNT_SETTINGS=10;const MODAL_ADD_ADDRESS=20;const MODAL_ADD_PROJECT_OPTION=150;const MODAL_ADD_PROJECT_ROOM=30;const MODAL_CHANGE_PASSWORD=40;const MODAL_CONFIRMATION=50;const MODAL_COPY_PROJECT=60;const MODAL_EDIT_ADDRESS=80;const MODAL_EDIT_NON_STOCK_ITEM=140;const MODAL_EDIT_PROJECT=90;const MODAL_EDIT_TRADE_REQUEST=160;const MODAL_EMAIL_PROJECT=100;const MODAL_RENAME_PROJECT_ROOM=110;const MODAL_TAX_EXEMPTION=120;const MODAL_XFER_PROJECT_ITEMS=130;const TOOL_NONE=0;const TOOL_ADD_CUSTOMER=10;const TOOL_EDIT_CUSTOMER=20;const TOOL_CART_ACTIVITY=25;const TOOL_FIND_CUSTOMER=30;const TOOL_FIND_PRODUCT=40;const TOOL_FIND_PROJECT=45;const TOOL_FIND_WISHLIST=50;const TOOL_RESOURCES=60;const TOOL_SALES_TAX_RATE=70;const TOOL_VIEW_CART=75;const TOOL_VIRTUAL_INVENTORY=80;const SEND_PROJECT_EMAIL=1;const PREVIEW_PROJECT_EMAIL=2;var spinner_img=$('');var ajax_call_in_progress=false;var ajax_call_button_text='Working...';var ajax_call_error_text='System Error';var tool_add_customer_height=0;var tool_cart_activity_height=0;var tool_edit_customer_height=0;var tool_find_customer_height=0;var tool_find_product_height=0;var tool_find_project_height=0;var tool_find_wishlist_height=0;var tool_sales_tax_rate_height=0;var selected_tool=TOOL_NONE;var modal_email_project_height=0;var modal_email_project_height_adder1=0;var modal_email_project_height_adder2=0;var modal_email_project_height_adder3=0;var modal_xfer_project_items_height=300;let selected_project_files=[];let selected_project_items=[];function create_customer_address(address_changed,addr_validated,addr_residential,address_1,address_2,city,zip,state_id,country_id,extra_values) {let url='https://www.lightology.com/index.php?module=dispatcher';let prefix=extra_values['prefix'];let data='action=create_customer_address'+'&user_type='+extra_values['user_type']+'&addr_type='+extra_values['addr_type']+'&addr_parent_type='+extra_values['addr_parent_type']+'&addr_parent_id='+extra_values['addr_parent_id']+'&label='+encodeURIComponent(extra_values[prefix+'label'])+'&first_name='+encodeURIComponent(extra_values[prefix+'first_name'])+'&last_name='+encodeURIComponent(extra_values[prefix+'last_name'])+'&company_name='+encodeURIComponent(extra_values[prefix+'company_name'])+'&address_1='+encodeURIComponent(address_1)+'&address_2='+encodeURIComponent(address_2)+'&city='+encodeURIComponent(city)+'&zip='+zip+'&state_id='+state_id+'&country_id='+country_id+'&addr_validated='+addr_validated+'&addr_residential='+addr_residential+'&prefix='+prefix;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data&&data.html){if(extra_values.hasOwnProperty('user_type')){if(extra_values['user_type']==='user'){$('#addresses_panel .panel-wrap').html(data.html);}else if(extra_values['user_type']==='cust'){$('#edit_customer_address_book').html(data.html);}}else{$('.address_list').append(data.html);}}},error:function(){}});} function create_customer(address_changed,addr_validated,addr_residential,address_1,address_2,city,zip,state_id,country_id,extra_values) {let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=create_customer'+'&cust_account_type='+extra_values['cust_account_type']+'&cust_first_name='+encodeURIComponent(extra_values['cust_first_name'])+'&cust_last_name='+encodeURIComponent(extra_values['cust_last_name'])+'&price_code='+extra_values['price_code']+'&cust_company_name='+encodeURIComponent(extra_values['cust_company_name'])+'&occupation='+extra_values['occupation']+'&cust_address_1='+encodeURIComponent(address_1)+'&cust_address_2='+encodeURIComponent(address_2)+'&cust_city='+encodeURIComponent(city)+'&cust_state_id='+state_id+'&cust_zip='+zip+'&cust_country_id='+country_id+'&addr_validated='+addr_validated+'&addr_residential='+addr_residential+'&cust_phone='+extra_values['cust_phone']+'&cust_phone_mobile='+extra_values['cust_phone_mobile']+'&cust_phone_other='+extra_values['cust_phone_other']+'&cust_phone_fax='+extra_values['cust_phone_fax']+'&cust_email='+encodeURIComponent(extra_values['cust_email'])+'&sales_rep_id='+extra_values['sales_rep_id']+'&cust_contact_ok='+extra_values['cust_contact_ok']+'&send_email='+extra_values['send_email']+'&include_100_off='+extra_values['include_100_off']+'&order_catalogs='+extra_values['order_catalogs']+'&catalogs='+extra_values['catalogs'].join('|');if(address_changed){$('#cust_address_1').val(address_1);$('#cust_city').val(city);$('#cust_zip').val(zip);} $.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data){if(data.hasOwnProperty('message')){$('.message').html(data.message);} if(data.hasOwnProperty('code')&&data.code>0){if(typeof gtag!=='undefined'){let user_name=$('#ga_user_name').text();gtag('event','new_account',{'event_category':'new_account_rep','event_label':user_name});}}}},error:function(){}});} function save_address(prefix,save_callback,$this) {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let $button=$('#submit_'+prefix+'address');let button_text=$button.text();$button.text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let form_data=$('#'+prefix+'address_form').serialize();let data='action=validate_address&'+form_data;if(!$this){$('#'+prefix+'address_form *').removeClass('err_bg');} $.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#submit_'+prefix+'address').text(button_text);let code=(typeof data.code=='string')?parseInt(data.code):data.code;switch(code){case 0:if(!$this){let modal_type=MODAL_ADD_ADDRESS;if(prefix==='edit_'){modal_type=MODAL_EDIT_ADDRESS;} set_modal_height(modal_type,data.fields.length);if(data.fields.length){for(let property in data.fields){if(data.fields.hasOwnProperty(property)){$('#'+data.fields[property]).addClass('err_bg');}}} $('#'+prefix+'address_form .message').html(data.message);} break;case 1:let extra_values=data.output;extra_values['prefix']=prefix;extra_values['token']=$('#token').val();extra_values['addr_id']=$('#addr_id').val();extra_values['addr_type']=$('#addr_type').val();extra_values['addr_parent_type']=$('#addr_parent_type').val();extra_values['addr_parent_id']=$('#addr_parent_id').val();extra_values['user_type']=$('#user_type').val();let address_1=extra_values[prefix+'address_1'];let address_2=extra_values[prefix+'address_2'];let city=extra_values[prefix+'city'];let country_id=extra_values[prefix+'country_id'];let state_id=extra_values[prefix+'state_id'];let zip=extra_values[prefix+'zip'];if(typeof state_id==='undefined'){state_id=0;} setTimeout(function(){if($this){$this.dialog('close').remove();}else{$('#'+prefix+'address_form .message').html('');$('#'+prefix+'address_modal').modal('hide');}},1500);if(async_supported){lookup_save_domestic_address('Address Selection',address_1,address_2,city,zip,state_id,country_id,extra_values,save_callback);}else{save_callback(false,0,0,address_1,address_2,city,zip,state_id,country_id,extra_values);} break;}},error:function(){ajax_call_in_progress=false;$('#submit_add_address').text(ajax_call_error_text);}});} function save_new_password($this){var url='https://www.lightology.com/index.php?module=dispatcher';var data='action=save_user_new_password';data+='&'+$('#change_password_form').serialize();$('.ui-dialog-buttonset').append(spinner_img.attr('id','spinner_change_password_form').css('margin-left','10px'));$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){$('#spinner_change_password_form').remove();$('#change_password_form .message').html(data.message);if(data.code==1){setTimeout(function(){$('#change_password_form .message').html('');$this.dialog('close').remove();},3000);}},error:function(){}});} function set_modal_height(modal,extra_lines) {let width=$(window).width() let line_height=20;let height=0;switch(modal){case MODAL_ACCOUNT_SETTINGS:let adjustment=0;let user_account_type=$('input[name="user_account_type"]:checked').val();if(user_account_type=='2'){adjustment=100;} if(width>=1367){height=340+adjustment+extra_lines*line_height;}else if(width>=480){height=560+adjustment+extra_lines*line_height;}else{height=600+adjustment+extra_lines*line_height;} $('#account_settings_inquiry').height(height);break;case MODAL_ADD_ADDRESS:if(width>=1367){height=540+extra_lines*line_height;}else{height=720+extra_lines*line_height;} $('#add_address_inquiry').height(height);break;case MODAL_EDIT_NON_STOCK_ITEM:if(width>=1367){height=780+extra_lines*line_height;}else{height=1040+extra_lines*line_height;} $('#add_non_stock_item_inquiry').height(height);break;case MODAL_ADD_PROJECT_OPTION:if(width>=450){height=140+extra_lines*line_height;}else{height=160+extra_lines*line_height;} $('#add_project_option_inquiry').height(height);break;case MODAL_ADD_PROJECT_ROOM:if(width>=450){height=140+extra_lines*line_height;}else{height=160+extra_lines*line_height;} $('#add_project_room_inquiry').height(height);break;case MODAL_CHANGE_PASSWORD:if(width>=450){height=260+extra_lines*line_height;}else{height=260+extra_lines*30;} $('#change_password_inquiry').height(height);break;case MODAL_CONFIRMATION:if(width>=450){height=130;}else{height=160;} $('#confirmation_inquiry').height(height);break;case MODAL_COPY_PROJECT:if(width>=450){height=140;}else{height=160;} $('#copy_project_inquiry').height(height);break;case MODAL_EDIT_ADDRESS:if(width>=1367){height=540+extra_lines*line_height;}else{height=720+extra_lines*line_height;} $('#edit_address_inquiry').height(height);break;case MODAL_EDIT_PROJECT:if(width>=450){height=540+extra_lines*line_height;}else{height=680+extra_lines*line_height;} if($('#owner_id_fieldset').length){height+=120;} $('#edit_project_inquiry').height(height);break;case MODAL_EDIT_TRADE_REQUEST:if(width>=450){height=1170+extra_lines*line_height;}else{height=1190+extra_lines*line_height;} $('#edit_trade_request_modal_content').height(height);break;case MODAL_EMAIL_PROJECT:if(extra_lines==0){if(width>1366){modal_email_project_height=520;}else if(width>=480){modal_email_project_height=610;}else{modal_email_project_height=690;} height=modal_email_project_height+ modal_email_project_height_adder1+ modal_email_project_height_adder2+ modal_email_project_height_adder3;}else{height=modal_email_project_height+ modal_email_project_height_adder1+ modal_email_project_height_adder2+ modal_email_project_height_adder3+ extra_lines*line_height;} $('#email_project_inquiry').height(height);break;case MODAL_RENAME_PROJECT_ROOM:if(width>=450){height=140;}else{height=160;} $('#rename_project_room_inquiry').height(height);break;case MODAL_TAX_EXEMPTION:if(width>=480){height=160;}else if(width>=424){height=180;}else if(width>=332){height=200;}else{height=220;} $('#tax_exemption_inquiry').height(height);break;case MODAL_XFER_PROJECT_ITEMS:if(width>=450){height=modal_xfer_project_items_height+extra_lines*line_height;}else{height=modal_xfer_project_items_height+20+extra_lines*line_height;} $('#xfer_project_items_inquiry').height(height);break;}} function set_tool_height(tool,extra_lines) {selected_tool=tool;let width=$(window).width() let line_height=20;let height=0;switch(tool){case TOOL_ADD_CUSTOMER:if(extra_lines===0){if(width>=1367){tool_add_customer_height=1040;}else if(width>=877){tool_add_customer_height=1380;}else if(width>=769){tool_add_customer_height=1460;}else if(width>=612){tool_add_customer_height=1660;}else if(width>=364){tool_add_customer_height=1720;}else{tool_add_customer_height=1800;} height=tool_add_customer_height;}else{height=tool_add_customer_height+extra_lines*line_height;} break;case TOOL_CART_ACTIVITY:if(extra_lines===0){if(width>=769){tool_cart_activity_height=280;}else{tool_cart_activity_height=320;} height=tool_cart_activity_height;}else{height=tool_cart_activity_height+extra_lines*line_height;} break;case TOOL_EDIT_CUSTOMER:if(extra_lines===0){if(width>=1367){tool_edit_customer_height=1020;}else if(width>=769){tool_edit_customer_height=1420;}else{tool_edit_customer_height=1840;} height=tool_edit_customer_height;}else{height=tool_edit_customer_height+extra_lines*line_height;} break;case TOOL_FIND_CUSTOMER:if(extra_lines===0){if(width>=1350){tool_find_customer_height=430;}else if(width>=769){tool_find_customer_height=580;}else{tool_find_customer_height=570;} height=tool_find_customer_height;}else{height=tool_find_customer_height+extra_lines*line_height;} break;case TOOL_FIND_PRODUCT:if(extra_lines===0){if(width>=769){tool_find_product_height=330;}else{tool_find_product_height=370;} height=tool_find_product_height;}else{height=tool_find_product_height+extra_lines*line_height;} break;case TOOL_FIND_PROJECT:if(extra_lines===0){if(width>=769){tool_find_project_height=300;}else{tool_find_project_height=340;} height=tool_find_project_height;}else{height=tool_find_project_height+extra_lines*line_height;} break;case TOOL_FIND_WISHLIST:if(extra_lines===0){if(width>=769){tool_find_wishlist_height=260;}else{tool_find_wishlist_height=300;} height=tool_find_wishlist_height;}else{height=tool_find_wishlist_height+extra_lines*line_height;} break;case TOOL_RESOURCES:if(width>=1326){height=3160;}else{height=3600;} break;case TOOL_SALES_TAX_RATE:if(extra_lines===0){if(width>=769){tool_sales_tax_rate_height=520;}else{tool_sales_tax_rate_height=640;} height=tool_sales_tax_rate_height;}else{height=tool_sales_tax_rate_height+extra_lines*line_height;} break;case TOOL_VIRTUAL_INVENTORY:if(width>=769){height=400;}else{height=540;} break;case TOOL_VIEW_CART:if(width>=769){height=260+extra_lines*line_height;}else{height=380+extra_lines*line_height;} break;} $('#static-display-form').height(height);$('#form-single-tools').height(height);} function show_dialog(content) {$('#quickview_box').append(content);$('#quickview_box').dialog({height:'auto',width:'auto',modal:true,show:{effect:'fade',duration:800},close:function(){$('#quickview_box').remove();$('body').append('
');}});} function update_customer_address(address_changed,addr_validated,addr_residential,address_1,address_2,city,zip,state_id,country_id,extra_values) {let prefix=extra_values['prefix'];let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=update_customer_address'+'&addr_id='+extra_values['addr_id']+'&user_type='+extra_values['user_type']+'&addr_type='+extra_values['addr_type']+'&addr_parent_id='+extra_values['addr_parent_id']+'&addr_parent_type='+extra_values['addr_parent_type']+'&label='+encodeURIComponent(extra_values[prefix+'label'])+'&first_name='+encodeURIComponent(extra_values[prefix+'first_name'])+'&last_name='+encodeURIComponent(extra_values[prefix+'last_name'])+'&company_name='+encodeURIComponent(extra_values[prefix+'company_name'])+'&address_1='+encodeURIComponent(address_1)+'&address_2='+encodeURIComponent(address_2)+'&city='+encodeURIComponent(city)+'&zip='+zip+'&state_id='+state_id+'&country_id='+country_id+'&addr_validated='+addr_validated+'&addr_residential='+addr_residential+'&prefix='+prefix;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data&&data.html){if(extra_values['user_type']=='user'){$('#addresses_panel .panel-wrap').html(data.html);}else if(extra_values['user_type']=='cust'){$('#edit_customer_address_book').html(data.html);}}},error:function(){}});} function update_customer(output) {let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=update_customer'+'&cust_nxt_id='+output['cust_nxt_id']+'&cust_account_type='+output['cust_account_type']+'&cust_email='+encodeURIComponent(output['cust_email'])+'&cust_first_name='+encodeURIComponent(output['cust_first_name'])+'&cust_last_name='+encodeURIComponent(output['cust_last_name'])+'&cust_company_name='+encodeURIComponent(output['cust_company_name'])+'&cust_phone='+output['cust_phone']+'&cust_phone_mobile='+output['cust_phone_mobile']+'&cust_phone_other='+output['cust_phone_other']+'&cust_phone_fax='+output['cust_phone_fax']+'&sales_rep_id='+output['sales_rep_id']+'&sales_rep_change_reason='+encodeURIComponent(output['sales_rep_change_reason'])+'&price_code='+output['price_code']+'&occupation='+output['occupation']+'&cust_contact_ok='+output['cust_contact_ok']+'&send_email='+output['send_email']+'&include_100_off='+output['include_100_off'];$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data&&data.message){$('.cust-submit-button-div').append(data.message);$('.message').html(data.message);}},error:function(){}});} function handle_account_signin_click() {let url='https://www.lightology.com/index.php?module=dispatcher';let form_data=$('#account_signin_form').serialize();let data='action=account_signin&'+form_data;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data){switch(data.code){case 0:window.location=data.redirect;break;case 1:let html='
'+'

Your account has items in carts on one or more other devices. '+'Would you like to include these items in your cart?

'+'
'+''+'
'+''+''+''+''+'
'+'
'+'
';show_dialog(html);break;case 2:$('#account_signin_form > .red_txt').html(data.message);break;}}},error:function(){}});} function handle_account_tab_click($this) {let tab_id=$this.attr('id');if(tab_id.indexOf('_button')>0){tab_id=tab_id.replace('_button','');} let panel=tab_id.split('_')[0];if(panel==='tools'){window.location='https://www.lightology.com/index.php?module=admin';return;} if(panel==='projects'){window.location='https://www.lightology.com/index.php?module=pm_home';return;} if(ajax_call_in_progress){return;} ajax_call_in_progress=true;$('.account-tabs li').removeClass('active');$('.account-panel').removeClass('active');$('#active_tool_content').html('');$('#'+tab_id).parent().addClass('active');$('#'+panel+'_panel').addClass('active');let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=set_user_active_tab&active_tab='+panel;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(){ajax_call_in_progress=false;},error:function(){ajax_call_in_progress=false;}});} function handle_add_address_click($this) {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;if($('#add_address_modal').length){$('#add_address_modal').remove();} if($('#edit_address_modal').length){$('#edit_address_modal').remove();} let url='https://www.lightology.com/index.php?module=dispatcher';let user_type=$this.data('userType');let cust_id=$this.attr('id').replace('cust_id_','');let data='action=build_add_customer_address_dialog&addr_type=0&addr_parent_type=0&addr_parent_id='+cust_id+'&user_type='+user_type;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data){ajax_call_in_progress=false;if($('#account-layout').length){$('#account-layout').append(data);}else if($('.admin_tools').length){$('.admin_tools').append(data);} $('#add_address_modal').modal();set_modal_height(MODAL_ADD_ADDRESS,0);}},error:function(){ajax_call_in_progress=false;$('#add_address').text(ajax_call_error_text);}});} function handle_address_country_change() {let url='https://www.lightology.com/index.php?module=dispatcher';let country_id=parseInt($('#address_country_id').val(),10);let data='action=address_country_change&country_id='+country_id;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){let $address_state_div=$('#address_state_div');let $address_state_id=$('#address_state_id');$address_state_id.find('option').remove();if(data.length){$address_state_div.show();$address_state_id.append(data);}else{$address_state_div.hide();}},error:function(){}});} function handle_address_default_click($this,$type) {let checked=$this.is(':checked');if(!checked){$this.prop('checked',true);} else{let url='https://www.lightology.com/index.php?module=dispatcher';let user_type=$this.data('userType');let addr_type_bit=($type==='bill')?'1':'2';let addr_id=$this.attr('id').replace($type+'_id_','');let data='action=set_customer_addr_type_bit&addr_id='+addr_id+'&addr_type_bit='+addr_type_bit+'&exclusive=1&user_type='+user_type;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data){if(data.html){if(user_type=='user'){$('#addresses_panel .panel-wrap').html(data.html);}else if(user_type=='cust'){$('#edit_customer_address_book').html(data.html);}}else if(!data.set){window.location.reload();}}},error:function(){}});}} function handle_back_to_dashboard_click() {$('.account-panel').removeClass('active');$('#dashboard_panel').addClass('active');let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=set_user_active_tab&active_tab=dashboard';$.ajax({type:'POST',url:url,data:data,dataType:'json'});} function handle_change_password_redesign_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#change_password_redesign').text();$('#change_password_redesign').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=build_change_password_dialog_redesign';$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#change_password_redesign').text(button_text);if(data){if($('#change_password_modal').length){$('#change_password_modal').replaceWith(data);} else{$('#account-layout').append(data);} $('#change_password_modal').modal();set_modal_height(MODAL_CHANGE_PASSWORD,0);if(typeof acsbJS!=='undefined'){acsbJS.restart();}}},error:function(){ajax_call_in_progress=false;$('#change_password_redesign').text(ajax_call_error_text);}});} function handle_create_customer_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;const fields={catalogs:{multiselect_checkbox:true},cust_account_type:{checkbox:true},cust_address_1:{},cust_address_2:{},cust_city:{},cust_company_name:{},cust_contact_ok:{checkbox:true},cust_country_id:{select_dropdown:true},cust_email:{},cust_first_name:{},cust_last_name:{},cust_phone:{},cust_phone_fax:{},cust_phone_mobile:{},cust_phone_other:{},cust_state_id:{select_dropdown:true},cust_zip:{},include_100_off:{checkbox:true},occupation:{select_dropdown:true},order_catalogs:{checkbox:true},price_code:{select_dropdown:true},sales_rep_id:{select_dropdown:true},send_email:{checkbox:true}};let $message=$('.message');$message.html('');let $create_customer=$('#create_customer');let button_text=$create_customer.text();$create_customer.text(ajax_call_button_text);$('#add_new_customer_form *').removeClass('err_bg');let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=validate_create_customer';for(let field in fields){if(fields[field].hasOwnProperty('multiselect_checkbox')){let values=[];$.each($('input[name="'+field+'"]:checked'),function(){values.push($(this).val());});data+='&'+field+'='+values.join('|');}else if(fields[field].hasOwnProperty('checkbox')){data+='&'+field+'='+$('input[name="'+field+'"]:checked').val();}else if(fields[field].hasOwnProperty('select_dropdown')){data+='&'+field+'='+$('select[name="'+field+'"] option:selected').val();}else{data+='&'+field+'='+encodeURIComponent($('input[name="'+field+'"]').val());}} $.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$create_customer.text(button_text);if(data.hasOwnProperty('code')){let code=(typeof data.code=='string')?parseInt(data.code):data.code;switch(code){case 0:if(data.hasOwnProperty('message')){$message.html(data.message);} if(data.hasOwnProperty('fields')&&data.fields.length>0){set_tool_height(TOOL_ADD_CUSTOMER,data.fields.length);for(let property in data.fields){if(data.fields.hasOwnProperty(property)){$('#'+data.fields[property]).addClass('err_bg');}}} break;case 1:let extra_values=data.output;extra_values['token']=$('#token').val();let address_1=extra_values['cust_address_1'];let address_2=extra_values['cust_address_2'];let city=extra_values['cust_city'];let country_id=extra_values['cust_country_id'];let state_id=extra_values['cust_state_id'];let zip=extra_values['cust_zip'];if(typeof state_id==='undefined'){state_id=0;} if(async_supported){lookup_save_domestic_address('Customer Address Selection',address_1,address_2,city,zip,state_id,country_id,extra_values,create_customer);}else{create_customer(false,0,0,address_1,address_2,city,zip,state_id,country_id,extra_values);} break;}}},error:function(){ajax_call_in_progress=false;$create_customer.text(ajax_call_error_text);}});} function handle_cust_account_type_change($this) {let height=$('#static-display-form').height();if($this.val()=='2'){$('#company_name_div, #cust_phone_fax_div').show();height+=60;if($('#create_customer').is(':visible')){tool_add_customer_height+=60;}}else{$('#company_name_div, #cust_phone_fax_div').hide();height-=60;if($('#create_customer').is(':visible')){tool_add_customer_height-=60;}} $('#static-display-form').height(height);$('#form-single-tools').height(height);} function handle_cust_country_change() {var url='https://www.lightology.com/index.php?module=dispatcher';var country_id=parseInt($('#cust_country_id').val(),10);var data='action=cust_country_change&country_id='+country_id;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data){var $cust_state=$('#cust_state');var $cust_state_id=$('#cust_state_id');$cust_state_id.find('option').remove();if(data.states.length){$cust_state.show();$cust_state_id.append(data.states);}else{$cust_state.hide();}}},error:function(){}});} function handle_cust_order_catalogs_change() {let $static_display_form=$('#static-display-form');let height=$static_display_form.height();let order_catalogs=$('input[name="order_catalogs"]:checked').val();if(order_catalogs>0){$('#order_catalogs_container').show();tool_add_customer_height+=420;height+=420;}else{$('#order_catalogs_container').hide();tool_add_customer_height-=420;height-=420;} $static_display_form.height(height);$('#form-single-tools').height(height);} function handle_cust_send_email_change() {let height=$('#static-display-form').height();let price_level=parseInt($('#price_code').val(),10);let send_email=$('input[name="send_email"]:checked').val();if([6,7].includes(price_level)&&send_email>0){if(!$('.include-50').is(':visible')){$('.include-50').show();height+=60;if($('#create_customer').is(':visible')){tool_add_customer_height+=60;}}}else if($('.include-50').is(':visible')){$('.include-50').hide();height-=60;if($('#create_customer').is(':visible')){tool_add_customer_height-=60;}} $('#static-display-form').height(height);$('#form-single-tools').height(height);} function handle_delete_customer_address_click($this) {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let cust_id=$this.data('custId');let user_type=$this.data('userType');let url='https://www.lightology.com/index.php?module=dispatcher';let addr_id=$this.attr('id').replace('addr_id_','');let data='action=delete_customer_address&addr_id='+addr_id+'&cust_id='+cust_id+'&user_type='+user_type;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;if(data&&data.html){if(user_type=='user'){$('#addresses_panel .panel-wrap').html(data.html);}else if(user_type=='cust'){$('#edit_customer_address_book').html(data.html);}}},error:function(){ajax_call_in_progress=false;}});} function handle_edit_account_settings_redesign_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#edit_account_settings_redesign').text();$('#edit_account_settings_redesign').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=build_account_settings_dialog_redesign';$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#edit_account_settings_redesign').text(button_text);if(data){if($('#account_settings_modal').length){$('#account_settings_modal').replaceWith(data);}else{$('#account-layout').append(data);} $('#account_settings_modal').modal();set_modal_height(MODAL_ACCOUNT_SETTINGS,0);if(typeof acsbJS!=='undefined'){acsbJS.restart();}}},error:function(){ajax_call_in_progress=false;$('#edit_account_settings_redesign').text(ajax_call_error_text);}});} function handle_edit_address_click($this) {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;if($('#add_address_modal').length){$('#add_address_modal').remove();} if($('#edit_address_modal').length){$('#edit_address_modal').remove();} let url='https://www.lightology.com/index.php?module=dispatcher';let user_type=$this.data('userType');let addr_id=$this.attr('id').replace('addr_id_','');let data='action=build_edit_address_dialog&addr_id='+addr_id+'&user_type='+user_type;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;if(data){if($('#account-layout').length){$('#account-layout').append(data);}else if($('.admin_tools').length){$('.admin_tools').append(data);} $('#edit_address_modal').modal();set_modal_height(MODAL_EDIT_ADDRESS,0);}},error:function(){ajax_call_in_progress=false;}});} function handle_edit_customer_country_change() {let url='https://www.lightology.com/index.php?module=dispatcher';let country_id=parseInt($('#edit_customer_country_id').val(),10);let data='action=address_country_change&country_id='+country_id;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){let $edit_customer_state_div=$('#edit_customer_state_div');let $edit_customer_state_id=$('#edit_customer_state_id');$edit_customer_state_id.find('option').remove();if(data.length){$edit_customer_state_div.show();$edit_customer_state_id.append(data);}else{$edit_customer_state_div.hide();$edit_customer_state_id.html('');}},error:function(){}});} function handle_find_customer_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let $find_customer=$('#find_customer');let button_text=$find_customer.text();$find_customer.text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let form_data=$('#find_customer_form').serialize();let data='action=find_matching_customers&'+form_data;$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$find_customer.text(button_text);$('#active_tool_content').append(data);},error:function(){ajax_call_in_progress=false;$find_customer.text(ajax_call_error_text);}});} function handle_find_customer_reset_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#find_customer_reset').text();$('#find_customer_reset').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=find_customer_reset';$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#find_customer_reset').text(button_text);$('#active_tool_content').html(data);set_tool_height(TOOL_FIND_CUSTOMER,0);},error:function(){ajax_call_in_progress=false;$('#find_customer_reset').text(ajax_call_error_text);}});} function handle_find_product_redesign_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#find_product_redesign').text();$('#find_product_redesign').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let form_data=$('#find_product_form').serialize();let data='action=find_matching_products&'+form_data;$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#find_product_redesign').text(button_text);$('#active_tool_content').append(data);},error:function(){ajax_call_in_progress=false;$('#find_product_redesign').text(ajax_call_error_text);}});} function handle_find_product_reset_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#find_product_reset').text();$('#find_product_reset').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=find_product_reset';$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#find_product_reset').text(button_text);$('#active_tool_content').html(data);set_tool_height(TOOL_FIND_PRODUCT,0);},error:function(){ajax_call_in_progress=false;$('#find_product_reset').text(ajax_call_error_text);}});} function handle_find_virtual_inventory_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#find_virtual_inventory').text();$('#find_virtual_inventory').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let form_data=$('#virtual_inventory_form').serialize();let data='action=find_virtual_inventory&'+form_data;$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#find_virtual_inventory').text(button_text);$('#active_tool_content').append(data);},error:function(){ajax_call_in_progress=false;$('#find_virtual_inventory').text(ajax_call_error_text);}});} function handle_find_virtual_inventory_reset_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#find_virtual_inventory_reset').text();$('#find_virtual_inventory_reset').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=find_virtual_inventory_reset';$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#find_virtual_inventory_reset').text(button_text);$('#active_tool_content').html(data);set_tool_height(TOOL_VIRTUAL_INVENTORY,0);},error:function(){ajax_call_in_progress=false;$('#find_virtual_inventory_reset').text(ajax_call_error_text);}});} function handle_find_wishlist_redesign_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#find_wishlist_redesign').text();$('#find_wishlist_redesign').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let form_data=$('#find_wishlist_form').serialize();let data='action=find_matching_wishlists&redesign=1&'+form_data;$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#find_wishlist_redesign').text(button_text);$('#active_tool_content').append(data);},error:function(){ajax_call_in_progress=false;$('#find_wishlist_redesign').text(ajax_call_error_text);}});} function handle_find_wishlist_reset_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#find_wishlist_reset').text();$('#find_wishlist_reset').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=find_wishlist_reset';$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#find_wishlist_reset').text(button_text);$('#active_tool_content').html(data);set_tool_height(TOOL_FIND_WISHLIST,0);},error:function(){ajax_call_in_progress=false;$('#find_wishlist_reset').text(ajax_call_error_text);}});} function handle_get_zip_sales_tax_rate_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#get_zip_sales_tax_rate').text();$('#get_zip_sales_tax_rate').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let zip=$('#sales_tax_zip').val();let data='action=get_zip_sales_tax_data&zip='+zip;$('#zip_sales_tax_data').html('');$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#get_zip_sales_tax_rate').text(button_text);$('#zip_sales_tax_data').html(data);let extra_lines=3;if(data.indexOf('tax rate data for zip code')>0){extra_lines=17;} set_tool_height(TOOL_SALES_TAX_RATE,extra_lines);},error:function(){ajax_call_in_progress=false;$('#get_zip_sales_tax_rate').text(ajax_call_error_text);}});} function handle_include_other_db_carts() {var url='https://www.lightology.com/index.php?module=dispatcher';var data='action=include_other_db_carts';$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){window.location=$('input[name="redirect"]').val();},error:function(){window.location=$('input[name="redirect"]').val();}});} function handle_load_database_cart_click() {if($('#load_database_cart').is(':checked')){$('#user_cart_id_div').show();}else{$('#user_cart_id_div').hide();}} function handle_project_select_type_change($this) {switch($this.val()){case'1':$('#new_project_room_fieldset').hide();modal_xfer_project_items_height=300;break;case'2':$('#new_project_room_fieldset').show();modal_xfer_project_items_height=360;break;} set_modal_height(MODAL_XFER_PROJECT_ITEMS,0);} function handle_reason_select_change(element) {var prod_id=element.id.substring(14);var reason=$('#'+element.id).val();if(reason=='C'){$('#restocking_fee_'+prod_id).show();}else{$('#restocking_fee_'+prod_id).hide();}} function handle_resend_order_email_button_click($this) {var url='https://www.lightology.com/index.php?module=dispatcher';var form_data=$('#resend_order_email_form').serialize();var data='action=resend_order_email&'+form_data;$('#results').html('');var spinner=$('    Sending...');var $td=$this.closest('td');var $button=$this.detach();$td.prepend(spinner);$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){$td.find('span').replaceWith($button);$('#results').html(data);}});} function handle_reset_find_project_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#reset_find_project').text();$('#reset_find_project').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=reset_find_project';$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#reset_find_project').text(button_text);$('#active_tool_content').html(data);set_tool_height(TOOL_FIND_PROJECT,0);},error:function(){ajax_call_in_progress=false;$('#reset_find_project').text(ajax_call_error_text);}});} function handle_sales_tax_state_change() {let url='https://www.lightology.com/index.php?module=dispatcher';let state_id=parseInt($('#sales_tax_state').val(),10);let data='action=sales_tax_state_change&state_id='+state_id;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data){if(data.sales_tax_rate){$('#state_sales_tax_rate').val(data.sales_tax_rate);}else{$('#state_sales_tax_rate').val('System Error');}}},error:function(){$('#state_sales_tax_rate').val('System Error');}});} function handle_spec_sheet_show_sku_click($this) {let prod_id=$this.attr('id').replace('show_sku_','');let $link=$('a#spec_sheet_link_'+prod_id);let href=$link.attr('href');if($this.prop('checked')){$link.attr('href',href+'&show_sku=1');}else{$link.attr('href',href.replace(/&show_sku=[0-9]+/g,''));}} function handle_start_customer_emulation_click(element) {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let cust_id=0;let cart_id=0;let wishlist_id=0;let element_id=element.id let return_module='';if(typeof element_id==='string'&&element_id.indexOf('db_cart_')===0){cart_id=parseInt(element_id.substring(8));} else if(typeof element_id==='string'&&element_id.indexOf('wishlist_id_')===0){wishlist_id=parseInt(element_id.substring(12));return_module='admin_find_cust';} else if(typeof element_id==='string'&&element_id.indexOf('matching_wishlist_id_')===0){wishlist_id=parseInt(element_id.substring(21));cust_id=$(element).data('custId');return_module='admin_find_wish';} let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=start_customer_emulation&cust_id='+cust_id+'&cart_id='+cart_id;if(return_module.length>0){data=data+'&return_module='+return_module;} $.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data) {ajax_call_in_progress=false;if(data){if(data.code==1){if(wishlist_id>0){window.location='https://www.lightology.com/index.php?module=wishlist&wishlist_id='+wishlist_id;}else{window.location='https://www.lightology.com/index.php?module=cust';}}}},error:function(){ajax_call_in_progress=false;}});} function handle_submit_account_settings_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#submit_account_settings').text();$('#submit_account_settings').text(ajax_call_button_text);$('#account_settings_form *').removeClass('err_bg');let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=save_user_account_settings_redesign';data+='&'+$('#account_settings_form').serialize();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#submit_account_settings').text(button_text);$('#account_settings_form .message').html(data.message);let code=(typeof data.code=='string')?parseInt(data.code):data.code;switch(code){case 0:if(data.fields.length){set_modal_height(MODAL_ACCOUNT_SETTINGS,data.fields.length);for(let property in data.fields){if(data.fields.hasOwnProperty(property)){$('#'+data.fields[property]).addClass('err_bg');}}} break;case 1:$('#user_account_settings').replaceWith(data.html);setTimeout(function(){$('#account_settings_form .message').html('');$('#account_settings_modal').modal('hide');},1500);break;}},error:function(){ajax_call_in_progress=false;$('#submit_account_settings').text(ajax_call_error_text);}});} function handle_submit_change_password_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#submit_change_password').text();$('#submit_change_password').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=save_user_new_password';data+='&'+$('#change_password_form').serialize();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#submit_change_password').text(button_text);$('#change_password_form .message').html(data.message);set_modal_height(MODAL_CHANGE_PASSWORD,2) if(data.code==1){setTimeout(function(){$('#change_password_form .message').html('');$('#change_password_modal').modal('hide');},3000);}},error:function(){ajax_call_in_progress=false;$('#submit_change_password').text(ajax_call_error_text);}});} function handle_submit_find_project_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#submit_find_project').text();$('#submit_find_project').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let form_data=$('#find_project_form').serialize();let profile_page='';if($('.profile_page').length){profile_page='&profile_page';} let data='action=find_matching_projects&'+form_data+profile_page;$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#submit_find_project').text(button_text);if(data){if(data.html){$('#active_tool_content').append(data.html);} if(data.profile){$('.profile_page').replaceWith(data.profile);}}},error:function(){ajax_call_in_progress=false;$('#submit_find_project').text(ajax_call_error_text);}});} function handle_tax_exemption_click() {if($('#tax_exemption_modal').length){$('#tax_exemption_modal').modal();} else{if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#tax_exemption_dialog').text();$('#tax_exemption_dialog').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=build_tax_exemption_dialog';$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){if(data){ajax_call_in_progress=false;$('#tax_exemption_dialog').text(button_text);$('#account-layout').append(data);$('#tax_exemption_modal').modal();set_modal_height(MODAL_TAX_EXEMPTION,0);}},error:function(){ajax_call_in_progress=false;$('#tax_exemption_dialog').text(ajax_call_error_text);}});}} function handle_tool_window_resize() {if(selected_tool!==TOOL_NONE){set_tool_height(selected_tool,0);}} function handle_update_customer_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;const fields={catalogs:{multiselect_checkbox:true},cust_account_type:{checkbox:true},cust_company_name:{},cust_contact_ok:{checkbox:true},cust_email:{},cust_first_name:{},cust_last_name:{},cust_nxt_id:{},cust_phone:{},cust_phone_fax:{},cust_phone_mobile:{},cust_phone_other:{},include_100_off:{checkbox:true},occupation:{select_dropdown:true},order_catalogs:{checkbox:true},price_code:{select_dropdown:true},sales_rep_change_reason:{textarea:true},sales_rep_id:{select_dropdown:true},send_email:{checkbox:true}};$('.message').html('');let $update_customer=$('#update_customer');let button_text=$update_customer.text();$update_customer.text(ajax_call_button_text);$('#edit_customer_form *').removeClass('err_bg');let url='https://www.lightology.com/index.php?module=dispatcher';let data='action=update_customer';for(let field in fields){if(fields[field].hasOwnProperty('multiselect_checkbox')){let values=[];$.each($('input[name="'+field+'"]:checked'),function(){values.push($(this).val());});data+='&'+field+'='+values.join('|');}else if(fields[field].hasOwnProperty('checkbox')){data+='&'+field+'='+$('input[name="'+field+'"]:checked').val();}else if(fields[field].hasOwnProperty('select_dropdown')){data+='&'+field+'='+$('select[name="'+field+'"] option:selected').val();}else if(fields[field].hasOwnProperty('textarea')){data+='&'+field+'='+encodeURIComponent($('textarea[name="'+field+'"]').val());}else{data+='&'+field+'='+encodeURIComponent($('input[name="'+field+'"]').val());}} $.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$update_customer.text(button_text);if(data.hasOwnProperty('message')){$('.message').html(data.message);} if(data.hasOwnProperty('code')){let code=(typeof data.code=='string')?parseInt(data.code):data.code;if(code<1&&data.hasOwnProperty('fields')){if(data.fields.length>0){set_modal_height(TOOL_EDIT_CUSTOMER,data.fields.length);for(let property in data.fields){if(data.fields.hasOwnProperty(property)){$('#'+data.fields[property]).addClass('err_bg');}}}}}},error:function(){ajax_call_in_progress=false;$('#update_customer').text(ajax_call_error_text);}});} function handle_update_salesrep_click() {var url='https://www.lightology.com/index.php?module=dispatcher';var salesrep_id=parseInt($('#sales_rep_id').val(),10);var data='action=update_salesrep&salesrep_id='+salesrep_id;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){window.location.reload();},error:function(){}});} function handle_user_account_type_change($this) {let height=$('#account_settings_inquiry').height();if($this.val()=='2'){$('#company_name_div, #company_website_div, #company_occupation_div').show();height+=100;}else{$('#company_name_div, #company_website_div, #company_occupation_div').hide();height-=100;} $('#account_settings_inquiry').height(height);} function handle_user_country_change() {let url='https://www.lightology.com/index.php?module=dispatcher';let country_id=parseInt($('#user_country_id').val(),10);let data='action=address_country_change&country_id='+country_id;$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){let $user_state=$('#user_state');let $user_state_id=$('#user_state_id');$user_state_id.find('option').remove();if(data.length){$user_state.show();$user_state_id.append(data);}else{$user_state.hide();}},error:function(){}});} function handle_user_has_salesrep_click() {if($('#user_has_salesrep').is(':checked')){$('#user_salesrep_id').show();}else{$('#user_salesrep_id').hide();}} function handle_view_cart_activity_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let $view_cart_activity=$('#view_cart_activity');let button_text=$view_cart_activity.text();$view_cart_activity.text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let cart_activity_arg=$('#cart_activity_arg').val();let data='action=view_cart_activity&cart_activity_arg='+cart_activity_arg;$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$view_cart_activity.text(button_text);$('#active_tool_content').append(data);},error:function(){ajax_call_in_progress=false;$('#view_cart_activity').text(ajax_call_error_text);}});} function handle_view_cart_button_click() {if(ajax_call_in_progress){return;} ajax_call_in_progress=true;let button_text=$('#view_cart').text();$('#view_cart').text(ajax_call_button_text);let url='https://www.lightology.com/index.php?module=dispatcher';let form_data=$('#view_cart_form').serialize();let data='action=view_cart&'+form_data;$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){ajax_call_in_progress=false;$('#view_cart').text(button_text);$('#active_tool_content').append(data);},error:function(){ajax_call_in_progress=false;$('#view_cart').text(ajax_call_error_text);}});} function handle_view_order_details_click($this) {let url='https://www.lightology.com/index.php?module=dispatcher';let cust_type=$this.data('custType');let nxtrend_order_id=$this.data('nxtrendOrderId');let data='action=build_order_details_html&nxtrend_order_id='+nxtrend_order_id+'&cust_type='+cust_type;if($this.hasClass('expanded')){$('#order_details_'+nxtrend_order_id).remove();$this.find('.expand_button').html('');$this.removeClass('expanded');} else{$this.find('.expand_button').html('');$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){$this.find('.expand_button').html('');if(data.code===1){$this.closest('div').after(data.html);}}});$this.addClass('expanded');}} function handle_virtual_inventory_page_click($this) {let url='https://www.lightology.com/index.php?module=dispatcher';let page=$this.attr('id').replace('page_','');let form_data=$('#virtual_inventory_form').serialize();let data='action=find_virtual_inventory&'+form_data+'&page='+page;$('#tool_results').remove();$.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){$('#active_tool_content').append(data);}});} $(function(){$(window).on('scroll',function(){let scrollTop=$(window).scrollTop();if(scrollTop>50){$('.project_files_action_bar').stop().css("padding","12px 20px 15px");$('.project_action_bar').stop().css("padding","12px 20px 15px");$('.scroll-fx').stop().css("height","25px");} else{$('.project_files_action_bar').stop().css("padding","50px 20px");$('.project_action_bar').stop().css("padding","50px 20px");$('.scroll-fx').stop().css("height","50px");}});$('body').on('click','#account_logout_link',function(event){event.preventDefault();handle_logout_link_click($(this));}).on('click','#account_signin',function(event){event.preventDefault();handle_account_signin_click();}).on('click','.account-tabs li a, .account_tab_button',function(){handle_account_tab_click($(this));}).on('click','.add-address',function(){handle_add_address_click($(this));}).on('click','.address_bill',function(){handle_address_default_click($(this),'bill');}).on('change','#address_country_id',function(){handle_address_country_change();}).on('change','#edit_customer_country_id',function(){handle_edit_customer_country_change();}).on('click','.address_ship',function(){handle_address_default_click($(this),'ship');}).on('click','#back_to_dashboard',function(){handle_back_to_dashboard_click()}).on('click','#cancel_account_settings',function(event){event.preventDefault();$('#account_settings_modal').modal('hide');}).on('click','#cancel_add_address',function(event){event.preventDefault();$('#add_address_modal').modal('hide');}).on('click','#cancel_add_non_stock_item',function(event){event.preventDefault();$('#edit_non_stock_item_modal').modal('hide');}).on('click','#cancel_add_project_option',function(event){event.preventDefault();$('#add_project_option_modal').modal('hide');}).on('click','#cancel_add_project_room',function(event){event.preventDefault();$('#add_project_room_modal').modal('hide');}).on('click','#cancel_change_password',function(event){event.preventDefault();$('#change_password_modal').modal('hide');}).on('click','#cancel_copy_project',function(event){event.preventDefault();$('#copy_project_modal').modal('hide');}).on('click','#cancel_edit_address',function(event){event.preventDefault();$('#edit_address_modal').modal('hide');}).on('click','#cancel_edit_project',function(event){event.preventDefault();$('#edit_project_modal').modal('hide');}).on('click','#cancel_edit_trade_request',function(event){event.preventDefault();$('#edit_trade_request_modal').modal('hide');}).on('click','#cancel_remove_project',function(event){event.preventDefault();$('#confirmation_modal').modal('hide');}).on('click','#cancel_remove_project_item',function(event){event.preventDefault();$('#confirmation_modal').modal('hide');}).on('click','#cancel_remove_project_room',function(event){event.preventDefault();$('#confirmation_modal').modal('hide');}).on('click','#cancel_rename_project_room',function(event){event.preventDefault();$('#rename_project_room_modal').modal('hide');}).on('click','#cancel_tax_exemption',function(event){event.preventDefault();$('#tax_exemption_modal').modal('hide');}).on('click','#cancel_update_non_stock_item',function(event){event.preventDefault();$('#edit_non_stock_item_modal').modal('hide');}).on('click','#cancel_xfer_project_items',function(event){event.preventDefault();$('#xfer_project_items_modal').modal('hide');}).on('click','#change_password_redesign',function(){handle_change_password_redesign_click();}).on('click','#create_account_show_password > input',function(){var field_type=$('#user_password').attr('type');if(field_type==='password'){$('#user_password, #user_password_confirm').attr('type','text');}else{$('#user_password, #user_password_confirm').attr('type','password');}}).on('click','#create_customer',function(event){event.preventDefault();handle_create_customer_button_click();}).on('change','input[type=radio][name=cust_account_type]',function(){handle_cust_account_type_change($(this));}).on('change','#cust_country_id',function(){handle_cust_country_change();}).on('click','#cust_got_consultant',function(){if($(this).prop('checked')){$('#cust_slsrep').prop('disabled',false);}else{$('#cust_slsrep').prop('disabled',true);}}).on('click','#cust_talk_consultant',function(){if($(this).prop('checked')){$('#cust_contact_info').prop('disabled',false);}else{$('#cust_contact_info').prop('disabled',true);}}).on('click','.delete_customer_address',function(){handle_delete_customer_address_click($(this));}).on('click','#edit_account_settings_redesign',function(){handle_edit_account_settings_redesign_click();}).on('click','.edit_address_redesign',function(){handle_edit_address_click($(this));}).on('click','#find_customer',function(event){event.preventDefault();handle_find_customer_button_click();}).on('keypress','#find_customer_form',function(event){let key=event.which;if(key==13){event.preventDefault();handle_find_customer_button_click();}}).on('click','#find_customer_reset',function(event){event.preventDefault();handle_find_customer_reset_button_click();}).on('keypress','#find_product_form',function(event){let key=event.which;if(key==13){event.preventDefault();handle_find_product_redesign_button_click();}}).on('click','#find_product_redesign',function(event){event.preventDefault();handle_find_product_redesign_button_click();}).on('click','#find_product_reset',function(event){event.preventDefault();handle_find_product_reset_button_click();}).on('keypress','#find_project_form',function(event){let key=event.which;if(key==13){event.preventDefault();handle_submit_find_project_click();}}).on('click','#find_virtual_inventory',function(event){event.preventDefault();handle_find_virtual_inventory_button_click();}).on('click','#find_virtual_inventory_reset',function(event){event.preventDefault();handle_find_virtual_inventory_reset_button_click();}).on('keypress','#find_wishlist_form',function(event){let key=event.which;if(key==13){event.preventDefault();handle_find_wishlist_redesign_button_click();}}).on('click','#find_wishlist_redesign',function(event){event.preventDefault();handle_find_wishlist_redesign_button_click();}).on('click','#find_wishlist_reset',function(event){event.preventDefault();handle_find_wishlist_reset_button_click();}).on('click','#get_zip_sales_tax_rate',function(){handle_get_zip_sales_tax_rate_click();}).on('click','input[name="include_carts_no"]',function(event){event.preventDefault();window.location=$('input[name="redirect"]').val();}).on('click','input[name="include_carts_yes"]',function(event){event.preventDefault();handle_include_other_db_carts();}).on('change','#load_database_cart',function(){handle_load_database_cart_click();}).on('change','#price_code',function(){handle_cust_send_email_change();}).on('click','#project_owner_find',function(event){event.preventDefault();handle_project_owner_name_change();}).on('click','#project_owner_reset',function(event){event.preventDefault();window.location='https://www.lightology.com/index.php?module=pm_home';}).on('change','input[type=radio][name=project_select]',function(){handle_project_select_type_change($(this));}).on('change','.reason_select',function(){handle_reason_select_change(this);}).on('click','#resend_order_email',function(event){event.preventDefault();handle_resend_order_email_button_click($(this));}).on('click','#reset_find_project',function(event){event.preventDefault();handle_reset_find_project_button_click();}).on('change','#sales_rep_id',function(){if($('#edit_customer_form').length){$('#sales_rep_change_reason_div').show();let height=$('#static-display-form').height();height+=160;$('#static-display-form').height(height);$('#form-single-tools').height(height);}}).on('change','#sales_tax_state',function(){handle_sales_tax_state_change();}).on('change','input[name="order_catalogs"]',function(){handle_cust_order_catalogs_change();}).on('change','input[name="send_email"]',function(){handle_cust_send_email_change();}).on('click','.spec_sheet_show_sku',function(){handle_spec_sheet_show_sku_click($(this));}).on('click','#start_customer_emulation, .emulate_customer_cart, '+'.account_wishlist_name, .matching_wishlist_name',function(event) {event.preventDefault();handle_start_customer_emulation_click(this);}).on('click','#submit_account_settings',function(event){event.preventDefault();handle_submit_account_settings_click();}).on('click','#submit_add_address',function(event){event.preventDefault();save_address('add_',create_customer_address,null);}).on('click','#submit_change_password',function(event){event.preventDefault();handle_submit_change_password_click();}).on('click','#submit_edit_address',function(event){event.preventDefault();save_address('edit_',update_customer_address,null);}).on('click','#submit_find_project',function(event){event.preventDefault();handle_submit_find_project_click();}).on('click','#submit_tax_exemption',function(){$('#tax_exemption_modal').modal('hide');}).on('click','#tax_exemption_dialog',function(){handle_tax_exemption_click();}).on('click','#update_customer',function(event){event.preventDefault();handle_update_customer_button_click();}).on('click','#update_salesrep',function(){handle_update_salesrep_click();}).on('change','input[type=radio][name=user_account_type]',function(){handle_user_account_type_change($(this));}).on('change','#user_country_id',function(){handle_user_country_change();}).on('change','#user_has_salesrep',function(){handle_user_has_salesrep_click();}).on('click','#view_cart',function(event){event.preventDefault();handle_view_cart_button_click();}).on('click','#view_cart_activity',function(event){event.preventDefault();handle_view_cart_activity_button_click();}).on('keypress','#view_cart_form',function(event){let key=event.which;if(key==13){event.preventDefault();handle_view_cart_button_click();}}).on('click','.view_order_details',function(){handle_view_order_details_click($(this));}).on('keypress','#virtual_inventory_form',function(event){let key=event.which;if(key==13){event.preventDefault();handle_find_virtual_inventory_button_click();}}).on('click','.virtual_inventory_page',function(event){event.preventDefault();handle_virtual_inventory_page_click($(this));}).on('keypress','#xfer_items_project_name',function(){$('input[name="project_select"]:eq(1)').prop('checked',true);$('#new_project_room_fieldset').show();modal_xfer_project_items_height=360;set_modal_height(MODAL_XFER_PROJECT_ITEMS,0);}).on('keypress','#zip_sales_tax_rate_form',function(event){let key=event.which;if(key==13){event.preventDefault();handle_get_zip_sales_tax_rate_click();}})});$(document).ready(function(){if($(".registration_failed").length>0){$(".show-top")[0].scrollIntoView();if(window.matchMedia("only screen and (max-width: 920px)").matches){$("document").ready(function(){$(".set-top-mob").css("margin-top","140px");});} if(window.matchMedia("only screen and (min-width: 1320px)").matches){$("document").ready(function(){$(".set-top-mob").css("margin-top","60px");});}}});