update
This commit is contained in:
764
modules/dpdpoland/js/adminOrder.js
Normal file
764
modules/dpdpoland/js/adminOrder.js
Normal file
@@ -0,0 +1,764 @@
|
||||
/**
|
||||
* 2019 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2019 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
togglePudoMap();
|
||||
|
||||
if (redirect_and_open) {
|
||||
toggleShipmentCreationDisplay();
|
||||
window.location = dpdpoland_pdf_uri + '?printLabels&id_package_ws=' + redirect_and_open + '&printout_format=' + printout_format + '&token=' + encodeURIComponent(dpdpoland_token) +
|
||||
'&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
|
||||
}
|
||||
|
||||
updateParcelsListData();
|
||||
|
||||
$('#dpdpoland_shipment_parcels input[type="text"]').live('keypress', function () {
|
||||
$(this).addClass('modified');
|
||||
$(this).siblings('p.preference_description').slideDown('fast');
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_parcels input[type="text"]').live('on', 'paste', function () {
|
||||
$(this).addClass('modified');
|
||||
$(this).siblings('p.preference_description').slideDown('fast');
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_parcels input[type="text"]').live('on', 'input', function () {
|
||||
$(this).addClass('modified');
|
||||
$(this).siblings('p.preference_description').slideDown('fast');
|
||||
});
|
||||
|
||||
$('#dpdpoland_duty').on('change', function () {
|
||||
if (this.checked)
|
||||
$('#dpdpoland_duty_container').removeClass("hidden");
|
||||
else
|
||||
$('#dpdpoland_duty_container').addClass("hidden");
|
||||
})
|
||||
|
||||
$('#dpdpoland_dpdfood').on('change', function () {
|
||||
if (this.checked)
|
||||
$('#dpdfood_limit_date_container').removeClass("hidden");
|
||||
else
|
||||
$('#dpdfood_limit_date_container').addClass("hidden");
|
||||
})
|
||||
|
||||
$('#dpdpoland_dpdlq').on('change', function () {
|
||||
if (this.checked) {
|
||||
$('.adr-package').removeClass("hidden-element");
|
||||
$('.adr-package input').prop("checked", true)
|
||||
} else {
|
||||
$('.adr-package').addClass("hidden-element");
|
||||
}
|
||||
})
|
||||
|
||||
$('#dpdpoland_recipient_address_selection').live('change', function () {
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_recipient_address_container .dpdpoland_address').fadeOut('fast');
|
||||
|
||||
const id_address = $(this).val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "html",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&getFormattedAddressHTML=true" +
|
||||
"&id_address=" + encodeURIComponent(id_address),
|
||||
success: function (address_html) {
|
||||
$('#ajax_running').slideUp();
|
||||
$('#dpdpoland_recipient_address_container .dpdpoland_address').html(address_html).fadeIn('fast');
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
setDPDSenderAddress();
|
||||
|
||||
$('#sender_address_selection').live('change', function () {
|
||||
setDPDSenderAddress();
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_creation #add_parcel').click(function () {
|
||||
const max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').attr('value');
|
||||
const new_parcel_number = Number(max_parcel_number) + 1;
|
||||
|
||||
const $tr_parcel = $('<tr />');
|
||||
|
||||
const $input_parcel_number = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'parcels[' + new_parcel_number + '][number]'
|
||||
}).val(new_parcel_number);
|
||||
const $td_parcel_number = $('<td />').addClass('center').append(new_parcel_number).append($input_parcel_number);
|
||||
$tr_parcel.append($td_parcel_number);
|
||||
|
||||
const $input_content_hidden = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'parcels[' + new_parcel_number + '][content]'
|
||||
});
|
||||
const $input_content = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '46',
|
||||
'name': 'parcels[' + new_parcel_number + '][content]'
|
||||
});
|
||||
const $td_content = $('<td />').append($input_content_hidden);
|
||||
$td_content.append($input_content);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_content.append($modified_message);
|
||||
$tr_parcel.append($td_content);
|
||||
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
|
||||
const $adrVisibility = $("#dpdpoland_dpdlq").is(':checked') ? '' : 'hidden-element'
|
||||
|
||||
const $input_adr = $('<input />').attr({
|
||||
'type': 'checkbox',
|
||||
'size': '10',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][adr]',
|
||||
'checked': 'true'
|
||||
});
|
||||
const $td_adr = $('<td />').attr({
|
||||
'class': 'adr-package ' + $adrVisibility,
|
||||
}).append($input_adr);
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_adr.append($modified_message);
|
||||
$tr_parcel.append($td_adr);
|
||||
|
||||
const $input_weight_adr = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][weight_adr]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
const $td_weight_adr = $('<td />').attr({
|
||||
'class': 'adr-package ' + $adrVisibility,
|
||||
}).append($input_weight_adr);
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_weight_adr.append($modified_message);
|
||||
$tr_parcel.append($td_weight_adr);
|
||||
|
||||
const $input_weight = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'name': 'parcels[' + new_parcel_number + '][weight]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
const $td_weight = $('<td />').append($input_weight);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_weight.append($modified_message);
|
||||
$tr_parcel.append($td_weight);
|
||||
|
||||
const $input_height = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'name': 'parcels[' + new_parcel_number + '][height]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
const $td_height = $('<td />').append($input_height);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_height.append($modified_message);
|
||||
$tr_parcel.append($td_height);
|
||||
|
||||
const $input_length = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'name': 'parcels[' + new_parcel_number + '][length]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
const $td_length = $('<td />').append($input_length);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_length.append($modified_message);
|
||||
$tr_parcel.append($td_length);
|
||||
|
||||
const $input_width = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'name': 'parcels[' + new_parcel_number + '][width]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
const $td_width = $('<td />').append($input_width);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_width.append($modified_message);
|
||||
$tr_parcel.append($td_width);
|
||||
|
||||
$('<td />').addClass('parcel_dimension_weight').text('0.000').appendTo($tr_parcel);
|
||||
|
||||
const $td_delete_parcel = $('<td><img src="../img/admin/delete.gif" class="delete_parcel"></td>');
|
||||
$tr_parcel.append($td_delete_parcel);
|
||||
|
||||
$('#dpdpoland_shipment_parcels tbody tr:last').after($tr_parcel);
|
||||
|
||||
const $new_parcel_option = $('<option />').val(new_parcel_number).text(new_parcel_number);
|
||||
$('#dpdpoland_shipment_products').find('select.parcel_selection').append($new_parcel_option);
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_parcels .delete_parcel').live('click', function () {
|
||||
const $tr_parcel = $(this).parent().parent();
|
||||
|
||||
const deleted_parcel_number = $tr_parcel.find('input[name$="[number]"]').attr('value');
|
||||
const max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').val();
|
||||
|
||||
$('#dpdpoland_shipment_products select.parcel_selection option[value="' + deleted_parcel_number + '"]').remove();
|
||||
|
||||
/* deleting parcel from the middle of list */
|
||||
if (deleted_parcel_number !== max_parcel_number)
|
||||
recalculateParcels(deleted_parcel_number);
|
||||
|
||||
$tr_parcel.remove();
|
||||
});
|
||||
|
||||
$("#dpdpoland_select_product").autocomplete(dpdpoland_ajax_uri,
|
||||
{
|
||||
minChars: 3,
|
||||
max: 10,
|
||||
width: 500,
|
||||
selectFirst: false,
|
||||
scroll: false,
|
||||
dataType: "json",
|
||||
highlightItem: true,
|
||||
formatItem: function (data, i, max, value, term) {
|
||||
return value;
|
||||
},
|
||||
parse: function (data) {
|
||||
const products = [];
|
||||
if (typeof (data.products) != 'undefined')
|
||||
for (let i = 0; i < data.products.length; i++)
|
||||
products[i] = {data: data.products[i], value: data.products[i].name};
|
||||
return products;
|
||||
},
|
||||
extraParams: {
|
||||
ajax: true,
|
||||
token: dpdpoland_token,
|
||||
getProducts: 'true',
|
||||
id_lang: dpdpoland_id_lang,
|
||||
id_shop: dpdpoland_id_shop
|
||||
}
|
||||
}
|
||||
)
|
||||
.result(function (event, data, formatted) {
|
||||
$(this).val(formatted);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value', data.id_product);
|
||||
|
||||
if (!data.id_product_attribute) {
|
||||
data.id_product_attribute = 0;
|
||||
}
|
||||
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value', data.id_product_attribute);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value', data.weight_numeric);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value', data.parcel_content);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value', data.weight);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value', data.name);
|
||||
});
|
||||
|
||||
$('#dpdpoland_add_product').live('click', function () {
|
||||
const id_product = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value');
|
||||
|
||||
if (Number(id_product)) {
|
||||
const id_product_attribute = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value');
|
||||
const weight_numeric = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value');
|
||||
const parcel_content = $('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value');
|
||||
const weight = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value');
|
||||
const product_name = $('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value');
|
||||
|
||||
const $tr_product = $('<tr />');
|
||||
|
||||
const new_product_index = $('#dpdpoland_shipment_products tbody tr').length;
|
||||
|
||||
const $input_id_product = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'dpdpoland_products[' + new_product_index + '][id_product]',
|
||||
'value': id_product
|
||||
});
|
||||
const $input_id_product_attribute = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'dpdpoland_products[' + new_product_index + '][id_product_attribute]',
|
||||
'value': id_product_attribute
|
||||
});
|
||||
const $td_parcel_reference = $('<td />').addClass('parcel_reference').append($input_id_product, $input_id_product_attribute, parcel_content);
|
||||
$td_parcel_reference.appendTo($tr_product);
|
||||
|
||||
const $input_weight_hidden = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'parcel_weight',
|
||||
'value': weight_numeric
|
||||
});
|
||||
$('<td />').addClass('product_name').text(product_name).appendTo($tr_product);
|
||||
$('<td />').addClass('parcel_weight').append($input_weight_hidden, weight).appendTo($tr_product);
|
||||
|
||||
const $parcels_selection = $('#dpdpoland_shipment_products select.parcel_selection:first').clone();
|
||||
$parcels_selection.attr('name', 'dpdpoland_products[' + new_product_index + '][parcel]').find('option:first').attr('selected', 'selected');
|
||||
$('<td />').append($parcels_selection).appendTo($tr_product);
|
||||
|
||||
|
||||
const $td_delete_product = $('<td />');
|
||||
const $img_delete_parcel = $('<img />').attr({'src': '../img/admin/delete.gif'}).addClass('delete_product').appendTo($td_delete_product);
|
||||
$tr_product.append($td_delete_product);
|
||||
|
||||
$('#dpdpoland_shipment_products tbody tr:last').after($tr_product);
|
||||
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value', 0);
|
||||
$('#dpdpoland_select_product').attr('value', '');
|
||||
}
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_products .delete_product').live('click', function () {
|
||||
$(this).parents('tr:first').remove();
|
||||
});
|
||||
|
||||
$('#save_and_print_labels').click(function () {
|
||||
let available = true;
|
||||
$('#dpdpoland_shipment_products .parcel_selection').each(function () {
|
||||
if ($(this).val() === '' || $(this).val() === 0) {
|
||||
available = false;
|
||||
alert(dpdpoland_parcels_error_message);
|
||||
}
|
||||
});
|
||||
|
||||
if (!available)
|
||||
return false;
|
||||
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_msg_container').slideUp().html('');
|
||||
|
||||
const pudo_code = $('#dpdpoland_pudo_code_input').val();
|
||||
let pudo_data = "";
|
||||
if (pudo_code.length > 0) {
|
||||
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_order=" + encodeURIComponent(id_order) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
|
||||
"&savePackagePrintLabels=true&" + $('#dpdpoland :input').serialize() +
|
||||
pudo_data,
|
||||
success: function (resp) {
|
||||
if (resp.error) {
|
||||
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
|
||||
$.scrollTo('#dpdpoland', 400, {offset: {top: -100}});
|
||||
} else {
|
||||
id_package_ws = resp.id_package_ws;
|
||||
window.location = dpdpoland_pdf_uri + resp.link_to_labels_pdf + '&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
|
||||
}
|
||||
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#save_labels').click(function () {
|
||||
|
||||
let available = true;
|
||||
$('#dpdpoland_shipment_products .parcel_selection').each(function () {
|
||||
if ($(this).val() === '' || $(this).val() === 0) {
|
||||
available = false;
|
||||
alert(dpdpoland_parcels_error_message);
|
||||
}
|
||||
});
|
||||
|
||||
if (!available)
|
||||
return false;
|
||||
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_msg_container').slideUp().html('');
|
||||
const pudo_code = $('#dpdpoland_pudo_code_input').val();
|
||||
let pudo_data = "";
|
||||
if (pudo_code.length > 0) {
|
||||
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_order=" + encodeURIComponent(id_order) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&sender_address_selection=" + $('#sender_address_selection').val() +
|
||||
"&printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
|
||||
"&savePackagePrintLabels=true&" + $('#dpdpoland :input').serialize() +
|
||||
pudo_data,
|
||||
success: function (resp) {
|
||||
if (resp.error) {
|
||||
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
|
||||
$.scrollTo('#dpdpoland', 400, {offset: {top: -100}});
|
||||
} else {
|
||||
current_order_uri = current_order_uri.replace(/&/g, '&') + '&scrollToShipment';
|
||||
window.location = current_order_uri;
|
||||
}
|
||||
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#print_labels').live('click', function () {
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_msg_container').slideUp().html('');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_order=" + encodeURIComponent(id_order) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&printLabels=true" +
|
||||
"&dpdpoland_printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
|
||||
"&id_package_ws=" + encodeURIComponent(id_package_ws) +
|
||||
"&_PS_ADMIN_DIR_=" + encodeURIComponent(_PS_ADMIN_DIR_),
|
||||
success: function (resp) {
|
||||
if (resp.error) {
|
||||
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
|
||||
} else {
|
||||
window.location = dpdpoland_pdf_uri + resp.link_to_labels_pdf + '&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
|
||||
}
|
||||
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#dpdpoland_shipment_parcels input").live("change keyup paste", function () {
|
||||
const default_value = 0;
|
||||
const $inputs_container = $(this).parents('tr:first');
|
||||
|
||||
const height = $inputs_container.find('input[name$="[height]"]').attr('value');
|
||||
const length = $inputs_container.find('input[name$="[length]"]').attr('value');
|
||||
const width = $inputs_container.find('input[name$="[width]"]').attr('value');
|
||||
|
||||
let dimention_weight = Number(length) * Number(width) * Number(height) / Number(_DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_);
|
||||
if (dimention_weight > 0) {
|
||||
dimention_weight = dimention_weight.toFixed(3);
|
||||
} else {
|
||||
dimention_weight = default_value.toFixed(3);
|
||||
}
|
||||
$inputs_container.find('td.parcel_dimension_weight').text(dimention_weight);
|
||||
});
|
||||
|
||||
const shipment_mode_select = $('select[name="dpdpoland_SessionType"]');
|
||||
|
||||
toggleServiceInputs(shipment_mode_select.val());
|
||||
|
||||
shipment_mode_select.change(function () {
|
||||
togglePudoMap();
|
||||
toggleServiceInputs($(this).val());
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_products select.parcel_selection').live('change', function () {
|
||||
updateParcelsListData();
|
||||
});
|
||||
});
|
||||
|
||||
function toggleServiceInputs(shipment_mode) {
|
||||
const cod_container = $('#dpdpoland_cod_amount_container');
|
||||
const dpd_next_day_container = $('#dpdpoland_dpdnd_container');
|
||||
const dpd_express_container = $('#dpdpoland_dpde_container');
|
||||
|
||||
const dpd_food_container = $('.dpdpoland_dpdfood_container');
|
||||
const dpd_today_container = $('.dpdpoland_dpdtoday_container');
|
||||
const dpd_saturday_container = $('.dpdpoland_dpdsaturday_container');
|
||||
const isCodPaymentMethod = $('#dpdpoland_is_cod_payment_method').val();
|
||||
|
||||
if (shipment_mode === 'domestic_with_cod' || shipment_mode === 'pudo_cod' || isCodPaymentMethod === '1') {
|
||||
cod_container.fadeIn();
|
||||
cod_container.show();
|
||||
} else {
|
||||
cod_container.fadeOut();
|
||||
}
|
||||
|
||||
if (shipment_mode === 'international') {
|
||||
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
|
||||
dpd_next_day_container.hide();
|
||||
dpd_express_container.fadeIn();
|
||||
dpd_food_container.fadeIn();
|
||||
dpd_today_container.fadeIn();
|
||||
dpd_saturday_container.fadeIn();
|
||||
} else if (shipment_mode === 'domestic' || shipment_mode === 'domestic_with_cod') {
|
||||
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
|
||||
dpd_express_container.hide();
|
||||
dpd_next_day_container.fadeIn();
|
||||
dpd_food_container.fadeIn();
|
||||
dpd_today_container.fadeIn();
|
||||
dpd_saturday_container.fadeIn();
|
||||
} else {
|
||||
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
|
||||
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
|
||||
dpd_today_container.find('input#dpdpoland_dpdtoday').prop('checked', false);
|
||||
dpd_saturday_container.find('input#dpdpoland_dpdsaturday').prop('checked', false);
|
||||
dpd_food_container.find('input#dpdpoland_dpdfood').prop('checked', false);
|
||||
dpd_express_container.fadeOut();
|
||||
dpd_next_day_container.fadeOut();
|
||||
dpd_food_container.fadeOut();
|
||||
dpd_today_container.fadeOut();
|
||||
dpd_saturday_container.fadeOut();
|
||||
}
|
||||
|
||||
if ($("#dpdpoland_dpdlq").is(':checked')) {
|
||||
$('.adr-package').removeClass("hidden-element")
|
||||
$('.adr-package input').prop("checked", true)
|
||||
} else {
|
||||
$('.adr-package').addClass("hidden-element")
|
||||
}
|
||||
}
|
||||
|
||||
function updateParcelsListData() {
|
||||
const attr = $('#dpdpoland_shipment_creation select[name="dpdpoland_SessionType"]').attr('disabled');
|
||||
if (typeof attr !== 'undefined' && attr !== false) {
|
||||
return;
|
||||
}
|
||||
|
||||
const default_value = 0;
|
||||
const products_count = $('#dpdpoland_shipment_products .parcel_reference').length;
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(2) input[type="text"]').not('.modified').attr('value', '');
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(4) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(5) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(2) input[type="hidden"]').attr('value', '');
|
||||
|
||||
$('#dpdpoland_shipment_products .parcel_reference').each(function () {
|
||||
let product_weight = $(this).parent().find('td:nth-child(3)').find('input[type="hidden"]').val();
|
||||
product_weight = Number(product_weight);
|
||||
|
||||
let product_id = $(this).find('input[type="hidden"]:nth-child(1)').val();
|
||||
let product_attr_id = $(this).find('input[type="hidden"]:nth-child(2)').val();
|
||||
const product_reference = $(this).find('input[type="hidden"]:nth-child(3)').val()
|
||||
const product_name = $(this).find('input[type="hidden"]:nth-child(4)').val()
|
||||
const productContent = getProductContent(product_id, product_attr_id, product_reference, product_name)
|
||||
|
||||
const parcel_id = $(this).siblings().find('select').val();
|
||||
|
||||
const parcel_description_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(2)').find('input[type="text"]');
|
||||
const parcel_adr_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(3)').find('input[type="text"]');
|
||||
const parcel_weight_adr_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(4)').find('input[type="text"]');
|
||||
const parcel_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(5)').find('input[type="text"]');
|
||||
const parcel_height_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(6)').find('input[type="text"]');
|
||||
const parcel_length_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(7)').find('input[type="text"]');
|
||||
const parcel_width_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(8)').find('input[type="text"]');
|
||||
const parcel_dimension_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(9)');
|
||||
|
||||
const parcel_description_safe = parcel_description_field.siblings('input[type="hidden"]:first');
|
||||
let weights = parcel_weight_field.val();
|
||||
weights = Number(weights);
|
||||
weights = weights + product_weight;
|
||||
|
||||
const description = getProductDescription(parcel_description_safe, productContent)
|
||||
|
||||
if (!parcel_weight_field.hasClass('modified')) {
|
||||
parcel_weight_field.attr('value', weights.toFixed(6));
|
||||
}
|
||||
|
||||
if (!parcel_description_field.hasClass('modified')) {
|
||||
parcel_description_field.attr('value', description);
|
||||
parcel_description_safe.attr('value', description);
|
||||
}
|
||||
|
||||
if (products_count === 1) {
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(6) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(7) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(8) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(9)').not('.modified').text(default_value.toFixed(3));
|
||||
|
||||
parcel_height_field.attr('value', $('#product_height').val());
|
||||
parcel_length_field.attr('value', $('#product_length').val());
|
||||
parcel_width_field.attr('value', $('#product_width').val());
|
||||
|
||||
if (!parcel_height_field.hasClass('modified') &&
|
||||
!parcel_length_field.hasClass('modified') &&
|
||||
!parcel_width_field.hasClass('modified')
|
||||
) {
|
||||
const value = parcel_height_field.val() * parcel_length_field.val() * parcel_width_field.val() / _DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_;
|
||||
parcel_dimension_weight_field.text(value.toFixed(3));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getProductContent(product_id, product_attr_id, product_reference, product_name) {
|
||||
const parcel_content_source = $('input[name="dpdpoland_parcel_content_type"]').val()
|
||||
|
||||
switch (parcel_content_source) {
|
||||
case "PARCEL_CONTENT_SOURCE_SKU":
|
||||
return product_reference
|
||||
case "PARCEL_CONTENT_SOURCE_PRODUCT_ID":
|
||||
return product_id + "_" + product_attr_id
|
||||
case "PARCEL_CONTENT_SOURCE_PRODUCT_NAME":
|
||||
return product_name
|
||||
}
|
||||
return product_id + "_" + product_attr_id;
|
||||
}
|
||||
|
||||
function getProductDescription(parcel_description_safe, newContent) {
|
||||
const current_value = parcel_description_safe.attr('value')
|
||||
if (!current_value || current_value === '' || current_value.indexOf(newContent) >= 0)
|
||||
if (current_value === null || current_value === undefined || current_value === '')
|
||||
return newContent;
|
||||
|
||||
if(current_value.indexOf(newContent) >= 0)
|
||||
return current_value;
|
||||
|
||||
return current_value + ', ' + newContent;
|
||||
}
|
||||
|
||||
function displayErrorInShipmentArea(errorText) {
|
||||
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + errorTextr + '</p>').slideDown();
|
||||
}
|
||||
|
||||
function recalculateParcels(deleted_parcel_number) {
|
||||
$('#dpdpoland_shipment_parcels input[name$="[number]"]').each(function () {
|
||||
const parcel_number = Number($(this).attr('value'));
|
||||
|
||||
if (parcel_number > deleted_parcel_number) {
|
||||
const updated_parcel_number = parcel_number - 1;
|
||||
const $input = $(this).attr('value', updated_parcel_number);
|
||||
$(this).parent().text(updated_parcel_number).append($input);
|
||||
$(this).parent().parent().find('input[name^="parcels"]').each(function () {
|
||||
$(this).attr('name', $(this).attr('name').replace(parcel_number, updated_parcel_number));
|
||||
});
|
||||
$('#dpdpoland_shipment_products select.parcel_selection option[value="' + parcel_number + '"]').attr('value', updated_parcel_number).text(updated_parcel_number);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleShipmentCreationDisplay() {
|
||||
const $display_cont = $('#dpdpoland_shipment_creation');
|
||||
const $legend = $display_cont.siblings('legend').find('a');
|
||||
const fieldset_title_substitution = $legend.attr('rel');
|
||||
const current_fieldset_title = $legend.text();
|
||||
const $dpd_fieldset = $('fieldset#dpdpoland');
|
||||
|
||||
if ($dpd_fieldset.hasClass('extended')) {
|
||||
$display_cont.slideToggle(function () {
|
||||
$dpd_fieldset.removeClass('extended');
|
||||
});
|
||||
} else {
|
||||
$dpd_fieldset.addClass('extended');
|
||||
$display_cont.slideToggle();
|
||||
}
|
||||
|
||||
$legend.attr('rel', current_fieldset_title).text(fieldset_title_substitution);
|
||||
}
|
||||
|
||||
const animation_speed = 'fast';
|
||||
|
||||
function togglePudoMap() {
|
||||
const selected_carrier = $('select[name="dpdpoland_SessionType"] option:selected').val();
|
||||
|
||||
if (typeof selected_carrier == 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selected_carrier === 'pudo' || selected_carrier === 'pudo_cod' || selected_carrier === 'swipbox') {
|
||||
$('.pudo-map-container').slideDown(animation_speed);
|
||||
} else {
|
||||
$('.pudo-map-container').slideUp(animation_speed);
|
||||
}
|
||||
}
|
||||
|
||||
function setDPDSenderAddress() {
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_sender_address_container .dpdpoland_address').fadeOut('fast');
|
||||
|
||||
const id_address = $('#sender_address_selection').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "html",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&getFormattedSenderAddressHTML=true" +
|
||||
"&id_address=" + encodeURIComponent(id_address),
|
||||
success: function (address_html) {
|
||||
$('#ajax_running').slideUp();
|
||||
$('#dpdpoland_sender_address_container .dpdpoland_address').html(address_html).fadeIn('fast');
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function savePickupPointAddress(id_point) {
|
||||
const block = $('.js-result[data-point-id="' + id_point + '"]');
|
||||
|
||||
console.log(block.text());
|
||||
}
|
||||
738
modules/dpdpoland/js/adminOrder_1.7.js
Normal file
738
modules/dpdpoland/js/adminOrder_1.7.js
Normal file
@@ -0,0 +1,738 @@
|
||||
/**
|
||||
* 2019 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2019 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
togglePudoMap();
|
||||
|
||||
if (redirect_and_open) {
|
||||
toggleShipmentCreationDisplay();
|
||||
window.location = dpdpoland_pdf_uri + '?printLabels&id_package_ws=' + redirect_and_open + '&printout_format=' + printout_format + '&token=' + encodeURIComponent(dpdpoland_token) +
|
||||
'&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
|
||||
}
|
||||
|
||||
updateParcelsListData();
|
||||
|
||||
$('#dpdpoland_shipment_parcels').on('keypress', function () {
|
||||
$(this).addClass('modified');
|
||||
$(this).siblings('p.preference_description').slideDown('fast');
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_parcels').on('paste', 'input[type="text"]', function () {
|
||||
$(this).addClass('modified');
|
||||
$(this).siblings('p.preference_description').slideDown('fast');
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_parcels').on('input', 'input[type="text"]', function () {
|
||||
$(this).addClass('modified');
|
||||
$(this).siblings('p.preference_description').slideDown('fast');
|
||||
});
|
||||
|
||||
$('#dpdpoland_duty').on('change', function () {
|
||||
if (this.checked)
|
||||
$('#dpdpoland_duty_container').removeClass("d-none");
|
||||
else
|
||||
$('#dpdpoland_duty_container').addClass("d-none");
|
||||
})
|
||||
|
||||
|
||||
$('#dpdpoland_dpdfood').on('change', function () {
|
||||
if (this.checked)
|
||||
$('#dpdfood_limit_date_container').removeClass("d-none");
|
||||
else
|
||||
$('#dpdfood_limit_date_container').addClass("d-none");
|
||||
})
|
||||
|
||||
$('#dpdpoland_dpdlq').on('change', function () {
|
||||
if (this.checked) {
|
||||
$('.adr-package').removeClass("d-none");
|
||||
$('.adr-package input').prop("checked", true)
|
||||
} else {
|
||||
$('.adr-package').addClass("d-none");
|
||||
}
|
||||
})
|
||||
|
||||
$('#dpdpoland_recipient_address_selection').on('change', function () {
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_recipient_address_container .dpdpoland_address').fadeOut('fast');
|
||||
|
||||
const id_address = $(this).val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "html",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&getFormattedAddressHTML=true" +
|
||||
"&id_address=" + encodeURIComponent(id_address),
|
||||
success: function (address_html) {
|
||||
$('#ajax_running').slideUp();
|
||||
$('#dpdpoland_recipient_address_container .dpdpoland_address').html(address_html).fadeIn('fast');
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
setDPDSenderAddress();
|
||||
|
||||
$('#sender_address_selection').on('change', function () {
|
||||
setDPDSenderAddress();
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_creation #add_parcel').on('click', function () {
|
||||
const max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').attr('value');
|
||||
const new_parcel_number = Number(max_parcel_number) + 1;
|
||||
|
||||
const $tr_parcel = $('<tr />');
|
||||
|
||||
const $input_parcel_number = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'parcels[' + new_parcel_number + '][number]'
|
||||
}).val(new_parcel_number);
|
||||
const $td_parcel_number = $('<td />').addClass('center').append(new_parcel_number).append($input_parcel_number);
|
||||
$tr_parcel.append($td_parcel_number);
|
||||
|
||||
const $input_content_hidden = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'parcels[' + new_parcel_number + '][content]'
|
||||
});
|
||||
const $input_content = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '46',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][content]'
|
||||
});
|
||||
const $td_content = $('<td />').append($input_content_hidden);
|
||||
$td_content.append($input_content);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_content.append($modified_message);
|
||||
$tr_parcel.append($td_content);
|
||||
|
||||
const $adrVisibility = $("#dpdpoland_dpdlq").is(':checked') ? '' : 'd-none'
|
||||
|
||||
const $input_adr = $('<input />').attr({
|
||||
'type': 'checkbox',
|
||||
'size': '10',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][adr]',
|
||||
'checked': 'true'
|
||||
});
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
const $td_adr = $('<td />').attr({
|
||||
'class': 'adr-package ' + $adrVisibility,
|
||||
}).append($input_adr);
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_adr.append($modified_message);
|
||||
$tr_parcel.append($td_adr);
|
||||
|
||||
const $input_weight_adr = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][weight_adr]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
const $td_weight_adr = $('<td />').attr({
|
||||
'class': 'adr-package ' + $adrVisibility,
|
||||
}).append($input_weight_adr);
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_weight_adr.append($modified_message);
|
||||
$tr_parcel.append($td_weight_adr);
|
||||
|
||||
|
||||
const $input_weight = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][weight]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
const $td_weight = $('<td />').append($input_weight);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_weight.append($modified_message);
|
||||
$tr_parcel.append($td_weight);
|
||||
|
||||
const $input_height = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][height]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
const $td_height = $('<td />').append($input_height);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_height.append($modified_message);
|
||||
$tr_parcel.append($td_height);
|
||||
|
||||
const $input_length = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][length]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
const $td_length = $('<td />').append($input_length);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_length.append($modified_message);
|
||||
$tr_parcel.append($td_length);
|
||||
|
||||
const $input_width = $('<input />').attr({
|
||||
'type': 'text',
|
||||
'size': '10',
|
||||
'class': 'form-control',
|
||||
'name': 'parcels[' + new_parcel_number + '][width]',
|
||||
'value': '0.000000'
|
||||
});
|
||||
const $td_width = $('<td />').append($input_width);
|
||||
var $modified_message = $('<p />').attr({
|
||||
'class': 'preference_description clear',
|
||||
'style': 'display: none; width: auto;'
|
||||
});
|
||||
$modified_message.append(modified_field_message);
|
||||
$td_width.append($modified_message);
|
||||
$tr_parcel.append($td_width);
|
||||
|
||||
$('<td />').addClass('parcel_dimension_weight').text('0.000').appendTo($tr_parcel);
|
||||
|
||||
const $td_delete_parcel = $('<td />');
|
||||
const $delete_btn = $('<input />').attr({
|
||||
'type': 'button',
|
||||
'size': '10',
|
||||
'value': 'X'
|
||||
});
|
||||
|
||||
$delete_btn.addClass('delete_parcel').appendTo($td_delete_parcel);
|
||||
$tr_parcel.append($td_delete_parcel);
|
||||
|
||||
$('#dpdpoland_shipment_parcels tbody tr:last').after($tr_parcel);
|
||||
|
||||
const $new_parcel_option = $('<option />').val(new_parcel_number).text(new_parcel_number);
|
||||
$('#dpdpoland_shipment_products').find('select.parcel_selection').append($new_parcel_option);
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_parcels').on('click', '.delete_parcel', function () {
|
||||
const $tr_parcel = $(this).parent().parent();
|
||||
|
||||
const deleted_parcel_number = $tr_parcel.find('input[name$="[number]"]').attr('value');
|
||||
const max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').val();
|
||||
|
||||
$('#dpdpoland_shipment_products select.parcel_selection option[value="' + deleted_parcel_number + '"]').remove();
|
||||
|
||||
/* deleting parcel from the middle of list */
|
||||
if (deleted_parcel_number != max_parcel_number)
|
||||
recalculateParcels(deleted_parcel_number);
|
||||
|
||||
$tr_parcel.remove();
|
||||
});
|
||||
|
||||
$('#dpdpoland_add_product').on('click', function () {
|
||||
const id_product = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value');
|
||||
|
||||
if (Number(id_product)) {
|
||||
const id_product_attribute = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value');
|
||||
const weight_numeric = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value');
|
||||
const parcel_content = $('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value');
|
||||
const weight = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value');
|
||||
const product_name = $('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value');
|
||||
|
||||
const $tr_product = $('<tr />');
|
||||
|
||||
const new_product_index = $('#dpdpoland_shipment_products tbody tr').length;
|
||||
|
||||
const $input_id_product = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'dpdpoland_products[' + new_product_index + '][id_product]',
|
||||
'value': id_product
|
||||
});
|
||||
const $input_id_product_attribute = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'dpdpoland_products[' + new_product_index + '][id_product_attribute]',
|
||||
'value': id_product_attribute
|
||||
});
|
||||
const $td_parcel_reference = $('<td />').addClass('parcel_reference').append($input_id_product, $input_id_product_attribute, parcel_content);
|
||||
$td_parcel_reference.appendTo($tr_product);
|
||||
|
||||
const $input_weight_hidden = $('<input />').attr({
|
||||
'type': 'hidden',
|
||||
'name': 'parcel_weight',
|
||||
'value': weight_numeric
|
||||
});
|
||||
$('<td />').addClass('product_name').text(product_name).appendTo($tr_product);
|
||||
$('<td />').addClass('parcel_weight').append($input_weight_hidden, weight).appendTo($tr_product);
|
||||
|
||||
const $parcels_selection = $('#dpdpoland_shipment_products select.parcel_selection:first').clone();
|
||||
$parcels_selection.attr('name', 'dpdpoland_products[' + new_product_index + '][parcel]').find('option:first').attr('selected', 'selected');
|
||||
$('<td />').append($parcels_selection).appendTo($tr_product);
|
||||
|
||||
const $td_delete_product = $('<td />');
|
||||
const $img_delete_parcel = $('<p />').attr({'src': '../img/admin/delete.gif'}).addClass('delete_product').appendTo($td_delete_product);
|
||||
$tr_product.append($td_delete_product);
|
||||
|
||||
$('#dpdpoland_shipment_products tbody tr:last').after($tr_product);
|
||||
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value', 0);
|
||||
$('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value', 0);
|
||||
$('#dpdpoland_select_product').attr('value', '');
|
||||
}
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_products').on('click', '.delete_product', function () {
|
||||
$(this).parents('tr:first').remove();
|
||||
});
|
||||
|
||||
$('#save_and_print_labels').click(function () {
|
||||
|
||||
let available = true;
|
||||
$('#dpdpoland_shipment_products .parcel_selection').each(function () {
|
||||
if ($(this).val() == '' || $(this).val() == 0) {
|
||||
available = false;
|
||||
alert(dpdpoland_parcels_error_message);
|
||||
}
|
||||
});
|
||||
|
||||
if (!available)
|
||||
return false;
|
||||
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_msg_container').slideUp().html('');
|
||||
|
||||
const pudo_code = $('#dpdpoland_pudo_code_input').val();
|
||||
let pudo_data = "";
|
||||
if (pudo_code.length > 0) {
|
||||
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_order=" + encodeURIComponent(id_order) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
|
||||
"&savePackagePrintLabels=true&" + $('#dpdpoland :input').serialize() +
|
||||
pudo_data,
|
||||
success: function (resp) {
|
||||
if (resp.error) {
|
||||
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
|
||||
$([document.documentElement, document.body]).animate({
|
||||
scrollTop: $("#dpdpoland").offset().top - 150
|
||||
}, 400);
|
||||
} else {
|
||||
id_package_ws = resp.id_package_ws;
|
||||
window.location = dpdpoland_pdf_uri + resp.link_to_labels_pdf + '&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
|
||||
}
|
||||
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#save_labels').click(function () {
|
||||
|
||||
let available = true;
|
||||
$('#dpdpoland_shipment_products .parcel_selection').each(function () {
|
||||
if ($(this).val() == '' || $(this).val() == 0) {
|
||||
available = false;
|
||||
alert(dpdpoland_parcels_error_message);
|
||||
}
|
||||
});
|
||||
|
||||
if (!available)
|
||||
return false;
|
||||
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_msg_container').slideUp().html('');
|
||||
const pudo_code = $('#dpdpoland_pudo_code_input').val();
|
||||
let pudo_data = "";
|
||||
if (pudo_code.length > 0) {
|
||||
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_order=" + encodeURIComponent(id_order) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&sender_address_selection=" + $('#sender_address_selection').val() +
|
||||
"&printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
|
||||
"&savePackagePrintLabels=true&" + $('#dpdpoland :input').serialize() +
|
||||
pudo_data,
|
||||
success: function (resp) {
|
||||
if (resp.error) {
|
||||
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
|
||||
$([document.documentElement, document.body]).animate({
|
||||
scrollTop: $("#dpdpoland").offset().top - 150
|
||||
}, 400);
|
||||
} else {
|
||||
current_order_uri = current_order_uri.replace(/&/g, '&') + '&scrollToShipment';
|
||||
window.location = current_order_uri;
|
||||
}
|
||||
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#print_labels').on('click', function () {
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_msg_container').slideUp().html('');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_order=" + encodeURIComponent(id_order) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&printLabels=true" +
|
||||
"&dpdpoland_printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
|
||||
"&id_package_ws=" + encodeURIComponent(id_package_ws) +
|
||||
"&_PS_ADMIN_DIR_=" + encodeURIComponent(_PS_ADMIN_DIR_),
|
||||
success: function (resp) {
|
||||
if (resp.error) {
|
||||
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
|
||||
} else {
|
||||
window.location = dpdpoland_pdf_uri + resp.link_to_labels_pdf + '&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
|
||||
}
|
||||
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#dpdpoland_shipment_parcels input").on("change keyup paste", function () {
|
||||
const default_value = 0;
|
||||
const $inputs_container = $(this).parents('tr:first');
|
||||
|
||||
const height = $inputs_container.find('input[name$="[height]"]').attr('value');
|
||||
const length = $inputs_container.find('input[name$="[length]"]').attr('value');
|
||||
const width = $inputs_container.find('input[name$="[width]"]').attr('value');
|
||||
|
||||
let dimention_weight = Number(length) * Number(width) * Number(height) / Number(_DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_);
|
||||
if (dimention_weight > 0) {
|
||||
dimention_weight = dimention_weight.toFixed(3);
|
||||
} else {
|
||||
dimention_weight = default_value.toFixed(3);
|
||||
}
|
||||
$inputs_container.find('td.parcel_dimension_weight').text(dimention_weight);
|
||||
});
|
||||
|
||||
const shipment_mode_select = $('select[name="dpdpoland_SessionType"]');
|
||||
|
||||
toggleServiceInputs(shipment_mode_select.val());
|
||||
|
||||
shipment_mode_select.change(function () {
|
||||
togglePudoMap();
|
||||
toggleServiceInputs($(this).val());
|
||||
});
|
||||
|
||||
$('#dpdpoland_shipment_products select.parcel_selection').on('change', function () {
|
||||
updateParcelsListData();
|
||||
});
|
||||
});
|
||||
|
||||
function toggleServiceInputs(shipment_mode) {
|
||||
const cod_container = $('#dpdpoland_cod_amount_container');
|
||||
const dpd_next_day_container = $('#dpdpoland_dpdnd_container');
|
||||
const dpd_express_container = $('#dpdpoland_dpde_container');
|
||||
|
||||
const dpd_food_container = $('.dpdpoland_dpdfood_container');
|
||||
const dpd_today_container = $('.dpdpoland_dpdtoday_container');
|
||||
const dpd_saturday_container = $('.dpdpoland_dpdsaturday_container');
|
||||
const isCodPaymentMethod = $('#dpdpoland_is_cod_payment_method').val();
|
||||
|
||||
if (shipment_mode === 'domestic_with_cod' || shipment_mode === 'pudo_cod' || isCodPaymentMethod === '1') {
|
||||
cod_container.fadeIn();
|
||||
cod_container.show();
|
||||
} else {
|
||||
cod_container.fadeOut();
|
||||
}
|
||||
|
||||
if (shipment_mode === 'international') {
|
||||
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
|
||||
dpd_next_day_container.hide();
|
||||
dpd_express_container.fadeIn();
|
||||
dpd_food_container.fadeIn();
|
||||
dpd_today_container.fadeIn();
|
||||
dpd_saturday_container.fadeIn();
|
||||
} else if (shipment_mode === 'domestic' || shipment_mode === 'domestic_with_cod') {
|
||||
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
|
||||
dpd_express_container.hide();
|
||||
dpd_next_day_container.fadeIn();
|
||||
dpd_food_container.fadeIn();
|
||||
dpd_today_container.fadeIn();
|
||||
dpd_saturday_container.fadeIn();
|
||||
} else {
|
||||
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
|
||||
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
|
||||
dpd_today_container.find('input#dpdpoland_dpdtoday').prop('checked', false);
|
||||
dpd_saturday_container.find('input#dpdpoland_dpdsaturday').prop('checked', false);
|
||||
dpd_food_container.find('input#dpdpoland_dpdfood').prop('checked', false);
|
||||
dpd_express_container.fadeOut();
|
||||
dpd_next_day_container.fadeOut();
|
||||
dpd_food_container.fadeOut();
|
||||
dpd_today_container.fadeOut();
|
||||
dpd_saturday_container.fadeOut();
|
||||
}
|
||||
|
||||
if ($("#dpdpoland_dpdlq").is(':checked')) {
|
||||
$('.adr-package').removeClass("d-none")
|
||||
$('.adr-package input').prop("checked", true)
|
||||
} else {
|
||||
$('.adr-package').addClass("d-none")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateParcelsListData() {
|
||||
const attr = $('#dpdpoland_shipment_creation select[name="dpdpoland_SessionType"]').attr('disabled');
|
||||
if (typeof attr !== 'undefined' && attr !== false) {
|
||||
return;
|
||||
}
|
||||
|
||||
const default_value = 0;
|
||||
const products_count = $('#dpdpoland_shipment_products .parcel_reference').length;
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(2) input[type="text"]').not('.modified').attr('value', '');
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(4) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(5) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(2) input[type="hidden"]').attr('value', '');
|
||||
|
||||
$('#dpdpoland_shipment_products .parcel_reference').each(function () {
|
||||
let product_weight = $(this).parent().find('td:nth-child(3)').find('input[type="hidden"]').val();
|
||||
product_weight = Number(product_weight);
|
||||
|
||||
let product_id = $(this).find('input[type="hidden"]:nth-child(1)').val();
|
||||
let product_attr_id = $(this).find('input[type="hidden"]:nth-child(2)').val();
|
||||
const product_reference = $(this).find('input[type="hidden"]:nth-child(3)').val()
|
||||
const product_name = $(this).find('input[type="hidden"]:nth-child(4)').val()
|
||||
const productContent = getProductContent(product_id, product_attr_id, product_reference, product_name)
|
||||
|
||||
const parcel_id = $(this).siblings().find('select').val();
|
||||
|
||||
const parcel_description_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(2)').find('input[type="text"]');
|
||||
const parcel_adr_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(3)').find('input[type="text"]');
|
||||
const parcel_weight_adr_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(4)').find('input[type="text"]');
|
||||
const parcel_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(5)').find('input[type="text"]');
|
||||
const parcel_height_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(6)').find('input[type="text"]');
|
||||
const parcel_length_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(7)').find('input[type="text"]');
|
||||
const parcel_width_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(8)').find('input[type="text"]');
|
||||
const parcel_dimension_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(9)');
|
||||
|
||||
const parcel_description_safe = parcel_description_field.siblings('input[type="hidden"]:first');
|
||||
let weights = parcel_weight_field.val();
|
||||
weights = Number(weights);
|
||||
weights = weights + product_weight;
|
||||
|
||||
const description = getProductDescription(parcel_description_safe, productContent)
|
||||
|
||||
if (!parcel_weight_field.hasClass('modified')) {
|
||||
parcel_weight_field.attr('value', weights.toFixed(6));
|
||||
}
|
||||
|
||||
if (!parcel_description_field.hasClass('modified')) {
|
||||
parcel_description_field.attr('value', description);
|
||||
parcel_description_safe.attr('value', description);
|
||||
}
|
||||
|
||||
if (products_count === 1) {
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(6) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(7) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(8) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
|
||||
$('#dpdpoland_shipment_parcels td:nth-child(9)').not('.modified').text(default_value.toFixed(3));
|
||||
|
||||
parcel_height_field.attr('value', $('#product_height').val());
|
||||
parcel_length_field.attr('value', $('#product_length').val());
|
||||
parcel_width_field.attr('value', $('#product_width').val());
|
||||
|
||||
if (!parcel_height_field.hasClass('modified') &&
|
||||
!parcel_length_field.hasClass('modified') &&
|
||||
!parcel_width_field.hasClass('modified')
|
||||
) {
|
||||
const value = parcel_height_field.val() * parcel_length_field.val() * parcel_width_field.val() / _DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_;
|
||||
parcel_dimension_weight_field.text(value.toFixed(3));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getProductContent(product_id, product_attr_id, product_reference, product_name) {
|
||||
const parcel_content_source = $('input[name="dpdpoland_parcel_content_type"]').val()
|
||||
|
||||
switch (parcel_content_source) {
|
||||
case "PARCEL_CONTENT_SOURCE_SKU":
|
||||
return product_reference
|
||||
case "PARCEL_CONTENT_SOURCE_PRODUCT_ID":
|
||||
return product_id + "_" + product_attr_id
|
||||
case "PARCEL_CONTENT_SOURCE_PRODUCT_NAME":
|
||||
return product_name
|
||||
}
|
||||
return product_id + "_" + product_attr_id;
|
||||
}
|
||||
|
||||
function getProductDescription(parcel_description_safe, newContent) {
|
||||
const current_value = parcel_description_safe.attr('value')
|
||||
if (current_value === null || current_value === undefined || current_value === '')
|
||||
return newContent;
|
||||
|
||||
if(current_value.indexOf(newContent) >= 0)
|
||||
return current_value;
|
||||
|
||||
return current_value + ', ' + newContent;
|
||||
}
|
||||
|
||||
function displayErrorInShipmentArea(errorText) {
|
||||
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + errorTextr + '</p>').slideDown();
|
||||
}
|
||||
|
||||
function recalculateParcels(deleted_parcel_number) {
|
||||
$('#dpdpoland_shipment_parcels input[name$="[number]"]').each(function () {
|
||||
const parcel_number = Number($(this).attr('value'));
|
||||
|
||||
if (parcel_number > deleted_parcel_number) {
|
||||
const updated_parcel_number = parcel_number - 1;
|
||||
const $input = $(this).attr('value', updated_parcel_number);
|
||||
$(this).parent().text(updated_parcel_number).append($input);
|
||||
$(this).parent().parent().find('input[name^="parcels"]').each(function () {
|
||||
$(this).attr('name', $(this).attr('name').replace(parcel_number, updated_parcel_number));
|
||||
});
|
||||
$('#dpdpoland_shipment_products select.parcel_selection option[value="' + parcel_number + '"]').attr('value', updated_parcel_number).text(updated_parcel_number);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleShipmentCreationDisplay() {
|
||||
const $display_cont = $('#dpdpoland_shipment_creation');
|
||||
const $legend = $display_cont.siblings('legend').find('a');
|
||||
const fieldset_title_substitution = $legend.attr('rel');
|
||||
const current_fieldset_title = $legend.text();
|
||||
const $dpd_fieldset = $('fieldset#dpdpoland');
|
||||
|
||||
if ($dpd_fieldset.hasClass('extended')) {
|
||||
$display_cont.slideToggle(function () {
|
||||
$dpd_fieldset.removeClass('extended');
|
||||
});
|
||||
} else {
|
||||
$dpd_fieldset.addClass('extended');
|
||||
$display_cont.slideToggle();
|
||||
}
|
||||
|
||||
$legend.attr('rel', current_fieldset_title).text(fieldset_title_substitution);
|
||||
}
|
||||
|
||||
const animation_speed = 'fast';
|
||||
|
||||
function togglePudoMap() {
|
||||
const selected_carrier = $('select[name="dpdpoland_SessionType"] option:selected').val();
|
||||
|
||||
if (typeof selected_carrier == 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selected_carrier === 'pudo' || selected_carrier === 'pudo_cod' || selected_carrier === 'swipbox') {
|
||||
$('.pudo-map-container').slideDown(animation_speed);
|
||||
} else {
|
||||
$('.pudo-map-container').slideUp(animation_speed);
|
||||
}
|
||||
}
|
||||
|
||||
function setDPDSenderAddress() {
|
||||
$('#ajax_running').slideDown();
|
||||
$('#dpdpoland_sender_address_container .dpdpoland_address').fadeOut('fast');
|
||||
|
||||
const id_address = $('#sender_address_selection').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "html",
|
||||
global: false,
|
||||
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
|
||||
"&getFormattedSenderAddressHTML=true" +
|
||||
"&id_address=" + encodeURIComponent(id_address),
|
||||
success: function (address_html) {
|
||||
$('#ajax_running').slideUp();
|
||||
$('#dpdpoland_sender_address_container .dpdpoland_address').html(address_html).fadeIn('fast');
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function savePickupPointAddress(id_point) {
|
||||
const block = $('.js-result[data-point-id="' + id_point + '"]');
|
||||
|
||||
console.log(block.text());
|
||||
}
|
||||
51
modules/dpdpoland/js/adminorders.js
Normal file
51
modules/dpdpoland/js/adminorders.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 2019 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2019 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#form-order').on('click', '.bulk-actions a', function(event){
|
||||
event.preventDefault();
|
||||
|
||||
var selector = $(this);
|
||||
|
||||
if (selector.find('i').hasClass('dpd-label')) {
|
||||
var current_url = $('#form-order').attr('action');
|
||||
var new_url = current_url.replace('&submitBulkprint_a4order', '');
|
||||
$('#form-order').attr('action', new_url);
|
||||
$('#form-order').submit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (selector.find('i').hasClass('dpd-a4')) {
|
||||
var current_url = $('#form-order').attr('action');
|
||||
var new_url = current_url.replace('&submitBulkprint_labelorder', '');
|
||||
$('#form-order').attr('action', new_url);
|
||||
$('#form-order').submit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var current_url = $('#form-order').attr('action');
|
||||
var new_url = current_url.replace('&submitBulkprint_labelorder', '');
|
||||
new_url = new_url.replace('&submitBulkprint_a4order', '');
|
||||
$('#form-order').attr('action', new_url);
|
||||
|
||||
return true;
|
||||
});
|
||||
});
|
||||
312
modules/dpdpoland/js/backoffice.js
Normal file
312
modules/dpdpoland/js/backoffice.js
Normal file
@@ -0,0 +1,312 @@
|
||||
/**
|
||||
* 2019 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2019 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#addClientNumber').click(function () {
|
||||
addClientNumber();
|
||||
});
|
||||
|
||||
$('#dpd_swipbox').change(function () {
|
||||
enableDisableZones();
|
||||
});
|
||||
|
||||
$('#dpd_standard_cod').change(function () {
|
||||
enableDisableZones();
|
||||
});
|
||||
|
||||
$('#dpd_standard').change(function () {
|
||||
enableDisableZones();
|
||||
});
|
||||
|
||||
$('#dpd_classic').change(function () {
|
||||
enableDisableZones();
|
||||
});
|
||||
|
||||
$('#dpd_pudo').change(function () {
|
||||
enableDisableZones();
|
||||
});
|
||||
|
||||
$('#dpd_pudo_cod').change(function () {
|
||||
enableDisableZones();
|
||||
});
|
||||
|
||||
$('select[name="pickupTime"]').live('change', function () {
|
||||
calculateTimeLeftForArrangePickup();
|
||||
});
|
||||
|
||||
$('#pickupDate').live("change keyup paste", function () {
|
||||
getTimeFramesByDate();
|
||||
});
|
||||
|
||||
$('#sender_address_selection').live("change", function () {
|
||||
getTimeFramesByDate();
|
||||
});
|
||||
|
||||
$('input[name="downloadModuleCSVSettings"]').click(function () {
|
||||
window.location = dpdpoland_pdf_uri + "?downloadModuleCSVSettings&token=" + encodeURIComponent(dpdpoland_token);
|
||||
return false;
|
||||
});
|
||||
|
||||
toggleEnvelope();
|
||||
toggleParcel();
|
||||
togglePallet();
|
||||
|
||||
enableDisableZones();
|
||||
|
||||
if ($('#pickup_date').length)
|
||||
getTimeFramesByDate();
|
||||
|
||||
$('#toggleEnvelope').change(function () {
|
||||
toggleEnvelope();
|
||||
});
|
||||
|
||||
$('#toggleParcel').change(function () {
|
||||
toggleParcel();
|
||||
});
|
||||
|
||||
$('#togglePallet').change(function () {
|
||||
togglePallet();
|
||||
});
|
||||
|
||||
toggleAdditionalSettings();
|
||||
|
||||
$('#additional_settings .radio input[type="radio"]').on('change', function () {
|
||||
toggleAdditionalSettings();
|
||||
});
|
||||
|
||||
$('#duty').on('change', function () {
|
||||
if (this.checked)
|
||||
$('#declared_value').prop('checked', true);
|
||||
})
|
||||
});
|
||||
|
||||
function toggleAdditionalSettings() {
|
||||
$('#additional_settings .hidable').slideUp(0);
|
||||
$('#additional_settings input[type="radio"]:checked').closest('.radio').find('.hidable').slideDown(0);
|
||||
}
|
||||
|
||||
function enableDisableZones() {
|
||||
if ($('#dpd_swipbox').is(':checked'))
|
||||
$('.swipbox_zone').removeAttr('disabled');
|
||||
else
|
||||
$('.swipbox_zone').attr('disabled', 'disabled');
|
||||
|
||||
if ($('#dpd_standard').is(':checked'))
|
||||
$('.domestic_zone').removeAttr('disabled');
|
||||
else
|
||||
$('.domestic_zone').attr('disabled', 'disabled');
|
||||
|
||||
if ($('#dpd_standard_cod').is(':checked'))
|
||||
$('.domestic_cod_zone').removeAttr('disabled');
|
||||
else
|
||||
$('.domestic_cod_zone').attr('disabled', 'disabled');
|
||||
|
||||
if ($('#dpd_classic').is(':checked'))
|
||||
$('.classic_zone').removeAttr('disabled');
|
||||
else
|
||||
$('.classic_zone').attr('disabled', 'disabled');
|
||||
|
||||
if ($('#dpd_pudo').is(':checked'))
|
||||
$('.pudo_zone').removeAttr('disabled');
|
||||
else
|
||||
$('.pudo_zone').attr('disabled', 'disabled');
|
||||
|
||||
|
||||
if ($('#dpd_pudo_cod').is(':checked'))
|
||||
$('.pudo_cod_zone').removeAttr('disabled');
|
||||
else
|
||||
$('.pudo_cod_zone').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
function toggleEnvelope() {
|
||||
if ($('#toggleEnvelope').is(':checked'))
|
||||
$('#envelopes_container').slideDown();
|
||||
else
|
||||
$('#envelopes_container').slideUp();
|
||||
}
|
||||
|
||||
function toggleParcel() {
|
||||
if ($('#toggleParcel').is(':checked'))
|
||||
$('#parcels_container').slideDown();
|
||||
else
|
||||
$('#parcels_container').slideUp();
|
||||
}
|
||||
|
||||
function togglePallet() {
|
||||
if ($('#togglePallet').is(':checked'))
|
||||
$('#pallets_container').slideDown();
|
||||
else
|
||||
$('#pallets_container').slideUp();
|
||||
}
|
||||
|
||||
function getTimeFramesByDate() {
|
||||
$('#ajax_running').slideDown();
|
||||
|
||||
var current_date = $('#pickupDate').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: "getTimeFrames=true&date=" + encodeURIComponent(current_date) +
|
||||
"&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&sender_address_selection=" + $('#sender_address_selection').val() +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
|
||||
success: function (resp) {
|
||||
$('#timeframe_container').html(resp);
|
||||
calculateTimeLeftForArrangePickup();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function calculateTimeLeftForArrangePickup() {
|
||||
if (!$('#ajax_running').is(':visible'))
|
||||
$('#ajax_running').slideDown();
|
||||
|
||||
var current_timeframe = $('select[name="pickupTime"]').val();
|
||||
var current_date = $('#pickupDate').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: "calculateTimeLeft=true&timeframe=" + encodeURIComponent(current_timeframe) +
|
||||
"&date=" + encodeURIComponent(current_date) +
|
||||
"&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
|
||||
success: function (resp) {
|
||||
$('#timeframe_container span.time_left').text(resp);
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addClientNumber() {
|
||||
if (typeof (dpdpoland_16) == 'undefined') {
|
||||
$('#ajax_running').slideDown();
|
||||
}
|
||||
|
||||
$('#error_message').slideUp();
|
||||
$('#success_message').slideUp();
|
||||
|
||||
var ajax_request_params = 'ajax=true&addDPDClientNumber=true';
|
||||
var client_number = $('#client_number').val();
|
||||
var client_name = $('#client_name').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: ajax_request_params +
|
||||
"&client_number=" + encodeURIComponent(client_number) +
|
||||
"&name=" + encodeURIComponent(client_name) +
|
||||
"&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
|
||||
success: function (resp) {
|
||||
if (resp.error) {
|
||||
$('#error_message').html(resp.error).slideDown('fast');
|
||||
} else
|
||||
$('#success_message').html(resp.message).slideDown('fast');
|
||||
|
||||
displayPayerNumbersTable();
|
||||
if (typeof (dpdpoland_16) == 'undefined') {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
if (typeof (dpdpoland_16) == 'undefined') {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteClientNumber(id_client_number) {
|
||||
$('#ajax_running').slideDown();
|
||||
|
||||
$('#error_message').slideUp();
|
||||
$('#success_message').slideUp();
|
||||
|
||||
var ajax_request_params = 'ajax=true&deleteDPDClientNumber=true';
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: ajax_request_params +
|
||||
"&client_number=" + encodeURIComponent(id_client_number) +
|
||||
"&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
|
||||
success: function (resp) {
|
||||
if (resp.error) {
|
||||
$('#error_message').html(resp.error).slideDown('fast');
|
||||
} else
|
||||
$('#success_message').html(resp.message).slideDown('fast');
|
||||
|
||||
displayPayerNumbersTable();
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function displayPayerNumbersTable() {
|
||||
$('#ajax_running').slideDown();
|
||||
|
||||
var ajax_request_params = 'ajax=true&getPayerNumbersTableHTML=true';
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: dpdpoland_ajax_uri,
|
||||
dataType: "json",
|
||||
global: false,
|
||||
data: ajax_request_params +
|
||||
"&token=" + encodeURIComponent(dpdpoland_token) +
|
||||
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
|
||||
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
|
||||
success: function (resp) {
|
||||
$('#client_numbers_table_container').html(resp);
|
||||
$('#ajax_running').slideUp();
|
||||
},
|
||||
error: function () {
|
||||
$('#ajax_running').slideUp();
|
||||
}
|
||||
});
|
||||
}
|
||||
65
modules/dpdpoland/js/dpdpoland-pudo-cod-iframe.js
Normal file
65
modules/dpdpoland/js/dpdpoland-pudo-cod-iframe.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2024 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2024 DPD Polska Sp. z o.o.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
// noinspection JSUnresolvedReference
|
||||
|
||||
if (typeof dpdPolandCodEventCreated == 'undefined') {
|
||||
var dpdPolandCodEventCreated = false;
|
||||
}
|
||||
|
||||
var dpdPolandCod_iframe = document.createElement("iframe");
|
||||
dpdPolandCod_iframe.setAttribute("id", "dpdpoland-widget-pudo-cod-iframe");
|
||||
dpdPolandCod_iframe.setAttribute("allow", "geolocation");
|
||||
dpdPolandCod_iframe.src = dpdpoland_iframe_cod_url;
|
||||
dpdPolandCod_iframe.style.width = "100%";
|
||||
dpdPolandCod_iframe.style.border = "none";
|
||||
dpdPolandCod_iframe.style.minHeight = "400px";
|
||||
dpdPolandCod_iframe.style.height = "768px";
|
||||
|
||||
var dpdPolandCod_script = document.getElementById("dpdpoland-widget-pudo-cod");
|
||||
if (dpdPolandCod_script)
|
||||
dpdPolandCod_script.parentNode.insertBefore(dpdPolandCod_iframe, dpdPolandCod_script);
|
||||
|
||||
if (!dpdPolandCodEventCreated) {
|
||||
var dpdPolandCod_eventListener = window[window.addEventListener ? "addEventListener" : "attachEvent"];
|
||||
var dpdPolandCod_messageEvent = ("attachEvent" === dpdPolandCod_eventListener) ? "onmessage" : "message";
|
||||
dpdPolandCod_eventListener(dpdPolandCod_messageEvent, function (a) {
|
||||
if (getDpdPolandIdPudoCodCarrier() === getDpdPolandSelectedCarrier()) {
|
||||
if (a.data.height && !isNaN(a.data.height)) {
|
||||
dpdPolandCod_iframe.style.height = a.data.height + "px"
|
||||
} else if (a.data.point_id)
|
||||
dpdPolandCodPointSelected(a.data.point_id);
|
||||
}
|
||||
}, !1);
|
||||
dpdPolandCodEventCreated = true
|
||||
}
|
||||
|
||||
function dpdPolandCodPointSelected(pudoCode) {
|
||||
$('.container_dpdpoland_pudo_cod_error').css("display", "none");
|
||||
$('.dpdpoland-pudo-cod-new-point').css("display", "none");
|
||||
$('.dpdpoland-pudo-cod-selected-point').css("display", "block");
|
||||
|
||||
dpdPolandSavePudoCode(pudoCode, $('#dpdpolandPudoCodModal'));
|
||||
dpdPolandGetPudoAddress(pudoCode, $('.dpdpoland-cod-selected-point'))
|
||||
}
|
||||
|
||||
65
modules/dpdpoland/js/dpdpoland-pudo-iframe.js
Normal file
65
modules/dpdpoland/js/dpdpoland-pudo-iframe.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2024 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2024 DPD Polska Sp. z o.o.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
// noinspection JSUnresolvedReference
|
||||
|
||||
if (typeof dpdpolandEventCreated == 'undefined') {
|
||||
var dpdpolandEventCreated = false;
|
||||
}
|
||||
|
||||
var dpdpoland_iframe = document.createElement("iframe");
|
||||
dpdpoland_iframe.setAttribute("id", "dpdpoland-widget-pudo-iframe");
|
||||
dpdpoland_iframe.setAttribute("allow", "geolocation");
|
||||
dpdpoland_iframe.src = dpdpoland_iframe_url;
|
||||
dpdpoland_iframe.style.width = "100%";
|
||||
dpdpoland_iframe.style.border = "none";
|
||||
dpdpoland_iframe.style.minHeight = "400px";
|
||||
dpdpoland_iframe.style.height = "768px";
|
||||
|
||||
var dpdpoland_script = document.getElementById("dpdpoland-widget-pudo");
|
||||
if (dpdpoland_script)
|
||||
dpdpoland_script.parentNode.insertBefore(dpdpoland_iframe, dpdpoland_script);
|
||||
|
||||
if (!dpdpolandEventCreated) {
|
||||
var dpdpoland_eventListener = window[window.addEventListener ? "addEventListener" : "attachEvent"];
|
||||
var dpdpoland_messageEvent = ("attachEvent" === dpdpoland_eventListener) ? "onmessage" : "message";
|
||||
dpdpoland_eventListener(dpdpoland_messageEvent, function (a) {
|
||||
if (getDpdPolandIdPudoCarrier() === getDpdPolandSelectedCarrier()) {
|
||||
if (a.data.height && !isNaN(a.data.height)) {
|
||||
dpdpoland_iframe.style.height = a.data.height + "px"
|
||||
} else if (a.data.point_id)
|
||||
dpdPolandPointSelected(a.data.point_id);
|
||||
}
|
||||
}, !1);
|
||||
dpdpolandEventCreated = true
|
||||
}
|
||||
|
||||
function dpdPolandPointSelected(pudoCode) {
|
||||
$('.container_dpdpoland_pudo_error').css("display", "none");
|
||||
$('.dpdpoland-pudo-new-point').css("display", "none");
|
||||
$('.dpdpoland-pudo-selected-point').css("display", "block");
|
||||
|
||||
dpdPolandSavePudoCode(pudoCode, $('#dpdpolandPudoModal'));
|
||||
dpdPolandGetPudoAddress(pudoCode, $('.dpdpoland-selected-point'))
|
||||
|
||||
}
|
||||
66
modules/dpdpoland/js/dpdpoland-swipbox-iframe.js
Normal file
66
modules/dpdpoland/js/dpdpoland-swipbox-iframe.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2025 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2025 DPD Polska Sp. z o.o.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
// noinspection JSUnresolvedReference
|
||||
|
||||
if (typeof dpdpolandSwipBoxEventCreated == 'undefined') {
|
||||
var dpdpolandSwipBoxEventCreated = false;
|
||||
}
|
||||
|
||||
var dpdpoland_swipbox_iframe = document.createElement("iframe");
|
||||
dpdpoland_swipbox_iframe.setAttribute("id", "dpdpoland-widget-swipbox-iframe");
|
||||
dpdpoland_swipbox_iframe.setAttribute("allow", "geolocation");
|
||||
dpdpoland_swipbox_iframe.src = dpdpoland_iframe_swipbox_url;
|
||||
dpdpoland_swipbox_iframe.style.width = "100%";
|
||||
dpdpoland_swipbox_iframe.style.border = "none";
|
||||
dpdpoland_swipbox_iframe.style.minHeight = "400px";
|
||||
dpdpoland_swipbox_iframe.style.height = "768px";
|
||||
|
||||
var dpdpoland_swipbox_script = document.getElementById("dpdpoland-widget-swipbox");
|
||||
if (dpdpoland_swipbox_script)
|
||||
dpdpoland_swipbox_script.parentNode.insertBefore(dpdpoland_swipbox_iframe, dpdpoland_swipbox_script);
|
||||
|
||||
if (!dpdpolandSwipBoxEventCreated) {
|
||||
var dpdpoland_swipbox_eventListener = window[window.addEventListener ? "addEventListener" : "attachEvent"];
|
||||
var dpdpoland_swipbox_messageEvent = ("attachEvent" === dpdpoland_swipbox_eventListener) ? "onmessage" : "message";
|
||||
dpdpoland_swipbox_eventListener(dpdpoland_swipbox_messageEvent, function (a) {
|
||||
console.log('hit' + getDpdPolandIdSwipBoxCarrier() +' ' + getDpdPolandSelectedCarrier())
|
||||
if (getDpdPolandIdSwipBoxCarrier() === getDpdPolandSelectedCarrier()) {
|
||||
if (a.data.height && !isNaN(a.data.height)) {
|
||||
dpdpoland_swipbox_iframe.style.height = a.data.height + "px"
|
||||
} else if (a.data.point_id)
|
||||
dpdPolandPointSelected(a.data.point_id);
|
||||
}
|
||||
}, !1);
|
||||
dpdpolandSwipBoxEventCreated = true
|
||||
}
|
||||
|
||||
function dpdPolandPointSelected(pudoCode) {
|
||||
$('.container_dpdpoland_swipbox_error').css("display", "none");
|
||||
$('.dpdpoland-swipbox-new-point').css("display", "none");
|
||||
$('.dpdpoland-swipbox-selected-point').css("display", "block");
|
||||
|
||||
dpdPolandSavePudoCode(pudoCode, $('#dpdpolandSwipboxModal'));
|
||||
dpdPolandGetPudoAddress(pudoCode, $('.dpdpoland-selected-point'))
|
||||
|
||||
}
|
||||
29
modules/dpdpoland/js/index.php
Normal file
29
modules/dpdpoland/js/index.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* 2019 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2019 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
3
modules/dpdpoland/js/jquery-migrate-3.1.0.min.js
vendored
Normal file
3
modules/dpdpoland/js/jquery-migrate-3.1.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
modules/dpdpoland/js/jquery.bpopup.min.js
vendored
Normal file
7
modules/dpdpoland/js/jquery.bpopup.min.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*================================================================================
|
||||
* @name: bPopup - if you can't get it up, use bPopup
|
||||
* @author: (c)Bjoern Klinggaard (twitter@bklinggaard)
|
||||
* @demo: http://dinbror.dk/bpopup
|
||||
* @version: 0.9.4.min
|
||||
================================================================================*/
|
||||
(function(b){b.fn.bPopup=function(z,F){function K(){a.contentContainer=b(a.contentContainer||c);switch(a.content){case "iframe":var h=b('<iframe class="b-iframe" '+a.iframeAttr+"></iframe>");h.appendTo(a.contentContainer);r=c.outerHeight(!0);s=c.outerWidth(!0);A();h.attr("src",a.loadUrl);k(a.loadCallback);break;case "image":A();b("<img />").load(function(){k(a.loadCallback);G(b(this))}).attr("src",a.loadUrl).hide().appendTo(a.contentContainer);break;default:A(),b('<div class="b-ajax-wrapper"></div>').load(a.loadUrl,a.loadData,function(){k(a.loadCallback);G(b(this))}).hide().appendTo(a.contentContainer)}}function A(){a.modal&&b('<div class="b-modal '+e+'"></div>').css({backgroundColor:a.modalColor,position:"fixed",top:0,right:0,bottom:0,left:0,opacity:0,zIndex:a.zIndex+t}).appendTo(a.appendTo).fadeTo(a.speed,a.opacity);D();c.data("bPopup",a).data("id",e).css({left:"slideIn"==a.transition||"slideBack"==a.transition?"slideBack"==a.transition?g.scrollLeft()+u:-1*(v+s):l(!(!a.follow[0]&&m||f)),position:a.positionStyle||"absolute",top:"slideDown"==a.transition||"slideUp"==a.transition?"slideUp"==a.transition?g.scrollTop()+w:x+-1*r:n(!(!a.follow[1]&&p||f)),"z-index":a.zIndex+t+1}).each(function(){a.appending&&b(this).appendTo(a.appendTo)});H(!0)}function q(){a.modal&&b(".b-modal."+c.data("id")).fadeTo(a.speed,0,function(){b(this).remove()});a.scrollBar||b("html").css("overflow","auto");b(".b-modal."+e).unbind("click");g.unbind("keydown."+e);d.unbind("."+e).data("bPopup",0<d.data("bPopup")-1?d.data("bPopup")-1:null);c.undelegate(".bClose, ."+a.closeClass,"click."+e,q).data("bPopup",null);H();return!1}function G(h){var b=h.width(),e=h.height(),d={};a.contentContainer.css({height:e,width:b});e>=c.height()&&(d.height=c.height());b>=c.width()&&(d.width=c.width());r=c.outerHeight(!0);s=c.outerWidth(!0);D();a.contentContainer.css({height:"auto",width:"auto"});d.left=l(!(!a.follow[0]&&m||f));d.top=n(!(!a.follow[1]&&p||f));c.animate(d,250,function(){h.show();B=E()})}function L(){d.data("bPopup",t);c.delegate(".bClose, ."+a.closeClass,"click."+e,q);a.modalClose&&b(".b-modal."+e).css("cursor","pointer").bind("click",q);M||!a.follow[0]&&!a.follow[1]||d.bind("scroll."+e,function(){B&&c.dequeue().animate({left:a.follow[0]?l(!f):"auto",top:a.follow[1]?n(!f):"auto"},a.followSpeed,a.followEasing)}).bind("resize."+e,function(){w=y.innerHeight||d.height();u=y.innerWidth||d.width();if(B=E())clearTimeout(I),I=setTimeout(function(){D();c.dequeue().each(function(){f?b(this).css({left:v,top:x}):b(this).animate({left:a.follow[0]?l(!0):"auto",top:a.follow[1]?n(!0):"auto"},a.followSpeed,a.followEasing)})},50)});a.escClose&&g.bind("keydown."+e,function(a){27==a.which&&q()})}function H(b){function d(e){c.css({display:"block",opacity:1}).animate(e,a.speed,a.easing,function(){J(b)})}switch(b?a.transition:a.transitionClose||a.transition){case "slideIn":d({left:b?l(!(!a.follow[0]&&m||f)):g.scrollLeft()-(s||c.outerWidth(!0))-C});break;case "slideBack":d({left:b?l(!(!a.follow[0]&&m||f)):g.scrollLeft()+u+C});break;case "slideDown":d({top:b?n(!(!a.follow[1]&&p||f)):g.scrollTop()-(r||c.outerHeight(!0))-C});break;case "slideUp":d({top:b?n(!(!a.follow[1]&&p||f)):g.scrollTop()+w+C});break;default:c.stop().fadeTo(a.speed,b?1:0,function(){J(b)})}}function J(b){b?(L(),k(F),a.autoClose&&setTimeout(q,a.autoClose)):(c.hide(),k(a.onClose),a.loadUrl&&(a.contentContainer.empty(),c.css({height:"auto",width:"auto"})))}function l(a){return a?v+g.scrollLeft():v}function n(a){return a?x+g.scrollTop():x}function k(a){b.isFunction(a)&&a.call(c)}function D(){x=p?a.position[1]:Math.max(0,(w-c.outerHeight(!0))/2-a.amsl);v=m?a.position[0]:(u-c.outerWidth(!0))/2;B=E()}function E(){return w>c.outerHeight(!0)&&u>c.outerWidth(!0)}b.isFunction(z)&&(F=z,z=null);var a=b.extend({},b.fn.bPopup.defaults,z);a.scrollBar||b("html").css("overflow","hidden");var c=this,g=b(document),y=window,d=b(y),w=y.innerHeight||d.height(),u=y.innerWidth||d.width(),M=/OS 6(_\d)+/i.test(navigator.userAgent),C=200,t=0,e,B,p,m,f,x,v,r,s,I;c.close=function(){a=this.data("bPopup");e="__b-popup"+d.data("bPopup")+"__";q()};return c.each(function(){b(this).data("bPopup")||(k(a.onOpen),t=(d.data("bPopup")||0)+1,e="__b-popup"+t+"__",p="auto"!==a.position[1],m="auto"!==a.position[0],f="fixed"===a.positionStyle,r=c.outerHeight(!0),s=c.outerWidth(!0),a.loadUrl?K():A())})};b.fn.bPopup.defaults={amsl:50,appending:!0,appendTo:"body",autoClose:!1,closeClass:"b-close",content:"ajax",contentContainer:!1,easing:"swing",escClose:!0,follow:[!0,!0],followEasing:"swing",followSpeed:500,iframeAttr:'scrolling="no" frameborder="0"',loadCallback:!1,loadData:!1,loadUrl:!1,modal:!0,modalClose:!0,modalColor:"#000",onClose:!1,onOpen:!1,opacity:0.7,position:["auto","auto"],positionStyle:"absolute",scrollBar:!0,speed:250,transition:"fadeIn",transitionClose:!1,zIndex:9997}})(jQuery);
|
||||
167
modules/dpdpoland/js/pudo-common.js
Normal file
167
modules/dpdpoland/js/pudo-common.js
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* 2024 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2024 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
handleDpdPudo();
|
||||
$(document).on('click', '.delivery_option_radio', handleDpdPudo);
|
||||
$(document).on('click', 'input[name^="delivery_option"]', handleDpdPudo);
|
||||
|
||||
$('.dpdpoland-pudo-container').parent().css('border-right', '0');
|
||||
$('.dpdpoland-pudo-cod-container').parent().css('border-right', '0');
|
||||
$('.dpdpoland-swipbox-container').parent().css('border-right', '0');
|
||||
|
||||
$(document).on('click', '.dpdpoland-swipbox-open-map-btn', (e) => showModal(e, '#dpdpolandSwipboxModal'));
|
||||
$(document).on('click', '.dpdpoland-swipbox-change-map-btn', (e) => showModal(e, '#dpdpolandSwipboxModal'));
|
||||
|
||||
$(document).on('click', '.dpdpoland-pudo-open-map-btn', (e) => showModal(e, '#dpdpolandPudoModal'));
|
||||
$(document).on('click', '.dpdpoland-pudo-change-map-btn', (e) => showModal(e, '#dpdpolandPudoModal'));
|
||||
|
||||
$(document).on('click', '.dpdpoland-pudo-cod-open-map-btn', (e) => showModal(e, '#dpdpolandPudoCodModal'));
|
||||
$(document).on('click', '.dpdpoland-pudo-cod-change-map-btn', (e) => showModal(e, '#dpdpolandPudoCodModal'));
|
||||
|
||||
});
|
||||
|
||||
function dpdPolandSavePudoCode(pudoCode, modal) {
|
||||
$.ajax({
|
||||
url: dpdpoland_ajax_uri,
|
||||
type: 'POST',
|
||||
data: {
|
||||
'pudo_code': pudoCode,
|
||||
'save_pudo_id': 1,
|
||||
'token': dpdpoland_token,
|
||||
'id_cart': dpdpoland_cart,
|
||||
'session': dpdpoland_session
|
||||
},
|
||||
success: function (response) {
|
||||
if (Number(response) === 1) {
|
||||
$('.dpdpoland-pudo-new-point').css("display", "none");
|
||||
$('.dpdpoland-pudo-selected-point').css("display", "block");
|
||||
enableDpdPolandOrderProcessBtn();
|
||||
} else {
|
||||
$('.container_dpdpoland_pudo_error').css("display", "block");
|
||||
disableDpdPolandOrderProcessBtn();
|
||||
console.error('Error:', response);
|
||||
}
|
||||
hideModal(modal);
|
||||
},
|
||||
error: function (error) {
|
||||
console.error('Error:', error);
|
||||
hideModal(modal);
|
||||
}
|
||||
});
|
||||
|
||||
function hideModal(modal) {
|
||||
setTimeout(() => {
|
||||
modal.modal('toggle');
|
||||
$(".modal-backdrop").hide();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function dpdPolandGetPudoAddress(pudoCode, input) {
|
||||
$.ajax({
|
||||
url: dpdpoland_ajax_uri,
|
||||
type: 'GET',
|
||||
data: {
|
||||
'pudo_code': pudoCode,
|
||||
'call_pudo_address': 1,
|
||||
'token': dpdpoland_token,
|
||||
'id_cart': dpdpoland_cart
|
||||
},
|
||||
success: function (response) {
|
||||
input.text(response);
|
||||
},
|
||||
error: function (error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showModal(event, modalDiv) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$(modalDiv).modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
})
|
||||
handleDpdPudo();
|
||||
}
|
||||
|
||||
function handleDpdPudo() {
|
||||
|
||||
$('.container_dpdpoland_pudo_cod_error').css("display", "none");
|
||||
$('.container_dpdpoland_pudo_cod_warning').css("display", "none");
|
||||
|
||||
if (getDpdPolandSelectedCarrier() === getDpdPolandIdPudoCarrier()) {
|
||||
$('.dpdpoland-pudo-new-point').css("display", "block");
|
||||
$('.dpdpoland-pudo-selected-point').css("display", "none");
|
||||
|
||||
$('.dpdpoland-selected-point').text("");
|
||||
const dpdPolandWidgetPudoIframe = $("#dpd-widget-pudo-iframe")
|
||||
dpdPolandWidgetPudoIframe.attr("src", dpdPolandWidgetPudoIframe.attr("src"));
|
||||
|
||||
disableDpdPolandOrderProcessBtn();
|
||||
} else if (getDpdPolandSelectedCarrier() === getDpdPolandIdPudoCodCarrier()) {
|
||||
$('.dpdpoland-pudo-cod-selected-point').css("display", "none");
|
||||
$('.dpdpoland-pudo-cod-new-point').css("display", "block");
|
||||
|
||||
$('.dpdpoland-selected-point-cod').text("");
|
||||
const dpdPolandWidgetPudoCodIframe = $("#dpd-widget-pudo-cod-iframe")
|
||||
dpdPolandWidgetPudoCodIframe.attr("src", dpdPolandWidgetPudoCodIframe.attr("src"));
|
||||
|
||||
disableDpdPolandOrderProcessBtn();
|
||||
} else if (getDpdPolandSelectedCarrier() === getDpdPolandIdSwipBoxCarrier()) {
|
||||
$('.dpdpoland-swipbox-selected-point').css("display", "none");
|
||||
$('.dpdpoland-swipbox-new-point').css("display", "block");
|
||||
|
||||
$('.dpdpoland-selected-point-swipbox').text("");
|
||||
const dpdPolandWidgetSwipBoxIframe = $("#dpd-widget-swipbox-iframe")
|
||||
dpdPolandWidgetSwipBoxIframe.attr("src", dpdPolandWidgetSwipBoxIframe.attr("src"));
|
||||
|
||||
disableDpdPolandOrderProcessBtn();
|
||||
} else {
|
||||
enableDpdPolandOrderProcessBtn();
|
||||
}
|
||||
}
|
||||
|
||||
function getDpdPolandIdPudoCarrier() {
|
||||
return Number(dpdpoland_id_pudo_carrier);
|
||||
}
|
||||
|
||||
function getDpdPolandIdPudoCodCarrier() {
|
||||
return Number(dpdpoland_id_pudo_cod_carrier);
|
||||
}
|
||||
|
||||
function getDpdPolandIdSwipBoxCarrier() {
|
||||
return Number(dpdpoland_id_swipbox_carrier);
|
||||
}
|
||||
|
||||
function getDpdPolandSelectedCarrier() {
|
||||
let idDpdPolandSelectedCarrier = $('input[name^="delivery_option"]:checked').val();
|
||||
|
||||
if (typeof idDpdPolandSelectedCarrier == 'undefined')
|
||||
return null;
|
||||
|
||||
idDpdPolandSelectedCarrier = idDpdPolandSelectedCarrier.replace(',', '');
|
||||
if (typeof idDpdPolandSelectedCarrier == 'undefined' || idDpdPolandSelectedCarrier === 0)
|
||||
return null;
|
||||
|
||||
return Number(idDpdPolandSelectedCarrier);
|
||||
}
|
||||
26
modules/dpdpoland/js/pudo-default.js
Normal file
26
modules/dpdpoland/js/pudo-default.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 2024 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2024 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
function disableDpdPolandOrderProcessBtn() {
|
||||
$('button[name="confirmDeliveryOption"]').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
function enableDpdPolandOrderProcessBtn() {
|
||||
$('button[name="confirmDeliveryOption"]').removeAttr('disabled');
|
||||
}
|
||||
34
modules/dpdpoland/js/pudo-easycheckout.js
Normal file
34
modules/dpdpoland/js/pudo-easycheckout.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 2025 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2025 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
setTimeout(() => {
|
||||
handleDpdShippingPudo()
|
||||
}, 2000);
|
||||
})
|
||||
|
||||
function disableDpdPolandOrderProcessBtn() {
|
||||
$("#payment-confirmation button").prop("disabled", true);
|
||||
$("#payment-confirmation a").addClass("disabled").attr("aria-disabled", "true");
|
||||
}
|
||||
|
||||
function enableDpdPolandOrderProcessBtn() {
|
||||
$("#payment-confirmation button").prop("disabled", false);
|
||||
$("#payment-confirmation a").removeClass("disabled").removeAttr("aria-disabled");
|
||||
}
|
||||
33
modules/dpdpoland/js/pudo-opc-prestasmart.js
Normal file
33
modules/dpdpoland/js/pudo-opc-prestasmart.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 2025 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2025 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
setTimeout(() => {
|
||||
handleDpdShippingPudo()
|
||||
}, 2000);
|
||||
})
|
||||
|
||||
function disableDpdPolandOrderProcessBtn() {
|
||||
$("#confirm_order").css("pointer-events", "none");
|
||||
}
|
||||
|
||||
function enableDpdPolandOrderProcessBtn() {
|
||||
$("#confirm_order").css("pointer-events", "auto");
|
||||
}
|
||||
|
||||
42
modules/dpdpoland/js/pudo-opc-prestateam-1.7.js
Normal file
42
modules/dpdpoland/js/pudo-opc-prestateam-1.7.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 2025 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2025 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
const refreshDpdPudoState = () => {
|
||||
if (typeof handleDpdPudo === 'function') {
|
||||
handleDpdPudo();
|
||||
}
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
refreshDpdPudoState();
|
||||
}, 2000);
|
||||
|
||||
$(document).on('opc-load-carrier:completed opc-update-carrier:completed', () => {
|
||||
setTimeout(refreshDpdPudoState, 100);
|
||||
});
|
||||
})
|
||||
|
||||
function disableDpdPolandOrderProcessBtn() {
|
||||
$("#btn_place_order").css("pointer-events", "none");
|
||||
}
|
||||
|
||||
function enableDpdPolandOrderProcessBtn() {
|
||||
$("#btn_place_order").css("pointer-events", "auto");
|
||||
}
|
||||
42
modules/dpdpoland/js/pudo-opc-prestateam-8.js
Normal file
42
modules/dpdpoland/js/pudo-opc-prestateam-8.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 2025 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2025 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
const refreshDpdPudoState = () => {
|
||||
if (typeof handleDpdPudo === 'function') {
|
||||
handleDpdPudo();
|
||||
}
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
refreshDpdPudoState();
|
||||
}, 2000);
|
||||
|
||||
$(document).on('opc-load-carrier:completed opc-update-carrier:completed', () => {
|
||||
setTimeout(refreshDpdPudoState, 100);
|
||||
});
|
||||
})
|
||||
|
||||
function disableDpdPolandOrderProcessBtn() {
|
||||
$("#opc_step_shipping_footer, #opc_step_payment_header").css("pointer-events", "none");
|
||||
}
|
||||
|
||||
function enableDpdPolandOrderProcessBtn() {
|
||||
$("#opc_step_shipping_footer, #opc_step_payment_header").css("pointer-events", "auto");
|
||||
}
|
||||
34
modules/dpdpoland/js/pudo-supercheckout.js
Normal file
34
modules/dpdpoland/js/pudo-supercheckout.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 2025 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2025 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
setTimeout(() => {
|
||||
handleDpdPudo()
|
||||
}, 2000);
|
||||
})
|
||||
|
||||
function disableDpdPolandOrderProcessBtn() {
|
||||
$('#supercheckout_confirm_order').attr('disabled', 'disabled');
|
||||
$('#supercheckout_confirm_order').css('pointer-events', 'none');
|
||||
}
|
||||
|
||||
function enableDpdPolandOrderProcessBtn() {
|
||||
$('#supercheckout_confirm_order').removeAttr('disabled');
|
||||
$('#supercheckout_confirm_order').css('pointer-events', '');
|
||||
}
|
||||
33
modules/dpdpoland/js/pudo-thecheckout-prestasmart.js
Normal file
33
modules/dpdpoland/js/pudo-thecheckout-prestasmart.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 2025 DPD Polska Sp. z o.o.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* prestashop@dpd.com.pl so we can send you a copy immediately.
|
||||
*
|
||||
* @author DPD Polska Sp. z o.o.
|
||||
* @copyright 2025 DPD Polska Sp. z o.o.
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
setTimeout(() => {
|
||||
handleDpdShippingPudo()
|
||||
}, 2000);
|
||||
})
|
||||
|
||||
function disableDpdPolandOrderProcessBtn() {
|
||||
$("#confirm_order").css("pointer-events", "none");
|
||||
}
|
||||
|
||||
function enableDpdPolandOrderProcessBtn() {
|
||||
$("#confirm_order").css("pointer-events", "auto");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user