first commit

This commit is contained in:
2024-11-11 18:46:54 +01:00
commit a630d17338
25634 changed files with 4923715 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,180 @@
$(document).ready(function() {
$('.showStatus').on('click', function() {
$('#modalTracking .trackInfo').html('');
var ref = $(this).data('reference');
$.ajax({
url: ajaxTrackingLink,
data: 'track='+ref,
dataType: 'json',
method: 'get',
success: function(json) {
var html = '';
if (json.error != 'error') {
var last = json.current
html = '<span class="badge badge-success">'+last.date+'</span><div class="trackInfoBox"><p>Aktualny status przesyłki to:</p>';
html += '<label>'+last.status.title+'</label><span>'+last.status.description+'</span></div>';
} else {
html = '<div class="alert alert-danger">Wystąpił błąd: Przesyłka nie istnieje w systemie.</div>';
}
$('#modalTracking #myModalLabel').html('Śledzenie przesyłki InPost nr: <br />'+json.result.tracking_number);
$('#modalTracking .trackInfo').html(html);
$('#modalTracking').modal('show');
}
});
});
$('.showHistory').on('click', function() {
$('#modalTracking .trackInfo').html('');
var ref = $(this).data('reference');
$.ajax({
url: ajaxTrackingHistoryLink,
data: 'track='+ref,
dataType: 'json',
method: 'get',
success: function(json) {
var html = '';
if (json.error != 'error') {
var lista = json.result.tracking_details;
$.each(lista, function(index, value) {
var curr = '';
if (index == 0) {
curr = ' current';
}
html += '<div class="item'+curr+'"><span class="badge badge-success">'+value.date+'</span><div class="trackInfoBox"><p>Aktualny status przesyłki to:</p>';
html += '<label>'+value.statusPL.title+'</label><span>'+value.statusPL.description+'</span></div></div>';
});
} else {
html = '<div class="alert alert-danger">Wystąpił błąd: Przesyłka nie istnieje w systemie.</div>';
}
$('#modalTracking #myModalLabel').html('Historia statusów przesyłki nr:<br />'+json.result.tracking_number);
$('#modalTracking .trackInfo').html(html);
$('#modalTracking').modal('show');
}
});
});
});
var assetsServer = 'https://api-pl-points.easypack24.net/v1';
function openModalMap(id) {
$('#easypack-widget').empty();
$('#easypack-map').empty();
var pointType = ['parcel_locker_only'];
if (pTypes == 1) {
pointType = ['parcel_locker', 'pop'];
}
if (mapBox == 1) {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
});
}
if (imw == 1) {
var width = 500;
var height = ($(window).height() * 0.7); // 600
} else {
var width = $(window).width() - 25;
var height = ($(window).height() -25); // 600
}
if (mapShow == 2) {
width = ($(window).width() * 0.7);
}
easyPack.modalMap(function (point, modal) {
updateInpostInfo(id, point.name);
modal.closeModal();
return false;
}, {width: width, height: height});
} else {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
});
}
easyPack.mapWidget('easypack-widget', function(point) {
updateInpostInfo(id, point.name);
});
}
}
function updateInpostInfo(customer, point)
{
console.log(customer+' '+point);
$.ajax({
type: 'POST',
headers: {"cache-control": "no-cache"},
url: baseDirShop + 'module/inpostship/setUserPoint',
async: false,
cache: false,
dataType: 'json',
data: 'id=' + customer
+ '&point=' + point,
success: function (jsonData) {
if (jsonData == true) {
window.location.refresh();
}
}
});
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 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/afl-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
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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;

View File

@@ -0,0 +1,33 @@
var inpostkey = '{$paczkomaty}';
var inpostkey_cod = '{$paczkomaty_cod}';
var courierkey = '{$courier}';
var courierkey_cod = '{$courier_cod}';
var alertPoint = "{l s='You must choose a delivery point of inpost' mod='inpostship'}";
var cart = '{$cart_id}';
var pointDir = '{$pointDir}';
var baseDirShop = '{$baseDirShop}';
var opc = '{if isset($pos)}{$opc}{else}0{/if}';
var box_pos = '{if isset($pos)}{$box_pos}{else}0{/if}';
var shop_version = '{$version}';
var selectedPointInfo = '{$selectedPointInfo}';
var testMap = '{$testMap}';
var id = 0;
var module_img_dir = '{$module_dir_img}';
var imap = '{$imap}';
var imgm = '{$imgm}';
var testMap = 0;
var weekPrice = '{$weekPrice}';
var showWeek = '{$showWeek}';
var isTable = '{$isTable}';
if (shop_version < '1.7') {
if ($("#cgv").length) {
$("#cgv").unbind('click', inpostCGV).bind('click', inpostCGV);
} else {
$("button.standard-checkout").unbind('click', inpostCGV).bind('click', inpostCGV);
$("button.continue").unbind('click', inpostCGV).bind('click', inpostCGV);
}
$('.delivery_option_radio').off('click', '.delivery_option_radio', inpostBindRadio);
$('.delivery_option_radio').on('click', '.delivery_option_radio', inpostBindRadio);
initInpost($('.delivery_option_radio' + ":checked"));
}

View File

@@ -0,0 +1,783 @@
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code
*
* @author PrestaHelp.com
* @copyright 2019-2022 PrestaHelp
* @license LICENSE.txt
*/
$(document).ready(function () {
if (typeof checkoutInpost == 'undefined') {
checkoutInpost = 'default';
}
if (typeof showWeek == 'undefined') {
showWeek = 0;
}
if (checkoutInpost == 'ets_onepagecheckout') {
setTimeout(function() {
initInpost($('.delivery-options-list .delivery-option input:checked'));
}, 500);
$(document).on('click', '.delivery-options-list .delivery-option input', function() {
initInpost($(this));
});
$(document).on('click', '.ec-order-btn', function() {
inpostCGVspStepCheckout($("#conditions_to_approve"));
});
$(document).on('click', '#conditions_to_approve', function() {
inpostCGVspStepCheckout($("#conditions_to_approve"))
})
}
if (checkoutInpost == 'steasycheckout') {
$('.steco-custom-input').on('click', function(e) {
inpostBindRadio($(this), e);
});
prestashop.on('steco_init', function () {
setTimeout(function() {
$('.steco-custom-input-box.steco-tick').each(function(){
var ch = $(this).find('i.checkbox-checked');
if (ch.is(':visible')) {
id = parseInt(ch.parent().prev().val());
elem = ch.parent().prev();
}
});
initInpost(elem);
}, 2500);
})
prestashop.on('steco_event_init', function () {
setTimeout(function() {
$('.steco-custom-input-box.steco-tick').each(function(){
var ch = $(this).find('i.checkbox-checked');
if (ch.is(':visible')) {
id = parseInt(ch.parent().prev().val());
elem = ch.parent().prev();
}
});
initInpost(elem);
}, 2500);
})
prestashop.on(
'updatedDeliveryForm',
function() {
setTimeout(function() {
$('.steco-custom-input-box.steco-tick').each(function(){
var ch = $(this).find('i.checkbox-checked');
if (ch.is(':visible')) {
id = parseInt(ch.parent().prev().val());
elem = ch.parent().prev();
}
});
initInpost(elem);
}, 1000);
}
);
$(document).on("click", "#steco-conditions-to-approve .steco-custom-input" , function() {
inpostCGV();
});
}
if (checkoutInpost == 'supercheckout') {
if ($("#conditions_to_approve[terms-and-conditions]").length) {
$("#conditions_to_approve[terms-and-conditions]").unbind('click', inpostCGV).bind('click', inpostCGV);
}
$('#supercheckout-agree input').on('click', function() {
inpostCGV();
});
var elem;
setTimeout(function() {
$('.delivery_option_radio').each(function(){
var ch = $(this);
if (ch.is(':checked')) {
id = parseInt(ch.val());
elem = ch;
}
});
initInpost(elem);
}, 2500);
}
if (checkoutInpost == 'default') {
$("button.standard-checkout").unbind('click', inpostCGV).bind('click', inpostCGV);
$("button.continue").unbind('click', inpostCGV).bind('click', inpostCGV);
$('#checkout-payment-step h1').unbind('click', inpostCGV).bind('click', inpostCGV);
$('.delivery-option input').on('click', function (e) {
inpostBindRadio($(this), e);
});
initInpost($('.custom-radio input' + ":checked"));
$(document).on('click', '.delivery-options-list .continue', function () {
// inpostCGVspStepCheckout();
});
if (showWeek == 0) {
$('.custom-radio input').each(function() {
var idd = parseInt($(this).find('input').val());
if (inpostkey_week.indexOf(idd) > -1 || inpostkey_week_cod.indexOf(idd) > -1) {
$(this).hide();
}
});
}
}
if (checkoutInpost == 'spstepcheckout') {
setTimeout(function() {
$('.delivery-option').each(function(){
var ch = $(this).find('input.delivery_option_radio');
if (ch.is(':checked')) {
id = parseInt(ch.val());
elem = ch;
}
});
initInpost(elem);
}, 2500);
}
$('.delivery-options-list button').on('click', function(){
var val = $('.tr-inpost-box .inpostship-main .inpost-point').val();
if (val == '' && selectedPointInfo == '') {
$('#inpostshipmodal').modal();
$('#cgv').parent().removeClass('checked');
return false;
}
});
$('#inpostshipmodal .modal-footer button').on('click', function() {
$('#inpostshipmodal').modal('hide');
});
$('#inpostshipmodal .modal-header button').on('click', function() {
$('#inpostshipmodal').modal('hide');
});
$(document).on('click', '#inpostshipmodal .modal-footer button', function() {
$('#inpostshipmodal').modal('hide');
});
$(document).on('click', '#inpostshipmodal .modal-header button', function() {
$('#inpostshipmodal').modal('hide');
});
});
function afterPointSelected(point) {
updateInpostInfo(cart, id, point.name);
}
var assetsServer = 'https://api-pl-points.easypack24.net/v1';
function openModalMap(id) {
$('#easypack-widget').empty();
$('#easypack-map').empty();
var pointType = ['parcel_locker_only'];
if (pTypes == 1) {
pointType = ['parcel_locker', 'pop'];
}
if (mapBox == 1) {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
});
}
if (imw == 1) {
var width = 500;
var height = ($(window).height() * 0.7); // 600
} else {
var width = $(window).width() - 25;
var height = ($(window).height() -25); // 600
}
if (mapShow == 2) {
width = ($(window).width() * 0.7);
}
easyPack.modalMap(function (point, modal) {
updateInpostInfo(cart, id, point.name);
modal.closeModal();
return false;
}, {width: width, height: height});
} else {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
});
}
easyPack.mapWidget('easypack-widget', function(point) {
updateInpostInfo(cart, id, point.name);
});
}
}
function openModalMapCod(id) {
$('#easypack-widget').empty();
$('#easypack-map').empty();
var pointType = ['parcel_locker'];
if (pTypes == 1) {
pointType = ['parcel_locker', 'pop'];
}
if (mapBox == 1) {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
paymentFilter: {
visible: true,
showOnlyWithPayment: true,
}
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
paymentFilter: {
visible: false,
showOnlyWithPayment: true,
}
});
}
var width = 500;
var height = ($(window).height() * 0.7); // 600
if (mapShow == 2) {
width = ($(window).width() * 0.7);
}
easyPack.modalMap(function (point, modal) {
updateInpostInfo(cart, id, point.name);
modal.closeModal();
return false;
}, {width: width, height: height});
} else {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
paymentFilter: {
visible: true,
showOnlyWithPayment: true,
}
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
paymentFilter: {
visible: true,
showOnlyWithPayment: true,
}
});
}
easyPack.mapWidget('easypack-widget', function(point) {
updateInpostInfo(cart, id, point.name);
});
}
}
function inpostCGVUncheck() {
$("#cgv").prop('checked', false);
if (typeof $.uniform != 'undefined') {
$.uniform.update();
}
}
function inpostBindRadio(el, e) {
inpostCGVUncheck();
initInpost(el, true);
}
function updateInpostInfo(id_cart, id_carrier, point) {
$('.saveInfo').remove();
var ile = 9;
if (point.indexOf('POP') > -1) {
ile = 12;
}
if (point.length < ile) {
$('.tr-inpost-box .inpostship-main').css({
'border': '1px solid #999'
});
$('.point-info').remove();
var week = 0;
if ($('.weekPack').is(':checked')){
week = 1;
}
$.ajax({
type: 'POST',
headers: {"cache-control": "no-cache"},
url: baseDirShop + 'modules/inpostship/setPoint.php',
async: false,
cache: false,
dataType: 'json',
data: 'id_cart=' + id_cart
+ '&id_carrier=' + id_carrier
+ '&point=' + point
+ '&week='+week,
success: function (jsonData) {
$('.saveInfo').remove();
if (jsonData === false) {
$('.inpostship-content').css({
'border-color': '#ff0000'
});
$('.inpostship-main-box').append('<small class="saveInfo text-danger">Paczkomat nie został poprawnie zapisany</small>');
} else {
$('.inpostship-content').css({
'border-color': '#67A901'
});
$('.inpostship-main-box').append('<p class="point-info">Wybrany paczkomat:<br /><b>' + jsonData.point_code + ', ul. ' + jsonData.point_address1 + ', ' + jsonData.point_address2 + '</b><br />' + jsonData.point_desc + '</p>');
selectedPointInfo = jsonData.point_code;
if (selectedPointInfo != '') {
$('.inpostship-main-box').append('<small class="saveInfo text-success">Paczkomat został poprawnie zapisany</small>');
} else {
$('.inpostship-main-box').append('<small class="saveInfo text-danger">Paczkomat nie został poprawnie zapisany</small>');
}
}
setTimeout(function() {
$('.saveInfo').remove();
}, 3000);
}
});
}
}
function updateInpostInfoCourier(id_cart, id_carrier) {
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseDirShop + 'modules/inpostship/setCourier.php',
async: false,
cache: false,
dataType: 'json',
data: 'id_cart='+id_cart+'&id_carrier='+id_carrier,
success: function(jsonData) {
}
});
}
var inpostCGVspStepCheckout = function() {
if (typeof inpostkey === "undefined") {
inpostkey = [];
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = [];
}
if (typeof inpostkey_week === "undefined") {
inpostkey_week = [];
}
if (typeof inpostkey_week_cod === "undefined") {
inpostkey_week_cod = [];
}
$('.custom-radio').each(function() {
var inp = $(this).find('input');
if (inp.is(':checked')) {
id = parseInt(inp.val());
}
});
if (isNaN(id)) {
id = parseInt($("input.delivery_option_radio:checked").val());
}
if (isNaN(id)) {
id = parseInt($(".delivery-options-list .delivery-option input:checked").val());
}
console.log(inpostkey)
console.log(id)
if (inpostkey.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
if (inpostkey_cod.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
if (inpostkey_week.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
if (inpostkey_week_cod.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
return true;
};
var inpostCGV = function() {
if (typeof inpostkey === "undefined") {
inpostkey = [];
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = [];
}
if (typeof inpostkey_week === "undefined") {
inpostkey = [];
}
if (typeof inpostkey_week_cod === "undefined") {
inpostkey_cod = [];
}
$('.custom-radio').each(function() {
var inp = $(this).find('input');
if (inp.is(':checked')) {
id = parseInt(inp.val());
}
});
if (isNaN(id)) {
id = parseInt($("input.delivery_option_radio:checked").val());
}
if (isNaN(id)) {
id = parseInt($(".delivery-options-list .delivery-option input:checked").val());
}
if (inpostkey.indexOf(id) > -1 || inpostkey_week.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
if (checkoutInpost == 'steasycheckout') {
$('#steco-conditions-to-approve .steco-custom-input').removeAttr('checked').next().find('i').css('display', 'none');
} else if (checkoutInpost == 'supercheckout') {
$('#supercheckout-agree input').removeAttr('checked');
} else {
$('#cgv').parent().removeClass('checked');
}
return false;
}
}
if (inpostkey_cod.indexOf(id) > -1 || inpostkey_week_cod.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
if (checkoutInpost == 'steasycheckout') {
$('#steco-conditions-to-approve .steco-custom-input').removeAttr('checked').next().find('i').css('display', 'none');
} else if (checkoutInpost == 'supercheckout') {
$('#supercheckout-agree input').removeAttr('checked');
} else {
$('#cgv').parent().removeClass('checked');
}
return false;
}
}
};
var initInpost = function(elem) {
if (typeof inpostkey === "undefined") {
inpostkey = [];
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = [];
}
if (typeof inpostkey_week === "undefined") {
inpostkey_week = [];
}
if (typeof inpostkey_week_cod === "undefined") {
inpostkey_week_cod = [];
}
inpostCGVUncheck();
id = parseInt(elem.val());
$('.tr-inpost-box').remove();
var closest = '.delivery-option';
if (checkoutInpost == 'supercheckout') {
closest = '.highlight';
$('.supercheckoutListItemInpost').remove();
}
if (inpostkey.indexOf(id) > -1 || inpostkey_week.indexOf(id) > -1) {
elem.closest(closest).after(createInpostBox(id));
if (nps == 1) {
var obj = $('.inpostship-main');
$.ajax({
url: baseDirShop + 'modules/inpostship/ajax.php',
type: 'POST',
headers: {"cache-control": "no-cache"},
async: false,
cache: false,
dataType: 'json',
data: 'action=getUserPoints',
success: function (jsonData) {
if (jsonData) {
if (jsonData.points != '') {
var htmls = '<div class="inpostNear"><h4>Paczkomaty w pobliżu Twojego adresu:</h4>';
$.each(jsonData.points, function (index, value) {
htmls += '<div class="nearInpost" data-name="' + value.name + '" data-id="' + id + '" data-cart="' + cart + '"><p><img src="https://geowidget.easypack24.net/images/desktop/icons/parcel_locker.png?4.12.8" /><b>' + value.name + '</b><br />' + value.address + '<br />' + value.desc + '</p></div>';
});
htmls += '</div>';
obj.append(htmls);
}
}
}
});
}
$.ajax({
url: baseDirShop + 'module/inpostship/customerPoint',
type: 'POST',
headers: {"cache-control": "no-cache"},
async: false,
cache: false,
dataType: 'json',
// data: 'action=getUserPoints',
success: function (jsonData) {
if (jsonData) {
if (jsonData.points != '') {
var htmls = '<div class="inpostNear"><h4>Twoje najczęściej wybierane paczkomaty:</h4>';
$.each(jsonData.points, function (index, value) {
htmls += '<div class="nearInpost" data-name="' + value.name + '" data-id="' + id + '" data-cart="' + cart + '"><p><img src="https://geowidget.easypack24.net/images/desktop/icons/parcel_locker.png?4.12.8" /><b>' + value.name + '</b><br />' + value.address +'<br />' + value.desc + '</p></div>';
});
htmls += '</div>';
obj.append(htmls);
}
}
}
});
if (selectedPointInfo != '' || selectedPointInfo != 'undefined') {
$('.tr-inpost-box .inpostship-main').append('<p class="point-info"></p>');
selectedPointInfo = selectedPointInfo.replace('|| ', '<br />').replace(';;', '<b>').replace(';; ', '</b>').replace('||', '<br />');
$('.tr-inpost-box .inpostship-main .point-info').html(selectedPointInfo);
}
// } else if (id == inpostkey_cod || id == inpostkey_week_cod) {
} else if (inpostkey_cod.indexOf(id) > -1 || inpostkey_week_cod.indexOf(id) > -1) {
elem.closest(closest).after(createInpostBox(id, 1));
if (nps == 1) {
var obj = $('.inpostship-main');
$.ajax({
url: baseDirShop + 'modules/inpostship/ajax.php',
type: 'POST',
headers: {"cache-control": "no-cache"},
async: false,
cache: false,
dataType: 'json',
data: 'action=getUserPoints&cod=1',
success: function (jsonData) {
if (jsonData) {
if (jsonData.points != '') {
var htmls = '<div class="inpostNear"><h4>Paczkomaty w pobliżu Twojego adresu:</h4>';
$.each(jsonData, function (index, value) {
htmls += '<div class="nearInpost" data-name="' + value.name + '" data-id="' + id + '" data-cart="' + cart + '"><p><img src="https://geowidget.easypack24.net/images/desktop/icons/parcel_locker.png?4.12.8" /><b>' + value.name + '</b><br />' + value.address + '<br />' + value.desc + '</p></div>';
});
htmls += '</div>';
obj.append(htmls);
}
}
}
});
}
if (selectedPointInfo != '' || selectedPointInfo != 'undefined') {
$('.tr-inpost-box .inpostship-main').append('<p class="point-info"></p>');
selectedPointInfo = selectedPointInfo.replace('|| ', '<br />').replace(';;', '<b>').replace(';; ', '</b>').replace('||', '<br />');
$('.tr-inpost-box .inpostship-main .point-info').html(selectedPointInfo);
}
} else {
if (typeof courierkey === "undefined") {
courierkey = [];
}
if (typeof courierkey_cod === "undefined") {
courierkey_cod = [];
}
if (courierkey.indexOf(id) > -1) {
updateInpostInfoCourier(cart, id);
}
if (courierkey_cod.indexOf(id) > -1) {
updateInpostInfoCourier(cart, id);
}
}
}
function createInpostBox(idCarrier, cod = 0)
{
if (geoWidget == 4) {
var obj = $('.inpostship-main');
var html = '';
if (isTable == 1) {
html += '<tr><td colspan="4">';
}
if (checkoutInpost == 'supercheckout') {
html += '<li class="supercheckoutListItemInpost">';
}
html += '<div class="row tr-inpost-box"><div class="inpostship-main i-go"><div class="inpostship-main-box">';
html += '<table>' +
'<tbody>';
if (showWeek == 1) {
// html += '<tr><td colspan="2"><span class="custom-checkbox" style="float: left;margin-right: 15px;"><input type="checkbox" value="1" class="weekPack" /><span><i class="material-icons rtl-no-flip checkbox-checked"></i></span></span> Paczka w weekend (+' + weekPrice + ' zł)</td> </tr>';
}
html += '<tr>' +
'<td>' +
'<span class="btn btn-success btn-md btn-block openMap';
if (cod == 1) {
html += 'Cod';
}
html += '" onclick="openModalMap';
if (cod == 1) {
html += 'Cod';
}
html += '(' + idCarrier + ');">Wybierz paczkomat z mapy</span>' +
'</td>' +
'</tr>' +
'</tbody>' +
'</table>';
html += '</div><div id="easypack-widget"></div><div id="easypack-widget2"></div></div><br /></div>';
if (checkoutInpost == 'supercheckout') {
html += '</li>';
}
if (isTable == 1) {
html += '</td></tr>';
}
} else {
let config = 'parcelCollect';
if (cod == 1) {
config = 'parcelCollectPayment';
}
if (sandbox == 1) {
html = '<link rel="stylesheet" href="https://sandbox-easy-geowidget-sdk.easypack24.net/inpost-geowidget.css"/>'+
'<script src="https://sandbox-easy-geowidget-sdk.easypack24.net/inpost-geowidget.js" defer></script>';
} else {
html = '<link rel="stylesheet" href="https://geowidget.inpost.pl/inpost-geowidget.css"/>' +
'<script src="https://geowidget.inpost.pl/inpost-geowidget.js" defer></script>';
}
html += '<div class="inpostship-content row"><div class="inpostship-main-box"><span class="btn btn-success btn-md btn-block openMap" data-cod="'+cod+'">Wybierz paczkomat z mapy</span><div class="load-geo-box"></div></div></div>';
}
return html;
}
$(document).ready(function () {
$('.tr-inpost-box .inpostship-main .inpost-point').on('change', function(){
var vl = $(this).html();
if (vl != '' && vl != null && selectedPointInfo != '') {
var vla = vl.split(',');
updateInpostInfo(cart, inpostkey, vla[0]);
} else {
$('#cgv').removeAttr('checked');
$('#cgv').parent().removeClass('checked');
return false;
}
});
$(document).on('click', '.nearInpost', function() {
var point = $(this).data('name');
var cart = $(this).data('cart');
var id = $(this).data('id');
updateInpostInfo(cart, id, point);
});
$(document).on('click', '.openMap', function() {
let config = 'parcelCollect',
cod = $(this).data('cod');
if (cod == 1) {
config = 'parcelCollectPayment';
}
let html = '<inpost-geowidget class="inpost-geowidget-box" onpoint="afterPointSelected" token="'+geoWidgetToken+'" language="pl" config="'+config+'"></inpost-geowidget>';
$('.load-geo-box').append(html);
})
});

View File

@@ -0,0 +1,248 @@
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code
*
* @author PrestaHelp.com
* @copyright 2019 PrestaHelp
* @license LICENSE.txt
*/
$(document).ready(function(){
if (typeof tooltip != 'undefined') {
$('.label-tooltip').tooltip();
}
$(document).on('click', '.select_all', function(e) {
if ($(this).is(':checked')) {
$('.select_one').each(function() {
$(this).prop('checked', 'checked').change();
});
} else {
$('.select_one').each(function() {
$(this).removeAttr('checked').change();
});
}
});
$(document).on('click', '.select_pww_all', function(e) {
if ($(this).is(':checked')) {
$('.select_pww_one').each(function() {
$(this).prop('checked', 'checked').change();
});
} else {
$('.select_pww_one').each(function() {
$(this).removeAttr('checked').change();
});
}
});
$(document).on('change', '.select_ins_all', function(e) {
let ins = $(this).val();
$('.select_one').each(function() {
if ($(this).is(':checked')) {
$(this).closest('tr').find('.select_ins_one').val(ins).change();
}
});
});
$(document).on('change', '.select_sendtype_all', function(e) {
let ins = $(this).val();
$('.select_one').each(function() {
let service = $(this).data('service');
if ($(this).is(':checked')) {
if (ins == 'parcel_locker') {
if (service != 5 && service != 6 && service != 2) {
$(this).closest('tr').find('.select_sendtype_one').val(ins).change();
}
} else {
$(this).closest('tr').find('.select_sendtype_one').val(ins).change();
}
}
});
});
$(document).on('change', '.select_packtype_all', function(e) {
let pt = $(this).val();
$('.select_one').each(function() {
if ($(this).is(':checked')) {
$(this).closest('tr').find('.select_packtype_one').val(pt).change();
}
});
});
$('.selectAllCheckbox').on('click', function () {
var chked = false;
if ($(this).is(':checked')) {
chked = true;
}
$('.chBox').each(function() {
if (chked) {
$(this).attr('checked', 'checked')
} else {
$(this).removeAttr('checked')
}
});
});
$('.settingsInpost').on('click', function() {
$('.alertInpost').remove();
var mapType = $('#INPOSTSHIP_MAP_TYPE').val();
if (mapType == 'google') {
var api = $('#INPOSTSHIP_GOOGLE_MAPS_API').val();
if (api == '') {
$('#INPOSTSHIP_GOOGLE_MAPS_API').after('<p class="alert alert-danger alertInpost">Wybrałeś jako typ mapy Google Maps. Musisz podać klucz API aby działały poprawnie!</p>');
return false;
}
return true;
}
return true;
});
$('.btnToPrepare').on('click', function(){
var html = $(this).html();
$(this).html(html + '<i class="icon-spin animation"></i>');
});
$('.btnToAll').on('click', function() {
var error = 0;
$('.errorSize').each(function() {
$(this).removeClass('errorSize');
});
var owner = $('#ownSize');
if (owner.is(':checked')) {
var s1 = parseInt($('#size1').val());
var s2 = parseInt($('#size2').val());
var s3 = parseInt($('#size3').val());
if (s1 > 350) {
error = 1;
$('#size1').addClass('errorSize');
}
if (s2 > 240) {
error = 1;
$('#size2').addClass('errorSize');
}
if (s3 > 240) {
error = 1;
$('#size3').addClass('errorSize');
}
}
var rnumber = $('#refNumber').val();
if (rnumber.length < 3) {
$('#refNumber').addClass('errorSize');
error = 1;
}
var recEmail = $('#recEmail').val();
if (recEmail.length < 1) {
$('#recEmail').addClass('errorSize');
error = 1;
}
var recPhone = $('#recPhone').val();
if (recPhone.length < 1) {
$('#recPhone').addClass('errorSize');
error = 1;
}
var ins = $('#ins').val();
var total = $('#totalOrder').val();
if (ins < total) {
$('#ins').addClass('errorSize');
error = 1;
}
if (error == 1) {
return false;
}
$(this).find('span').text('trwa tworzenie przesyłki...');
});
$('.add-package').click(function(){
$('.packageCreate').toggle();
});
$('#ajax-update-point').click(function(){
$('.ajax-inpost-result').empty();
pointSteps();
});
});
function pointSteps() {
$('.ajax-inpost-result').append('<div class="alert alert-info"></div>');
setPointStep1();
}
function setPointStep1() {
$.ajax({
url: step1url+'?action=deletePoint',
dataType: 'json',
method: 'get',
success: function() {
$('.ajax-inpost-result div').append('<p>Krok 1 - baza punktów wyczyszczona.</p>');
setPointStep2();
}
});
}
async function setPointStep2() {
if (points_count === undefined) {
// var points_count = 0;
}
if (points_all === undefined) {
// var points_all = 0;
}
$('.ajax-inpost-result div').append('<p>Krok 2 - Import punktów z Inpost.</p>');
$('.ajax-inpost-result div').append('<p class="st2"><span>0</span> z '+points_all+' <small></small></p><br /><div class="progresBarPoints"><div class="progress">\n' +
' <div class="progress-bar bg-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>\n' +
'</div></div>');
var i;
var all = 0;
var progress = 0;
for (let i = 1; i <= points_count; i++) {
all = await inport(i, all);
var current = Math.ceil(all / 100);
progress = Math.ceil((i * 100) / points_count);
$('.progresBarPoints .progress-bar').css('width', progress+'%');
$('.progresBarPoints .progress-bar').attr('aria-valuenow', progress);
$('.progresBarPoints .progress-bar').text(progress+' %');
if (points_all == all) {
stepPoint3();
}
if (i == points_count) {
// stepPoint3();
}
}
}
function inport(i, all)
{
var state = $.ajax({
url: step1url+'?action=addPoint&page='+i,
dataType: 'json',
method: 'get',
success: function(data) {
var current_count = parseInt($('.st2 > span').html());
var data_count = parseInt(data);
all = current_count+data_count;
$('.st2 > span').text(current_count+data_count);
}
});
return state;
}
function stepPoint3()
{
$('.ajax-inpost-result div').append('<p>Krok 3 Zakończono import. Zaraz nastąpi przeładowanie strony.<span class="ccc"></span></p>');
var time = 5;
setInterval(function() {
$('.ccc').text(' (za '+time+'s)');
time--;
}, 1000);
setTimeout(function() {
window.location.reload(true);
}, 5000);
}

View File

@@ -0,0 +1,506 @@
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code
*
* @author PrestaHelp.com
* @copyright 2019 PrestaHelp
* @license LICENSE.txt
*/
$(document).ready(function () {
if (typeof checkout == 'undefined') {
checkout = 'default';
}
if (typeof showWeek == 'undefined') {
showWeek = 0;
}
if (checkout == 'default') {
if ($("#cgv").length) {
// $("#cgv").unbind('click', inpostCGV($('#cgv'))).bind('click', inpostCGV($('#cgv')));
} else {
$("button.standard-checkout").unbind('click', inpostCGV($('#cgv'))).bind('click', inpostCGV($('#cgv')));
}
if (showWeek == 0) {
$('.delivery-option').each(function() {
var idd = parseInt($(this).find('input').val());
if (inpostkey_week.indexOf(idd) || inpostkey_week_cod.indexOf(idd)) {
$(this).hide();
}
});
}
}
if (checkout == 'onepagecheckoutps') {
$('.approval-payment #regulamin').on('click', function() {
// console.log('onepagecheckoutps_step_three_container')
})
$("#regulamin").unbind('click', inpostCGV($("#regulamin"))).bind('click', inpostCGV($("#regulamin")));
}
if (checkout == 'onepagecheckout') {
if ($("#cgv").length) {
// $("#cgv").unbind('click', inpostCGV($('#cgv'))).bind('click', inpostCGV($('#cgv')));
} else {
$("button.confirm_button").unbind('click', inpostCGV($('#cgv'))).bind('click', inpostCGV($('#cgv')));
}
setTimeout(function() {
initInpost($('#carrierTable .carrier_action input:checked'));
}, 500);
}
$('.delivery_option_radio').off('click', '.delivery_option_radio', inpostBindRadio);
$('.delivery_option_radio').on('click', '.delivery_option_radio', inpostBindRadio);
initInpost($('.delivery_option_radio' + ":checked"));
$('#inpostshipmodal .modal-footer button').on('click', function() {
$('#inpostshipmodal').modal('hide');
});
$('#inpostshipmodal .modal-header button').on('click', function() {
$('#inpostshipmodal').modal('hide');
});
$(document).on('click', '#inpostshipmodal .modal-footer button', function() {
$('#inpostshipmodal').modal('hide');
});
$(document).on('click', '#inpostshipmodal .modal-header button', function() {
$('#inpostshipmodal').modal('hide');
});
});
var assetsServer = 'https://api-pl-points.easypack24.net/v1';
function openModalMap(id) {
$('#easypack-widget').empty();
$('#easypack-map').empty();
var pointType = ['parcel_locker_only'];
if (pTypes == 1) {
pointType = ['parcel_locker', 'pop'];
}
if (mapBox == 1) {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType
},
});
}
if (imw == 1) {
var width = 500;
var height = ($(window).height() * 0.7); // 600
} else {
var width = $(window).width() - 25;
var height = ($(window).height() -25); // 600
}
if (mapShow == 2) {
width = ($(window).width() * 0.7);
}
easyPack.modalMap(function (point, modal) {
updateInpostInfo(cart, id, point.name);
modal.closeModal();
return false;
}, {width: width, height: 600});
} else {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
});
}
easyPack.mapWidget('easypack-widget', function(point) {
updateInpostInfo(cart, id, point.name);
});
}
}
function inpostCGVUncheck() {
$("#cgv").prop('checked', false);
if (typeof $.uniform != 'undefined') {
$.uniform.update();
}
}
function inpostBindRadio(e) {
inpostCGVUncheck();
initInpost($(this), true);
}
function updateInpostInfo(id_cart, id_carrier, point) {
$('.saveInfo').remove();
if (point.length < 9) {
$('.tr-inpost-box .inpostship-main').css({
'border': '1px solid #999'
});
$('.point-info').remove();
var week = 0;
if ($('.weekPack').is(':checked')){
week = 1;
}
$.ajax({
type: 'POST',
headers: {"cache-control": "no-cache"},
url: baseDir + 'modules/inpostship/setPoint.php',
async: false,
cache: false,
dataType: 'json',
data: 'id_cart=' + id_cart
+ '&id_carrier=' + id_carrier
+ '&point=' + point
+ '&week='+week,
success: function (jsonData) {
$('.saveInfo').remove();
if (jsonData === false) {
$('.tr-inpost-box .inpostship-main').css({
'border': '3px solid #ff0000'
});
$('.tr-inpost-box .inpostship-main').append('<small class="saveInfo text-danger">Paczkomat nie został poprawnie zapisany</small>');
} else {
$('.tr-inpost-box .inpostship-main').css({
'border': '3px solid #67A901'
});
$('.tr-inpost-box .inpostship-main').append('<p class="point-info">Wybrany paczkomat:<br /><b>' + jsonData.point_code + ', ul. ' + jsonData.point_address1 + ', ' + jsonData.point_address2 + '</b><br />' + jsonData.point_desc + '</p>');
selectedPointInfo = jsonData.point_code;
if (selectedPointInfo != '') {
$('.tr-inpost-box .inpostship-main').append('<small class="saveInfo text-success">Paczkomat został poprawnie zapisany</small>');
} else {
$('.tr-inpost-box .inpostship-main').append('<small class="saveInfo text-danger">Paczkomat nie został poprawnie zapisany</small>');
}
}
setTimeout(function() {
$('.saveInfo').remove();
}, 3000);
}
});
}
}
function updateInpostInfoCourier(id_cart, id_carrier) {
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseDir + 'modules/inpostship/setCourier.php',
async: false,
cache: false,
dataType: 'json',
data: 'id_cart='+id_cart+'&id_carrier='+id_carrier,
success: function(jsonData) {
}
});
}
var inpostCGV = function(obj){
if (typeof inpostkey === "undefined") {
inpostkey = [];
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = [];
}
if (typeof inpostkey_week === "undefined") {
inpostkey_week = [];
}
if (typeof inpostkey_week_cod === "undefined") {
inpostkey_week_cod = [];
}
id = parseInt($("input.delivery_option_radio:checked").val());
if (inpostkey.indexOf(id) > 0){
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
$(obj).parent().removeClass('checked');
return false;
}
}
if (inpostkey_cod.indexOf(id) > 0) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
$(obj).parent().removeClass('checked');
return false;
}
}
if (inpostkey_week.indexOf(id) > 0) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
if (inpostkey_week_cod.indexOf(id) > 0) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
};
var initInpost = function(elem){
if (typeof checkout === 'undefined') {
checkout = 'default';
}
if (typeof inpostkey === "undefined") {
inpostkey = [];
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = [];
}
if (typeof inpostkey_week === "undefined") {
inpostkey_week = [];
}
if (typeof inpostkey_week_cod === "undefined") {
inpostkey_week_cod = [];
}
inpostCGVUncheck();
id = parseInt(elem.val());
if (checkout == 'onepagecheckout') {
var idString = id.toString();
var id3 = idString.slice(0, -3)
var id2 = id3.slice(1);
id = parseInt(id2);
}
$('.tr-inpost-box').remove();
if (inpostkey.indexOf(id) > -1 || inpostkey_week.indexOf(id) > -1) {
if (opc == 1) {
if (box_pos == 1) {
elem.closest('tbody').append(createInpostBox(id, checkout));
} else {
var closest = '.delivery_options';
if (checkout == 'onepagecheckoutps') {
closest = '.delivery_option.selected'
}
elem.closest(closest).append(createInpostBox(id, checkout));
}
} else {
var closest = 'tbody';
if (checkout == 'onepagecheckoutps') {
closest = '.delivery_option'
}
elem.closest(closest).append(createInpostBox(id, checkout));
}
if (nps == 1) {
var obj = $('.inpostship-main');
$.ajax({
url: baseDirShop + 'modules/inpostship/ajax.php',
type: 'POST',
headers: {"cache-control": "no-cache"},
async: false,
cache: false,
dataType: 'json',
data: 'action=getUserPoints',
success: function (jsonData) {
if (jsonData) {
if (jsonData.points != '') {
var htmls = '<div class="inpostNear"><h4>Paczkomaty w pobliżu Twojego adresu:</h4>';
$.each(jsonData.points, function (index, value) {
htmls += '<div class="nearInpost" data-name="' + value.name + '" data-id="' + id + '" data-cart="' + cart + '"><p><img src="https://geowidget.easypack24.net/images/desktop/icons/parcel_locker.png?4.12.8" /><b>' + value.name + '</b><br />' + value.address + '<br />' + value.desc + '</p></div>';
});
htmls += '</div>';
obj.append(htmls);
}
}
}
});
}
if (selectedPointInfo != '' || selectedPointInfo != 'undefined') {
$('.tr-inpost-box .inpostship-main').append('<p class="point-info"></p>');
selectedPointInfo = selectedPointInfo.replace('|| ', '<br />').replace(';;', '<b>').replace(';; ', '</b>').replace('||', '<br />');
$('.tr-inpost-box .inpostship-main .point-info').html(selectedPointInfo);
}
} else if (inpostkey_cod.indexOf(id) > -1 || inpostkey_week.indexOf(id) > -1) {
if (opc == 1) {
if (box_pos == 1) {
elem.closest('tbody').append(createInpostBox(id, checkout));
} else {
var closest = '.delivery_options';
if (checkout == 'onepagecheckoutps') {
closest = '.delivery_option.selected'
}
elem.closest(closest).append(createInpostBox(id, checkout));
}
} else {
var closest = 'tbody';
if (checkout == 'onepagecheckoutps') {
closest = '.delivery_option'
}
elem.closest(closest).append(createInpostBox(id, checkout));
}
if (nps == 1) {
var obj = $('.inpostship-main');
$.ajax({
url: baseDirShop + 'modules/inpostship/ajax.php',
type: 'POST',
headers: {"cache-control": "no-cache"},
async: false,
cache: false,
dataType: 'json',
data: 'action=getUserPoints&cod=1',
success: function (jsonData) {
if (jsonData) {
if (jsonData.points != '') {
var htmls = '<div class="inpostNear"><h4>Paczkomaty w pobliżu Twojego adresu:</h4>';
$.each(jsonData.points, function (index, value) {
htmls += '<div class="nearInpost" data-name="' + value.name + '" data-id="' + id + '" data-cart="' + cart + '"><p><img src="https://geowidget.easypack24.net/images/desktop/icons/parcel_locker.png?4.12.8" /><b>' + value.name + '</b><br />' + value.address + '<br />' + value.desc + '</p></div>';
});
htmls += '</div>';
obj.append(htmls);
}
}
}
});
}
if (selectedPointInfo != '' || selectedPointInfo != 'undefined') {
$('.tr-inpost-box .inpostship-main').append('<p class="point-info"></p>');
selectedPointInfo = selectedPointInfo.replace('|| ', '<br />').replace(';;', '<b>').replace(';; ', '</b>').replace('||', '<br />');
$('.tr-inpost-box .inpostship-main .point-info').html(selectedPointInfo);
}
} else {
if (typeof courierkey === "undefined") {
courierkey = [];
}
if (typeof courierkey_cod === "undefined") {
courierkey_cod = [];
}
if (courierkey.indexOf(id) > -1) {
updateInpostInfoCourier(cart, id);
}
if (courierkey_cod.indexOf(id) > -1) {
updateInpostInfoCourier(cart, id);
}
}
}
function createInpostBox(idCarrier, checkout)
{
if (geoWidget == 4) {
var html = '';
if (isTable == 1) {
html += '<tr><td colspan="4">';
}
html += '<div class="row tr-inpost-box inpost-' + checkout + '"><div class="inpostship-main i-go"><div class="inpostship-main-box">';
html += '<table>' +
'<tbody>';
if (showWeek == 1) {
// html += '<tr><td colspan="2"><span class="custom-checkbox" style="float: left;margin-right: 15px;"><input type="checkbox" value="1" class="weekPack" /><span><i class="material-icons rtl-no-flip checkbox-checked"></i></span></span> Paczka w weekend (+' + weekPrice + ' zł)</td> </tr>';
}
html += '<tr>' +
'<td>' +
'<span class="btn btn-success btn-md btn-block openMap" onclick="openModalMap(' + idCarrier + ');">Wybierz paczkomat z mapy</span>' +
'</td>' +
'</tr>' +
'</tbody>' +
'</table>';
html += '</div><div id="easypack-widget"></div><div id="easypack-widget2"></div></div><br /></div>';
if (isTable == 1) {
html += '</td></tr>';
}
} else {
let config = 'parcelCollect';
if (cod == 1) {
config = 'parcelCollectPayment';
}
if (sandbox == 1) {
html = '<link rel="stylesheet" href="https://sandbox-easy-geowidget-sdk.easypack24.net/inpost-geowidget.css"/>'+
'<script src="https://sandbox-easy-geowidget-sdk.easypack24.net/inpost-geowidget.js" defer></script>';
} else {
html = '<link rel="stylesheet" href="https://geowidget.inpost.pl/inpost-geowidget.css"/>' +
'<script src="https://geowidget.inpost.pl/inpost-geowidget.js" defer></script>';
}
html += '<div class="inpostship-content row"><div class="inpostship-main-box"><span class="btn btn-success btn-md btn-block openMap" data-cod="'+cod+'">Wybierz paczkomat z mapy</span><div class="load-geo-box"></div></div></div>';
}
return html;
}
function afterPointSelected(point) {
updateInpostInfo(cart, id, point.name);
}
$(document).ready(function () {
$('.tr-inpost-box .inpostship-main .inpost-point').on('change', function(){
var vl = $(this).val();
if (vl != '' && vl != null && selectedPointInfo != '') {
var vla = vl.split(',');
updateInpostInfo(cart, inpostkey, vla[0]);
} else {
alert(alertPoint);
$('#cgv').removeAttr('checked');
$('#cgv').parent().removeClass('checked');
// updatePaymentMethodsDisplay();
return false;
}
});
$(document).on('click', '.nearInpost', function() {
var point = $(this).data('name');
var cart = $(this).data('cart');
var id = $(this).data('id');
updateInpostInfo(cart, id, point);
});
$(document).on('click', '.openMap', function() {
let config = 'parcelCollect',
cod = $(this).data('cod');
if (cod == 1) {
config = 'parcelCollectPayment';
}
let html = '<inpost-geowidget class="inpost-geowidget-box" onpoint="afterPointSelected" token="'+geoWidgetToken+'" language="pl" config="'+config+'"></inpost-geowidget>';
$('.load-geo-box').append(html);
})
});

View File

@@ -0,0 +1,272 @@
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code
*
* @author PrestaHelp.com
* @copyright 2019 PrestaHelp
* @license LICENSE.txt
*/
$(document).ready(function () {
testMap = 0;
if ($("#cgv").length) {
$("#cgv").unbind('click', inpostCGV).bind('click', inpostCGV);
} else {
$("button.standard-checkout").unbind('click', inpostCGV).bind('click', inpostCGV);
}
$('.delivery_option_radio').off('click', '.delivery_option_radio', inpostBindRadio);
$('.delivery_option_radio').on('click', '.delivery_option_radio', inpostBindRadio);
initInpost($('.delivery_option_radio' + ":checked"));
$('#inpostshipmodal .modal-footer button').on('click', function() {
$('#inpostshipmodal').modal('hide');
});
$('#inpostshipmodal .modal-header button').on('click', function() {
$('#inpostshipmodal').modal('hide');
});
});
if (typeof testMap == 'undefined') {
var testMap = 0;
}
var assetsServer = 'https://api-pl-points.easypack24.net/v1';
if (testMap == 1) {
assetsServer = 'https://test-api-pl-points.easypack24.net/v1';
}
function openModalMap(id) {
$('#easypack-widget').empty();
$('#easypack-map').empty();
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: ['parcel_locker_only']
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: ['parcel_locker_only'],
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: ['parcel_locker_only']
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: ['parcel_locker_only'],
},
});
}
easyPack.modalMap(function(point) {
updateInpostInfo(cart, id, point.name);
$('#widget-modal').parent().remove();
$('#widget-modal').remove();
return false;
}, { width: 500, height: 600 });
}
function openDropDown(id) {
$('#easypack-widget').empty();
$('#easypack-map').empty();
var gmap = null;
if (imap == 'google') {
gmap = 'googleKey: "'+imgm+'"';
}
easyPack.init({
instance: 'pl',
mapType: imap,
searchType: imap,
apiEndpoint: assetsServer,
points: {
types: ['parcel_locker'],
},
map: {
useGeolocation: true,
initialTypes: ['parcel_locker'],
gmap
}
});
easyPack.dropdownWidget('easypack-widget', function(point) {
updateInpostInfo(cart, id, point.name);
});
}
function inpostCGVUncheck() {
$("#cgv").prop('checked', false);
if (typeof $.uniform != 'undefined') {
$.uniform.update();
}
}
function inpostBindRadio(el, e) {
inpostCGVUncheck();
initInpost(el, true);
}
function updateInpostInfo(id_cart, id_carrier, point) {
if (point.length < 9) {
$('.tr-inpost-box .inpostship-main').css({
'border': '1px solid #999'
});
$('.point-info').remove();
$.ajax({
type: 'POST',
headers: {"cache-control": "no-cache"},
url: baseDirShop + 'modules/inpostship/setPoint.php',
async: false,
cache: false,
dataType: 'json',
data: 'id_cart=' + id_cart
+ '&id_carrier=' + id_carrier
+ '&point=' + point,
success: function (jsonData) {
if (jsonData === false) {
$('.tr-inpost-box .inpostship-main').css({
'border': '3px solid #ff0000'
});
} else {
$('.tr-inpost-box .inpostship-main').css({
'border': '3px solid #67A901'
});
$('.tr-inpost-box .inpostship-main').append('<p class="point-info">Wybrany paczkomat: ' + jsonData.point_code + ', ul. ' + jsonData.point_address1 + ', ' + jsonData.point_address2 + ' - ' + jsonData.point_desc + '</p>');
selectedPointInfo = jsonData.point_code;
}
}
});
}
}
function updateInpostInfoCourier(id_cart, id_carrier) {
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseDirShop + 'modules/inpostship/setCourier.php',
async: false,
cache: false,
dataType: 'json',
data: 'id_cart='+id_cart+'&id_carrier='+id_carrier,
success: function(jsonData) {
}
});
}
var inpostCGV = function(){
if (typeof inpostkey === "undefined") {
inpostkey = 0;
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = 0;
}
var id = parseInt($("input.delivery_option_radio:checked").val());
if (id == inpostkey) {
var val = $('.tr-inpost-box .inpostship-main .inpost-point').val();
if (val == '' && selectedPointInfo == '') {
$('#inpostshipmodal').modal();
$('#cgv').parent().removeClass('checked');
return false;
}
}
if (id == inpostkey_cod) {
var val = $('.tr-inpost-box .inpostship-main .inpost-point').val();
if (val == '' && selectedPointInfo == '') {
$('#inpostshipmodal').modal();
$('#cgv').parent().removeClass('checked');
return false;
}
}
};
var initInpost = function(elem){
// inpostCGVUncheck();
var allow = false;
var id = parseInt(elem.val());
var ida = parseInt(elem.data('id_address'));
$('.tr-inpost-box').remove();
var win_width = $(window).width();
if (id == inpostkey) {
elem.closest('.delivery_option').after(createInpostBox(id));
if (selectedPointInfo != '' || selectedPointInfo != 'undefined') {
$('.tr-inpost-box .inpostship-main').append('<p class="point-info">'+selectedPointInfo+'</p>');
}
} else if( id == inpostkey_cod ) {
elem.closest('.delivery_option').after(createInpostBox(id));
if (selectedPointInfo != '' || selectedPointInfo != 'undefined') {
$('.tr-inpost-box .inpostship-main').append('<p class="point-info">'+selectedPointInfo+'</p>');
}
} else {
if (typeof courierkey === "undefined") {
courierkey = 0;
}
if (typeof courierkey_cod === "undefined") {
courierkey_cod = 0;
}
if (id == courierkey) {
updateInpostInfoCourier(cart, courierkey);
}
if (id == courierkey_cod) {
updateInpostInfoCourier(cart, courierkey_cod);
}
}
}
function createInpostBox(idCarrier)
{
var html = '';
html += '<div class="row tr-inpost-box"><div class="inpostship-main i-go"><div class="inpostship-main-box">';
html += '<table>' +
'<tbody>' +
'<tr>' +
'<td>' +
'<img src="'+module_img_dir+'inpostpaczkomaty.jpg" alt="" />' +
'</td>' +
'<td>' +
'<span class="btn btn-success openDropDown" onclick="openDropDown('+idCarrier+');">Wybierz paczkomat z listy</span>' +
'<span class="btn btn-success openMap" onclick="openModalMap('+idCarrier+');">Wybierz paczkomat z mapy</span>' +
'</td>' +
'</tr>' +
'</tbody>' +
'</table>';
html += '</div><div id="easypack-widget"></div><div id="easypack-widget2"></div></div></div><br />';
return html;
}
$(document).ready(function () {
$('.tr-inpost-box .inpostship-main .inpost-point').on('change', function(){
var vl = $(this).val();
if (vl != '' && vl != null && selectedPointInfo != '') {
var vla = vl.split(',');
updateInpostInfo(cart, inpostkey, vla[0]);
} else {
alert(alertPoint);
$('#cgv').removeAttr('checked');
$('#cgv').parent().removeClass('checked');
updatePaymentMethodsDisplay();
return false;
}
});
});

View File

@@ -0,0 +1,774 @@
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code
*
* @author PrestaHelp.com
* @copyright 2019-2022 PrestaHelp
* @license LICENSE.txt
*/
$(document).ready(function () {
if (typeof checkoutInpost == 'undefined') {
checkoutInpost = 'default';
}
if (typeof showWeek == 'undefined') {
showWeek = 0;
}
if (checkoutInpost == 'ets_onepagecheckout') {
setTimeout(function() {
initInpost($('.delivery-options-list .delivery-option input:checked'));
}, 500);
$(document).on('click', '.delivery-options-list .delivery-option input', function() {
initInpost($(this));
});
$(document).on('click', '.ec-order-btn', function() {
inpostCGVspStepCheckout($("#conditions_to_approve"));
});
$(document).on('click', '#conditions_to_approve', function() {
inpostCGVspStepCheckout($("#conditions_to_approve"))
})
}
if (checkoutInpost == 'steasycheckout') {
$('.steco-custom-input').on('click', function(e) {
inpostBindRadio($(this), e);
});
prestashop.on('steco_init', function () {
setTimeout(function() {
$('.steco-custom-input-box.steco-tick').each(function(){
var ch = $(this).find('i.checkbox-checked');
if (ch.is(':visible')) {
id = parseInt(ch.parent().prev().val());
elem = ch.parent().prev();
}
});
initInpost(elem);
}, 2500);
})
prestashop.on('steco_event_init', function () {
setTimeout(function() {
$('.steco-custom-input-box.steco-tick').each(function(){
var ch = $(this).find('i.checkbox-checked');
if (ch.is(':visible')) {
id = parseInt(ch.parent().prev().val());
elem = ch.parent().prev();
}
});
initInpost(elem);
}, 2500);
})
prestashop.on(
'updatedDeliveryForm',
function() {
setTimeout(function() {
$('.steco-custom-input-box.steco-tick').each(function(){
var ch = $(this).find('i.checkbox-checked');
if (ch.is(':visible')) {
id = parseInt(ch.parent().prev().val());
elem = ch.parent().prev();
}
});
initInpost(elem);
}, 1000);
}
);
$(document).on("click", "#steco-conditions-to-approve .steco-custom-input" , function() {
inpostCGV();
});
}
if (checkoutInpost == 'supercheckout') {
if ($("#conditions_to_approve[terms-and-conditions]").length) {
$("#conditions_to_approve[terms-and-conditions]").unbind('click', inpostCGV).bind('click', inpostCGV);
}
$('#supercheckout-agree input').on('click', function() {
inpostCGV();
});
var elem;
setTimeout(function() {
$('.delivery_option_radio').each(function(){
var ch = $(this);
if (ch.is(':checked')) {
id = parseInt(ch.val());
elem = ch;
}
});
initInpost(elem);
}, 2500);
}
if (checkoutInpost == 'default') {
$("button.standard-checkout").unbind('click', inpostCGV).bind('click', inpostCGV);
$("button.continue").unbind('click', inpostCGV).bind('click', inpostCGV);
$('#checkout-payment-step h1').unbind('click', inpostCGV).bind('click', inpostCGV);
$('.delivery-option input').on('click', function (e) {
inpostBindRadio($(this), e);
});
initInpost($('.delivery-option input' + ":checked"));
if (showWeek == 0) {
$('.delivery-option').each(function() {
var idd = parseInt($(this).find('input').val());
if (inpostkey_week.indexOf(idd) > -1 || inpostkey_week_cod.indexOf(idd) > -1) {
$(this).hide();
}
});
}
}
if (checkoutInpost == 'spstepcheckout') {
setTimeout(function() {
$('.delivery-option').each(function(){
var ch = $(this).find('input.delivery_option_radio');
if (ch.is(':checked')) {
id = parseInt(ch.val());
elem = ch;
}
});
initInpost(elem);
}, 2500);
}
$('.delivery-options-list button').on('click', function(){
var val = $('.tr-inpost-box .inpostship-main .inpost-point').val();
if (val == '' && selectedPointInfo == '') {
$('#inpostshipmodal').modal();
$('#cgv').parent().removeClass('checked');
return false;
}
});
$('#inpostshipmodal .modal-footer button').on('click', function() {
$('#inpostshipmodal').modal('hide');
});
$('#inpostshipmodal .modal-header button').on('click', function() {
$('#inpostshipmodal').modal('hide');
});
$(document).on('click', '#inpostshipmodal .modal-footer button', function() {
$('#inpostshipmodal').modal('hide');
});
$(document).on('click', '#inpostshipmodal .modal-header button', function() {
$('#inpostshipmodal').modal('hide');
});
});
var assetsServer = 'https://api-pl-points.easypack24.net/v1';
function openModalMap(id) {
$('#easypack-widget').empty();
$('#easypack-map').empty();
var pointType = ['parcel_locker_only'];
if (pTypes == 1) {
pointType = ['parcel_locker', 'pop'];
}
if (mapBox == 1) {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
});
}
if (imw == 1) {
var width = 500;
var height = ($(window).height() * 0.7); // 600
} else {
var width = $(window).width() - 25;
var height = ($(window).height() -25); // 600
}
if (mapShow == 2) {
width = ($(window).width() * 0.7);
}
easyPack.modalMap(function (point, modal) {
updateInpostInfo(cart, id, point.name);
modal.closeModal();
return false;
}, {width: width, height: height});
} else {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
});
}
easyPack.mapWidget('easypack-widget', function(point) {
updateInpostInfo(cart, id, point.name);
});
}
}
function openModalMapCod(id) {
$('#easypack-widget').empty();
$('#easypack-map').empty();
var pointType = ['parcel_locker'];
if (pTypes == 1) {
pointType = ['parcel_locker', 'pop'];
}
if (mapBox == 1) {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
paymentFilter: {
visible: true,
showOnlyWithPayment: true,
}
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
paymentFilter: {
visible: false,
showOnlyWithPayment: true,
}
});
}
var width = 500;
var height = ($(window).height() * 0.7); // 600
if (mapShow == 2) {
width = ($(window).width() * 0.7);
}
easyPack.modalMap(function (point, modal) {
updateInpostInfo(cart, id, point.name);
modal.closeModal();
return false;
}, {width: width, height: height});
} else {
if (imap == 'google') {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
googleKey: imgm
},
paymentFilter: {
visible: true,
showOnlyWithPayment: true,
}
});
} else {
easyPack.init({
instance: 'pl',
defaultLocale: 'pl',
points: {
types: pointType
},
locales: 'pl',
apiEndpoint: assetsServer,
mapType: imap,
searchType: imap,
map: {
useGeolocation: true,
initialTypes: pointType,
},
paymentFilter: {
visible: true,
showOnlyWithPayment: true,
}
});
}
easyPack.mapWidget('easypack-widget', function(point) {
updateInpostInfo(cart, id, point.name);
});
}
}
function inpostCGVUncheck() {
$("#cgv").prop('checked', false);
if (typeof $.uniform != 'undefined') {
$.uniform.update();
}
}
function inpostBindRadio(el, e) {
inpostCGVUncheck();
initInpost(el, true);
}
function updateInpostInfo(id_cart, id_carrier, point) {
$('.saveInfo').remove();
var ile = 9;
if (point.indexOf('POP') > -1) {
ile = 12;
}
if (point.length < ile) {
$('.tr-inpost-box .inpostship-main').css({
'border': '1px solid #999'
});
$('.point-info').remove();
var week = 0;
if ($('.weekPack').is(':checked')){
week = 1;
}
$.ajax({
type: 'POST',
headers: {"cache-control": "no-cache"},
url: baseDirShop + 'modules/inpostship/setPoint.php',
async: false,
cache: false,
dataType: 'json',
data: 'id_cart=' + id_cart
+ '&id_carrier=' + id_carrier
+ '&point=' + point
+ '&week='+week,
success: function (jsonData) {
$('.saveInfo').remove();
if (jsonData === false) {
$('.tr-inpost-box .inpostship-main').css({
'border': '3px solid #ff0000'
});
$('.tr-inpost-box .inpostship-main').append('<small class="saveInfo text-danger">Paczkomat nie został poprawnie zapisany</small>');
} else {
$('.tr-inpost-box .inpostship-main').css({
'border': '3px solid #67A901'
});
$('.tr-inpost-box .inpostship-main').append('<p class="point-info">Wybrany paczkomat:<br /><b>' + jsonData.point_code + ', ul. ' + jsonData.point_address1 + ', ' + jsonData.point_address2 + '</b><br />' + jsonData.point_desc + '</p>');
selectedPointInfo = jsonData.point_code;
if (selectedPointInfo != '') {
$('.tr-inpost-box .inpostship-main').append('<small class="saveInfo text-success">Paczkomat został poprawnie zapisany</small>');
} else {
$('.tr-inpost-box .inpostship-main').append('<small class="saveInfo text-danger">Paczkomat nie został poprawnie zapisany</small>');
}
}
setTimeout(function() {
$('.saveInfo').remove();
}, 3000);
}
});
}
}
function updateInpostInfoCourier(id_cart, id_carrier) {
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseDirShop + 'modules/inpostship/setCourier.php',
async: false,
cache: false,
dataType: 'json',
data: 'id_cart='+id_cart+'&id_carrier='+id_carrier,
success: function(jsonData) {
}
});
}
var inpostCGVspStepCheckout = function() {
if (typeof inpostkey === "undefined") {
inpostkey = 0;
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = 0;
}
if (typeof inpostkey_week === "undefined") {
inpostkey_week = 0;
}
if (typeof inpostkey_week_cod === "undefined") {
inpostkey_week_cod = 0;
}
$('.custom-radio').each(function() {
var inp = $(this).find('input');
if (inp.is(':checked')) {
id = parseInt(inp.val());
}
});
if (isNaN(id)) {
id = parseInt($("input.delivery_option_radio:checked").val());
}
if (isNaN(id)) {
id = parseInt($(".delivery-options-list .delivery-option input:checked").val());
}
if (inpostkey.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
if (inpostkey_cod.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
if (inpostkey_week.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
if (inpostkey_week_cod.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
return false;
}
}
return true;
};
var inpostCGV = function() {
if (typeof inpostkey === "undefined") {
inpostkey = 0;
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = 0;
}
if (typeof inpostkey_week === "undefined") {
inpostkey = 0;
}
if (typeof inpostkey_week_cod === "undefined") {
inpostkey_cod = 0;
}
$('.custom-radio').each(function() {
var inp = $(this).find('input');
if (inp.is(':checked')) {
id = parseInt(inp.val());
}
});
if (isNaN(id)) {
id = parseInt($("input.delivery_option_radio:checked").val());
}
if (isNaN(id)) {
id = parseInt($(".delivery-options-list .delivery-option input:checked").val());
}
if (inpostkey.indexOf(id) > -1 || inpostkey_week.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
if (checkoutInpost == 'steasycheckout') {
$('#steco-conditions-to-approve .steco-custom-input').removeAttr('checked').next().find('i').css('display', 'none');
} else if (checkoutInpost == 'supercheckout') {
$('#supercheckout-agree input').removeAttr('checked');
} else {
$('#cgv').parent().removeClass('checked');
}
return false;
}
}
if (inpostkey_cod.indexOf(id) > -1 || inpostkey_week_cod.indexOf(id) > -1) {
if (selectedPointInfo == '') {
$('#inpostshipmodal').modal();
if (checkoutInpost == 'steasycheckout') {
$('#steco-conditions-to-approve .steco-custom-input').removeAttr('checked').next().find('i').css('display', 'none');
} else if (checkoutInpost == 'supercheckout') {
$('#supercheckout-agree input').removeAttr('checked');
} else {
$('#cgv').parent().removeClass('checked');
}
return false;
}
}
};
var initInpost = function(elem) {
if (typeof inpostkey === "undefined") {
inpostkey = [];
}
if (typeof inpostkey_cod === "undefined") {
inpostkey_cod = [];
}
if (typeof inpostkey_week === "undefined") {
inpostkey_week = [];
}
if (typeof inpostkey_week_cod === "undefined") {
inpostkey_week_cod = [];
}
inpostCGVUncheck();
id = parseInt(elem.val());
$('.tr-inpost-box').remove();
var closest = '.delivery-option';
if (checkoutInpost == 'supercheckout') {
closest = '.highlight';
$('.supercheckoutListItemInpost').remove();
}
if (inpostkey.indexOf(id) > -1 || inpostkey_week.indexOf(id) > -1) {
elem.closest(closest).after(createInpostBox(id));
if (nps == 1) {
var obj = $('.inpostship-main');
$.ajax({
url: baseDirShop + 'modules/inpostship/ajax.php',
type: 'POST',
headers: {"cache-control": "no-cache"},
async: false,
cache: false,
dataType: 'json',
data: 'action=getUserPoints',
success: function (jsonData) {
if (jsonData) {
if (jsonData.points != '') {
var htmls = '<div class="inpostNear"><h4>Paczkomaty w pobliżu Twojego adresu:</h4>';
$.each(jsonData.points, function (index, value) {
htmls += '<div class="nearInpost" data-name="' + value.name + '" data-id="' + id + '" data-cart="' + cart + '"><p><img src="https://geowidget.easypack24.net/images/desktop/icons/parcel_locker.png?4.12.8" /><b>' + value.name + '</b><br />' + value.address + '<br />' + value.desc + '</p></div>';
});
htmls += '</div>';
obj.append(htmls);
}
}
}
});
}
$.ajax({
url: baseDirShop + 'module/inpostship/customerPoint',
type: 'POST',
headers: {"cache-control": "no-cache"},
async: false,
cache: false,
dataType: 'json',
// data: 'action=getUserPoints',
success: function (jsonData) {
if (jsonData) {
if (jsonData.points != '') {
var htmls = '<div class="inpostNear"><h4>Twoje najczęściej wybierane paczkomaty:</h4>';
$.each(jsonData.points, function (index, value) {
htmls += '<div class="nearInpost" data-name="' + value.name + '" data-id="' + id + '" data-cart="' + cart + '"><p><img src="https://geowidget.easypack24.net/images/desktop/icons/parcel_locker.png?4.12.8" /><b>' + value.name + '</b><br />' + value.address +'<br />' + value.desc + '</p></div>';
});
htmls += '</div>';
obj.append(htmls);
}
}
}
});
if (selectedPointInfo != '' || selectedPointInfo != 'undefined') {
$('.tr-inpost-box .inpostship-main').append('<p class="point-info"></p>');
selectedPointInfo = selectedPointInfo.replace('|| ', '<br />').replace(';;', '<b>').replace(';; ', '</b>').replace('||', '<br />');
$('.tr-inpost-box .inpostship-main .point-info').html(selectedPointInfo);
}
} else if (inpostkey_cod.indexOf(id) > -1 || inpostkey_week_cod.indexOf(id) > -1) {
elem.closest(closest).after(createInpostBox(id, 1));
if (nps == 1) {
var obj = $('.inpostship-main');
$.ajax({
url: baseDirShop + 'modules/inpostship/ajax.php',
type: 'POST',
headers: {"cache-control": "no-cache"},
async: false,
cache: false,
dataType: 'json',
data: 'action=getUserPoints&cod=1',
success: function (jsonData) {
if (jsonData) {
if (jsonData.points != '') {
var htmls = '<div class="inpostNear"><h4>Paczkomaty w pobliżu Twojego adresu:</h4>';
$.each(jsonData, function (index, value) {
htmls += '<div class="nearInpost" data-name="' + value.name + '" data-id="' + id + '" data-cart="' + cart + '"><p><img src="https://geowidget.easypack24.net/images/desktop/icons/parcel_locker.png?4.12.8" /><b>' + value.name + '</b><br />' + value.address + '<br />' + value.desc + '</p></div>';
});
htmls += '</div>';
obj.append(htmls);
}
}
}
});
}
if (selectedPointInfo != '' || selectedPointInfo != 'undefined') {
$('.tr-inpost-box .inpostship-main').append('<p class="point-info"></p>');
selectedPointInfo = selectedPointInfo.replace('|| ', '<br />').replace(';;', '<b>').replace(';; ', '</b>').replace('||', '<br />');
$('.tr-inpost-box .inpostship-main .point-info').html(selectedPointInfo);
}
} else {
if (typeof courierkey === "undefined") {
courierkey = [];
}
if (typeof courierkey_cod === "undefined") {
courierkey_cod = [];
}
if (courierkey.indexOf(id) > -1) {
updateInpostInfoCourier(cart, id);
}
if (courierkey_cod.indexOf(id) > -1) {
updateInpostInfoCourier(cart, id);
}
}
}
function createInpostBox(idCarrier, cod = 0)
{
if (geoWidget == 4) {
var obj = $('.inpostship-main');
var html = '';
if (isTable == 1) {
html += '<tr><td colspan="4">';
}
if (checkoutInpost == 'supercheckout') {
html += '<li class="supercheckoutListItemInpost">';
}
html += '<div class="row tr-inpost-box"><div class="inpostship-main i-go"><div class="inpostship-main-box">';
html += '<table>' +
'<tbody>';
if (showWeek == 1) {
// html += '<tr><td colspan="2"><span class="custom-checkbox" style="float: left;margin-right: 15px;"><input type="checkbox" value="1" class="weekPack" /><span><i class="material-icons rtl-no-flip checkbox-checked"></i></span></span> Paczka w weekend (+' + weekPrice + ' zł)</td> </tr>';
}
html += '<tr>' +
'<td>' +
'<span class="btn btn-success btn-md btn-block openMap';
if (cod == 1) {
html += 'Cod';
}
html += '" onclick="openModalMap';
if (cod == 1) {
html += 'Cod';
}
html += '(' + idCarrier + ');">Wybierz paczkomat z mapy</span>' +
'</td>' +
'</tr>' +
'</tbody>' +
'</table>';
html += '</div><div id="easypack-widget"></div><div id="easypack-widget2"></div></div><br /></div>';
if (checkoutInpost == 'supercheckout') {
html += '</li>';
}
if (isTable == 1) {
html += '</td></tr>';
}
} else {
let config = 'parcelCollect';
if (cod == 1) {
config = 'parcelCollectPayment';
}
if (sandbox == 1) {
html = '<link rel="stylesheet" href="https://sandbox-easy-geowidget-sdk.easypack24.net/inpost-geowidget.css"/>'+
'<script src="https://sandbox-easy-geowidget-sdk.easypack24.net/inpost-geowidget.js" defer></script>';
} else {
html = '<link rel="stylesheet" href="https://geowidget.inpost.pl/inpost-geowidget.css"/>' +
'<script src="https://geowidget.inpost.pl/inpost-geowidget.js" defer></script>';
}
html += '<div class="inpostship-content row"><div class="inpostship-main-box"><span class="btn btn-success btn-md btn-block openMap" data-cod="'+cod+'">Wybierz paczkomat z mapy</span><div class="load-geo-box"></div></div></div>';
}
return html;
}
function afterPointSelected(point) {
updateInpostInfo(cart, id, point.name);
}
$(document).ready(function () {
$('.tr-inpost-box .inpostship-main .inpost-point').on('change', function(){
var vl = $(this).html();
if (vl != '' && vl != null && selectedPointInfo != '') {
var vla = vl.split(',');
updateInpostInfo(cart, inpostkey, vla[0]);
} else {
$('#cgv').removeAttr('checked');
$('#cgv').parent().removeClass('checked');
return false;
}
});
$(document).on('click', '.nearInpost', function() {
var point = $(this).data('name');
var cart = $(this).data('cart');
var id = $(this).data('id');
updateInpostInfo(cart, id, point);
});
$(document).on('click', '.openMap', function() {
let config = 'parcelCollect',
cod = $(this).data('cod');
if (cod == 1) {
config = 'parcelCollectPayment';
}
let html = '<inpost-geowidget class="inpost-geowidget-box" onpoint="afterPointSelected" token="'+geoWidgetToken+'" language="pl" config="'+config+'"></inpost-geowidget>';
$('.load-geo-box').append(html);
})
});

View File

@@ -0,0 +1,33 @@
/*window.easyPackAsyncInit = function () {
easyPack.init({
defaultLocale: 'pl',
locales: ['pl'],
assetsServer: 'https://geowidget.easypack24.net',
infoboxLibraryUrl: '/js/lib/infobox.min.js',
markersUrl: '/images/desktop/markers/',
iconsUrl: '/images/desktop/icons/',
loadingIcon: '/images/desktop/icons/ajax-loader.gif',
});
var map = easyPack.mapWidget('easypack-map', function(point) {
console.log(point);
alert(point.name, point.location_description);
});
};*/
$('.openMap').on('click', function(){
alert('xxx');
});
$(document).ready(function(){
$('.openMap').on('click', function(){
alert('xxx');
});
});
function geoMap() {
alert('xxx');
}

View File

@@ -0,0 +1,42 @@
$(document).ready(function() {
$(document).on('click', '.tablePackageList .select_one', function() {
if ($(this).is(':checked')) {
$('.generatePacked').removeAttr('disabled');
}
let count = 0;
$('.tablePackageList .select_one').each(function () {
if ($(this).is(':checked')) {
count++;
}
});
if (count == 0) {
$('.generatePacked').attr('disabled', 'disabled');
} else {
$('.generatePacked').removeAttr('disabled');
}
});
$(document).on('click', '.tablePackageList .select_all', function() {
if ($(this).is(':checked')) {
$('.generatePacked').removeAttr('disabled');
} else {
$('.generatePacked').attr('disabled', 'disabled');
}
});
$(document).on('click', '.show_products small', function() {
let show = $(this).parent().data('show');
if (show == 'off') {
$(this).text('Ukryj produkty');
$(this).parent().data('show', 'on');
$(this).closest('tr').next().show();
} else {
$(this).text('Pokaż produkty');
$(this).parent().data('show', 'off');
$(this).closest('tr').next().hide();
}
});
});

File diff suppressed because one or more lines are too long