1$(function() { 2 $('.orderby').change(function() { 3 searchProduct() 4 }); 5 6}); 7$(function () { 8 $(document).scroll(function () { 9 var $nav = $(".km-navbar"); 10 $nav.toggleClass('scrolled', $(this).scrollTop() > $nav.height()); 11 }); 12 }); 13$(document).ready(function() { 14 15 /*slim scroll*/ 16 $('.scrollingDivContent').slimScroll({ 17 alwaysVisible: true, 18 //height:'280px', 19 display: 'block' 20 }); 21 22 /*$(".product-covered .nav-tabs li a").click(function(){ 23 var slimscrollHeight = $(".tab-pane.active .slimScrollBar").css( "height" ); 24 alert(slimscrollHeight); 25 });*/ 26 27 28 29 $('.activeProDiv').click(function() { 30 //alert($(this).attr('id')); 31 var actTab = $(this).attr('id'); 32 // alert(actTab); 33 // alert("sd"); 34 var slimscrollHeight = $(".tab-pane.active .slimScrollBar").css("height"); 35 36 37 38 //alert(slimscrollHeight); 39 $('#testDiv_' + actTab).slimScroll({ 40 alwaysVisible: true, 41 height: '320px', 42 display: 'block' 43 }); 44 }); 45 46 /*change heart icon effect*/ 47 // $('.hearticon-change').hover(function() { 48 // $(this).toggleClass( 49 // ($(this).hasClass('far') ? 'fas' : '') + 50 // '', 51 // 200 52 // ); 53 // }); 54 55 56 $('#selProductSrch').multiselect({ 57 enableClickableOptGroups: true, 58 enableCollapsibleOptGroups: true, 59 maxHeight: 200, 60 nonSelectedText: 'Select Product', 61 enableCaseInsensitiveFiltering: true, 62 filterPlaceholder: 'Search Here...', 63 includeSelectAllOption: true, 64 numberDisplayed: 1, 65 }); 66 67 $('#selMarketSrch').multiselect({ 68 enableClickableOptGroups: true, 69 maxHeight: 200, 70 nonSelectedText: 'Select Market', 71 enableCaseInsensitiveFiltering: true, 72 filterPlaceholder: 'Search Here...', 73 includeSelectAllOption: true, 74 numberDisplayed: 1 75 }); 76 77 $('#selTermsSrch').multiselect({ 78 includeSelectAllOption: true, 79 maxHeight: 200, 80 nonSelectedText: 'Select Term', 81 enableCaseInsensitiveFiltering: true, 82 filterPlaceholder: 'Search Here...', 83 numberDisplayed: 1 84 }); 85 86 $('#selProductComp').multiselect({ 87 enableCollapsibleOptGroups: true, 88 enableClickableOptGroups: true, 89 maxHeight: 200, 90 nonSelectedText: 'Select Product', 91 enableCaseInsensitiveFiltering: true, 92 filterPlaceholder: 'Search Here...', 93 includeSelectAllOption: true, 94 numberDisplayed: 1 95 }); 96 97 $('#selMarketComp').multiselect({ 98 enableClickableOptGroups: true, 99 maxHeight: 200, 100 nonSelectedText: 'Select Market', 101 enableCaseInsensitiveFiltering: true, 102 filterPlaceholder: 'Search Here...', 103 includeSelectAllOption: true, 104 numberDisplayed: 1 105 }); 106 107 $('#selTermsComp').multiselect({ 108 includeSelectAllOption: true, 109 maxHeight: 200, 110 nonSelectedText: 'Select Term', 111 enableCaseInsensitiveFiltering: true, 112 filterPlaceholder: 'Search Here...', 113 includeSelectAllOption: true, 114 numberDisplayed: 1 115 }); 116 117 118 119 120 121 122 123 // $("#divDailyMarket .multiselect-search").keyup(function(){ 124 // //alert(this.value+'<==>'+this.value.length); 125 // if(this.value.length>0){ 126 // $("#divDailyMarket li.multiselect-all label.checkbox").hide(); 127 // }else{ 128 // $("#divDailyMarket li.multiselect-all label.checkbox").show(); 129 // } 130 // }); 131 132 // $("#divDailyTerms .multiselect-search").keyup(function(){ 133 // //alert(this.value+'<==>'+this.value.length); 134 // if(this.value.length>0){ 135 // $("#divDailyTerms li.multiselect-all label.checkbox").hide(); 136 // }else{ 137 // $("#divDailyTerms li.multiselect-all label.checkbox").show(); 138 // } 139 // }); 140 141 // $("#divDailyProductComp .multiselect-search").keyup(function(){ 142 // //alert(this.value+'<==>'+this.value.length); 143 // if(this.value.length>0){ 144 // $("#divDailyProductComp li.multiselect-all label.checkbox").hide(); 145 // }else{ 146 // $("#divDailyProductComp li.multiselect-all label.checkbox").show(); 147 // } 148 // }); 149 150 // $("#divDailyMarketComp .multiselect-search").keyup(function(){ 151 // //alert(this.value+'<==>'+this.value.length); 152 // if(this.value.length>0){ 153 // $("#divDailyMarketComp li.multiselect-all label.checkbox").hide(); 154 // }else{ 155 // $("#divDailyMarketComp li.multiselect-all label.checkbox").show(); 156 // } 157 // }); 158 159 // $("#divDailyTermsComp .multiselect-search").keyup(function(){ 160 // //alert(this.value+'<==>'+this.value.length); 161 // if(this.value.length>0){ 162 // $("#divDailyTermsComp li.multiselect-all label.checkbox").hide(); 163 // }else{ 164 // $("#divDailyTermsComp li.multiselect-all label.checkbox").show(); 165 // } 166 // }); 167 168 $('.multiselect-search').keyup(function() { 169 $('.multiselect-search').each(function() { 170 if (this.value.length > 0) { 171 $(this).parent().parent().next().hide(); 172 } else { 173 $(this).parent().parent().next().show(); 174 } 175 }); 176 }); 177}); 178 179 180 181// $(document).on("click", function(event){ 182// var $trigger = $(".marketplace-filter-list-wrap .dropdown-menu"); 183 184// if($trigger !== event.target && !$trigger.has(event.target).length){ 185// $(".marketplace-filter-list-wrap .dropdown-menu").slideUp("fast"); 186// } 187// }); 188 189// $(document).ready(function(){ 190// $(".marketplace-filter-list-wrap .dropdown-menu").click(function(){ 191// $(".marketplace-filter-list-wrap .dropdown-menu").removeClass("show"); 192// $(this).addClass("show"); 193// }); 194 195// }); 196 197 198 199function isNumber(evt) { 200 evt = (evt) ? evt : window.event;
201 var charCode = (evt.which) ? evt.which : evt.keyCode; 202 if (charCode > 31 && (charCode < 48 || charCode > 57)) { 203 return false; 204 } 205 return true; 206} 207 208function onlyLetter(evt) { 209 evt = (evt) ? evt : window.event; 210 var regex = new RegExp("^[a-zA-Z ]+$"); 211 var key = String.fromCharCode(!evt.charCode ? evt.which : evt.charCode); 212 if (!regex.test(key)) { 213 evt.preventDefault(); 214 return false; 215 } 216 return true; 217} 218 219$('#txtFrgtPassEmailId').keypress(function(event) { 220 221 var keycode = (event.keyCode ? event.keyCode : event.which); 222 if (keycode == '13') { 223 showLoginDiv(); 224 return false; 225 } 226 227}); 228 229$('#loginEmailId').keypress(function(event) { 230 231 var keycode = (event.keyCode ? event.keyCode : event.which); 232 if (keycode == '13') { 233 checkLogin(); 234 return false; 235 } 236 237}); 238 239$('#loginPassword').keypress(function(event) { 240 241 var keycode = (event.keyCode ? event.keyCode : event.which); 242 if (keycode == '13') { 243 checkLogin(); 244 return false; 245 } 246 247}); 248 249function showForgotPassDiv(i) { 250 if (i == 1) { 251 $("#dvLogin").hide(); 252 $("#dvForgotPass").show(); 253 } else { 254 $("#dvLogin").show(); 255 $("#dvForgotPass").hide(); 256 } 257} 258 259function showLoginDiv() { 260 var forgotPassVal = $("#txtFrgtPassEmailId").val(); 261 //alert("forgotPass==>"+forgotPassVal); 262 if (forgotPassVal != '') { 263 $.ajax({ 264 url: '/wp-admin/admin-ajax.php', 265 type: "POST", 266 data: { 267 action: 'forgotPassword', 268 forgotPassVal: forgotPassVal, 269 }, 270 beforeSend: function (xhr) { 271 $(".km-loader-parent").css('display', 'flex'); 272 }, 273 success: function (data) { 274 $(".km-loader-parent").hide(); 275 //console.log(data.data); 276 if (data.data != "" && typeof data.data !== 'undefined') { 277 var chkFlag = data.data.split('@'); 278 if (chkFlag[1] == '0') { 279 toastr.error(chkFlag[0]); 280 } else { 281 toastr.success(chkFlag[0]); 282 $("#continueLogin").show(); 283 } 284 } 285 } 286 }); 287 } else { 288 toastr.error('Please enter email Id'); 289 $("#dvLogin").hide(); 290 $("#dvForgotPass").show(); 291 } 292} 293 294function checkLogin() { 295 var domain_url = $("#domain_url").val(); 296 var emailId = $("#loginEmailId").val(); 297 var passwordV = $("#loginPassword").val(); 298 //alert("domain_url=>"+domain_url); 299 if (emailId == '') { 300 toastr.error('Please enter email Id'); 301 return false; 302 } 303 if (passwordV == '') { 304 toastr.error('Please enter password'); 305 return false; 306 } 307 if (emailId != "" && passwordV != "") { 308 $.ajax({ 309 url: '/wp-admin/admin-ajax.php', 310 type: "POST", 311 data: { 312 action: 'validateLogin', 313 emailIdVal: emailId, 314 passwordVal: passwordV 315 }, 316 beforeSend: function (xhr) { 317 $(".km-loader-parent").css('display', 'flex'); 318 }, 319 success: function (data) { 320 $(".km-loader-parent").hide(); 321 console.log(data); 322 if (data.data[0] != "" && typeof data.data[0] !== 'undefined') { 323 //if(emailId == '[email protected]' && data.data[0].status == 'Approved'){ 324 if (emailId == '[email protected]') { 325 window.location = domain_url + "/mis/index.php"; 326 //}else if(emailId != '[email protected]' && data.data[0].status == 'Approved'){ 327 // } else if (emailId != '[email protected]' && data.data[0].is_redirect_price==0) { 328 } 329 //else if(data.data[0].status == 'N') 330 // toastr.error('User is registered but not verified. <br>Please verify to login'); 331 else if (data.data[0].status == 'Error') { 332 toastr.error('Invalid User'); 333 }else{ 334 window.location = domain_url + "/myaccount/mi-dashboard/"; 335 // } else if (emailId != '[email protected]' && data.data[0].is_redirect_price==1) { 336 // window.location = domain_url + "/pricing-plan/"; 337 } 338 } else { 339 toastr.error('Invalid User'); 340 } 341 } 342 }); 343 } 344} 345 346 347//$('#regSubmit').click(function(){ 348function registerUser() { 349 //return true; 350 var assets_url = $("#assets_url").val(); 351 352 var fName = $("#txtFirstName").val(); 353 var lName = $("#txtLastName").val(); 354 var is_trial = $("#is_trial").val(); 355 var uName = fName + " " + lName; 356 //alert("uName=>"+uName); 357 var emailId = $("#txtEmailId").val(); 358 var passwordV = $("#txtPassword").val(); 359 var cnfPassword = $("#txtConfPassword").val(); 360 var countryName = iti.selectedCountryData['name']; 361 var newsletter = ''; //$("#txtNewsletter").val(); 362 var newsletter = $("#txtNewsletter").prop("checked") == true ? 'Y' : 'N'; 363 364 var companyName = $("#txtCompanyName").val(); 365 var mobile = $("#txtMobile").val(); 366 var selInterest = $("#selInterest").val(); 367 // var gCaptcha = $("#g-recaptcha-response").val(); 368 var imgCaptcha = $("#txtImageCaptcha").val(); 369 370 371 var txtJobTitle = $("#txtJobTitle").val(); 372 var primaryRole = $("#primaryRole").val();
373 var user_type = $("#user_type").prop("checked") == true ? "shop_manager" : "customer"; 374 var nature_of_business = $("#nature_of_business").val(); 375 var employee_size = $("#employee_size").val(); 376 var product_services = ""; 377 var product_services_buy = ""; 378 var where_ref = $("#where_ref").val(); 379 var where_ref_other = $("#where_ref_other").val(); 380 var sustainable_practices = $("#sustainable_practices").val(); 381 var plan_selected = 1; 382 //alert("gCaptcha=>"+gCaptcha); 383 384 385 if (newsletter == '') { 386 newsletter = 'N'; 387 } 388 // if(gCaptcha != ""){ 389 390 $.ajax({ 391 url: '/wp-admin/admin-ajax.php', 392 type: "POST", 393 data: { 394 action: 'registerUser', 395 uName: uName, 396 passwordV: passwordV, 397 cnfPassword: cnfPassword, 398 emailId: emailId, 399 mobile: mobile, 400 newsletter: newsletter, 401 companyName: companyName, 402 countryName: countryName, 403 selInterest: selInterest, 404 imgCaptcha: imgCaptcha, 405 txtJobTitle: txtJobTitle, 406 primaryRole: primaryRole, 407 user_type: user_type, 408 nature_of_business: nature_of_business, 409 employee_size: employee_size, 410 product_services: product_services, 411 product_services_buy: product_services_buy, 412 sustainable_practices: sustainable_practices, 413 plan_selected: plan_selected, 414 where_ref: where_ref, 415 where_ref_other: where_ref_other, 416 is_trial: is_trial 417 }, 418 beforeSend: function (xhr) { 419 $(".km-loader-parent").css('display', 'flex'); 420 }, 421 success: function (data) { 422 $(".km-loader-parent").hide(); 423 if (data.data == 'Y') { 424 $("#reg_div_3").show(); 425 $("#reg_div_1").hide(); 426 $("#otp_div").hide(); 427 $("#reg_div").hide(); 428 $("#reg_div_2").hide(); 429 // if (plan_selected == 1 || plan_selected == 3) 430 // $("#displayMsg").html("Registration successfull."); 431 // else { 432 // window.location = "https://www.yarnsandfibers.com/service-plan-subscribe/?planId=18643"; 433 // } 434 $("#txtFirstName").val(''); 435 $("#txtLastName").val(''); 436 $("#txtEmailId").val(''); 437 $("#txtPassword").val(''); 438 $("#txtConfPassword").val(''); 439 $("#selCountry").val(''); 440 $("#txtNewsletter").val(''); 441 $("#txtCompanyName").val(''); 442 $("#txtMobile").val(''); 443 $("#selInterest").val(''); 444 $("#txtImageCaptcha").val(''); 445 446 } else { 447 $("#displayMsg").html(data.data); 448 } 449 450 451 } 452 }); 453 // }else{ 454 // alert("Please validate Captcha"); 455 // } 456} 457 458 459function getProdSubCat(mainCatVal) { 460 var mainCatV = mainCatVal.split('@@@@'); 461 var mainCatId = mainCatV[0]; 462 // alert("mainCatId=>"+mainCatId); 463 $.ajax({ 464 url: '/wp-admin/admin-ajax.php', 465 type: "POST", 466 data: { 467 action: 'getProdSubCat', 468 mainCatId: mainCatId, 469 }, 470 success: function(data) { 471 // console.log(data.data); 472 $("#proSubCat option").remove(); 473 $("#proSubCat").append('<option value="">Select Sub Category</option>'); 474 for (i = 0; i < data.data.length; i++) { 475 $("#proSubCat").append('<option value="' + data.data[i].srno + '@@@@' + data.data[i].name + '">' + data.data[i].name + '</option>'); 476 } 477 } 478 }); 479} 480 481function getProduct(subCatVal) { 482 var mainCatVal = $("#proMainCat").val(); 483 var mainCatV = mainCatVal.split('@@@@'); 484 var mainCatId = mainCatV[0]; 485 486 var subCatV = subCatVal.split('@@@@'); 487 var subCatId = subCatV[0]; 488 489 //alert("subCatId=>"+subCatId+"<=mainCatId=>"+mainCatId); 490 $.ajax({ 491 url: '/wp-admin/admin-ajax.php', 492 type: "POST", 493 data: { 494 action: 'getProduct', 495 mainCatId: mainCatId, 496 subCatId: subCatId, 497 }, 498 success: function(data) { 499 //console.log(data.data); 500 $("#product option").remove(); 501 $("#product").append('<option value="">Select Product</option>'); 502 for (i = 0; i < data.data.length; i++) { 503 $("#product").append('<option value="' + data.data[i].srno + '@@@@' + data.data[i].name + '">' + data.data[i].name + '</option>'); 504 } 505 } 506 }); 507} 508 509function getProductData(productId) { 510 var assets_url = $("#assets_url").val(); 511 var mainCatVal = $("#proMainCat").val(); 512 var mainCatV = mainCatVal.split('@@@@'); 513 var mainCatId = mainCatV[0]; 514 var feature1 = ""; 515 var feature2 = ""; 516 var feature3 = ""; 517 518 divselectimage = "divselectimage"; 519 uploadimage = "uploadimage"; 520 521 522 if (mainCatId == 1) { 523 524 var dyesAndChemType = JSON.parse(dyesAndChemTypeVal); 525 var selDyesAndChemType = $("<select></select>").attr("id", "dyesAndChemType").attr("name", "dyesAndChemType"); 526 selDyesAndChemType.append($("<option></option>").attr("value", "").text("Select Type")); 527 $.each(dyesAndChemType, function(index, json) { 528 selDyesAndChemType.append($("<option></option>").attr("value", json).text(json)); 529 }); 530 feature1 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Type</label><div id="tddyesAndChemType"></div></div></div>'; 531 feature1 = feature1 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Purity</label><input type="text" id="txtdychPurity" name="txtdychPurity" class="form-control news-sub-input" placeholder="Type here"></div></div>'; 532 feature2 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Product Image</label>'; 533 534 feature2 = feature2 + '<div class="register-rdio-btn"><ul class="mp-add-product"><li>'; 535 feature2 = feature2 + "<label class='custom-radio-btn-wrap radio-inline'>"; 536 feature2 = feature2 + "<input type='radio' value='simage' name='selectimage' id='radio' onclick='selectImageDis(" + divselectimage + ");'>"; 537 feature2 = feature2 + '<span class="radio-circle"></span><span class="radio-title">Select Image</span></label></li><li>'; 538 feature2 = feature2 + "<label class='custom-radio-btn-wrap radio-inline'>"; 539 feature2 = feature2 + "<input type='radio' value='uimage' name='selectimage' id='radio2' onclick='selectImageDis(" + uploadimage + ");'>"; 540 feature2 = feature2 + '<span class="radio-circle"></span><span class="radio-title">Upload Image</span></label></li></ul></div></div></div>'; 541 542 feature2 = feature2 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Select Image</label>'; 543 feature2 = feature2 + '<div align="left" id="divselectimage" style="display:none">'; 544 feature2 = feature2 + '<table border="0" cellpadding="0" cellspacing="0">'; 545 feature2 = feature2 + '<tr><td><input type="hidden" name="imageid" id="imageid" />'; 546 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/dyes/1.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(1);" id="prodimage1"/>'; 547 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/dyes/2.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(2);" id="prodimage2"/>'; 548 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/dyes/3.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(3);" id="prodimage3"/>'; 549 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/dyes/4.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(4);" id="prodimage4"/>
549<br />'; 550 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/dyes/5.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(5);" id="prodimage5"/>'; 551 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/dyes/6.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(6);" id="prodimage6"/>'; 552 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/dyes/7.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(7);" id="prodimage7"/>'; 553 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/dyes/8.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(8);" id="prodimage8"/>'; 554 feature2 = feature2 + '</td></tr></table></div>'; 555 feature2 = feature2 + '<div align="left" id="uploadimage" style="display:none">'; 556 feature2 = feature2 + '<table border="0" cellpadding="0" cellspacing="0">'; 557 feature2 = feature2 + '<tr><td class="verdana11pxbodytext"><input name="txtProductImage" type="file" class="registration_textfield" id="txtProductImage"/>'; 558 feature2 = feature2 + '<p class="input-message">size max (77x77) 256KB allowed</p></td></tr></table></div></div></div>'; 559 560 $("#feature1").html(feature1); 561 $("#feature2").html(feature2);
562 $("#tddyesAndChemType").html(selDyesAndChemType); 563 564 } else if (mainCatId == 2) { 565 566 var fabricPattern = JSON.parse(fabricPatternVal); 567 var selFabricPattern = $("<select></select>").attr("id", "fabricPattern").attr("name", "fabricPattern"); 568 selFabricPattern.append($("<option></option>").attr("value", "").text("Select Pattern")); 569 $.each(fabricPattern, function(index, json) { 570 selFabricPattern.append($("<option></option>").attr("value", json).text(json)); 571 }); 572 573 var fabricStyle = JSON.parse(fabricStyleVal); 574 var selFabricStyleVal = $("<select></select>").attr("id", "fabricStyle").attr("name", "fabricStyle"); 575 selFabricStyleVal.append($("<option></option>").attr("value", "").text("Select Style")); 576 $.each(fabricStyle, function(index, json) { 577 selFabricStyleVal.append($("<option></option>").attr("value", json).text(json)); 578 }); 579 580 var fabricEndUse = JSON.parse(fabricEndUseVal); 581 var selfabricEndUseVal = $("<select></select>").attr("id", "fabricEndUse").attr("name", "fabricEndUse"); 582 selfabricEndUseVal.append($("<option></option>").attr("value", "").text("Select End Use")); 583 $.each(fabricEndUse, function(index, json) { 584 selfabricEndUseVal.append($("<option></option>").attr("value", json).text(json)); 585 }); 586 587 var fabricWidth = JSON.parse(fabricWidthVal); 588 var selfabricWidthVal = $("<select></select>").attr("id", "fabricWidth").attr("name", "fabricWidth"); 589 selfabricWidthVal.append($("<option></option>").attr("value", "").text("Select Width")); 590 $.each(fabricWidth, function(index, json) { 591 selfabricWidthVal.append($("<option></option>").attr("value", json).text(json)); 592 }); 593 594 feature1 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Pattern</label><div id="tdfabricPattern"></div></div></div>'; 595 feature1 = feature1 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Style</label><div id="tdfabricStyle"></div></div></div>'; 596 feature1 = feature1 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">End Use</label><div id="tdfabricEndUse"></div></div></div>'; 597 feature2 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Yarn Count</label><input type="text" id="txtFabricyarnCnt" name="txtFabricyarnCnt" class="form-control news-sub-input" placeholder="Type here"></div></div>'; 598 feature2 = feature2 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Density</label><input type="text" id="txtFabricDensity" name="txtFabricDensity" class="form-control news-sub-input" placeholder="Type here"></div></div>'; 599 feature2 = feature2 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Width</label><div id="tdfabricWidth"></div></div></div>'; 600 feature3 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Weight</label><input type="text" id="txtFabricWeight" name="txtFabricWeight" class="form-control news-sub-input" placeholder="Type here"></div></div>'; 601 feature3 = feature3 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Product Image</label>'; 602 feature3 = feature3 + '<div class="register-rdio-btn"><ul class="mp-add-product"><li>'; 603 feature3 = feature3 + "<label class='custom-radio-btn-wrap radio-inline'>"; 604 feature3 = feature3 + "<input type='radio' value='simage' name='selectimage' id='radio' onclick='selectImageDis(" + divselectimage + ");'>"; 605 feature3 = feature3 + '<span class="radio-circle"></span><span class="radio-title">Select Image</span></label></li><li>'; 606 feature3 = feature3 + "<label class='custom-radio-btn-wrap radio-inline'>"; 607 feature3 = feature3 + "<input type='radio' value='uimage' name='selectimage' id='radio2' onclick='selectImageDis(" + uploadimage + ");'>"; 608 feature3 = feature3 + '<span class="radio-circle"></span><span class="radio-title">Upload Image</span></label></li></ul></div></div></div>'; 609 feature3 = feature3 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Select Image</label>'; 610 feature3 = feature3 + '<div align="left" id="divselectimage" style="display:none">'; 611 feature3 = feature3 + '<table border="0" cellpadding="0" cellspacing="0">'; 612 feature3 = feature3 + '<tr><td><input type="hidden" name="imageid" id="imageid" />'; 613 feature3 = feature3 + '<img src="' + assets_url + 'images/product_images/fabrics/1.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(1);" id="prodimage1"/>'; 614 feature3 = feature3 + '<img src="' + assets_url + 'images/product_images/fabrics/2.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(2);" id="prodimage2"/>'; 615 feature3 = feature3 + '<img src="' + assets_url + 'images/product_images/fabrics/3.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(3);" id="prodimage3"/>'; 616 feature3 = feature3 + '<img src="' + assets_url + 'images/product_images/fabrics/4.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(4);" id="prodimage4"/>
616<br />'; 617 feature3 = feature3 + '<img src="' + assets_url + 'images/product_images/fabrics/5.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(5);" id="prodimage5"/>'; 618 feature3 = feature3 + '<img src="' + assets_url + 'images/product_images/fabrics/6.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(6);" id="prodimage6"/>'; 619 feature3 = feature3 + '<img src="' + assets_url + 'images/product_images/fabrics/7.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(7);" id="prodimage7"/>'; 620 feature3 = feature3 + '<img src="' + assets_url + 'images/product_images/fabrics/8.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(8);" id="prodimage8"/>'; 621 feature3 = feature3 + '</td></tr></table></div>'; 622 feature3 = feature3 + '<div align="left" id="uploadimage" style="display:none">'; 623 feature3 = feature3 + '<table border="0" cellpadding="0" cellspacing="0">'; 624 feature3 = feature3 + '<tr><td class="verdana11pxbodytext"><input name="txtProductImage" type="file" class="registration_textfield" id="txtProductImage"/>'; 625 feature3 = feature3 + '<p class="input-message">size max (77x77) 256KB allowed</p></td></tr></table></div></div></div>'; 626 $("#feature1").html(feature1); 627 $("#feature2").html(feature2); 628 $("#feature3").html(feature3); 629 $("#tdfabricPattern").html(selFabricPattern); 630 $("#tdfabricStyle").html(selFabricStyleVal); 631 $("#tdfabricEndUse").html(selfabricEndUseVal); 632 $("#tdfabricWidth").html(selfabricWidthVal); 633 634 } else if (mainCatId == 3) { 635 636 var fiberPattern = JSON.parse(fiberPatternVal); 637 var selfiberPatternVal = $("<select></select>").attr("id", "fiberPattern").attr("name", "fiberPattern"); 638 selfiberPatternVal.append($("<option></option>").attr("value", "").text("Select Pattern")); 639 $.each(fiberPattern, function(index, json) { 640 selfiberPatternVal.append($("<option></option>").attr("value", json).text(json)); 641 }); 642 643 var fiberFeature = JSON.parse(fiberFeatureVal); 644 var selfiberFeatureVal = $("<select></select>").attr("id", "fiberFeature").attr("name", "fiberFeature"); 645 selfiberFeatureVal.append($("<option></option>").attr("value", "").text("Select Feature")); 646 $.each(fiberFeature, function(index, json) { 647 selfiberFeatureVal.append($("<option></option>").attr("value", json).text(json)); 648 }); 649 650 feature1 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Pattern</label><div id="tdfiberPattern"></div></div></div>'; 651 feature1 = feature1 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Feature</label><div id="tdFiberFeature"></div></div></div>'; 652 feature2 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Product Image</label>'; 653 feature2 = feature2 + '<div class="register-rdio-btn"><ul class="mp-add-product"><li>'; 654 feature2 = feature2 + "<label class='custom-radio-btn-wrap radio-inline'>"; 655 feature2 = feature2 + "<input type='radio' value='simage' name='selectimage' id='radio' onclick='selectImageDis(" + divselectimage + ");'>"; 656 feature2 = feature2 + '<span class="radio-circle"></span><span class="radio-title">Select Image</span></label></li><li>'; 657 feature2 = feature2 + "<label class='custom-radio-btn-wrap radio-inline'>"; 658 feature2 = feature2 + "<input type='radio' value='uimage' name='selectimage' id='radio2' onclick='selectImageDis(" + uploadimage + ");'>"; 659 feature2 = feature2 + '<span class="radio-circle"></span><span class="radio-title">Upload Image</span></label></li></ul></div></div></div>'; 660 661 feature2 = feature2 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Select Image</label>'; 662 feature2 = feature2 + '<div align="left" id="divselectimage" style="display:none">'; 663 feature2 = feature2 + '<table border="0" cellpadding="0" cellspacing="0">'; 664 feature2 = feature2 + '<tr><td><input type="hidden" name="imageid" id="imageid" />'; 665 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/fibers/1.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(1);" id="prodimage1"/>'; 666 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/fibers/2.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(2);" id="prodimage2"/>'; 667 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/fibers/3.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(3);" id="prodimage3"/>'; 668 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/fibers/4.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(4);" id="prodimage4"/>
668<br />'; 669 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/fibers/5.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(5);" id="prodimage5"/>'; 670 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/fibers/6.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(6);" id="prodimage6"/>'; 671 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/fibers/7.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(7);" id="prodimage7"/>'; 672 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/fibers/8.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(8);" id="prodimage8"/>'; 673 feature2 = feature2 + '</td></tr></table></div>'; 674 feature2 = feature2 + '<div align="left" id="uploadimage" style="display:none">'; 675 feature2 = feature2 + '<table border="0" cellpadding="0" cellspacing="0">'; 676 feature2 = feature2 + '<tr><td class="verdana11pxbodytext"><input name="txtProductImage" type="file" class="registration_textfield" id="txtProductImage"/>'; 677 feature2 = feature2 + '<p class="input-message">size max (77x77) 256KB allowed</p></td></tr></table></div></div></div>'; 678 $("#feature1").html(feature1); 679 $("#feature2").html(feature2); 680 $("#tdfiberPattern").html(selfiberPatternVal); 681 $("#tdFiberFeature").html(selfiberFeatureVal); 682 683 } else if (mainCatId == 4) { 684 685 feature1 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Product Image</label>'; 686 feature1 = feature1 + '<div class="register-rdio-btn"><ul class="mp-add-product"><li>'; 687 feature1 = feature1 + "<label class='custom-radio-btn-wrap radio-inline'>"; 688 feature1 = feature1 + "<input type='radio' value='simage' name='selectimage' id='radio' onclick='selectImageDis(" + divselectimage + ");'>"; 689 feature1 = feature1 + '<span class="radio-circle"></span><span class="radio-title">Select Image</span></label></li><li>'; 690 feature1 = feature1 + "<label class='custom-radio-btn-wrap radio-inline'>"; 691 feature1 = feature1 + "<input type='radio' value='uimage' name='selectimage' id='radio2' onclick='selectImageDis(" + uploadimage + ");'>"; 692 feature1 = feature1 + '<span class="radio-circle"></span><span class="radio-title">Upload Image</span></label></li></ul></div></div></div>'; 693 694 feature1 = feature1 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Select Image</label>'; 695 feature1 = feature1 + '<div align="left" id="divselectimage" style="display:none">'; 696 feature1 = feature1 + '<table border="0" cellpadding="0" cellspacing="0">'; 697 feature1 = feature1 + '<tr><td><input type="hidden" name="imageid" id="imageid" />'; 698 feature1 = feature1 + '<img src="' + assets_url + 'images/product_images/fabrics/1.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(1);" id="prodimage1"/>'; 699 feature1 = feature1 + '<img src="' + assets_url + 'images/product_images/fabrics/2.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(2);" id="prodimage2"/>'; 700 feature1 = feature1 + '<img src="' + assets_url + 'images/product_images/fabrics/3.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(3);" id="prodimage3"/>'; 701 feature1 = feature1 + '<img src="' + assets_url + 'images/product_images/fabrics/4.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(4);" id="prodimage4"/><br />'; 702 feature1 = feature1 + '<img src="' + assets_url + 'images/product_images/fabrics/5.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(5);" id="prodimage5"/>'; 703 feature1 = feature1 + '<img src="' + assets_url + 'images/product_images/fabrics/6.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(6);" id="prodimage6"/>'; 704 feature1 = feature1 + '<img src="' + assets_url + 'images/product_images/fabrics/7.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(7);" id="prodimage7"/>'; 705 feature1 = feature1 + '<img src="' + assets_url + 'images/product_images/fabrics/8.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(8);" id="prodimage8"/>'; 706 feature1 = feature1 + '</td></tr></table></div>'; 707 feature1 = feature1 + '<div align="left" id="uploadimage" style="display:none">'; 708 feature1 = feature1 + '<table border="0" cellpadding="0" cellspacing="0">'; 709 feature1 = feature1 + '<tr><td class="verdana11pxbodytext">
709<input name="txtProductImage" type="file" class="registration_textfield" id="txtProductImage"/>'; 710 feature1 = feature1 + '<p class="input-message">size max (77x77) 256KB allowed</p></td></tr></table></div></div></div>'; 711 $("#feature1").html(feature1); 712 713 } else if (mainCatId == 5) { 714 715 feature1 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Brand Name</label><input type="text" id="txtMachineBrandName" name="txtMachineBrandName" class="form-control news-sub-input" placeholder="Type here"></div></div>'; 716 feature1 = feature1 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Model No</label><input type="text" id="txtMachineModel" name="txtMachineModel" class="form-control news-sub-input" placeholder="Type here"></div></div>'; 717 feature2 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Product Image</label>'; 718 feature2 = feature2 + '<div class="register-rdio-btn"><ul class="mp-add-product"><li>'; 719 feature2 = feature2 + "<label class='custom-radio-btn-wrap radio-inline'>"; 720 feature2 = feature2 + "<input type='radio' value='simage' name='selectimage' id='radio' onclick='selectImageDis(" + divselectimage + ");'>"; 721 feature2 = feature2 + '<span class="radio-circle"></span><span class="radio-title">Select Image</span></label></li><li>'; 722 feature2 = feature2 + "<label class='custom-radio-btn-wrap radio-inline'>"; 723 feature2 = feature2 + "<input type='radio' value='uimage' name='selectimage' id='radio2' onclick='selectImageDis(" + uploadimage + ");'>"; 724 feature2 = feature2 + '<span class="radio-circle"></span><span class="radio-title">Upload Image</span></label></li></ul></div></div></div>'; 725 726 feature2 = feature2 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Select Image</label>'; 727 feature2 = feature2 + '<div align="left" id="divselectimage" style="display:none">'; 728 feature2 = feature2 + '<table border="0" cellpadding="0" cellspacing="0">'; 729 feature2 = feature2 + '<tr><td><input type="hidden" name="imageid" id="imageid" />'; 730 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/machinery/1.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(1);" id="prodimage1"/>'; 731 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/machinery/2.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(2);" id="prodimage2"/>'; 732 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/machinery/3.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(3);" id="prodimage3"/>'; 733 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/machinery/4.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(4);" id="prodimage4"/><br />'; 734 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/machinery/5.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(5);" id="prodimage5"/>'; 735 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/machinery/6.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(6);" id="prodimage6"/>'; 736 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/machinery/7.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(7);" id="prodimage7"/>'; 737 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/machinery/8.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(8);" id="prodimage8"/>'; 738 feature2 = feature2 + '</td></tr></table></div>'; 739 feature2 = feature2 + '<div align="left" id="uploadimage" style="display:none">'; 740 feature2 = feature2 + '<table border="0" cellpadding="0" cellspacing="0">'; 741 feature2 = feature2 + '<tr><td class="verdana11pxbodytext"><input name="txtProductImage" type="file" class="registration_textfield" id="txtProductImage"/>'; 742 feature2 = feature2 + '<p class="input-message">size max (77x77) 256KB allowed</p></td></tr></table></div></div></div>'; 743 $("#feature1").html(feature1); 744 $("#feature2").html(feature2); 745 746 } else if (mainCatId == 6) { 747 748 $('.newlyAdded').remove(); 749 var yarnPattern = JSON.parse(yarnPatternVal); 750 var selyarnPattern = $("<select></select>").attr("id", "yarnPattern").attr("name", "yarnPattern"); 751 selyarnPattern.append($("<option></option>").attr("value", "").text("Select Pattern")); 752 $.each(yarnPattern, function(index, json) { 753 selyarnPattern.append($("<option></option>").attr("value", json).text(json)); 754 }); 755 756 var yarnEndUse = JSON.parse(yarnEndUseVal); 757 var selyarnEndUseVal = $("<select></select>").attr("id", "yarnEndUse").attr("name", "yarnEndUse"); 758 selyarnEndUseVal.append($("<option></option>").attr("value", "").text("Select End Use")); 759 $.each(yarnEndUse, function(index, json) { 760 selyarnEndUseVal.append($("<option></option>").attr("value", json).text(json)); 761 }); 762 763 var yarnFeature = JSON.parse(yarnFeatureVal); 764 var selyarnFeatureVal = $("<select></select>").attr("id", "yarnFeature").attr("name", "yarnFeature"); 765 selyarnFeatureVal.append($("<option></option>").attr("value", "").text("Select Feature")); 766 $.each(yarnFeature, function(index, json) { 767 selyarnFeatureVal.append($("<option></option>").attr("value", json).text(json)); 768 }); 769 770 feature1 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Pattern</label><div id="tdYarnPattern"></div></div></div>'; 771 feature1 = feature1 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">End Use</label><div id="tdYarnEndUse"></div></div></div>'; 772 feature1 = feature1 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Feature</label><div id="tdYarnFeature"></div></div></div>'; 773 feature2 = '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Product Image</label>'; 774 feature2 = feature2 + '<div class="register-rdio-btn"><ul class="mp-add-product"><li>'; 775 feature2 = feature2 + "<label class='custom-radio-btn-wrap radio-inline'>"; 776 feature2 = feature2 + "<input type='radio' value='simage' name='selectimage' id='radio' onclick='selectImageDis(" + divselectimage + ");'>"; 777 feature2 = feature2 + '<span class="radio-circle"></span><span class="radio-title">Select Image</span></label></li><li>'; 778 feature2 = feature2 + "<label class='custom-radio-btn-wrap radio-inline'>"; 779 feature2 = feature2 + "<input type='radio' value='uimage' name='selectimage' id='radio2' onclick='selectImageDis(" + uploadimage + ");'>"; 780 feature2 = feature2 + '<span class="radio-circle"></span><span class="radio-title">Upload Image</span></label></li></ul></div></div></div>'; 781 782 feature2 = feature2 + '<div class="col-12 col-sm-4 mb-3"><div class="form-group"><label class="cust-form-label">Select Image</label>'; 783 feature2 = feature2 + '<div align="left" id="divselectimage" style="display:none">'; 784 feature2 = feature2 + '<table border="0" cellpadding="0" cellspacing="0">'; 785 feature2 = feature2 + '<tr><td><input type="hidden" name="imageid" id="imageid" />'; 786 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/yarn/1.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(1);" id="prodimage1"/>'; 787 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/yarn/2.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(2);" id="prodimage2"/>'; 788 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/yarn/3.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(3);" id="prodimage3"/>'; 789 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/yarn/4.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(4);" id="prodimage4"/>
789<br />'; 790 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/yarn/5.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(5);" id="prodimage5"/>'; 791 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/yarn/6.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(6);" id="prodimage6"/>'; 792 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/yarn/7.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(7);" id="prodimage7"/>'; 793 feature2 = feature2 + '<img src="' + assets_url + 'images/product_images/yarn/8.jpg" width="82" height="82" class="lightbox" onclick="setSelectedImage(8);" id="prodimage8"/>'; 794 feature2 = feature2 + '</td></tr></table></div>'; 795 feature2 = feature2 + '<div align="left" id="uploadimage" style="display:none">'; 796 feature2 = feature2 + '<table border="0" cellpadding="0" cellspacing="0">'; 797 feature2 = feature2 + '<tr><td class="verdana11pxbodytext"><input name="txtProductImage" type="file" class="registration_textfield" id="txtProductImage"/>'; 798 feature2 = feature2 + '<p class="input-message">size max (77x77) 256KB allowed</p></td></tr></table></div></div></div>'; 799 800 $("#feature1").html(feature1); 801 $("#feature2").html(feature2); 802 $("#tdYarnPattern").html(selyarnPattern); 803 $("#tdYarnEndUse").html(selyarnEndUseVal); 804 $("#tdYarnFeature").html(selyarnFeatureVal); 805 806 } 807 808} 809 810 811function editProductDetails(txtVal) { 812 813 $("#display" + txtVal).hide(); 814 $("#edit" + txtVal).show(); 815} 816 817function saveProductDetails(txtVal) { 818 // alert("Clicked"); 819 var productId = $("#txtProductId").val(); 820 var imageId = $("#imageid").val(); 821 var newVal = $("#val" + txtVal).val(); 822 if (!txtVal.includes('Image')) { 823 $.ajax({ 824 url: '/wp-admin/admin-ajax.php', 825 type: "POST", 826 data: { 827 action: 'editProductDetails', 828 valueChange: txtVal, 829 newValue: newVal, 830 productId: productId, 831 imageId: imageId, 832 }, 833 success: function(html) { 834 //console.log(html.data); 835 if (html.data != 'Error') { 836 $("#display" + txtVal).show(); 837 $("#edit" + txtVal).hide(); 838 $("#display" + txtVal).html(newVal); 839 } else { 840 alert("Error"); 841 } 842 } 843 }); 844 } else { 845 alert("In else=>" + newVal); 846 //$('body').on('change', '#val'+txtVal, function() { 847 } 848 849} 850 851$(document).on('click', '.uploadProImg', function(e) { 852 var product_image_url = $("#product_image_url").val(); 853 var productId = $("#txtProductId").val(); 854 var newVal = $('#valImage').val(); 855 var imageid = $('#imageid').val(); 856 var imageFldr = $('#imageFldr').val(); 857 var file_data = ""; 858 //alert("imageid=>"+imageid+"<=imageFldr=>"+imageFldr+"<=productId=>"+productId); 859 if (imageid == "") { 860 file_data = $('#valImage').prop('files')[0]; 861 } 862 863 864 var form_data = new FormData(); 865 form_data.append('file', file_data); 866 form_data.append('action', 'editProductDetails'); 867 form_data.append('valueChange', 'Image'); 868 form_data.append('newValue', newVal); 869 form_data.append('productId', productId); 870 form_data.append('imageFldr', imageFldr); 871 form_data.append('imageid', imageid); 872 873 $.ajax({ 874 url: '/wp-admin/admin-ajax.php', 875 type: 'POST', 876 contentType: false, 877 processData: false, 878 data: form_data, 879 success: function(response) { 880 $("#displayImage").show(); 881 $("#editImage").hide(); 882 if (file_data != "") { 883 //alert("file_data=>"+product_image_url+response.data); 884 $("#showProImage").attr("src", product_image_url + response.data); 885 } else { 886 //alert("FileName=>"+product_image_url+imageFldr+response.data) 887 $("#showProImage").attr("src", product_image_url + response.data); 888 } 889 $("#divselectimage").show(); 890 $("#changeImage").hide(); 891 892 893 } 894 }); 895}); 896 897function selectImageDis(imageType) { 898 //alert("imageType=>"+imageType); 899 if (imageType == "divselectimage") { 900 $("#divselectimage").show(); 901 $("#uploadimage").hide(); 902 $("#changeImage").show(); 903 904 } else { 905 $("#divselectimage").hide(); 906 $("#uploadimage").show(); 907 $("#changeImage").show(); 908 } 909} 910 911function setSelectedImage(imageId) { 912 $("#imageid").val(imageId); 913 $("img.selectProImg").removeClass("selectProImg"); 914 $("#prodimage" + imageId).addClass("selectProImg"); 915} 916 917function seePreviewProduct() { 918 // alert('Clieck'); 919 var assets_url = $("#assets_url").val(); 920 921 var productTitle = $('#productTitle').val(); 922 923 if ($('#proMainCat').val() != '') { 924 var proMainCatVal = $('#proMainCat').val().split('@@@@'); 925 var proMainCatId = proMainCatVal[0]; 926 var proMainCatName = proMainCatVal[1]; 927 } else { 928 var proMainCatId = ''; 929 var proMainCatName = ''; 930 } 931 if ($('#proSubCat').val() != '') { 932 var proSubCatVal = $('#proSubCat').val().split('@@@@'); 933 var proSubCatId = proSubCatVal[0]; 934 var proSubCatName = proSubCatVal[1]; 935 } else { 936 var proSubCatId = ''; 937 var proSubCatName = ''; 938 } 939 940 if ($('#product').val() != '') { 941 var productVal = $('#product').val().split('@@@@'); 942 var productId = productVal[0]; 943 var productName = productVal[1]; 944 } else { 945 var productId = ''; 946 var productName = ''; 947 } 948 949 950 var productFor = $("input[name='product-type']:checked").val(); //$('input[name=product-type]').val(); 951 952 var selectedImage = $("#imageid").val(); 953 var upLoadedImage = $("#txtProductImage").val(); 954 955 var productDesc = $('#proDesc').val(); 956 var sellingType = $('#selType').val(); 957 var selCountry = $('#selCountry').val(); 958 var selImagePath = ''; 959 if (typeof productFor === 'undefined') { 960 $("#dvError").html("Please select if you're a buyer or a seller"); 961 return false;
962 } 963 if (productTitle == '') { 964 $("#dvError").html("Please enter product title"); 965 return false; 966 } 967 if (proMainCatId == '') { 968 $("#dvError").html("Please select product category"); 969 return false; 970 } 971 if (proSubCatId == '') { 972 $("#dvError").html("Please select product sub category"); 973 return false; 974 } 975 if (productId == '') { 976 $("#dvError").html("Please select product"); 977 return false; 978 } 979 if (sellingType == '') { 980 $("#dvError").html("Please select selling type"); 981 return false; 982 } 983 if (selCountry == '') { 984 $("#dvError").html("Please select place of origin"); 985 return false; 986 } 987 if (proMainCatId == 1) { 988 989 var productType = $('#dyesAndChemType').val(); 990 var productPurity = $('#txtdychPurity').val(); 991 selImagePath = assets_url + 'images/product_images/dyes/' + selectedImage + '.jpg'; 992 if (productType == '') { 993 $("#dvError").html("Please select product type"); 994 return false; 995 } 996 if (productPurity == '') { 997 $("#dvError").html("Please enter product purity"); 998 return false; 999 } 1000 1001 } else if (proMainCatId == 2) { 1002 1003 var productPattern = $('#fabricPattern').val(); 1004 var productStyle = $('#fabricStyle').val(); 1005 var productEndUse = $('#fabricEndUse').val(); 1006 var productYarnCnt = $('#txtFabricyarnCnt').val(); 1007 var productDensity = $('#txtFabricDensity').val(); 1008 var productWidth = $('#fabricWidth').val(); 1009 var productWeight = $('#txtFabricWeight').val(); 1010 selImagePath = assets_url + 'images/product_images/fabrics/' + selectedImage + '.jpg'; 1011 if (productPattern == '') { 1012 $("#dvError").html("Please select product pattern"); 1013 return false; 1014 } 1015 if (productStyle == '') { 1016 $("#dvError").html("Please select product style"); 1017 return false; 1018 } 1019 if (productEndUse == '') { 1020 $("#dvError").html("Please select product end use"); 1021 return false; 1022 } 1023 if (productYarnCnt == '') { 1024 $("#dvError").html("Please enter product yarn count"); 1025 return false; 1026 } 1027 if (productDensity == '') { 1028 $("#dvError").html("Please enter product density"); 1029 return false; 1030 } 1031 if (productWidth == '') { 1032 $("#dvError").html("Please select product width"); 1033 return false; 1034 } 1035 if (productWeight == '') { 1036 $("#dvError").html("Please enter product weight"); 1037 return false; 1038 } 1039 1040 } else if (proMainCatId == 3) { 1041 1042 var productPattern = $('#fiberPattern').val(); 1043 var productFeature = $('#fiberFeature').val(); 1044 selImagePath = assets_url + 'images/product_images/fibers/' + selectedImage + '.jpg'; 1045 if (productPattern == '') { 1046 $("#dvError").html("Please select product pattern"); 1047 return false; 1048 } 1049 if (productFeature == '') { 1050 $("#dvError").html("Please select product feature"); 1051 return false; 1052 } 1053 1054 } else if (proMainCatId == 4) { 1055 1056 selImagePath = assets_url + 'images/product_images/fabrics/' + selectedImage + '.jpg'; 1057 1058 } else if (proMainCatId == 5) { 1059 1060 var productBrand = $('#txtMachineBrandName').val(); 1061 var productModel = $('#txtMachineModel').val(); 1062 selImagePath = assets_url + 'images/product_images/machinery/' + selectedImage + '.jpg'; 1063 if (productBrand == '') { 1064 $("#dvError").html("Please enter product brand"); 1065 return false; 1066 } 1067 if (productModel == '') { 1068 $("#dvError").html("Please enter product model"); 1069 return false; 1070 } 1071 1072 } else if (proMainCatId == 6) { 1073 1074 var productPattern = $('#yarnPattern').val(); 1075 var productEndUse = $('#yarnEndUse').val(); 1076 var productFeature = $('#yarnFeature').val(); 1077 selImagePath = assets_url + 'images/product_images/yarn/' + selectedImage + '.jpg'; 1078 if (productPattern == '') { 1079 $("#dvError").html("Please select product pattern"); 1080 return false;
1081 } 1082 if (productEndUse == '') { 1083 $("#dvError").html("Please select product end use"); 1084 return false; 1085 } 1086 if (productFeature == '') { 1087 $("#dvError").html("Please select product feature"); 1088 return false; 1089 } 1090 } 1091 if (typeof productPattern === 'undefined') { 1092 productPattern = 'N/A'; 1093 } 1094 if (typeof productFeature === 'undefined') { 1095 productFeature = 'N/A'; 1096 } 1097 if (typeof productType === 'undefined') { 1098 productType = 'N/A'; 1099 } 1100 if (typeof productEndUse === 'undefined') { 1101 productEndUse = 'N/A'; 1102 } 1103 1104 var today = new Date(); 1105 var toDayDate = pad(today.getDate(), 2) + '.' + pad((today.getMonth() + 1), 2) + '.' + today.getFullYear(); 1106 1107 var str = ''; 1108 str = str + '<div class="col-12 col-sm-6"><div class="row"><div class="col-12 col-sm-4"><div class="product-img-outer">'; 1109 str = str + '<div class="product-img"><img src="' + assets_url + '/images/yarns-product.jpg" id="showImage" class="img-fluid"></div>'; 1110 str = str + '<div class="product-desc"><div class="prod-y-title">' + productFor + '</div><div class="product-date">uploaded on:' + toDayDate + '</div>'; 1111 str = str + '</div></div></div><div class="col-12 col-sm-8"><div class="product-desc-outer"><div class="sub-title">'; 1112 str = str + '<span class="p-yello-title">' + productFor + '</span>' + productTitle + '(' + selCountry + ')'; 1113 //str = str + '<span class="edit-product-link "><a href="#" class="sub-title yellow-text">edit</a></span>'; 1114 str = str + '</div><div class="sub-div"><p><strong>' + proMainCatName + '</strong></p>'; 1115 str = str + '<p>' + proSubCatName + '</p></div>'; 1116 str = str + '<div class="sub-div"><ul><li><strong>pattern : </strong>' + productPattern + '</li><li><strong>features : </strong>' + productFeature + '</li>'; 1117 str = str + '<li><strong>type : </strong>' + productType + '</li><li><strong>end use : </strong>' + productEndUse + '</li></ul></div>'; 1118 str = str + '<div class="sub-div"><p><strong>product description : </strong>' + productDesc + '</p></div></div>'; 1119 str = str + '</div></div></div>'; 1120 1121 // alert("<=>"+selectedImage+"<=>"+upLoadedImage); 1122 if (selectedImage == "" && upLoadedImage == "") { 1123 $("#dvError").html("Please select or upload product image"); 1124 } else { 1125 $("#previewProduct").html(str); 1126 1127 if (upLoadedImage != '' && typeof upLoadedImage !== 'undefined') { 1128 var file = document.getElementById('txtProductImage').files[0]; 1129 1130 var reader = new FileReader(); 1131 reader.onloadend = function(e) { 1132 var img = new Image(); 1133 img.src = e.target.result; 1134 1135 img.onload = function() { 1136 var w = this.width; 1137 var h = this.height; 1138 //alert("Uploaded file Width & Height is "+h+" X "+w); 1139 // if(w>77 || h>77){ 1140 // alert("File Width & Height must be 1920 X 800."); 1141 // }else{ 1142 $("#showImage").attr("src", reader.result); 1143 // } 1144 } 1145 } 1146 if (file) { 1147 reader.readAsDataURL(file); 1148 } else { 1149 //alert("Please upload Image"); 1150 } 1151 1152 } else if (selImagePath != '') { 1153 $("#showImage").attr("src", selImagePath); 1154 } 1155 $("#product-preview").toggle(); 1156 } 1157 1158} 1159 1160$("#seePreviewBtn").click(function() { 1161 //alert('Clieck'); 1162 var assets_url = $("#assets_url").val(); 1163 1164 var productTitle = $('#productTitle').val(); 1165 1166 if ($('#proMainCat').val() != '') { 1167 var proMainCatVal = $('#proMainCat').val().split('@@@@'); 1168 var proMainCatId = proMainCatVal[0]; 1169 var proMainCatName = proMainCatVal[1]; 1170 } else { 1171 var proMainCatId = ''; 1172 var proMainCatName = ''; 1173 } 1174 if ($('#proSubCat').val() != '') { 1175 var proSubCatVal = $('#proSubCat').val().split('@@@@'); 1176 var proSubCatId = proSubCatVal[0]; 1177 var proSubCatName = proSubCatVal[1]; 1178 } else { 1179 var proSubCatId = ''; 1180 var proSubCatName = ''; 1181 } 1182 1183 if ($('#product').val() != '') { 1184 var productVal = $('#product').val().split('@@@@'); 1185 var productId = productVal[0]; 1186 var productName = productVal[1]; 1187 } else { 1188 var productId = ''; 1189 var productName = ''; 1190 } 1191 1192 1193 var productFor = $("input[name='product-type']:checked").val(); //$('input[name=product-type]').val(); 1194 1195 var selectedImage = $("#imageid").val(); 1196 var upLoadedImage = $("#txtProductImage").val(); 1197 1198 var productDesc = $('#proDesc').val(); 1199 var sellingType = $('#selType').val(); 1200 var selCountry = $('#selCountry').val(); 1201 var selImagePath = ''; 1202 if (typeof productFor === 'undefined') { 1203 $("#dvError").html("Please select if you're a buyer or a seller"); 1204 return false;
1205 } 1206 if (productTitle == '') { 1207 $("#dvError").html("Please enter Product Title"); 1208 return false; 1209 } 1210 if (proMainCatVal == '') { 1211 $("#dvError").html("Please select Product Category"); 1212 return false; 1213 } 1214 if (proSubCatVal == '') { 1215 $("#dvError").html("Please select Product Sub Category"); 1216 return false; 1217 } 1218 if (productVal == '') { 1219 $("#dvError").html("Please select Product"); 1220 return false; 1221 } 1222 if (sellingType == '') { 1223 $("#dvError").html("Please select Selling Type"); 1224 return false; 1225 } 1226 if (selCountry == '') { 1227 $("#dvError").html("Please select Place of Origin"); 1228 return false; 1229 } 1230 if (proMainCatId == 1) { 1231 1232 var productType = $('#dyesAndChemType').val(); 1233 var productPurity = $('#txtdychPurity').val(); 1234 selImagePath = assets_url + 'images/product_images/dyes/' + selectedImage + '.jpg'; 1235 if (productType == '') { 1236 $("#dvError").html("Please select Product Type"); 1237 return false; 1238 } 1239 if (productPurity == '') { 1240 $("#dvError").html("Please enter Product Purity"); 1241 return false; 1242 } 1243 1244 } else if (proMainCatId == 2) { 1245 1246 var productPattern = $('#fabricPattern').val(); 1247 var productStyle = $('#fabricStyle').val(); 1248 var productEndUse = $('#fabricEndUse').val(); 1249 var productYarnCnt = $('#txtFabricyarnCnt').val(); 1250 var productDensity = $('#txtFabricDensity').val(); 1251 var productWidth = $('#fabricWidth').val(); 1252 var productWeight = $('#txtFabricWeight').val(); 1253 selImagePath = assets_url + 'images/product_images/fabrics/' + selectedImage + '.jpg'; 1254 if (productPattern == '') { 1255 $("#dvError").html("Please select Product Pattern"); 1256 return false; 1257 } 1258 if (productStyle == '') { 1259 $("#dvError").html("Please select Product Style"); 1260 return false; 1261 } 1262 if (productEndUse == '') { 1263 $("#dvError").html("Please select Product End Use"); 1264 return false; 1265 } 1266 if (productYarnCnt == '') { 1267 $("#dvError").html("Please enter Product Yarn Count"); 1268 return false; 1269 } 1270 if (productDensity == '') { 1271 $("#dvError").html("Please enter Product Density"); 1272 return false; 1273 } 1274 if (productWidth == '') { 1275 $("#dvError").html("Please select Product Width"); 1276 return false; 1277 } 1278 if (productWeight == '') { 1279 $("#dvError").html("Please enter Product Weight"); 1280 return false; 1281 } 1282 1283 } else if (proMainCatId == 3) { 1284 1285 var productPattern = $('#fiberPattern').val(); 1286 var productFeature = $('#fiberFeature').val(); 1287 selImagePath = assets_url + 'images/product_images/fibers/' + selectedImage + '.jpg'; 1288 if (productPattern == '') { 1289 $("#dvError").html("Please select Product Pattern"); 1290 return false; 1291 } 1292 if (productFeature == '') { 1293 $("#dvError").html("Please select Product Feature"); 1294 return false; 1295 } 1296 1297 } else if (proMainCatId == 4) { 1298 1299 selImagePath = assets_url + 'images/product_images/fabrics/' + selectedImage + '.jpg'; 1300 1301 } else if (proMainCatId == 5) { 1302 1303 var productBrand = $('#txtMachineBrandName').val(); 1304 var productModel = $('#txtMachineModel').val(); 1305 selImagePath = assets_url + 'images/product_images/machinery/' + selectedImage + '.jpg'; 1306 if (productBrand == '') { 1307 $("#dvError").html("Please enter Product Brand"); 1308 return false; 1309 } 1310 if (productModel == '') { 1311 $("#dvError").html("Please enter Product Model"); 1312 return false; 1313 } 1314 1315 } else if (proMainCatId == 6) { 1316 1317 var productPattern = $('#yarnPattern').val(); 1318 var productEndUse = $('#yarnEndUse').val(); 1319 var productFeature = $('#yarnFeature').val(); 1320 selImagePath = assets_url + 'images/product_images/yarn/' + selectedImage + '.jpg'; 1321 if (productPattern == '') { 1322 $("#dvError").html("Please select Product Pattern"); 1323 return false;
1324 } 1325 if (productEndUse == '') { 1326 $("#dvError").html("Please select Product End Use"); 1327 return false; 1328 } 1329 if (productFeature == '') { 1330 $("#dvError").html("Please select Product Feature"); 1331 return false; 1332 } 1333 } 1334 if (typeof productPattern === 'undefined') { 1335 productPattern = 'N/A'; 1336 } 1337 if (typeof productFeature === 'undefined') { 1338 productFeature = 'N/A'; 1339 } 1340 if (typeof productType === 'undefined') { 1341 productType = 'N/A'; 1342 } 1343 if (typeof productEndUse === 'undefined') { 1344 productEndUse = 'N/A'; 1345 } 1346 1347 var today = new Date(); 1348 var toDayDate = pad(today.getDate(), 2) + '.' + pad((today.getMonth() + 1), 2) + '.' + today.getFullYear(); 1349 1350 var str = ''; 1351 str = str + '<div class="col-12 col-sm-6"><div class="row"><div class="col-12 col-sm-4"><div class="product-img-outer">'; 1352 str = str + '<div class="product-img"><img src="' + assets_url + '/images/yarns-product.jpg" id="showImage" class="img-fluid"></div>'; 1353 str = str + '<div class="product-desc"><div class="prod-y-title">' + productFor + '</div><div class="product-date">uploaded on:' + toDayDate + '</div>'; 1354 str = str + '</div></div></div><div class="col-12 col-sm-8"><div class="product-desc-outer"><div class="sub-title">'; 1355 str = str + '<span class="p-yello-title">' + productFor + '</span>' + productTitle + '(' + selCountry + ')'; 1356 //str = str + '<span class="edit-product-link "><a href="#" class="sub-title yellow-text">edit</a></span>'; 1357 str = str + '</div><div class="sub-div"><p><strong>' + proMainCatName + '</strong></p>'; 1358 str = str + '<p>' + proSubCatName + '</p></div>'; 1359 str = str + '<div class="sub-div"><ul><li><strong>pattern : </strong>' + productPattern + '</li><li><strong>features : </strong>' + productFeature + '</li>'; 1360 str = str + '<li><strong>type : </strong>' + productType + '</li><li><strong>end use : </strong>' + productEndUse + '</li></ul></div>'; 1361 str = str + '<div class="sub-div"><p><strong>product description : </strong>' + productDesc + '</p></div></div>'; 1362 str = str + '</div></div></div>'; 1363 1364 1365 $("#previewProduct").html(str); 1366 1367 if (upLoadedImage != '' && typeof upLoadedImage !== 'undefined') { 1368 var file = document.getElementById('txtProductImage').files[0]; 1369 1370 var reader = new FileReader(); 1371 reader.onloadend = function(e) { 1372 var img = new Image(); 1373 img.src = e.target.result; 1374 1375 img.onload = function() { 1376 var w = this.width; 1377 var h = this.height; 1378 //alert("Uploaded file Width & Height is "+h+" X "+w); 1379 // if(w>77 || h>77){ 1380 // alert("File Width & Height must be 1920 X 800."); 1381 // }else{ 1382 $("#showImage").attr("src", reader.result); 1383 // } 1384 } 1385 } 1386 if (file) { 1387 reader.readAsDataURL(file); 1388 } else { 1389 //alert("Please upload Image"); 1390 } 1391 1392 } else if (selImagePath != '') { 1393 $("#showImage").attr("src", selImagePath); 1394 } 1395 $("#product-preview").toggle(); 1396 1397}); 1398 1399function pad(str, max) { 1400 str = str.toString(); 1401 return str.length < max ? pad("0" + str, max) : str; 1402} 1403 1404function displayandhideproduct(j) { 1405 var assets_url = $("#assets_url").val(); 1406 if ($("#mainproduct_" + j).css("visibility") == "visible") { 1407 $("#mainproduct_" + j).hide(); 1408 $("#mainproduct_" + j).css("visibility", "hidden"); 1409 $("#productimage_" + j).attr("src", assets_url + '/images/plus.png') 1410 1411 1412 } else if ($("#mainproduct_" + j).css("visibility") == "hidden") { 1413 $("#mainproduct_" + j).show(); 1414 $("#mainproduct_" + j).css("visibility", "visible"); 1415 $("#productimage_" + j).attr("src", assets_url + '/images/minus.png'); 1416 } 1417} 1418 1419function getFreeReport() { 1420 1421 //alert("In Js"); 1422 var assets_url = $("#assets_url").val(); 1423 var custName = $("#nameFrEnqRpt").val(); 1424 var lastnameFrRpt = $("#lastnameFrEnqRpt").val(); 1425 var companyName = $("#companyFrEnqRpt").val(); 1426 var emailId = $("#emailFrEnqRpt").val(); 1427 var countryName = $("#selCountryFrEnqRpt").val(); 1428 var mobileNo = $("#mobileFrEnqRpt").val(); 1429 var reportType = $("#reportFrEnqRpt").val(); 1430 var imgCaptcha = $("#txtImageCaptchaRpt").val(); 1431 var enqVal = 'Y';
1432 // alert("imgCaptcha=>"+imgCaptcha); 1433 1434 if (reportType == '') { 1435 var browserURL = $("#reportFromEnqRpt").val(); 1436 var splitURL = browserURL.split('/'); 1437 if (splitURL[3] != '') 1438 reportType = splitURL[3]; 1439 else 1440 reportType = splitURL[2]; 1441 } 1442 if (custName == "") { 1443 $("#displayEnqMsgRpt").html("<lable style='color: red'>Please enter first name</label>"); 1444 return false; 1445 //alert("Please enter first Name"); 1446 } else if (lastnameFrRpt == "") { 1447 $("#displayEnqMsgRpt").html("<lable style='color: red'>Please enter last name</label>"); 1448 return false; 1449 //alert("Please enter last Name"); 1450 } else if (emailId == "" || !ValidateEmail(emailId)) { 1451 $("#displayEnqMsgRpt").html("<lable style='color: red'>Please enter valid email Id</label>"); 1452 return false; 1453 //alert("Please enter Email Id"); 1454 } else if (countryName == "") { 1455 $("#displayEnqMsgRpt").html("<lable style='color: red'>Please select country</label>"); 1456 return false; 1457 //alert("Please Select Country"); 1458 } else if (companyName == "") { 1459 $("#displayEnqMsgRpt").html("<lable style='color: red'>Please enter company name</label>"); 1460 return false; 1461 //alert("Please enter Company Name"); 1462 } else if (imgCaptcha == '') { 1463 $("#displayEnqMsgRpt").html("<lable style='color: red'>Please enter the Captcha Code</label>"); 1464 return false; 1465 //alert("Please enter Company Name"); 1466 } else { 1467 1468 $.ajax({ 1469 url: '/wp-admin/admin-ajax.php', 1470 type: "POST", 1471 data: { 1472 action: 'getFreeReport', 1473 custName: custName, 1474 lastname: lastnameFrRpt, 1475 companyName: companyName, 1476 emailId: emailId, 1477 countryName: countryName, 1478 mobileNo: mobileNo, 1479 reportType: reportType, 1480 imgCaptcha: imgCaptcha, 1481 enqVal: enqVal 1482 }, 1483 success: function(data) { 1484 //console.log(data.data); 1485 if (data.data == "Mail Sent") { 1486 $("#displayEnqMsgRpt").html("<lable style='color: green'>Thank You.</label>"); 1487 //alert("Sample Report will be mailed to you."); 1488 $("#nameFrEnqRpt").val(""); 1489 $("#lastnameFrEnqRpt").val(""); 1490 $("#companyFrEnqRpt").val(""); 1491 $("#emailFrEnqRpt").val(""); 1492 $("#selCountryFrEnqRpt").val(""); 1493 $("#mobileFrEnqRpt").val(""); 1494 $("#reportFrEnqRpt").val(""); 1495 $("#reportFromEnqRpt").val(""); 1496 $("#txtImageCaptchaRpt").val(""); 1497 1498 } else if (data.data == "Captcha Mismatch") { 1499 $("#displayEnqMsgRpt").html("<lable style='color: red'>Captcha Code not matching.</label>"); 1500 } else { 1501 $("#displayEnqMsgRpt").html("<lable style='color: red'>Facing some issues.</label>"); 1502 //alert("Facing some issues."); 1503 } 1504 1505 1506 } 1507 }); 1508 } 1509} 1510 1511 1512$(function() { 1513 $(".sampleFormModal").click(function() { 1514 //alert("Clicked"); 1515 var my_id_value = $(this).data('report-type'); 1516 //alert("Clicked=>"+my_id_value); 1517 $("#reportFrRpt").val(my_id_value); 1518 $("#reportFrEnqRpt").val(my_id_value); 1519 if (my_id_value == 'daily') { 1520 var setVal = '<h2 class="section-title mb-28 yellow-color">Ask For Free Trial</h2>'; 1521 $("#sampleFormTitle").html(setVal); 1522 } else { 1523 var setVal = '<h2 class="section-title mb-28 yellow-color">Ask For Free Sample Report</h2>'; 1524 $("#sampleFormTitle").html(setVal); 1525 } 1526 }) 1527}); 1528 1529function askForSampleReport() { 1530 var assets_url = $("#assets_url").val(); 1531 var custName = $("#nameFrRpt").val(); 1532 var companyName = $("#companyFrRpt").val(); 1533 var emailId = $("#emailFrRpt").val(); 1534 var countryName = $("#selCountryFrRpt").val(); 1535 var mobileNo = $("#mobileFrRpt").val(); 1536 var reportType = $("#reportFrRpt").val(); 1537 var domain_url = $("#domain_url").val(); 1538 var lastnameFrRpt = $('#lastnameFrRpt').val(); 1539 var gCaptcha = $("#g-recaptcha-response").val(); 1540 var imgCaptcha = $("#txtImageCaptcha").val(); 1541 //alert("gCaptcha new=>"+gCaptcha); 1542 1543 if (custName == "") { 1544 $("#displayMsgRpt").html("<lable style='color: red'>Please enter first name</label>"); 1545 //alert("Please enter first Name"); 1546 } else if (lastnameFrRpt == "") { 1547 $("#displayMsgRpt").html("<lable style='color: red'>Please enter last name</label>"); 1548 //alert("Please enter last Name"); 1549 } else if (emailId == "" || !ValidateEmail(emailId)) { 1550 $("#displayMsgRpt").html("<lable style='color: red'>Please enter valid email Id</label>"); 1551 //alert("Please enter Email Id"); 1552 } else if (countryName == "") { 1553 $("#displayMsgRpt").html("<lable style='color: red'>Please select country</label>"); 1554 //alert("Please Select Country"); 1555 } else if (companyName == "") { 1556 $("#displayMsgRpt").html("<lable style='color: red'>Please enter company name</label>"); 1557 //alert("Please enter Company Name"); 1558 } else if (gCaptcha == "") { 1559 $("#displayMsgRpt").html("<lable style='color: red'>Please validate the captcha</label>"); 1560 //alert("Please enter Company Name"); 1561 } else { 1562 1563 $.ajax({ 1564 url: domain_url + '/mailerlite.php', 1565 type: "POST", 1566 data: { 1567 action: 'askForSampleReport', 1568 custName: custName, 1569 lastname: lastnameFrRpt, 1570 companyName: companyName, 1571 emailId: emailId, 1572 countryName: countryName, 1573 mobileNo: mobileNo, 1574 reportType: reportType, 1575 }, 1576 success: function(data) { 1577 //console.log(data.data); 1578 if (data.data != "") { 1579 $("#displayMsgRpt").html("<lable style='color: green'>Thank You.</label>"); 1580 //alert("Sample Report will be mailed to you."); 1581 } else { 1582 $("#displayMsgRpt").html("<lable style='color: red'>Facing some issues.</label>"); 1583 //alert("Facing some issues."); 1584 } 1585 1586 $("#nameFrRpt").val(""); 1587 $("#lastnameFrRpt").val(""); 1588 $("#companyFrRpt").val(""); 1589 $("#emailFrRpt").val(""); 1590 $("#selCountryFrRpt").val(""); 1591 $("#mobileFrRpt").val(""); 1592 $("#reportFrRpt").val(""); 1593 1594 } 1595 }); 1596 } 1597} 1598 1599 1600function ValidateEmail(mail) { 1601 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)) { 1602 return (true) 1603 } 1604 return (false) 1605} 1606 1607function loadNewsData(page_num) { 1608 1609 window.scrollTo(100, 100); 1610 var domain_url = $("#domain_url").val(); 1611 page_num = page_num ? page_num : 0; 1612 1613 var selSelectAll = $("#selSelectAll").val(); 1614 var selCategory = $("#selCategory").val(); 1615 var selNewsType = $("#selNewsType").val(); 1616 var selChains = $("#selChains").val(); 1617 var selNewsCountry = $("#selNewsCountry").val(); 1618 1619 $.ajax({ 1620 type: 'POST', 1621 url: domain_url + '/news-inner-page/', 1622 data: 'page=' + page_num + '&newsCategory=' + selCategory + '&newsType=' + selNewsType + '&newsChains=' + selChains + '&newsCountry=' + selNewsCountry + '&selSelectAll=' + selSelectAll, 1623 beforeSend: function() { 1624 $('.loading-overlay').show(); 1625 $('#posts_content').hide(); 1626 }, 1627 success: function(html) { 1628 //alert("here"); 1629 $('#posts_content').show(); 1630 $('#posts_content').html(html); 1631 $('.loading-overlay').fadeOut("slow"); 1632 //$("body").scrollTop(0); 1633 1634 } 1635 }); 1636} 1637 1638function resetNewsData() { 1639 1640 $("#selSelectAll").val(""); 1641 $("#selCategory").val(""); 1642 $("#selNewsType").val(""); 1643 $("#selChains").val(""); 1644 $("#selNewsCountry").val(""); 1645 loadNewsData(); 1646 1647} 1648 1649 1650function loadInterviewData(page_num) { 1651 1652 window.scrollTo(100, 100); 1653 var domain_url = $("#domain_url").val(); 1654 page_num = page_num ? page_num : 0; 1655 1656 var selSelectAll = $("#selSelectAll").val(); 1657 var selCategory = $("#selCategory").val(); 1658 // var selNewsType = $("#selNewsType").val(); 1659 var selChains = $("#selChains").val(); 1660 var selNewsCountry = $("#selNewsCountry").val(); 1661 1662 $.ajax({ 1663 type: 'POST', 1664 url: domain_url + '/interview-inner-page/', 1665 data: 'page=' + page_num + '&newsCategory=' + selCategory + '&newsChains=' + selChains + '&newsCountry=' + selNewsCountry + '&selSelectAll=' + selSelectAll, 1666 beforeSend: function() { 1667 $('.loading-overlay').show(); 1668 $('#posts_content').hide(); 1669 }, 1670 success: function(html) { 1671 //alert("here"); 1672 $('#posts_content').show(); 1673 $('#posts_content').html(html); 1674 $('.loading-overlay').fadeOut("slow"); 1675 //$("body").scrollTop(0); 1676 1677 } 1678 }); 1679} 1680 1681function resetInterviewData() { 1682 1683 $("#selSelectAll").val(""); 1684 $("#selCategory").val(""); 1685 $("#selNewsType").val(""); 1686 $("#selChains").val(""); 1687 $("#selNewsCountry").val(""); 1688 loadInterviewData(); 1689 1690} 1691 1692function resetInsightsData() { 1693 1694 $("#selChains").val(""); 1695 loadInsightsData(); 1696 1697} 1698 1699function loadMyNewsData(page_num) { 1700 window.scrollTo(100, 100); 1701 var domain_url = $("#domain_url").val(); 1702 page_num = page_num ? page_num : 0; 1703 1704 var selCategory = $("#selCategory").val(); 1705 var selNewsType = $("#selNewsType").val(); 1706 var selChains = $("#selChains").val(); 1707 var selNewsCountry = $("#selNewsCountry").val(); 1708 1709 $.ajax({ 1710 type: 'POST', 1711 url: domain_url + '/my-account/my-news-inner/', 1712 data: 'page=' + page_num + '&newsCategory=' + selCategory + '&newsType=' + selNewsType + '&newsChains=' + selChains + '&newsCountry=' + selNewsCountry, 1713 beforeSend: function() { 1714 //$('.loading-overlay').show(); 1715 //$('#posts_content').hide(); 1716 }, 1717 success: function(html) { 1718 $('#posts_content').show(); 1719 $('#posts_content').html(html); 1720 $('.loading-overlay').fadeOut("slow"); 1721 } 1722 }); 1723} 1724 1725function loadMyProductWishData(page_num) { 1726 window.scrollTo(100, 100); 1727 var domain_url = $("#domain_url").val(); 1728 page_num = page_num ? page_num : 0; 1729 1730 $.ajax({ 1731 type: 'POST', 1732 url: domain_url + '/my-account/my-wishlist-inner/', 1733 data: 'page=' + page_num, 1734 beforeSend: function() { 1735 //$('.loading-overlay').show(); 1736 //$('#posts_content').hide(); 1737 }, 1738 success: function(html) { 1739 $('#posts_content').show(); 1740 $('#posts_content').html(html); 1741 $('.loading-overlay').fadeOut("slow"); 1742 } 1743 }); 1744} 1745 1746 1747 1748function loadInsightsData(page_num) { 1749 1750 window.scrollTo(100, 100); 1751 1752 var domain_url = $("#domain_url").val(); 1753 page_num = page_num ? page_num : 0; 1754 1755 // var selCategory = $("#selCategory").val(); 1756 // var selNewsType = $("#selNewsType").val(); 1757 var selChains = $("#selChains").val(); 1758 // var selNewsCountry = $("#selNewsCountry").val(); 1759 1760 $.ajax({ 1761 type: 'POST', 1762 url: domain_url + '/insights-inner-page/', 1763 //data:'page='+page_num+'&newsCategory='+selCategory+'&newsType='+selNewsType+'&newsChains='+selChains+'&newsCountry='+selNewsCountry, 1764 data: 'page=' + page_num + '&newsChains=' + selChains, 1765 beforeSend: function() { 1766 $('.loading-overlay').show(); 1767 // $('#posts_content').hide(); 1768 }, 1769 success: function(html) { 1770 $('#posts_content').show(); 1771 $('#posts_content').html(html); 1772 $('.loading-overlay').fadeOut("slow"); 1773 } 1774 }); 1775} 1776 1777function loadEventData(page_num) { 1778 window.scrollTo(100, 100); 1779 var domain_url = $("#domain_url").val(); 1780 page_num = page_num ? page_num : 0; 1781 1782 var searchEvent = $("#eventname").val(); 1783 var eventMonth = $("#eventMonth").val(); 1784 var eventLocation = $("#eventLocation").val(); 1785 //alert("searchEvent=>"+searchEvent); 1786 $.ajax({ 1787 type: 'POST', 1788 url: domain_url + '/events-inner-page/', 1789 data: 'page=' + page_num + '&searchEvent=' + searchEvent + '&eventMonth=' + eventMonth + '&eventLocation=' + eventLocation, 1790 beforeSend: function() { 1791 $('.loading-overlay').show(); 1792 $('#posts_content').hide(); 1793 }, 1794 success: function(html) { 1795 $('#posts_content').show(); 1796 $('#posts_content').html(html); 1797 $('.loading-overlay').fadeOut("slow"); 1798 } 1799 }); 1800} 1801 1802 1803function loadViewProductData(page_num) { 1804 window.scrollTo(100, 100); 1805 var domain_url = $("#domain_url").val(); 1806 page_num = page_num ? page_num : 0; 1807 1808 // var selCategory = $("#selCategory").val(); 1809 // var selNewsType = $("#selNewsType").val(); 1810 // var selChains = $("#selChains").val(); 1811 // var selNewsCountry = $("#selNewsCountry").val(); 1812 1813 $.ajax({ 1814 type: 'POST', 1815 url: domain_url + '/myaccount/view-product-inner/', 1816 data: 'page=' + page_num, 1817 beforeSend: function() { 1818 $('.loading-overlay').show(); 1819 $('#posts_content').hide(); 1820 }, 1821 success: function(html) { 1822 $('#posts_content').show(); 1823 $('#posts_content').html(html); 1824 $('.loading-overlay').fadeOut("slow"); 1825 } 1826 }); 1827} 1828 1829function loadMarketPlaceData(page_num) { 1830 // alert("CLicekd"); 1831 window.scrollTo(100, 100); 1832 var domain_url = $("#domain_url").val(); 1833 page_num = page_num ? page_num : 0; 1834 1835 var proMainSubCatId = $("#proMainSubCatId").val(); 1836 var proTypeValue = $("#proTypeValue").val(); 1837 var activeTabValue = $("#activeTabValue").val(); 1838 var searchVal = $("#searchVal").val(); 1839 if (typeof searchVal === 'undefined') { 1840 searchVal = ''; 1841 } 1842 if (proMainSubCatId != '' && typeof proMainSubCatId !== 'undefined') { 1843 if (proMainSubCatId.includes('@')) { 1844 var splitIds = proMainSubCatId.split('@'); 1845 var proMainCatId = splitIds[0]; 1846 var proSubCatId = splitIds[1]; 1847 } else { 1848 var proMainCatId = proMainSubCatId.substring(0, 1); 1849 var proSubCatId = ''; 1850 } 1851 } else { 1852 var proMainCatId = ''; 1853 var proSubCatId = ''; 1854 } 1855 // alert('page=' + page_num + '&proMainCatId=' + proMainCatId + '&proSubCatId=' + proSubCatId + '&proTypeValue=' + proTypeValue + '&activeTabValue=' + activeTabValue + "&searchVal=" + searchVal); 1856 $.ajax({ 1857 type: 'POST', 1858 url: domain_url + '/market-place-listing-inner/', 1859 data: 'page=' + page_num + '&proMainCatId=' + proMainCatId + '&proSubCatId=' + proSubCatId + '&proTypeValue=' + proTypeValue + '&activeTabValue=' + activeTabValue + "&searchVal=" + searchVal, 1860 beforeSend: function() { 1861 $('.loading-overlay').show(); 1862 $('#posts_content').hide(); 1863 }, 1864 success: function(html) { 1865 $('#posts_content').show(); 1866 $('#posts_content').html(html); 1867 $('.loading-overlay').fadeOut("slow"); 1868 1869 /*Mouse hover open the submenu*/ 1870 if ($(window).width() > 991) { 1871 $(".header .dropdown").hover( 1872 function() { 1873 $('>.dropdown-menu', this).stop(true, true).fadeIn("fast"); 1874 $(this).addClass('show'); 1875 }, 1876 function() { 1877 $('>.dropdown-menu', this).stop(true, true).fadeOut("fast"); 1878 $(this).removeClass('show'); 1879 }); 1880 1881 $(".header .dropdown-submenu").hover( 1882 function() { 1883 $('>.dropdown-menu', this).stop(true, true).fadeIn("fast"); 1884 $(this).addClass('show'); 1885 }, 1886 function() { 1887 $('>.dropdown-menu', this).stop(true, true).fadeOut("fast"); 1888 $(this).removeClass('show'); 1889
1889 }); 1890 } 1891 /*menu navbar end*/ 1892 /*submenu add and remove class navbar start*/ 1893 $('.dropdown-menu a.dropdown-toggle').on('click', function(e) { 1894 if (!$(this).next().hasClass('show')) { 1895 $(this).parents('.dropdown-menu').first().find('.show').removeClass('show'); 1896 } 1897 var $subMenu = $(this).next('.dropdown-menu'); 1898 $subMenu.toggleClass('show'); 1899 1900 1901 $(this).parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function(e) { 1902 $('.dropdown-submenu .show').removeClass('show'); 1903 }); 1904 return false; 1905 }); 1906 } 1907 }); 1908} 1909 1910function loadCompanyProfileNewData(page_num) { 1911 window.scrollTo(100, 100); 1912 var domain_url = $("#domain_url").val(); 1913 page_num = page_num ? page_num : 0; 1914 1915 var companyId = $("#companyId").val(); 1916 var selProductId = $("#selProductId").val(); 1917 1918 $.ajax({ 1919 type: 'POST', 1920 url: domain_url + '/company-profile-new-inner/', 1921 data: 'page=' + page_num + '&companyId=' + companyId + '&productId=' + selProductId, 1922 beforeSend: function() { 1923 $('.loading-overlay').show(); 1924 $('#productService').hide(); 1925 }, 1926 success: function(html) { 1927 $('#productService').show(); 1928 $('#productService').html(html); 1929 $('.loading-overlay').fadeOut("slow"); 1930 } 1931 }); 1932} 1933 1934 1935$(function() { 1936 $(".dataMarketPlace").click(function() { 1937 //alert("Clicked"); 1938 var my_id_value = $(this).data('product-type'); 1939 //alert("Clicked=>"+my_id_value); 1940 $("#proTypeValue").val(my_id_value); 1941 $("#activeTabValue").val(my_id_value); 1942 loadMarketPlaceData(); 1943 }) 1944}); 1945 1946$(document).on("keypress", "#searchVal", function(e) { 1947 if (e.keyCode == 13 || e.which == '13') { 1948 loadMarketPlaceData(); 1949 } 1950}); 1951//$("#searchVal").keypress(function (event) { 1952// var searchVal = $("#searchVal").val(); 1953// alert("searchVal=>"+searchVal); 1954// if (searchVal != '') { 1955// if (event.which == 13) { 1956// loadMarketPlaceData(); 1957// } 1958// } 1959// 1960//}); 1961 1962 1963function selectProduct(selValue) { 1964 //alert(selValue); 1965 if (selValue != "") { 1966 $("#proMainSubCatId").val(selValue); 1967 loadMarketPlaceData(); 1968 } 1969} 1970 1971function Get_product_price(marketCode, industryCodeChild, fieldTermsValue, i) { 1972 var assets_url = $("#assets_url").val(); 1973 //alert(marketCode+"-"+industryCodeChild+"-"+fieldTermsValue+"-"+i) 1974 $.ajax({ 1975 url: '/wp-admin/admin-ajax.php', 1976 type: "POST", 1977 data: { 1978 action: 'getProductPrice', 1979 marketCode: marketCode, 1980 industryCodeChild: industryCodeChild, 1981 fieldTermsValue: fieldTermsValue, 1982 }, 1983 beforeSend: function() { 1984 $("#showprice_" + i).html("<img src='" + assets_url + "images/[email protected]' width='20' height='20' align='center'>") 1985 }, 1986 success: function(data) { 1987 //console.log(data.data); 1988 1989 var splitData = data.data.split("*_*"); 1990 var productPrice = splitData[0]; 1991 var movement = splitData[1]; 1992 $("#showprice_" + i).html(productPrice); 1993 if (movement < 0) { 1994 movement = "<i class='fas fa-caret-down green-color'></i>" + movement; 1995 } else if (movement > 0) { 1996 movement = "<i class='fas fa-caret-up red-color'></i>" + movement; 1997 } else if (movement == 0) { 1998 movement = "<img src='" + assets_url + "images/tild_green.gif' align='center'>" + movement; 1999 } 2000 $("#Movement_" + i).html(movement); 2001 2002 } 2003 }); 2004} 2005 2006 2007function selDailyMarket(proVal) { 2008 var productComp = ''; 2009 if (proVal == 'searchPro') { 2010 $.each($("#selProductSrch option:selected"), function() { 2011 productComp = productComp + '\',\'' + $(this).val(); 2012 }); 2013 } else if (proVal == 'compPro') { 2014 $.each($("#selProductComp option:selected"), function() {
2015 productComp = productComp + '\',\'' + $(this).val(); 2016 }); 2017 } else if (proVal == 'spreadInput') { 2018 $.each($("#selProductInput option:selected"), function() { 2019 productComp = productComp + '\',\'' + $(this).val(); 2020 }); 2021 } else if (proVal == 'spreadOutput') { 2022 $.each($("#selProductOutput option:selected"), function() { 2023 productComp = productComp + '\',\'' + $(this).val(); 2024 }); 2025 } 2026 productComp1 = productComp.substring(2); 2027 productCompVal = productComp1 + '\''; 2028 //alert("proVal=>"+productCompVal); 2029 2030 $.ajax({ 2031 url: '/wp-admin/admin-ajax.php', 2032 type: "POST", 2033 data: { 2034 action: 'getDailyMarket', 2035 productComp: productCompVal, 2036 proVal: proVal, 2037 }, 2038 success: function(html) { 2039 //console.log(html); 2040 if (proVal == 'searchPro') { 2041 $("#divDailyMarket").html(html.data); 2042 $('#selMarketSrch').multiselect({ 2043 enableClickableOptGroups: true, 2044 maxHeight: 200, 2045 nonSelectedText: 'Select Market', 2046 enableCaseInsensitiveFiltering: true, 2047 filterPlaceholder: 'Search Here...', 2048 includeSelectAllOption: true, 2049 numberDisplayed: 1 2050 }); 2051 2052 } else if (proVal == 'compPro') { 2053 $("#divDailyMarketComp").html(html.data); 2054 $('#selMarketComp').multiselect({ 2055 enableClickableOptGroups: true, 2056 maxHeight: 200, 2057 nonSelectedText: 'Select Market', 2058 enableCaseInsensitiveFiltering: true, 2059 filterPlaceholder: 'Search Here...', 2060 includeSelectAllOption: true, 2061 numberDisplayed: 1 2062 }); 2063 } else if (proVal == 'spreadInput') { 2064 $("#divMarketInput").html(html.data); 2065 } else if (proVal == 'spreadOutput') { 2066 $("#divMarketOutput").html(html.data); 2067 } 2068 $('.multiselect-search').keyup(function() { 2069 $('.multiselect-search').each(function() { 2070 if (this.value.length > 0) { 2071 $(this).parent().parent().next().hide(); 2072 } else { 2073 $(this).parent().parent().next().show(); 2074 } 2075 }); 2076 }); 2077 } 2078 }); 2079} 2080 2081 2082function selDailyTerms(proVal) { 2083 var productComp = ''; 2084 if (proVal == 'searchMarket') { 2085 $.each($("#selProductSrch option:selected"), function() { 2086 productComp = productComp + '\',\'' + $(this).val(); 2087 }); 2088 } else if (proVal == 'compMarket') { 2089 $.each($("#selProductComp option:selected"), function() { 2090 productComp = productComp + '\',\'' + $(this).val(); 2091 }); 2092 } else if (proVal == 'inputMarket') { 2093 $.each($("#selProductInput option:selected"), function() { 2094 productComp = productComp + '\',\'' + $(this).val(); 2095 }); 2096 } else if (proVal == 'outputMarket') { 2097 $.each($("#selProductOutput option:selected"), function() { 2098 productComp = productComp + '\',\'' + $(this).val(); 2099 }); 2100 } 2101 productComp1 = productComp.substring(2); 2102 productCompVal = productComp1 + '\''; 2103 2104 2105 var marketComp = ''; 2106 if (proVal == 'searchMarket') { 2107 $.each($("#selMarketSrch option:selected"), function() { 2108 marketComp = marketComp + '\',\'' + $(this).val(); 2109 }); 2110 } else if (proVal == 'compMarket') { 2111 $.each($("#selMarketComp option:selected"), function() { 2112 marketComp = marketComp + '\',\'' + $(this).val(); 2113 }); 2114 } else if (proVal == 'inputMarket') { 2115 $.each($("#selMarketInput option:selected"), function() { 2116 marketComp = marketComp + '\',\'' + $(this).val(); 2117 }); 2118 } else if (proVal == 'outputMarket') { 2119 $.each($("#selMarketOutput option:selected"), function() { 2120 marketComp = marketComp + '\',\'' + $(this).val(); 2121 }); 2122 } 2123 2124 marketComp1 = marketComp.substring(2); 2125 marketCompVal = marketComp1 + '\''; 2126 //alert("proVal=>"+marketCompVal); 2127 2128 $.ajax({ 2129 url: '/wp-admin/admin-ajax.php', 2130 type: "POST", 2131 data: { 2132 action: 'getDailyTerms',
2133 productComp: productCompVal, 2134 marketComp: marketCompVal, 2135 proVal: proVal, 2136 }, 2137 success: function(html) { 2138 //console.log(html); 2139 if (proVal == 'searchMarket') { 2140 $("#divDailyTerms").html(html.data); 2141 2142 $('#selTermsSrch').multiselect({ 2143 includeSelectAllOption: true, 2144 maxHeight: 200, 2145 nonSelectedText: 'Select Term', 2146 enableCaseInsensitiveFiltering: true, 2147 filterPlaceholder: 'Search Here...', 2148 includeSelectAllOption: true, 2149 numberDisplayed: 1 2150 }); 2151 } else if (proVal == 'compMarket') { 2152 $("#divDailyTermsComp").html(html.data); 2153 2154 $('#selTermsComp').multiselect({ 2155 includeSelectAllOption: true, 2156 maxHeight: 200, 2157 nonSelectedText: 'Select Term', 2158 enableCaseInsensitiveFiltering: true, 2159 filterPlaceholder: 'Search Here...', 2160 includeSelectAllOption: true, 2161 numberDisplayed: 1 2162 }); 2163 } else if (proVal == 'inputMarket') { 2164 $("#divTermsInput").html(html.data); 2165 } else if (proVal == 'outputMarket') { 2166 $("#divTermsOutput").html(html.data); 2167 } 2168 $('.multiselect-search').keyup(function() { 2169 $('.multiselect-search').each(function() { 2170 if (this.value.length > 0) { 2171 $(this).parent().parent().next().hide(); 2172 } else { 2173 $(this).parent().parent().next().show(); 2174 } 2175 }); 2176 }); 2177 } 2178 }); 2179} 2180 2181function downloadExcel(productSrch, marketSrch, termSrch, currencySrch, frmDate, toDate, reportType) { 2182 var domain_url = $("#domain_url").val(); 2183 // alert(productSrch+'<=>'+marketSrch+'<=>'+termSrch+'<=>'+currencySrch+'<=>'+frmDate+'<=>'+toDate+'<=>'+reportType); 2184 location.href = domain_url + '/daily-textile-prices-excel/?productSrch=' + productSrch + '&marketSrch=' + marketSrch + '&termSrch=' + termSrch + '¤cySrch=' + currencySrch + '&frmDate=' + frmDate + '&toDate=' + toDate + '&reportType=' + reportType; 2185 // $.ajax({ 2186 // url: domain_url+'/daily-textile-prices-excel/', 2187 // type: "GET", 2188 // data: { 2189 // productSrch : productSrch, 2190 // marketSrch : marketSrch, 2191 // termSrch : termSrch, 2192 // currencySrch : currencySrch, 2193 // frmDate : frmDate, 2194 // toDate : toDate, 2195 // reportType : reportType, 2196 // }, 2197 // success: function(data) { 2198 // //console.log(data); 2199 // //console.log(data.data); 2200 // } 2201 // }); 2202} 2203 2204function downloadPriceSpreadExcel(productInput, productOutput, marketInput, marketOutput, termInput, termOutput, currencySpread, frmDate, toDate, reportType) { 2205 var domain_url = $("#domain_url").val(); 2206 //alert(productInput+'<=>'+productOutput+'<=>'+marketInput+'<=>'+marketOutput+'<=>'+termInput+'<=>'+termOutput+'<=>'+currencySrch+'<=>'+frmDate+'<=>'+toDate+'<=>'+reportType); 2207 location.href = domain_url + '/daily-textile-prices-excel/?productInput=' + productInput + '&productOutput=' + productOutput + '&marketInput=' + marketInput + '&marketOutput=' + marketOutput + '&termInput=' + termInput + '&termOutput=' + termOutput + '¤cySpread=' + currencySpread + '&frmDate=' + frmDate + '&toDate=' + toDate + '&reportType=' + reportType; 2208 // $.ajax({ 2209 // //url: '/wp-admin/admin-ajax.php', 2210 // url: domain_url+'/daily-textile-prices-excel/', 2211 // type: "GET", 2212 // data: { 2213 // productInput : productInput, 2214 // productOutput : productOutput, 2215 // marketInput : marketInput, 2216 // marketOutput : marketOutput, 2217 // termInput : termInput, 2218 // termOutput : termOutput, 2219 // currencySrch : currencySrch, 2220 // frmDate : frmDate, 2221 // toDate : toDate, 2222 // reportType : reportType, 2223 // }, 2224 // success: function(data) { 2225 // //console.log(data); 2226 // //console.log(data.data); 2227 // } 2228 // }); 2229} 2230 2231function dailyDashBoardData(productSrch, marketSrch, termSrch, dateSrch) { 2232 var assets_url = $("#assets_url").val(); 2233 var currencySrch = 'US_price'; 2234 var price = 'In US'; 2235 $.ajax({ 2236 url: '/wp-admin/admin-ajax.php', 2237 type: "POST", 2238 data: { 2239 action: 'getDailyDashboardData', 2240 productSrch: productSrch, 2241 marketSrch: marketSrch, 2242 termSrch: termSrch, 2243 dateSrch: dateSrch 2244 }, 2245 beforeSend: function() { 2246 $('#dailyDashboardModal').modal(); 2247 $("#divDailyDashboardModal").html("<div class='modal-header text-center'><div class='btn-wrap'><img src='" + assets_url + "images/[email protected]' width='50' height='50' align='center'></div></div>"); 2248 }, 2249 success: function(data) { 2250 //console.log(data); 2251 //console.log(data.data); 2252 var str = ""; 2253 if (data.data == "No Data Found") { // && !data.data.includes("Download") ){ 2254 str = str + '<div class="modal-header text-center">'; 2255 str = str + '<div class="btn-wrap">'; 2256 //str = str + '<button type="button" onclick="downloadExcel
2256(\''+productSrch+'\',\''+marketSrch+'\',\''+termSrch+'\',\''+currencySrch+'\',\''+frmDate+'\',\''+toDate+'\')" class="set-btn ">download</button>'; 2257 str = str + '</div>'; 2258 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2259 str = str + '<div class="modal-body">'; 2260 2261 str = str + '<div class="modal-body-wrap">'; 2262 str = str + '<div class="container">'; 2263 str = str + '<div class="row">'; 2264 str = str + '<div class="col-12">'; 2265 str = str + '<div class="report-info">'; 2266 str = str + '<div class="sect sect-1">'; 2267 str = str + '<p class="set-bold">No Data Found</p>'; 2268 str = str + '</div></div>'; 2269 str = str + '</div>'; 2270 str = str + '</div>'; 2271 str = str + '</div>'; 2272 str = str + '</div></div>'; 2273 2274 $("#divDailyDashboardModal").html(str); 2275 } else if (data.data.includes("Download")) { 2276 2277 str = str + '<div class="modal-header text-center">'; 2278 str = str + '<div class="btn-wrap">'; 2279 //str = str + '<button type="button" onclick="downloadExcel(\''+productSrch+'\',\''+marketSrch+'\',\''+termSrch+'\',\''+currencySrch+'\',\''+frmDate+'\',\''+toDate+'\')" class="set-btn ">download</button>'; 2280 str = str + '</div>'; 2281 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2282 str = str + '<div class="modal-body">'; 2283 2284 str = str + '<div class="modal-body-wrap">'; 2285 str = str + '<div class="container">'; 2286 str = str + '<div class="row">'; 2287 str = str + '<div class="col-12">'; 2288 str = str + '<div class="report-info">'; 2289 str = str + '<div class="sect sect-1">'; 2290 str = str + '<p class="set-bold">' + data.data + '</p>'; 2291 str = str + '</div></div>'; 2292 str = str + '</div>'; 2293 str = str + '</div>'; 2294 str = str + '</div>'; 2295 str = str + '</div></div>'; 2296 $("#divDailySearchDetailsModal").html(str); 2297 2298 } else { 2299 str = str + '<div class="modal-header text-center">'; 2300 str = str + '<div class="btn-wrap">'; 2301 // str = str + '<button type="button" onclick="downloadExcel(\'' + productSrch + '\',\'' + marketSrch + '\',\'' + termSrch + '\',\'' + currencySrch + '\',\'' + frmDate + '\',\'' + toDate + '\',\'ProductSearch\')" class="set-btn ">download</button>'; 2302 str = str + '</div>'; 2303 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2304 str = str + '<div class="modal-body">'; 2305 2306 str = str + '<div class="modal-body-wrap">'; 2307 str = str + '<div class="container">'; 2308 str = str + '<div class="row">'; 2309 str = str + '<div class="col-12">'; 2310 str = str + '<div class="report-info">'; 2311 str = str + '<div class="sect sect-1">'; 2312 // str = str + '<p class="set-bold">output product</p>'; 2313 // str = str + '<p class="grey-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit adipiscing elit</p>'; 2314 str = str + '</div>'; 2315 str = str + '<div class="sect sect-2">'; 2316 // str = str + '<p class="set-bold">output product</p>'; 2317 // str = str + '<p class="grey-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit adipiscing elit</p>'; 2318 str = str + '</div>'; 2319 str = str + '</div>'; 2320 str = str + '<hr class="yellow-border">'; 2321 str = str + '</div>'; 2322 str = str + '<div class="col-12">'; 2323 str = str + '<div class="modal-table-wrapper">'; 2324 str = str + '<div class="table-responsive">'; 2325 str = str + '<table class="table fixed_header" align="center">'; 2326 str = str + '<thead>'; 2327 str = str + '<tr>'; 2328 str = str + '<th >Product</th>'; 2329 str = str + '<th >Market</th>'; 2330 str = str + '<th >Term</th>'; 2331 str = str + '<th >Unit</th>'; 2332 str = str + '<th >Price ' + price + '</th>'; 2333 str = str + '<th >Movement</th>'; 2334 str = str + '<th >Date</th>'; 2335 str = str + '</tr>'; 2336 str = str + '</thead>'; 2337 str = str + '<tbody id="modalbodyscroll">'; 2338 for (z = 0; z < data.data.length; z++) { 2339 var EURO_price = data.data[z].EURO_price; 2340 var US_price = data.data[z].US_price; 2341 var field_price_value = data.data[z].field_price_value; 2342 var field_unit_value = ''; 2343 var field_date_value = data.data[z].field_date_value; 2344 var local_price = data.data[z].local_price; 2345 var local_EURO_price = data.data[z].local_EURO_price; 2346 var local_US_price = data.data[z].local_US_price; 2347 var movement = 0; 2348 2349 if (currencySrch == 'EURO_price') { 2350 field_price_value = EURO_price; 2351 movement = field_price_value - local_EURO_price; 2352 field_unit_value = "EURO/Kg"; 2353 2354 } else if (currencySrch == 'US_price') { 2355 field_price_value = US_price; 2356 movement = field_price_value - local_US_price; 2357 field_unit_value = "US/Kg"; 2358 //alert('movement=>'+movement+'<=field_price_value=>'+field_price_value+'<==>'); 2359 } 2360 movement = (Math.round(movement * 100) / 100); 2361 if (movement < 0) { 2362 movement = "<i class='fas fa-caret-down green-color'></i>" + movement; 2363 } else if (movement > 0) { 2364 movement = "<i class='fas fa-caret-up red-color'></i>" + movement; 2365 } else if (movement == 0) { 2366 movement = "<img src='" + assets_url + "images/tild_green.gif' align='center'>" + movement; 2367 } 2368 2369 str = str + '<tr>'; 2370 str = str + '<td > ' + data.data[z].productName + ' </td>'; 2371 str = str + '<td > ' + data.data[z].MarketName + ' </td>'; 2372 str = str + '<td > ' + data.data[z].field_terms_value + ' </td>'; 2373 str = str + '<td > ' + field_unit_value + ' </td>'; 2374 str = str + '<td > ' + field_price_value + ' </td>'; 2375 str = str + '<td > ' + movement + ' </td>'; 2376 str = str + '<td > ' + field_date_value + ' </td>'; 2377 str = str + '</tr>'; 2378 } 2379 str = str + '</tbody>'; 2380 str = str + '</table>'; 2381 str = str + '</div>'; 2382 str = str + '</div>'; 2383 str = str + '</div>'; 2384 str = str + '</div>'; 2385 str = str + '</div></div>'; 2386 $("#divDailyDashboardModal").html(str); 2387 } 2388 } 2389 }); 2390} 2391 2392function searchProductDailyFrm() { 2393 var assets_url = $("#assets_url").val(); 2394 var productSrch = []; 2395 $.each($("#selProductSrch option:selected"), function() { 2396 productSrch.push($(this).val()); 2397 }); 2398 2399 var marketSrch = []; 2400 $.each($("#selMarketSrch option:selected"), function() { 2401 marketSrch.push($(this).val()); 2402 }); 2403 2404 var termSrch = []; 2405 $.each($("#selTermsSrch option:selected"), function() { 2406 termSrch.push($(this).val()); 2407 }); 2408 2409 var currencySrch = $("#selCurrencySrch").val(); 2410 var frmDate = $("#from-datepicker").val(); 2411 var toDate = $("#to-datepicker").val(); 2412 2413 var minSelDate = new Date(); 2414 var pastYear = minSelDate.getFullYear() - 1; 2415 minSelDate.setFullYear(pastYear); 2416 2417 var oldDate = (minSelDate.getMonth() + 1) + '/' + minSelDate.getDate() + '/' + minSelDate.getFullYear(); 2418 2419 const date1 = new Date(frmDate); 2420 const date2 = new Date(toDate); 2421 const date3 = new Date(oldDate); 2422 const diffTimeFrm = date1 - date3; //Math.abs(date1 - date2); 2423 const diffDaysFrm = diffTimeFrm / (1000 * 60 * 60 * 24); //Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 2424 2425 const diffTimeTo = date2 - date3; //Math.abs(date1 - date2); 2426 const diffDaysTo = diffTimeTo / (1000 * 60 * 60 * 24); //Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 2427 2428 // alert(diffDaysFrm+'<==>'+diffDaysTo); 2429 if (productSrch.length < 1) { 2430 alert("Please select products"); 2431 } else if (marketSrch.length < 1) { 2432 alert("Please select markets"); 2433 } else if (termSrch.length < 1) { 2434 alert("Please select terms"); 2435 } else if (termSrch.length < 1) { 2436 alert("Please select terms"); 2437 } else if (currencySrch == "") { 2438 alert("Please select currency"); 2439 } else if (frmDate == "") { 2440 alert("Please select from date"); 2441 } else if (diffDaysFrm <= 0) { 2442 alert("Please select a date within the last 1 year. The module allows only 1 year of historical data."); 2443 } else if (toDate == "") { 2444 alert("Please select to date"); 2445 } else if (diffDaysTo <= 0) { 2446 alert("Please select a date within the last 1 year. The module allows only 1 year of historical data."); 2447 } else { 2448 2449 var price = ''; 2450 if (currencySrch == 'EURO_price') { 2451 price = 'In EURO'; 2452 } else if (currencySrch == 'US_price') { 2453 price = 'In US'; 2454 } else if (currencySrch == 'field_price_value') { 2455 price = ''; 2456 } 2457 2458 2459 // /alert("productSrch=>"+productSrch.length+"<=marketSrch=>"+marketSrch.length+"<=termSrch=>"+termSrch.length+"<=currencySrch=>"+currencySrch.length); 2460 2461 $.ajax({ 2462 url: '/wp-admin/admin-ajax.php', 2463 type: "POST", 2464 data: { 2465 action: 'getDailySearchProduct', 2466 productSrch: productSrch, 2467 marketSrch: marketSrch, 2468 termSrch: termSrch, 2469 currencySrch: currencySrch, 2470 frmDate: frmDate, 2471 toDate: toDate, 2472 }, 2473 beforeSend: function() { 2474 $('#dailySearchDetailsModal').modal(); 2475 $("#divDailySearchDetailsModal").html("<div class='modal-header text-center'><div class='btn-wrap'><img src='" + assets_url + "images/[email protected]' width='50' height='50' align='center'></div></div>") 2476 }, 2477 success: function(data) { 2478 //console.log(data); 2479 //console.log(data.data); 2480 var str = ""; 2481 if (data.data == "No Data Found") { // && !data.data.includes("Download") ){ 2482 str = str + '<div class="modal-header text-center">'; 2483 str = str + '<div class="btn-wrap">'; 2484 //str = str + '<button type="button" onclick="downloadExcel
2484(\''+productSrch+'\',\''+marketSrch+'\',\''+termSrch+'\',\''+currencySrch+'\',\''+frmDate+'\',\''+toDate+'\')" class="set-btn ">download</button>'; 2485 str = str + '</div>'; 2486 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2487 str = str + '<div class="modal-body">'; 2488 2489 str = str + '<div class="modal-body-wrap">'; 2490 str = str + '<div class="container">'; 2491 str = str + '<div class="row">'; 2492 str = str + '<div class="col-12">'; 2493 str = str + '<div class="report-info">'; 2494 str = str + '<div class="sect sect-1">'; 2495 str = str + '<p class="set-bold">No Data Found</p>'; 2496 str = str + '</div></div>'; 2497 str = str + '</div>'; 2498 str = str + '</div>'; 2499 str = str + '</div>'; 2500 str = str + '</div></div>'; 2501 2502 $("#divDailySearchDetailsModal").html(str); 2503 } else if (data.data.includes("Download")) { 2504 2505 str = str + '<div class="modal-header text-center">'; 2506 str = str + '<div class="btn-wrap">'; 2507 //str = str + '<button type="button" onclick="downloadExcel(\''+productSrch+'\',\''+marketSrch+'\',\''+termSrch+'\',\''+currencySrch+'\',\''+frmDate+'\',\''+toDate+'\')" class="set-btn ">download</button>'; 2508 str = str + '</div>'; 2509 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2510 str = str + '<div class="modal-body">'; 2511 2512 str = str + '<div class="modal-body-wrap">'; 2513 str = str + '<div class="container">'; 2514 str = str + '<div class="row">'; 2515 str = str + '<div class="col-12">'; 2516 str = str + '<div class="report-info">'; 2517 str = str + '<div class="sect sect-1">'; 2518 str = str + '<p class="set-bold">' + data.data + '</p>'; 2519 str = str + '</div></div>'; 2520 str = str + '</div>'; 2521 str = str + '</div>'; 2522 str = str + '</div>'; 2523 str = str + '</div></div>'; 2524 $("#divDailySearchDetailsModal").html(str); 2525 2526 } else { 2527 str = str + '<div class="modal-header text-center">'; 2528 str = str + '<div class="btn-wrap">'; 2529 str = str + '<button type="button" onclick="downloadExcel(\'' + productSrch + '\',\'' + marketSrch + '\',\'' + termSrch + '\',\'' + currencySrch + '\',\'' + frmDate + '\',\'' + toDate + '\',\'ProductSearch\')" class="set-btn ">download</button>'; 2530 str = str + '</div>'; 2531 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2532 str = str + '<div class="modal-body">'; 2533 2534 str = str + '<div class="modal-body-wrap">'; 2535 str = str + '<div class="container">'; 2536 str = str + '<div class="row">'; 2537 str = str + '<div class="col-12">'; 2538 str = str + '<div class="report-info">'; 2539 str = str + '<div class="sect sect-1">'; 2540 // str = str + '<p class="set-bold">output product</p>'; 2541 // str = str + '<p class="grey-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit adipiscing elit</p>'; 2542 str = str + '</div>'; 2543 str = str + '<div class="sect sect-2">'; 2544 // str = str + '<p class="set-bold">output product</p>'; 2545 // str = str + '<p class="grey-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit adipiscing elit</p>'; 2546 str = str + '</div>'; 2547 str = str + '</div>'; 2548 str = str + '<hr class="yellow-border">'; 2549 str = str + '</div>'; 2550 str = str + '<div class="col-12">'; 2551 str = str + '<div class="modal-table-wrapper">'; 2552 str = str + '<div class="table-responsive">'; 2553 str = str + '<table class="table fixed_header" align="center">'; 2554 str = str + '<thead>'; 2555 str = str + '<tr>'; 2556 str = str + '<th >Product</th>'; 2557 str = str + '<th >Market</th>'; 2558 str = str + '<th >Term</th>'; 2559 str = str + '<th >Unit</th>'; 2560 str = str + '<th >Price ' + price + '</th>'; 2561 str = str + '<th >Movement</th>'; 2562 str = str + '<th >Date</th>'; 2563 str = str + '</tr>'; 2564 str = str + '</thead>'; 2565 str = str + '<tbody id="modalbodyscroll">'; 2566 for (z = 0; z < data.data.length; z++) { 2567 var EURO_price = data.data[z].EURO_price; 2568 var US_price = data.data[z].US_price; 2569 var field_price_value = data.data[z].field_price_value; 2570 var field_unit_value = ''; 2571 var field_date_value = data.data[z].field_date_value; 2572 var local_price = data.data[z].local_price; 2573 var local_EURO_price = data.data[z].local_EURO_price; 2574 var local_US_price = data.data[z].local_US_price; 2575 var movement = 0; 2576 2577 if (currencySrch == 'EURO_price') { 2578 field_price_value = EURO_price; 2579 movement = field_price_value - local_EURO_price; 2580 field_unit_value = "EURO/Kg"; 2581 2582 } else if (currencySrch == 'US_price') { 2583 field_price_value = US_price; 2584 movement = field_price_value - local_US_price; 2585 field_unit_value = "US/Kg"; 2586 //alert('movement=>'+movement+'<=field_price_value=>'+field_price_value+'<==>'); 2587 } 2588 movement = (Math.round(movement * 100) / 100); 2589 if (movement < 0) { 2590 movement = "<i class='fas fa-caret-down green-color'></i>" + movement; 2591 } else if (movement > 0) { 2592 movement = "<i class='fas fa-caret-up red-color'></i>" + movement; 2593 } else if (movement == 0) { 2594 movement = "<img src='" + assets_url + "images/tild_green.gif' align='center'>" + movement; 2595 } 2596 2597 str = str + '<tr>'; 2598 str = str + '<td > ' + data.data[z].productName + ' </td>'; 2599 str = str + '<td > ' + data.data[z].MarketName + ' </td>'; 2600 str = str + '<td > ' + data.data[z].field_terms_value + ' </td>'; 2601 str = str + '<td > ' + field_unit_value + ' </td>'; 2602 str = str + '<td > ' + field_price_value + ' </td>'; 2603 str = str + '<td > ' + movement + ' </td>'; 2604 str = str + '<td > ' + field_date_value + ' </td>'; 2605 str = str + '</tr>'; 2606 } 2607 str = str + '</tbody>'; 2608 str = str + '</table>'; 2609 str = str + '</div>'; 2610 str = str + '</div>'; 2611 str = str + '</div>'; 2612 str = str + '</div>'; 2613 str = str + '</div></div>'; 2614 $("#divDailySearchDetailsModal").html(str); 2615 } 2616 } 2617 }); 2618 } 2619} 2620 2621 2622function priceSpreadDailyFrm() { 2623 2624 //alert("Called"); 2625 var assets_url = $("#assets_url").val(); 2626 2627 var productInput = $("#selProductInput").val(); 2628 var marketInput = $("#selMarketInput").val(); 2629 var termInput = $("#selTermsInput").val(); 2630 2631 var productOutput = $("#selProductOutput").val(); 2632 var marketOutput = $("#selMarketOutput").val(); 2633 var termOutput = $("#selTermsOutput").val(); 2634 2635 var currencySpread = $("#selCurrencySpread").val(); 2636 var frmDate = $("#psfrom-datepicker").val(); 2637 var toDate = $("#psto-datepicker").val(); 2638 2639 var minSelDate = new Date(); 2640 var pastYear = minSelDate.getFullYear() - 1; 2641 minSelDate.setFullYear(pastYear); 2642 2643 var oldDate = (minSelDate.getMonth() + 1) + '/' + minSelDate.getDate() + '/' + minSelDate.getFullYear(); 2644 2645 const date1 = new Date(frmDate); 2646 const date2 = new Date(toDate); 2647 const date3 = new Date(oldDate); 2648 const diffTimeFrm = date1 - date3; //Math.abs(date1 - date2); 2649 const diffDaysFrm = diffTimeFrm / (1000 * 60 * 60 * 24); //Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 2650 2651 const diffTimeTo = date2 - date3; //Math.abs(date1 - date2); 2652 const diffDaysTo = diffTimeTo / (1000 * 60 * 60 * 24); //Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 2653 2654 // alert(diffDaysFrm+'<==>'+diffDaysTo); 2655 if (productInput == '' || productOutput == '') { 2656 alert("Please select products"); 2657 } else if (marketInput == '' || marketOutput == '') { 2658 alert("Please select markets"); 2659 } else if (termInput == '' || termOutput == '') { 2660 alert("Please select terms"); 2661 } else if (currencySpread == "") { 2662 alert("Please select currency"); 2663 } else if (frmDate == "") { 2664 alert("Please select from date"); 2665 } else if (diffDaysFrm <= 0) { 2666 alert("Please select a date within the last 1 year. The module allows only 1 year of historical data."); 2667 } else if (toDate == "") { 2668 alert("Please select to date"); 2669 } else if (diffDaysTo <= 0) { 2670 alert("Please select a date within the last 1 year. The module allows only 1 year of historical data."); 2671 } else { 2672 2673 $.ajax({ 2674 url: '/wp-admin/admin-ajax.php', 2675 type: "POST", 2676 data: { 2677 action: 'getDailyPriceSpread', 2678 productInput: productInput, 2679 productOutput: productOutput, 2680 marketInput: marketInput, 2681 marketOutput: marketOutput, 2682 termInput: termInput, 2683 termOutput: termOutput, 2684 currencySpread: currencySpread, 2685 frmDate: frmDate, 2686 toDate: toDate, 2687 }, 2688 beforeSend: function() { 2689 $('#dailyPriceSpreadModal').modal(); 2690 $("#divDailyPriceSpreadModal").html("<div class='modal-header text-center'><div class='btn-wrap'><img src='" + assets_url + "images/[email protected]' width='50' height='50' align='center'></div></div>") 2691 }, 2692 success: function(data) { 2693 console.log(data); 2694 //alert("Processing"); 2695 console.log(data.data); 2696 var str = ""; 2697 if (data.data == "No Data Found") { 2698 2699 str = str + '<div class="modal-header text-center">'; 2700 str = str + '<div class="btn-wrap">'; 2701 //str = str + '<button type="button" onclick="downloadExcel
2701(\''+productSrch+'\',\''+marketSrch+'\',\''+termSrch+'\',\''+currencySrch+'\',\''+frmDate+'\',\''+toDate+'\',\'PriceSpread\')" class="set-btn ">download</button>'; 2702 str = str + '</div>'; 2703 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2704 str = str + '<div class="modal-body">'; 2705 2706 str = str + '<div class="modal-body-wrap">'; 2707 str = str + '<div class="container">'; 2708 str = str + '<div class="row">'; 2709 str = str + '<div class="col-12">'; 2710 str = str + '<div class="report-info">'; 2711 str = str + '<div class="sect sect-1">'; 2712 str = str + '<p class="set-bold">No Data Found</p>'; 2713 str = str + '</div></div>'; 2714 str = str + '</div>'; 2715 str = str + '</div>'; 2716 str = str + '</div>'; 2717 str = str + '</div></div>'; 2718 2719 $("#divDailyPriceSpreadModal").html(str); 2720 2721 } else if (data.data.includes("Download")) { 2722 //alert("data.data=>"+data.data); 2723 str = str + '<div class="modal-header text-center">'; 2724 str = str + '<div class="btn-wrap">'; 2725 //str = str + '<button type="button" onclick="downloadExcel(\''+productSrch+'\',\''+marketSrch+'\',\''+termSrch+'\',\''+currencySrch+'\',\''+frmDate+'\',\''+toDate+'\',\'PriceSpread\')" class="set-btn ">download</button>'; 2726 str = str + '</div>'; 2727 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2728 str = str + '<div class="modal-body">'; 2729 2730 str = str + '<div class="modal-body-wrap">'; 2731 str = str + '<div class="container">'; 2732 str = str + '<div class="row">'; 2733 str = str + '<div class="col-12">'; 2734 str = str + '<div class="report-info">'; 2735 str = str + '<div class="sect sect-1">'; 2736 str = str + '<p class="set-bold">' + data.data + '</p>'; 2737 str = str + '</div></div>'; 2738 str = str + '</div>'; 2739 str = str + '</div>'; 2740 str = str + '</div>'; 2741 str = str + '</div></div>'; 2742 2743 $("#divDailyPriceSpreadModal").html(str); 2744 2745 } else { 2746 //alert("IN Else==>"+data.data); 2747 var pnameRaw = data.data[0].pName; 2748 var splitpnameRaw = pnameRaw.split('@'); 2749 var splitpRawF = splitpnameRaw[0].split('###'); 2750 var splitpRawS = splitpnameRaw[1].split('###'); 2751 2752 var productInputName = ''; 2753 var productOutputName = ''; 2754 2755 if (splitpRawF[1] == 'input') { 2756 productInputName = splitpRawF[0]; 2757 } else if (splitpRawF[1] == 'output') { 2758 productOutputName = splitpRawF[0]; 2759 } 2760 2761 if (splitpRawS[1] == 'input') { 2762 productInputName = splitpRawS[0]; 2763 } else if (splitpRawS[1] == 'output') { 2764 productOutputName = splitpRawS[0]; 2765 } 2766 2767 var mnameRaw = data.data[0].mName; 2768 var splitmnameRaw = mnameRaw.split('@'); 2769 var splitmRawF = splitmnameRaw[0].split('###'); 2770 var splitmRawS = splitmnameRaw[1].split('###'); 2771 var marketInputName = ''; 2772 var marketOutputName = ''; 2773 2774 if (splitmRawF[1] == 'input') { 2775 marketInputName = splitmRawF[0]; 2776 } else if (splitmRawF[1] == 'output') { 2777 marketOutputName = splitmRawF[0]; 2778 } 2779 2780 if (splitmRawS[1] == 'input') { 2781 marketInputName = splitmRawS[0]; 2782 } else if (splitmRawS[1] == 'output') { 2783 marketOutputName = splitmRawS[0]; 2784 } 2785 2786 2787 str = str + '<div class="modal-header text-center">'; 2788 str = str + '<div class="btn-wrap">'; 2789 str = str + '<button type="button" onclick="downloadPriceSpreadExcel(\'' + productInput + '\',\'' + productOutput + '\',\'' + marketInput + '\',\'' + marketOutput + '\',\'' + termInput + '\',\'' + termOutput + '\',\'' + currencySpread + '\',\'' + frmDate + '\',\'' + toDate + '\',\'PriceSpread\')" class="set-btn ">download</button>'; 2790 str = str + '</div>'; 2791 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2792 str = str + '<div class="modal-body">'; 2793 2794 str = str + '<div class="modal-body-wrap">'; 2795 str = str + '<div class="container">'; 2796 str = str + '<div class="row">'; 2797 str = str + '<div class="col-12">'; 2798 str = str + '<div class="report-info">'; 2799 str = str + '<div class="sect sect-1">'; 2800 str = str + '<p class="set-bold">Input product</p>'; 2801 str = str + '<p class="grey-text">' + productInputName + ' - ' + marketInputName + ' - ' + termInput + '</p>'; 2802 str = str + '</div>'; 2803 str = str + '<div class="sect sect-2">'; 2804 str = str + '<p class="set-bold">output product</p>'; 2805 str = str + '<p class="grey-text">' + productOutputName + ' - ' + marketOutputName + ' - ' + termOutput + '</p>'; 2806 str = str + '</div>'; 2807 str = str + '</div>'; 2808 str = str + '<hr class="yellow-border">'; 2809 str = str + '</div>'; 2810 str = str + '<div class="col-12">'; 2811 str = str + '<div class="modal-table-wrapper">'; 2812 str = str + '<div class="table-responsive">'; 2813 str = str + '<table class="table fixed_header" align="center">'; 2814 str = str + '<thead>'; 2815 str = str + '<tr>'; 2816 str = str + '<th >Date</th>'; 2817 2818 if (currencySpread == 'EURO_price') 2819 var priceToShow = 'EURO/ton'; 2820 else 2821 var priceToShow = 'US/ton'; 2822 2823 str = str + '<th >Price Spread ' + priceToShow + '</th>'; 2824 str = str + '<th >Price %</th>'; 2825 str = str + '</tr>'; 2826 str = str + '</thead>'; 2827 str = str + '<tbody id="modalbodyscroll">'; 2828 for (z = 0; z < data.data.length; z++) { 2829 if (currencySpread == 'EURO_price' && data.data[z].euro_diff_percent != null) { 2830 str = str + '<tr>'; 2831 str = str + '<td > ' + data.data[z].field_date_value + ' </td>'; 2832 str = str + '<td > ' + data.data[z].euro_diff_amount + ' </td>'; 2833 str = str + '<td > ' + data.data[z].euro_diff_percent + ' </td>'; 2834 str = str + '</tr>'; 2835 } else if (currencySpread == 'US_price' && data.data[z].euro_diff_percent != null) { 2836 str = str + '<tr>'; 2837 str = str + '<td > ' + data.data[z].field_date_value + ' </td>'; 2838 str = str + '<td > ' + data.data[z].us_diff_amount + ' </td>'; 2839 str = str + '<td > ' + data.data[z].us_diff_percent + ' </td>'; 2840 str = str + '</tr>'; 2841 } 2842 } 2843 str = str + '</tbody>'; 2844 str = str + '</table>'; 2845 str = str + '</div>'; 2846 str = str + '</div>'; 2847 str = str + '</div>'; 2848 str = str + '</div>'; 2849 str = str + '</div></div>'; 2850 $("#divDailyPriceSpreadModal").html(str); 2851 } 2852 } 2853 }); 2854 } 2855} 2856 2857 2858function compProductDailyFrm() { 2859 2860 var assets_url = $("#assets_url").val();
2861 var productComp = []; 2862 $.each($("#selProductComp option:selected"), function() { 2863 productComp.push($(this).val()); 2864 }); 2865 2866 var marketComp = []; 2867 $.each($("#selMarketComp option:selected"), function() { 2868 marketComp.push($(this).val()); 2869 }); 2870 2871 var termComp = []; 2872 $.each($("#selTermsComp option:selected"), function() { 2873 termComp.push($(this).val()); 2874 }); 2875 2876 var currencyComp = $("#selCurrencyComp").val(); 2877 var frmDate = $("#cfrom-datepicker").val(); 2878 var toDate = $("#cto-datepicker").val(); 2879 2880 $.ajax({ 2881 url: '/wp-admin/admin-ajax.php', 2882 type: "POST", 2883 data: { 2884 action: 'getDailyCompareProduct', 2885 productComp: productComp, 2886 marketComp: marketComp, 2887 termComp: termComp, 2888 currencyComp: currencyComp, 2889 frmDate: frmDate, 2890 toDate: toDate, 2891 }, 2892 beforeSend: function() { 2893 $('#dailyProductCompareModal').modal(); 2894 $("#divDailyProductCompareModal").html("<div class='modal-header text-center'><div class='btn-wrap'><img src='" + assets_url + "images/[email protected]' width='50' height='50' align='center'></div></div>") 2895 }, 2896 success: function(data) { 2897 // console.log(data.data[0]); 2898 // console.log("-------"); 2899 // console.log(data.data[1]); 2900 2901 var new_graph = data.data[0]; 2902 var new_graph1 = data.data[1]; 2903 //alert("Processing"); 2904 //console.log(data.data); 2905 var str = ""; 2906 if (data.data == "No Data Found") { 2907 2908 str = str + '<div class="modal-header text-center">'; 2909 str = str + '<div class="btn-wrap">'; 2910 //str = str + '<button type="button" onclick="downloadExcel(\''+productSrch+'\',\''+marketSrch+'\',\''+termSrch+'\',\''+currencySrch+'\',\''+frmDate+'\',\''+toDate+'\',\'PriceSpread\')" class="set-btn ">download</button>'; 2911 str = str + '</div>'; 2912 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2913 str = str + '<div class="modal-body">'; 2914 2915 str = str + '<div class="modal-body-wrap">'; 2916 str = str + '<div class="container">'; 2917 str = str + '<div class="row">'; 2918 str = str + '<div class="col-12">'; 2919 str = str + '<div class="report-info">'; 2920 str = str + '<div class="sect sect-1">'; 2921 str = str + '<p class="set-bold">No Data Found</p>'; 2922 str = str + '</div></div>'; 2923 str = str + '</div>'; 2924 str = str + '</div>'; 2925 str = str + '</div>'; 2926 str = str + '</div></div>'; 2927 2928 $("#divDailyProductCompareModal").html(str); 2929 2930 } else if (data.data.includes("Download")) { 2931 2932 str = str + '<div class="modal-header text-center">'; 2933 str = str + '<div class="btn-wrap">'; 2934 //str = str + '<button type="button" onclick="downloadExcel(\''+productSrch+'\',\''+marketSrch+'\',\''+termSrch+'\',\''+currencySrch+'\',\''+frmDate+'\',\''+toDate+'\',\'PriceSpread\')" class="set-btn ">download</button>'; 2935 str = str + '</div>'; 2936 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2937 str = str + '<div class="modal-body">'; 2938 2939 str = str + '<div class="modal-body-wrap">'; 2940 str = str + '<div class="container">'; 2941 str = str + '<div class="row">'; 2942 str = str + '<div class="col-12">'; 2943 str = str + '<div class="report-info">'; 2944 str = str + '<div class="sect sect-1">'; 2945 str = str + '<p class="set-bold">' + data.data + '</p>'; 2946 str = str + '</div></div>'; 2947 str = str + '</div>'; 2948 str = str + '</div>'; 2949 str = str + '</div>'; 2950 str = str + '</div></div>'; 2951 2952 $("#divDailyProductCompareModal").html(str); 2953 2954 } else { 2955 str = str + '<div class="modal-header text-center">'; 2956 str = str + '<div class="btn-wrap">'; 2957 str = str + '<button type="button" onclick="downloadExcel
2957(\'' + productSrch + '\',\'' + marketSrch + '\',\'' + termSrch + '\',\'' + currencySrch + '\',\'' + frmDate + '\',\'' + toDate + '\',\'CompareProduct\')" class="set-btn ">download</button>'; 2958 str = str + '</div>'; 2959 str = str + '<button type="button" class="close" data-dismiss="modal"><span class="closeicon">×</span></button></div>'; 2960 str = str + '<div class="modal-body">'; 2961 2962 2963 str = str + '<div class="modal-body-wrap">'; 2964 str = str + '<div class="container">'; 2965 str = str + '<div class="row">'; 2966 str = str + '<div class="col-12">'; 2967 str = str + '<div class="report-info">Statistics'; 2968 str = str + '</div>'; 2969 str = str + '<hr class="yellow-border">'; 2970 str = str + '</div>'; 2971 str = str + '<div class="col-12">'; 2972 str = str + '<div class="modal-table-wrapper">'; 2973 str = str + '<div class="table-responsive" id="compareProductGraph">'; 2974 str = str + 'Graph Here'; 2975 str = str + '</div>'; 2976 str = str + '</div>'; 2977 str = str + '</div>'; 2978 str = str + '</div>'; 2979 str = str + '</div></div>'; 2980 $("#divDailyProductCompareModal").html(str); 2981 // Morris Line Chart 2982 // var tax_data = [data.data[0]]; 2983 // Morris.Line({ 2984 // element: 'compareProductGraph', 2985 // data: tax_data, 2986 // xkey: 'period', 2987 // xLabels: "day", 2988 // ykeys: [data.data[1]], 2989 // labels: [data.data[1]] 2990 // }); 2991 $("#compareProductGraph").html("Lets try the graph"); 2992 var data = [new_graph], 2993 config = { 2994 data: data, 2995 xkey: 'period', 2996 ykeys: [new_graph1], 2997 xLabels: 'day', 2998 labels: [new_graph1], 2999 fillOpacity: 0.6, 3000 hideHover: 'auto', 3001 behaveLikeLine: true, 3002 resize: true, 3003 pointFillColors: ['#ffffff'], 3004 pointStrokeColors: ['black'], 3005 lineColors: ['gray', 'red'] 3006 }; 3007 config.element = 'compareProductGraph'; 3008 Morris.Line(config); 3009 3010 3011 } 3012 3013 3014 } 3015 }); 3016} 3017 3018function downloadFiles(filePath, fileName) { 3019 //alert("filePath=>"+filePath+"<=fileName=>"+fileName) 3020 $.ajax({ 3021 url: '/wp-admin/admin-ajax.php', 3022 type: "POST", 3023 data: { 3024 action: 'downloadFilesFromServer', 3025 filePath: filePath, 3026 fileName: fileName, 3027 }, 3028 success: function(html) { 3029 //console.log(html); 3030 } 3031 }); 3032 3033} 3034 3035function openWeeklyDatewise() { 3036 3037 var domain_url = $("#domain_url").val() 3038 var weekly_pw_rpt = $("#weekly_pw_rpt").val(); 3039 var selectedDate = $("#cfrom-datepicker").val(); 3040 3041 var minSelDate = new Date(); 3042 var pastYear = minSelDate.getFullYear() - 2; 3043 minSelDate.setFullYear(pastYear); 3044 3045 var oldDate = (minSelDate.getMonth() + 1) + '/' + minSelDate.getDate() + '/' + minSelDate.getFullYear(); 3046 3047 const date1 = new Date(selectedDate); 3048 const date2 = new Date(oldDate); 3049 const diffTime = date1 - date2; //Math.abs(date1 - date2); 3050 const diffDays = diffTime / (1000 * 60 * 60 * 24); //Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 3051 3052 //alert("<==>"+date1+"<==>"+date2+"<=>"+diffDays); 3053 if (diffDays > 0) { 3054 $.ajax({ 3055 url: '/wp-admin/admin-ajax.php', 3056 type: "POST", 3057 data: {
3058 action: 'openWeeklyReportforDate', 3059 selectedDate: selectedDate, 3060 }, 3061 success: function(html) { 3062 //console.log(html.data[0]['path']); 3063 var fileName = html.data[0]['path']; 3064 // DOMAIN_URL.'/report-download/?action=browser&type='.$moduletype.'&key='.base64_encode($path) 3065 // window.open(weekly_pw_rpt + fileName, '_blank'); 3066 window.open(domain_url + '/report-download/?action=browser&type=pi&key=' + btoa(fileName), '_blank'); 3067 } 3068 }); 3069 } else { 3070 alert("Only last 2 years dates are allowed"); 3071 } 3072} 3073 3074 3075function downloadWeeklyDatewise() { 3076 3077 var domain_url = $("#domain_url").val() 3078 var weekly_pw_rpt = $("#selWeeklyDatePDF").val(); 3079 //alert(domain_url+"/download.php?filename="+weekly_pw_rpt); 3080 window.location.href = domain_url + "/download.php?filename=" + weekly_pw_rpt; 3081} 3082 3083function openPriceFCDatewise(reportType) { 3084 3085 var price_fc_rpt = $("#price_fc_rpt").val(); 3086 var selectedYear = $("#selYearPFCRpt").val(); 3087 $.ajax({ 3088 url: '/wp-admin/admin-ajax.php', 3089 type: "POST", 3090 data: { 3091 action: 'openPriceFCReportforDate', 3092 selectedYear: selectedYear, 3093 reportType: reportType, 3094 }, 3095 success: function(html) { 3096 //console.log(html.data); 3097 if (html.data != 'N') { 3098 $("#forcastscrollDIV").html(html.data); 3099 } else { 3100 alert("No Data Found"); 3101 } 3102 } 3103 }); 3104} 3105 3106function openFibreYarnExportDatewise(reportType) { 3107 3108 var fibre_yarn_export_rpt = $("#fibre_yarn_export_rpt").val(); 3109 var selectedYear = $("#selYearFYERpt").val(); 3110 $.ajax({ 3111 url: '/wp-admin/admin-ajax.php', 3112 type: "POST", 3113 data: { 3114 action: 'openFibreYarnReportforDate', 3115 selectedYear: selectedYear, 3116 reportType: reportType, 3117 }, 3118 success: function(html) { 3119 //console.log(html.data); 3120 if (html.data != 'N') { 3121 $("#exportscrollDIV").html(html.data); 3122 } else { 3123 alert("No Data Found"); 3124 } 3125 } 3126 }); 3127} 3128 3129function weeklyPriceWatchTable() { 3130 var assets_url = $("#assets_url").val(); 3131 3132 var beforeSendDiv = '<div class="loading-overlay text-center mt-3 mb-3"><div class="overlay-content">Loading Data.......</div></div>'; 3133 $.ajax({ 3134 url: '/wp-admin/admin-ajax.php', 3135 type: "POST", 3136 data: { 3137 action: 'get_pricewatch_table', 3138 }, 3139 beforeSend: function() { 3140 $("#divPriceWatchTable").html(beforeSendDiv); 3141 }, 3142 success: function(html) { 3143 //console.log(html.data); 3144 3145 if (html.data != 'N') { 3146 $("#divPriceWatchTable").html(html.data); 3147 $('.loading-overlay').fadeOut("slow"); 3148 } else { 3149 alert("No Data Found"); 3150 } 3151 //$(".scrollingDivContent").css({"overflow":"scroll","height":"300px","display":"block"}); 3152 } 3153 }); 3154} 3155 3156function displayGraph() { 3157 var domain_url = $("#domain_url").val() 3158 var frmDate = $("#from-datepicker").val(); 3159 var toDate = $("#to-datepicker").val(); 3160 var productIds = ""; 3161 var prodIDs = $('input:checked').map(function() { 3162 return $(this).val(); 3163 }); 3164 var mag_factor = $("#mag_factor").val(); 3165 var graph_type = $("#graph_type").val(); 3166 var pCount = 0; 3167 3168 var minSelDate = new Date(); 3169 var pastYear = minSelDate.getFullYear() - 2; 3170 minSelDate.setFullYear(pastYear); 3171 3172 var oldDate = (minSelDate.getMonth() + 1) + '/' + minSelDate.getDate() + '/' + minSelDate.getFullYear(); 3173 const date1 = new Date(frmDate); 3174 const date2 = new Date(toDate); 3175 const date3 = new Date(oldDate); 3176 const diffTimeFrm = date1 - date3; //Math.abs(date1 - date2); 3177 const diffDaysFrm = diffTimeFrm / (1000 * 60 * 60 * 24); //Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 3178 3179 const diffTimeTo = date2 - date3; //Math.abs(date1 - date2); 3180 const diffDaysTo = diffTimeTo / (1000 * 60 * 60 * 24); //Math.ceil(diffTime / (1000 * 60 * 60 * 24)); 3181 3182 //alert("<==>"+date1+"<==>"+date2+"<=>"+diffDaysFrm+'<==>'+diffDaysTo); 3183 3184 if (frmDate == "") { 3185 alert("Please select from date"); 3186 return false;
3187 } else if (toDate == "") { 3188 alert("Please select to date"); 3189 return false; 3190 } else if (diffDaysFrm < 0 || diffDaysTo < 0) { 3191 alert("Please select dates between last 2 years"); 3192 return false; 3193 } else if (prodIDs.length < 2) { 3194 alert("Please select atleast 2 products"); 3195 return false; 3196 } else { 3197 3198 for (i = 0; i < prodIDs.length; i++) { 3199 productIds = productIds + "@@" + prodIDs[i]; 3200 pCount++; 3201 } 3202 productIds = productIds.substring(2); 3203 //alert(productIds); 3204 productIds = encodeURIComponent(productIds); 3205 3206 var imgSrc = domain_url + "/weekly-graph-inner/?frmDate=" + frmDate + "&toDate=" + toDate + "&productIds=" + productIds + "&mag_factor=" + mag_factor + "&graph_type=" + graph_type; 3207 //console.log(imgSrc); 3208 $("#imgGraph").attr("src", imgSrc); 3209 } 3210} 3211 3212function editMyAccount(txtVal) { 3213 //alert("txtVal==>"+txtVal); 3214 3215 if (txtVal == 'firstname') { 3216 $("#divNameName").hide(); 3217 $("#divName").show(); 3218 } else if (txtVal == 'surname') { 3219 $("#divSurnameName").hide(); 3220 $("#divSurname").show(); 3221 } else if (txtVal == 'emailId') { 3222 $("#divEmailName").hide(); 3223 $("#divEmail").show(); 3224 } else if (txtVal == 'mobile') { 3225 $("#divMobileNo").hide(); 3226 $("#divMobile").show(); 3227 } else if (txtVal == 'country') { 3228 $("#divCountryName").hide(); 3229 $("#divCountry").show(); 3230 } else if (txtVal == 'company') { 3231 $("#divCompanyName").hide(); 3232 $("#divCompany").show(); 3233 } else if (txtVal == 'interest') { 3234 $("#divInterestName").hide(); 3235 $("#divInterest").show(); 3236 } 3237} 3238 3239function saveMyAcoount(txtVal) { 3240 var newVal = ''; 3241 var userIdVal = $("#txtUserId").val(); 3242 3243 if (txtVal == 'firstname') { 3244 newVal = $("#txtName").val(); 3245 //alert("newVal=>"+newVal); 3246 $.ajax({ 3247 url: '/wp-admin/admin-ajax.php', 3248 type: "POST", 3249 data: { 3250 action: 'editMyAccount', 3251 valueChange: txtVal, 3252 newValue: newVal, 3253 userId: userIdVal, 3254 }, 3255 success: function(html) { 3256 //console.log(html.data); 3257 if (html.data == 'Yes') { 3258 $("#divNameName").show(); 3259 $("#divNameName").html(newVal); 3260 $("#divName").hide(); 3261 } else { 3262 alert("Error"); 3263 } 3264 } 3265 }); 3266 3267 } else if (txtVal == 'surname') { 3268 newVal = $("#txtSurname").val(); 3269 //alert("newVal=>"+newVal); 3270 $.ajax({ 3271 url: '/wp-admin/admin-ajax.php', 3272 type: "POST", 3273 data: { 3274 action: 'editMyAccount', 3275 valueChange: txtVal, 3276 newValue: newVal, 3277 userId: userIdVal, 3278 }, 3279 success: function(html) { 3280 //console.log(html.data); 3281 if (html.data == 'Yes') { 3282 $("#divSurnameName").show(); 3283 $("#divSurnameName").html(newVal); 3284 $("#divSurname").hide(); 3285 } else { 3286 alert("Error"); 3287 } 3288 } 3289 }); 3290 3291 } else if (txtVal == 'emailId') { 3292 newVal = $("#txtEmailId").val(); 3293 3294 $.ajax({ 3295 url: '/wp-admin/admin-ajax.php', 3296 type: "POST", 3297 data: { 3298 action: 'editMyAccount', 3299 valueChange: txtVal, 3300 newValue: newVal, 3301 userId: userIdVal, 3302 }, 3303 success: function(html) { 3304 //console.log(html.data); 3305 if (html.data == 'Yes') { 3306 $("#divEmailName").show(); 3307 $("#divEmailName").html(newVal); 3308 $("#divEmail").hide(); 3309 } else { 3310 alert("Error"); 3311 } 3312 } 3313 }); 3314 3315 } else if (txtVal == 'mobile') { 3316 newVal = $("#txtMobile").val(); 3317 3318 $.ajax({ 3319 url: '/wp-admin/admin-ajax.php', 3320 type: "POST", 3321 data: { 3322 action: 'editMyAccount', 3323 valueChange: txtVal, 3324 newValue: newVal, 3325 userId: userIdVal, 3326 }, 3327 success: function(html) { 3328 //console.log(html.data); 3329 if (html.data == 'Yes') { 3330 $("#divMobileNo").show(); 3331 $("#divMobile").hide(); 3332 $("#divMobileNo").html(newVal); 3333 } else { 3334 alert("Error"); 3335 } 3336 } 3337 }); 3338 3339 } else if (txtVal == 'country') { 3340 newVal = $("#txtCountry").val(); 3341 3342 $.ajax({ 3343 url: '/wp-admin/admin-ajax.php', 3344 type: "POST", 3345 data: { 3346 action: 'editMyAccount', 3347 valueChange: txtVal, 3348 newValue: newVal, 3349 userId: userIdVal, 3350 }, 3351 success: function(html) { 3352 //console.log(html.data); 3353 if (html.data == 'Yes') { 3354 $("#divCountryName").show(); 3355 $("#divCountry").hide(); 3356 $("#divCountryName").html(newVal); 3357 } else { 3358 alert("Error"); 3359 } 3360 } 3361 }); 3362 3363 } else if (txtVal == 'company') { 3364 newVal = $("#txtCompanyName").val(); 3365 3366 $.ajax({ 3367 url: '/wp-admin/admin-ajax.php', 3368 type: "POST", 3369 data: { 3370 action: 'editMyAccount', 3371 valueChange: txtVal, 3372 newValue: newVal, 3373 userId: userIdVal, 3374 }, 3375 success: function(html) { 3376 //console.log(html.data); 3377 if (html.data == 'Yes') { 3378 $("#divCompanyName").show(); 3379 $("#divCompany").hide(); 3380 $("#divCompanyName").html(newVal); 3381 } else { 3382 alert("Error"); 3383 } 3384 } 3385 }); 3386 3387 3388 } else if (txtVal == 'interest') { 3389 newVal = $("#txtInterest").val(); 3390 3391 $.ajax({ 3392 url: '/wp-admin/admin-ajax.php', 3393 type: "POST", 3394 data: { 3395 action: 'editMyAccount', 3396 valueChange: txtVal, 3397 newValue: newVal, 3398 userId: userIdVal, 3399 }, 3400 success: function(html) { 3401 //console.log(html.data); 3402 if (html.data == 'Yes') { 3403 $("#divInterestName").show(); 3404 $("#divInterest").hide(); 3405 $("#divInterestName").html(newVal); 3406 } else { 3407 alert("Error"); 3408 } 3409 } 3410 }); 3411 3412 } else if (txtVal == 'all') { 3413 if ($("#txtFirstName").val() != '' && $("#txtLastName").val() != '' && $("#txtEmailId").val() != '' && $("#txtCompanyName").val() != '' && $("#selCountry").val() != '' && 3414 $("#txtMobile").val() != '' && $("#txtJobTitle").val() != '' && $("#primaryRole").val() != '' && 3415 $("#selInterest").val() != '') { 3416 $("#displayMsg").html(""); 3417 3418 var fName = $("#txtFirstName").val(); 3419 var lName = $("#txtLastName").val(); 3420 var uName = fName + " " + lName; 3421 //alert("uName=>"+uName); 3422 var emailId = $("#txtEmailId").val(); 3423 var countryName = $("#selCountry").val(); 3424 var newsletter = ''; //$("#txtNewsletter").val(); 3425 3426 var newsletter = $("#txtNewsletter").prop("checked") == true ? 'Y' : 'N'; 3427 var companyName = $("#txtCompanyName").val(); 3428 var mobile = $("#txtMobile").val(); 3429 var selInterest = $("#selInterest").val(); 3430 var txtJobTitle = $("#txtJobTitle").val(); 3431 var primaryRole = $("#primaryRole").val();
3432 var user_type = $("#user_type").prop("checked") == true ? "supplier" : "customer"; 3433 if (newsletter == '') { 3434 newsletter = 'N'; 3435 } 3436 $.ajax({ 3437 url: '/wp-admin/admin-ajax.php', 3438 type: "POST", 3439 data: { 3440 action: 'editMyAccount', 3441 valueChange: txtVal, 3442 uName: uName, 3443 emailId: emailId, 3444 countryName: countryName, 3445 newsletter: newsletter, 3446 companyName: companyName, 3447 mobile: mobile, 3448 selInterest: selInterest, 3449 txtJobTitle: txtJobTitle, 3450 primaryRole: primaryRole, 3451 user_type: user_type, 3452 userId: userIdVal, 3453 }, 3454 success: function(html) { 3455 console.log(html.data); 3456 if (html.data == 'Yes') { 3457 alert("Profile Updated Successfully"); 3458 3459 } else { 3460 alert("Error"); 3461 } 3462 } 3463 }); 3464 } else { 3465 $("#displayMsg").html("Please Enter All Details"); 3466 $("html, body").animate({ scrollTop: 0 }, "slow"); 3467 } 3468 } else if (txtVal == 'company_details') { 3469 if ($("#founded_in").val() != '' && 3470 $("#company_ownership").val() != '' && 3471 $("#head_office_country").val() != '' && 3472 $("#other_office_country").val() != '' && 3473 $("#nature_of_business").val() != '' && 3474 $("#employee_size").val() != '' && 3475 $("#uploaded_imgdata").attr("src") != '' && 3476 $("#company_desc").summernote('code') != '' && 3477 $("#shipping_area").val() != '' 3478 ) { 3479 $("#displayMsg").html(""); 3480 3481 var founded_in = $("#founded_in").val(); 3482 var company_ownership = $("#company_ownership").val(); 3483 var head_office_country = $("#head_office_country").val(); 3484 var other_office_country = $("#other_office_country").val(); 3485 var nature_of_business = $("#nature_of_business").val(); 3486 var employee_size = $("#employee_size").val(); 3487 var uploaded_imgdata = $("#uploaded_imgdata").attr("src"); 3488 var company_desc = $("#company_desc").summernote('code'); 3489 var shipping_area = $("#shipping_area").val(); 3490 var banner_img_url = $("#banner_img_url").val(); 3491 var formData = new FormData(); 3492 formData.append("action", "editMyAccount"); 3493 formData.append("valueChange", txtVal); 3494 formData.append("userId", userIdVal); 3495 formData.append("founded_in", founded_in); 3496 formData.append("company_ownership", company_ownership); 3497 formData.append("head_office_country", head_office_country); 3498 formData.append("other_office_country", other_office_country); 3499 formData.append("nature_of_business", nature_of_business); 3500 formData.append("employee_size", employee_size); 3501 formData.append("uploaded_imgdata", uploaded_imgdata); 3502 formData.append("company_desc", company_desc); 3503 formData.append("shipping_area", shipping_area); 3504 formData.append('banner_img', $('#banner_img')[0].files[0]); 3505 formData.append("banner_img_url", banner_img_url); 3506 3507 $.ajax({ 3508 url: '/wp-admin/admin-ajax.php', 3509 type: "POST", 3510 data: formData, 3511 contentType: false, 3512 processData: false, 3513 success: function(html) { 3514 console.log(html.data); 3515 if (html.data == 'Yes') { 3516 alert("Successfully Updated Company Details"); 3517 setTimeout(function(){ 3518 window.location.href = '/dashboard'; 3519 }, 500); 3520 3521 } else { 3522 alert("Error"); 3523 } 3524 } 3525 }); 3526 } else { 3527 $("#displayMsg").html("Please Enter All Details"); 3528 $("html, body").animate({ scrollTop: 0 }, "slow"); 3529 } 3530 } else if (txtVal == 'certificates') { 3531 if ($("#certificates").val() != '' && 3532 $("#sustainable_practices").val() != '' 3533 ) { 3534 $("#displayMsg").html(""); 3535 // var certificates = $("#certificates").val(); 3536 // var certificates_other = $("#certificates_other").val(); 3537 // var sustainable_practices = $("#sustainable_practices").val(); 3538 var report_link = $(".report_link"); 3539 var report_link_file = $(".report_link_file"); 3540 // var achievements = $("#achievements").val(); 3541 var flag = 0; 3542 var report_link_file_url = $(".report_link_file_url"); 3543 if (report_link.length != report_link_file_url.length) { 3544 for (let i = 0; i < report_link.length; i++) { 3545 console.log($(report_link_file[i])[0].files.length) 3546 if (($(report_link[i]).val() == '' || $(report_link_file[i])[0].files.length == 0) && report_link_file_url[i] === undefined) { 3547 flag = 1; 3548 } 3549 } 3550 3551 } 3552 var certificate_link = $(".certificate_link"); 3553 var certificate_link_file = $(".certificate_link_file"); 3554 var certificate_link_file_url = $(".certificate_link_file_url"); 3555 if (certificate_link.length != certificate_link_file_url.length) { 3556 for (let i = 0; i < certificate_link.length; i++) { 3557 console.log($(certificate_link_file[i])[0].files.length) 3558 if ($(certificate_link[i]).val() == '' || $(certificate_link_file[i])[0].files.length == 0 && certificate_link_file_url[i] === undefined) { 3559 flag = 1; 3560 } 3561 } 3562 } 3563 3564 var sustainable_practices_name = $(".sustainable_practices_name"); 3565 var sustainable_practices_remarks = $(".sustainable_practices_remarks"); 3566 3567 for (let i = 0; i < sustainable_practices_remarks.length; i++) { 3568 3569 if ($(sustainable_practices_name[i]).val() == '' || $(sustainable_practices_remarks[i]).val() == '') { 3570 flag = 1; 3571 } 3572 } 3573 3574 if (flag == 0) { 3575 var certificateForm = document.getElementById('certificateForm'); 3576 var formData = new FormData(certificateForm); 3577 formData.append("action", "editMyAccount"); 3578 formData.append("valueChange", txtVal); 3579 formData.append("userId", userIdVal); 3580 console.log(formData); 3581 $.ajax({ 3582 url: '/wp-admin/admin-ajax.php', 3583 type: "POST", 3584 processData: false, 3585 contentType: false, 3586 cache: false, 3587 data: formData, 3588 success: function(html) { 3589 console.log(html.data); 3590 if (html.data == 'Yes') { 3591 alert("Successfully Updated Certificates"); 3592 setTimeout(function(){ 3593 window.location.href = '/dashboard'; 3594 }, 500); 3595 3596 } else { 3597 alert("Error"); 3598 } 3599 } 3600 }); 3601 } else { 3602 $("#displayMsg").html("Please Enter All Details"); 3603 $("html, body").animate({ scrollTop: 0 }, "slow"); 3604 } 3605 } else { 3606 $("#displayMsg").html("Please Enter All Details"); 3607 $("html, body").animate({ scrollTop: 0 }, "slow"); 3608 } 3609 } 3610} 3611
3612function changePassMYAcc() { 3613 var userIdVal = $("#txtUserId").val(); 3614 var curPass = $("#current-pass").val(); 3615 var newPass = $("#new-pass").val(); 3616 var confNewPass = $("#confirm-new-pass").val(); 3617 3618 if (curPass == "") { 3619 $("#loginMsg").html('Please enter current password'); 3620 //alert("Pleae enter Current Password"); 3621 } else if (newPass == "") { 3622 $("#loginMsg").html('Please enter new password'); 3623 //alert("Please enter New Password"); 3624 } else if (confNewPass == "") { 3625 $("#loginMsg").html('Please enter confirm password'); 3626 //alert("Please enter Confirm Password"); 3627 } else if (confNewPass != newPass) { 3628 $("#loginMsg").html('New password & Confirm password are not matching'); 3629 //alert("New Password & Confirm Password are not matching"); 3630 } else { 3631 $.ajax({ 3632 url: '/wp-admin/admin-ajax.php', 3633 type: "POST", 3634 data: { 3635 action: 'changePassword', 3636 curPass: curPass, 3637 newPass: newPass, 3638 userId: userIdVal, 3639 }, 3640 success: function(html) { 3641 //console.log(html.data); 3642 $("#loginMsg").html(html.data); 3643 } 3644 }); 3645 3646 } 3647} 3648 3649$('#subsNewsLttr').click(function() { 3650 var userIdVal = $("#txtUserId").val(); 3651 var checkedVal = "" 3652 if ($(this).prop("checked") == true) { 3653 checkedVal = 'Y'; 3654 } else if ($(this).prop("checked") == false) { 3655 checkedVal = 'N'; 3656 } 3657 3658 $.ajax({ 3659 url: '/wp-admin/admin-ajax.php', 3660 type: "POST", 3661 data: { 3662 action: 'subscribeNewsLetter', 3663 checkedVal: checkedVal, 3664 userId: userIdVal, 3665 }, 3666 success: function(html) { 3667 //console.log(html.data); 3668 $("#subscrMsg").html(html.data); 3669 } 3670 }); 3671}); 3672 3673 3674$("#seePreviewBtnCompPro").click(function() { 3675 $("#product-preview").toggle(); 3676}); 3677 3678function editCompPro(txtVal) { 3679 3680 $("#display" + txtVal).hide(); 3681 $("#edit" + txtVal).show(); 3682} 3683 3684function saveCompPro(txtVal) { 3685 //alert("Clicked"); 3686 var userIdVal = $("#txtUserId").val(); 3687 var newVal = $("#val" + txtVal).val(); 3688 if (userIdVal != "") { 3689 //alert("In if user=>"+userIdVal); 3690 if (txtVal != "CompanyLogo") { 3691 //alert("In if value=>"+txtVal); 3692 3693 $.ajax({ 3694 url: '/wp-admin/admin-ajax.php', 3695 type: "POST", 3696 data: { 3697 action: 'editCompProfile', 3698 valueChange: txtVal, 3699 newValue: newVal, 3700 userId: userIdVal, 3701 }, 3702 success: function(html) { 3703 //console.log(html.data); 3704 if (html.data != 'Error') { 3705 $("#display" + txtVal).show(); 3706 $("#edit" + txtVal).hide(); 3707 $("#display" + txtVal).html(newVal); 3708 } else { 3709 alert("Error"); 3710 } 3711 } 3712 }); 3713 } else { 3714 //alert("In else=>"+newVal); 3715 //$('body').on('change', '#val'+txtVal, function() { 3716 } 3717 } 3718} 3719 3720$(document).on('click', '.uploadLogoFile', function(e) { 3721 var logo_image_url = $("#logo_image_url").val(); 3722 var userIdVal = $("#txtUserId").val(); 3723 var newVal = $('#valCompanyLogo').val(); 3724 var file_data = $('#valCompanyLogo').prop('files')[0]; 3725 var form_data = new FormData(); 3726 form_data.append('file', file_data); 3727 form_data.append('action', 'editCompProfile'); 3728 form_data.append('valueChange', 'CompanyLogo'); 3729 form_data.append('newValue', newVal); 3730 form_data.append('userId', userIdVal); 3731 3732 $.ajax({ 3733 url: '/wp-admin/admin-ajax.php', 3734 type: 'POST', 3735 contentType: false, 3736 processData: false, 3737 data: form_data, 3738 success: function(response) { 3739 $("#displayCompanyLogo").show(); 3740 $("#editCompanyLogo").hide();
3741 $("#showImage").attr("src", logo_image_url + response.data); 3742 3743 } 3744 }); 3745}); 3746 3747 3748$(function() { 3749 $(".enquire-now-btn").click(function() { 3750 var my_id_value = $(this).data('product-id'); 3751 //alert("Clicked=>"+my_id_value); 3752 $("#enquireNowModal #productId").val(my_id_value); 3753 }) 3754}); 3755 3756 3757 3758function checkAll(checkVal) { 3759 3760 //alert("clicked=>"+checkVal); 3761 $('.' + checkVal).attr('checked', 'checked'); 3762 //alert($(".chkBoxAll").val()); 3763} 3764 3765function checkAllProVal(status) { 3766 //$("#checkAllPro").change(function () { //"select all" change 3767 3768 // var status = this.checked; // "select all" checked status 3769 // alert("Cliek=>"+status); 3770 var selectValues = ''; 3771 $('.allProducts').each(function() { //iterate all listed checkbox items 3772 this.checked = status; //change ".checkbox" checked status 3773 selectValues = selectValues + ',' + this.value; 3774 }); 3775 selectValues = selectValues.substring(1); 3776 if (status == true) { 3777 $(".check-title").html("Deselect All"); 3778 $("#txtCheckAll").val(selectValues); 3779 3780 } else { 3781 $(".check-title").html("Select All"); 3782 $("#txtCheckAll").val(""); 3783 } 3784 //}); 3785} 3786 3787function addProductToEnq(checkedVal) { 3788 //alert("Before=>"+$("#txtCheckAll").val()); 3789 var actVal = $("#txtCheckAll").val(); 3790 if (actVal.includes(checkedVal)) { 3791 actVal = actVal.replace(checkedVal, ''); 3792 actVal = actVal.replace(',,', ','); 3793 } else { 3794 actVal = actVal + ',' + checkedVal; 3795 var firstChar = actVal.substring(0, 1); 3796 if (firstChar == ',') 3797 actVal = actVal.substring(1); 3798 } 3799 $("#txtCheckAll").val(actVal); 3800 //alert("After=>"+$("#txtCheckAll").val()); 3801} 3802 3803$("#checkBuyerPro").change(function() { //"select all" change 3804 var status = this.checked; // "select all" checked status 3805 $('.allProducts').each(function() { //iterate all listed checkbox items 3806 this.checked = status; //change ".checkbox" checked status 3807 }); 3808}); 3809$("#checkSellerPro").change(function() { //"select all" change 3810 var status = this.checked; // "select all" checked status 3811 $('.allProducts').each(function() { //iterate all listed checkbox items 3812 this.checked = status; //change ".checkbox" checked status 3813 }); 3814}); 3815 3816$(function() { 3817 $(".enqTab").click(function() { 3818 var my_id_value = $(this).data('active-tab'); 3819 // alert("Clicked=>"+my_id_value); 3820 $("#txtActiveTab").val(my_id_value); 3821 }) 3822}); 3823 3824 3825function checkConversations(selValue) { 3826 3827 var activeTab = $("#txtActiveTab").val(); 3828 var userIdVal = $("#userIdVal").val(); 3829 //alert("Clicek=>"+activeTab); 3830 $.ajax({ 3831 url: '/wp-admin/admin-ajax.php', 3832 type: "POST", 3833 data: { 3834 action: 'conversationsStatus', 3835 selectedVal: selValue, 3836 activeTab: activeTab, 3837 userId: userIdVal, 3838 }, 3839 success: function(html) { 3840 //console.log(html); 3841 if (html.data != 'N') { 3842 if (activeTab == 'Sent') { 3843 $("#displaySendConvData").html(html.data); 3844 } else if (activeTab == 'Received') { 3845 $("#displayReceiveConvData").html(html.data); 3846 } 3847 3848 } else { 3849 alert("No Data Found"); 3850 } 3851 } 3852 }); 3853} 3854 3855function fnProductEnquiry() { 3856 3857 var checkAllVal = $("#txtCheckAll").val(); 3858 var selectedPro = checkAllVal.replace(',', '@'); 3859 //alert("selectedPro=>"+selectedPro); 3860 //var multiProductId = explode(',', checkAllVal); 3861 var productId = $("#productId").val(); 3862 var txtFirstName = $("#first-name").val(); 3863 var txtLastName = $("#last-name").val(); 3864 var txtDesignation = $("#designation").val(); 3865 var txtCompanyName = $("#companyName").val(); 3866 var txtActualUser = $("input[name='account_type']:checked").val(); //$("#account_type").val(); 3867 var txtAddress1 = $("#address-1").val(); 3868 var txtAddress2 = $("#address-2").val(); 3869 var txtCity = $("#city").val(); 3870 var txtState = $("#provice").val(); 3871 var txtCountry = $("#valCountry").val(); 3872 var txtZipCode = $("#zip-code").val(); 3873 var txtTelephone = $("#telephone").val(); 3874 var txtMobile = $("#mobileNo").val(); 3875 var txtFax = $("#fax").val(); 3876 var txtEmail = $("#emailId").val(); 3877 var txtAlternateEmail = ''; //$("#txtAlternateEmail").val(); 3878 var txtWebsite = ''; //$("#txtWebsite").val(); 3879 var txtComment = $("#commentTab").val(); 3880 var memid = $("#userId").val(); 3881 3882 //alert("CLicked=>"+memid+"<=txtActualUser=>"+txtActualUser); 3883 3884 if (txtFirstName == '') { 3885 $("#proEnqMsg").html("Please enter first name"); 3886 return false;
3887 } else if (txtLastName == '') { 3888 $("#proEnqMsg").html("Please enter last name"); 3889 return false; 3890 } else if (txtCompanyName == '') { 3891 $("#proEnqMsg").html("Please enter company name"); 3892 return false; 3893 } else if (txtEmail == '') { 3894 $("#proEnqMsg").html("Please enter email Id"); 3895 return false; 3896 } else if (txtMobile == '') { 3897 $("#proEnqMsg").html("Please enter mobile no"); 3898 return false; 3899 } else { 3900 $.ajax({ 3901 url: '/wp-admin/admin-ajax.php', 3902 type: "POST", 3903 data: { 3904 action: 'productEnquiryForm', 3905 productId: productId, 3906 txtFirstName: txtFirstName, 3907 txtLastName: txtLastName, 3908 txtDesignation: txtDesignation, 3909 txtCompanyName: txtCompanyName, 3910 txtActualUser: txtActualUser, 3911 txtAddress1: txtAddress1, 3912 txtAddress2: txtAddress2, 3913 txtCity: txtCity, 3914 txtState: txtState, 3915 txtCountry: txtCountry, 3916 txtMobile: txtMobile, 3917 txtTelephone: txtTelephone, 3918 txtFax: txtFax, 3919 txtEmail: txtEmail, 3920 txtAlternateEmail: txtAlternateEmail, 3921 txtComment: txtComment, 3922 memid: memid, 3923 checkAllVal: selectedPro, 3924 txtZipCode: txtZipCode, 3925 }, 3926 success: function(html) { 3927 //console.log(html); 3928 if (html.data != 'N') { 3929 $("#proEnqMsg").html("Enquiry Sent Successfully"); 3930 } else { 3931 alert("No Data Found"); 3932 } 3933 } 3934 }); 3935 3936 } 3937 3938} 3939 3940 3941$(function() { 3942 $(".enquireServicePlan").click(function() { 3943 var my_id_value = $(this).data('plan-id'); 3944 //alert("Clicked=>"+my_id_value); 3945 $("#enquirePlanModal #planId").val(my_id_value); 3946 }) 3947}); 3948 3949 3950function getState(countryData) { 3951 //alert(countryData); 3952 3953 var countryVal = countryData.split('@'); 3954 countryId = countryVal[0]; 3955 planId = countryVal[1]; 3956 3957 $.ajax({ 3958 url: '/wp-admin/admin-ajax.php', 3959 type: "POST", 3960 data: { 3961 action: 'stateData', 3962 countryId: countryId, 3963 planId: planId, 3964 }, 3965 success: function(html) { 3966 //console.log(html); 3967 if (html.data != 'N') { 3968 $("#dvStateDisplay").html(html.data); 3969 } 3970 } 3971 }); 3972} 3973 3974 3975function getCity(stateData) { 3976 //alert(stateData); 3977 3978 var stateVal = stateData.split('@'); 3979 stateId = stateVal[0]; 3980 planId = stateVal[1]; 3981 3982 $.ajax({ 3983 url: '/wp-admin/admin-ajax.php', 3984 type: "POST", 3985 data: { 3986 action: 'cityData', 3987 stateId: stateId, 3988 planId: planId, 3989 }, 3990 success: function(html) { 3991 //console.log(html); 3992 if (html.data != 'N') { 3993 $("#dvCityDisplay").html(html.data); 3994 } 3995 } 3996 }); 3997} 3998 3999function getAmount(countryData) { 4000 //alert(countryData); 4001 4002 var countryVal = countryData.split('@'); 4003 countryId = countryVal[0]; 4004 planId = countryVal[1]; 4005 4006 $.ajax({ 4007 url: '/wp-admin/admin-ajax.php', 4008 type: "POST", 4009 data: { 4010 action: 'amountData', 4011 countryId: countryId, 4012 planId: planId, 4013 }, 4014 success: function(html) { 4015 //console.log(html); 4016 if (html.data != 'N') { 4017 $("#dvPayableAmt").html(html.data); 4018 } 4019 } 4020 }); 4021} 4022 4023 4024function getIndiaAmt(stateData) { 4025 //alert(stateData); 4026 4027 var stateVal = stateData.split('@'); 4028 stateId = stateVal[0]; 4029 planId = stateVal[1]; 4030 4031 $.ajax({ 4032 url: '/wp-admin/admin-ajax.php', 4033 type: "POST", 4034 data: { 4035 action: 'indiaAmountData', 4036 stateId: stateId, 4037 planId: planId, 4038 }, 4039 success: function(html) { 4040 //console.log(html); 4041 if (html.data != 'N') { 4042 $("#dvPayableAmt").html(html.data); 4043 } 4044 } 4045 }); 4046} 4047 4048function markFavorite(newsId, userId, flag) { 4049 //alert(newsId+'<=>'+userId+'<==>'+flag); 4050 $.ajax({ 4051 url: '/wp-admin/admin-ajax.php', 4052 type: "POST", 4053 data: { 4054 action: 'markMyFavorite', 4055 newsId: newsId, 4056 userId: userId, 4057 flag: flag, 4058 }, 4059 success: function(html) { 4060 //console.log(html); 4061 if (flag == 'Add') { 4062 var str = '<i class="fas fa-heart fa-heart-yellow" id="fav' + newsId + '" onclick="markFavorite(\'' + newsId + '\',\'' + userId + '\',\'Remove\')"></i>'; 4063 $("#favAddRemove" + newsId).html(str); 4064 //$("#fav"+newsId).removeClass('far'); 4065 // $("#fav"+newsId).addClass('fas'); 4066 } else if (flag == 'Remove') { 4067 var str = '<i class="far fa-heart hearticon-change" id="fav' + newsId + '" onclick="markFavorite(\'' + newsId + '\',\'' + userId + '\',\'Add\')"></i>'; 4068 $("#favAddRemove" + newsId).html(str); 4069 // $("#fav"+newsId).removeClass('fas'); 4070 // $("#fav"+newsId).addClass('far'); 4071 } else if (flag == 'FavRemove') { 4072 $("#fav" + newsId).removeClass('fas'); 4073 $("#fav" + newsId).addClass('far'); 4074 loadMyNewsData(); 4075 } 4076 } 4077 }); 4078} 4079 4080function deleteProduct(productId, userId) { 4081 if (productId != '' && userId != '') { 4082 if (confirm("Are you sure you want to delete this Product?")) { 4083 4084 $.ajax({ 4085 url: '/wp-admin/admin-ajax.php', 4086 type: "POST", 4087 data: { 4088 action: 'deleteMyProduct', 4089 productId: productId, 4090 userId: userId, 4091 }, 4092 success: function(html) { 4093 //console.log(html);
4094 if (html.data != 'Error') { 4095 alert('Product Deleted'); 4096 loadViewProductData(); 4097 } 4098 } 4099 }); 4100 } else { 4101 return false; 4102 } 4103 } 4104} 4105 4106function addToWishList(param, productId, title, sub_cat, userId, flag) { 4107 //alert(productId+"<=>"+userId+"<==>"+flag); 4108 if ($(param).hasClass("fav_wish_list")) { 4109 $(param).removeClass("fav_wish_list") 4110 $(param).addClass("fa-heart-o") 4111 $(param).removeClass("fa-heart") 4112 } else { 4113 $(param).addClass("fav_wish_list") 4114 $(param).removeClass("fa-heart-o") 4115 $(param).addClass("fa-heart") 4116 } 4117 if (productId != '' && title != '' && sub_cat != '' && userId != '' && flag != '') { 4118 $.ajax({ 4119 url: '/wp-admin/admin-ajax.php', 4120 type: "POST", 4121 data: { 4122 action: 'addProductToWishlist', 4123 productId: productId, 4124 userId: userId, 4125 sub_cat: sub_cat, 4126 title: title, 4127 flag: flag, 4128 }, 4129 success: function(html) { 4130 if (flag == '1') { 4131 alert("Product added to wishlist"); 4132 } else { 4133 alert("Product removed to wishlist"); 4134 } 4135 4136 // setTimeout(function() { location.reload(); }, 3000); 4137 //console.log(html); 4138 // if (flag == 'Add') { 4139 // var str = '<i class="fas fa-star fa-star-yellow" id="fav' + productId + '" onclick="addToWishList(\'' + productId + '\',\'' + userId + '\',\'Remove\')"></i>'; 4140 // $("#favAddRemove" + productId).html(str); 4141 // } else if (flag == 'Remove') { 4142 // var str = '<i class="far fa-star hearticon-change" id="fav' + productId + '" onclick="addToWishList(\'' + productId + '\',\'' + userId + '\',\'Add\')"></i>'; 4143 // $("#favAddRemove" + productId).html(str); 4144 // } else if (flag == 'favRemove') { 4145 // loadMyProductWishData(); 4146 // } 4147 } 4148 }); 4149 } 4150} 4151 4152 4153 4154// Kishor 4155function openModal() { 4156 document.getElementById("img_modal_marketplace").style.display = "block"; 4157} 4158 4159function closeModal() { 4160 document.getElementById("img_modal_marketplace").style.display = "none"; 4161} 4162 4163var slideIndex = 1; 4164showSlides(slideIndex); 4165 4166function plusSlides(n) { 4167 showSlides(slideIndex += n); 4168} 4169 4170function currentSlide(n) { 4171 showSlides(slideIndex = n); 4172} 4173 4174function showSlides(n) { 4175 try { 4176 4177 var i; 4178 var slides = document.getElementsByClassName("img_mySlides"); 4179 var captionText = document.getElementById("caption"); 4180 if (n > slides.length) { 4181 slideIndex = 1 4182 } 4183 if (n < 1) { 4184 slideIndex = slides.length 4185 } 4186 for (i = 0; i < slides.length; i++) { 4187 slides[i].style.display = "none"; 4188 } 4189 slides[slideIndex - 1].style.display = "block"; 4190 4191 } catch (error) { 4192 4193 } 4194} 4195 4196 4197 4198 4199 4200 4201var banner_slideIndex = 1; 4202banner_showSlides(banner_slideIndex); 4203 4204// Next/previous controls 4205function banner_plusSlides(n) { 4206 banner_showSlides(banner_slideIndex += n); 4207} 4208 4209// Thumbnail image controls 4210function banner_currentSlide(n) { 4211 banner_showSlides(banner_slideIndex = n); 4212} 4213 4214function banner_showSlides(n) { 4215 try { 4216 var i; 4217 var slides = document.getElementsByClassName("banner_mySlides"); 4218 if (n > slides.length) { 4219 banner_slideIndex = 1 4220 } 4221 if (n < 1) { 4222 banner_slideIndex = slides.length 4223 } 4224 for (i = 0; i < slides.length; i++) { 4225 slides[i].style.display = "none"; 4226 } 4227 slides[banner_slideIndex - 1].style.display = "block"; 4228 } catch (error) { 4229 4230 } 4231} 4232 4233 4234// function addToWishList(param) { 4235// if ($(param).hasClass("fav_wish_list")) { 4236// $(param).removeClass("fav_wish_list") 4237// $(param).addClass("fa-heart-o") 4238// $(param).removeClass("fa-heart") 4239// } else { 4240// $(param).addClass("fav_wish_list") 4241// $(param).removeClass("fa-heart-o") 4242// $(param).addClass("fa-heart") 4243// } 4244// } 4245$(document).ready(function() { 4246 // $('.product_child_category').on('click', function() { 4247 // $(this).addClass('active'); 4248 4249 // $.ajax({ 4250 // type: 'POST', 4251 // url: '/wp-admin/admin-ajax.php', 4252 // dataType: 'html', 4253 // data: { 4254 // action: 'filter_projects', 4255 // category: $(this).data('slug'), 4256 // }, 4257 // success: function(res) { 4258 // $('.project-tiles').html(res); 4259 // } 4260 // }) 4261 // }); 4262 if ($(".trending_search").length > 0) { 4263 $(".trending_search ul li a").each(function(i, obj) { 4264 var url = new URL($(this).attr("href")); 4265 // url.searchParams.append("post_type", "product"); 4266 var s = url.searchParams.get("s"); 4267 // $(this).attr("href", url.href) 4268 $(this).attr("href", "#"); 4269 $(this).attr("onclick", "setSearchValue('" + s + "')"); 4270 }); 4271 } 4272 if ($('.customer-logos').length > 0) { 4273 var slides = $(".slide").length; 4274 var mobile_slides = $(".slide").length; 4275 if (slides > 4) { 4276 mobile_slides = 3; 4277 } else { 4278 slides = 4; 4279 } 4280 $('.customer-logos').slick({ 4281 slidesToShow: slides, 4282 slidesToScroll: 1, 4283 autoplay: false, 4284 autoplaySpeed: 1000, 4285 arrows: true, 4286 dots: false, 4287 pauseOnHover: false, 4288 responsive: [{ 4289 breakpoint: 768, 4290 settings: { 4291 slidesToShow: slides 4292 } 4293 }, { 4294 breakpoint: 520, 4295 settings: { 4296 slidesToShow: mobile_slides 4297 } 4298 }] 4299 }); 4300 } 4301}); 4302 4303function change_country_code() { 4304 $("#phone_country_code").html("+" + $("#country").find(':selected').data('country_id') + "-"); 4305} 4306 4307function change_country_code_reg() { 4308 $("#phone_country_code").html("+" + $("#selCountry").find(':selected').data('country_id') + "-"); 4309} 4310 4311function setSearchValue(s) { 4312 $("#s").val(s); 4313 searchProduct() 4314} 4315 4316function searchProduct() { 4317 var s = $("#s").val(); 4318 var orderby_value = $(".orderby").val(); 4319 var orderby = $(".orderby").find(':selected').data("order_column"); 4320 var orderby_sort = $(".orderby").find(':selected').data("order_sort"); 4321 var product_price_min = $("#product_price_min").val(); 4322 var product_price_max = $("#product_price_max").val(); 4323 var product_child_category_filter = $(".product_child_category_filter"); 4324 var place_of_origin_filter = $(".place_of_origin_filter"); 4325 var req_for_price = $(".req_for_price"); 4326 var sustainable_practices_filter = $(".sustainable_practices_filter"); 4327 var certifications_filter = $(".certifications_filter"); 4328 var supplier_status_filter = $(".supplier_status_filter"); 4329 var type_of_supplier_filter = $(".type_of_supplier_filter"); 4330 var product_child_category = []; 4331 var place_of_origin = []; 4332 var sustainable_practices = []; 4333 var certifications = []; 4334 var supplier_status = []; 4335 var type_of_supplier = []; 4336 var filter_apply = 0; 4337 var html = '<button class="reset_filter" style="color: #ffa300;" onclick="reset_search_filter()">Reset All Filters <span class="reset_cancel">X</span></button>'; 4338 for (let i = 0; i < product_child_category_filter.length; i++) { 4339 if ($(product_child_category_filter[i]).hasClass("filter_active")) { 4340 product_child_category.push($(product_child_category_filter[i]).data('slug')); 4341 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'product_child_category_filter'" + ',' + "'" + $(product_child_category_filter[i]).data('slug') + "'" + ')">' + $(product_child_category_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4342 filter_apply = 1; 4343 } 4344 } 4345 for (let i = 0; i < place_of_origin_filter.length; i++) { 4346 if ($(place_of_origin_filter[i]).hasClass("filter_active")) { 4347 place_of_origin.push($(place_of_origin_filter[i]).data('slug')); 4348 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'place_of_origin_filter'" + ',' + "'" + $(place_of_origin_filter[i]).data('slug') + "'" + ')">' + $(place_of_origin_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4349 filter_apply = 1; 4350 } 4351 } 4352 4353 for (let i = 0; i < req_for_price.length; i++) { 4354 if ($(req_for_price[i]).hasClass("filter_active")) { 4355 // place_of_origin.push($(req_for_price[i]).data('slug')); 4356 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'req_for_price'" + ',' + "'" + $(req_for_price[i]).data('slug') + "'" + ')">' + $(req_for_price[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4357 filter_apply = 1; 4358 } 4359 } 4360 for (let i = 0; i < sustainable_practices_filter.length; i++) { 4361 if ($(sustainable_practices_filter[i]).hasClass("filter_active")) { 4362 sustainable_practices.push($(sustainable_practices_filter[i]).data('slug')); 4363 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'sustainable_practices_filter'" + ',' + "'" + $(sustainable_practices_filter[i]).data('slug') + "'" + ')">' + $(sustainable_practices_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4364 filter_apply = 1; 4365 } 4366 } 4367 for (let i = 0; i < certifications_filter.length; i++) { 4368 if ($(certifications_filter[i]).hasClass("filter_active")) { 4369 certifications.push($(certifications_filter[i]).data('slug')); 4370 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'certifications_filter'" + ',' + "'" + $(certifications_filter[i]).data('slug') + "'" + ')">' + $(certifications_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4371 filter_apply = 1; 4372 } 4373 } 4374 for (let i = 0; i < supplier_status_filter.length; i++) { 4375 if ($(supplier_status_filter[i]).hasClass("filter_active")) { 4376 supplier_status.push($(supplier_status_filter[i]).data('slug')); 4377 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'supplier_status_filter'" + ',' + "'" + $(supplier_status_filter[i]).data('slug') + "'" + ')">' + $(supplier_status_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4378 filter_apply = 1; 4379 } 4380 } 4381 for (let i = 0; i < type_of_supplier_filter.length; i++) { 4382 if ($(type_of_supplier_filter[i]).hasClass("filter_active")) { 4383 type_of_supplier.push($(type_of_supplier_filter[i]).data('slug')); 4384 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'type_of_supplier_filter'" + ',' + "'" + $(type_of_supplier_filter[i]).data('slug') + "'" + ')">' + $(type_of_supplier_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4385 filter_apply = 1; 4386 } 4387 } 4388 if (s != '') { 4389 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'s'" + ',' + "'" + s + "'" + ')">' + s + ' <span class="reset_cancel">X</span></button>'; 4390 filter_apply = 1; 4391 } // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'" + orderby + "'" + ')">' + orderby + ' <span class="reset_cancel">X</span></button>'; 4392 if (product_price_min != '') { 4393 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'product_price_min'" + ',' + "'" + product_price_min + "'" + ')">Min Price-$' + product_price_min + ' <span class="reset_cancel">X</span></button>'; 4394 filter_apply = 1; 4395 } 4396 if (product_price_max != '') { 4397 html += '<button class="reset_filter" onclick="reset_search_filter(' + "'product_price_max'" + ',' + "'" + product_price_max + "'" + ')">Max Price-$' + product_price_max + ' <span class="reset_cancel">X</span></button>'; 4398 filter_apply = 1; 4399 } 4400 if (filter_apply == 1) 4401 $("#reset_filter_div").html(html) 4402 else 4403 $("#reset_filter_div").html("") 4404 4405 $.ajax({ 4406 type: 'POST', 4407 url: '/wp-admin/admin-ajax.php', 4408 dataType: 'html', 4409 data: { 4410 action: 'filter_projects', 4411 s: s, 4412 orderby: orderby, 4413 orderby_sort: orderby_sort, 4414 product_child_category: product_child_category, 4415 place_of_origin: place_of_origin, 4416 sustainable_practices: sustainable_practices, 4417 certifications: certifications, 4418 product_price_min: product_price_min,
4419 product_price_max: product_price_max, 4420 supplier_status: supplier_status, 4421 type_of_supplier: type_of_supplier 4422 }, 4423 success: function(res) { 4424 $('.project-tiles').html(res); 4425 $('.orderby').val(orderby_value); 4426 $('.orderby').change(function() { 4427 searchProduct() 4428 }); 4429 } 4430 }) 4431} 4432 4433function product_filter_ajax(param) { 4434 if (!$(param).hasClass('filter_active')) 4435 $(param).addClass('filter_active'); 4436 else 4437 $(param).removeClass('filter_active'); 4438 4439 searchProduct(); 4440 // var s = $("#s").val(); 4441 // var orderby = $(".orderby").val(); 4442 // var product_price_min = $("#product_price_min").val(); 4443 // var product_price_max = $("#product_price_max").val(); 4444 // var product_child_category_filter = $(".product_child_category_filter"); 4445 // var place_of_origin_filter = $(".place_of_origin_filter"); 4446 // var sustainable_practices_filter = $(".sustainable_practices_filter"); 4447 // var certifications_filter = $(".certifications_filter"); 4448 // var product_child_category = []; 4449 // var place_of_origin = []; 4450 // var sustainable_practices = []; 4451 // var certifications = []; 4452 // var filter_apply = 0; 4453 // var html = '<button class="reset_filter" onclick="reset_search_filter()">Reset All Filters <span class="reset_cancel">X</span></button>'; 4454 // for (let i = 0; i < product_child_category_filter.length; i++) { 4455 // if ($(product_child_category_filter[i]).hasClass("filter_active")) { 4456 // product_child_category.push($(product_child_category_filter[i]).data('slug')); 4457 // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'product_child_category_filter'" + ',' + "'" + $(product_child_category_filter[i]).data('slug') + "'" + ')">' + $(product_child_category_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4458 // filter_apply = 1; 4459 // } 4460 // } 4461 // for (let i = 0; i < place_of_origin_filter.length; i++) { 4462 // if ($(place_of_origin_filter[i]).hasClass("filter_active")) { 4463 // place_of_origin.push($(place_of_origin_filter[i]).data('slug')); 4464 // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'place_of_origin_filter'" + ',' + "'" + $(place_of_origin_filter[i]).data('slug') + "'" + ')">' + $(product_child_category_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4465 // filter_apply = 1; 4466 // } 4467 // } 4468 // for (let i = 0; i < sustainable_practices_filter.length; i++) { 4469 // if ($(sustainable_practices_filter[i]).hasClass("filter_active")) { 4470 // sustainable_practices.push($(sustainable_practices_filter[i]).data('slug')); 4471 // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'sustainable_practices_filter'" + ',' + "'" + $(sustainable_practices_filter[i]).data('slug') + "'" + ')">' + $(product_child_category_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4472 // filter_apply = 1; 4473 // } 4474 // } 4475 // for (let i = 0; i < certifications_filter.length; i++) { 4476 // if ($(certifications_filter[i]).hasClass("filter_active")) { 4477 // certifications.push($(certifications_filter[i]).data('slug')); 4478 // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'certifications_filter'" + ',' + "'" + $(certifications_filter[i]).data('slug') + "'" + ')">' + $(product_child_category_filter[i]).data('slug') + ' <span class="reset_cancel">X</span></button>'; 4479 // filter_apply = 1; 4480 // } 4481 // } 4482 // if (s != '') { 4483 // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'s'" + ',' + "'" + s + "'" + ')">' + s + ' <span class="reset_cancel">X</span></button>'; 4484 // filter_apply = 1; 4485 // } // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'" + orderby + "'" + ')">' + orderby + ' <span class="reset_cancel">X</span></button>'; 4486 // if (product_price_min != '') { 4487 // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'product_price_min'" + ',' + "'" + product_price_min + "'" + ')">Min Price-$' + product_price_min + ' <span class="reset_cancel">X</span></button>'; 4488 // filter_apply = 1; 4489 // } 4490 // if (product_price_max != '') { 4491 // html += '<button class="reset_filter" onclick="reset_search_filter(' + "'product_price_max'" + ',' + "'" + product_price_max + "'" + ')">Max Price-$' + product_price_max + ' <span class="reset_cancel">X</span></button>'; 4492 // filter_apply = 1; 4493 // } 4494 // if (filter_apply == 1) 4495 // $("#reset_filter_div").html(html) 4496 // $.ajax({ 4497 // type: 'POST', 4498 // url: '/wp-admin/admin-ajax.php', 4499 // dataType: 'html', 4500 // data: { 4501 // action: 'filter_projects', 4502 // s: s, 4503 // orderby: orderby, 4504 // product_child_category: product_child_category, 4505 // place_of_origin: place_of_origin, 4506 // sustainable_practices: sustainable_practices, 4507 // certifications: certifications, 4508 // product_price_min: product_price_min,
4509 // product_price_max: product_price_max 4510 // }, 4511 // success: function(res) { 4512 // $('.project-tiles').html(res); 4513 // $('.orderby').val(orderby); 4514 // $('.orderby').change(function() { 4515 // searchProduct() 4516 // }); 4517 // } 4518 // }) 4519} 4520 4521function reset_search_filter(type = '', value = '') { 4522 if (type == '') { 4523 $(".category_filter_ul_child li").removeClass("filter_active"); 4524 $(".place_of_origin_filter").removeClass("filter_active"); 4525 $(".req_for_price").removeClass("filter_active"); 4526 4527 $(".sustainable_practices_filter").removeClass("filter_active"); 4528 $(".sustainable_practices_filter").prop('checked', false); 4529 $(".certifications_filter").removeClass("filter_active"); 4530 $(".certifications_filter").prop('checked', false); 4531 $(".type_of_supplier_filter").removeClass("filter_active"); 4532 $(".type_of_supplier_filter").prop('checked', false); 4533 $(".supplier_status_filter").removeClass("filter_active"); 4534 $(".supplier_status_filter").prop('checked', false); 4535 $("#s").val(""); 4536 $(".orderby").val(""); 4537 $("#product_price_min").val(""); 4538 $("#product_price_max").val(""); 4539 } 4540 if (type == "product_child_category_filter") { 4541 $(".product_child_category_filter[data-slug='" + value + "']").removeClass("filter_active"); 4542 } 4543 if (type == "place_of_origin_filter") { 4544 $(".place_of_origin_filter[data-slug='" + value + "']").removeClass("filter_active"); 4545 $(".place_of_origin_filter[data-slug='" + value + "']").prop('checked', false); 4546 } 4547 if (type == "req_for_price") { 4548 $(".req_for_price[data-slug='" + value + "']").removeClass("filter_active"); 4549 $(".req_for_price[data-slug='" + value + "']").prop('checked', false); 4550 } 4551 if (type == "sustainable_practices_filter") { 4552 $(".sustainable_practices_filter[data-slug='" + value + "']").removeClass("filter_active"); 4553 $(".sustainable_practices_filter[data-slug='" + value + "']").prop('checked', false); 4554 } 4555 if (type == "certifications_filter") { 4556 $(".certifications_filter[data-slug='" + value + "']").removeClass("filter_active"); 4557 $(".certifications_filter[data-slug='" + value + "']").prop('checked', false); 4558 } 4559 if (type == "type_of_supplier_filter") { 4560 $(".type_of_supplier_filter[data-slug='" + value + "']").removeClass("filter_active"); 4561 $(".type_of_supplier_filter[data-slug='" + value + "']").prop('checked', false); 4562 } 4563 if (type == "supplier_status_filter") { 4564 $(".supplier_status_filter[data-slug='" + value + "']").removeClass("filter_active"); 4565 $(".supplier_status_filter[data-slug='" + value + "']").prop('checked', false); 4566 } 4567 if (type == "s") { 4568 $("#s").val(""); 4569 } 4570 if (type == "product_price_min") { 4571 $("#product_price_min").val(""); 4572 } 4573 if (type == "product_price_max") { 4574 $("#product_price_max").val(""); 4575 } 4576 searchProduct(); 4577} 4578 4579function change_sustainability_search(param) { 4580 var sustainability = JSON.parse($("#sustainability_array").val()); 4581 var html = ''; 4582 for (i = 0; i < sustainability.length; i++) { 4583 if (sustainability[i][0].indexOf(param.value) != -1) { 4584 html += '<label class="main_filter_checkbox">'; 4585 html += '<input type="checkbox" onclick="product_filter_ajax(this)" data-slug="' + sustainability[i][0] + '" class="sustainable_practices_filter">'; 4586 html += '<span class="geekmark"></span>' + sustainability[i][0] + '</label>'; 4587 } 4588 } 4589 $("#sustainability_search").html(html); 4590} 4591 4592function change_certificates_search(param) { 4593 var certificates = JSON.parse($("#certificates_array").val()); 4594 var html = ''; 4595 for (i = 0; i < certificates.length; i++) { 4596 if (certificates[i][0].indexOf(param.value) != -1) { 4597 html += '<label class="main_filter_checkbox">'; 4598 html += '<input type="checkbox" onclick="product_filter_ajax(this)" data-slug="' + certificates[i][0] + '" class="certifications_filter">'; 4599 html += '<span class="geekmark"></span>' + certificates[i][0] + '</label>'; 4600 } 4601 } 4602 $("#certificates_search").html(html); 4603} 4604 4605 4606 4607$(document).ready(function() { 4608 $(document).on("scroll", onScroll); 4609 4610 $('a[href*=\\#]').bind('click', function(e) { 4611 e.preventDefault(); // prevent hard jump, the default behavior 4612 4613 var target = $(this).attr("href"); // Set the target as variable 4614 if (target.indexOf("tab-") == -1) { 4615 $('html, body').animate({ 4616 scrollTop: ($(target).offset().top - 200) 4617 }, 500); 4618 } 4619 4620 return false;
4621 }); 4622 4623 4624}); 4625 4626function onScroll(event) { 4627 var scrollPos = $(document).scrollTop(); 4628 4629 $('.supplier_header_menu a').each(function() { 4630 var currLink = $(this); 4631 var refElement = $(currLink.attr("href")); 4632 if (refElement.position().top - 200 <= scrollPos && refElement.position().top - 200 + refElement.height() > scrollPos) { 4633 $('.supplier_header_menu ul li a').removeClass("active"); 4634 currLink.addClass("active"); 4635 } else { 4636 currLink.removeClass("active"); 4637 } 4638 }); 4639} 4640 4641function openNextRegForm(id) { 4642 if (id == 1) { 4643 if ($("#txtFirstName").val() != '' && $("#txtLastName").val() != '' && $("#txtEmailId").val() != '' && $("#txtImageCaptcha").val() != '') { 4644 sendOTP(); 4645 } else { 4646 toastr.error('Please Enter All Details'); 4647 $("html, body").animate({ scrollTop: 0 }, "slow"); 4648 } 4649 } 4650 if (id == 2) { 4651 var otp_input = $(".otp_input"); 4652 var error = 0; 4653 var otp = ''; 4654 for (let i = 0; i < otp_input.length; i++) { 4655 if ($(otp_input[i]).val() == '') { 4656 error = 1; 4657 } else { 4658 otp += '' + $(otp_input[i]).val(); 4659 } 4660 } 4661 if (error == 1) { 4662 toastr.error('Please Enter OTP'); 4663 $("html, body").animate({ scrollTop: 0 }, "slow"); 4664 } else { 4665 validateOTP(otp); 4666 } 4667 } 4668 if (id == 3) { 4669 if ($("#txtCompanyName").val() != '' && 4670 $("#txtMobile").val() != '' && $("#txtPassword").val() != '' && $("#txtConfPassword").val() != '' && $("#txtJobTitle").val() != '' && $("#primaryRole").val() != '' && 4671 $("#selInterest").val() != '') { 4672 if (($("#txtPassword").val() == $("#txtConfPassword").val())) { 4673 $("#reg_div_2").show(); 4674 $("#reg_div_1").hide(); 4675 $("#otp_div").hide(); 4676 $("#reg_div").hide(); 4677 $("#reg_div_3").hide(); 4678 } else { 4679 toastr.error('Please Enter Same Password'); 4680 $("html, body").animate({ scrollTop: 0 }, "slow"); 4681 } 4682 } else { 4683 toastr.error('Please Enter All Details'); 4684 $("html, body").animate({ scrollTop: 0 }, "slow"); 4685 } 4686 } 4687 if (id == 4) { 4688 if (($("#nature_of_business").val() != "") && ($("#employee_size").val() != "") && ($("#where_ref").val() != "")) { 4689 if ($('#terms_cond').is(':checked')) { 4690 if ($("#where_ref").val() == "Other") { 4691 if ($("#where_ref_other").val() == "") { 4692 toastr.error('Please Enter All Details'); 4693 $("html, body").animate({ scrollTop: 0 }, "slow"); 4694 } else { 4695 registerUser(); 4696 } 4697 } else { 4698 registerUser(); 4699 } 4700 } else { 4701 toastr.error('Please indicate that you accept the Terms and Conditions'); 4702 $("html, body").animate({ scrollTop: 0 }, "slow"); 4703 } 4704 } else { 4705 toastr.error('Please Enter All Details'); 4706 $("html, body").animate({ scrollTop: 0 }, "slow"); 4707 } 4708 } 4709} 4710 4711function changePlan(id, param) { 4712 $("#plan_selected").val(id); 4713 $(".plan_btn").html("Select"); 4714 $(".plan_btn").closest(".card").removeClass("active_plan"); 4715 $(param).html("Selected"); 4716 $(param).closest(".card").addClass("active_plan"); 4717} 4718 4719function openPrevRegForm(id) { 4720 if (id == 0) { 4721 $("#dvLogin").show(); 4722 $("#dvLogin1").hide(); 4723 $("#dvLogin2").hide(); 4724 } 4725 if (id == 1) { 4726 if ($("#user_type").prop("checked") == true) { 4727 $("#dvLogin").hide(); 4728 $("#dvLogin1").show(); 4729 $(".seller_div_input").show(); 4730 $(".buyer_div_input").hide(); 4731 $("#dvLogin2").hide(); 4732 } else { 4733 $("#dvLogin1").show(); 4734 $("#dvLogin").hide(); 4735 $("#dvLogin2").hide(); 4736 $(".buyer_div_input").show(); 4737 $(".seller_div_input").hide(); 4738 4739 } 4740 } 4741} 4742function sendOTP() { 4743 if (parseInt($("#opt_send_count").html()) == 3) { 4744 toastr.error("Limit reached to send otp"); 4745 } else { 4746 var fName = $("#txtFirstName").val(); 4747 var lName = $("#txtLastName").val(); 4748 var uName = fName + " " + lName; 4749 var emailId = $("#txtEmailId").val(); 4750 var imgCaptcha = $("#txtImageCaptcha").val(); 4751 4752 $.ajax({ 4753 url: '/wp-admin/admin-ajax.php', 4754 type: "POST", 4755 data: { 4756 action: 'sendOTP', 4757 uName: uName, 4758 emailId: emailId, 4759 imgCaptcha: imgCaptcha 4760 }, 4761 beforeSend: function (xhr) { 4762 $(".km-loader-parent").css('display', 'flex'); 4763 }, 4764 success: function (data) { 4765 $(".km-loader-parent").hide(); 4766 if (data.data.error == 0) { 4767 $("#opt_send_count").html(parseInt($("#opt_send_count").html()) + 1); 4768 $("#otp_div").show(); 4769 $("#reg_div").hide(); 4770 $("#reg_div_1").hide(); 4771 $("#reg_div_2").hide(); 4772 toastr.success(data.data.msg); 4773 } else { 4774 toastr.error(data.data.msg); 4775 } 4776 } 4777 }); 4778 } 4779} 4780function validateOTP(otp) { 4781 4782 $.ajax({ 4783 url: '/wp-admin/admin-ajax.php', 4784 type: "POST", 4785 data: { 4786 action: 'validateOTP', 4787 otp: otp 4788 }, 4789 beforeSend: function (xhr) { 4790 $(".km-loader-parent").css('display', 'flex'); 4791 }, 4792 success: function (data) { 4793 $(".km-loader-parent").hide(); 4794 if (data.data.error == 0) { 4795 $("#reg_div_1").show(); 4796 $("#otp_div").hide(); 4797 $("#reg_div").hide(); 4798 $("#reg_div_2").hide(); 4799 $("#reg_div_3").hide(); 4800 toastr.success(data.data.msg); 4801 } else { 4802 toastr.error(data.data.msg); 4803 } 4804 } 4805 }); 4806} 4807 4808function selectUserType(type, param) { 4809 $(".user_type").removeClass("active"); 4810 if (type == "buyer") { 4811 $("#user_type").attr("checked", false); 4812 $(".buyer_div").addClass("active"); 4813 } else { 4814 $("#user_type").attr("checked", true); 4815 $(".seller_div").addClass("active"); 4816 } 4817} 4818 4819function cloneReportDiv() { 4820 var html = '<div class="row report_div"><div class="col-md-5 col-lg-5 col-sm-12">' + 4821 '<input type="text" class="form-control report_link" name="report_link[]" placeholder="Report Name" onkeypress="return onlyLetter(event)">' + 4822 '<input type="hidden" class="form-control report_link_id" name="report_link_id[]" value="
48220" placeholder="Report Name">' + 4823 '</div>' + 4824 '<div class="col-md-5 col-lg-5 col-sm-12">' + 4825 '<input type="file" class="form-control report_link_file" name="report_link_file[]" >' + 4826 '</div>' + 4827 '<div class="col-md-2 col-lg-2 col-sm-12">' + 4828 '<button type="button" onclick="removeReportDiv(this)" class="set-btn " style="margin-top: 4px;">-</button>' + 4829 '</div>' + 4830 '</div>'; 4831 var report_div = $(".report_div"); 4832 $(report_div[report_div.length - 1]).after(html); 4833} 4834 4835function removeReportDiv(param) { 4836 $(param).closest(".row").remove(); 4837} 4838 4839function sendEnquiry(type = 0) { 4840 if (type == 0) { 4841 var fname = $("#fname").val(); 4842 var lname = $("#lname").val(); 4843 var email_id = $("#email_id").val(); 4844 var country = $("#country").val(); 4845 var number = $("#number").val(); 4846 var company = $("#company").val(); 4847 var designation = $("#designation").val(); 4848 var message = $("#message").val(); 4849 var user_id = $("#user_id").val(); 4850 var shop_id = $("#shop_id").val(); 4851 var product_id = $("#product_id").val(); 4852 $.ajax({ 4853 url: '/wp-admin/admin-ajax.php', 4854 type: "POST", 4855 data: { 4856 action: 'sendEnquiry', 4857 fname: fname, 4858 lname: lname, 4859 email_id: email_id, 4860 country: country, 4861 number: number, 4862 company: company, 4863 designation: designation, 4864 message: message, 4865 user_id: user_id, 4866 shop_id: shop_id, 4867 product_id: product_id, 4868 type: type 4869 }, 4870 beforeSend: function(msg) { 4871 $(".loading").show() 4872 }, 4873 success: function(html) { 4874 $(".loading").hide() 4875 //console.log(html.data); 4876 if (html.data == 'Yes') { 4877 // alert("Enquiry send successfully"); 4878 $(".enquiry_success").hide(); 4879 $("#enquiry_success_msg").show(); 4880 } else { 4881 alert("Error"); 4882 } 4883 } 4884 }); 4885 } else { 4886 var inquiry_id = $("#inquiry_id").val(); 4887 var user_type = $("#user_type").val(); 4888 var supplier_message_text = $("#supplier_message_text").val(); 4889 $.ajax({ 4890 url: '/wp-admin/admin-ajax.php', 4891 type: "POST", 4892 data: { 4893 action: 'sendEnquiry', 4894 inquiry_id: inquiry_id, 4895 user_type: user_type, 4896 supplier_message_text: supplier_message_text, 4897 type: type 4898 }, 4899 beforeSend: function(msg) { 4900 $(".loading").show() 4901 }, 4902 success: function(html) { 4903 $(".loading").hide() 4904 //console.log(html.data); 4905 if (html.data == 'Yes') { 4906 $("#supplier_message_text").val(""); 4907 alert("Message sent successfully"); 4908 $.ajax({ 4909 url: '/wp-admin/admin-ajax.php', 4910 type: "POST", 4911 data: { 4912 action: 'inquiry_chat_message', 4913 inquiry_id: inquiry_id, 4914 user_type: user_type 4915 }, 4916 success: function(html) { 4917 $("#old_chat").html(html.data); 4918 4919 } 4920 }); 4921 } else { 4922 alert("Error"); 4923 } 4924 } 4925 }); 4926 } 4927} 4928 4929function close_collapse_menu(param, id) { 4930 if ($("#" + id).hasClass("show")) { 4931 $(param).addClass("collapsed"); 4932 console.log(id) 4933 $("#" + id).removeClass("show"); 4934 } else { 4935 $(param).removeClass("collapsed"); 4936 console.log(id) 4937 $("#" + id).addClass("show"); 4938 } 4939} 4940 4941function show_tab_div(div_id, param) { 4942 console.log("as"); 4943 $(".activeProDiv").removeClass('active'); 4944 $(param).addClass('active'); 4945 $(".tab-pane-pro").removeClass('active'); 4946 $(div_id).addClass('active'); 4947}
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.