function OCTgeturlparam(param) {
var urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param) !== null ? param+'='+urlParams.get(param) : '';
}
var OCT4_GET_LANG = '';
var atqatc_ur1201 = 'index.php?route=module/atqatc/';
var atqatc_url230 = 'index.php?route=extension/module/atqatc/';
var atqatc_url401 = 'index.php?route=extension/atqatc/module/atqatc|';
var atqatc_url402 = 'index.php?route=extension/atqatc/module/atqatc.';
var atqatc = {
'atgrid': function() {
var product_ids = [];
$("[onclick*='cart.add'], [onclick*='addToCart'], button[formaction*='checkout/cart.add']").each(function() {
if($(this).closest('form').find("[name*='product_id']").length) {
var target = $(this).closest('.product-thumb, .product-wrapper');
var product_id = $(this).closest('form').find("[name*='product_id']").val();
} else {
var target = $(this).closest('.product-thumb, .product-wrapper');
var product_id = $(this).attr('onclick').match(/[0-9]+/).toString();
}
if(target.length && target.hasClass('atqatc_atgridcol') == false) {
target.addClass('atqatc_atgridcol').addClass('atqatc_atgridcol'+product_id);
product_ids.push(product_id);
}
});
if(product_ids.length) {
//console.log(product_ids.length);
$.ajax({
url: atqatc_url230 + 'getcache' + OCT4_GET_LANG,
type: 'post',
data: {product_ids:product_ids},
cache: true,
complete: function() {
},
success: function(json) {
if(json) {
//console.log(json);
$("[onclick*='cart.add'], [onclick*='addToCart'], button[formaction*='checkout/cart.add']").each(function() {
if($(this).closest('form').find("[name*='product_id']").length) {
var target = $(this).closest('.product-thumb, .product-wrapper');
var product_id = $(this).closest('form').find("[name*='product_id']").val();
} else {
var target = $(this).closest('.product-thumb, .product-wrapper');
var product_id = $(this).attr('onclick').match(/[0-9]+/).toString();
}
if(json[product_id] && target.length && target.find('.atqatc_grdbtn').length == 0) {
if(parseInt(json[product_id]['btntype']) == 0) {
$(this).html(json[product_id]['btntext']).addClass('atqatc_grdbtn').attr('onclick', 'atqatc.add('+product_id+','+json[product_id]['atqatc_id']+')');
} else {
$(this).before(''+json[product_id]['btntext']+'');
}
if(parseInt(json[product_id]['hideprc']) >= 1) {
target.find('.price').remove();
}
}
});
}
}
});
}
},
'prodpage': function() {
var product_ids = [];
var product_id = false;
if($(".button-group-page input[name='product_id']").length) {
product_id = $(".button-group-page input[name='product_id']").val();
product_ids.push(product_id);
} else if($('#input-product-id').length) {
product_id = $('#input-product-id').val();
product_ids.push(product_id);
} else if($(".product-info input[name='product_id']").length) {
product_id = $(".product-info input[name='product_id']").val();
product_ids.push(product_id);
} else if($("#product input[name='product_id']").length) {
product_id = $("#product input[name='product_id']").val();
product_ids.push(product_id);
}
if (product_ids.length) {
$.ajax({
url: atqatc_url230 + 'getcache' + OCT4_GET_LANG,
type: 'post',
data: {product_ids:product_ids},
cache: true,
complete: function() {
},
success: function(json) {
if(json) {
//console.log(json);
var target = $('#product');
var target_J2 = $('.route-product-product .product-info .left .image');
var target_J3 = $('.product-left .product-image');
var target_OC4 = $('.magnific-popup');
if(json[product_id]) {
if(target.length && target.find('.atqatc_prdbtn').length == 0) {
if(parseInt(json[product_id]['btntype']) == 0) {
$('#button-cart').unbind('click').html(json[product_id]['btntext']).addClass('atqatc_prdbtn').attr('onclick', 'atqatc.addprd('+product_id+', '+json[product_id]['atqatc_id']+')');
} else {
$('#button-cart').after(''+json[product_id]['btntext']+'');
}
if(parseInt(json[product_id]['hideprc']) >= 1) {
$('#product').parent().find('ul.list-unstyled:eq(1)').remove();
$('#product .price-wrapper, #product ul.price').remove();
}
}
}
}
}
});
}
},
'setdatepicker': function() {
$('.date').datetimepicker({
pickTime: false
});
$('.datetime').datetimepicker({
pickDate: true,
pickTime: true
});
$('.time').datetimepicker({
pickDate: false
});
},
'showpop': function() {
$('#pop-atqatc').modal('show');
$('#pop-atqatc .modal-body').html('');
},
'refreshpop': function() {
$.ajax({
url: atqatc_url230 + 'loadenqcart' + OCT4_GET_LANG,
dataType: 'html',
cache: false,
beforeSend: function() { $('#pop-atqatc .modal-body').html(''); },
success: function(html) {
$('#pop-atqatc .modal-dialog').html(html);
atqatc.setdatepicker();
}
});
},
'after_add': function(json) {
setTimeout(function () {
$('.btnenqcart').html(json['total']);
$('#cart-total').html('' + json['total'] + '');
}, 100);
$('#cart > ul').load('index.php?route=common/cart/info ul li');
if(json['rsdata']['btnact'] == 0 && json['rsdata']['carttype'] == 1) {
location = 'index.php?route=checkout/cart';
} else if(json['rsdata']['btnact'] == 1) {
atqatc.showpop();
atqatc.refreshpop();
} else if(json['rsdata']['btnact'] == 2) {
$('#content').parent().before('
' + json['success'] + '
');
$('html, body').animate({ scrollTop: 0 }, 'slow');
} else {
atqatc.showpop();
atqatc.refreshpop();
}
},
'add': function(product_id, atqatc_id, quantity) {
$.ajax({
url: atqatc_url230 + 'add' + OCT4_GET_LANG,
type: 'post',
data: {product_id:product_id, atqatc_id:atqatc_id, quantity:(typeof(quantity) != 'undefined' ? quantity : 1)},
dataType: 'json',
beforeSend: function() { $('.btnenqcart').button('loading'); },
complete: function() { $('.btnenqcart').button('reset'); },
success: function(json) {
$('.alert, .text-danger').remove();
if (json['redirect']) { location = json['redirect']; }
if (json['success']) { atqatc.after_add(json); }
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
},
'addprd': function(product_id, atqatc_id) {
$('#product').append('');
$.ajax({
url: atqatc_url230 + 'add' + OCT4_GET_LANG,
type: 'post',
data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
dataType: 'json',
beforeSend: function() { $('.btnenqcart').button('loading'); },
complete: function() { $('.btnenqcart').button('reset'); },
success: function(json) {
$('.alert, .text-danger').remove();
$('.form-group, .mb-3').removeClass('has-error');
if (json['error']) {
if (json['error']['option']) {
for (i in json['error']['option']) {
var element = $('#input-option' + i.replace('_', '-'));
if (element.parent().hasClass('input-group')) {
element.parent().after('' + json['error']['option'][i] + '
');
} else {
element.after('' + json['error']['option'][i] + '
');
}
}
}
// Highlight any found errors
$('.text-danger').parent().addClass('has-error');
}
if (json['success']) { atqatc.after_add(json); }
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
},
'edit': function(key, quantity) {
$.ajax({
url: atqatc_url230 + 'edit' + OCT4_GET_LANG,
type: 'post',
data: $('#pop-atqatc input[type="text"]'),
dataType: 'json',
cache: false,
beforeSend: function() { $('.btnenqcart').button('loading'); },
complete: function() { $('.btnenqcart').button('reset'); },
success: function(json) {
setTimeout(function () { $('.btnenqcart').html(json['total']); }, 100);
$('#cart > ul').load('index.php?route=common/cart/info ul li');
atqatc.refreshpop();
}
});
},
'remove': function(key) {
$.ajax({
url: atqatc_url230 + 'remove' + OCT4_GET_LANG,
type: 'post',
data: 'key=' + key,
dataType: 'json',
cache: false,
beforeSend: function() { $('.btnenqcart').button('loading'); },
complete: function() { $('.btnenqcart').button('reset'); },
success: function(json) {
setTimeout(function () { $('.btnenqcart').html(json['total']); }, 100);
$('#cart > ul').load('index.php?route=common/cart/info ul li');
atqatc.refreshpop();
}
});
},
'initjson': function() {
atqatc.atgrid();
$(document).ajaxStop(function() {
atqatc.atgrid(); $(".price, #product .price-wrapper, #product ul.price, .col-sm-4 ul.list-unstyled, #product-info ul.list-unstyled, [onclick*='cart.add'], [formaction*='checkout/cart.add'], [onclick*='addToCart'], #button-cart, .btn-1-extra").attr('style','opacity:1;');
});
atqatc.prodpage();
var pophtml = '';
$('body').append(pophtml);
$.ajax({
url: atqatc_url230 + 'get_enqcart_count' + OCT4_GET_LANG,
dataType: 'json',
cache: false,
success: function(json) {
$('#cart').after('');
// OC4 $('#header-cart').after('');
setTimeout(function () { $('.btnenqcart').html(json['total']); }, 100);
$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
});
}
}
$(document).ready(function() {
atqatc.initjson();
});
$(document).delegate('.btnenqcart', 'click', function() {
atqatc.showpop();
atqatc.refreshpop();
});
/*Quote Form Submit*/
$(document).delegate('#button-atqatc_form_submit', 'click', function() {
$('.alert, .text-danger').remove();
$('#atqatcform td').removeClass('has-error');
$.ajax({
url: atqatc_url230 + 'submitform' + OCT4_GET_LANG,
type: 'post',
data: $('#atqatcform input[type="text"], #atqatcform input[type="email"], #atqatcform input[type="date"], #atqatcform input[type="datetime"], #atqatcform input[type="time"], #atqatcform input[type="password"], #atqatcform input[type="hidden"], #atqatcform input[type="checkbox"]:checked, #atqatcform input[type="radio"]:checked, #atqatcform textarea, #atqatcform select'),
dataType: 'json',
beforeSend: function() { $('#button-atqatc_form_submit').button('loading'); },
complete: function() { $('#button-atqatc_form_submit').button('reset'); },
success: function(json) {
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
for (i in json['error']) {
var element = $('#atqatcform').find('#input-' + i);
if ($(element).parent().hasClass('input-group')) {
$(element).parent().after('' + json['error'][i] + '
');
} else {
$(element).after('' + json['error'][i] + '
');
}
if(i == 'captcha'){
$('div.atqatccaptcha').append('' + json['error'][i] + '
');
}
}
$('.text-danger').closest('td').addClass('has-error');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
/*AUTO SAVE START*/
$(document).delegate('#atqatcform input[type="text"], #atqatcform textarea, #atqatcform input[type="date"], #atqatcform input[type="datetime"], #atqatcform input[type="time"], #atqatcform input[type="password"], #atqatcform input[type="hidden"]', 'blur', function() {
$.ajax({
url: atqatc_url230 + 'autosave' + OCT4_GET_LANG,
type: 'post',
data: $('#atqatcform input[type="text"], #atqatcform input[type="email"], #atqatcform input[type="date"], #atqatcform input[type="datetime"], #atqatcform input[type="time"], #atqatcform input[type="password"], #atqatcform input[type="hidden"], #atqatcform input[type="checkbox"]:checked, #atqatcform input[type="radio"]:checked, #atqatcform textarea, #atqatcform select'),
dataType: 'json',
beforeSend: function() { },
complete: function() { },
success: function(json) {
//console.log(json['postdata']);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$(document).delegate('#atqatcform input[type="checkbox"], #atqatcform input[type="radio"], #atqatcform select', 'change', function() {
$.ajax({
url: atqatc_url230 + 'autosave' + OCT4_GET_LANG,
type: 'post',
data: $('#atqatcform input[type="text"], #atqatcform input[type="email"], #atqatcform input[type="date"], #atqatcform input[type="datetime"], #atqatcform input[type="time"], #atqatcform input[type="password"], #atqatcform input[type="hidden"], #atqatcform input[type="checkbox"]:checked, #atqatcform input[type="radio"]:checked, #atqatcform textarea, #atqatcform select'),
dataType: 'json',
beforeSend: function() { },
complete: function() { },
success: function(json) {
//console.log(json['postdata']);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$(document).delegate('#atqatcform button[id*="button-fld"]', 'click', function() {
var node = this;
$('#form-upload').remove();
$('body').prepend('');
$('#form-upload input[name="file"]').trigger('click');
if (typeof timer != 'undefined') {
clearInterval(timer);
}
timer = setInterval(function() {
if ($('#form-upload input[name="file"]').val() != '') {
clearInterval(timer);
$.ajax({
url: 'index.php?route=tool/upload' + OCT4_GET_LANG,
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$(node).button('loading');
},
complete: function() {
$(node).button('reset');
},
success: function(json) {
$(node).parent().find('.text-danger').remove();
if (json['error']) {
$(node).parent().find('input').after('' + json['error'] + '
');
}
if (json['success']) {
alert(json['success']);
$(node).parent().find('input').val(json['code']);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}, 500);
});