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