181 lines
6.0 KiB
JavaScript
181 lines
6.0 KiB
JavaScript
$(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();
|
|
}
|
|
}
|
|
});
|
|
}
|