1function getRequestHeaders() { 2 var csrfToken = $("meta[name='_csrf']").attr("content"); 3 var csrfHeader = $("meta[name='_csrf_header']").attr("content"); 4 5 var requestHeaders = { 6 'Accept' : 'application/json', 7 }; 8 requestHeaders[csrfHeader] = csrfToken; 9 return requestHeaders; 10}; 11 12/* 13* 14* PURCHASE ACCOUNT SELECTION MODAL 15* 16*/ 17 18function disableSave(){ 19 // disable the save button 20 $(".js-save").attr("disabled", true); 21} 22 23function enableSave(){ 24 // enable the save button 25 $(".js-save").attr("disabled", false); 26} 27 28function enableSubAccount(){ 29 // enable checkbox 30 $(".js-pa-subAccountToggle").attr("disabled", false); 31} 32 33function enableShowAvailabilityFor(){ 34 // enable the radio buttons 35 $(".js_showAvail").attr("disabled", false); 36 $(".purchaseAccount .js-shipTo").attr("disabled", false); 37} 38 39function resetForm(){ 40 // reset the entire form back to it's default state. 41 $(".js-pa-subAccountToggle").prop("checked", false).attr("disabled", true); 42 $(".js-pa-subAccountOption").hide(); 43 $(".js_showAvail").attr("disabled", true); 44 $(".purchaseAccount .js-shipTo").attr("disabled", true); 45 $(".js-save").attr("disabled", true); 46 $(".customerNameUnit").val("Please select"); 47} 48 49function fatalError(){ 50 // Shut everything down if we can't retrieve a feed due to an error. 51 // $(".js_purchaseAccountError").show(); 52 // $(".js_purchaseAccountForm").hide(); 53} 54 55function setDefaultData(){ 56 var payerId = $("#payerId").val(); 57 var soldToId = $("#soldToId").val(); 58 var isDefaultAddressPickup = $("#isDefaultAddressPickup").val(); 59 60 if(soldToId) { 61 $('.customerNameUnit').change(); 62 if (payerId && payerId != soldToId) { 63 $(".js-pa-subAccountToggle").prop("checked", true); 64 $(".js-pa-subAccountOption").toggle(true); 65 } 66 else{ 67 $(".js-pa-subAccountToggle").prop("checked", false); 68 $(".js-pa-subAccountOption").toggle(false); 69 } 70 71 if (isDefaultAddressPickup && isDefaultAddressPickup != "false") { 72 $("#showAvailPickup").prop("checked", true); 73 } else { 74 $("#showAvailDelivery").prop("checked", true); 75 } 76 updateShipTo(); 77 } 78} 79 80function initializeSoldTo(){ 81 82 // Initialize the SOLD TO dropdown. 83 $.ajax({ 84 url: ACC.config.encodedContextPath + "/my-account-api/getB2BCustDetailsAjax", 85 dataType: "json", 86 data: {}, 87 success: function(data) { 88 var soldToId = $("#soldToId").val(); 89 var options = '<option value="Please select">Select an account</option>'; 90 for (var i = 0; i < data.length; i++){ 91 var addressValue = ""; 92 if(data[i].addresses[0].line1.length != 0) addressValue = data[i].addresses[0].line1 + ", "; 93 if(data[i].addresses[0].town.length != 0) addressValue = ", " + addressValue + data[i].addresses[0].town + ", "; 94 if(data[i].addresses[0].region.isocodeShort.length != 0) addressValue = addressValue + data[i].addresses[0].region.isocodeShort +", "; 95 if(data[i].addresses[0].postalCode.length != 0) addressValue += data[i].addresses[0].postalCode; 96 97 if(soldToId == data[i].uid) 98 options += '<option value="' + data[i].uid + '" selected>' + data[i].uid + ", " + data[i].name + addressValue + '</option>'; 99 else 100 options += '<option value="' + data[i].uid + '">' + data[i].uid + ", " + data[i].name + addressValue + '</option>'; 101 } 102 $(".customerNameUnit").empty().append(options); 103 $("body").addClass("jsModalLoaded"); 104 if (data.length > 0) { 105 setDefaultData(); 106 } 107 }, 108 error: function() { 109 //fatalError(); 110 console.log("could not fetch: " + ACC.config.encodedContextPath + "/my-account-api/getB2BCustDetailsAjax"); 111 } 112 }); 113} 114 115$('.customerNameUnit').change(function () { 116 // Main Account - Sold To 117 var currentValue = $(this).val(); 118 $.ajax({ 119 url: ACC.config.encodedContextPath + "/my-account-api/getPayerDetails", 120 dataType: "json", 121 data: { 122 b2bUnitCode: $(".customerNameUnit").val() 123 }, 124 success: function (data) { 125 var defaultShipTo = $("#payerId").val(); 126 //Check if default payer exits 127 const selectPayer = data.find(address => address.id == defaultShipTo) ? defaultShipTo : currentValue; 128 var options = ""; 129 130 for (var i = 0; i < data.length; i++) { 131 var addressValue = ""; 132 if(data[i].addressLine1 != null) addressValue = ", " + data[i].addressLine1 +", "; 133 if(data[i].town != null) addressValue = addressValue + data[i].town +", "; 134 if(data[i].isoShortCode != null) addressValue = addressValue + data[i].isoShortCode +", "; 135 if(data[i].postalCode != null) addressValue += data[i].postalCode; 136 137 if(data[i].id == selectPayer){ 138 options += '<option value="' + data[i].id + '" selected>' + data[i].id + ', ' + data[i].companyName + addressValue + '</option>'; 139 } else { 140 options += '<option value="' + data[i].id + '">' + data[i].id + ', ' + data[i].companyName + addressValue + '</option>'; 141 } 142 } 143 144 $(".payerName").empty().append(options); 145 146 if (data.length > 0) { 147 enableSubAccount(); 148 enableShowAvailabilityFor(); 149 updateShipTo(); 150 } else { 151 resetForm(); 152 } 153 if(!data.find(address => address.id == currentValue)) { 154 $(".js-pa-subAccountToggle").prop("checked", true); 155 $(".js-pa-subAccountOption").toggle(true); 156 } 157 else{ 158 $(".js-pa-subAccountToggle").prop("checked", false); 159 $(".js-pa-subAccountOption").toggle(false); 160 } 161 }, 162 error: function (jqXHR, exception) { 163 console.log("error"); 164 if (data.length > 0) { 165 //fatalError(); 166 } 167 } 168 }); 169}); 170 171$('.js-pa-subAccountToggle').click(function() { 172 // Only show Sub Account Options when check mark is checked. 173 $(".js-pa-subAccountOption").toggle(this.checked); 174 if ($(this).prop("checked") == false) { 175 //Set it to the current value or default value. 176 $(".js-pa-subAccountToggle").prop("checked", false); 177 $(".js-pa-subAccountOption").hide(); 178 var selectedSoldTo = $("#customerNameUnit").val(); 179 if(selectedSoldTo){ 180 $("#payerName").val(selectedSoldTo); 181 } 182 updateShipTo(); 183 } 184}); 185 186$("input[name=showAvail]").change(function(){ 187 // Updates the Ship-to SELECT depending on if the user wants PICK UP or DELIVERY 188 updateShipTo(); 189}); 190 191$('.payerName').change(function () { 192 // Updates the Ship-to SELECT with user selects a new PAYER 193 updateShipTo(); 194}); 195 196$('.purchaseAccount .shipTo').change(function() { 197 if(!($(".purchaseAccount .js-shipTo").val()=='Select Ship To Address')){ 198 if($(".purchaseAccount .js-shipTo").text() && $(".customerNameUnit").text()) { 199 enableSave(); 200 } else { 201 disableSave(); 202 } 203 var payerId=$(".js-payer").val(); 204 var soldId=$(".customerNameUnit").val(); 205 var shipTo=$(".purchaseAccount .js-shipTo").val(); 206 207 if($("#hiddenCartValue").val() && !($("#soldToId").val()==soldId && $("#payerId").val()==payerId && $("#defaultAddressId").val()==shipTo)) { 208 $(".cartValueChanges").show(); 209 }else { 210 $(".cartValueChanges").hide(); 211 } 212 }else{ 213 $(".cartValueChanges").hide(); 214 } 215}); 216 217// #save 218$('.js-save').click(function(){ 219 $('.changeAccountDOM .js-save').text(''); 220 $('.changeAccountDOM .context-loader').css('display','block'); 221 var checkedValue = document.getElementById("defaultCheckBox").checked; 222 //event.preventDefault(); 223 $.ajax({
224 url : ACC.config.encodedContextPath + "/my-account-api/saveDefaultDetailsOfAUser", 225 type : 'POST', 226 data : { 227 payerName : $(".js-payer").val(), 228 shipToName : $(".purchaseAccount .js-shipTo").val(), 229 soldToName : $(".customerNameUnit").val(), 230 defaultFlagSelected: document.getElementById("defaultCheckBox").checked 231 }, 232 success : function(data) { 233 if (data.status == 'success') { 234 // window.location.href = ACC.config.encodedContextPath; 235 if (window.location.href.indexOf("getB2BCustDetails") > -1) { 236 if (getCookie("BSERedirectAfterLogin") != "" && getCookie("BSERedirectAfterLogin").indexOf("com.chrome.devtools.json") < 0) { 237 var redirectAfterLoginUrl = decodeURI(getCookie("BSERedirectAfterLogin")); 238 document.cookie = "BSERedirectAfterLogin=;secure; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; 239 window.location.href = redirectAfterLoginUrl; 240 } else { 241 window.location.href = "/"; 242 } 243 } else { 244 if (window.location.href.indexOf("/clearance") > -1 || (window.location.href.indexOf("campaignAttributes") > -1 && window.location.href.indexOf("-Clearance") > -1 && window.location.href.indexOf("WH") > -1)) { 245 window.location.href = "/"; 246 } else { 247 window.location.reload(); 248 } 249 } 250 } else if (data.status == 'redirectToProfilePage') { 251 window.location.href = ACC.config.encodedContextPath + "/my-account/update-profile"; 252 } 253 }, 254 error: function (jqXHR, exception) { 255 var options = '<option value="Select Address">Select Address</option>'; 256 $(".shipTo").empty().append(options); 257 } 258 }); 259}); 260 261 262$('#ChangeCustomerOrShipTo').click(function(){ 263 window.location = ACC.config.encodedContextPath + "/my-account/getB2BCustDetails"; 264}); 265 266$(document).ready(function(){ 267 268 // Initialize colorbox modal 269 $('.js-changePurchaseAccountModal').colorbox({ 270 inline: true, 271 maxWidth: 800, 272 width: "100%", 273 maxHeight:"99%", 274 className: "purchaseAccountModal", 275 close: '<img alt=\"\" src=\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMC44OSIgaGVpZ2h0PSIyMC44OSIgdmlld0JveD0iMCAwIDIwLjg5IDIwLjg5Ij4KICAgIDxkZWZzPgogICAgICAgIDxzdHlsZT4KICAgICAgICAgICAgLmNscy0xe2ZpbGw6IzAwNTdiOH0KICAgICAgICA8L3N0eWxlPgogICAgPC9kZWZzPgogICAgPGcgaWQ9ImNsb3NlIj4KICAgICAgICA8ZyBpZD0iR3JvdXBfOTQwIiBkYXRhLW5hbWU9Ikdyb3VwIDk0MCI+CiAgICAgICAgICAgIDxwYXRoIGlkPSJSZWN0YW5nbGVfMTA3MiIgZD0iTTAgMGgyNS4xMDV2NC40MzhIMHoiIGNsYXNzPSJjbHMtMSIgZGF0YS1uYW1lPSJSZWN0YW5nbGUgMTA3MiIgdHJhbnNmb3JtPSJyb3RhdGUoLTQ1IDIxLjQyOSA4Ljg3NikiLz4KICAgICAgICA8L2c+CiAgICAgICAgPGcgaWQ9Ikdyb3VwXzk0MSIgZGF0YS1uYW1lPSJHcm91cCA5NDEiPgogICAgICAgICAgICA8cGF0aCBpZD0iUmVjdGFuZ2xlXzEwNzMiIGQ9Ik0wIDBoNC40Mzh2MjUuMTA1SDB6IiBjbGFzcz0iY2xzLTEiIGRhdGEtbmFtZT0iUmVjdGFuZ2xlIDEwNzMiIHRyYW5zZm9ybT0icm90YXRlKC00NSAzLjc4OCAxLjU2OSkiLz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPgo=\" />', 276 href: ".changeAccountDOM", 277 onOpen: function() { 278 initializeSoldTo(); 279 } 280 }); 281 282 // For the 'cancel' button 283 $('.js-purchaseAccountCancel').click(function(){ 284 resetForm(); 285 if ($("body").hasClass("page-changeB2BCustAddress")){ 286 // not a modal 287 var goUrl = $(".site-logo").find("a").attr("href"); 288 document.location.href = goUrl; 289 } else { 290 // in a modal 291 parent.$.colorbox.close(); 292 return false; 293 } 294 }); 295 296 if (window.location.href.indexOf("getB2BCustDetails") > -1) { 297 // we're on the B2B page 298 $(".js-openPAModal").hide(); 299 } else { 300 $(".js_noModal").remove(); 301 } 302}); 303 304 305//myCompanyManageUserAddEditformPAge.jsp 306 307$('.userSoldTo').change(function() { 308 //event.preventDefault(); 309 $.ajax({
310 url : ACC.config.encodedContextPath + "/my-account-api/getPayerDetails", 311 dataType: "json", 312 data : { 313 b2bUnitCode : $("#userSoldTo").val() 314 }, 315 success : function(data) { 316 var options = '<option value="Please Select">Select Sub Account </option>'; 317 318 for (var i = 0; i < data.length; i++) { 319 options += '<option value="' + data[i].id + '">' + data[i].id + '</option>'; 320 } 321 $(".userPayer").empty().append(options); 322 if(data.length>0){ 323 document.getElementById("createUserPayerDiv").style.display = "block"; 324 document.getElementById("createUserShipToDiv").style.display = "none"; 325 } 326 }, 327 error: function (jqXHR, exception) { 328 if(data.length>0){ 329 document.getElementById("createUserPayerDiv").style.display = "none"; 330 document.getElementById("createUserShipToDiv").style.display = "none"; 331 } 332 } 333 }); 334}); 335 336$('.userPayer').change(function() { 337 $.ajax({ 338 url : ACC.config.encodedContextPath + "/my-account-api/getShipToDetails", 339 dataType: "json", 340 data : { 341 payer : $("#userPayer").val() 342 }, 343 success : function(data) { 344 var options = '<option value="Please Select">Select Ship To</option>'; 345 for (var i = 0; i < data.length; i++) { 346 options += '<option value="' + data[i].id + '">' + data[i].formattedAddress + '</option>'; 347 } 348 $(".userShipto").empty().append(options); 349 if(data.length>0){ 350 document.getElementById("createUserPayerDiv").style.display = "block"; 351 document.getElementById("createUserShipToDiv").style.display = "block"; 352 } 353 }, 354 error: function (jqXHR, exception) { 355 var options = '<option value="Please Select">Select Ship To</option>'; 356 $(".userShipto").empty().append(options); 357 } 358 359 }); 360}); 361 362function checkEnable() { 363 364 if ($("input[name='firstName']").val() == '' || $("input[name='lastName']").val() == '' || $("input[name='email']").val() == '' || !$("input[name='roles']:checked").val() || !checkCheckBoxStatus() ) { 365 //Check to see if there is any text entered 366 // If there is no text within the input ten disable the button 367 $('#userCreateBtn').prop('disabled', true); 368 } else { 369 //If there is text in the input, then enable the button 370 $('#userCreateBtn').prop('disabled', false); 371 } 372} 373 374$("#userCreateForm").change(function(){ 375 checkEnable(); 376}); 377function checkCheckBoxStatus(){ 378 var checkedOne=false; 379 $('.unitsdiv > div.totaldiv').each(function(){ 380 381 $(this).find("input[type=checkbox][name=unitsData]").each(function () { 382 383 if(this.checked){ 384 385 $(this).parent().find(".payersdiv").find("input[type=checkbox]").each(function(){ 386 var ele=$(this); 387 if(ele.is(":checked")){ 388 checkedOne=true; 389 } 390 }); 391 } 392 393 }); 394 395 }); 396 return checkedOne; 397} 398 399$(".helperTextUserOwn").on("click",function(){ 400 setTimeout(function(){ 401 $.colorbox.resize({ 402 width: window.innerWidth > parseInt(cboxOptions.maxWidth) ? cboxOptions.maxWidth : cboxOptions.width, 403 height: window.innerHeight > parseInt(cboxOptions.maxHeight) ? cboxOptions.maxHeight : cboxOptions.height 404 }); 405 406 },0); 407}); 408$("button.newusercancel").on("click",function(){ 409 $("input[name='pwd']").val(''); 410 $("input[name='checkPwd']").val(''); 411 $("#password_bar").hide(); 412}); 413$(document).ready(function(){
414 $(".loginNewPasswordChg #password_minchar").css('visibility','hidden'); 415 checkEnable(); 416 417}); 418 419$(document).ready(function(){ 420 421 $(".datepicker input").attr("autocomplete", "off"); 422 423 $("#quotetodate").datepicker(); 424 $("#quotefromdate").datepicker(); 425 426 $(document).on("change", '#form_quoteHistoryForm #selectSoldTo select', function () { 427 $("#form_quoteHistoryForm #quote\\.payer").empty(); 428 displayPayerBySoldTo($(this).val(), "form_quoteHistoryForm"); 429 }); 430 431 432 function displayPayerBySoldTo(soldToCode, owner) { 433 $("#" + owner + " #quote\\.payer").empty(); 434 $("#" + owner + " #quote\\.payer").append($("<option></option>") 435 .attr("value", "ALL").text("ALL")); 436 437 $("#" + owner + " #inactivePayer").empty(); 438 $("#" + owner + " #inactivePayer").append($("<option></option>") 439 .attr("value", "ALL").text("ALL")); 440 441 442 // Do not call filterPayers if the soldToCode is empty (not chosen) 443 if ((soldToCode == null) || (soldToCode == "") || (soldToCode == "ALL")) { 444 $("#" + owner + " #quote\\.payer").enable(); 445 $("#" + owner + " #inactivePayer").enable(); 446 return; 447 } 448 449 $.ajax({ 450 type: 'GET', 451 url: ACC.config.encodedContextPath + "/my-account-api/getPayerDetails", 452 dataType: "json", 453 data: {'b2bUnitCode': soldToCode}, 454 success: function (response) { 455 456 $.each(response, function (key, value) { 457 $("#" + owner + " #quote\\.payer").append($("<option></option>") 458 .attr("value", value.id) 459 .text(value.companyName)) 460 }); 461 // Enables the select box after the result have been added 462 $("#" + owner + " #quote\\.payer").enable(); 463 }, 464 error: function (xhr, ajaxOptions, thrownError) { 465 if (xhr.status == 404) { 466 alert(thrownError); 467 } 468 $("#" + owner + " #quote\\.payer").enable(); 469 } 470 }); 471 472 $.ajax({ 473 type: 'GET', 474 url: ACC.config.encodedContextPath + "/my-account-api/getInactivePayerDetails", 475 dataType: "json", 476 data: {'b2bUnitCode': soldToCode}, 477 success: function (response) { 478 479 $.each(response, function (key, value) { 480 $("#" + owner + " #inactivePayer").append($("<option></option>") 481 .attr("value", value.id) 482 .text(value.companyName)) 483 }); 484 // Enables the select box after the result have been added 485 $("#" + owner + " #inactivePayer").enable(); 486 }, 487 error: function (xhr, ajaxOptions, thrownError) { 488 if (xhr.status == 404) { 489 alert(thrownError); 490 } 491 $("#" + owner + " #inactivePayer").enable(); 492 } 493 }); 494 495 } 496 497 $("#logout").on("click",function(){ 498 localStorage.removeItem("listGridDisabledFlag"); 499 }); 500 501 checkListGridView(); 502 $(".listGridView img").on("click",function(){ 503 if(!$(this).hasClass("disabledImage")){ 504 var view=$(this).attr("id"); 505 var gridViewSelectedFlag; 506 if(view == "gridView") 507 gridViewSelectedFlag = true; 508 else 509 gridViewSelectedFlag = false; 510 if($("#isLoggedInUser").val()=="true"){ 511 $.ajax({ 512 type: 'GET', 513 url: ACC.config.encodedContextPath + "/my-account/updateUserPreference", 514 dataType: "json", 515 data: {'userPrefGridViewSlctdFlag': gridViewSelectedFlag}, 516 success: function (response) {}, 517 error: function (xhr, ajaxOptions, thrownError) {} 518 }); 519 520 $(".listGridView img").removeClass("disabledImage"); 521 $(this).addClass("disabledImage"); 522 }else{ 523 console.log(view); 524 localStorage.setItem("listGridDisabledFlag",view
524); 525 $(".listGridView img").removeClass("disabledImage"); 526 $(this).addClass("disabledImage"); 527 //localStorage.removeItem("listGridDisabledFlag"); 528 } 529 if(view=="listView"){ 530 $(".listViewComp").show(); 531 $(".gridViewComp").hide(); 532 }else if(view=="gridView"){ 533 $(".gridViewComp").show(); 534 $(".listViewComp").hide(); 535 } 536 } 537 }); 538}); 539function checkListGridView(){ 540 if(!localStorage.getItem("listGridDisabledFlag")){ 541 localStorage.setItem("listGridDisabledFlag","gridView"); 542 } 543 if($("#isLoggedInUser")){ 544 if(!($("#isLoggedInUser").val()=="true")){ 545 if(localStorage.getItem("listGridDisabledFlag")=="listView"){ 546 $(".listViewComp").show(); 547 $(".gridViewComp").hide(); 548 $("#listView").addClass("disabledImage"); 549 $("#gridView").removeClass("disabledImage"); 550 551 }else if(localStorage.getItem("listGridDisabledFlag")=="gridView"){ 552 $(".listViewComp").hide(); 553 $(".gridViewComp").show(); 554 $("#gridView").addClass("disabledImage"); 555 $("#listView").removeClass("disabledImage"); 556 } 557 }else{ 558 559 } 560 } 561} 562 563$(document).ready(function(){ 564 565 $(document).on("change", '#bseInvoiceHistorySearchFormId #selectSoldTo select', function () { 566 $("#bseInvoiceHistorySearchFormId #order\\.payer").empty(); 567 displayPayerBySoldTo($(this).val(), "bseInvoiceHistorySearchFormId"); 568 $("#bseInvoiceHistorySearchFormId #order\\.user").empty(); 569 displayUserBySoldTo($(this).val(), "bseInvoiceHistorySearchFormId"); 570 }); 571 572 function displayPayerBySoldTo(soldToCode, owner) { 573 $("#" + owner + " #order\\.payer").empty(); 574 $("#" + owner + " #order\\.payer").append($("<option></option>") 575 .attr("value", "ALL").text("ALL")); 576 577 // Do not call filterPayers if the soldToCode is empty (not chosen) 578 if ((soldToCode == null) || (soldToCode == "") || (soldToCode == "ALL")) { 579 $("#" + owner + " #order\\.payer").enable(); 580 return; 581 } 582 583 $.ajax({ 584 type: 'GET', 585 url: ACC.config.encodedContextPath + "/my-account-api/getPayerDetails", 586 dataType: "json", 587 data: {'b2bUnitCode': soldToCode}, 588 success: function (response) { 589 590 $.each(response, function (key, value) { 591 $("#" + owner + " #order\\.payer").append($("<option></option>") 592 .attr("value", value.id) 593 .text(value.companyName)) 594 }); 595 // Enables the select box after the result have been added 596 $("#" + owner + " #order\\.payer").enable(); 597 }, 598 error: function (xhr, ajaxOptions, thrownError) { 599 if (xhr.status == 404) { 600 alert(thrownError); 601 } 602 $("#" + owner + " #order\\.payer").enable(); 603 } 604 }); 605 606 } 607 function displayUserBySoldTo(soldToCode, owner) { 608 $("#" + owner + " #order\\.user").empty(); 609 $("#" + owner + " #order\\.user").append($("<option></option>") 610 .attr("value", "ALL").text("ALL")); 611 612 // Do not call filterPayers if the soldToCode is empty (not chosen) 613 if ((soldToCode == null) || (soldToCode == "") || (soldToCode == "ALL")) { 614 $("#" + owner + " #order\\.user").enable(); 615 return; 616 } 617 618 $.ajax({ 619 type: 'GET', 620 url: ACC.config.encodedContextPath + "/my-account/getCustomerDetails", 621 dataType: "json", 622 data: {'b2bUnitCode': soldToCode}, 623 success: function (response) { 624 625 $.each(response, function (key, value) { 626 $("#" + owner + " #order\\.user").append($("<option></option>") 627 .attr("value", value.uid) 628 .text(value.firstName + " " + value.lastName)) 629 }); 630 }, 631 error: function (xhr, ajaxOptions, thrownError) { 632 if (xhr.status == 404) { 633 alert(thrownError); 634 } 635 $("#" + owner + " #order\\.user").enable(); 636 } 637 }); 638 639 } 640 641 642 643}); 644 645var previousPodToDate = $("#podToDate").val(); 646var previousPodFromDate = $("#podFromDate").val(); 647 648$(".datepicker input").on("change", function (){ 649 var monthDiff = 6; 650 651 $(".datepicker input").attr("autocomplete", "off"); 652 var bt = document.getElementById('submitPodFormBtn'); 653 var podToDate = $("#podToDate").val(); 654 var podFromDate = $("#podFromDate").val(); 655 656 if(Date.parse(podFromDate) > Date.parse(podToDate)) { 657 $("#podToDateLessErrors").html("Please note that the To Date precedes the From Date in y
657our search"); 658 $("#podToDateLessErrors").fadeIn(); 659 $("#initialPodDateMessage").fadeOut(); 660 bt.disabled = true; 661 } else{ 662 var optionStatus = getOtherSearchOptionsStatus(); 663 $("#submitPodFormBtn").attr("disabled", (optionStatus || false)); 664 665 var monthMaxPast = ($('#lastMonthsMaxDisplay').val() == null ? 18 : parseInt($('#lastMonthsMaxDisplay').val())); 666 var todayDate = new Date(); 667 var monthRemovedDate = new Date(todayDate.setMonth(todayDate.getMonth()-monthMaxPast)); 668 var maxPastDate = new Date(monthRemovedDate.setTime(monthRemovedDate.getTime() - (24*60*60*1000))); 669 var datePodFrom = new Date(podFromDate); 670 671 if (datePodFrom.getTime() < maxPastDate.getTime()) { 672 $("#podToDateLessErrors").html('Date range is restricted to the last ' + monthMaxPast + ' months.'); 673 $("#podToDateLessErrors").fadeIn(); 674 $("#initialPodDateMessage").fadeOut(); 675 bt.disabled = true; 676 } else if((podToDate != previousPodToDate)) { 677 $("#podToDateLessErrors").fadeOut(); 678 $("#initialPodDateMessage").fadeIn(); 679 previousPodToDate=podToDate; 680 var date1=new Date(podFromDate); 681 var date2=new Date(podToDate); 682 var diffMinToDate = new Date(date2.setMonth(date2.getMonth()-monthDiff)); 683 var minPastToDate = new Date(diffMinToDate.setTime(diffMinToDate.getTime())); 684 685 if (date1.getTime() < minPastToDate.getTime()) { 686 $("#initialPodDateMessage").addClass("error"); 687 bt.disabled = true; 688 }else { 689 $("#initialPodDateMessage").removeClass("error"); 690 bt.disabled = (getOtherSearchOptionsStatus() || false); 691 } 692 693 } else if((podFromDate != previousPodFromDate) ){ 694 $("#podToDateLessErrors").fadeOut(); 695 $("#initialPodDateMessage").fadeIn(); 696 var date1From=new Date(podFromDate); 697 var date2To=new Date(previousPodToDate); 698 var date1_from = date1From.getTime(); 699 var date2_to = date2To.getTime(); 700 var diffMinDate = new Date(date2To.setMonth(date2To.getMonth()-monthDiff)); 701 var minPastDate = new Date(diffMinDate.setTime(diffMinDate.getTime())); 702 703 if (date1From.getTime() < minPastDate.getTime()) { 704 $("#initialPodDateMessage").addClass("error"); 705 bt.disabled = true; 706 } else { 707 $("#initialPodDateMessage").removeClass("error"); 708 bt.disabled = (getOtherSearchOptionsStatus() || false); 709 } 710 } else{ 711 $("#submitPodFormBtn").attr("disabled", false); 712 $("#initialPodDateMessage").removeClass("error"); 713 } 714 } 715}); 716 717var previousInvoiceToDate = $("#invoiceToDate").val(); 718var previousInvoiceFromDate = $("#invoiceFromDate").val(); 719 720$(".datepicker input").on("change", function (){ 721 var monthDiff = 6; 722 $(".datepicker input").attr("autocomplete", "off"); 723 var bt = document.getElementById('submitInvoiceFormBtn'); 724 var invoiceToDate = $("#invoiceToDate").val(); 725 var invoiceFromDate = $("#invoiceFromDate").val(); 726 727 if(Date.parse(invoiceFromDate) > Date.parse(invoiceToDate)) { 728 $("#invoiceToLessDateErrors").html("Please note that the To Date precedes the From Date in your search"); 729 $("#invoiceToLessDateErrors").fadeIn(); 730 $("#invoiceFromDateErrors").fadeOut(); 731 $("#invoiceToDateErrors").fadeOut(); 732 $("#initialInvoiceDateMessage").fadeOut(); 733 bt.disabled = true; 734 } else{ 735 $("#submitInvoiceFormBtn").attr("disabled", false); 736 $("#invoiceFromDateErrors").fadeOut(); 737 $("#invoiceToDateErrors").fadeOut(); 738 $("#invoiceToLessDateErrors").fadeOut(); 739 $("#initialInvoiceDateMessage").fadeIn(); 740 } 741 742 var monthMaxPast = ($('#lastMonthsMaxDisplay').val() == null ? 18 : parseInt($('#lastMonthsMaxDisplay').val())); 743 var todayDate = new Date(); 744 var monthRemovedDate = new Date(todayDate.setMonth(todayDate.getMonth()-monthMaxPast)); 745 var maxPastDate = new Date(monthRemovedDate.setTime(monthRemovedDate.getTime() - (24*60*60*1000))); 746 var dateInvoiceFrom = new Date(invoiceFromDate); 747 748 if (dateInvoiceFrom.getTime() < maxPastDate.getTime()) { 749 $("#invoiceFromDateErrors").html('Date range is restricted to the last ' + monthMaxPast + ' months.'); 750 $("#invoiceFromDateErrors").fadeIn(); 751 bt.disabled = true; 752 $("#invoiceFromDateErrors").fadeOut(); 753 $("#invoiceToLessDateErrors").fadeOut(); 754 $("#initialInvoiceDateMessage").fadeOut(); 755 } else if((invoiceToDate != previousInvoiceToDate)) { 756 previousInvoiceToDate = invoiceToDate; 757 var date1=new Date(invoiceFromDate); 758 var date2=new Date(invoiceToDate); 759 var diffMinToDate = new Date(date2.setMonth(date2.getMonth()-monthDiff)); 760 var minPastToDate = new Date(diffMinToDate.setTime(diffMinToDate.getTime())); 761 762 if (date1.getTime() < minPastToDate.getTime()) { 763 764 $("#invoiceToDateErrors").html("Please note that the To Date cannot exceed more than " + monthDiff + " months in time-frame from the From Date for any period you intend to search"); 765 $("#invoiceToDateErrors").fadeIn(); 766 bt.disabled = true; 767 $("#invoiceFromDateErrors").fadeOut(); 768 $("#invoiceToLessDateErrors").fadeOut(); 769 $("#initialInvoiceDateMessage").fadeOut(); 770 } 771 772 }else if((invoiceFromDate != previousInvoiceFromDate) ){ 773 var date1From=new Date(invoiceFromDate); 774 var date2To=new Date(previousInvoiceToDate); 775 var diffMinDate = new Date(date1From.setMonth(date1From.getMonth()-monthDiff)); 776 var minPastDate = new Date(diffMinDate.setTime(diffMinDate.getTime())); 777 778 if (date1From.getTime() < minPastDate.getTime()) { 779 780 $("#invoiceFromDateErrors").html("Please note that the From Date cannot exceed more than " + monthDiff + " months in time-frame from the To Date for any period you intend to search"); 781 $("#invoiceFromDateErrors").fadeIn(); 782 $("#invoiceToLessDateErrors").fadeOut(); 783 bt.disabled = true; 784 $("#initialInvoiceDateMessage").fadeOut(); 785 } 786 } 787 else{ 788 $("#submitInvoiceFormBtn").attr("disabled", false); 789 $("#invoiceFromDateErrors").fadeOut(); 790 $("#invoiceToDateErrors").fadeOut(); 791 $("#invoiceToLessDateErrors").fadeOut(); 792 $("#initialInvoiceDateMessage").fadeIn(); 793 } 794}); 795 796function beforeShowDataPicker(dataPicker) { 797 798 dataPicker.datepicker({ 799 beforeShow: function (input, inst) { 800 setTimeout(function () { 801 inst.dpDiv.css({ 802 top: dataPicker.offset().top + 35, 803 left: dataPicker.offset().left 804 }); 805 }, 0); 806 } 807 }); 808}; 809$(document).ready(function () { 810 $(".pod-other-search-field").change(function(){ 811 if($($(".pod-other-search-field")[0]).val() === $($(".pod-other-search-field")[1]).val() && 812 $($(".pod-other-search-field")[0]).val() !== '') { 813 $("#podOtherSearchLessErrors").html("The search selections cannot be the same"); 814 $("#podOtherSearchLessErrors").fadeIn(); 815 $("#initialPodOtherMessage").fadeOut(); 816 document.getElementById('submitPodFormBtn').disabled = true; 817 } else { 818 var dateStatus = getDateStatus(); 819 $("#submitPodFormBtn").attr("disabled", (dateStatus || false)); 820 $("#podOtherSearchLessErrors").fadeOut(); 821 $("#initialPodOtherMessage").fadeIn(); 822 } 823 }); 824 825 $(".js-pod-print-button").click(function(){ 826 window.print(); 827 }); 828 829}); 830 831function getOtherSearchOptionsStatus(){ 832 return $($(".pod-other-search-field")[0]).val() === $($(".pod-other-search-field")[1]).val() && 833 $($(".pod-other-search-field")[0]).val() !== '' ; 834} 835 836function getDateStatus(){ 837 var podToDate = $("#podToDate").val(); 838 var podFromDate = $("#podFromDate").val(); 839 return Date.parse(podFromDate) > Date.parse(podToDate); 840} 841 842$(document).ready(function(){ 843 $(".datepicker input").attr("autocomplete", "off"); 844 845 var todayDate = new Date(); 846 var monthMaxPast = ($('#lastMonthsMaxDisplay').val() == null ? 18 : parseInt($('#lastMonthsMaxDisplay').val())); 847 var maxPastDate = new Date(todayDate.setMonth(todayDate.getMonth()-monthMaxPast)); 848 849 $("#podFromDate").datepicker(({ minDate: maxPastDate })); 850 $("#podToDate").datepicker(({ minDate: maxPastDate })); 851 852 var invoiceFromDate = $("#invoiceFromDate"); 853 invoiceFromDate.datepicker("option", { 854 minDate: maxPastDate, 855 orientation: 'bottom', 856 beforeShow: beforeShowDataPicker(invoiceFromDate) 857 }); 858 859 var invoiceToDate = $("#invoiceToDate"); 860 invoiceToDate.datepicker("option", { 861 minDate: maxPastDate, 862 orientation: 'bottom', 863 beforeShow: beforeShowDataPicker(invoiceToDate) 864 }); 865 866 $("#invoice_from_date_icon").click(function() { 867 $("#invoiceFromDate").datepicker("show"); 868 }); 869 870 $("#invoice_to_date_icon").click(function() { 871 $("#invoiceToDate").datepicker("show"); 872 }); 873 874 var invoiceFromDueDate = $("#invoiceFromDueDate"); 875 $('#invoiceFromDueDate').datepicker("option", { 876 minDate: maxPastDate, 877 orientation: 'bottom', 878 beforeShow: beforeShowDataPicker(invoiceFromDueDate) 879 }); 880 881 var invoiceToDueDate = $("#invoiceToDueDate"); 882 $('#invoiceToDueDate').datepicker("option", { 883 minDate: maxPastDate, 884 orientation: 'bottom', 885 beforeShow: beforeShowDataPicker(invoiceToDueDate) 886 }); 887 888 $("#invoice_from_due_date_icon").click(function() { 889 $("#invoiceFromDueDate").datepicker("show"); 890 }); 891 892 $("#invoice_to_due_date_icon").click(function() { 893 $("#invoiceToDueDate").datepicker("show"); 894 }); 895 896 $(document).on("change", '#proofOfDeliveryHistorySearchFormId #selectSoldTo select', function () { 897 $("#proofOfDeliveryHistorySearchFormId #pod\\.payer").empty(); 898 displayPayerBySoldTo($(this).val(), "proofOfDeliveryHistorySearchFormId"); 899 $("#proofOfDeliveryHistorySearchFormId #pod\\.user").empty(); 900 displayUserBySoldTo($(this).val(), "proofOfDeliveryHistorySearchFormId"); 901 }); 902 903 function displayPayerBySoldTo(soldToCode, owner) { 904 $("#" + owner + " #pod\\.payer").empty(); 905 $("#" + owner + " #pod\\.payer").append($("<option></option>") 906 .attr("value", "ALL").text("ALL")); 907 908 $("#" + owner + " #inactivePayer").empty(); 909 $("#" + owner + " #inactivePayer").append($("<option></option>") 910 .attr("value", "ALL").text("ALL")); 911
912 // Do not call filterPayers if the soldToCode is empty (not chosen) 913 if ((soldToCode == null) || (soldToCode == "") || (soldToCode == "ALL")) { 914 $("#" + owner + " #pod\\.payer").enable(); 915 $("#" + owner + " #inactivePayer").enable(); 916 return; 917 } 918 919 $.ajax({ 920 type: 'GET', 921 url: ACC.config.encodedContextPath + "/my-account-api/getPayerDetails", 922 dataType: "json", 923 data: {'b2bUnitCode': soldToCode}, 924 success: function (response) { 925 926 $.each(response, function (key, value) { 927 $("#" + owner + " #pod\\.payer").append($("<option></option>") 928 .attr("value", value.id) 929 .text(value.companyName)) 930 }); 931 // Enables the select box after the result have been added 932 $("#" + owner + " #pod\\.payer").enable(); 933 }, 934 error: function (xhr, ajaxOptions, thrownError) { 935 if (xhr.status == 404) { 936 alert(thrownError); 937 } 938 $("#" + owner + " #pod\\.payer").enable(); 939 } 940 }); 941 942 $.ajax({ 943 type: 'GET', 944 url: ACC.config.encodedContextPath + "/my-account-api/getInactivePayerDetails", 945 dataType: "json", 946 data: {'b2bUnitCode': soldToCode}, 947 success: function (response) { 948 949 $.each(response, function (key, value) { 950 $("#" + owner + " #inactivePayer").append($("<option></option>") 951 .attr("value", value.id) 952 .text(value.companyName)) 953 }); 954 // Enables the select box after the result have been added 955 $("#" + owner + " #inactivePayer").enable(); 956 }, 957 error: function (xhr, ajaxOptions, thrownError) { 958 if (xhr.status == 404) { 959 alert(thrownError); 960 } 961 $("#" + owner + " #inactivePayer").enable(); 962 } 963 }); 964 965 } 966 function displayUserBySoldTo(soldToCode, owner) { 967 $("#" + owner + " #pod\\.user").empty(); 968 $("#" + owner + " #pod\\.user").append($("<option></option>") 969 .attr("value", "ALL").text("ALL")); 970 971 // Do not call filterPayers if the soldToCode is empty (not chosen) 972 if ((soldToCode == null) || (soldToCode == "") || (soldToCode == "ALL")) { 973 $("#" + owner + " #pod\\.user").enable(); 974 return; 975 } 976 977 $.ajax({ 978 type: 'GET', 979 url: ACC.config.encodedContextPath + "/my-account/getCustomerDetails", 980 dataType: "json", 981 data: {'b2bUnitCode': soldToCode}, 982 success: function (response) { 983 984 $.each(response, function (key, value) { 985 $("#" + owner + " #pod\\.user").append($("<option></option>") 986 .attr("value", value.uid) 987 .text(value.firstName + " " + value.lastName)) 988 }); 989 }, 990 error: function (xhr, ajaxOptions, thrownError) { 991 if (xhr.status == 404) { 992 alert(thrownError); 993 } 994 $("#" + owner + " #pod\\.user").enable(); 995 } 996 }); 997 } 998 999}); 1000 1001$(document).on("click", '#clearPodFormBtn', function () { 1002 window.location.replace(ACC.config.encodedContextPath + '/my-account/proofOfDelivery?showSearchOptions=true'); 1003}); 1004 1005$(document).on("click", '#clearFormBtnUsers', function () { 1006 window.location.replace(ACC.config.encodedContextPath + '/my-company/organization-management/manage-users'); 1007 1008}); 1009 1010$(document).ready(function(){ 1011 1012 $(".unitsdiv input[type='checkbox'][name='unitsData']").on('click',function(e){ 1013 1014 if($(e.target).is(":checked")){ 1015 1016 $(e.target).parent().find('.payersdiv').show(); 1017 $(e.target).parent().find('.payersdiv').find('.errormsg').hide(); 1018 $(e.target).parent().find('.payersdiv').find("input[type='checkbox']").prop('checked', true); 1019 1020 } 1021 1022 else { 1023 $(e.target).parent().find('.payersdiv').hide(); 1024 $(e.target).parent().find('.payersdiv').find("input[type='checkbox']").prop('checked', false); 1025 1026 } 1027 1028 }) 1029 1030 $(".all").on('click',function(e){ 1031 if($(e.target).is(":checked")){ 1032 $(e.target).parent().find("input[type='checkbox']").prop('checked', true); 1033 } 1034 else { 1035 $(e.target).parent().find("input[type='checkbox']").prop('checked', false); 1036 } 1037 }); 1038 1039 $(".payersdiv input[type='checkbox']").on("click",function(e){ 1040 var ele=$(this); 1041 if(ele.hasClass('all')){ 1042 if(ele.is(":checked")){ 1043 ele.parent().find('.errormsg').hide(); 1044 ele.parent().find("input[type='checkbox']").prop('checked', true); 1045 } 1046 else { 1047 ele.parent().find('.errormsg').show(); 1048 ele.parent().find("input[type='checkbox']").prop('checked', false); 1049 } 1050 }else{ 1051 ele.parent().find("input.all").prop('checked', checkStatus(ele.parent())); 1052 if(checkErrorStatus(ele.parent())){ 1053 ele.parent().find('.errormsg').hide(); 1054 }else{ 1055 ele.parent().find('.errormsg').show(); 1056 } 1057 } 1058 }); 1059 1060 function checkErrorStatus(ele){ 1061 var elements=$(ele).find("input[type='checkbox']"); 1062 var checkErrorStatus=false; 1063 for (var i = 0; i < elements.length; i++) { 1064 if(!$(elements[i]).hasClass('all')){ 1065 if($(elements[i]).is(":checked")){ 1066 checkErrorStatus=true; 1067 break; 1068 } 1069 } 1070 } 1071 return checkErrorStatus; 1072 } 1073 1074 function checkStatus(ele){ 1075 var elements=$(ele).find("input[type='checkbox']"); 1076 var checkedStatus=true; 1077 for (var i = 0; i < elements.length; i++) { 1078 if(!$(elements[i]).hasClass('all')){ 1079 if(!$(elements[i]).is(":checked")){ 1080 checkedStatus=false; 1081 break; 1082 } 1083 } 1084 } 1085 return checkedStatus; 1086 } 1087 1088 // Tooltip for QuestionMark icons. 1089 tippy('.payment-admin-tooltip', { 1090 content(reference) { 1091 const id = reference.getAttribute('data-template'); 1092 const template = document.getElementById(id); 1093 return template.innerHTML; 1094 }, 1095 arrow: true, 1096 animation: 'scale', 1097 placement: 'right-start', 1098 showtitle: false, 1099 allowHTML: true, 1100 theme: 'paymentadmin' 1101 }); 1102 1103 tippy('.payment-admin-tooltip-mob', { 1104 content(reference) { 1105 const id = reference.getAttribute('data-template'); 1106 const template = document.getElementById(id); 1107 return template.innerHTML; 1108 },
1109 arrow: false, 1110 animation: 'scale', 1111 placement: 'bottom', 1112 showtitle: false, 1113 allowHTML: true, 1114 theme: 'paymentadmin', 1115 trigger: 'click', 1116 maxWidth: 'none' 1117 }); 1118}); 1119 1120 1121 1122$(document).ready(function(){ 1123 $(".paymentOrder #card_cardType option[value='024']").remove(); 1124 $('#search_form').on('submit', function(e) { 1125 e.preventDefault(); 1126 productSearch(); 1127 return false; 1128 }); 1129}); 1130 1131$('#search_button').click(productSearch); 1132 1133function productSearch() { 1134 var searchKeyword = ""; 1135 var userDeviceIsMobile = $('#js-site-search-input').is(":visible") ? false : true; 1136 if(userDeviceIsMobile) 1137 searchKeyword = $('.show-search-box-mobile #js-site-search-input').val(); 1138 else 1139 searchKeyword = $("#js-site-search-input").val(); 1140 1141 if(searchKeyword.replace(/\s/g,"") != "") 1142 window.location = ACC.config.encodedContextPath + "/search?q="+encodeURIComponent(searchKeyword.toLowerCase())+"%3Arelevance%3AallCategories%3A"+$("#categoryCode option:selected" ).val(); 1143} 1144 1145$(".use-address").click(function() { 1146 var $row = $(this).closest("tr"); // Find the row 1147 var $text = $row.find(".firstName").text(); // Find the text 1148}); 1149 1150
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.