first commit
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
class stPaczkomatyFrontendActions extends stActions
|
||||
{
|
||||
public function executeChooseDeliveryPoint()
|
||||
{
|
||||
$delivery_id = $this->getRequestParameter('delivery_id');
|
||||
|
||||
$points = $this->getUser()->getAttribute('delivery_point', array(), 'soteshop/stPaczkomatyPlugin');
|
||||
|
||||
$points[$delivery_id] = $this->getRequestParameter('point');
|
||||
|
||||
$this->getUser()->setAttribute('delivery_point', $points, 'soteshop/stPaczkomatyPlugin');
|
||||
|
||||
return sfView::HEADER_ONLY;
|
||||
}
|
||||
|
||||
public function executeShowMap() {
|
||||
$this->smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
$this->setLayout(false);
|
||||
$this->config = stConfig::getInstance('stPaczkomatyBackend');
|
||||
|
||||
$this->cities = stPaczkomatyCites::getListofCities();
|
||||
|
||||
$delivery = DeliveryPeer::retrieveByPK($this->getRequestParameter('deliveryId'));
|
||||
|
||||
if (is_object($delivery))
|
||||
$this->machinesNamespace = $delivery->getPaczkomatyType();
|
||||
}
|
||||
|
||||
public function executeGetMachines() {
|
||||
$i18n = $this->getContext()->getI18n();
|
||||
|
||||
if ($this->getRequestParameter('machinesNamespace', 'ALL') == 'COD') {
|
||||
$data = stPaczkomatyMachines::getListOfCodMachines();
|
||||
} else {
|
||||
$data = stPaczkomatyMachines::getListOfMachines();
|
||||
}
|
||||
|
||||
return $this->renderJSON($data);
|
||||
}
|
||||
|
||||
public function executeGetMachine() {
|
||||
|
||||
return $this->renderJSON(stPaczkomatyMachines::getMachine($this->getRequestParameter('number')));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function executeGetMachineByPostCode() {
|
||||
|
||||
return $this->renderJSON(stPaczkomatyMachines::getMachineByPostCode($this->getRequestParameter('post_code')));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function executeGetMachinesByPostCode()
|
||||
{
|
||||
return $this->renderJSON(stPaczkomatyMachines::getMachinesByPostCode($this->getRequestParameter('post_code'), $this->getRequestParameter('limit')));
|
||||
}
|
||||
|
||||
public function executeGet3MachinesByPostCode() {
|
||||
|
||||
return $this->renderJSON(stPaczkomatyMachines::get3MachinesByPostCode($this->getRequestParameter('post_code')));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function executeEasyPackShow()
|
||||
{
|
||||
$config = stConfig::getInstance('stPaczkomatyBackend');
|
||||
$pickupPoint = stDeliveryTypePickupPoint::createFromJson($this->getRequestParameter('pickup_point'));
|
||||
|
||||
$smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
$smarty->assign('sandbox', $config->get('sandbox'));
|
||||
$smarty->assign('delivery_id', $this->getRequestParameter('delivery_id'));
|
||||
$smarty->assign('pickup_point_name', null !== $pickupPoint ? $pickupPoint->getName() : null);
|
||||
|
||||
if (!$config->get('sandbox'))
|
||||
{
|
||||
$smarty->assign('api_endpoint', 'https://api-pl-points.easypack24.net/v1');
|
||||
}
|
||||
else
|
||||
{
|
||||
$smarty->assign('api_endpoint', 'https://stage-api-pl-points.easypack24.net/v1');
|
||||
}
|
||||
|
||||
sfConfig::set('sf_web_debug', false);
|
||||
|
||||
return $this->renderText($smarty->fetch('easy_pack_show.html'));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class stPaczkomatyFrontendComponents extends sfComponents {
|
||||
|
||||
public function executeBasketTerms() {
|
||||
if(stPaczkomaty::isActive() == false)
|
||||
return sfView::NONE;
|
||||
|
||||
|
||||
$this->smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
$this->number = htmlspecialchars($this->getRequestParameter('user_data_billing[paczkomaty_machine_number]'));
|
||||
}
|
||||
|
||||
public function executeDeliveryOnBasketList() {
|
||||
if(stPaczkomaty::isActive() == false || !$this->delivery->getPaczkomatyType() || $this->delivery->getPaczkomatyType() == 'NONE')
|
||||
return sfView::NONE;
|
||||
|
||||
$this->smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
|
||||
$point = json_decode($this->getRequestParameter('user_data_billing[paczkomaty_machine_number]'), true);
|
||||
|
||||
$this->smarty->assign('point', $point);
|
||||
|
||||
$this->smarty->assign('id', $this->delivery->getId());
|
||||
}
|
||||
|
||||
public function executeHelper()
|
||||
{
|
||||
if ($this->getModuleName() != 'stBasket')
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
|
||||
$ids = [];
|
||||
$smarty = new stSmarty('stPaczkomatyFrontend');
|
||||
|
||||
foreach (PaymentTypePeer::doSelectCached() as $payment)
|
||||
{
|
||||
if ($payment->getIsCod())
|
||||
{
|
||||
$ids[] = $payment->getId();
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign('payments', json_encode($ids));
|
||||
$smarty->assign('endpoint', stInPostApi::getInstance()->getEndpoint());
|
||||
|
||||
return $smarty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$smarty->assign('number', $number);
|
||||
$smarty->display('paczkomaty_basket_terms.html');
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$smarty->display('paczkomaty_delivery_on_basket_list.html');
|
||||
@@ -0,0 +1 @@
|
||||
<?php $smarty->display('easy_pack_show.html') ?>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$smarty->assign('machinesNamespace', $machinesNamespace);
|
||||
$messages = array(__('Wybierz Paczkomat'),
|
||||
__('Zmień Paczkomat'),
|
||||
__('Dostawa Paczkomaty'),
|
||||
__('Proszę wybrać Paczkomat.'),
|
||||
__('Paczkomat'),
|
||||
);
|
||||
$smarty->assign('messages', json_encode($messages));
|
||||
$smarty->assign('configMapGroupPoints', $config->get('map_group_points'));
|
||||
$smarty->display('paczkomaty_show_map.html');
|
||||
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{__ text="Wybierz paczkomat"}</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://geowidget.easypack24.net/css/easypack.css?v2">
|
||||
<script async src="https://geowidget.easypack24.net/js/sdk-for-javascript.js?v2"></script>
|
||||
<script src="/js/jquery-1.8.3.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body style="position: absolute; height: 100%; width: 100%; padding: 0; margin: 0;">
|
||||
<div id="easypack-map" style="position: absolute; width: 100%; height: 100%;"></div>
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
window.easyPackAsyncInit = function () {
|
||||
var googleKey = "{/literal}{$google_api_key}{literal}";
|
||||
|
||||
function getUrlParameter(name) {
|
||||
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
||||
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
||||
var results = regex.exec(location.search);
|
||||
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||
}
|
||||
|
||||
function init(position) {
|
||||
var point = getUrlParameter('point');
|
||||
|
||||
easyPack.init({
|
||||
defaultLocale: 'pl',
|
||||
points: {
|
||||
types: ['parcel_locker']
|
||||
},
|
||||
map: {
|
||||
useGeolocation: position ? true : false,
|
||||
defaultLocation: position ? [position.coords.latitude, position.coords.longitude] : [51.9194, 19.1451],
|
||||
initialZoom: position || point ? 13 : 6,
|
||||
}
|
||||
});
|
||||
|
||||
var map = easyPack.mapWidget('easypack-map', function(point) {
|
||||
window.parent.jQuery(window.parent.document).trigger('paczkomaty.updatePoint', point);
|
||||
window.parent.jQuery('#paczkomaty_overlay').data('overlay').close();
|
||||
}, function(map) {
|
||||
|
||||
if (point) {
|
||||
map.searchLockerPoint(point);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (window.location.protocol === 'https:' && navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(init, function() { init(); });
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{/literal}
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,173 @@
|
||||
<div id="st_paczkomaty">
|
||||
<div id="paczkomaty_overlay">
|
||||
<div class="paczkomaty_overlay_content"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(document).ready(function() {
|
||||
{/literal}
|
||||
var url = "{urlfor internal='@stPaczkomatyPlugin?action=easyPackShow'}";
|
||||
var is_authenticated = {$sf_user->isAuthenticated()|string_format:"%d"};
|
||||
var shopping_cart_delivery = $('#st_basket-delivery');
|
||||
var current = shopping_cart_delivery.find('input[type="radio"]:checked');
|
||||
var selected = current.parent().find('.inpost-easypack-trigger').length > 0;
|
||||
var payments = {$payments};
|
||||
{literal}
|
||||
|
||||
$(document).on("delivery.change.started", function() {
|
||||
current = $(this);
|
||||
selected = $(this).parent().find('.inpost-easypack-trigger').length > 0;
|
||||
update();
|
||||
});
|
||||
|
||||
var i18n = {
|
||||
{/literal}
|
||||
choose_delivery_point: '{__ text="Wybierz punkt odbioru"}',
|
||||
change_delivey_point: '{__ text="Wybrany punkt nie obsługuje płatności przy odbiorze.<br>Zmień płatność lub wybierz inny punkt odbioru."}',
|
||||
{literal}
|
||||
}
|
||||
|
||||
$('#paczkomaty_overlay').overlay({
|
||||
oneInstance: false,
|
||||
onLoad: function() {
|
||||
var point = current.parent().find('.inpost-easypack').data('inpost-point');
|
||||
|
||||
if (point) {
|
||||
var src = url.indexOf('?') > -1 ? url+'&point='+point : url+'?point='+point;
|
||||
} else {
|
||||
var src = url;
|
||||
}
|
||||
|
||||
var wrap = this.getOverlay().find('.paczkomaty_overlay_content');
|
||||
|
||||
wrap.html('<iframe src="'+src+'" style="width: 100%; height: 100%; position: absolute; top: 0; left: 0; border: none" allowfullscreen></iframe>');
|
||||
},
|
||||
onClose: function () {
|
||||
var wrap = this.getOverlay().find('.paczkomaty_overlay_content');
|
||||
wrap.html('');
|
||||
},
|
||||
load: false
|
||||
});
|
||||
|
||||
var modal = $('#paczkomaty_overlay').data('overlay');
|
||||
|
||||
$.fn.paczkomatyEqualHeight = function() {
|
||||
tallest = 0;
|
||||
this.each(function() {
|
||||
$(this).css("height","auto");
|
||||
thisHeight = $(this).height();
|
||||
if(thisHeight > tallest) {
|
||||
tallest = thisHeight;
|
||||
}
|
||||
});
|
||||
this.height(tallest);
|
||||
}
|
||||
|
||||
function updateHeight() {
|
||||
$(".frame").paczkomatyEqualHeight();
|
||||
$(".data_frame").paczkomatyEqualHeight();
|
||||
}
|
||||
|
||||
function showMessage(message) {
|
||||
window.alert(message);
|
||||
}
|
||||
|
||||
function update() {
|
||||
var different_delivery = $('#different_delivery');
|
||||
shopping_cart_delivery.find('.inpost-easypack-address').hide();
|
||||
|
||||
if (selected) {
|
||||
|
||||
current.parent().find('.inpost-easypack-address').show();
|
||||
$('#paczkomaty_machine_number').prop('disabled', false);
|
||||
updateHeight();
|
||||
|
||||
if (different_delivery.prop('checked')) {
|
||||
different_delivery.get(0).click();
|
||||
}
|
||||
|
||||
different_delivery.prop('disabled', true);
|
||||
|
||||
if (is_authenticated) {
|
||||
$('#order_form_delivery').hide();
|
||||
$('#order_form_billing').parent().addClass('col-sm-push-6');
|
||||
}
|
||||
} else {
|
||||
different_delivery.prop('disabled', false);
|
||||
|
||||
$('#paczkomaty_machine_number').prop('disabled', true);
|
||||
updateHeight();
|
||||
|
||||
if (is_authenticated) {
|
||||
$('#order_form_delivery').show();
|
||||
$('#order_form_billing').parent().removeClass('col-sm-push-6');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateDeliveryPoint() {
|
||||
if (selected) {
|
||||
var payment_id = $('#st_basket-payment input[type=radio]:checked').val();
|
||||
|
||||
if (current.parent().find('.inpost-easypack-address').is(':empty')) {
|
||||
showMessage(i18n.choose_delivery_point);
|
||||
return false;
|
||||
}
|
||||
|
||||
var cod = current.parent().find('.inpost-easypack').data('inpost-cod');
|
||||
|
||||
if (!cod && (payments.indexOf(payment_id) > -1 || payments.indexOf(Number(payment_id)) > -1)) {
|
||||
showMessage(i18n.change_delivey_point);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function addressFormat(point) {
|
||||
var address = [];
|
||||
|
||||
var ad = point.address_details;
|
||||
|
||||
address.push('<b>'+point.name+'</b>');
|
||||
address.push(ad.street+' '+ad.building_number+(ad.flat_number ? '/'+ad.flat_number : ''));
|
||||
address.push(ad.post_code+' '+ad.city);
|
||||
|
||||
return address.join('<br>');
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
$('#user_delivery_form').submit(validateDeliveryPoint);
|
||||
|
||||
$(document).on('delivery.change.started', function(e, delivery) {
|
||||
current = $(delivery);
|
||||
|
||||
selected = current.parent().find('.inpost-easypack-trigger').length > 0;
|
||||
update();
|
||||
});
|
||||
|
||||
$(document).on('paczkomaty.updatePoint', function(event, point) {
|
||||
var address = addressFormat(point);
|
||||
var cod = point.name.indexOf('POP-') === -1;
|
||||
current.get(0).click();
|
||||
current.parent().find('.inpost-easypack-address').html(addressFormat(point));
|
||||
current.parent().find('.inpost-easypack').data('inpost-point', point.name).data('inpost-cod', cod);
|
||||
|
||||
$('#paczkomaty_machine_number').val(JSON.stringify({ name: point.name, address: point.address_details, "cod": cod }));
|
||||
updateHeight();
|
||||
});
|
||||
|
||||
shopping_cart_delivery.on('click', '.inpost-easypack-trigger', function() {
|
||||
current = $(this).closest('li').find('input[type="radio"]');
|
||||
modal.load();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1 @@
|
||||
<input type="hidden" id="paczkomaty_machine_number" name="user_data_billing[paczkomaty_machine_number]" value="{$number}"/>
|
||||
@@ -0,0 +1,14 @@
|
||||
{use_stylesheet src="stPaczkomatyPlugin.css"}
|
||||
|
||||
<div data-delivery-id="{$id}" class="inpost-easypack"{if $point} data-inpost-point="{$point.name}" data-inpost-cod="{$point.cod}"{/if}>
|
||||
<a href="#" class="inpost-easypack-trigger">{__ text="Wybierz Paczkomat"}</a>
|
||||
{if $point}
|
||||
<div class="inpost-easypack-address">
|
||||
<b>{$point.name}</b><br>
|
||||
{$point.address.street} {$point.address.building_number}{if $point.address.flat_number} / {$point.address.flat_number}{/if}<br>
|
||||
{$point.address.post_code} {$point.address.city}
|
||||
</div>
|
||||
{else}
|
||||
<div class="inpost-easypack-address" style="display: none;"></div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,62 @@
|
||||
<div id="st_paczkomaty">
|
||||
<div id="paczkomaty_overlay">
|
||||
<div class="paczkomaty_overlay_content"></div>
|
||||
</div>
|
||||
</div>
|
||||
{literal}
|
||||
<script type="text/javascript" src="{/literal}{$mapJsUrl}{literal}"></script>
|
||||
<script type="text/javascript" language="javascript">
|
||||
jQuery(function ($) {
|
||||
var messages = {/literal}{$messages}{literal}
|
||||
|
||||
$(document).ready(function() {
|
||||
{/literal}
|
||||
{if $number != ''}
|
||||
$.paczkomatySelectMachine('{$number}', messages);
|
||||
{/if}
|
||||
{literal}
|
||||
$('.st_delivery-default').click(function() {
|
||||
$.paczkomatyRestoreBasket(messages);
|
||||
});
|
||||
|
||||
$('.st_delivery-label').click(function() {
|
||||
$.paczkomatyRestoreBasket(messages);
|
||||
});
|
||||
|
||||
$('#user_delivery_form').submit(function() {
|
||||
var deliveryIdChecked = $('input.st_delivery-default:checked').val();
|
||||
|
||||
if($('#st_paczkomaty_delivery-' + deliveryIdChecked).length && !$('#st_paczkomaty_delivery_address-' + deliveryIdChecked).is(':visible')) {
|
||||
alert(messages[3]);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#st_basket-delivery').on('click', '.paczkomaty_active_overlay', function() {
|
||||
$.paczkomatyRestoreBasket(messages);
|
||||
|
||||
var deliveryId = $(this).data('delivery-id');
|
||||
|
||||
$("#delivery_default_delivery-" + deliveryId).prop('checked', true);
|
||||
$("#delivery_default_delivery-" + deliveryId).trigger('click');
|
||||
|
||||
$('#paczkomaty_overlay').data('overlay', '');
|
||||
$('#paczkomaty_overlay').overlay({
|
||||
oneInstance: false,
|
||||
onBeforeLoad: function() {
|
||||
var wrap = this.getOverlay().find('.paczkomaty_overlay_content');
|
||||
$.get('{/literal}{$mapUrl}{literal}/' + deliveryId, function(data) {
|
||||
wrap.html(data);
|
||||
});
|
||||
},
|
||||
onClose: function () {
|
||||
var wrap = this.getOverlay().find('.paczkomaty_overlay_content');
|
||||
wrap.html('');
|
||||
},
|
||||
load: true
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1,238 @@
|
||||
<div id="st_paczkomaty_map_content_loading">
|
||||
<img src="/images/frontend/theme/default2/loading.gif" alt=""/>
|
||||
</div>
|
||||
<div id="st_paczkomaty_map_content">
|
||||
<div id="st_paczkomaty_map_post_code">
|
||||
<h3>{__ text="Podaj kod pocztowy"}</h3>
|
||||
<div class="clear"></div>
|
||||
<div id="st_paczkomaty_map_post_code_error">
|
||||
<img src="{image_path image='exclamation.png'}" title="{__ text="Podany kod pocztowy jest nieprawidłowy."}" alt="{__ text="Podany kod pocztowy jest nieprawidłowy."}">
|
||||
</div>
|
||||
<input id="st_paczkomaty_map_post_code_input" name="st_paczkomaty_map_post_code_input" type="text" placeholder="__-___">
|
||||
<input id="st_paczkomaty_map_post_code_button" type="button" value="{__ text="Szukaj"}">
|
||||
</div>
|
||||
<div id="st_paczkomaty_map_cities_box">
|
||||
<h3>{__ text="Wybierz miasto"}</h3>
|
||||
<div class="clear"></div>
|
||||
<select id="st_paczkomaty_map_cities_list">
|
||||
<option value="NONE">-- {__ text="wszystkie lokalizacje"} --</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="st_paczkomaty_map_list_box">
|
||||
<h3>{__ text="Wybierz Paczkomat"}</h3>
|
||||
<div class="clear"></div>
|
||||
<div id="st_paczkomaty_map_machines_list_div">
|
||||
<ul id="st_paczkomaty_map_machines_list">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="map_canvas" style="height: 95%; position: absolute; right: 1%; top: 3%; width: 69%;"/>
|
||||
{literal}
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
function selectMachine(number) {
|
||||
jQuery(function ($) {
|
||||
if ($('#paczkomaty_overlay').data('overlay'))
|
||||
$('#paczkomaty_overlay').data('overlay').close();
|
||||
|
||||
var messages = {/literal}{$messages}{literal}
|
||||
|
||||
$.paczkomatySelectMachine(number, messages);
|
||||
});
|
||||
};
|
||||
|
||||
jQuery(function ($) {
|
||||
function createMachine(marker) {
|
||||
return '<li class="st_paczkomaty_map_machines_list_element" ' +
|
||||
' data-maps-city="' + marker.city +
|
||||
'" data-maps-machine-name="' + marker.number +
|
||||
'" data-maps-latitude="' + marker.latitude +
|
||||
'" data-maps-longitude="' + marker.longitude + '">' +
|
||||
'<b>' + marker.number + '</b>, ' + marker.street + ' ' + marker.house + ',<br />' +
|
||||
marker.postCode + ' ' + marker.city +
|
||||
'</li>';
|
||||
}
|
||||
$(document).ready(function () {
|
||||
|
||||
var messages = {/literal}{$messages}{literal}
|
||||
var allMarkers = [];
|
||||
var allMachines = [];
|
||||
var machinesNames = {};
|
||||
|
||||
$('#st_paczkomaty_map_post_code_input').mask('00-000');
|
||||
|
||||
$("#st_paczkomaty_map_content_loading img").css('margin-top', $("#st_paczkomaty_map_content").height()/2);
|
||||
var machines_list = $('#st_paczkomaty_map_machines_list');
|
||||
$.getJSON('/paczkomaty/getMachines/machinesNamespace/{/literal}{$machinesNamespace}{literal}', function(data) {
|
||||
|
||||
$('#map_canvas').gmap({'center': "52,20"}).bind('init', function(ev, map) {
|
||||
$('#map_canvas').gmap('option', 'zoom', 6);
|
||||
|
||||
var cities = [];
|
||||
var results = '';
|
||||
$.each(data, function(i, marker) {
|
||||
|
||||
if (marker.city == 'Bielsko Biała') {
|
||||
marker.city = 'Bielsko-Biała';
|
||||
} else if (marker.city == 'Bialystok') {
|
||||
marker.city = 'Białystok';
|
||||
}
|
||||
|
||||
|
||||
if ($.inArray(marker.city, cities) === -1) {
|
||||
$('#st_paczkomaty_map_cities_list').append($('<option>', {
|
||||
value: marker.city,
|
||||
text: marker.city
|
||||
}));
|
||||
cities.push(marker.city);
|
||||
}
|
||||
|
||||
results += createMachine(marker);
|
||||
allMachines[i] = marker;
|
||||
machinesNames[marker.number] = i;
|
||||
|
||||
|
||||
m = $('#map_canvas').gmap('addMarker', {
|
||||
'position': new google.maps.LatLng(marker.latitude, marker.longitude),
|
||||
'icon': '/images/frontend/theme/default2/stPaczkomatyPlugin/marker-' + marker.cod + '.png',
|
||||
'bounds': true
|
||||
});
|
||||
|
||||
allMarkers[i] = m;
|
||||
|
||||
m.click(function() {
|
||||
var content = "<div id=\"st_paczkomaty_map_machine\">" +
|
||||
" <p id=\"st_paczkomaty_map_machine_name\">" + messages[4] + " " + marker.number + "</p>" +
|
||||
" <div id=\"st_paczkomaty_map_machine_address\">" +
|
||||
" " + marker.street + ' ' + marker.house + "<br />" +
|
||||
" " + marker.postCode + ' ' + marker.city + "<br />" +
|
||||
" </div>" +
|
||||
" <div id=\"st_paczkomaty_map_machine_button\" class=\"buttons\">" +
|
||||
" <a href=\"#st_basket-delivery\" onClick=\"selectMachine('" + marker.number + "');\" class=\"buttons\">" + messages[0] + "</a>" +
|
||||
" </div>" +
|
||||
"</div>";
|
||||
$('#map_canvas').gmap('openInfoWindow', { 'content': content }, this);
|
||||
});
|
||||
});
|
||||
machines_list.html(results);
|
||||
{/literal}{if $configMapGroupPoints}{literal}
|
||||
var clusterStyles = [{
|
||||
url: '/images/frontend/theme/default2/stPaczkomatyPlugin/markerClusterer.png',
|
||||
height: 36,
|
||||
width: 26,
|
||||
anchorText: [12, 0]
|
||||
}, {
|
||||
url: '/images/frontend/theme/default2/stPaczkomatyPlugin/markerClusterer.png',
|
||||
height: 36,
|
||||
width: 26,
|
||||
anchorText: [12, 0]
|
||||
}, {
|
||||
url: '/images/frontend/theme/default2/stPaczkomatyPlugin/markerClusterer.png',
|
||||
height: 36,
|
||||
width: 26,
|
||||
anchorText: [12, 0]
|
||||
}
|
||||
];
|
||||
|
||||
var mcOptions = {
|
||||
gridSize: 50,
|
||||
styles: clusterStyles,
|
||||
};
|
||||
|
||||
$('#map_canvas').gmap('set', 'MarkerClusterer', new MarkerClusterer(map, $(this).gmap('get', 'markers'), mcOptions));
|
||||
{/literal}{/if}{literal}
|
||||
$('#st_paczkomaty_map_content').show();
|
||||
$('#st_paczkomaty_map_content_loading').hide();
|
||||
machines = $('#st_paczkomaty_map_machines_list_div li');
|
||||
});
|
||||
});
|
||||
|
||||
$('#st_paczkomaty_map_cities_list').change(function() {
|
||||
var selected= $(this).val();
|
||||
$('#st_paczkomaty_map_post_code_input').val('');
|
||||
var results = '';
|
||||
if (selected == 'NONE') {
|
||||
$('#map_canvas').gmap('get', 'map').setCenter({lat: 52.12, lng: 18.9});
|
||||
$('#map_canvas').gmap('option', 'zoom', 6);
|
||||
$.each(allMachines, function() {
|
||||
if (this.number) {
|
||||
results += createMachine(this);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.each(allMachines, function() {
|
||||
if (this.city == selected) {
|
||||
results += createMachine(this);
|
||||
}
|
||||
});
|
||||
$('#map_canvas').gmap('search', { 'address': selected}, function(results, status) {
|
||||
if ( status === 'OK' ) {
|
||||
$('#map_canvas').gmap('get', 'map').panTo(results[0].geometry.location);
|
||||
$('#map_canvas').gmap('option', 'zoom', 11);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
machines_list.html(results);
|
||||
});
|
||||
|
||||
$("#st_paczkomaty_map_post_code_error img[title]").tooltip({
|
||||
effect: 'slide',
|
||||
opacity: 1,
|
||||
position: 'bottom right',
|
||||
offset: [15,4],
|
||||
tipClass: 'alert_tooltip'
|
||||
});
|
||||
|
||||
function setMapToPostCode() {
|
||||
var postCode = $('#st_paczkomaty_map_post_code_input').val();
|
||||
$('#st_paczkomaty_map_content').hide();
|
||||
$('#st_paczkomaty_map_content_loading').show();
|
||||
|
||||
$('#st_paczkomaty_map_cities_list').val("NONE");
|
||||
$.getJSON('/paczkomaty/getMachineByPostCode/' + postCode, function(machine) {
|
||||
if (machine.name) {
|
||||
$('#map_canvas').gmap('get', 'map').panTo(new google.maps.LatLng(machine.latitude, machine.longitude));
|
||||
$('#map_canvas').gmap('option', 'zoom', 13);
|
||||
$("#st_paczkomaty_map_post_code_error").css('display', 'none');
|
||||
$.getJSON('/paczkomaty/getMachinesByPostCode/' + machine.postcode + '/10', function(data) {
|
||||
var results = '';
|
||||
$.each(data, function() {
|
||||
var index = machinesNames[this.name];
|
||||
results += createMachine(allMachines[index]);
|
||||
});
|
||||
|
||||
machines_list.html(results);
|
||||
$('#st_paczkomaty_map_content').show();
|
||||
$('#st_paczkomaty_map_content_loading').hide();
|
||||
});
|
||||
} else {
|
||||
$("#st_paczkomaty_map_post_code_error").css('display', 'inline');
|
||||
$('#st_paczkomaty_map_content').show();
|
||||
$('#st_paczkomaty_map_content_loading').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
$('#st_paczkomaty_map_post_code_button').click(function() {
|
||||
setMapToPostCode();
|
||||
});
|
||||
|
||||
$('#st_paczkomaty_map_post_code_input').keypress(function(e) {
|
||||
if (e.which == 13)
|
||||
setMapToPostCode();
|
||||
});
|
||||
|
||||
machines_list.on("click", ".st_paczkomaty_map_machines_list_element", function(event){
|
||||
$('#map_canvas').gmap('get', 'map').panTo(new google.maps.LatLng($(this).data('maps-latitude'), $(this).data('maps-longitude')));
|
||||
$('#map_canvas').gmap('option', 'zoom', 13);
|
||||
var index = machinesNames[$(this).data('maps-machine-name')];
|
||||
allMarkers[index].triggerEvent('click');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1 @@
|
||||
<iframe src="{pickup_point_url internal_url='@stPaczkomatyPlugin?action=easyPackShow'}" style="width: 100%; height: 500px; top: 0; left: 0; border: none" allowfullscreen></iframe>
|
||||
@@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{__ text="Wybierz paczkomat"}</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://geowidget.easypack24.net/css/easypack.css?v3">
|
||||
<script async src="https://geowidget.easypack24.net/js/sdk-for-javascript.js?v3"></script>
|
||||
<script src="/js/jquery-1.8.3.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body style="position: absolute; height: 100%; width: 100%; padding: 0; margin: 0;">
|
||||
<div id="easypack-map" style="position: absolute; width: 100%; height: 100%; padding-top: 56px"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
const apiEndpoint = "{$api_endpoint}";
|
||||
const pointName = "{$pickup_point_name}";
|
||||
|
||||
{literal}
|
||||
window.easyPackAsyncInit = function () {
|
||||
easyPack.init({
|
||||
defaultLocale: 'pl',
|
||||
apiEndpoint: apiEndpoint,
|
||||
points: {
|
||||
types: ['parcel_locker']
|
||||
},
|
||||
map: {
|
||||
useGeolocation: true,
|
||||
initialZoom: 13,
|
||||
}
|
||||
});
|
||||
|
||||
const map = easyPack.mapWidget('easypack-map', function(point) {
|
||||
let address = point.address_details.street;
|
||||
|
||||
if (point.address_details.building_number) {
|
||||
address += ' ' + point.address_details.building_number;
|
||||
}
|
||||
|
||||
if (point.address_details.flat_number) {
|
||||
address += '/' + point.address_details.flat_number;
|
||||
}
|
||||
|
||||
window.parent.jQuery.deliveryModal.showPreloader();
|
||||
|
||||
$.get(apiEndpoint + '/points/' + point.name, function(response) {
|
||||
window.parent.jQuery.delivery.updatePickupPoint(response.name, response.name, address, response.address_details.post_code, response.address_details.city, 'PL', response.payment_available, response.location_247);
|
||||
});
|
||||
}, function(map) {
|
||||
if (pointName) {
|
||||
map.searchLockerPoint(pointName);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
{/literal}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,236 @@
|
||||
<div class="modal fade" id="inpost-easypack" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document" style="width: 1150px; height: 98%; max-width: 98%; margin: 0.5% auto 0 auto; padding: 0">
|
||||
<div class="modal-content" style="width: 100%; height: 100%; padding: 0">
|
||||
<div class="modal-header text-left" style="position: relative; z-index: 1">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Wybierz paczkomat</h4>
|
||||
</div>
|
||||
<div class="modal-body" style="position: absolute; width: 100%; padding: 0; top: 0; height: 100%; margin: 0"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade modal-vertical-centered" id="inpost-message-modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-md" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header text-left">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">{__ text="InPost - Paczkomaty"}</h4>
|
||||
</div>
|
||||
<div class="modal-body text-center"></div>
|
||||
<div class="modal-footer">
|
||||
<div class="text-center">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{__ text="Zamknij"}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
jQuery(function ($) {
|
||||
{
|
||||
/literal}
|
||||
var url = "{urlfor internal='@stPaczkomatyPlugin?action=easyPackShow'}";
|
||||
var is_authenticated = { $sf_user-> isAuthenticated() | string_format:"%d"
|
||||
};
|
||||
var shopping_cart_delivery = $('#shopping-cart-delivery');
|
||||
var current = shopping_cart_delivery.find('.delivery-radio:checked');
|
||||
var selected = current.parent().find('.inpost-easypack-trigger').length > 0;
|
||||
var payments = { $payments };
|
||||
var apiEndpoint = "{$endpoint}";
|
||||
{ literal }
|
||||
|
||||
var i18n = {
|
||||
{
|
||||
/literal}
|
||||
choose_delivery_point: '{__ text="Wybierz punkt odbioru."}',
|
||||
change_delivey_point: '{__ text="Wybrany punkt nie obsługuje płatności przy odbiorze.<br>Zmień płatność lub wybierz inny punkt odbioru."}',
|
||||
delivery_point_does_not_exist: '{__ text="Wybrany punkt został wyłączony lub nie istnieje."}'
|
||||
{ literal }
|
||||
}
|
||||
|
||||
function showMessage(message) {
|
||||
var modal = $('#inpost-message-modal');
|
||||
modal.find('.modal-body').html(message);
|
||||
modal.modal('show');
|
||||
}
|
||||
|
||||
function setParameter(name, value) {
|
||||
var storage = window.localStorage;
|
||||
storage.setItem(name, typeof value === 'object' ? JSON.stringify(value) : value);
|
||||
}
|
||||
|
||||
function getParameter(name, defaultValue = null) {
|
||||
var storage = window.localStorage;
|
||||
var value = storage.getItem(name);
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) { }
|
||||
|
||||
return value ? value : defaultValue;
|
||||
}
|
||||
|
||||
function pointUpdate() {
|
||||
var point = getParameter('inpost_pickup_point');
|
||||
|
||||
if (point) {
|
||||
$(document).trigger('paczkomaty.updatePoint', point, false);
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
var different_delivery = $('#different_delivery');
|
||||
|
||||
if (selected) {
|
||||
shopping_cart_delivery.data('delivery-type', 'inpost-paczkomaty');
|
||||
shopping_cart_delivery.attr('data-delivery-type', 'inpost-paczkomaty');
|
||||
}
|
||||
|
||||
var update = shopping_cart_delivery.data('delivery-type') == 'inpost-paczkomaty';
|
||||
|
||||
if (selected) {
|
||||
|
||||
current.parent().find('.inpost-easypack-address').show();
|
||||
$('#paczkomaty_machine_number').prop('disabled', false);
|
||||
|
||||
$(window).trigger('resize');
|
||||
|
||||
if (update) {
|
||||
if (different_delivery.prop('checked')) {
|
||||
different_delivery.get(0).click();
|
||||
}
|
||||
|
||||
different_delivery.prop('disabled', true);
|
||||
|
||||
if (is_authenticated) {
|
||||
$('#order_form_delivery').hide();
|
||||
$('#order_form_billing').parent().addClass('col-sm-push-6');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
shopping_cart_delivery.find('.inpost-easypack-address').hide();
|
||||
$('#paczkomaty_machine_number').prop('disabled', true);
|
||||
$(window).trigger('resize');
|
||||
|
||||
if (update) {
|
||||
different_delivery.prop('disabled', false);
|
||||
if (is_authenticated) {
|
||||
$('#order_form_delivery').show();
|
||||
$('#order_form_billing').parent().removeClass('col-sm-push-6');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function validateDeliveryPoint() {
|
||||
if (selected) {
|
||||
const point = getParameter('inpost_pickup_point');
|
||||
let payment_id = $('#shopping-cart-payment .radio input[type=radio]:checked').val();
|
||||
|
||||
if (!point) {
|
||||
showMessage(i18n.choose_delivery_point);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (point.status != 'Operating') {
|
||||
showMessage(i18n.delivery_point_does_not_exist);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!point.payment_available && (payments.indexOf(payment_id) > -1 || payments.indexOf(Number(payment_id)) > -1)) {
|
||||
showMessage(i18n.change_delivey_point);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function addressFormat(point) {
|
||||
var address = [];
|
||||
|
||||
var ad = point.address_details;
|
||||
|
||||
address.push('<b>' + point.name + '</b>');
|
||||
address.push(ad.street + ' ' + ad.building_number + (ad.flat_number ? '/' + ad.flat_number : ''));
|
||||
address.push(ad.post_code + ' ' + ad.city);
|
||||
|
||||
return address.join('<br>');
|
||||
}
|
||||
|
||||
$('#user_delivery_form').submit(validateDeliveryPoint);
|
||||
|
||||
shopping_cart_delivery.on('change', '.delivery-radio', function () {
|
||||
current = $(this);
|
||||
selected = $(this).parent().find('.inpost-easypack-trigger').length > 0;
|
||||
pointUpdate();
|
||||
update();
|
||||
});
|
||||
|
||||
$(document).on('paczkomaty.ajaxUpdate', function () {
|
||||
current = shopping_cart_delivery.find('.delivery-radio:checked');
|
||||
selected = current.parent().find('.inpost-easypack-trigger').length > 0;
|
||||
pointUpdate();
|
||||
update();
|
||||
});
|
||||
|
||||
$(document).on('paczkomaty.updatePoint', function (event, point, withClick = true) {
|
||||
var address = addressFormat(point);
|
||||
|
||||
$(document).trigger('delivery.update.started');
|
||||
$.get(apiEndpoint + '/points/' + point.name, function (response) {
|
||||
point.payment_available = response.payment_available;
|
||||
|
||||
if (selected || !withClick) {
|
||||
$(document).trigger('delivery.update.finished');
|
||||
} else {
|
||||
current.click();
|
||||
}
|
||||
|
||||
if (response.status != '404') {
|
||||
point = response;
|
||||
} else {
|
||||
point.status = response.status;
|
||||
}
|
||||
|
||||
current.parent().find('.inpost-easypack-address').html(addressFormat(point));
|
||||
current.parent().find('.inpost-easypack').data('inpost-point', point.name).data('inpost-cod', point.payment_available);
|
||||
|
||||
$('#paczkomaty_machine_number').val(JSON.stringify({ name: point.name, address: point.address_details, "cod": point.payment_available }));
|
||||
setParameter('inpost_pickup_point', point);
|
||||
|
||||
$(window).trigger('resize');
|
||||
});
|
||||
});
|
||||
|
||||
shopping_cart_delivery.on('click', '.inpost-easypack-trigger', function () {
|
||||
current = $(this).closest('.radio').find('.delivery-radio');
|
||||
$('#inpost-easypack').modal('show');
|
||||
});
|
||||
|
||||
$('#inpost-easypack').on('show.bs.modal', function (event) {
|
||||
var point = current.parent().find('.inpost-easypack').data('inpost-point');
|
||||
|
||||
if (point) {
|
||||
var src = url.indexOf('?') > -1 ? url + '&point=' + point : url + '?point=' + point;
|
||||
} else {
|
||||
var src = url;
|
||||
}
|
||||
|
||||
$(this).find('.modal-body').find('iframe').remove();
|
||||
|
||||
$(this).find('.modal-body').html('<iframe src="' + src + '" style="width: 100%; height: 100%; position: absolute; top: 0; left: 0; border: none" allowfullscreen></iframe>');
|
||||
});
|
||||
|
||||
update();
|
||||
|
||||
if (selected) {
|
||||
pointUpdate();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1 @@
|
||||
<input type="hidden" id="paczkomaty_machine_number" name="user_data_billing[paczkomaty_machine_number]" value="{$number}"/>
|
||||
@@ -0,0 +1,4 @@
|
||||
<div data-delivery-id="{$id}" class="inpost-easypack">
|
||||
<a href="#" class="btn btn-default inpost-easypack-trigger">{__ text="Wybierz Paczkomat"}</a>
|
||||
<div class="inpost-easypack-address" style="display: none;"></div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user