1"use strict"; 2 3/* --------------------------------------------------------------------------------------------------------------------------------------------------- 4 5Common-Functions or events 6 1.login-Module 7 2.Product-Module 8 3.Category-Module 9 4.Order-Module 10 5.Featured_Section-Module 11 6.Notifation-Module 12 7.Faq-Module 13 8.Slider-Module 14 9.Offer-Module 15 10.Promo_code-Module 16 11.Delivery_boys-Module 17 12.Settings-Module 18 13.City-Module 19 14.Transaction_Module 20 15.Customer-Wallet-Module 21 16.Fund-Transfer-Module 22 17.Return-Request-Module 23 18.Tax-Module 24 19.Image Upload 25 20.Client Api Key Module 26 21.System Users 27--------------------------------------------------------------------------------------------------------------------------------------------------- */ 28 29 30$(document).ready(function () { 31 $('#loading').hide(); 32}); 33 34var from = 'admin'; 35if (window.location.href.indexOf("seller/") > -1) { 36 var from = 'seller'; 37} 38 39 40$.event.special.touchstart = { 41 setup: function (_, ns, handle) { 42 this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") }); 43 } 44}; 45$(document).ready(function () { 46 $('.kv-fa').rating({ 47 theme: 'krajee-fa', 48 filledStar: '<i class="fas fa-star"></i>', 49 emptyStar: '<i class="far fa-star"></i>', 50 showClear: false, 51 size: 'md' 52 }); 53}); 54 55 56$(document).on('load-success.bs.table', '#product-rating-table', function (event) { 57 58 $('.kv-fa').rating({ 59 theme: 'krajee-fa', 60 filledStar: '<i class="fas fa-star"></i>', 61 emptyStar: '<i class="far fa-star"></i>', 62 showClear: false, 63 size: 'md' 64 }); 65 66}); 67 68$(document).on('load-success.bs.table', '#products_table', function (event) { 69 70 $('.kv-fa').rating({ 71 theme: 'krajee-fa', 72 filledStar: '<i class="fas fa-star"></i>', 73 emptyStar: '<i class="far fa-star"></i>', 74 showClear: false, 75 size: 'md' 76 }); 77 78}); 79 80$(document).on('column-switch.bs.table', '#products_table', function (event) { 81 82 $('.kv-fa').rating({ 83 theme: 'krajee-fa', 84 filledStar: '<i class="fas fa-star"></i>', 85 emptyStar: '<i class="far fa-star"></i>', 86 showClear: false, 87 size: 'md' 88 }); 89 90}); 91 92 93$(document).on('click', '.delete-product-rating', function () { 94 var cat_id = $(this).data('id'); 95 Swal.fire({ 96 title: 'Are You Sure!', 97 text: "You won't be able to revert this!", 98 type: 'warning', 99 showCancelButton: true, 100 confirmButtonColor: '#3085d6', 101 cancelButtonColor: '#d33', 102 confirmButtonText: 'Yes, delete it!', 103 showLoaderOnConfirm: true, 104 preConfirm: function () { 105 return new Promise((resolve, reject) => { 106 $.ajax({ 107 type: 'GET', 108 url: base_url + 'admin/product/delete_rating', 109 data: { id: cat_id }, 110 dataType: 'json' 111 }) 112 .done(function (response, textStatus) { 113 if (response.error == false) { 114 Swal.fire('Deleted!', response.message, 'success'); 115 $('table').bootstrapTable('refresh'); 116 csrfName = response['csrfName']; 117 csrfHash = response['csrfHash']; 118 } else { 119 Swal.fire('Oops...', response.message, 'warning'); 120 $('table').bootstrapTable('refresh'); 121 csrfName = response['csrfName']; 122 csrfHash = response['csrfHash']; 123 } 124 }) 125 .fail(function (jqXHR, textStatus, errorThrown) { 126 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 127 csrfName = response['csrfName']; 128 csrfHash = response['csrfHash']; 129 }); 130 }); 131 }, 132 allowOutsideClick: false 133 }); 134}); 135 136 137 138 139iziToast.settings({ 140 position: 'topRight', 141}); 142 143$("[data-toggle=tooltip").tooltip(); 144 145var attributes_values_selected = []; 146var variant_values_selected = []; 147var value_check_array = []; 148var attributes_selected_variations = []; 149var attributes_values = []; 150var pre_selected_attr_values = []; 151var current_attributes_selected = []; 152var current_variants_selected = []; 153var attribute_flag = 0; 154var pre_selected_attributes_name = [] 155var current_selected_image; 156var attributes_values = []; 157var all_attributes_values = []; 158var counter = 0; 159var variant_counter = 0; 160 161//------------- 162//- CATEGORY EISE PRODUCT SALE CHART - 163//------------- 164// Get context with jQuery - using jQuery's .get() method. 165 166 167if (document.getElementById('piechart_3d')) { 168 $.ajax({ 169 url: base_url + from + '/home/category_wise_product_count', 170 type: 'GET', 171 dataType: 'json', 172 success: function (result) { 173 google.charts.load("current", { packages: ["corechart"] }); 174 google.charts.setOnLoadCallback(drawChart); 175 function drawChart() { 176 177 var data = google.visualization.arrayToDataTable(result); 178 var options = { 179 title: '', 180 is3D: true, 181 }; 182 183 var chart = new google.visualization.PieChart(document.getElementById('piechart_3d')); 184 chart.draw(data, options); 185 } 186 } 187 }); 188 189 190 191 $.ajax({ 192 url: base_url + from + '/home/fetch_sales', 193 type: 'GET', 194 dataType: 'json', 195 success: function (result) { 196 $(window).on, 197 function (e, t, a) { 198 "use strict"; 199 var n, s, i, o, r, l, h, c; 200 n = function (e, t, a) { 201 var n = new Chartist.Line("#" + e, { 202 labels: t, 203 series: [a] 204 }, { 205 lineSmooth: Chartist.Interpolation.simple({ 206 divisor: 2 207 }), 208 fullWidth: !0, 209 chartPadding: { 210 right: 25 211 }, 212 series: { 213 "series-1": { 214 showArea: !1 215 } 216 }, 217 axisX: { 218 showGrid: !1 219 }, 220 axisY: { 221 labelInterpolationFnc: function (e) { 222 return e / 1e3 + "K" 223 }, 224 scaleMinSpace: 40 225 }, 226 low: 0, 227 showPoint: !1, 228 height: 300 229 }); 230 n.on("created", (function (t) { 231 var a = t.svg.querySelector("defs") || t.svg.elem("defs"), 232 n = (t.svg.width(), t.svg.height(), a.elem("filter", { 233 x: 0, 234 y: "-10%", 235 id: "shadow" + e 236 }, "", !0)); 237 return n.elem("feGaussianBlur", { 238 in: "SourceAlpha", 239 stdDeviation: "24", 240 result: "offsetBlur" 241 }), n.elem("feOffset", { 242 dx: "0", 243 dy: "32" 244 }), n.elem("feBlend", { 245 in: "SourceGraphic", 246 mode: "multiply" 247 }), a.elem("linearGradient", { 248 id: e + "-gradient", 249 x1: 0, 250 y1: 0, 251 x2: 1, 252 y2: 0 253 }).elem("stop", { 254 offset: 0, 255 "stop-color": "rgba(22, 141, 238, 1)" 256 }).parent().elem("stop", { 257 offset: 1, 258 "stop-color": "rgba(98, 188, 246, 1)" 259 }), a 260 })).on("draw", (function (t) { 261 "line" === t.type ? t.element.attr({ 262 filter: "url(#shadow" + e + ")" 263 }) : "point" === t.type && new Chartist.Svg(t.element._node.parentNode).elem("line", { 264 x1: t.x, 265 y1: t.y, 266 x2: t.x + .01, 267 y2: t.y, 268 class: "ct-point-content" 269 }), "line" !== t.type && "area" != t.type || t.element.animate({ 270 d: { 271 begin: 1e3 * t.index, 272 dur: 1e3, 273 from: t.path.clone().scale(1, 0).translate(0, t.chartRect.height()).stringify(), 274 to: t.path.clone().stringify(), 275 easing: Chartist.Svg.Easing.easeOutQuint 276 } 277 }) 278 })) 279 }, 280 s = result[2].day, i = { 281 name: "series-1", 282 data: result[2].total_sale 283 }, 284 o = result[1].week, 285 r = { 286 name: "series-1", 287 data: result[1].total_sale 288 }, 289 l = result[0].month_name, 290 h = { 291 name: "series-1", 292 data: result[0].total_sale 293 }, (c = function (e) { 294 switch ((e || a("#ecommerceChartView .chart-action").find(".active")).attr("href")) { 295 case "#scoreLineToDay": 296 n("scoreLineToDay", s, i); 297 break; 298 case "#scoreLineToWeek": 299 n("scoreLineToWeek", o, r); 300 break; 301 case "#scoreLineToMonth": 302 n("scoreLineToMonth", l, h) 303 } 304 }
304)(), a(".chart-action li a").on("click", (function () { 305 c(a(this)) 306 })) 307 }(window, document, jQuery); 308 } 309 }); 310 311 312} 313 314 315 316$(document).on("click", '[data-toggle="lightbox"]', function (event) { 317 event.preventDefault(); 318 $(this).ekkoLightbox(); 319}); 320 321 322 323var url = window.location.origin + window.location.pathname; 324var $selector = $('.sidebar a[href="' + url + '"]'); 325$($selector).addClass('active'); 326$($selector).closest('ul').closest('li').addClass('menu-open'); 327$($selector).closest('ul').removeAttr('style'); 328$($selector).closest('ul').closest('li').find('a[href*="#"').addClass('active'); 329 330 331 332 333 334var tmp = []; 335var permute_counter = 0; 336 337//User defined functions 338 339 340function copyToClipboard(element) { 341 var $temp = $("<input>"); 342 $("body").append($temp); 343 $temp.val($(element).text()).select(); 344 document.execCommand("copy"); 345 $temp.remove(); 346} 347 348function containsAll(needles, haystack) { 349 for (var i = 0; i < needles.length; i++) { 350 if ($.inArray(needles[i], haystack) == -1) return false; 351 } 352 return true; 353} 354 355function getPermutation(args) { 356 var r = [], 357 max = args.length - 1; 358 359 function helper(arr, i) { 360 for (var j = 0, l = args[i].length; j < l; j++) { 361 var a = arr.slice(0); // clone arr 362 a.push(args[i][j]); 363 if (i == max) 364 r.push(a); 365 else 366 helper(a, i + 1); 367 } 368 } 369 helper([], 0); 370 return r; 371} 372 373 374function clear_form_elements(class_name) { 375 jQuery("." + class_name).find(':input').each(function () { 376 switch (this.type) { 377 case 'password': 378 case 'text': 379 case 'textarea': 380 case 'file': 381 case 'select-one': 382 case 'select-multiple': 383 case 'date': 384 case 'number': 385 case 'tel': 386 case 'email': 387 jQuery(this).val(''); 388 break; 389 case 'checkbox': 390 case 'radio': 391 this.checked = false; 392 break; 393 } 394 }); 395} 396 397 398 399function add_product_variant_html(type) { 400 401 if (type == 'packet') { 402 var html = "<div class='row offset-md-1 border-bottom ml-5 mr-5 mb-3'><div class='col-md-12 mt-2 remove_pro_btn'><div class='card-tools float-right'> <label>Remove</label> <button type='button' class='btn btn-tool' id='remove_product_btn'> <i class='text-danger far fa-times-circle fa-2x '></i> </button></div></div><div class='form-group col-md-4'> <label for='inputPassword' class='col-sm-4 col-form-label'>Measurement</label><div class='col-sm-10'> <span><input type='number' name='packet_measurement[]' ></span></div></div><div class='form-group col-md-4'> <label for='inputPassword' class='col-sm-6 col-form-label'>Unit</label><div class='col-sm-6'> <select class='form-control valid' name='packet_measurement_unit_id[]' aria-invalid='false'><option value='1'>kg</option><option value='2'>gm</option><option value='3'>ltr</option><option value='4'>ml</option><option value='5'>pack</option> </select></div></div><div class='form-group col-md-4'> <label for='inputPassword' class='col-sm-4 col-form-label'>Price</label><div class='col-sm-10'> <span><input type='number' class='price' name='packet_price[]'></span></div></div><div class='form-group col-md-4'> <label for='inputPassword' class='col-sm-4 col-form-label'>Discounted Price</label><div class='col-sm-10'> <span><input type='number' class='discount' name='packet_discnt[]'></span></div></div><div class='form-group col-md-4'> <label for='inputPassword' class='col-sm-4 col-form-label'>Stock</label><div class='col-sm-10'> <input type='number' name='packet_stock[]'></div></div><div class='form-group col-md-4'> <label for='inputPassword' class='col-sm-4 col-form-label'>Unit</label><div class='col-sm-6'> <select class='form-control valid' name='packet_stock_unit_id[]' aria-invalid='false'><option value='1'>kg</option><option value='2'>gm</option><option value='3'>ltr</option><option value='4'>ml</option><option value='5'>pack</option> </select></div></div><div class='form-group col-md-4'> <label for='inputPassword' class='col-sm-4 col-form-label'>Status</label><div class='col-sm-6'> <select name='packet_serve_for[]' class='form-control' required='' aria-invalid='false'><option value='Available'>Available</option><option value='Sold Out'>Sold Out</option> </select></div></div></div>"; 403 return html; 404 } else { 405 var html = '<div class="row offset-md-1 border-bottom ml-5 mr-5 mb-3"><div class="col-md-12 mt-2 remove_pro_btn"><div class="card-tools float-right"> <label>Remove</label> <button type="button" class="btn btn-tool" id="remove_product_bt
405n"> <i class="text-danger far fa-times-circle fa-2x "></i> </button></div></div><div class="form-group col-md-3 col-12"> <label for="inputPassword" class="col-sm-12 col-form-label">Measurement</label><div class="col-12"> <span><input type="number" name="loose_measurement[]" class="col-12" ></span></div></div><div class="form-group col-md-3"> <label for="inputPassword" class="col-sm-6 col-form-label">Unit</label><div class="col-sm-12"> <select class="form-control valid" name="loose_measurement_unit_id[] col-12" aria-invalid="false"><option value="1">kg</option><option value="2">gm</option><option value="3">ltr</option><option value="4">ml</option><option value="5">pack</option> </select></div></div><div class="form-group col-md-3"> <label for="inputPassword" class="col-sm-4 col-form-label">Price</label><div class="col-sm-10"> <span><input type="number" name="loose_price[]" class="col-12 price"></span></div></div><div class="form-group col-md-3"> <label for="inputPassword" class="col-sm-12 col-form-label">Discounted Price</label><div class="col-sm-10"> <span><input type="number" name="loose_discnt[]" class="col-12 discount"></span></div></div></div>'; 406 return html; 407 } 408 409} 410 411 412function save_attributes() { 413 414 415 416 attributes_values = []; 417 all_attributes_values = []; 418 var tmp = $('.product-attr-selectbox'); 419 $.each(tmp, function (index) { 420 var data = $(tmp[index]).closest('.row').find('.multiple_values').select2('data'); 421 var tmp_values = []; 422 for (var i = 0; i < data.length; i++) { 423 if (!$.isEmptyObject(data[i])) { 424 tmp_values[i] = data[i].id; 425 } 426 } 427 if (!$.isEmptyObject(data)) { 428 all_attributes_values.push(tmp_values); 429 } 430 if ($(tmp[index]).find('.is_attribute_checked').is(':checked')) { 431 if (!$.isEmptyObject(data)) { 432 attributes_values.push(tmp_values); 433 } 434 } 435 }); 436 437 438} 439 440function create_variants(preproccessed_permutation_result = false, from) { 441 442 var html = ""; 443 var is_appendable = false; 444 var permutated_attribute_value = []; 445 if (preproccessed_permutation_result != false) { 446 var response = preproccessed_permutation_result; 447 is_appendable = true; 448 } else { 449 var response = getPermutation(attributes_values); 450 } 451 var selected_variant_ids = JSON.stringify(response); 452 var selected_attributes_values = JSON.stringify(attributes_values); 453 454 $('.no-variants-added').hide(); 455 $.ajax({ 456 type: 'GET', 457 url: base_url + from + '/product/get_variants_by_id', 458 data: { 459 variant_ids: selected_variant_ids, 460 attributes_values: selected_attributes_values, 461 }, 462 dataType: 'json', 463 success: function (data) { 464 var result = data['result']; 465 $.each(result, function (a, b) { 466 467 variant_counter++; 468 var attr_name = 'pro_attr_' + variant_counter; 469 html += '<div class="form-group move row my-auto p-2 border rounded bg-gray-light product-variant-selectbox"><div class="col-1 text-center my-auto"><i class="fas fa-sort"></i></div>'; 470 var tmp_variant_value_id = " "; 471 $.each(b, function (key, value) { 472 tmp_variant_value_id = tmp_variant_value_id + " " + value.id; 473 html += '<div class="col-2"> <input type="text" class="col form-control" value="' + value.value + '" readonly></div>'; 474 }); 475 html += '<input type="hidden" name="variants_ids[]" value="' + tmp_variant_value_id + '"><div class="col my-auto row justify-content-center"> <a data-toggle="collapse" class="btn btn-tool text-primary" data-target="#' + attr_name + '" aria-expanded="true"><i class="fas fa-angle-down fa-2x"></i> </a> <button type="button" class="btn btn-tool remove_variants"> <i class="text-danger far fa-times-circle fa-2x "></i> </button></div><div class="col-12" id="variant_stock_management_html"><div id=' + attr_name + ' style="" class="collapse">'; 476 if ($('.variant_stock_status').is(':checked') && $('.variant-stock-level-type').val() == 'variable_level') { 477 html += '<div class="form-group row"><div class="col col-xs-12"><label class="control-label">Price :</label><input type="number" name="variant_price[]" class="col form-control price varaint-must-fill-field" min="0" step="0.01"></div><div class="col col-xs-12"><label class="control-label">
477Special Price :</label><input type="number" name="variant_special_price[]" class="col form-control discounted_price" min="0" step="0.01"></div><div class="col col-xs-12"> <label class="control-label">Sku :</label> <input type="text" name="variant_sku[]" class="col form-control varaint-must-fill-field"></div><div class="col col-xs-12"> <label class="control-label">Total Stock :</label> <input type="text" name="variant_total_stock[]" class="col form-control varaint-must-fill-field"></div><div class="col col-xs-12"> <label class="control-label">Stock Status :</label> <select type="text" name="variant_level_stock_status[]" class="col form-control varaint-must-fill-field"><option value="1">In Stock</option><option value="0">Out Of Stock</option> </select></div></div>'; 478 } else { 479 html += '<div class="form-group row"><div class="col col-xs-12"><label class="control-label">Price :</label><input type="number" name="variant_price[]" class="col form-control price varaint-must-fill-field" min="0" step="0.01"></div><div class="col col-xs-12"><label class="control-label">Special Price :</label><input type="number" name="variant_special_price[]" class="col form-control discounted_price" min="0" step="0.01"></div>'; 480 } 481 html += '<div class="col-12 pt-3"><label class="control-label">Images :</label><div class="col-md-3"><a class="uploadFile img btn btn-primary text-white btn-sm" data-input="variant_images[' + a + '][]" data-isremovable="1" data-is-multiple-uploads-allowed="1" data-toggle="modal" data-target="#media-upload-modal" value="Upload Photo"><i class="fa fa-upload"></i> Upload</a> </div><div class="container-fluid row image-upload-section"></div></div>'; 482 html += '</div></div></div></div></div>'; 483 }); 484 485 if (is_appendable == false) { 486 $('#variants_process').html(html); 487 } else { 488 $('#variants_process').append(html); 489 } 490 $('#variants_process').unblock(); 491 } 492 }); 493} 494 495function create_attributes(value, selected_attr) { 496 counter++; 497 var $attribute = $('#attributes_values_json_data').find('.select_single'); 498 var $options = $($attribute).clone().html(); 499 var $selected_attrs = []; 500 if (selected_attr) { 501 $.each(selected_attr.split(","), function () { 502 $selected_attrs.push($.trim(this)); 503 }); 504 } 505 506 var attr_name = 'pro_attr_' + counter; 507 508 // product-attr-selectbox 509 if ($('#product-type').val() == 'simple_product') { 510 var html = '<div class="form-group move row my-auto p-2 border rounded bg-gray-light product-attr-selectbox" id=' + attr_name + '><div class="col-md-1 col-sm-12 text-center my-auto"><i class="fas fa-sort"></i></div><div class="col-md-4 col-sm-12"> <select name="attribute_id[]" class="attributes select_single" data-placeholder=" Type to search and select attributes"><option value=""></option>' + $options + '</select></div><div class="col-md-4 col-sm-12"> <select name="attribute_value_ids[]" class="multiple_values" multiple="" data-placeholder=" Type to search and select attributes values"><option value=""></option> </select></div><div class="col-md-2 col-sm-6 text-center py-1 align-self-center"> <button type="button" class="btn btn-tool remove_attributes"> <i class="text-danger far fa-times-circle fa-2x "></i> </button></div></div>'; 511 } else { 512 $('#note').removeClass('d-none'); 513 var html = '<div class="form-group row move my-auto p-2 border rounded bg-gray-light product-attr-selectbox" id=' + attr_name + '><div class="col-md-1 col-sm-12 text-center my-auto"><i class="fas fa-sort"></i></div><div class="col-md-4 col-sm-12"> <select name="attribute_id[]" class="attributes select_single" data-placeholder=" Type to search and select attributes"><option value=""></option>' + $options + '</select></div><div class="col-md-4 col-sm-12"> <select name="attribute_value_ids[]" class="multiple_values" multiple="" data-placeholder=" Type to search and select attributes values"><option value=""></option> </select></div><div class="col-md-2 col-sm-6 text-center py-1 align-self-center"><input type="checkbox" name="variations[]" class="is_attribute_checked custom-checkbox mt-2"></div><div class="col-md-1 col-sm-6 text-center py-1 align-self-center"> <button type="button" class="btn btn-tool remove_attributes"> <i class="text-danger far fa-times-circle fa-2x "></i> </button></div></div>'; 514 } 515 $('#attributes_process').append(html); 516 if (selected_attr) { 517 if ($.inArray(value.name, $selected_attrs) > -1) { 518 $("#attributes_process").find('.product-attr-selectbox').last().find('.is_attribute_checked').prop('checked', true).addClass('custom-checkbox mt-2'); 519 $("#attributes_process").find('.product-attr-selectbox').last().find('.remove_attributes').addClass('remove_edit_attribute').removeClass('remove_attributes'); 520 521 } 522 } 523 $("#attributes_process").find('.product-attr-selectbox').last().find(".attributes").select2({ 524 theme: 'bootstrap4', 525 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 526 placeholder: $(this).data('placeholder'), 527 allowClear: Boolean($(this).data('allow-clear')), 528 }).val(value.name); 529 530 $("#attributes_process").find('.product-attr-selectbox').last().find(".attributes").trigger('change'); 531 $("#attributes_process").find('.product-attr-selectbox').last().find(".select_single").trigger('select2:select'); 532 533 var multiple_values = []; 534 $.each(value.ids.split(","), function () { 535 multiple_values.push($.trim(this)); 536 }); 537 538 $("#attributes_process").find('.product-attr-selectbox').last().find(".multiple_values").select2({ 539 theme: 'bootstrap4', 540 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 541 placeholder: $(this).data('placeholder'), 542 allowClear: Boolean($(this).data('allow-clear')), 543 }).val(multiple_values); 544 $("#attributes_process").find('.product-attr-selectbox').last().find(".multiple_values").trigger('change'); 545} 546 547function create_fetched_attributes_html(from) { 548 549 var edit_id = $('input[name="edit_product_id"]').val(); 550 var edit_id_new = $('input[name="edit_product_id1"]').val(); 551 var product = $('input[name="product"]').val(); 552 553 if(edit_id!=undefined && edit_id!=""){ 554url="fetch_attributes_by_id"; 555 }else if(edit_id_new!=undefined && edit_id_new!=""){ 556url="fetch_attributes_new_by_id"; 557edit_id=edit_id_new; 558 }else{ 559url="fetch_attributes_new_by_id"; 560edit_id=product; 561 } 562 563 $.ajax({ 564 type: 'GET', 565 url: base_url + from + '/product/'+url, 566 data: { 567 edit_id: edit_id, 568 [csrfName]: csrfHash, 569 }, 570 dataType: 'json', 571 success: function (data) { 572 csrfName = data['csrfName']; 573 csrfHash = data['csrfHash']; 574 var result = data['result']; 575 576 if (!$.isEmptyObject(result.attr_values)) { 577 578 $.each(result.attr_values, function (key, value) { 579 create_attributes(value, result.pre_selected_variants_names); 580 }); 581 582 $.each(result['pre_selected_variants_ids'], function (key, val) { 583 var tempArray = []; 584 if (val.variant_ids) { 585 $.each(val.variant_ids.split(','), function (k, v) { 586 tempArray.push($.trim(v)); 587 }); 588 pre_selected_attr_values[key] = tempArray; 589 } 590 }); 591 592 if (result.pre_selected_variants_names) { 593 $.each(result.pre_selected_variants_names.split(','), function (key, value) { 594 pre_selected_attributes_name.push($.trim(value)); 595 }); 596 } 597 } else { 598 $('.no-attributes-added').show(); 599 $('#save_attributes').addClass('d-none'); 600 } 601 } 602 }); 603 return $.Deferred().resolve(); 604} 605 606function search_category_wise_products() { 607 var category_id = $('#category_parent').val(); 608 if (category_id != '') { 609 $.ajax({ 610 data: { 611 'cat_id': category_id, 612 }, 613 type: 'GET', 614 url: base_url + 'admin/product/search_category_wise_products', 615 dataType: 'json', 616 success: function (result) { 617 var html = ""; 618 var i = 0; 619 if (!$.isEmptyObject(result)) { 620 $.each(result, function (index, value) { 621 html += '<li class="list-group-item d-flex bg-gray-light align-items-center h-25 ui-sortable-handle" id="product_id-' + value['id'] + '">'; 622 html += '<div class="col-md-1"><span> ' + i + ' </span></div>'; 623 html += '<div class="col-md-3"><span> ' + value['row_order'] + ' </span></div>'; 624 html += '<div class="col-md-4"><span>' + value['name'] + '</span></div>'; 625 html += '<div class="col-md-4"><img src="' + base_url + value['image'] + '" class="w-25"></div>'; 626 i++; 627 }); 628 $('#sortable').html(html); 629 } else { 630 631 iziToast.error({ 632 message: 'No Products Are Available', 633 }); 634 635 html += '<li class="list-group-item d-flex justify-content-center bg-gray-light align-items-center h-25 ui-sortable-handle" id="product_id-3"><div class="col-md-12 d-flex justify-content-center"><span>No Products Are Available</span></div></li>'; 636 $('#sortable').html(html); 637 } 638 } 639 }); 640 } else { 641 iziToast.error({ 642 message: 'Category Field Should Be Selected', 643 }); 644 } 645} 646 647 648 649function save_product(form) { 650 651 $('input[name="product_type"]').val($('#product-type').val()); 652 if ($('.simple_stock_management_status').is(':checked')) { 653 $('input[name="simple_product_stock_status"]').val($('#simple_product_stock_status').val()); 654 } else { 655 $('input[name="simple_product_stock_status"]').val(''); 656 } 657 $('#product-type').prop('disabled', true); 658 $('.product-attributes').removeClass('disabled'); 659 $('.product-variants').removeClass('disabled'); 660 $('.simple_stock_management_status').prop('disabled', true); 661 662 var catid = $('#product_category_tree_view_html').jstree("get_selected"); 663 var formData = new FormData(form); 664 var submit_btn = $('#submit_btn'); 665 var btn_html = $('#submit_btn').html(); 666 var btn_val = $('#submit_btn').val(); 667 var button_text = (btn_html != '' || btn_html != 'undefined') ? btn_html : btn_val; 668 save_attributes(); 669 formData.append(csrfName, csrfHash); 670 671 formData.append('category_id', catid); 672 formData.append('attribute_values', all_attributes_values); 673 674 $.ajax({ 675 type: 'POST', 676 url: $(form).attr('action'), 677 data: formData, 678 beforeSend: function () { 679 submit_btn.html('Please Wait..'); 680 submit_btn.attr('disabled', true); 681 }, 682 cache: false, 683 contentType: false, 684 processData: false, 685 dataType: 'json', 686 success: function (result) { 687 csrfName = result['csrfName']; 688 csrfHash = result['csrfHash']; 689 690 if (result['error'] == true) { 691 submit_btn.html(button_text); 692 submit_btn.attr('disabled', false); 693 iziToast.error({ 694 message: result['message'], 695 }); 696 697 } else { 698 submit_btn.html(button_text); 699 submit_btn.attr('disabled', false); 700 iziToast.success({ 701 message: result['message'], 702 }); 703 // setTimeout(function () { location.reload(); }, 600); 704 } 705 } 706 }); 707} 708 709 710function get_variants(edit_id, from) { 711 return $.ajax({ 712 type: 'GET', 713 url: base_url + from + '/product/fetch_variants_values_by_pid', 714 data: { 715 edit_id: edit_id 716 }, 717 dataType: 'json' 718 }) 719 .done(function (data) { 720 return data.responseCode != 200 ? 721 $.Deferred().reject(data) : data; 722 }); 723 724} 725function get_variants_new(edit_id, from) { 726 return $.ajax({ 727 type: 'GET', 728 url: base_url + from + '/product/fetch_variants_new_values_by_pid', 729 data: { 730 edit_id: edit_id 731 }, 732 dataType: 'json' 733 }) 734 .done(function (data) { 735 return data.responseCode != 200 ? 736 $.Deferred().reject(data) : data; 737 }); 738 739} 740 741function create_fetched_variants_html(add_newly_created_variants = false, from) { 742 743 var newArr1 = []; 744 for (var i = 0; i < pre_selected_attr_values.length; i++) { 745 var temp = newArr1.concat(pre_selected_attr_values[i]); 746 newArr1 = [...new Set(temp)]; 747 748 } 749 var newArr2 = []; 750 for (var i = 0; i < attributes_values.length; i++) { 751 newArr2 = newArr2.concat(attributes_values[i]); 752 } 753 754 755 current_attributes_selected = $.grep(newArr2, function (x) { return $.inArray(x, newArr1) < 0 }); 756 757 if (containsAll(newArr1, newArr2)) { 758 759 var temp = []; 760 if (!$.isEmptyObject(current_attributes_selected)) { 761 762 $.ajax({ 763 type: 'GET', 764 url: base_url + from + '/product/fetch_attribute_values_by_id', 765 data: { 766 id: current_attributes_selected, 767 }, 768 dataType: 'json', 769 success: function (result) { 770 temp = result; 771 $.each(result, function (key, value) { 772 if (pre_selected_attributes_name.indexOf($.trim(value.name)) > -1) { 773 delete temp[key]; 774 } 775 }); 776 var resetArr = temp.filter(function () { return true; }); 777 setTimeout(function () { 778 779 var edit_id = $('input[name="edit_product_id"]').val(); 780 var edit_id_new = $('input[name="edit_product_id1"]').val(); 781 var product = $('input[name="product"]').val(); 782 783 if(edit_id!=undefined && edit_id !=""){ 784 get_variants(edit_id, from).done(function (data) { 785 create_editable_variants(data.result, false, add_newly_created_variants); 786 }); 787 }else if(edit_id_new!=undefined && edit_id_new!=""){ 788 get_variants_new(edit_id_new, from).done(function (data) { 789 create_editable_variants(data.result, false, add_newly_created_variants); 790 }); 791 }else{ 792get_variants_new(product, from).done(function (data) { 793 create_editable_variants(data.result, false, add_newly_created_variants); 794 }); 795 } 796 }, 1000); 797 } 798 }); 799 } else { 800 801 if (attribute_flag == 0) { 802 803 var edit_id = $('input[name="edit_product_id"]').val(); 804 var edit_id_new = $('input[name="edit_product_id1"]').val(); 805 var product = $('input[name="product"]').val(); 806 807 if(edit_id!=undefined && edit_id !=""){ 808 get_variants(edit_id, from).done(function (data) { 809 create_editable_variants(data.result, false, add_newly_created_variants); 810 }); 811 }else if(edit_id_new!=undefined && edit_id_new!=""){ 812 get_variants_new(edit_id_new, from).done(function (data) { 813 create_editable_variants(data.result, false, add_newly_created_variants); 814 }); 815 }else{ 816get_variants_new(product, from).done(function (data) { 817 create_editable_variants(data.result, false, add_newly_created_variants); 818 }); 819 } 820 } 821 } 822 } else { 823
824 var edit_id = $('input[name="edit_product_id"]').val(); 825 var edit_id_new = $('input[name="edit_product_id1"]').val(); 826 var product = $('input[name="product"]').val(); 827 828 if(edit_id!=undefined && edit_id !=""){ 829 get_variants(edit_id, from).done(function (data) { 830 create_editable_variants(data.result, false, add_newly_created_variants); 831 }); 832 }else if(edit_id_new!=undefined && edit_id_new !=""){ 833 get_variants_new(edit_id_new, from).done(function (data) { 834 create_editable_variants(data.result, false, add_newly_created_variants); 835 }); 836 }else{ 837get_variants_new(product, from).done(function (data) { 838 create_editable_variants(data.result, false, add_newly_created_variants); 839 }); 840 } 841 } 842} 843 844function create_editable_variants(data, newly_selected_attr = false, add_newly_created_variants = false) { 845 if (data[0].variant_ids) { 846 $('#reset_variants').show(); 847 var html = ''; 848 849 if (!$.isEmptyObject(attributes_values) && add_newly_created_variants == true) { 850 var permuted_value_result = getPermutation(attributes_values); 851 } 852 853 $.each(data, function (a, b) { 854 855 if (!$.isEmptyObject(permuted_value_result) && add_newly_created_variants == true) { 856 var permuted_value_result_temp = permuted_value_result; 857 var varinat_ids = b.variant_ids.split(','); 858 $.each(permuted_value_result_temp, function (index, value) { 859 if (containsAll(varinat_ids, value)) { 860 permuted_value_result.splice(index, 1); 861 } 862 }); 863 } 864 865 variant_counter++; 866 var attr_name = 'pro_attr_' + variant_counter; 867 html += '<div class="form-group move row my-auto p-2 border rounded bg-gray-light product-variant-selectbox"><div class="col-1 text-center my-auto"><i class="fas fa-sort"></i></div>'; 868 html += '<input type="hidden" name="edit_variant_id[]" value=' + b.id + '>'; 869 var tmp_variant_value_id = ""; 870 var varaint_array = []; 871 var varaint_ids_temp_array = []; 872 var flag = 0; 873 var variant_images = ""; 874 var image_html = ""; 875 variant_images = JSON.parse(b.images); 876 877 $.each(b.variant_ids.split(","), function (key) { 878 varaint_ids_temp_array[key] = $.trim(this); 879 }); 880 881 $.each(b.variant_values.split(","), function (key) { 882 varaint_array[key] = $.trim(this); 883 }); 884 885 $.each(variant_images, function (img_key, img_value) { 886 image_html += '<div class="col-md-3 col-sm-12 shadow bg-white rounded m-3 p-3 text-center grow"><div class="image-upload-div"><img src=' + base_url + img_value + ' alt="Image Not Found"></div> <a href="javascript:void(0)" class="delete-img m-3" data-id="' + b.id + '" data-field="images" data-img=' + img_value + ' data-table="product_variants" data-path="uploads/media/" data-isjson="true"> <span class="btn btn-block bg-gradient-danger btn-xs"><i class="far fa-trash-alt "></i> Delete</span></a> <input type="hidden" name="variant_images[' + a + '][]" value=' + img_value + '></div>'; 887 }); 888 889 for (var i = 0; i < varaint_array.length; i++) { 890 html += '<div class="col-2 variant_col"> <input type="hidden" value="' + varaint_ids_temp_array[i] + '"><input type="text" class="col form-control" value="' + varaint_array[i] + '" readonly></div>'; 891 } 892 if (newly_selected_attr != false && newly_selected_attr.length > 0) { 893 for (var i = 0; i < newly_selected_attr.length; i++) { 894 var tempVariantsIds = []; 895 var tempVariantsValues = []; 896 $.each(newly_selected_attr[i].attribute_values_id.split(','), function () { 897 tempVariantsIds.push($.trim(this)); 898 }); 899 html += '<div class="col-2"><select class="col new-added-variant form-control" ><option value="">Select Attribute</option>'; 900 $.each(newly_selected_attr[i].attribute_values.split(','), function (key) { 901 tempVariantsValues.push($.trim(this)); 902 html += '<option value="' + tempVariantsIds[key] + '">' + tempVariantsValues[key] + '</option>'; 903 }); 904 html += '</select></div>'; 905 } 906 } 907 html += '<input type="hidden" name="variants_ids[]" value="' + b.attribute_value_ids + '"><div class="col my-auto row justify-content-center"> <a data-toggle="collapse" class="btn btn-tool text-primary" data-target="#' + attr_name + '" aria-expanded="true"><i class="fas fa-angle-down fa-2x"></i> </a> <button type="button" class="btn btn-tool remove_variants"> <i class="text-danger far fa-times-circle fa-2x "></i> </button></div><div class="col-12" id="variant_stock_management_html"><div id=' + attr_name + ' style="" class="collapse">'; 908 if ($('.variant_stock_status').is(':checked') && $('.variant-stock-level-type').val() == 'variable_level') { 909 var selected = (b.availability == '0') ? 'selected' : ' '; 910 html += '<div class="form-group row"><div class="col col-xs-12"><label class="control-label">Price :</label><input type="number" name="variant_price[]" class="col form-control price varaint-must-fill-field" value="' + b.price + '" min="0" step="0.01"></div><div class="col col-xs-12"><label class="control-label">
910Special Price :</label><input type="number" name="variant_special_price[]" class="col form-control discounted_price" min="0" value="' + b.special_price + '" step="0.01"></div><div class="col col-xs-12"> <label class="control-label">Sku :</label> <input type="text" name="variant_sku[]" class="col form-control varaint-must-fill-field" value="' + b.sku + '" ></div><div class="col col-xs-12"> <label class="control-label">Total Stock :</label> <input type="text" name="variant_total_stock[]" class="col form-control varaint-must-fill-field" value="' + b.stock + '"></div><div class="col col-xs-12"> <label class="control-label">Stock Status :</label> <select type="text" name="variant_level_stock_status[]" class="col form-control varaint-must-fill-field"><option value="1">In Stock</option><option value="0" ' + selected + ' >Out Of Stock</option> </select></div></div>'; 911 } else { 912 html += '<div class="form-group row"><div class="col col-xs-12"><label class="control-label">Price :</label><input type="number" name="variant_price[]" class="col form-control price varaint-must-fill-field" value="' + b.price + '" min="0" step="0.01"></div><div class="col col-xs-12"><label class="control-label">Special Price :</label><input type="number" name="variant_special_price[]" class="col form-control discounted_price" min="0" value="' + b.special_price + '" step="0.01"></div></div>'; 913 } 914 html += '<div class="col-12 pt-3"><label class="control-label">Images :</label><div class="col-md-3"><a class="uploadFile img btn btn-primary text-white btn-sm" data-input="variant_images[' + a + '][]" data-isremovable="1" data-is-multiple-uploads-allowed="1" data-toggle="modal" data-target="#media-upload-modal" value="Upload Photo"><i class="fa fa-upload"></i> Upload</a> </div><div class="container-fluid row image-upload-section"> ' + image_html + ' </div></div>'; 915 html += '</div></div></div>'; 916 917 $('#variants_process').html(html); 918 }); 919 920 if (!$.isEmptyObject(attributes_values) && add_newly_created_variants == true) { 921 create_variants(permuted_value_result, from); 922 } 923 924 } 925} 926 927function status_date_wise_search() { 928 $('.table-striped').bootstrapTable('refresh'); 929} 930 931function resetfilters() { 932 $('#datepicker').val(''); 933 $('#media-type').val(''); 934 $('#start_date').val(''); 935 $('#end_date').val(''); 936} 937 938function formatRepo(repo) { 939 940 if (repo.loading) return repo.text; 941 var markup = "<div class='select2-result-repository clearfix'>" + 942 "<div class='select2-result-repository__meta'>" + 943 "<div class='select2-result-repository__title'>" + repo.name + "</div>"; 944 945 if (repo.description) { 946 markup += "<div class='select2-result-repository__description'> In " + repo.category_name + "</div>"; 947 } 948 949 return markup; 950} 951function formatRepo1(repo) { 952 953 if (repo.loading) return repo.text; 954 var markup = "<div class='select2-result-repository clearfix'>" + 955 "<div class='select2-result-repository__meta'>" + 956 "<div class='select2-result-repository__title'>" + repo.zipcode + "</div>"; 957 958 return markup; 959} 960 961function formatRepoSelection(repo) { 962 return repo.name || repo.text; 963} 964function formatRepoSelection1(repo) { 965 return repo.zipcode || repo.text; 966} 967 968function mediaParams(p) { 969 return { 970 'type': $('#media_type').val(), 971 limit: p.limit, 972 sort: p.sort, 973 order: p.order, 974 offset: p.offset, 975 search: p.search 976 }; 977} 978 979function mediaUploadParams(p) { 980 return { 981 'type': $('#media-type').val(), 982 "start_date": $('#start_date').val(), 983 "end_date": $('#end_date').val(), 984 limit: p.limit, 985 sort: p.sort, 986 order: p.order, 987 offset: p.offset, 988 search: p.search 989 }; 990} 991 992function home_query_params(p) { 993 return { 994 "start_date": $('#start_date').val(), 995 "end_date": $('#end_date').val(), 996 "order_status": $('#order_status').val(), 997 limit: p.limit, 998 sort: p.sort, 999 order: p.order, 1000 offset: p.offset, 1001 search: p.search 1002 }; 1003} 1004 1005function queryParams(p) { 1006 return { 1007 limit: p.limit, 1008 sort: p.sort, 1009 order: p.order, 1010 offset: p.offset, 1011 search: p.search, 1012 category_parent:$('#category_parent').val() 1013 }; 1014} 1015function ticket_queryParams(p) { 1016 return { 1017 limit: p.limit, 1018 sort: p.sort, 1019 order: p.order, 1020 offset: p.offset, 1021 search: p.search 1022 }; 1023} 1024 1025function customer_wallet_query_params(p) { 1026 return { 1027 transaction_type: 'wallet', 1028 limit: p.limit, 1029 sort: p.sort, 1030 order: p.order, 1031 offset: p.offset, 1032 search: p.search 1033 }; 1034} 1035function order_tracking_query_params(p) { 1036 return { 1037 "order_id": $('input[name="order_id"]').val(), 1038 limit: p.limit, 1039 sort: p.sort, 1040 order: p.order, 1041 offset: p.offset, 1042 search: p.search 1043 }; 1044} 1045 1046function category_query_params(p) { 1047 return { 1048 "category_id": $('#category_id').val(), 1049 limit: p.limit, 1050 sort: p.sort, 1051 order: p.order, 1052 offset: p.offset, 1053 search: p.search 1054 }; 1055} 1056 1057function product_query_params(p) { 1058 return { 1059 "category_id": $('#category_parent').val(), 1060 "seller_id": $('#seller_filter').val(), 1061 "status": $('#status_filter').val(), 1062 limit: p.limit, 1063 sort: p.sort, 1064 order: p.order, 1065 offset: p.offset, 1066 search: p.search 1067 }; 1068} 1069function payment_request_queryParams(p) { 1070 return { 1071 "user_filter": $('#user_filter').val(), 1072 limit: p.limit, 1073 sort: p.sort, 1074 order: p.order, 1075 offset: p.offset, 1076 search: p.search 1077 }; 1078} 1079 1080function ratingParams(p) { 1081 return { 1082 "category_id": $('#category_parent').val(), 1083 limit: p.limit, 1084 sort: p.sort, 1085 order: p.order, 1086 offset: p.offset, 1087 search: p.search 1088 }; 1089} 1090 1091function sales_invoice_query_params(p) { 1092 return { 1093 "start_date": $('#start_date').val(), 1094 "end_date": $('#end_date').val(), 1095 "order_status": $('#order_status').val(), 1096 limit: p.limit, 1097 sort: p.sort, 1098 order: p.order, 1099 offset: p.offset, 1100 search: p.search 1101 }; 1102} 1103 1104function address_query_params(p) { 1105 return { 1106 user_id: $('#address_user_id').val(), 1107 limit: p.limit, 1108 sort: p.sort, 1109 order: p.order, 1110 offset: p.offset, 1111 search: p.search 1112 }; 1113} 1114 1115function orders_query_params(p) { 1116 return { 1117 "start_date": $('#start_date').val(), 1118 "end_date": $('#end_date').val(), 1119 "order_status": $('#order_status').val(), 1120 "user_id": $('#order_user_id').val(), 1121 limit: p.limit, 1122 sort: p.sort, 1123 order: p.order, 1124 offset: p.offset, 1125 search: p.search 1126 }; 1127} 1128 1129function transaction_query_params(p) { 1130 return { 1131 transaction_type: 'transaction', 1132 user_id: $('#transaction_user_id').val(), 1133 limit: p.limit, 1134 sort: p.sort, 1135 order: p.order, 1136 offset: p.offset, 1137 search: p.search 1138 }; 1139} 1140 1141$(document).on('change', '.type_event_trigger', function (e, data) { 1142 e.preventDefault(); 1143 var type_val = $(this).val();
1144 if (type_val != 'default' && type_val != ' ') { 1145 if (type_val == 'categories') { 1146 $('.slider-categories').removeClass('d-none'); 1147 $('.notification-categories').removeClass('d-none'); 1148 $('.slider-products').addClass('d-none'); 1149 $('.notification-products').addClass('d-none'); 1150 } else { 1151 $('.slider-products').removeClass('d-none'); 1152 $('.notification-products').removeClass('d-none'); 1153 $('.slider-categories').addClass('d-none'); 1154 $('.notification-categories').addClass('d-none'); 1155 } 1156 } else { 1157 $('.slider-categories').addClass('d-none'); 1158 $('.slider-products').addClass('d-none'); 1159 $('.notification-categories').addClass('d-none'); 1160 $('.notification-products').addClass('d-none'); 1161 } 1162}); 1163if ($("input[data-bootstrap-switch]").length) { 1164 1165 $("input[data-bootstrap-switch]").each(function () { 1166 $('input[data-bootstrap-switch]').bootstrapSwitch(); 1167 }); 1168} 1169 1170$(document).on('click', '.edit_btn', function () { 1171 var id = $(this).data('id'); 1172 var url = $(this).data('url');; 1173 $('.edit-modal-lg').modal('show').find('.modal-body').load(base_url + url + '?edit_id=' + id + ' .form-submit-event', function () { 1174 1175 if ($("input[data-bootstrap-switch]").length) { 1176 1177 $("input[data-bootstrap-switch]").each(function () { 1178 $('input[data-bootstrap-switch]').bootstrapSwitch(); 1179 }); 1180 } 1181 $('#category_parent').select2({ 1182 theme: 'bootstrap4', 1183 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 1184 placeholder: $(this).data('placeholder'), 1185 allowClear: Boolean($(this).data('allow-clear')), 1186 templateResult: function (data) { 1187 if (!data.element) { 1188 return data.text; 1189 } 1190 1191 var $element = $(data.element); 1192 1193 var $wrapper = $('<span></span>'); 1194 $wrapper.addClass($element[0].className); 1195 1196 $wrapper.text(data.text); 1197 1198 return $wrapper; 1199 } 1200 }); 1201 $('.select_multiple').each(function () { 1202 $(this).select2({ 1203 theme: 'bootstrap4', 1204 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 1205 placeholder: $(this).data('placeholder'), 1206 allowClear: Boolean($(this).data('allow-clear')), 1207 }); 1208 }); 1209 1210 $(".search_product").select2({ 1211 ajax: { 1212 url: base_url + 'home/get_products', 1213 dataType: 'json', 1214 delay: 250, 1215 data: function (params) { 1216 return { 1217 search: params.term, // search term 1218 page: params.page 1219 }; 1220 }, 1221 processResults: function (response, params) { 1222 params.page = params.page || 1; 1223 1224 return { 1225 results: response.data, 1226 pagination: { 1227 more: (params.page * 30) < response.total 1228 } 1229 }; 1230 }, 1231 cache: true 1232 }, 1233 escapeMarkup: function (markup) { return markup; }, 1234 minimumInputLength: 1, 1235 templateResult: formatRepo, 1236 templateSelection: formatRepoSelection, 1237 theme: 'bootstrap4', 1238 placeholder: 'Search for products' 1239 }); 1240 searchable_zipcodes(); 1241 setTimeout(function () { 1242 $('.edit-modal-lg').unblock(); 1243 }, 2000); 1244 1245 }); 1246}); 1247 1248function searchable_zipcodes() { 1249 var search_zipcodes = $(".search_zipcode").select2({ 1250 ajax: { 1251 url: base_url + from + '/area/get_zipcodes', 1252 dataType: 'json', 1253 delay: 250, 1254 data: function (params) { 1255 return { 1256 search: params.term, // search term 1257 page: params.page 1258 }; 1259 }, 1260 processResults: function (response, params) { 1261 // parse the results into the format expected by Select2 1262 // since we are using custom formatting functions we do not need to 1263 // alter the remote JSON data, except to indicate that infinite 1264 // scrolling can be used 1265 params.page = params.page || 1; 1266 1267 return { 1268 results: response.data, 1269 pagination: { 1270 more: (params.page * 30) < response.total 1271 } 1272 }; 1273 }, 1274 cache: true 1275 }, 1276 escapeMarkup: function (markup) { 1277 return markup; 1278 }, 1279 minimumInputLength: 1, 1280 templateResult: formatRepo1, 1281 templateSelection: formatRepoSelection1, 1282 theme: 'bootstrap4', 1283 placeholder: 'Search for zipcodes', 1284 allowClear: Boolean($(this).data('allow-clear')), 1285 }); 1286 return search_zipcodes; 1287} 1288$(document).on('click', '.view_address', function () { 1289 var id = $(this).data('id'); 1290 var url = $(this).data('url'); 1291 1292}); 1293 1294$(document).on('click', '.view_btn', function () { 1295 var id = $(this).data('id'); 1296 var url = $(this).data('url'); 1297 $('.modal-body').load(base_url + url + '?edit_id=' + id + ' .form-submit-event'); 1298 $('.modal-title').html('Manage Promo code'); 1299 $('.modal-body').addClass('view'); 1300 $(".edit-modal-lg").modal(); 1301}); 1302 1303$(document).on('hidden.bs.modal', '.edit-modal-lg', function () { 1304 $('.edit-modal-lg .modal-body').removeClass('view'); 1305 $('.edit-modal-lg .modal-body').html(''); 1306}) 1307 1308//form-submit-event 1309$(document).on('submit', '.container-fluid .form-submit-event', function (e) { 1310 e.preventDefault(); 1311 var formData = new FormData(this); 1312 var update_id = $('#update_id').val(); 1313 if (update_id == '1') { 1314 var error_box = $('.edit-modal-lg #error_box'); 1315 var submit_btn = $('.edit-modal-lg #submit_btn'); 1316 var btn_html = $('.edit-modal-lg #submit_btn').html(); 1317 var btn_val = $('.edit-modal-lg #submit_btn').val(); 1318 var button_text = (btn_html != '' || btn_html != 'undefined') ? btn_html : btn_val; 1319 1320 } else { 1321 var error_box = $('#error_box', this); 1322 var submit_btn = $('#submit_btn'); 1323 var btn_html = $('#submit_btn').html(); 1324 var btn_val = $('#submit_btn').val(); 1325 var button_text = (btn_html != '' || btn_html != 'undefined') ? btn_html : btn_val; 1326 } 1327 1328 formData.append(csrfName, csrfHash); 1329 1330 $.ajax({ 1331 type: 'POST', 1332 url: $(this).attr('action'), 1333 data: formData, 1334 beforeSend: function () { 1335 submit_btn.html('Please Wait..'); 1336 submit_btn.attr('disabled', true); 1337 }, 1338 cache: false, 1339 contentType: false, 1340 processData: false, 1341 dataType: 'json', 1342 success: function (result) { 1343 csrfName = result['csrfName']; 1344 csrfHash = result['csrfHash']; 1345 1346 if (result['error'] == true) { 1347
1348 error_box.addClass("msg_error rounded p-3").removeClass('d-none msg_success'); 1349 error_box.show().delay(1000).fadeOut(); 1350 error_box.html(result['message']); 1351 submit_btn.html(button_text); 1352 submit_btn.attr('disabled', false); 1353 iziToast.error({ 1354 message: result['message'], 1355 }); 1356 1357 } else { 1358 1359 error_box.addClass("msg_success rounded p-3").removeClass('d-none msg_error'); 1360 error_box.show().delay(1000).fadeOut(); 1361 error_box.html(result['message']); 1362 submit_btn.html(button_text); 1363 submit_btn.attr('disabled', false); 1364 setTimeout(function () { $('.modal').modal('hide'); }, 1000); 1365 $('.table-striped').bootstrapTable('refresh'); 1366 iziToast.success({ 1367 message: result['message'], 1368 }); 1369 $('.form-submit-event')[0].reset(); 1370 if (window.location.href.indexOf("login") > -1) { 1371 setTimeout(function () { location.reload(); }, 600); 1372 } 1373 1374 } 1375 } 1376 }); 1377}); 1378 1379// 1.login 1380 1381//forgot_page 1382$(document).ready(function () { 1383 $('#forgot_password_page').on('submit', function (e) { 1384 e.preventDefault(); 1385 var formData = new FormData(this); 1386 formData.append(csrfName, csrfHash); 1387 $.ajax({ 1388 type: 'POST', 1389 url: $(this).attr('action'), 1390 data: formData, 1391 beforeSend: function () { 1392 $('#submit_btn').html('Please Wait..'); 1393 $('#submit_btn').attr('disabled', true); 1394 }, 1395 cache: false, 1396 contentType: false, 1397 processData: false, 1398 dataType: "json", 1399 success: function (result) { 1400 csrfName = result['csrfName']; 1401 csrfHash = result['csrfHash']; 1402 $('#result').html(result['message']); 1403 $('#result').show().delay(6000).fadeOut(); 1404 $('#submit_btn').html('Send Email'); 1405 $('#submit_btn').attr('disabled', false); 1406 } 1407 }); 1408 }); 1409}); 1410 1411//2.Product-Module 1412var edit_product_id = $('input[name=edit_product_id]').val(); 1413var edit_new_product_id = $('input[name=edit_product_id1]').val(); 1414var product = $('input[name=product]').val(); 1415 1416if (edit_product_id || edit_new_product_id || product) { 1417 1418 create_fetched_attributes_html('seller').done(function () { 1419 $('.no-attributes-added').hide(); 1420 $('#save_attributes').removeClass('d-none'); 1421 $('.no-variants-added').hide(); 1422 save_attributes(); 1423 create_fetched_variants_html(false, from); 1424 }); 1425 1426} 1427 1428$(document).on('switchChange.bootstrapSwitch', '#is_cancelable', function (event) { 1429 event.preventDefault(); 1430 var state = $(this).bootstrapSwitch('state'); 1431 if (state) { 1432 $('#cancelable_till').show(); 1433 } else { 1434 $('#cancelable_till').hide(); 1435 } 1436 1437}); 1438 1439$(document).on('change', '#category_parent', function () { 1440 $('#products_table').bootstrapTable('refresh'); 1441}); 1442$(document).on('change', '#seller_filter', function () { 1443 $('#products_table').bootstrapTable('refresh'); 1444}); 1445$(document).on('change', '#user_filter', function () { 1446 $('#payment_request_table').bootstrapTable('refresh'); 1447}); 1448$(document).on('change', '#status_filter', function () { 1449 $('#products_table').bootstrapTable('refresh'); 1450}); 1451 1452//Summer-note 1453$(document).ready(function () { 1454 1455 $('.textarea').summernote({ 1456 toolbar: [ 1457 // [groupName, [list of button]] 1458 ['style', ['bold', 'italic', 'underline', 'clear', 'style']], 1459 ['font', ['strikethrough', 'superscript', 'subscript']], 1460 ['fontsize', ['fontsize']], 1461 ['color', ['color']], 1462 ['para', ['ul', 'ol', 'paragraph']], 1463 ['height', ['height']], 1464 ['fontname', ['fontname']], 1465 ['table', ['table']], 1466 ['insert', ['link', 'video']], 1467 ['view', ['fullscreen', 'codeview', 'help']], 1468 ], 1469 height: 250, //set editable area's height 1470 codemirror: { // codemirror options 1471 theme: 'monokai' 1472 } 1473 }); 1474 1475 var sub_id = $('#subcategory_id_js').val(); 1476 if (typeof sub_id !== 'undefined') { 1477 $('#category_id').trigger('change', [{ subcategory_id: sub_id }]); 1478 } 1479 1480}); 1481
1482$(document).on('click', '#variation_product_btn', function (e) { 1483 e.preventDefault(); 1484 var radio = $("input[name='pro_input_type']:checked").val(); 1485 var edit_product_id = $('input[name=edit_product_id]').val(); 1486 var html = ''; 1487 html = add_product_variant_html(radio); 1488 $('#product_variance_html').append(html); 1489 if (typeof edit_product_id != 'undefined') { 1490 $("#product_variance_html").children('div').last().append("<input type='hidden' name='edit_product_variant[]'>"); 1491 } 1492}); 1493$(document).on('click', '#remove_product_btn', function (e) { 1494 e.preventDefault(); 1495 $(this).closest('.row').remove(); 1496}); 1497$(document).on('click', '.delete-img', function () { 1498 var isJson = false; 1499 var id = $(this).data('id'); 1500 var path = $(this).data('path'); 1501 var field = $(this).data('field'); 1502 var img_name = $(this).data('img'); 1503 var table_name = $(this).data('table'); 1504 var t = this; 1505 var isjson = $(this).data('isjson'); 1506 Swal.fire({ 1507 title: 'Are You Sure!', 1508 text: "You won't be able to revert this!", 1509 type: 'warning', 1510 showCancelButton: true, 1511 confirmButtonColor: '#3085d6', 1512 cancelButtonColor: '#d33', 1513 confirmButtonText: 'Yes, delete it!', 1514 showLoaderOnConfirm: true, 1515 preConfirm: function () { 1516 return new Promise((resolve, reject) => { 1517 $.ajax({ 1518 type: 'POST', 1519 url: base_url + 'admin/home/delete_image', 1520 data: { 1521 id: id, 1522 path: path, 1523 field: field, 1524 img_name: img_name, 1525 table_name: table_name, 1526 isjson: isjson, 1527 [csrfName]: csrfHash 1528 }, 1529 dataType: 'json', 1530 success: function (result) { 1531 csrfName = result['csrfName']; 1532 csrfHash = result['csrfHash']; 1533 if (result['is_deleted'] == true) { 1534 $(t).closest('div').remove(); 1535 Swal.fire('Success', 'Media Deleted !', 'success'); 1536 } else { 1537 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 1538 } 1539 } 1540 }); 1541 }); 1542 }, 1543 allowOutsideClick: false 1544 }).then((result) => { 1545 if (result.dismiss === Swal.DismissReason.cancel) { 1546 Swal.fire('Cancelled!', 'Your data is safe.', 'error'); 1547 } 1548 }); 1549}); 1550 1551$(document).on('click', '.delete-media', function () { 1552 1553 var id = $(this).data('id'); 1554 var t = this; 1555 Swal.fire({ 1556 title: 'Are You Sure!', 1557 text: "You won't be able to revert this!", 1558 type: 'warning', 1559 showCancelButton: true, 1560 confirmButtonColor: '#3085d6', 1561 cancelButtonColor: '#d33', 1562 confirmButtonText: 'Yes, delete it!', 1563 showLoaderOnConfirm: true, 1564 preConfirm: function () { 1565 return new Promise((resolve, reject) => { 1566 $.ajax({ 1567 type: 'GET', 1568 url: base_url + 'admin/media/delete/' + id, 1569 dataType: 'json', 1570 success: function (result) { 1571 csrfName = result['csrfName']; 1572 csrfHash = result['csrfHash']; 1573 if (result['error'] == false) { 1574 $('table').bootstrapTable('refresh'); 1575 Swal.fire('Success', 'File Deleted !', 'success'); 1576 } else { 1577 Swal.fire('Oops...', result['message'], 'error'); 1578 } 1579 } 1580 }); 1581 }); 1582 }, 1583 allowOutsideClick: false 1584 }).then((result) => { 1585 if (result.dismiss === Swal.DismissReason.cancel) { 1586 Swal.fire('Cancelled!', 'Your data is safe.', 'error'); 1587 } 1588 }); 1589}); 1590 1591 1592 1593$(document).on('focusout', '.discounted_price', function () { 1594 var discount_amt = parseInt($(this).val()); 1595 var price = parseInt($(this).closest('.form-group').siblings().find('.price').val()); 1596 if (typeof price != 'undefined' && price != "") { 1597 if (discount_amt > price) { 1598 iziToast.error({ 1599 message: "Special price can" + "'" + "t exceed price", 1600 }); 1601 $(this).val(''); 1602 } 1603 } 1604}); 1605$(document).on('focusout', '.price', function () { 1606 var price = parseInt($(this).val()); 1607 var discount_amt = parseInt($(this).closest('.form-group').siblings().find('.discounted_price').val()); 1608 if (typeof discount_amt != 'undefined' && discount_amt != "") { 1609 if (discount_amt > price) { 1610 iziToast.error({ 1611 message: "Special price can" + "'" + "t exceed price", 1612 }); 1613 $(this).val(''); 1614 } 1615 } 1616}); 1617$(document).on('click', '.clear-product-variance', function () { 1618 var edit_product_id = $('input[name=edit_product_id]').val(); 1619 var radio_val = $("input[name='pro_input_type']:checked").val(); 1620 var t = this; 1621 Swal.fire({ 1622 title: 'Are You Sure!', 1623 text: "You won't be able to revert this!", 1624 type: 'warning', 1625 showCancelButton: true, 1626 confirmButtonColor: '#3085d6', 1627 cancelButtonColor: '#d33', 1628 confirmButtonText: 'Yes, delete it!', 1629 showLoaderOnConfirm: true, 1630 preConfirm: function () { 1631 return new Promise((resolve, reject) => { 1632 $.ajax({ 1633 url: base_url + 'admin/product/delete_product', 1634 type: 'GET', 1635 data: { 1636 'id': edit_product_id 1637 }, 1638 dataType: 'json' 1639 }).done(function (response, textStatus) { 1640 Swal.fire('Deleted!', response.message); 1641 if (radio_val == 'packet') { 1642 html = add_product_variant_html(radio_val); 1643 $('#product_variance_html').html(html); 1644 $('#product_loose_html').hide(); 1645 $('.pro_loose').hide(); 1646 $('.remove_pro_btn').hide(); 1647 $(t).hide(); 1648 } else { 1649 $('#product_variance_html').show(); 1650 html = add_product_variant_html(radio_val); 1651 $('#product_loose_html').show(); 1652 $('#product_variance_html').html(html); 1653 $('.remove_pro_btn').hide(); 1654 } 1655 }).fail(function (jqXHR, textStatus, errorThrown) { 1656 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 1657 }); 1658 }); 1659 }, 1660 allowOutsideClick: false 1661 }).then((result) => { 1662 if (result.dismiss === Swal.DismissReason.cancel) { 1663 Swal.fire('Cancelled!', 'Your data is safe.', 'error'); 1664 } 1665 }); 1666}); 1667$('#sortable').sortable({ 1668 axis: 'y', 1669 opacity: 0.6, 1670 cursor: 'grab' 1671}); 1672 1673$(document).on('click', '#save_product_order', function () { 1674 var data = $('#sortable').sortable('serialize'); 1675 $.ajax({ 1676 data: data, 1677 type: 'GET', 1678 url: base_url + 'admin/product/update_product_order', 1679 dataType: 'json', 1680 success: function (response) { 1681 if (response.error == false) { 1682 iziToast.success({ 1683 message: response.message, 1684 }); 1685 } else { 1686 iziToast.error({ 1687 message: response.message, 1688 }); 1689 } 1690 } 1691 }); 1692}); 1693 1694$(document).on('click', '#save_section_order', function () { 1695 var data = $('#sortable').sortable('serialize'); 1696 $.ajax({ 1697 data: data, 1698 type: 'GET', 1699 url: base_url + 'admin/featured_sections/update_section_order', 1700 dataType: 'json', 1701 success: function (response) { 1702 if (response.error == false) { 1703 iziToast.success({ 1704 message: response.message, 1705 }); 1706 } else { 1707 iziToast.error({ 1708 message: response.message, 1709 }); 1710 } 1711 } 1712 }); 1713}); 1714 1715 1716//form-submit-event 1717$(document).on('submit', '#save-product', function (e) { 1718 e.preventDefault(); 1719 var product_type = $('#product-type').val(); 1720 var counter = 0; 1721 if (product_type != 'undefined' && product_type != ' ') { 1722 1723 if ($.trim(product_type) == 'simple_product') { 1724 if ($('.simple_stock_management_status').is(':checked')) { 1725 var len = 0 1726 } else { 1727 var len = 1 1728 } 1729 1730 if ($('.stock-simple-mustfill-field').filter(function () { return this.value === ''; }).length === len) { 1731 1732 $('input[name="product_type"]').val($('#product-type').val()); 1733 if ($('.simple_stock_management_status').is(':checked')) { 1734 $('input[name="simple_product_stock_status"]').val($('#simple_product_stock_status').val()); 1735 } else { 1736 $('input[name="simple_product_stock_status"]').val(''); 1737 } 1738 $('#product-type').prop('disabled', true); 1739 $('.product-attributes').removeClass('disabled'); 1740 $('.product-variants').removeClass('disabled'); 1741 $('.simple_stock_management_status').prop('disabled', true); 1742 1743 save_product(this); 1744 } else { 1745 iziToast.error({ 1746 message: 'Please Fill All The Fields', 1747 }); 1748 } 1749 } 1750 1751 if ($.trim(product_type) == 'variable_product') { 1752 if ($('.variant_stock_status').is(":checked")) { 1753 var variant_stock_level_type = $('.variant-stock-level-type').val(); 1754 if (variant_stock_level_type == 'product_level') { 1755 if ($('.variant-stock-level-type').filter(function () { return this.value === ''; }).length === 0 && $.trim($('.variant-stock-level-type').val()) != "") { 1756 1757 if ($('.variant-stock-level-type').val() == 'product_level' && $('.variant-stock-mustfill-field').filter(function () { return this.value === ''; }).length !== 0) { 1758 iziToast.error({ 1759 message: 'Please Fill All The Fields', 1760 }); 1761 } else { 1762 var varinat_price = $('input[name="variant_price[]"]').val(); 1763 1764 if ($('input[name="variant_price[]"]').length >= 1) { 1765 1766 if ($('.varaint-must-fill-field').filter(function () { return this.value === ''; }).length == 0) { 1767 1768 $('input[name="product_type"]').val($('#product-type').val()); 1769 $('input[name="variant_stock_level_type"]').val($('#stock_level_type').val()); 1770 $('input[name="varaint_stock_status"]').val("0"); 1771 $('#product-type').prop('disabled', true); 1772 $('#stock_level_type').prop('disabled', true); 1773 $(this).removeClass('save-variant-general-sett
1773ings'); 1774 $('.product-attributes').removeClass('disabled'); 1775 $('.product-variants').removeClass('disabled'); 1776 $('.variant-stock-level-type').prop('readonly', true); 1777 $('#stock_status_variant_type').attr('readonly', true); 1778 $('.variant-product-level-stock-management').find('input,select').prop('readonly', true); 1779 $('#tab-for-variations').removeClass('d-none'); 1780 $('.variant_stock_status').prop('disabled', true); 1781 $('#product-tab a[href="#product-attributes"]').tab('show'); 1782 save_product(this); 1783 1784 } else { 1785 $('.varaint-must-fill-field').each(function () { 1786 $(this).css('border', ''); 1787 if ($(this).val() == '') { 1788 $(this).css('border', '2px solid red'); 1789 $(this).closest('#variant_stock_management_html').find('div:first').addClass('show'); 1790 $('#product-tab a[href="#product-variants"]').tab('show'); 1791 counter++; 1792 } 1793 }); 1794 } 1795 1796 1797 } else { 1798 1799 Swal.fire('Variation Needed !', 'Atleast Add One Variation To Add The Product.', 'warning'); 1800 } 1801 } 1802 } else { 1803 iziToast.error({ 1804 message: 'Please Fill All The Fields', 1805 }); 1806 } 1807 } else { 1808 if ($('input[name="variant_price[]"]').length >= 1) { 1809 1810 if ($('.varaint-must-fill-field').filter(function () { return this.value === ''; }).length == 0) { 1811 $('input[name="product_type"]').val($('#product-type').val()); 1812 $('.variant_stock_status').prop('disabled', true); 1813 $('#product-type').prop('disabled', true); 1814 $('.product-attributes').removeClass('disabled'); 1815 $('.product-variants').removeClass('disabled'); 1816 $('#tab-for-variations').removeClass('d-none'); 1817 save_product(this); 1818 } else { 1819 $('.varaint-must-fill-field').each(function () { 1820 $(this).css('border', ''); 1821 if ($(this).val() == '') { 1822 $(this).css('border', '2px solid red'); 1823 $(this).closest('#variant_stock_management_html').find('div:first').addClass('show'); 1824 $('#product-tab a[href="#product-variants"]').tab('show'); 1825 counter++; 1826 } 1827 }); 1828 } 1829 1830 } else { 1831 1832 Swal.fire('Variation Needed !', 'Atleast Add One Variation To Add The Product.', 'warning'); 1833 1834 } 1835 } 1836 } else { 1837 1838 if ($('input[name="variant_price[]"]').length == 0) { 1839 Swal.fire('Variation Needed !', 'Atleast Add One Variation To Add The Product.', 'warning'); 1840 } else { 1841 if ($('.varaint-must-fill-field').filter(function () { return this.value === ''; }).length == 0) { 1842 save_product(this); 1843 } else { 1844 $('.varaint-must-fill-field').each(function () { 1845 $(this).css('border', ''); 1846 if ($(this).val() == '') { 1847 $(this).css('border', '2px solid red'); 1848 $(this).closest('#variant_stock_management_html').find('div:first').addClass('show'); 1849 $('#product-tab a[href="#product-variants"]').tab('show'); 1850 counter++; 1851 } 1852 }); 1853 } 1854 } 1855 } 1856 } 1857 1858 } else { 1859 iziToast.error({ 1860 message: 'Please Select Product Type !', 1861 }); 1862 } 1863 1864 if (counter > 0) { 1865 iziToast.error({ 1866 message: 'Please fill all the required fields in the variation tab !', 1867 }); 1868 } 1869 1870}); 1871 1872 1873 1874$(document).on('click', '#delete-product', function () { 1875 var id = $(this).data('id'); 1876 Swal.fire({ 1877 title: 'Are You Sure!', 1878 text: "You won't be able to revert this!", 1879 type: 'warning', 1880 showCancelButton: true, 1881 confirmButtonColor: '#3085d6', 1882 cancelButtonColor: '#d33', 1883 confirmButtonText: 'Yes, delete it!', 1884 showLoaderOnConfirm: true, 1885 preConfirm: function () { 1886 return new Promise((resolve, reject) => { 1887 $.ajax({ 1888 type: 'GET', 1889 url: base_url + from +'/product/delete_product', 1890 data: { 1891 id: id 1892 }, 1893 dataType: 'json' 1894 }).done(function (response, textStatus) { 1895 if (response.error == false) { 1896 1897 Swal.fire('Deleted!', response.message, 'success'); 1898 } else { 1899 Swal.fire('Oops...', response.message, 'error'); 1900 } 1901 $('table').bootstrapTable('refresh'); 1902 csrfName = response['csrfName']; 1903 csrfHash = response['csrfHash']; 1904 }).fail(function (jqXHR, textStatus, errorThrown) { 1905 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 1906 csrfName = response['csrfName']; 1907 csrfHash = response['csrfHash']; 1908 }); 1909 }); 1910 }, 1911 allowOutsideClick: false 1912 }); 1913}); 1914 1915 1916 1917 1918$(document).on('click', '#delete-product1', function () { 1919 var id = $(this).data('id'); 1920 Swal.fire({ 1921 title: 'Are You Sure!', 1922 text: "You won't be able to revert this!", 1923 type: 'warning', 1924 showCancelButton: true, 1925 confirmButtonColor: '#3085d6', 1926 cancelButtonColor: '#d33', 1927 confirmButtonText: 'Yes, delete it!', 1928 showLoaderOnConfirm: true, 1929 preConfirm: function () { 1930 return new Promise((resolve, reject) => { 1931 $.ajax({ 1932 type: 'GET', 1933 url: base_url + from +'/product/delete_product1', 1934 data: { 1935 id: id 1936 }, 1937 dataType: 'json' 1938 }).done(function (response, textStatus) { 1939 if (response.error == false) { 1940 1941 Swal.fire('Deleted!', response.message, 'success'); 1942 } else { 1943 Swal.fire('Oops...', response.message, 'error'); 1944 } 1945 $('table').bootstrapTable('refresh'); 1946 csrfName = response['csrfName']; 1947 csrfHash = response['csrfHash']; 1948 }).fail(function (jqXHR, textStatus, errorThrown) { 1949 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 1950 csrfName = response['csrfName']; 1951 csrfHash = response['csrfHash']; 1952 }); 1953 }); 1954 }, 1955 allowOutsideClick: false 1956 }); 1957}); 1958// multiple_values 1959$('.select_single , .multiple_values , #product-type').each(function () { 1960 $(this).select2({ 1961 theme: 'bootstrap4', 1962 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 1963 placeholder: $(this).data('placeholder'), 1964 allowClear: Boolean($(this).data('allow-clear')), 1965 }); 1966}); 1967 1968$(document).on('select2:selecting', '.select_single', function (e) { 1969 1970 if ($.inArray($(this).val(), attributes_values_selected) > -1) { 1971 //Remove value if further selected 1972 attributes_values_selected.splice(attributes_values_selected.indexOf($(this).select2().find(":selected").val()), 1); 1973 } 1974 1975}); 1976 1977$(document).on('select2:selecting', '.select_single .variant_attributes', function (e) { 1978 1979 if ($.inArray($(this).val(), variant_values_selected) > -1) { 1980 //Remove value if further selected 1981 variant_values_selected.splice(variant_values_selected.indexOf($(this).select2().find(":selected").val()), 1); 1982 1983 } 1984 1985}); 1986 1987$(document).on('select2:select', '.select_single', function (e) { 1988 var text = this.className; 1989 var type; 1990 $(this).closest('.row').find(".multiple_values").text(null).trigger('change'); 1991 var data = $(this).select2().find(":selected").data("values"); 1992 if (text.search('attributes') != -1) { 1993 value_check_array = attributes_values_selected.slice(); 1994 type = 'attributes'; 1995 } 1996 1997 if (text.search('variant_attributes') != -1) { 1998 value_check_array = variant_values_selected.slice(); 1999 type = 'variant_attributes'; 2000 } 2001 2002 if ($.inArray($(this).select2().find(":selected").val(), value_check_array) > -1) { 2003 iziToast.error({ 2004 message: 'Attribute Already Selected', 2005 }); 2006 $(this).val('').trigger('change'); 2007 } else { 2008 value_check_array.push($(this).select2().find(":selected").val()); 2009 } 2010 if (text.search('attributes') != -1) { 2011 attributes_values_selected = value_check_array.slice(); 2012 } 2013 2014 if (text.search('variant_attributes') != -1) { 2015 variant_values_selected = value_check_array.slice(); 2016 } 2017 $(this).closest('.row').find("." + type).select2({ 2018 theme: 'bootstrap4', 2019 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 2020 placeholder: $(this).data('placeholder'), 2021 allowClear: Boolean($(this).data('allow-clear')), 2022 }); 2023 $(this).closest('.row').find(".multiple_values").select2({ 2024 theme: 'bootstrap4', 2025 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 2026 placeholder: $(this).data('placeholder'), 2027 allowClear: Boolean($(this).data('allow-clear')), 2028 data: data, 2029 }); 2030 2031 2032}); 2033 2034$(document).on('click', ' #add_attributes , #tab-for-variations', function (e) { 2035 2036 if (e.target.id == 'add_attributes') { 2037 2038 $('.no-attributes-added').hide(); 2039 $('#save_attributes').removeClass('d-none'); 2040 counter++; 2041 var $attribute = $('#attributes_values_json_data').find('.select_single'); 2042 var $options = $($attribute).clone().html(); 2043 var attr_name = 'pro_attr_' + counter; 2044 // product-attr-selectbox 2045 if ($('#product-type').val() == 'simple_product') { 2046 var html = '<div class="form-group move row my-auto p-2 border rounded bg-gray-light product-attr-selectbox" id=' + attr_name + '><div class="col-md-1 col-sm-12 text-center my-auto"><i class="fas fa-sort"></i></div><div class="col-md-4 col-sm-12"> <select name="attribute_id[]" class="attributes select_single" data-placeholder=" Type to search and select attributes"><option value=""></option>' + $options + '</select></div><div class="col-md-4 col-sm-12 "> <select name="attribute_value_ids[]" class="multiple_values" multiple="" data-placeholder=" Type to search and select attributes values"><option value=""></option> </select></div><div class="col-md-2 col-sm-6 text-center py-1 align-self-center"> <button type="button" class="btn btn-tool remove_attributes"> <i class="text-danger far fa-times-circle fa-2x "></i> </button></div></div>'; 2047 } else { 2048 $('#note').removeClass('d-none'); 2049 var html = '<div class="form-group row move my-auto p-2 border rounded bg-gray-light product-attr-selectbox" id=' + attr_name + '><div class="col-md-1 col-sm-12 text-center my-auto"><i class="fas fa-sort"></i></div><div class="col-md-4 col-sm-12"> <select name="attribute_id[]" class="attributes select_single" data-placeholder=" Type to search and select attributes"><option value=""></option>' + $options + '</select></div><div class="col-md-4 col-sm-12 "> <select name="attribute_value_ids[]" class="multiple_values" multiple="" data-placeholder=" Type to search and select attributes values"><option value=""></option> </select></div><div class="col-md-2 col-sm-6 text-center py-1 align-self-center"><input type="checkbox" name="variations[]" class="is_attribute_checked custom-checkbox "></div><div class="col-md-1 col-sm-6 text-center py-1 align-self-center "> <button type="button" class="btn btn-tool remove_attributes"> <i class="text-danger far fa-times-circle fa-2x "></i> </button></div></div>'; 2050 } 2051 $('#attributes_process').append(html); 2052 2053 $("#attributes_process").last().find(".attributes").select2({ 2054 theme: 'bootstrap4', 2055 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 2056 placeholder: $(this).data('placeholder'), 2057 allowClear: Boolean($(this).data('allow-clear')), 2058 }); 2059 2060 // $("#attributes_process").last().find(".attributes").trigger('change'); 2061 2062 $("#attributes_process").last().find(".multiple_values").select2({ 2063 theme: 'bootstrap4', 2064 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 2065 placeholder: $(this).data('placeholder'), 2066 allowClear: Boolean($(this).data('allow-clear')), 2067 }); 2068 } 2069 2070 if (e.target.id == 'tab-for-variations') { 2071 $('.additional-info').block({ 2072 message: '<h6>Loading Variations</h6>', 2073 css: { border: '3px solid #E7F3FE' } 2074 }); 2075 if (attributes_values.length > 0) { 2076 2077 $('.no-variants-added').hide(); 2078 create_variants(false, from); 2079 2080 } 2081 setTimeout(function () { 2082 $('.additional-info').unblock(); 2083 }, 3000); 2084 } 2085 2086}); 2087 2088$(document).on('click', '#reset_variants', function () { 2089 2090 Swal.fire({ 2091 title: 'Are You Sure To Reset!', 2092 text: "You won't be able to revert this after update!", 2093 type: 'warning', 2094 showCancelButton: true, 2095 confirmButtonColor: '#3085d6', 2096 cancelButtonColor: '#d33', 2097 confirmButtonText: 'Yes, Reset it!', 2098 showLoaderOnConfirm: true, 2099 allowOutsideClick: false 2100 }).then((result) => { 2101 if (result.value) { 2102 $('.additional-info').block({ 2103 message: '<h6>Reseting Variations</h6>', 2104 css: { border: '3px solid #E7F3FE' } 2105 }); 2106 if (attributes_values.length > 0) { 2107 $('.no-variants-added').hide(); 2108 create_variants(false, 'seller'); 2109 } 2110 setTimeout(function () { 2111 $('.additional-info').unblock(); 2112 }, 2000); 2113 } 2114 }); 2115}); 2116 2117$(document).on('click', '.remove_edit_attribute', function (e) { 2118 2119 $(this).closest('.row').remove(); 2120}); 2121 2122$(document).on('click', '.remove_attributes , .remove_variants', function (e) { 2123 Swal.fire({ 2124 title: 'Are you sure want to delete!', 2125 text: "You won't be able to revert this after update!", 2126 type: 'warning', 2127 showCancelButton: true, 2128 confirmButtonColor: '#3085d6', 2129 cancelButtonColor: '#d33', 2130 confirmButtonText: 'Yes, Delete it!', 2131 showLoaderOnConfirm: true, 2132 allowOutsideClick: false 2133 }).then((result) => { 2134 if (result.value) { 2135 var text = this.className; 2136 if (text.search('remove_attributes') != -1) { 2137 var edit_id = $('#edit_product_id').val(); 2138 2139 attributes_values_selected.splice(attributes_values_selected.indexOf($(this).select2().find(":selected").val()), 1); 2140
2140 $(this).closest('.row').remove(); 2141 counter -= 1; 2142 var numItems = $('.product-attr-selectbox').length; 2143 if (numItems == 0) { 2144 $('.no-attributes-added').show(); 2145 $('#save_attributes').addClass('d-none'); 2146 $('#note').addClass('d-none'); 2147 2148 } 2149 2150 } 2151 if (text.search('remove_variants') != -1) { 2152 variant_values_selected.splice(variant_values_selected.indexOf($(this).select2().find(":selected").val()), 1); 2153 $(this).closest('.form-group').remove(); 2154 variant_counter -= 1; 2155 var numItems = $('.product-variant-selectbox').length; 2156 if (numItems == 0) { 2157 $('.no-variants-added').show(); 2158 } 2159 } 2160 } 2161 }); 2162}); 2163 2164$(document).on('select2:select', '#product-type', function () { 2165 var value = $(this).val(); 2166 if ($.trim(value) != "") { 2167 if (value == 'simple_product') { 2168 $('#variant_stock_level').hide(200); 2169 $('#general_price_section').show(200); 2170 $('.simple-product-save').show(700); 2171 $('.product-attributes').addClass('disabled'); 2172 $('.product-variants').addClass('disabled'); 2173 2174 } 2175 if (value == 'variable_product') { 2176 $('#general_price_section').hide(200); 2177 $('.simple-product-level-stock-management').hide(200); 2178 $('.simple-product-save').hide(200); 2179 $('.product-attributes').addClass('disabled'); 2180 $('.product-variants').addClass('disabled'); 2181 $('#variant_stock_level').show(); 2182 } 2183 2184 } else { 2185 $('.product-attributes').addClass('disabled'); 2186 $('.product-variants').addClass('disabled'); 2187 $('#general_price_section').hide(200); 2188 $('.simple-product-level-stock-management').hide(200); 2189 $('.simple-product-save').hide(200) 2190 $('#variant_stock_level').hide(200); 2191 } 2192}); 2193 2194$(document).on('change', '.variant_stock_status', function () { 2195 if ($(this).prop("checked") == true) { 2196 $(this).attr("checked", true); 2197 $('#stock_level').show(200); 2198 } else { 2199 $(this).attr("checked", false); 2200 $('#stock_level').hide(200); 2201 } 2202}); 2203 2204$(document).on('change', '.variant-stock-level-type', function () { 2205 if ($('.variant-stock-level-type').val() == 'product_level') { 2206 $('.variant-product-level-stock-management').show(); 2207 } 2208 if ($.trim($('.variant-stock-level-type').val()) != 'product_level') { 2209 $('.variant-product-level-stock-management').hide(); 2210 } 2211}); 2212 2213$(document).on('change', '.simple_stock_management_status', function () { 2214 if ($(this).prop("checked") == true) { 2215 $(this).attr("checked", true); 2216 $('.simple-product-level-stock-management').show(200); 2217 } else { 2218 $(this).attr("checked", false); 2219 $('.simple-product-level-stock-management').hide(200); 2220 $('.simple-product-level-stock-management').find('input').val(''); 2221 } 2222}); 2223 2224$(document).on('click', '#save_attributes', function () { 2225 Swal.fire({ 2226 title: 'Are you sure want to save changes!', 2227 text: "Do not save attributes if you made no changes! It will reset the variants if there are no changes in attributes or its values !", 2228 type: 'warning', 2229 showCancelButton: true, 2230 confirmButtonColor: '#3085d6', 2231 cancelButtonColor: '#d33', 2232 confirmButtonText: 'Yes, save it!', 2233 showLoaderOnConfirm: true, 2234 allowOutsideClick: false 2235 }).then((result) => { 2236 if (result.value) { 2237 attribute_flag = 1; 2238 save_attributes(); 2239 create_fetched_variants_html(true, from); 2240 iziToast.success({ 2241 message: 'Attributes Saved Succesfully', 2242 }); 2243 } 2244 }); 2245}); 2246 2247$('#attributes_process').sortable({ 2248 axis: 'y', 2249 opacity: 0.6, 2250 cursor: 'grab' 2251}); 2252 2253$('#variants_process').sortable({ 2254 axis: 'y', 2255 opacity: 0.6, 2256 cursor: 'grab' 2257}); 2258
2259$(document).on('click', '.reset-settings', function (e) { 2260 2261 Swal.fire({ 2262 title: 'Are You Sure To Reset!', 2263 text: "This will reset all attributes && variants too if added.", 2264 type: 'warning', 2265 showCancelButton: true, 2266 confirmButtonColor: '#3085d6', 2267 cancelButtonColor: '#d33', 2268 confirmButtonText: 'Yes, Reset it!', 2269 showLoaderOnConfirm: true, 2270 allowOutsideClick: false 2271 }).then((result) => { 2272 if (result.value) { 2273 attributes_values_selected = []; 2274 value_check_array = []; 2275 pre_selected_attr_values = []; 2276 var html = ' <input type="hidden" name="reset_settings" value="1"><div class="row mt-4 col-md-12 "> <nav class="w-100"><div class="nav nav-tabs" id="product-tab" role="tablist"> <a class="nav-item nav-link active" id="tab-for-general-price" data-toggle="tab" href="#general-settings" role="tab" aria-controls="general-price" aria-selected="true">General</a> <a class="nav-item nav-link disabled product-attributes" id="tab-for-attributes" data-toggle="tab" href="#product-attributes" role="tab" aria-controls="product-attributes" aria-selected="false">Attributes</a> <a class="nav-item nav-link disabled product-variants d-none" id="tab-for-variations" data-toggle="tab" href="#product-variants" role="tab" aria-controls="product-variants" aria-selected="false">Variations</a></div> </nav><div class="tab-content p-3 col-md-12" id="nav-tabContent"><div class="tab-pane fade active show" id="general-settings" role="tabpanel" aria-labelledby="general-settings-tab"><div class="form-group"> <label for="type" class="col-md-2">Type Of Product :</label><div class="col-md-12"> <input type="hidden" name="product_type"> <input type="hidden" name="simple_product_stock_status"> <input type="hidden" name="variant_stock_level_type"> <input type="hidden" name="variant_stock_status"> <select name="type" id="product-type" class="form-control product-type" data-placeholder=" Type to search and select type"><option value=" ">Select Type</option><option value="simple_product">Simple Product</option><option value="variable_product">Variable Product</option> </select></div></div><div id="product-general-settings"><div id="general_price_section" class="collapse"><div class="form-group"> <label for="type" class="col-md-2">Price:</label><div class="col-md-12"> <input type="number" name="simple_price" class="form-control stock-simple-mustfill-field price" min="0"></div></div><div class="form-group"> <label for="type" class="col-md-2">Special Price:</label><div class="col-md-12"> <input type="number" name="simple_special_price" class="form-control discounted_price" min="0"></div></div><div class="form-group"><div class="col"> <input type="checkbox" name="simple_stock_management_status" class="align-middle simple_stock_management_status"> <span class="align-middle">Enable Stock Management</span></div></div></div><div class="form-group simple-product-level-stock-management collapse"><div class="col col-xs-12"> <label class="control-label">SKU :</label> <input type="text" name="product_sku" class="col form-control simple-pro-sku"></div><div class="col col-xs-12"> <label class="control-label">Total Stock :</label> <input type="text" name="product_total_stock" class="col form-control stock-simple-mustfill-field"></div><div class="col col-xs-12"> <label class="control-label">Stock Status :</label> <select type="text" class="col form-control stock-simple-mustfill-field" id="simple_product_stock_status"><option value="1">In Stock</option><option value="0">Out Of Stock</option> </select></div></div><div class="form-group collapse simple-product-save"><div class="col"> <a href="javascript:void(0);" class="btn btn-primary save-settings">Save Settings</a></div></div></div><div id="variant_stock_level" class="collapse"><div class="form-group"><div class="col"> <input type="checkbox" name="variant_stock_management_status" class="align-middle variant_stock_status"> <span class="align-middle"> Enable Stock Management</span></div></div><div class="form-group collapse" id="stock_level"> <label for="type" class="col-md-2">Choose Stock Management Type:</label><div class="col-md-12"> <select id="stock_level_type" class="form-control variant-stock-level-type" data-placeholder=" Type to search and select type"><option value=" ">Select Stock Type</option><option value="product_level">Product Level ( Stock Will Be Managed Generally )</option><option value="variable_level">Variable Level ( Stock Will Be Managed Variant Wise )</option> </select><div class="form-group row variant-product-level-stock-management collapse"><div class="col col-xs-12"> <label class="control-label">SKU :</label> <input type="text" name="sku_variant_type" class="col form-control"></div><div class="col col-xs-12"> <label class="control-label">Total Stock :</label> <input type="text" name="total_stock_variant_type" class="col form-control variant-stock-mustfill-field"></div><div class="col col-xs-12"> <label class="control-label">Stock Status :</label> <select type="text" id="stock_status_variant_type" name="variant_status" class="col form-control variant-stock-mustfill-field"><option value="1">In Stock</option><option value="0">Out Of Stock</option> </select></div></div></div></div><div class="form-group"><div class="col"> <a href="javascript:void(0);
2276" class="btn btn-primary save-variant-general-settings">Save Settings</a></div></div></div></div><div class="tab-pane fade" id="product-attributes" role="tabpanel" aria-labelledby="product-attributes-tab"><div class="info col-12 p-3 d-none" id="note"><div class=" col-12 d-flex align-center"> <strong>Note : </strong> <input type="checkbox" checked="checked" class="ml-3 my-auto custom-checkbox" disabled> <span class="ml-3">check if the attribute is to be used for variation </span></div></div><div class="col-md-12"> <a href="javascript:void(0);" id="add_attributes" class="btn btn-block btn-outline-primary col-md-2 float-right m-2 btn-sm">Add Attributes</a> <a href="javascript:void(0);" id="save_attributes" class="btn btn-block btn-outline-primary col-md-2 float-right m-2 btn-sm d-none">Save Attributes</a></div><div class="clearfix"></div><div id="attributes_process"><div class="form-group text-center row my-auto p-2 border rounded bg-gray-light col-md-12 no-attributes-added"><div class="col-md-12 text-center">No Product Attribures Are Added !</div></div></div></div><div class="tab-pane fade" id="product-variants" role="tabpanel" aria-labelledby="product-variants-tab"><div class="clearfix"></div><div class="form-group text-center row my-auto p-2 border rounded bg-gray-light col-md-12 no-variants-added"><div class="col-md-12 text-center">No Product Variations Are Added !</div></div><div id="variants_process" class="ui-sortable"></div></div></div></div>'; 2277 $('.additional-info').html(html); 2278 $('.no-attributes-added').show(); 2279 $('#product-type').each(function () { 2280 $(this).select2({ 2281 theme: 'bootstrap4', 2282 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 2283 placeholder: $(this).data('placeholder'), 2284 allowClear: Boolean($(this).data('allow-clear')), 2285 }); 2286 }); 2287 } 2288 }); 2289 2290 2291}); 2292$(document).on('click', '.save-settings', function (e) { 2293 e.preventDefault(); 2294 2295 if ($('.simple_stock_management_status').is(':checked')) { 2296 var len = 0 2297 } else { 2298 var len = 1 2299 } 2300 2301 if ($('.stock-simple-mustfill-field').filter(function () { return this.value === ''; }).length === len) { 2302 $('.additional-info').block({ 2303 message: '<h6>Saving Settings</h6>', 2304 css: { border: '3px solid #E7F3FE' } 2305 }); 2306 2307 $('input[name="product_type"]').val($('#product-type').val()); 2308 if ($('.simple_stock_management_status').is(':checked')) { 2309 $('input[name="simple_product_stock_status"]').val($('#simple_product_stock_status').val()); 2310 } else { 2311 $('input[name="simple_product_stock_status"]').val(''); 2312 } 2313 $('#product-type').prop('disabled', true); 2314 $('.product-attributes').removeClass('disabled'); 2315 $('.product-variants').removeClass('disabled'); 2316 $('.simple_stock_management_status').prop('disabled', true); 2317 setTimeout(function () { 2318 $('.additional-info').unblock(); 2319 }, 2000); 2320 2321 } else { 2322 iziToast.error({ 2323 message: 'Please Fill All The Fields', 2324 }); 2325 } 2326}); 2327 2328$(document).on('click', '.save-variant-general-settings', function (e) { 2329 e.preventDefault(); 2330 if ($('.variant_stock_status').is(":checked")) { 2331 if ($('.variant-stock-level-type').filter(function () { return this.value === ''; }).length === 0 && $.trim($('.variant-stock-level-type').val()) != "") { 2332 2333 if ($('.variant-stock-level-type').val() == 'product_level' && $('.variant-stock-mustfill-field').filter(function () { return this.value === ''; }).length !== 0) { 2334 iziToast.error({ 2335 message: 'Please Fill All The Fields', 2336 }); 2337 } else { 2338 $('input[name="product_type"]').val($('#product-type').val()); 2339 $('input[name="variant_stock_level_type"]').val($('#stock_level_type').val()); 2340 $('input[name="variant_stock_status"]').val("0"); 2341 $('#product-type').prop('disabled', true); 2342 $('#stock_level_type').prop('disabled', true);
2343 $(this).removeClass('save-variant-general-settings'); 2344 $('.product-attributes').removeClass('disabled'); 2345 $('.product-variants').removeClass('disabled'); 2346 $('.variant-stock-level-type').prop('readonly', true); 2347 $('#stock_status_variant_type').attr('readonly', true); 2348 $('.variant-product-level-stock-management').find('input,select').prop('readonly', true); 2349 $('#tab-for-variations').removeClass('d-none'); 2350 $('.variant_stock_status').prop('disabled', true); 2351 $('#product-tab a[href="#product-attributes"]').tab('show'); 2352 Swal.fire('Settings Saved !', 'Attributes & Variations Can Be Added Now', 'success'); 2353 } 2354 } else { 2355 iziToast.error({ 2356 message: 'Please Fill All The Fields', 2357 }); 2358 } 2359 2360 } else { 2361 2362 $('input[name="product_type"]').val($('#product-type').val()); 2363 $('input[name="variant_stock_status"]').val(""); 2364 $('input[name="variant_stock_level_type"]').val(""); 2365 $('#product-tab a[href="#product-attributes"]').tab('show'); 2366 $('.variant_stock_status').prop('disabled', true); 2367 $('#product-type').prop('disabled', true); 2368 $('.product-attributes').removeClass('disabled'); 2369 $('.product-variants').removeClass('disabled'); 2370 $('#tab-for-variations').removeClass('d-none'); 2371 Swal.fire('Settings Saved !', 'Attributes & Variations Can Be Added Now', 'success'); 2372 } 2373 2374}); 2375 2376 2377$(document).on('change', '.new-added-variant', function () { 2378 2379 var myOpts = $(this).children().map(function () { return $(this).val(); }).get(); 2380 var variant_id = $(this).val(); 2381 var curr_vals = []; 2382 var $variant_ids = $(this).closest('.product-variant-selectbox').find('input[name="variants_ids[]"]').val(); 2383 $.each($variant_ids.split(','), function (key, val) { 2384 if (val != '') { 2385 curr_vals[key] = $.trim(val); 2386 } 2387 }); 2388 var newvalues = curr_vals.filter((el) => !myOpts.includes(el)); 2389 var len = newvalues.length; 2390 if (variant_id != '') { 2391 newvalues[len] = $.trim(variant_id); 2392 } 2393 $(this).closest('.product-variant-selectbox').find('input[name="variants_ids[]"]').val(newvalues.toString()); 2394}); 2395 2396 2397 2398function get_seller_categories(seller_id, ignore_status, edit_id, from) { 2399 $.ajax({ 2400 type: 'GET', 2401 url: base_url + from + '/category/get_seller_categories', 2402 data: { 2403 "ignore_status": ignore_status, 2404 "seller_id": seller_id 2405 }, 2406 dataType: 'json', 2407 success: function (result) { 2408 if (result != "") { 2409 result.data = result.data.filter(function( obj ) { 2410 return obj.parent_id == '0'; 2411 }); 2412 } 2413 $('#product_category_tree_view_html').jstree("destroy").empty(); 2414 $('#product_category_tree_view_html').jstree({ 2415 plugins: ["checkbox", 'themes'], 2416 'core': { 2417 multiple: false, 2418 'data': result['data'], 2419 }, 2420 checkbox: { 2421 three_state: false, 2422 cascade: "none" 2423 } 2424 }); 2425 2426 $('#product_category_tree_view_html') 2427 .bind('ready.jstree', function (e, data) { 2428 $(this).jstree(true).select_node(edit_id); 2429 }); 2430 } 2431 }); 2432} 2433 2434if (window.location.href.indexOf("admin/product") > -1) { 2435 var edit_id = $('input[name="category_id"]').val(); 2436 var seller_id = $('input[name="seller_id"]').val(); 2437 var ignore_status = $.isNumeric(edit_id) && edit_id > 0 ? 1 : 0; 2438 if ($.isNumeric(seller_id) && seller_id > 0) { 2439 2440 2441 get_seller_categories(seller_id, ignore_status, edit_id, 'admin'); 2442 } else { 2443 $.ajax({ 2444 type: 'GET', 2445 url: base_url + 'admin/category/get_categories', 2446 data: { 2447 "ignore_status": ignore_status 2448 }, 2449 dataType: 'json', 2450 success: function (result) { 2451 var edit_id = $('input[name="category_id"]').val(); 2452 $('#product_category_tree_view_html').jstree({ 2453 plugins: ["checkbox", 'themes'], 2454 'core': { 2455 'data': result['data'], 2456 multiple: false 2457 }, 2458 checkbox: { 2459 three_state: false, 2460 cascade: "none" 2461 } 2462 }); 2463 2464 $('#product_category_tree_view_html') 2465 .bind('ready.jstree', function (e, data) { 2466 $(this).jstree(true).select_node(edit_id); 2467 }); 2468 } 2469 }); 2470 } 2471} 2472$(document).on('click', '.update_active_status', function () { 2473 2474 var update_id = $(this).data('id'); 2475 var status = $(this).data('status'); 2476 var table = $(this).data('table'); 2477 update_status(update_id, status, table, from); 2478 2479}); 2480if (window.location.href.indexOf("seller/product") > -1) { 2481 var edit_id = $('input[name="category_id"]').val(); 2482 var seller_id = $('input[name="seller_id"]').val(); 2483 var ignore_status = $.isNumeric(edit_id) && edit_id > 0 ? 1 : 0; 2484 if ($.isNumeric(seller_id) && seller_id > 0) { 2485 get_seller_categories(seller_id, ignore_status, edit_id, from); 2486 } else { 2487 $.ajax({ 2488 type: 'GET', 2489 url: base_url + 'seller/category/get_categories', 2490 data: { 2491 "ignore_status": ignore_status 2492 }, 2493 dataType: 'json', 2494 success: function (result) { 2495 var edit_id = $('input[name="category_id"]').val(); 2496 $('#product_category_tree_view_html').jstree({ 2497 plugins: ["checkbox", 'themes'], 2498 'core': { 2499 'data': result['data'], 2500 multiple: false 2501 }, 2502 checkbox: { 2503 three_state: false, 2504 cascade: "none" 2505 } 2506 }); 2507 2508 $('#product_category_tree_view_html') 2509 .bind('ready.jstree', function (e, data) { 2510 $(this).jstree(true).select_node(edit_id); 2511 }); 2512 } 2513 }); 2514 } 2515 2516} 2517 2518$(document).on('change', '#seller_id', function (e) { 2519 e.preventDefault(); 2520 var edit_id = $('input[name="category_id"]').val(); 2521 var seller_id = $(this).val(); 2522 var ignore_status = $.isNumeric(edit_id) && edit_id > 0 ? 1 : 0; 2523 get_seller_categories(seller_id, ignore_status, edit_id, 'admin'); 2524}); 2525 2526 2527// 3.Category-Module 2528$(document).on('click', '#list_view', function () { 2529 $('#list_view_html').show(); 2530 $('#tree_view_html').hide(); 2531}); 2532 2533$(document).on('click', '#tree_view', function () { 2534 $('#tree_view_html').show(); 2535 $('#list_view_html').hide(); 2536 2537 var category_url = base_url + 'admin/category/get_categories'; 2538 if (from == 'seller') { 2539 category_url = base_url + 'seller/category/get_seller_categories'; 2540 } 2541 $.ajax({ 2542 type: 'GET', 2543 url: category_url, 2544 dataType: 'json', 2545 success: function (result) { 2546 $('#tree_view_html').jstree({ 2547 'core': { 2548 'data': result['data'] 2549 } 2550 }); 2551 } 2552 }); 2553}); 2554 2555function update_status(update_id, status, table, user) { 2556 $.ajax({ 2557 type: 'GET', 2558 url: base_url + user + '/home/update_status', 2559 data: { id: update_id, status: status, table: table }, 2560 dataType: 'json', 2561 success: function (result) { 2562 if (result['error'] == true) { 2563 iziToast.success({ 2564 message: '<span style="text-transform:capitalize">' + result.message + '</span>
2564 Status Updated', 2565 }); 2566 $('.table').bootstrapTable('refresh'); 2567 } else { 2568 iziToast.error({ 2569 message: '<span style="text-transform:capitalize">' + result.message + '</span> Status Not Updated', 2570 }); 2571 } 2572 } 2573 }); 2574} 2575 2576$(document).on('click', '.update_default_theme', function () { 2577 var theme_id = $(this).data('id'); 2578 $.ajax({ 2579 type: 'POST', 2580 url: base_url + 'admin/setting/set-default-theme', 2581 data: { [csrfName]: csrfHash, theme_id: theme_id }, 2582 dataType: 'json', 2583 success: function (result) { 2584 csrfName = result.csrfName; 2585 csrfHash = result.csrfHash; 2586 if (result['error'] == false) { 2587 iziToast.success({ 2588 message: result.message, 2589 }); 2590 $('.table').bootstrapTable('refresh'); 2591 } else { 2592 iziToast.error({ 2593 message: result.message, 2594 }); 2595 } 2596 } 2597 }); 2598}); 2599 2600$(document).on('click', '#delete-category', function () { 2601 var cat_id = $(this).data('id'); 2602 Swal.fire({ 2603 title: 'Are You Sure!', 2604 text: "You won't be able to revert this!", 2605 type: 'warning', 2606 showCancelButton: true, 2607 confirmButtonColor: '#3085d6', 2608 cancelButtonColor: '#d33', 2609 confirmButtonText: 'Yes, delete it!', 2610 showLoaderOnConfirm: true, 2611 preConfirm: function () { 2612 return new Promise((resolve, reject) => { 2613 $.ajax({ 2614 type: 'GET', 2615 url: base_url + 'admin/category/delete_category', 2616 data: { id: cat_id }, 2617 dataType: 'json' 2618 }) 2619 .done(function (response, textStatus) { 2620 if (response.error == false) { 2621 Swal.fire('Deleted!', response.message, 'success'); 2622 $('table').bootstrapTable('refresh'); 2623 csrfName = response['csrfName']; 2624 csrfHash = response['csrfHash']; 2625 } else { 2626 Swal.fire('Oops...', response.message, 'warning'); 2627 $('table').bootstrapTable('refresh'); 2628 csrfName = response['csrfName']; 2629 csrfHash = response['csrfHash']; 2630 } 2631 2632 }) 2633 .fail(function (jqXHR, textStatus, errorThrown) { 2634 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 2635 csrfName = response['csrfName']; 2636 csrfHash = response['csrfHash']; 2637 }); 2638 }); 2639 }, 2640 allowOutsideClick: false 2641 }); 2642}); 2643 2644$('#category_parent').each(function () { 2645 $(this).select2({ 2646 theme: 'bootstrap4', 2647 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 2648 placeholder: $(this).data('placeholder'), 2649 allowClear: Boolean($(this).data('allow-clear')), 2650 dropdownCssClass: "test", 2651 templateResult: function (data) { 2652 // We only really care if there is an element to pull classes from 2653 if (!data.element) { 2654 return data.text; 2655 } 2656 2657 var $element = $(data.element); 2658 2659 var $wrapper = $('<span></span>'); 2660 $wrapper.addClass($element[0].className); 2661 2662 $wrapper.text(data.text); 2663 2664 return $wrapper; 2665 } 2666 }); 2667}); 2668 2669$(document).on('click', '#save_category_order', function () { 2670 var data = $('#sortable').sortable('serialize'); 2671 $.ajax({ 2672 data: data, 2673 type: 'GET', 2674 url: base_url + 'admin/category/update_category_order', 2675 dataType: 'json', 2676 success: function (response) { 2677 if (response.error == false) { 2678 iziToast.success({ 2679 message: response.message, 2680 }); 2681 } else { 2682 iziToast.error({ 2683 message: response.message, 2684 }); 2685 } 2686 } 2687 }); 2688}); 2689 2690 2691//4.Order-Module 2692$('#datepicker').attr({ 'placeholder': ' Select Date Of Ranges To Filter ', 'autocomplete': 'off' }); 2693$('#datepicker').on('cancel.daterangepicker', function (ev, picker) { 2694 $(this).val(''); 2695 $('#start_date').val(''); 2696 $('#end_date').val(''); 2697}); 2698$('#datepicker').on('apply.daterangepicker', function (ev, picker) { 2699 var drp = $('#datepicker').data('daterangepicker'); 2700 $('#start_date').val(drp.startDate.format('YYYY-MM-DD')); 2701 $('#end_date').val(drp.endDate.format('YYYY-MM-DD')); 2702 $(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY')); 2703}); 2704 2705$('#datepicker').daterangepicker({ 2706 showDropdowns: true, 2707 alwaysShowCalendars: true, 2708 autoUpdateInput: false, 2709 ranges: { 2710 'Today': [moment(), moment()], 2711 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], 2712 'Last 7 Days': [moment().subtract(6, 'days'), moment()], 2713 'Last 30 Days': [moment().subtract(29, 'days'), moment()], 2714 'This Month': [moment().startOf('month'), moment().endOf('month')], 2715 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] 2716 }, 2717 startDate: moment().subtract(29, 'days'), 2718 endDate: moment(), 2719 locale: { 2720 "format": "DD/MM/YYYY", 2721 "separator": " - ", 2722 "cancelLabel": 'Clear', 2723 'label': 'Select range of dates to filter' 2724 } 2725}); 2726 2727$(document).on('click', '.update_discount', function () { 2728 var field = 'discount'; 2729 var orderid = $(this).data('orderid'); 2730 var json = $(this).data('isjson'); 2731 if (typeof json == 'undefined') { 2732 json = false;
2733 } 2734 val = $(this).parent().find('input[type=number]').val(); 2735 var amount = $('#amount').html(); 2736 var delivery_charge = $('#delivery_charge').html(); 2737 var total = parseInt(amount) + parseInt(delivery_charge); 2738 $.ajax({ 2739 type: 'POST', 2740 url: base_url + 'admin/orders/update_orders', 2741 data: { orderid: orderid, field: field, val: val, json: json, [csrfName]: csrfHash }, 2742 dataType: 'json', 2743 success: function (result) { 2744 csrfName = result['csrfName']; 2745 csrfHash = result['csrfHash']; 2746 if (result['error'] == false) { 2747 iziToast.success({ 2748 message: 'Discount Updated Succesfully', 2749 }); 2750 $('#final_total').val(parseInt(result['total_amount'])); 2751 } else { 2752 2753 iziToast.error({ 2754 title: 'Error', 2755 message: 'Illegal operation', 2756 }); 2757 } 2758 } 2759 }); 2760}); 2761 2762$(document).on('click', '.update_status_admin', function (e) { 2763 var order_id = $(this).data('id'); 2764 var status = $(this).closest('.row').find('select').val(); 2765 2766 Swal.fire({ 2767 title: 'Are You Sure!', 2768 text: "You won't be able to revert this!", 2769 type: 'warning', 2770 showCancelButton: true, 2771 confirmButtonColor: '#3085d6', 2772 cancelButtonColor: '#d33', 2773 confirmButtonText: 'Yes, update it!', 2774 showLoaderOnConfirm: true, 2775 preConfirm: function () { 2776 return new Promise((resolve, reject) => { 2777 $.ajax({ 2778 type: 'POST', 2779 url: base_url + from + '/orders/update_order_status', 2780 data: { 'order_item_id[]': order_id, status: status, [csrfName]: csrfHash }, 2781 dataType: 'json', 2782 success: function (result) { 2783 csrfName = result['csrfName']; 2784 csrfHash = result['csrfHash']; 2785 if (result['error'] == false) { 2786 iziToast.success({ 2787 message: result['message'], 2788 }); 2789 } else { 2790 iziToast.error({ 2791 message: result['message'], 2792 }); 2793 } 2794 swal.close(); 2795 } 2796 }); 2797 }); 2798 }, 2799 allowOutsideClick: false 2800 }); 2801}); 2802$(document).on('click', '.update_delivery_boy_admin', function (e) { 2803 var order_id = $(this).data('id'); 2804 var d_boy = $(this).closest('.delivery_boy').find('select').val(); 2805 Swal.fire({ 2806 title: 'Are You Sure!', 2807 text: "You won't be able to revert this!", 2808 type: 'warning', 2809 showCancelButton: true, 2810 confirmButtonColor: '#3085d6', 2811 cancelButtonColor: '#d33', 2812 confirmButtonText: 'Yes, update it!', 2813 showLoaderOnConfirm: true, 2814 preConfirm: function () { 2815 return new Promise((resolve, reject) => { 2816 $.ajax({ 2817 type: 'POST', 2818 url: base_url + from + '/orders/update_order_status', 2819 data: { 'order_item_id[]': order_id, deliver_by: d_boy, [csrfName]: csrfHash }, 2820 dataType: 'json', 2821 success: function (result) { 2822 csrfName = result['csrfName']; 2823 csrfHash = result['csrfHash']; 2824 if (result['error'] == false) { 2825 iziToast.success({ 2826 message: result['message'], 2827 }); 2828 } else { 2829 iziToast.error({ 2830 message: result['message'], 2831 }); 2832 } 2833 swal.close(); 2834 } 2835 }); 2836 }); 2837 }, 2838 allowOutsideClick: false 2839 }); 2840}); 2841$(document).on('click', '.update_status_admin_bulk', function (e) { 2842 var data = $('#update_form').serialize(); 2843 Swal.fire({ 2844 title: 'Are You Sure!', 2845 text: "You won't be able to revert this!", 2846 type: 'warning', 2847 showCancelButton: true, 2848 confirmButtonColor: '#3085d6', 2849 cancelButtonColor: '#d33', 2850 confirmButtonText: 'Yes, update it!', 2851 showLoaderOnConfirm: true, 2852 preConfirm: function () { 2853 return new Promise((resolve, reject) => { 2854 $.ajax({ 2855 type: 'POST', 2856 url: base_url + from + '/orders/update_order_status', 2857 data: data + "&" + csrfName + "=" + csrfHash, 2858 dataType: 'json', 2859 success: function (result) { 2860 csrfName = result['csrfName']; 2861 csrfHash = result['csrfHash']; 2862 if (result['error'] == false) { 2863 iziToast.success({ 2864 message: result['message'], 2865 }); 2866 } else { 2867 iziToast.error({ 2868 message: result['message'], 2869 }); 2870 } 2871 swal.close(); 2872 } 2873 }); 2874 }); 2875 }, 2876 allowOutsideClick: false 2877 }); 2878}); 2879 2880$(document).on('click', '.update_status_delivery_boy', function (e) { 2881 var order_item_id = $(this).data('id'); 2882 var otp_system = $(this).data('otp-system'); 2883 order_item_id = order_item_id.replace(' ', ''); 2884 var status = $(this).closest('.row').find('select').val(); 2885 var post_otp = 0; 2886 if (otp_system == 1 && status == 'delivered') { 2887 post_otp = prompt('Enter Order OTP'); 2888 } 2889 2890 Swal.fire({ 2891 title: 'Are You Sure!', 2892 text: "You won't be able to revert this!", 2893 type: 'warning', 2894 showCancelButton: true, 2895 confirmButtonColor: '#3085d6', 2896 cancelButtonColor: '#d33', 2897 confirmButtonText: 'Yes, update it!', 2898 showLoaderOnConfirm: true, 2899 preConfirm: function () { 2900 return new Promise((resolve, reject) => { 2901 $.ajax({ 2902 type: 'GET', 2903 url: base_url + 'delivery_boy/orders/update_order_status', 2904 data: { id: order_item_id, status: status, otp: post_otp }, 2905 dataType: 'json', 2906 success: function (result) { 2907 csrfName = result['csrfName']; 2908 csrfHash = result['csrfHash']; 2909 if (result['error'] == false) { 2910 iziToast.success({ 2911 message: result['message'], 2912 }); 2913 } else { 2914 iziToast.error({ 2915 message: result['message'], 2916 }); 2917 } 2918 swal.close(); 2919 } 2920 }); 2921 }); 2922 }, 2923 allowOutsideClick: false 2924 }); 2925 2926}); 2927 2928$(document).on('click', '.delete-orders', function () { 2929 var id = $(this).data('id'); 2930 Swal.fire({ 2931 title: 'Are You Sure!', 2932 text: "You won't be able to revert this!", 2933 type: 'warning', 2934 showCancelButton: true, 2935 confirmButtonColor: '#3085d6', 2936 cancelButtonColor: '#d33', 2937 confirmButtonText: 'Yes, delete it!', 2938 showLoaderOnConfirm: true, 2939 preConfirm: function () { 2940 return new Promise((resolve, reject) => { 2941 $.ajax({ 2942 type: 'GET', 2943 url: base_url + 'admin/orders/delete_orders', 2944 data: { id: id }, 2945 dataType: 'json', 2946 success: function (result) { 2947 if (result['error'] == false) { 2948 Swal.fire('Deleted!', 'success'); 2949 $('table').bootstrapTable('refresh'); 2950 } else { 2951 Swal.fire('Oops...', result['message'], 'error'); 2952 } 2953 } 2954 }); 2955 }); 2956 }, 2957 allowOutsideClick: false 2958 }) 2959 .then((result) => { 2960 if (result.dismiss === Swal.DismissReason.cancel) { 2961 Swal.fire( 2962 'Cancelled!', 2963 'Your data is safe.', 2964 'error' 2965 ); 2966 } 2967 }); 2968 2969}); 2970$(document).on('click', '.delete-order-items', function () { 2971 var id = $(this).data('id'); 2972 Swal.fire({ 2973 title: 'Are You Sure!', 2974 text: "You won't be able to revert this!", 2975 type: 'warning', 2976 showCancelButton: true, 2977 confirmButtonColor: '#3085d6', 2978 cancelButtonColor: '#d33', 2979 confirmButtonText: 'Yes, delete it!', 2980 showLoaderOnConfirm: true, 2981 preConfirm: function () { 2982 return new Promise((resolve, reject) => { 2983 $.ajax({ 2984 type: 'GET', 2985 url: base_url + 'admin/orders/delete_order_items', 2986 data: { id: id }, 2987 dataType: 'json', 2988 success: function (result) { 2989 if (result['error'] == false) { 2990 Swal.fire('Deleted!', 'success'); 2991 $('table').bootstrapTable('refresh'); 2992 } else { 2993 Swal.fire('Oops...', result['message'], 'error'); 2994 } 2995 } 2996 }); 2997 }); 2998 }, 2999 allowOutsideClick: false 3000 }) 3001 .then((result) => { 3002 if (result.dismiss === Swal.DismissReason.cancel) { 3003 Swal.fire( 3004 'Cancelled!', 3005 'Your data is safe.', 3006 'error' 3007 ); 3008 } 3009 }); 3010 3011}); 3012 3013$(document).on('click', '.remove-sellers', function () { 3014 var id = $(this).data('id'); 3015 var status = $(this).data('seller_status'); 3016 Swal.fire({ 3017 title: 'Are You Sure! All data & media will be remove related to this seller', 3018 text: "You won't be able to revert this!", 3019 type: 'warning', 3020 showCancelButton: true, 3021 confirmButtonColor: '#3085d6', 3022 cancelButtonColor: '#d33', 3023 confirmButtonText: 'Yes, Remove it!', 3024 showLoaderOnConfirm: true, 3025 preConfirm: function () { 3026 return new Promise((resolve, reject) => { 3027 $.ajax({ 3028 type: 'GET', 3029 url: base_url + 'admin/sellers/remove_sellers', 3030 data: { id: id, status: status }, 3031 dataType: 'json', 3032 success: function (result) { 3033 if (result['error'] == false) { 3034 Swal.fire('Removed!', 'success'); 3035 $('table').bootstrapTable('refresh'); 3036 } else { 3037 Swal.fire('Oops...', result['message'], 'error'); 3038 } 3039 } 3040 }); 3041 }); 3042 }, 3043 allowOutsideClick: false 3044 }) 3045 .then((result) => { 3046 if (result.dismiss === Swal.DismissReason.cancel) { 3047 Swal.fire( 3048 'Cancelled!', 3049 'Your data is safe.', 3050 'error' 3051 ); 3052 } 3053 }); 3054}); 3055 3056$(document).on('click', '.delete-sellers', function () { 3057 var id = $(this).data('id'); 3058 Swal.fire({ 3059 title: 'Are You Sure! All data & media will be remove related to this seller', 3060 text: "You won't be able to revert this!", 3061 type: 'warning', 3062 showCancelButton: true, 3063 confirmButtonColor: '#3085d6', 3064 cancelButtonColor: '#d33', 3065 confirmButtonText: 'Yes, Remove it!', 3066 showLoaderOnConfirm: true, 3067 preConfirm: function () { 3068 return new Promise((resolve, reject) => { 3069 $.ajax({ 3070 type: 'GET', 3071 url: base_url + 'admin/sellers/delete_sellers', 3072 data: { id: id }, 3073 dataType: 'json', 3074 success: function (result) { 3075 if (result['error'] == false) { 3076 Swal.fire('Deleted!', result['message']); 3077 setTimeout(function () { 3078 $('table').bootstrapTable('refresh'); 3079 }, 1000); 3080 } else { 3081 Swal.fire('Oops...', result['message'], 'error'); 3082 } 3083 } 3084 }); 3085 }); 3086 }, 3087 allowOutsideClick: false 3088 }) 3089 .then((result) => { 3090 if (result.dismiss === Swal.DismissReason.cancel) { 3091 Swal.fire( 3092 'Cancelled!', 3093 'Your data is safe.', 3094 'error' 3095 ); 3096 } 3097 }); 3098}); 3099 3100//5.Featured_Section-Module 3101$('.select_multiple').each(function () { 3102 $(this).select2({ 3103 theme: 'bootstrap4', 3104 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 3105 placeholder: $(this).data('placeholder'), 3106 allowClear: Boolean($(this).data('allow-clear')), 3107 }); 3108}); 3109 3110 3111$('.search_product').each(function () { 3112 $(this).select2({ 3113 ajax: { 3114 url: base_url + 'admin/product/get_product_data', 3115 dataType: 'json', 3116 delay: 250, 3117 data: function (data) { 3118 return { 3119 search: data.term, // search term 3120 limit: 10 3121 }; 3122 }, 3123 processResults: function (response) { 3124 return { 3125 results: response.rows 3126 }; 3127 }, 3128 cache: true 3129 }, 3130 escapeMarkup: function (markup) { return markup; }, 3131 minimumInputLength: 1, 3132 templateResult: formatRepo, 3133 templateSelection: formatRepoSelection, 3134 placeholder: 'Search for products', 3135 theme: 'bootstrap4', 3136 width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', 3137 placeholder: $(this).data('placeholder'), 3138 allowClear: Boolean($(this).data('allow-clear')), 3139 }); 3140}); 3141 3142$(document).on('click', '#delete-featured-section', function () { 3143 var id = $(this).data('id'); 3144 Swal.fire({ 3145 title: 'Are You Sure!', 3146 text: "You won't be able to revert this!", 3147 type: 'warning', 3148 showCancelButton: true, 3149 confirmButtonColor: '#3085d6', 3150 cancelButtonColor: '#d33', 3151 confirmButtonText: 'Yes, delete it!', 3152 showLoaderOnConfirm: true, 3153 preConfirm: function () { 3154 return new Promise((resolve, reject) => { 3155 $.ajax({ 3156 type: 'GET', 3157 url: base_url + 'admin/featured_sections/delete_featured_section', 3158 data: { id: id }, 3159 dataType: 'json', 3160 success: function (result) { 3161 if (result['error'] == false) { 3162 Swal.fire('Deleted!', result['message'], 'success'); 3163 $('table').bootstrapTable('refresh'); 3164 } else { 3165 Swal.fire('Oops...', result['message'], 'warning'); 3166 } 3167 } 3168 }); 3169 }); 3170 }, 3171 allowOutsideClick: false 3172 }) 3173 .then((result) => { 3174 if (result.dismiss === Swal.DismissReason.cancel) { 3175 Swal.fire( 3176 'Cancelled!', 3177 'Your data is safe.', 3178 'error' 3179 ); 3180 } 3181 }); 3182}); 3183 3184 3185$(document).on('click', '.delete-user', function () { 3186 var id = $(this).data('id'); 3187 Swal.fire({ 3188 title: 'Are You Sure!', 3189 text: "You w
3189on't be able to revert this!", 3190 type: 'warning', 3191 showCancelButton: true, 3192 confirmButtonColor: '#3085d6', 3193 cancelButtonColor: '#d33', 3194 confirmButtonText: 'Yes, delete it!', 3195 showLoaderOnConfirm: true, 3196 preConfirm: function () { 3197 return new Promise((resolve, reject) => { 3198 $.ajax({ 3199 type: 'GET', 3200 url: base_url + 'admin/customer/delete_customer', 3201 data: { id: id }, 3202 dataType: 'json', 3203 success: function (result) { 3204 if (result['error'] == false) { 3205 Swal.fire('Deleted!', result['message'], 'success'); 3206 $('table').bootstrapTable('refresh'); 3207 } else { 3208 Swal.fire('Oops...', result['message'], 'warning'); 3209 } 3210 } 3211 }); 3212 }); 3213 }, 3214 allowOutsideClick: false 3215 }) 3216 .then((result) => { 3217 if (result.dismiss === Swal.DismissReason.cancel) { 3218 Swal.fire( 3219 'Cancelled!', 3220 'Your data is safe.', 3221 'error' 3222 ); 3223 } 3224 }); 3225}); 3226 3227//6.Notifation-Module 3228$("#image_checkbox").on('click', function () { 3229 if (this.checked) { 3230 $(this).prop("checked", true); 3231 $('.include_image').removeClass('d-none'); 3232 } else { 3233 $(this).prop("checked", false); 3234 $('.include_image').addClass('d-none'); 3235 } 3236}); 3237 3238$(document).on('click', '.delete_notifications', function () { 3239 var value = $(this).data('id'); 3240 var url = base_url + 'admin/Notification_settings/delete_notification'; 3241 Swal.fire({ 3242 title: 'Are You Sure !', 3243 text: "You won't be able to revert this!", 3244 type: 'warning', 3245 showCancelButton: true, 3246 confirmButtonColor: '#3085d6', 3247 cancelButtonColor: '#d33', 3248 confirmButtonText: 'Yes, delete it!', 3249 showLoaderOnConfirm: true, 3250 preConfirm: function () { 3251 return new Promise((resolve, reject) => { 3252 $.ajax({ 3253 url: url, 3254 type: 'GET', 3255 data: { 'id': value }, 3256 dataType: 'json', 3257 }) 3258 .done(function (result, textStatus) { 3259 if (result['error'] == false) { 3260 Swal.fire('Deleted!', result['message'], 'success'); 3261 $('table').bootstrapTable('refresh'); 3262 } else { 3263 Swal.fire('Oops...', result['message'], 'warning'); 3264 } 3265 }) 3266 .fail(function (jqXHR, textStatus, errorThrown) { 3267 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3268 }); 3269 }); 3270 }, 3271 allowOutsideClick: false 3272 }); 3273}); 3274 3275//7.Faq-Module 3276$(document).on('click', '.edit_faq', function () { 3277 var faq = $(this).parent().closest('.card'); 3278 if ($(this).hasClass('cancel')) { 3279 $(this).removeClass('cancel'); 3280 $(this).html('<i class="fa fa-pen"></i>'); 3281 $(this).closest('button').addClass('btn-primary').removeClass('btn-danger'); 3282 $(faq).find('input').addClass('d-none'); 3283 $(faq).find('textarea').addClass('d-none'); 3284 $(faq).find('.faq_question').show(); 3285 $(faq).find('.faq_answer').show(); 3286 $(faq).find('.save').addClass('d-none'); 3287 $(faq).find('.collapse').collapse("hide"); 3288 } else { 3289 $(this).addClass('cancel'); 3290 $(this).html('<i class="fa fa-times"></i>'); 3291 $(this).closest('button').addClass('btn-danger').removeClass('btn-primary'); 3292 var question = $(faq).find('.faq_question').html(); 3293 var answer = $(faq).find('.faq_answer').html(); 3294 $(faq).find('.faq_question').hide(); 3295 $(faq).find('.faq_answer').hide(); 3296 $(faq).find('.collapse').collapse("show"); 3297 $(faq).find('input').removeClass('d-none').val($.trim(question)); 3298 $(faq).find('.save').removeClass('d-none'); 3299 $(faq).find('textarea').removeClass('d-none').val($.trim(answer)); 3300 } 3301}); 3302 3303$(document).on('click', '.delete_faq', function () { 3304 var id = $(this).data('id'); 3305 var t = this; 3306 Swal.fire({ 3307 title: 'Are You Sure !', 3308 text: "You won't be able to revert this!", 3309 type: 'warning', 3310 showCancelButton: true, 3311 confirmButtonColor: '#3085d6', 3312 cancelButtonColor: '#d33', 3313 confirmButtonText: 'Yes, delete it!', 3314 showLoaderOnConfirm: true, 3315 preConfirm: function () { 3316 return new Promise((resolve, reject) => { 3317 $.ajax({ 3318 url: base_url + 'admin/faq/delete_faq', 3319 type: 'GET', 3320 data: { 'id': id }, 3321 dataType: 'json', 3322 }) 3323 .done(function (result, textStatus) { 3324 if (result['error'] == false) { 3325 $(t).closest('.card').remove(); 3326 Swal.fire('Deleted!', result['message'], 'success'); 3327 } else { 3328 Swal.fire('Oops...', result['message'], 'warning'); 3329 } 3330 }) 3331 .fail(function (jqXHR, textStatus, errorThrown) { 3332 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3333 }); 3334 }); 3335 }, 3336 allowOutsideClick: false 3337 }); 3338}); 3339 3340//8.Slider-Module 3341$(document).on('click', '#delete-slider', function () { 3342 var id = $(this).data('id'); 3343 Swal.fire({ 3344 title: 'Are You Sure !', 3345 text: "You won't be able to revert this!", 3346 type: 'warning', 3347 showCancelButton: true, 3348 confirmButtonColor: '#3085d6', 3349 cancelButtonColor: '#d33', 3350 confirmButtonText: 'Yes, delete it!', 3351 showLoaderOnConfirm: true, 3352 preConfirm: function () { 3353 return new Promise((resolve, reject) => { 3354 $.ajax({ 3355 url: base_url + 'admin/Slider/delete_slider', 3356 type: 'GET', 3357 data: { 'id': id }, 3358 dataType: 'json', 3359 }) 3360 .done(function (response, textStatus) { 3361 if (response.error == false) { 3362 Swal.fire('Deleted!', response.message, 'success'); 3363 $('table').bootstrapTable('refresh'); 3364 } else { 3365 Swal.fire('Oops...', response.message, 'warning'); 3366 } 3367 }) 3368 .fail(function (jqXHR, textStatus, errorThrown) { 3369 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3370 }); 3371 }); 3372 }, 3373 allowOutsideClick: false 3374 }); 3375}); 3376 3377$(document).on('change', '.product_type', function (e, data) { 3378 e.preventDefault(); 3379 var sort_type_val = $(this).val();
3380 if (sort_type_val == 'custom_products' && sort_type_val != ' ') { 3381 $('.custom_products').removeClass('d-none'); 3382 } else { 3383 $('.custom_products').addClass('d-none'); 3384 } 3385}); 3386 3387//9.Offer-Module 3388$(document).on('click', '#delete-offer', function () { 3389 var id = $(this).data('id'); 3390 Swal.fire({ 3391 title: 'Are You Sure !', 3392 text: "You won't be able to revert this!", 3393 type: 'warning', 3394 showCancelButton: true, 3395 confirmButtonColor: '#3085d6', 3396 cancelButtonColor: '#d33', 3397 confirmButtonText: 'Yes, delete it!', 3398 showLoaderOnConfirm: true, 3399 preConfirm: function () { 3400 return new Promise((resolve, reject) => { 3401 $.ajax({ 3402 url: base_url + 'admin/Offer/delete_offer', 3403 type: 'GET', 3404 data: { 'id': id }, 3405 dataType: 'json', 3406 }) 3407 .done(function (response, textStatus) { 3408 if (response.error == false) { 3409 Swal.fire('Deleted!', response.message, 'success'); 3410 $('table').bootstrapTable('refresh'); 3411 } else { 3412 Swal.fire('Oops...', response.message, 'warning'); 3413 } 3414 }) 3415 .fail(function (jqXHR, textStatus, errorThrown) { 3416 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3417 }); 3418 }); 3419 }, 3420 allowOutsideClick: false 3421 }); 3422}); 3423 3424//10.Promo_code-Module 3425$(document).on('change', '#repeat_usage', function () { 3426 var repeat_usage = $(this).val(); 3427 if (typeof repeat_usage != 'undefined' && repeat_usage == '1') { 3428 $('#repeat_usage_html').removeClass('d-none'); 3429 } else { 3430 $('#repeat_usage_html').addClass('d-none'); 3431 } 3432 3433}); 3434 3435$(document).on('click', '#delete-promo-code', function () { 3436 var id = $(this).data('id'); 3437 Swal.fire({ 3438 title: 'Are You Sure !', 3439 text: "You won't be able to revert this!", 3440 type: 'warning', 3441 showCancelButton: true, 3442 confirmButtonColor: '#3085d6', 3443 cancelButtonColor: '#d33', 3444 confirmButtonText: 'Yes, delete it!', 3445 showLoaderOnConfirm: true, 3446 preConfirm: function () { 3447 return new Promise((resolve, reject) => { 3448 $.ajax({ 3449 url: base_url + 'admin/Promo_code/delete_promo_code', 3450 type: 'GET', 3451 data: { 'id': id }, 3452 dataType: 'json', 3453 }) 3454 .done(function (response, textStatus) { 3455 Swal.fire('Deleted!', response.message, 'success'); 3456 $('.table-striped').bootstrapTable('refresh'); 3457 }) 3458 .fail(function (jqXHR, textStatus, errorThrown) { 3459 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3460 }); 3461 }); 3462 }, 3463 allowOutsideClick: false 3464 }); 3465}); 3466 3467//11.Delivery_boys-Module 3468$(document).on('click', '#delete-delivery-boys', function () { 3469 var id = $(this).data('id'); 3470 Swal.fire({ 3471 title: 'Are You Sure !', 3472 text: "You won't be able to revert this!", 3473 type: 'warning', 3474 showCancelButton: true, 3475 confirmButtonColor: '#3085d6', 3476 cancelButtonColor: '#d33', 3477 confirmButtonText: 'Yes, delete it!', 3478 showLoaderOnConfirm: true, 3479 preConfirm: function () { 3480 return new Promise((resolve, reject) => { 3481 $.ajax({ 3482 url: base_url + 'admin/Delivery_boys/delete_delivery_boys', 3483 type: 'GET', 3484 data: { 'id': id }, 3485 dataType: 'json', 3486 }) 3487 .done(function (response, textStatus) { 3488 if (response.error == false) { 3489 Swal.fire('Deleted!', response.message, 'success'); 3490 $('table').bootstrapTable('refresh'); 3491 } else { 3492 Swal.fire('Oops...', response.message, 'warning'); 3493 } 3494 }) 3495 .fail(function (jqXHR, textStatus, errorThrown) { 3496 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3497 }); 3498 }); 3499 }, 3500 allowOutsideClick: false 3501 }); 3502}); 3503 3504//12.Settings-Module 3505$(document).on('click', '#delete-time-slot', function () { 3506 var id = $(this).data('id'); 3507 Swal.fire({ 3508 title: 'Are You Sure !', 3509 text: "You won't be able to revert this!", 3510 type: 'warning', 3511 showCancelButton: true, 3512 confirmButtonColor: '#3085d6', 3513 cancelButtonColor: '#d33', 3514 confirmButtonText: 'Yes, delete it!', 3515 showLoaderOnConfirm: true, 3516 preConfirm: function () { 3517 return new Promise((resolve, reject) => { 3518 $.ajax({ 3519 url: base_url + 'admin/Time_slots/delete_time_slots', 3520 type: 'GET', 3521 data: { 'id': id }, 3522 dataType: 'json', 3523 }) 3524 .done(function (response, textStatus) { 3525 Swal.fire('Deleted!', response.message); 3526 $('.table-striped').bootstrapTable('refresh'); 3527 }) 3528 .fail(function (jqXHR, textStatus, errorThrown) { 3529 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3530 }); 3531 }); 3532 }, 3533 allowOutsideClick: false 3534 }); 3535}); 3536 3537 3538// tost message 3539$(document).on('click', '.delete-message', function () { 3540 var cat_id = $(this).data('id'); 3541 Swal.fire({ 3542 title: 'Are You Sure!', 3543 text: "You won't be able to revert this!", 3544 type: 'warning', 3545 showCancelButton: true, 3546 confirmButtonColor: '#3085d6', 3547 cancelButtonColor: '#d33', 3548 confirmButtonText: 'Yes, delete it!', 3549 showLoaderOnConfirm: true, 3550 preConfirm: function () { 3551 return new Promise((resolve, reject) => { 3552 Swal.fire('Oops...', 'The Delete Button will after live', 'error'); 3553 csrfName = response['csrfName']; 3554 csrfHash = response['csrfHash']; 3555 3556 }); 3557 }, 3558 allowOutsideClick: false 3559 }); 3560}); 3561// tost message 3562 3563 3564 3565//13.City-Module 3566$(document).on('click', '#delete-location', function () { 3567 3568 var id = $(this).data('id'); 3569 var table = $(this).data('table'); 3570 Swal.fire({ 3571 title: 'Are You Sure !', 3572 text: "You won't be able to revert this!", 3573 type: 'warning', 3574 showCancelButton: true, 3575 confirmButtonColor: '#3085d6', 3576 cancelButtonColor: '#d33', 3577 confirmButtonText: 'Yes, delete it!', 3578 showLoaderOnConfirm: true, 3579 preConfirm: function () { 3580 return new Promise((resolve, reject) => { 3581 $.ajax({ 3582 url: base_url + 'admin/Area/delete_city', 3583 type: 'GET', 3584 data: { 'id': id, 'table': table }, 3585 dataType: 'json', 3586 }) 3587 .done(function (response, textStatus) { 3588 if (response.error == false) { 3589 Swal.fire('Deleted!', response.message, 'success'); 3590 $('table').bootstrapTable('refresh'); 3591 } else { 3592 Swal.fire('Oops...', response.message, 'warning'); 3593 } 3594 }) 3595 .fail(function (jqXHR, textStatus, errorThrown) { 3596 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3597 }); 3598 }); 3599 }, 3600 allowOutsideClick: false 3601 }); 3602}); 3603 3604//14.Transaction_Module 3605$(document).on('change', '#transaction_type', function () { 3606 $('.table-striped').bootstrapTable('refresh'); 3607}); 3608 3609//15.Customer-Wallet-Module 3610$('#customers').on('check.bs.table', function (e, row) { 3611 $('#customer_dtls').val(row.name + " | " + row.email); 3612 $('#user_id').val(row.id); 3613}); 3614 3615//16.Fund-Transder-Module 3616$("#fund_transfer").on("click-cell.bs.table", function (field, value, row, $el) { 3617 $('#name').val($el.name); 3618 $('#mobile').val($el.mobile); 3619 $('#balance').val($el.balance); 3620 $('#delivery_boy_id').val($el.id); 3621}); 3622 3623//17.Return-Request-Module 3624$("#return_request_table").on("click-cell.bs.table", function (field, value, row, $el) { 3625 $('input[name="return_request_id"]').val($el.id); 3626 $('#user_id').val($el.user_id); 3627 $('#order_item_id').val($el.order_item_id); 3628 $('#update_remarks').html($el.remarks); 3629 3630 if ($el.status_digit == 0) { 3631 $('.pending').prop('checked', true); 3632 } else if ($el.status_digit == 1) { 3633 $('.approved').prop('checked', true); 3634 } else if ($el.status_digit == 2) { 3635 $('.rejected').prop('rejected', true); 3636 } 3637}); 3638 3639//18.Tax-Module 3640$(document).on('click', '#delete-tax', function () { 3641 var tax_id = $(this).data('id'); 3642 Swal.fire({ 3643 title: 'Are You Sure!', 3644 text: "You won't be able to revert this!", 3645 type: 'warning', 3646 showCancelButton: true, 3647 confirmButtonColor: '#3085d6', 3648 cancelButtonColor: '#d33', 3649 confirmButtonText: 'Yes, delete it!', 3650 showLoaderOnConfirm: true, 3651 preConfirm: function () { 3652 return new Promise((resolve, reject) => { 3653 $.ajax({ 3654 type: 'GET', 3655 url: base_url + 'admin/taxes/delete_tax', 3656 data: { id: tax_id }, 3657 dataType: 'json' 3658 }) 3659 .done(function (response, textStatus) { 3660 if (response.error == false) { 3661 Swal.fire('Deleted!', response.message, 'success'); 3662 } else { 3663 Swal.fire('Opps', response.message, 'warning'); 3664 } 3665 $('table').bootstrapTable('refresh'); 3666 }) 3667 .fail(function (jqXHR, textStatus, errorThrown) { 3668 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3669 }); 3670 }); 3671 }, 3672 allowOutsideClick: false 3673 }); 3674}); 3675 3676//18.Convenience Charge-Module 3677$(document).on('click', '#delete-charge', function () { 3678 var tax_id = $(this).data('id'); 3679 Swal.fire({ 3680 title: 'Are You Sure!', 3681 text: "You won't be able to revert this!", 3682 type: 'warning', 3683 showCancelButton: true, 3684 confirmButtonColor: '#3085d6', 3685 cancelButtonColor: '#d33', 3686 confirmButtonText: 'Yes, delete it!', 3687 showLoaderOnConfirm: true, 3688 preConfirm: function () { 3689 return new Promise((resolve, reject) => { 3690 $.ajax({ 3691 type: 'GET', 3692 url: base_url + 'admin/taxes/delete_charge', 3693 data: { id: tax_id }, 3694 dataType: 'json' 3695 }) 3696 .done(function (response, textStatus) { 3697 if (response.error == false) { 3698 Swal.fire('Deleted!', response.message, 'success'); 3699 } else { 3700 Swal.fire('Opps', response.message, 'warning'); 3701 } 3702 $('table').bootstrapTable('refresh'); 3703 }) 3704 .fail(function (jqXHR, textStatus, errorThrown) { 3705 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3706 }); 3707 }); 3708 }, 3709 allowOutsideClick: false 3710 }); 3711}); 3712 3713//19.Payment-Request-Module 3714$("#payment_request_table").on("click-cell.bs.table", function (field, value, row, $el) { 3715 $('input[name="payment_request_id"]').val($el.id); 3716 $('#update_remarks').html($el.remarks); 3717 3718 if ($el.status_digit == 0) { 3719 $('.pending').prop('checked', true); 3720 } else if ($el.status_digit == 1) { 3721 $('.approved').prop('checked', true); 3722 } else if ($el.status_digit == 2) { 3723 $('.rejected').prop('rejected', true); 3724 } 3725}); 3726 3727 3728 3729 3730 3731//19.Delete Attributes 3732$(document).on('click', '#delete-attribute', function () { 3733 var tax_id = $(this).data('id'); 3734 Swal.fire({ 3735 title: 'Are You Sure!', 3736 text: "You won't be able to revert this!", 3737 type: 'warning', 3738 showCancelButton: true, 3739 confirmButtonColor: '#3085d6', 3740 cancelButtonColor: '#d33', 3741 confirmButtonText: 'Yes, delete it!', 3742 showLoaderOnConfirm: true, 3743 preConfirm: function () { 3744 return new Promise((resolve, reject) => { 3745 $.ajax({ 3746 type: 'GET', 3747 url: base_url + 'admin/Attribute_set/delete-attribute', 3748 data: { id: tax_id }, 3749 dataType: 'json' 3750 }) 3751 .done(function (response, textStatus) { 3752 if (response.error == false) { 3753 Swal.fire('Deleted!', response.message, 'success'); 3754 } else { 3755 Swal.fire('Opps', response.message, 'warning'); 3756 } 3757 $('table').bootstrapTable('refresh'); 3758 }) 3759 .fail(function (jqXHR, textStatus, errorThrown) { 3760 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3761 }); 3762 }); 3763 }, 3764 allowOutsideClick: false 3765 }); 3766}); 3767 3768 3769 3770 3771 3772//19.Delete Tax Attributes 3773$(document).on('click', '#delete-attributetax', function () { 3774 var tax_id = $(this).data('id'); 3775 Swal.fire({ 3776 title: 'Are You Sure!', 3777 text: "You won't be able to revert this!", 3778 type: 'warning', 3779 showCancelButton: true, 3780 confirmButtonColor: '#3085d6', 3781 cancelButtonColor: '#d33', 3782 confirmButtonText: 'Yes, delete it!', 3783 showLoaderOnConfirm: true, 3784 preConfirm: function () { 3785 return new Promise((resolve, reject) => { 3786 $.ajax({ 3787 type: 'GET', 3788 url: base_url + 'admin/Attribute_set/delete_attributetax', 3789 data: { id: tax_id }, 3790 dataType: 'json' 3791 }) 3792 .done(function (response, textStatus) { 3793 if (response.error == false) { 3794 Swal.fire('Deleted!', response.message, 'success'); 3795 } else { 3796 Swal.fire('Opps', response.message, 'warning'); 3797 } 3798 $('table').bootstrapTable('refresh'); 3799 }) 3800 .fail(function (jqXHR, textStatus, errorThrown) { 3801 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3802 }); 3803 }); 3804 }, 3805 allowOutsideClick: false 3806 }); 3807}); 3808 3809 3810 3811//20.Delete valueAttributes 3812$(document).on('click', '#delete-attributevalue', function () { 3813 var tax_id = $(this).data('id'); 3814 Swal.fire({ 3815 title: 'Are You Sure!', 3816 text: "You won't be able to revert this!", 3817 type: 'warning', 3818 showCancelButton: true, 3819 confirmButtonColor: '#3085d6', 3820 cancelButtonColor: '#d33', 3821 confirmButtonText: 'Yes, delete it!', 3822 showLoaderOnConfirm: true, 3823 preConfirm: function () { 3824 return new Promise((resolve, reject) => { 3825 $.ajax({ 3826 type: 'GET', 3827 url: base_url + 'admin/Attribute_set/delete-attributevalue', 3828 data: { id: tax_id }, 3829 dataType: 'json' 3830 }) 3831 .done(function (response, textStatus) { 3832 if (response.error == false) { 3833 Swal.fire('Deleted!', response.message, 'success'); 3834 } else { 3835 Swal.fir
3835e('Opps', response.message, 'warning'); 3836 } 3837 $('table').bootstrapTable('refresh'); 3838 }) 3839 .fail(function (jqXHR, textStatus, errorThrown) { 3840 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 3841 }); 3842 }); 3843 }, 3844 allowOutsideClick: false 3845 }); 3846}); 3847 3848 3849 3850 3851 3852$('#upload-media').on('click', function () { 3853 var $result = $('#media-upload-table').bootstrapTable('getSelections'); 3854 3855 var path = base_url + $result[0].sub_directory + $result[0].name; 3856 var sub_directory = $result[0].sub_directory + $result[0].name; 3857 var media_type = $('#media-upload-modal').find('input[name="media_type"]').val(); 3858 var input = $('#media-upload-modal').find('input[name="current_input"]').val(); 3859 var is_removable = $('#media-upload-modal').find('input[name="remove_state"]').val(); 3860 var ismultipleAllowed = $('#media-upload-modal').find('input[name="multiple_images_allowed_state"]').val(); 3861 var removable_btn = (is_removable == '1') ? '<button class="remove-image btn btn-danger btn-xs mt-3">Remove</button>' : ''; 3862 3863 $(current_selected_image).closest('.form-group').find('.image').removeClass('d-none'); 3864 if (ismultipleAllowed == '1') { 3865 for (let index = 0; index < $result.length; index++) { 3866 $(current_selected_image).closest('.form-group').find('.image-upload-section').append('<div class="col-md-3 col-sm-12 shadow p-3 mb-5 bg-white rounded m-4 text-center grow image"><div class="image-upload-div"><img class="img-fluid" alt="' + $result[index].name + '" title="' + $result[index].name + '" src=' + base_url + $result[index].sub_directory + $result[index].name + ' ><input type="hidden" name=' + input + ' value=' + $result[index].sub_directory + $result[index].name + '></div>' + removable_btn + '</div>'); 3867 } 3868 } else { 3869 path = (media_type != 'image') ? base_url + 'assets/admin/images/' + media_type + '-file.png' : path; 3870 $(current_selected_image).closest('.form-group').find('.image-upload-section').html('<div class="col-md-3 col-sm-12 shadow p-3 mb-5 bg-white rounded m-4 text-center grow image"><div class="image-upload-div"><img class="img-fluid" alt="' + $result[0].name + '" title="' + $result[0].name + '" src=' + path + ' ><input type="hidden" name=' + input + ' value=' + sub_directory + '></div>' + removable_btn + '</div>'); 3871 } 3872 3873 current_selected_image = ''; 3874 $('#media-upload-modal').modal('hide'); 3875}); 3876 3877$(document).on('show.bs.modal', '#media-upload-modal', function (event) { 3878 var triggerElement = $(event.relatedTarget); 3879 current_selected_image = triggerElement; 3880 var input = $(current_selected_image).data('input'); 3881 var isremovable = $(current_selected_image).data('isremovable'); 3882 var ismultipleAllowed = $(current_selected_image).data('is-multiple-uploads-allowed'); 3883 var media_type = ($(current_selected_image).is('[data-media_type]')) ? $(current_selected_image).data('media_type') : 'image'; 3884 $('#media_type').val(media_type); 3885 if (ismultipleAllowed == 1) { 3886 $('#media-upload-table').bootstrapTable('refreshOptions', { 3887 singleSelect: false, 3888 }); 3889 } else { 3890 $('#media-upload-table').bootstrapTable('refreshOptions', { 3891 singleSelect: true, 3892 }); 3893 } 3894 3895 $(this).find('input[name="current_input"]').val(input); 3896 $(this).find('input[name="remove_state"]').val(isremovable); 3897 $(this).find('input[name="multiple_images_allowed_state"]').val(ismultipleAllowed); 3898}); 3899 3900$(document).on('change', '#video_type', function () { 3901 var video_type = $(this).val(); 3902 if (video_type == 'youtube' || video_type == 'vimeo') { 3903 $("#video_link_container").removeClass('d-none'); 3904 $("#video_media_container").addClass('d-none'); 3905 } else if (video_type == 'self_hosted') { 3906 $("#video_link_container").addClass('d-none'); 3907 $("#video_media_container").removeClass('d-none'); 3908 } else { 3909 $("#video_link_container").addClass('d-none'); 3910 $("#video_media_container").addClass('d-none'); 3911 } 3912}); 3913if ($('#tags').length) { 3914 var tags_element = document.querySelector('input[name=tags]'); 3915 new Tagify(tags_element); 3916} 3917 3918$(document).on('show.bs.modal', '#customer-address-modal', function (event) { 3919 var triggerElement = $(event.relatedTarget); 3920 current_selected_image = triggerElement; 3921 var id = $(current_selected_image).data('id'); 3922 var existing_url = $(this).find('#customer-address-table').data('url'); 3923 3924 if (existing_url.indexOf('?') > -1) { 3925 var temp = $(existing_url).text().split('?'); 3926 var new_url = temp[0] + '?user_id=' + id; 3927 } else { 3928 var new_url = existing_url + '?user_id=' + id; 3929 } 3930 $('#customer-address-table').bootstrapTable('refreshOptions', { 3931 url: new_url, 3932 }); 3933}); 3934$(document).on('show.bs.modal', '#product-rating-modal', function (event) { 3935 var triggerElement = $(event.relatedTarget); 3936 current_selected_image = triggerElement; 3937 var id = $(current_selected_image).data('id'); 3938 3939 var existing_url = $(this).find('#product-rating-table').data('url'); 3940 if (existing_url.indexOf('?') > -1) { 3941 var temp = $(existing_url).text().split('?'); 3942 var new_url = temp[0] + '?product_id=' + id; 3943 } else { 3944 var new_url = existing_url + '?product_id=' + id; 3945 } 3946 $('#product-rating-table').bootstrapTable('refreshOptions', { 3947 url: new_url, 3948 }); 3949}); 3950 3951$(document).on('click', '.remove-image', function (e) { 3952 e.preventDefault(); 3953 $(this).closest('.image').remove(); 3954}); 3955 3956$(document).on('change', '#media-type', function () { 3957 $('table').bootstrapTable('refresh'); 3958}); 3959 3960Dropzone.autoDiscover = false;
3961 3962if (document.getElementById('dropzone')) { 3963 3964 var myDropzone = new Dropzone("#dropzone", { 3965 url: base_url + from + '/media/upload', 3966 paramName: "documents", 3967 autoProcessQueue: false, 3968 parallelUploads: 12, 3969 maxFiles: 12, 3970 autoDiscover: false, 3971 addRemoveLinks: true, 3972 timeout: 180000, 3973 dictRemoveFile: 'x', 3974 dictMaxFilesExceeded: 'Only 12 files can be uploaded at a time ', 3975 dictResponseError: 'Error', 3976 uploadMultiple: true, 3977 dictDefaultMessage: '<p><input type="submit" value="Select Files" class="btn btn-success" /><br> or <br> Drag & Drop Media Files Here</p>', 3978 }); 3979 3980 myDropzone.on("addedfile", function (file) { 3981 var i = 0; 3982 if (this.files.length) { 3983 var _i, _len; 3984 for (_i = 0, _len = this.files.length; _i < _len - 1; _i++) { 3985 if (this.files[_i].name === file.name && this.files[_i].size === file.size && this.files[_i].lastModifiedDate.toString() === file.lastModifiedDate.toString()) { 3986 this.removeFile(file); 3987 i++; 3988 } 3989 } 3990 } 3991 }); 3992 3993 myDropzone.on("error", function (file, response) { 3994 }); 3995 3996 3997 myDropzone.on('sending', function (file, xhr, formData) { 3998 formData.append(csrfName, csrfHash); 3999 xhr.onreadystatechange = function () { 4000 if (this.readyState == 4 && this.status == 200) { 4001 var response = JSON.parse(this.response); 4002 csrfName = response.csrfName; 4003 csrfHash = response.csrfHash; 4004 if (response['error'] == false) { 4005 Dropzone.forElement('#dropzone').removeAllFiles(true); 4006 $("#media-upload-table").bootstrapTable('refresh'); 4007 iziToast.success({ 4008 message: response['message'], 4009 }); 4010 } else { 4011 iziToast.error({ 4012 title: 'Error', 4013 message: response['message'], 4014 }); 4015 } 4016 $(file.previewElement).find('.dz-error-message').text(response.message); 4017 } 4018 }; 4019 }); 4020} 4021if (document.getElementById('system-update-dropzone')) { 4022 4023 var systemDropzone = new Dropzone("#system-update-dropzone", { 4024 url: base_url + 'admin/updater/upload_update_file', 4025 paramName: "update_file", 4026 autoProcessQueue: false, 4027 parallelUploads: 1, 4028 maxFiles: 1, 4029 timeout: 360000, 4030 autoDiscover: false, 4031 addRemoveLinks: true, 4032 dictRemoveFile: 'x', 4033 dictMaxFilesExceeded: 'Only 1 file can be uploaded at a time ', 4034 dictResponseError: 'Error', 4035 uploadMultiple: true, 4036 dictDefaultMessage: '<p><input type="submit" value="Select Files" class="btn btn-success" /><br> or <br> Drag & Drop System Update / Installable / Plugin\'s .zip file Here</p>', 4037 }); 4038 4039 systemDropzone.on("addedfile", function (file) { 4040 var i = 0; 4041 if (this.files.length) { 4042 var _i, _len; 4043 for (_i = 0, _len = this.files.length; _i < _len - 1; _i++) { 4044 if (this.files[_i].name === file.name && this.files[_i].size === file.size && this.files[_i].lastModifiedDate.toString() === file.lastModifiedDate.toString()) { 4045 this.removeFile(file); 4046 i++; 4047 } 4048 } 4049 } 4050 }); 4051 4052 systemDropzone.on("error", function (file, response) { 4053 }); 4054 4055 4056 systemDropzone.on('sending', function (file, xhr, formData) { 4057 formData.append(csrfName, csrfHash); 4058 xhr.onreadystatechange = function () { 4059 if (this.readyState == 4 && this.status == 200) { 4060 var response = JSON.parse(this.response); 4061 csrfName = response.csrfName; 4062 csrfHash = response.csrfHash; 4063 if (response['error'] == false) { 4064 iziToast.success({ 4065 message: response['message'], 4066 }); 4067 } else { 4068 iziToast.error({ 4069 title: 'Error', 4070 message: response['message'], 4071 }); 4072 } 4073 $(file.previewElement).find('.dz-error-message').text(response.message); 4074 } 4075 }; 4076 }); 4077 $('#system_update_btn').on('click', function (e) { 4078 e.preventDefault(); 4079 systemDropzone.processQueue(); 4080 }); 4081} 4082 4083$('#upload-files-btn').on('click', function (e) { 4084 e.preventDefault(); 4085 myDropzone.processQueue(); 4086}); 4087 4088 4089 4090
4091$(document).on('click', '.copy-to-clipboard', function () { 4092 4093 var $element = $(this).closest('tr').find('.path'); 4094 copyToClipboard($element); 4095 iziToast.success({ 4096 message: 'Image path copied to clipboard', 4097 }); 4098}); 4099$(document).on('click', '.copy-relative-path', function () { 4100 var $element = $(this).closest('tr').find('.relative-path'); 4101 copyToClipboard($element); 4102 iziToast.success({ 4103 message: 'Image path copied to clipboard', 4104 }); 4105}); 4106 4107 4108$(document).on('click', 'button[type="reset"]', function () { 4109 $('.image-upload-div').remove(); 4110 $('.image-upload-section').find('.image').addClass('d-none'); 4111}); 4112 4113//20.Client Api Key Module 4114$(document).on('click', '#delete-client', function () { 4115 var id = $(this).data('id'); 4116 Swal.fire({ 4117 title: 'Are You Sure!', 4118 text: "You won't be able to revert this!", 4119 type: 'warning', 4120 showCancelButton: true, 4121 confirmButtonColor: '#3085d6', 4122 cancelButtonColor: '#d33', 4123 confirmButtonText: 'Yes, delete it!', 4124 showLoaderOnConfirm: true, 4125 preConfirm: function () { 4126 return new Promise((resolve, reject) => { 4127 $.ajax({ 4128 type: 'GET', 4129 url: base_url + 'admin/client_api_keys/delete_client', 4130 data: { id: id }, 4131 dataType: 'json' 4132 }) 4133 .done(function (response, textStatus) { 4134 if (response.error == false) { 4135 Swal.fire('Deleted!', response.message, 'success'); 4136 } else { 4137 Swal.fire('Opps', response.message, 'warning'); 4138 } 4139 $('table').bootstrapTable('refresh'); 4140 }) 4141 .fail(function (jqXHR, textStatus, errorThrown) { 4142 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 4143 }); 4144 }); 4145 }, 4146 allowOutsideClick: false 4147 }); 4148}); 4149 4150//21.System Users 4151$(document).on('click', '#delete-system-users', function () { 4152 var id = $(this).data('id'); 4153 Swal.fire({ 4154 title: 'Are You Sure!', 4155 text: "You won't be able to revert this!", 4156 type: 'warning', 4157 showCancelButton: true, 4158 confirmButtonColor: '#3085d6', 4159 cancelButtonColor: '#d33', 4160 confirmButtonText: 'Yes, delete it!', 4161 showLoaderOnConfirm: true, 4162 preConfirm: function () { 4163 return new Promise((resolve, reject) => { 4164 $.ajax({ 4165 type: 'GET', 4166 url: base_url + 'admin/system_users/delete_system_user', 4167 data: { id: id }, 4168 dataType: 'json' 4169 }) 4170 .done(function (response, textStatus) { 4171 if (response.error == false) { 4172 Swal.fire('Deleted!', response.message, 'success'); 4173 } else { 4174 Swal.fire('Opps', response.message, 'warning'); 4175 } 4176 $('table').bootstrapTable('refresh'); 4177 }) 4178 .fail(function (jqXHR, textStatus, errorThrown) { 4179 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 4180 }); 4181 }); 4182 }, 4183 allowOutsideClick: false 4184 }); 4185}); 4186 4187$(document).on('change', '.system-user-role', function () { 4188 var role = $(this).val(); 4189 if (role > 0) { 4190 $('.permission-table').removeClass('d-none'); 4191 } else { 4192 $('.permission-table').addClass('d-none'); 4193 } 4194}); 4195 4196$(document).on('click', '.remove_individual_variants', function () { 4197 var variant_id = $(this).closest('.variant_col').find('input[type="hidden"]').val(); 4198 var all_variant_ids = $(this).closest('.row').find('input[name="variants_ids[]"]').val().split(','); 4199 all_variant_ids.splice(all_variant_ids.indexOf(variant_id), 1); 4200 if ($.isEmptyObject(all_variant_ids)) { 4201 $(this).closest('.row').remove(); 4202 } else { 4203 $(this).closest('.row').find('input[name="variants_ids[]"]').val(all_variant_ids.toString()); 4204 $(this).closest('.variant_col').remove(); 4205 } 4206}); 4207 4208$(document).on('change', '#system_timezone', function () { 4209 var gmt = $(this).find(':selected').data('gmt'); 4210 $('#system_timezone_gmt').val(gmt); 4211}); 4212 4213$('#city').on('change', function (e) { 4214 e.preventDefault(); 4215 $.ajax({ 4216 type: 'POST', 4217 data: { 4218 'city_id': $(this).val(), 4219 [csrfName]: csrfHash, 4220 }, 4221 url: base_url + 'my-account/get-areas', 4222 dataType: 'json', 4223 success: function (result) { 4224 csrfName = result.csrfName; 4225 csrfHash = result.csrfHash; 4226 if (result.error == false) { 4227 var html = ''; 4228 $.each(result.data, function (i, e) { 4229 html += '<option value=' + e.id + '>' + e.name + '</option>'; 4230 }); 4231 $('#area').html(html); 4232 } else { 4233 Toast.fire({ 4234 icon: 'error', 4235 title: result.message 4236 }); 4237 $('#area').html(''); 4238 } 4239 } 4240 }) 4241}); 4242 4243$('#add-address-form').on('submit', function (e) { 4244 e.preventDefault(); 4245 var formdata = new FormData(this); 4246 formdata.append(csrfName, csrfHash); 4247 $.ajax({ 4248 type: 'POST', 4249 data: formdata, 4250 url: $(this).attr('action'), 4251 dataType: 'json', 4252 cache: false, 4253 contentType: false, 4254 processData: false, 4255 beforeSend: function () { 4256 $('#save-address-submit-btn').val('Please Wait...').attr('disabled', true); 4257 }, 4258 success: function (result) { 4259 csrfName = result.csrfName; 4260 csrfHash = result.csrfHash; 4261 if (result.error == false) { 4262 $('#save-address-result').html("<div class='alert alert-success'>" + result.message + "</div>").delay(1500).fadeOut(); 4263 $('#add-address-form')[0].reset(); 4264 $('#address_list_table').bootstrapTable('refresh'); 4265 } else { 4266 $('#save-address-result').html("<div class='alert alert-danger'>" + result.message + "</div>").delay(1500).fadeOut(); 4267 } 4268 $('#save-address-submit-btn').val('Save').attr('disabled', false); 4269 } 4270 }) 4271}) 4272 4273$(document).on('click', '.delete-address', function (e) { 4274 e.preventDefault(); 4275 if (confirm('Are you sure ? You want to delete this address?')) { 4276 $.ajax({ 4277 type: 'POST', 4278 data: { 4279 'id': $(this).data('id'), 4280 [csrfName]: csrfHash, 4281 }, 4282 url: base_url + 'my-account/delete-address', 4283 dataType: 'json', 4284 success: function (result) { 4285 csrfName = result.csrfName; 4286 csrfHash = result.csrfHash; 4287 if (result.error == false) { 4288 $('#address_list_table').bootstrapTable('refresh'); 4289 } else { 4290 Toast.fire({ 4291 icon: 'error', 4292 title: result.message 4293 }); 4294 } 4295 } 4296 }) 4297 } 4298}); 4299$('#edit_city').on('change', function (e, data) { 4300 e.preventDefault(); 4301 $.ajax({ 4302 type: 'POST', 4303 data: { 4304 'city_id': $(this).val(), 4305 [csrfName]: csrfHash, 4306 }, 4307 url: base_url + 'my-account/get-areas', 4308 dataType: 'json', 4309 success: function (result) { 4310 csrfName = result.csrfName; 4311 csrfHash = result.csrfHash; 4312 if (result.error == false) { 4313 var html = ''; 4314 $.each(result.data, function (i, e) { 4315 html += '<option value=' + e.id + '>' + e.name + '</option>'; 4316 }); 4317 $('#edit_area').html(html); 4318 } else { 4319 Toast.fire({ 4320 icon: 'error', 4321 title: result.message 4322 }); 4323 $('#edit_area').html(''); 4324 } 4325 } 4326 }) 4327}); 4328
4329$('#edit-address-form').on('submit', function (e) { 4330 e.preventDefault(); 4331 var formdata = new FormData(this); 4332 formdata.append(csrfName, csrfHash); 4333 $.ajax({ 4334 type: 'POST', 4335 data: formdata, 4336 url: $(this).attr('action'), 4337 dataType: 'json', 4338 cache: false, 4339 contentType: false, 4340 processData: false, 4341 beforeSend: function () { 4342 $('#edit-address-submit-btn').val('Please Wait...').attr('disabled', true); 4343 }, 4344 success: function (result) { 4345 csrfName = result.csrfName; 4346 csrfHash = result.csrfHash; 4347 if (result.error == false) { 4348 $('#edit-address-result').html("<div class='alert alert-success'>" + result.message + "</div>").delay(1500).fadeOut(); 4349 $('#edit-address-form')[0].reset(); 4350 $('#address_list_table').bootstrapTable('refresh'); 4351 setTimeout(function () { 4352 $('#address-modal').modal('hide'); 4353 }, 2000) 4354 } else { 4355 $('#edit-address-result').html("<div class='alert alert-danger'>" + result.message + "</div>").delay(1500).fadeOut(); 4356 } 4357 $('#edit-address-submit-btn').val('Save').attr('disabled', false); 4358 } 4359 }) 4360}) 4361 4362$('#add-new-language-form').on('submit', function (e) { 4363 e.preventDefault(); 4364 var formdata = new FormData(this); 4365 formdata.append(csrfName, csrfHash); 4366 $.ajax({ 4367 type: 'POST', 4368 data: formdata, 4369 url: $(this).attr('action'), 4370 dataType: 'json', 4371 cache: false, 4372 contentType: false, 4373 processData: false, 4374 beforeSend: function () { 4375 $('#submit_btn').val('Please Wait...').attr('disabled', true); 4376 }, 4377 success: function (result) { 4378 csrfName = result.csrfName; 4379 csrfHash = result.csrfHash; 4380 if (result.error == false) { 4381 $('#result').show().removeClass('msg_error').addClass('msg_success').html(result.message).delay(1500).fadeOut(); 4382 $('#add-new-language-form')[0].reset(); 4383 setTimeout(function () { 4384 $('#language-modal').modal('hide'); 4385 }, 2000) 4386 } else { 4387 $('#result').show().removeClass('msg_success').addClass('msg_error').html(result.message).delay(1500).fadeOut(); 4388 } 4389 $('#submit_btn').val('Save').attr('disabled', false); 4390 } 4391 }) 4392}) 4393 4394$('#selected_language').on('change', function () { 4395 var id = $(this).val(); 4396 window.location.href = base_url + 'admin/language?id=' + id; 4397}); 4398$('#update-language-form').on('submit', function (e) { 4399 e.preventDefault(); 4400 var formdata = new FormData(this); 4401 formdata.append(csrfName, csrfHash); 4402 $.ajax({ 4403 type: 'POST', 4404 data: formdata, 4405 url: $(this).attr('action'), 4406 dataType: 'json', 4407 cache: false, 4408 contentType: false, 4409 processData: false, 4410 beforeSend: function () { 4411 $('#update_btn').val('Please Wait...').attr('disabled', true); 4412 }, 4413 success: function (result) { 4414 csrfName = result.csrfName; 4415 csrfHash = result.csrfHash; 4416 if (result.error == false) { 4417 $('#update-result').show().removeClass('msg_error').addClass('msg_success').html(result.message).delay(1500).fadeOut(); 4418 } else { 4419 $('#update-result').show().removeClass('msg_success').addClass('msg_error').html(result.message).delay(1500).fadeOut(); 4420 } 4421 $('#update_btn').val('Save').attr('disabled', false); 4422 } 4423 }) 4424}) 4425 4426function product_rating_query_params(p) { 4427 return { 4428 'product_id': $('#product_id').val(), 4429 limit: p.limit, 4430 sort: p.sort, 4431 order: p.order, 4432 offset: p.offset, 4433 search: p.search 4434 }; 4435} 4436 4437$('#area_wise_delivery_charge').on('switchChange.bootstrapSwitch', function (event, state) { 4438 if (state == false) { 4439 if ($(".delivery_charge").hasClass("d-none")) { 4440 $(".delivery_charge").removeClass("d-none") 4441 } 4442 if ($(".min_amount").hasClass("d-none")) { 4443 $(".min_amount").removeClass("d-none") 4444 } 4445 if ($(".area_wise_delivery_charge").hasClass("col-md-6")) { 4446 $(".area_wise_delivery_charge").removeClass("col-md-6") 4447 $(".area_wise_delivery_charge").addClass("col-md-4") 4448 } 4449 } else { 4450 if (!$(".delivery_charge").hasClass("d-none")) { 4451 $(".delivery_charge").addClass("d-none") 4452 } 4453 if (!$(".min_amount").hasClass("d-none")) { 4454 $(".min_amount").addClass("d-none") 4455 } 4456 if ($(".area_wise_delivery_charge").hasClass("col-md-4")) { 4457 $(".area_wise_delivery_charge").removeClass("col-md-4") 4458 $(".area_wise_delivery_charge").addClass("col-md-6") 4459 } 4460 4461 4462 } 4463}); 4464 4465$('#bulk_upload_form').on('submit', function (e) { 4466 e.preventDefault(); 4467 var type = $('#type').val(); 4468 if (type != '') { 4469 var formdata = new FormData(this); 4470 formdata.append(csrfName, csrfHash); 4471 $.ajax({ 4472 type: 'POST', 4473 data: formdata, 4474 url: $(this).attr('action'), 4475 dataType: 'json', 4476 cache: false, 4477 contentType: false, 4478 processData: false, 4479 beforeSend: function () { 4480 $('#submit_btn').html('Please Wait...').attr('disabled', true); 4481 }, 4482 success: function (result) { 4483 csrfName = result.csrfName; 4484 csrfHash = result.csrfHash; 4485 if (result.error == false) { 4486 $('#upload_result').show().removeClass('msg_error').addClass('msg_success').html(result.message).delay(3000).fadeOut(); 4487 } else { 4488 $('#upload_result').show().removeClass('msg_success').addClass('msg_error').html(result.message).delay(3000).fadeOut(); 4489 } 4490 $('#submit_btn').html('Submit').attr('disabled', false); 4491 } 4492 }) 4493 } 4494 else { 4495 iziToast.error({ 4496 message: 'Please select type', 4497 }); 4498 } 4499 4500}); 4501$('#location_bulk_upload_form').on('submit', function (e) { 4502 e.preventDefault(); 4503 var type = $('#type').val(); 4504 var location_type = $('#location_type').val(); 4505 if (type != '' && location_type != "" && type != "undefined" && location_type != "undefined") { 4506 var formdata = new FormData(this); 4507 formdata.append(csrfName, csrfHash); 4508 $.ajax({ 4509 type: 'POST', 4510 data: formdata, 4511 url: $(this).attr('action'), 4512 dataType: 'json', 4513 cache: false, 4514 contentType: false, 4515 processData: false, 4516 beforeSend: function () { 4517 $('#submit_btn').html('Please Wait...').attr('disabled', true); 4518 }, 4519 success: function (result) { 4520 csrfName = result.csrfName; 4521 csrfHash = result.csrfHash; 4522 if (result.error == false) { 4523 $('#upload_result').show().removeClass('msg_error').addClass('msg_success').html(result.message).delay(3000).fadeOut(); 4524 } else { 4525 $('#upload_result').show().removeClass('msg_success').addClass('msg_error').html(result.message).delay(3000).fadeOut(); 4526 } 4527 $('#submit_btn').html('Submit').attr('disabled', false); 4528 } 4529 }); 4530 } 4531 else { 4532 iziToast.error({ 4533 message: 'Please select Type and Location Type', 4534 }); 4535 } 4536 4537}); 4538 4539 4540// swatche js 4541 4542// if ($('.swatche_type').length) { 4543$('#swatche_color').hide(); 4544$('#swatche_image').hide(); 4545$(document.body).on('change', '.swatche_type', function (e) { 4546 e.preventDefault(); 4547 var swatche_type = $(this).val(); 4548 if (swatche_type == "1") { 4549 $('#swatche_image').hide(); 4550 $('#swatche_color').show(); 4551 $('#swatche_image').val(''); 4552 } else if (swatche_type == "2") { 4553 $('#swatche_color').hide(); 4554 $('#swatche_image').show(); 4555 $('#swatche_color').val(''); 4556 } else { 4557 $('#swatche_color').hide(); 4558 $('#swatche_image').hide(); 4559 $('#swatche_color').val(''); 4560 $('#swatche_image').val(''); 4561 } 4562}); 4563// } 4564if ($('#google_pay_currency_code').length) { 4565 $('#google_pay_currency_code').on('change', function (e) { 4566 e.preventDefault(); 4567 var country_code = $(this).find(':selected').data('countrycode'); 4568 $('#google_pay_country_code').val(country_code); 4569 }); 4570} 4571 4572var ticket_id = ""; 4573var scrolled = 0; 4574$(document).on('click', '.view_ticket', function (e, row) { 4575 e.preventDefault(); 4576 scrolled = 0; 4577 $(".ticket_msg").data('max-loaded', false); 4578 ticket_id = $(this).data("id"); 4579 var username = $(this).data("username"); 4580 var date_created = $(this).data("date_created"); 4581 var subject = $(this).data("subject"); 4582 var status = $(this).data("status"); 4583 var ticket_type = $(this).data("ticket_type"); 4584 $('input[name="ticket_id"]').val(ticket_id); 4585 $('#user_name').html(username); 4586 $('#date_created').html(date_created); 4587 $('#subject').html(subject); 4588 $('.change_ticket_status').data('ticket_id', ticket_id); 4589 if (status == 1) { 4590 $('#status').html('<label class="badge badge-secondary ml-2">PENDING</label>'); 4591 } else if (status == 2) { 4592 $('#status').html('<label class="badge badge-info ml-2">OPENED</label>'); 4593 } else if (status == 3) { 4594 $('#status').html('<label class="badge badge-success ml-2">RESOLVED</label>'); 4595 } else if (status == 4) { 4596 $('#status').html('<label class="badge badge-danger ml-2">CLOSED</label>'); 4597 } else if (status == 5) { 4598 $('#status').html('<label class="badge badge-warning ml-2">REOPENED</label>'); 4599 }
4600 $('#ticket_type').html(ticket_type); 4601 $('.ticket_msg').html(""); 4602 $('.ticket_msg').data('limit', 5); 4603 $('.ticket_msg').data('offset', 0); 4604 load_messages($('.ticket_msg'), ticket_id); 4605}); 4606 4607$(document).ready(function () { 4608 if ($("#element").length) { 4609 $("#element").scrollTop($("#element")[0].scrollHeight); 4610 $('#element').scroll(function () { 4611 if ($('#element').scrollTop() == 0) { 4612 load_messages($('.ticket_msg'), ticket_id); 4613 } 4614 }); 4615 4616 $('#element').bind('mousewheel', function (e) { 4617 if (e.originalEvent.wheelDelta / 120 > 0) { 4618 if ($(".ticket_msg")[0].scrollHeight < 370 && scrolled == 0) { 4619 load_messages($('.ticket_msg'), ticket_id); 4620 scrolled = 1; 4621 } 4622 } 4623 }); 4624 } 4625}); 4626 4627$('#ticket_send_msg_form').on('submit', function (e) { 4628 e.preventDefault(); 4629 var formdata = new FormData(this); 4630 formdata.append(csrfName, csrfHash); 4631 4632 $.ajax({ 4633 type: 'POST', 4634 url: $(this).attr('action'), 4635 data: formdata, 4636 beforeSend: function () { 4637 $('#submit_btn').html('Sending..').attr('disabled', true); 4638 }, 4639 cache: false, 4640 contentType: false, 4641 processData: false, 4642 dataType: "json", 4643 success: function (result) { 4644 csrfHash = result.csrfHash; 4645 $('#submit_btn').html('Send').attr('disabled', false); 4646 if (result.error == false) { 4647 if (result.data.id > 0) { 4648 var message = result.data; 4649 var is_left = (message.user_type == 'user') ? 'left' : 'right'; 4650 var message_html = ""; 4651 var atch_html = ""; 4652 var i = 1; 4653 if (message.attachments.length > 0) { 4654 message.attachments.forEach(atch => { 4655 atch_html += "<div class='container-fluid image-upload-section'>" 4656 + "<a class='btn btn-danger btn-xs mr-1 mb-1' href='" + atch.media + "' target='_blank' alt='Attachment Not Found'>Attachment " + i + "</a>" + 4657 "<div class='col-md-3 col-sm-12 shadow p-3 mb-5 bg-white rounded m-4 text-center grow image d-none'></div>" + 4658 "</div>"; 4659 i++; 4660 }); 4661 } 4662 message_html += "<div class='direct-chat-msg " + is_left + "'>" + 4663 "<div class='direct-chat-infos clearfix'>" + 4664 "<span class='direct-chat-name float-" + is_left + "' id='name'>" + message.name + "</span>" + 4665 "<span class='direct-chat-timestamp float-" + is_left + "' id='last_updated'>" + message.last_updated + "</span>" + 4666 "</div>" + 4667 "<div class='direct-chat-text' id='message'>" + message.message + "</br>" + atch_html + "</div>" + 4668 "</div>"; 4669 4670 $('.ticket_msg').append(message_html); 4671 $("#message_input").val(''); 4672 4673 $("#element").scrollTop($("#element")[0].scrollHeight); 4674 $('input[name="attachments[]"]').val(''); 4675 } 4676 } else { 4677 $("#element").data('max-loaded', true); 4678 iziToast.error({ 4679 message: '<span style="text-transform:capitalize">' + result.message + '</span> ', 4680 }); 4681 return false; 4682 } 4683 iziToast.success({ 4684 message: '<span style="text-transform:capitalize">' + result.message + '</span> ', 4685 }); 4686 } 4687 }); 4688}); 4689 4690// if ($('#delete-ticket').length) { 4691$(document).on('click', '#delete-ticket', function () { 4692 4693 var id = $(this).data('id'); 4694 Swal.fire({ 4695 title: 'Are You Sure !', 4696 text: "You won't be able to revert this!", 4697 type: 'warning', 4698 showCancelButton: true, 4699 confirmButtonColor: '#3085d6', 4700 cancelButtonColor: '#d33', 4701 confirmButtonText: 'Yes, delete it!', 4702 showLoaderOnConfirm: true, 4703 preConfirm: function () { 4704 return new Promise((resolve, reject) => { 4705 $.ajax({ 4706 url: base_url + 'admin/tickets/delete_ticket', 4707 type: 'GET', 4708 data: { 'id': id }, 4709 dataType: 'json', 4710 }) 4711 .done(function (response, textStatus) { 4712 if (response.error == false) { 4713 Swal.fire('Deleted!', response.message, 'success'); 4714 $('table').bootstrapTable('refresh'); 4715 } else { 4716 Swal.fire('Oops...', response.message, 'warning'); 4717 } 4718 }) 4719 .fail(function (jqXHR, textStatus, errorThrown) { 4720 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 4721 }); 4722 }); 4723 }, 4724 allowOutsideClick: false 4725 }); 4726}); 4727// } 4728 4729$(document).on('change', '.change_ticket_status', function () { 4730 var status = $(this).val(); 4731 if (status != '') { 4732 if (confirm("Are you sure you want to mark the ticket as " + $(".change_ticket_status option:selected").text() + "? ")) { 4733 var id = $(this).data('ticket_id'); 4734 var dataString = { ticket_id: id, status: status, [csrfName]: csrfHash }; 4735 $.ajax({ 4736 type: 'post', 4737 url: base_url + 'admin/tickets/edit-ticket-status', 4738 data: dataString, 4739 dataType: 'json', 4740 success: function (result) { 4741 csrfHash = result.csrfHash; 4742 if (result.error == false) {
4743 $('#ticket_table').bootstrapTable('refresh'); 4744 iziToast.success({ 4745 message: '<span style="text-transform:capitalize">' + result.message + '</span> ', 4746 }); 4747 4748 } else { 4749 iziToast.error({ 4750 message: '<span>' + result.message + '</span> ', 4751 }); 4752 } 4753 } 4754 }); 4755 } 4756 } 4757}); 4758 4759$(document).on('click', '.delete-ticket-type', function () { 4760 var cat_id = $(this).data('id'); 4761 Swal.fire({ 4762 title: 'Are You Sure!', 4763 text: "You won't be able to revert this!", 4764 type: 'warning', 4765 showCancelButton: true, 4766 confirmButtonColor: '#3085d6', 4767 cancelButtonColor: '#d33', 4768 confirmButtonText: 'Yes, delete it!', 4769 showLoaderOnConfirm: true, 4770 preConfirm: function () { 4771 return new Promise((resolve, reject) => { 4772 $.ajax({ 4773 type: 'GET', 4774 url: base_url + 'admin/tickets/delete_ticket_type', 4775 data: { id: cat_id }, 4776 dataType: 'json' 4777 }) 4778 .done(function (response, textStatus) { 4779 if (response.error == false) { 4780 Swal.fire('Deleted!', response.message, 'success'); 4781 $('table').bootstrapTable('refresh'); 4782 csrfName = response['csrfName']; 4783 csrfHash = response['csrfHash']; 4784 } else { 4785 Swal.fire('Oops...', response.message, 'warning'); 4786 $('table').bootstrapTable('refresh'); 4787 csrfName = response['csrfName']; 4788 csrfHash = response['csrfHash']; 4789 } 4790 4791 }) 4792 .fail(function (jqXHR, textStatus, errorThrown) { 4793 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 4794 csrfName = response['csrfName']; 4795 csrfHash = response['csrfHash']; 4796 }); 4797 }); 4798 }, 4799 allowOutsideClick: false 4800 }); 4801}); 4802 4803function load_messages(element, ticket_id) { 4804 var limit = element.data('limit'); 4805 var offset = element.data('offset'); 4806 4807 element.data('offset', limit + offset); 4808 var max_loaded = element.data('max-loaded'); 4809 if (max_loaded == false) { 4810 var loader = '<div class="loader text-center"><img src="' + base_url + 'assets/pre-loader.gif" alt="Loading. please wait.. ." title="Loading. please wait.. ."></div>'; 4811 $.ajax({ 4812 type: 'get', 4813 data: 'ticket_id=' + ticket_id + '&limit=' + limit + '&offset=' + offset, 4814 url: base_url + 'admin/tickets/get_ticket_messages', 4815 beforeSend: function () { 4816 $('.ticket_msg').prepend(loader); 4817 }, 4818 dataType: 'json', 4819 cache: false, 4820 contentType: false, 4821 processData: false, 4822 success: function (result) { 4823 if (result.error == false) { 4824 if (result.error == false && result.data.length > 0) { 4825 var messages_html = ""; 4826 var is_left = ""; 4827 var is_right = ""; 4828 var atch_html = ""; 4829 var i = 1; 4830 result.data.reverse().forEach(messages => { 4831 is_left = (messages.user_type == 'user') ? 'left' : 'right'; 4832 is_right = (messages.user_type == 'user') ? 'right' : 'left'; 4833 if (messages.attachments.length > 0) { 4834 messages.attachments.forEach(atch => { 4835 atch_html += "<div class='container-fluid image-upload-section'>" 4836 + "<a class='btn btn-danger btn-xs mr-1 mb-1' href='" + atch.media + "' target='_blank' alt='Attachment Not Found'>Attachment " + i + "</a>" + 4837 "<div class='col-md-3 col-sm-12 shadow p-3 mb-5 bg-white rounded m-4 text-center grow image d-none'></div>" + 4838 "</div>"; 4839 i++; 4840 }); 4841 } 4842 messages_html += "<div class='direct-chat-msg " + is_left + "'>" + 4843 "<div class='direct-chat-infos clearfix'>" + 4844 "<span class='direct-chat-name float-" + is_left + "' id='name'>" + messages.name + "</span>" + 4845 "<span class='direct-chat-timestamp float-" + is_left + "' id='last_updated'>" + messages.last_updated + "</span>" + 4846 "</div>" + 4847 "<div class='direct-chat-text' id='message'>" + messages.message + "</br>" + atch_html + "</div>" + 4848 "</div>"; 4849 }); 4850 $('.ticket_msg').prepend(messages_html); 4851 $('.ticket_msg').find('.loader').remove(); 4852 $(element).animate({ 4853 scrollTop: $(element).offset().top 4854 }); 4855 } 4856 } else { 4857 element.data('offset', offset); 4858 element.data('max-loaded', true); 4859 $('.ticket_msg').find('.loader').remove(); 4860 $('.ticket_msg').prepend('<div class="text-center"> <p>You have reached the top most message!</p></div>'); 4861 } 4862 $('#element').scrollTop(20); // Scroll alittle way down, to allow user to scroll more 4863 $(element).animate({ 4864 scrollTop: $(element).offset().top 4865 }); 4866 return false;
4867 } 4868 }); 4869 4870 } 4871} 4872 4873$(document).on('click', '.edit_transaction', function (e, row) { 4874 e.preventDefault(); 4875 var id = $(this).data("id"); 4876 var txn_id = $(this).data("txn_id"); 4877 var status = $(this).data("status"); 4878 var message = $(this).data("message"); 4879 4880 $('#id').val(id); 4881 $('#txn_id').val(txn_id); 4882 $('#t_status').val(status); 4883 $('#message').val(message); 4884 4885}); 4886$(document).on('click', '.edit_order_tracking', function (e, rows) { 4887 e.preventDefault(); 4888 var order_item_id = $(this).data("order_item_id"); 4889 var order_id = $(this).data("order_id"); 4890 var courier_agency = $(this).data("courier_agency"); 4891 var tracking_id = $(this).data("tracking_id"); 4892 var url = $(this).data("url"); 4893 $('#order_item_id').val(order_item_id); 4894 $('input[name="order_id"]').val(order_id); 4895 $('#order_id').val(order_id); 4896 $('#courier_agency').val(courier_agency); 4897 $('#tracking_id').val(tracking_id); 4898 $('#url').val(url); 4899 $('#order_tracking_table').bootstrapTable('refresh'); 4900}); 4901 4902$('#edit_transaction_form').on('submit', function (e) { 4903 e.preventDefault(); 4904 var formdata = new FormData(this); 4905 formdata.append(csrfName, csrfHash); 4906 4907 $.ajax({ 4908 type: 'POST', 4909 url: $(this).attr('action'), 4910 data: formdata, 4911 beforeSend: function () { 4912 $('#submit_btn').html('Please Wait..').attr('disabled', true); 4913 }, 4914 cache: false, 4915 contentType: false, 4916 processData: false, 4917 dataType: "json", 4918 success: function (result) { 4919 csrfHash = result.csrfHash; 4920 $('#submit_btn').html('Update Transaction').attr('disabled', false); 4921 if (result.error == false) { 4922 $('table').bootstrapTable('refresh'); 4923 iziToast.success({ 4924 message: '<span style="text-transform:capitalize">' + result.message + '</span> ', 4925 }); 4926 } else { 4927 iziToast.error({ 4928 message: '<span>' + result.message + '</span> ', 4929 }); 4930 } 4931 } 4932 }); 4933}); 4934 4935$('#order_tracking_form').on('submit', function (e) { 4936 e.preventDefault(); 4937 var formdata = new FormData(this); 4938 formdata.append(csrfName, csrfHash); 4939 4940 $.ajax({ 4941 type: 'POST', 4942 url: $(this).attr('action'), 4943 data: formdata, 4944 beforeSend: function () { 4945 $('#submit_btn').html('Please Wait..').attr('disabled', true); 4946 }, 4947 cache: false, 4948 contentType: false, 4949 processData: false, 4950 dataType: "json", 4951 success: function (result) { 4952 csrfHash = result.csrfHash; 4953 $('#submit_btn').html('Update Transaction').attr('disabled', false); 4954 if (result.error == false) { 4955 $('table').bootstrapTable('refresh'); 4956 iziToast.success({ 4957 message: '<span style="text-transform:capitalize">' + result.message + '</span> ', 4958 }); 4959 } else { 4960 iziToast.error({ 4961 message: '<span>' + result.message + '</span> ', 4962 }); 4963 } 4964 } 4965 }); 4966}); 4967 4968$(document).on('click', '.delete-receipt', function () { 4969 var cat_id = $(this).data('id'); 4970 Swal.fire({ 4971 title: 'Are You Sure!', 4972 text: "You won't be able to revert this!", 4973 type: 'warning', 4974 showCancelButton: true, 4975 confirmButtonColor: '#3085d6', 4976 cancelButtonColor: '#d33', 4977 confirmButtonText: 'Yes, delete it!', 4978 showLoaderOnConfirm: true, 4979 preConfirm: function () { 4980 return new Promise((resolve, reject) => { 4981 $.ajax({ 4982 type: 'GET', 4983 url: base_url + 'admin/orders/delete_receipt', 4984 data: { id: cat_id }, 4985 dataType: 'json' 4986 }) 4987 .done(function (response, textStatus) { 4988 if (response.error == false) { 4989 Swal.fire('Deleted!', response.message, 'success'); 4990 $('table').bootstrapTable('refresh'); 4991 csrfName = response['csrfName']; 4992 csrfHash = response['csrfHash']; 4993 window.location.reload(); 4994 } else { 4995 Swal.fire('Oops...', response.message, 'warning'); 4996 $('table').bootstrapTable('refresh'); 4997 csrfName = response['csrfName']; 4998 csrfHash = response['csrfHash']; 4999 } 5000 5001 }) 5002 .fail(function (jqXHR, textStatus, errorThrown) { 5003 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 5004 csrfName = response['csrfName']; 5005 csrfHash = response['csrfHash']; 5006 }); 5007 }); 5008 }, 5009 allowOutsideClick: false 5010 }); 5011}); 5012 5013$('#update_receipt_status').on('change', function (e) { 5014 e.preventDefault(); 5015 var order_id = $(this).data('id'); 5016 var user_id = $(this).data('user_id'); 5017 var status = $(this).val(); 5018 $.ajax({ 5019 type: 'POST', 5020 data: { 5021 'order_id': order_id, 5022 'status': status, 5023 'user_id': user_id, 5024 [csrfName]: csrfHash, 5025 }, 5026 url: base_url + 'admin/orders/update_receipt_status', 5027 dataType: 'json', 5028 success: function (result) { 5029 csrfName = result.csrfName; 5030 csrfHash = result.csrfHash; 5031 if (result['error'] == false) { 5032 iziToast.success({ 5033 message: result['message'], 5034 }); 5035 } else { 5036 iziToast.error({ 5037 message: result['message'], 5038 }); 5039 } 5040 } 5041 }); 5042}); 5043 5044//13.City-Module 5045$(document).on('click', '#delete-zipcode', function () { 5046 5047 var id = $(this).data('id'); 5048 Swal.fire({ 5049 title: 'Are You Sure !', 5050 text: "You won't be able to revert this!", 5051 type: 'warning', 5052 showCancelButton: true, 5053 confirmButtonColor: '#3085d6', 5054 cancelButtonColor: '#d33', 5055 confirmButtonText: 'Yes, delete it!', 5056 showLoaderOnConfirm: true, 5057 preConfirm: function () { 5058 return new Promise((resolve, reject) => { 5059 $.ajax({ 5060 url: base_url + 'admin/Area/delete_zipcode', 5061 type: 'GET', 5062 data: { 'id': id }, 5063 dataType: 'json', 5064 }) 5065 .done(function (response, textStatus) { 5066 if (response.error == false) { 5067 Swal.fire('Deleted!', response.message, 'success'); 5068 $('table').bootstrapTable('refresh'); 5069 } else { 5070 Swal.fire('Oops...', response.message, 'warning'); 5071 } 5072 }) 5073 .fail(function (jqXHR, textStatus, errorThrown) { 5074 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 5075 }); 5076 }); 5077 }, 5078 allowOutsideClick: false 5079 }); 5080}); 5081 5082var search_zipcodes = searchable_zipcodes(); 5083 5084search_zipcodes.on('select2:select', function (e) { 5085 var data = e.params.data; 5086 if (data.link != undefined && data.link != null) { 5087 window.location.href = data.link; 5088 } 5089}); 5090 5091$(document).on('change', '#deliverable_type', function () { 5092 var type = $(this).val(); 5093 if (type == "1" || type == "0") { 5094 $('#deliverable_zipcodes').prop('disabled', 'disabled'); 5095 } else { 5096 $('#deliverable_zipcodes').prop('disabled', false); 5097 } 5098}); 5099 5100var cat_html = ""; 5101var count_view = 0; 5102$(document).on('click', '#seller_model', function (e) { 5103 5104 5105 e.preventDefault(); 5106 cat_html = $('#cat_html').html(); 5107 var cat_ids = $(this).data('cat_ids') + ','; 5108 var cat_array = cat_ids.split(","); 5109 cat_array = cat_array.filter(function (v) { return v !== '' }); 5110 cat_array.sort(function (a, b) { 5111 return a - b; 5112 }); 5113 var seller_id = $(this).data('seller_id'); 5114 5115 if (cat_ids != "" && cat_ids != 'undefined' && seller_id != "" && seller_id != 'undefined' && count_view == 0) { 5116 $.ajax({ 5117 type: 'POST', 5118 data: { 5119 'id': seller_id, 5120 [csrfName]: csrfHash 5121 }, 5122 url: base_url + 'admin/sellers/get_seller_commission_data', 5123 dataType: 'json', 5124 success: function (result) { 5125 csrfName = result.csrfName; 5126 csrfHash = result.csrfHash; 5127 if (result.error == false) { 5128 var option_html = ''; 5129 $.each(result.data, function (i, e) { 5130 var is_selected = (e.category_id == cat_array[i] && e.seller_id == seller_id) ? "selected" : ""; 5131 option_html += '<option value=' + e.category_id + ' ' + is_selected + '>
5131' + e.name + '</option>'; 5132 load_category_section("", true, option_html, e.commission); 5133 }); 5134 } else { 5135 iziToast.error({ 5136 message: '<span>' + result.message + '</span> ', 5137 }); 5138 } 5139 } 5140 }); 5141 count_view = 1; 5142 } else { 5143 if (count_view == 0) { 5144 load_category_section(cat_html); 5145 } 5146 count_view = 1; 5147 5148 } 5149 5150}); 5151 5152 5153var cat_html = ""; 5154var count_view = 0; 5155$(document).on('click', '#seller_model1', function (e) { 5156 5157 5158 5159 5160 e.preventDefault(); 5161 cat_html = $('#cat_html').html(); 5162 var cat_ids = $(this).data('cat_ids') + ','; 5163 var cat_array = cat_ids.split(","); 5164 cat_array = cat_array.filter(function (v) { return v !== '' }); 5165 cat_array.sort(function (a, b) { 5166 return a - b; 5167 }); 5168 var seller_id = $(this).data('seller_id'); 5169 5170 if (cat_ids != "" && cat_ids != 'undefined' && seller_id != "" && seller_id != 'undefined' && count_view == 0) { 5171 $.ajax({ 5172 type: 'POST', 5173 data: { 5174 'id': seller_id, 5175 [csrfName]: csrfHash 5176 }, 5177 url: base_url + 'seller/sellers/get_seller_commission_data', 5178 dataType: 'json', 5179 success: function (result) { 5180 csrfName = result.csrfName; 5181 csrfHash = result.csrfHash; 5182 if (result.error == false) { 5183 var option_html = ''; 5184 $.each(result.data, function (i, e) { 5185 var is_selected = (e.category_id == cat_array[i] && e.seller_id == seller_id) ? "selected" : ""; 5186 option_html += '<option value=' + e.category_id + ' ' + is_selected + '>' + e.name + '</option>'; 5187 load_category_section("", true, option_html, e.commission); 5188 }); 5189 } else { 5190 iziToast.error({ 5191 message: '<span>' + result.message + '</span> ', 5192 }); 5193 } 5194 } 5195 }); 5196 count_view = 1; 5197 } else { 5198 if (count_view == 0) { 5199 load_category_section(cat_html); 5200 } 5201 count_view = 1; 5202 5203 } 5204 5205}); 5206 5207$(document).on('click', '#add_category', function (e) { 5208 e.preventDefault(); 5209 load_category_section(cat_html, false); 5210}); 5211 5212function load_category_section(cat_html, is_edit = false, option_html = "", commission = 0) { 5213 5214 if (is_edit == true) { 5215 5216 var html = ' <div class="form-group row">' + 5217 '<div class="col-sm-5">' + 5218 '<select name="category_id" class="form-control select_multiple w-100" data-placeholder=" Select Category">' + 5219 '<option value="">Select Category </option>' + option_html 5220 + '</select>' + 5221 '</div>' + 5222 '<div class="col-sm-5">' + 5223 '<input type="number" step="any" min="0" class="form-control" placeholder="Enter Commission" name="commission" required value="' + commission + '">' + 5224 '</div>' + 5225 '<div class="col-sm-2"> ' + 5226 '<button type="button" class="btn btn-tool remove_category_section" > <i class="text-danger far fa-times-circle fa-2x "></i> </button>' + 5227 '</div>' + 5228 '</div>' + 5229 '</div>'; 5230 } else { 5231 var html = ' <div class="form-group row">' + 5232 '<div class="col-sm-5">' + 5233 '<select name="category_id" class="form-control select_multiple w-100" data-placeholder="Select Category">' + 5234 '<option value="">Select Category </option>' + cat_html + 5235 '</select>' + 5236 '</div>' + 5237 '<div class="col-sm-5">' + 5238 '<input type="number" step="any" min="0" class="form-control" placeholder="Enter Commission" name="commission" value="0">' + 5239 '</div>' + 5240 '<div class="col-sm-2"> ' + 5241 '<button type="button" class="btn btn-tool remove_category_section" > <i class="text-danger far fa-times-circle fa-2x "></i> </button>' + 5242 '</div>' + 5243 '</div>' + 5244 '</div>'; 5245 } 5246 $('#category_section').append(html); 5247 $('.select_multiple').each(function () { 5248 $('.select_multiple').select2({ 5249 theme: 'bootstrap4', 5250 width: $('.select_multiple').data('width') ? $('.select_multiple').data('width') : $('.select_multiple').hasClass('w-100') ? '100%' : 'style', 5251 placeholder: $('.select_multiple').data('placeholder'), 5252 allowClear: Boolean($('.select_multiple').data('allow-clear')), 5253 }); 5254 }); 5255 5256 5257} 5258 5259$(document).on('click', '.remove_category_section', function () { 5260 $(this).closest('.row').remove(); 5261}); 5262 5263$("#seller_table").on("click-cell.bs.table", function (field, value, row, $el) { 5264 $('input[name="seller_status"]').val($el.id); 5265}); 5266 5267 5268$('#add-seller-commission-form').on('submit', function (e) { 5269 e.preventDefault(); 5270 var formData = new FormData(this); 5271 5272 var object = {}; 5273 formData.forEach((value, key) => { 5274 // Reflect.has in favor of: object.hasOwnProperty(key) 5275 if (!Reflect.has(object, key)) { 5276 object[key] = value; 5277 return; 5278 } 5279 if (!Array.isArray(object[key])) { 5280 object[key] = [object[key]]; 5281 } 5282 object[key].push(value); 5283 }); 5284 var json = JSON.stringify(object); 5285 $('#cat_data').val(json); 5286 setTimeout(function () { 5287 $('#set_commission_model').modal('hide'); 5288 }, 2000); 5289 5290}); 5291 5292$(document).on('submit', '#verify-acount-form', function (e) { 5293 e.preventDefault(); 5294 var formdata = new FormData(this); 5295 formdata.append(csrfName, csrfHash); 5296 5297 $.ajax({ 5298 type: 'POST', 5299 url: $(this).attr('action'), 5300 data: formdata, 5301 beforeSend: function () { 5302 $('#submit_btn1').html('Please Wait..').attr('disabled', true); 5303 }, 5304 cache: false, 5305 contentType: false, 5306 processData: false, 5307 dataType: "json", 5308 success: function (result) { 5309 csrfHash = result.csrfHash; 5310 $('#submit_btn1').html('Verify Account').attr('disabled', false); 5311 if (result.error == false) { 5312 if (result.redirect == "3") { 5313 window.location.replace(base_url + 'seller/auth/sign_up'); 5314 } else if (result.redirect == "1") { 5315 iziToast.success({ 5316 message: '<span style="text-transform:capitalize">' + result.message + '</span> ', 5317 }); 5318 } 5319 5320 } else { 5321 if (result.redirect == '2') { 5322 window.location.replace(base_url + 'seller/auth/sign_up'); 5323 } 5324 iziToast.error({ 5325 message: '<span>' + result.message + '</span> ', 5326 }); 5327 } 5328 $('#verify-acount-form').trigger("reset"); 5329 setTimeout(function () { 5330 $('#has_account_model').modal('hide'); 5331 }, 3000); 5332 } 5333 }); 5334}); 5335 5336$(document).on('click', '#create-slug', function (e) { 5337 e.preventDefault(); 5338 $.ajax({ 5339 type: 'get', 5340 url: base_url + 'admin/sellers/create_slug', 5341 beforeSend: function () { 5342 $(this).html('Please Wait..').attr('disabled', true); 5343 }, 5344 cache: false, 5345 contentType: false, 5346 processData: false, 5347 dataType: "json", 5348 success: function (result) { 5349 csrfHash = result.csrfHash; 5350 $(this).html('Create Seller Slug').attr('disabled', false); 5351 if (result.error == false) { 5352 iziToast.success({ 5353 message: result['message'], 5354 }); 5355 } else { 5356 iziToast.error({ 5357 message: '<span>' + result.message + '</span> ', 5358 }); 5359 } 5360 } 5361 }); 5362}); 5363 5364 5365$(document).on('click', '.update-seller-commission', function () { 5366 5367 // var id = $(this).data('id'); 5368 Swal.fire({ 5369 title: 'Are You Sure !', 5370 text: "You won't be able to revert this!", 5371 type: 'info', 5372 showCancelButton: true, 5373 confirmButtonColor: '#3085d6', 5374 cancelButtonColor: '#d33', 5375 confirmButtonText: 'Yes, settle commission!', 5376 showLoaderOnConfirm: true, 5377 preConfirm: function () { 5378 return new Promise((resolve, reject) => { 5379 $.ajax({ 5380 url: base_url + 'admin/cron-job/settle-seller-commission', 5381 type: 'GET', 5382 data: { 'is_date': true }, 5383 dataType: 'json', 5384 }) 5385 .done(function (response, textStatus) { 5386 if (response.error == false) { 5387 Swal.fire('Done!', response.message, 'success'); 5388 $('table').bootstrapTable('refresh'); 5389 } else { 5390 Swal.fire('Oops...', response.message, 'warning'); 5391 } 5392 }) 5393 .fail(function (jqXHR, textStatus, errorThrown) { 5394 Swal.fire('Oops...', 'Something went wrong with ajax !', 'error'); 5395 }); 5396 }); 5397 }, 5398 allowOutsideClick: false 5399 }); 5400}); 5401 5402 5403function cash_collection_query_params(p) { 5404 return { 5405 filter_date: $('#filter_date').val(), 5406 filter_status: $('#filter_status').val(), 5407 filter_d_boy: $('#filter_d_boy').val(), 5408 "start_date": $('#start_date').val(), 5409 "end_date": $('#end_date').val(), 5410 limit: p.limit, 5411 sort: p.sort, 5412 order: p.order, 5413 offset: p.offset, 5414 search: p.search 5415 }; 5416} 5417 5418var d_boy_cash = 0; 5419$('#delivery_boys_details').on('check.bs.table', function (e, row) { 5420 d_boy_cash = row.cash_received; 5421 $('#details').val("Id: " + row.id + " | Name:" + row.name + " | Mobile: " + row.mobile + " | Cash: " + row.cash_received); 5422 $('#delivery_boy_id').val(row.id); 5423});
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.