first commit
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
class stPocztaPolskaBackendComponents extends autostPocztaPolskaBackendComponents
|
||||
{
|
||||
public function executeOrderDelivery()
|
||||
{
|
||||
/**
|
||||
* @var Order @order
|
||||
*/
|
||||
$order = $this->order;
|
||||
|
||||
|
||||
|
||||
if (!stConfig::getInstance('stPocztaPolskaBackend')->get('enabled') || $order->getOrderDelivery() === null || !$order->isAllegroOrder() && $order->getOrderDelivery()->getDelivery() === null)
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$delivery = $order->getOrderDelivery()->getDelivery();
|
||||
|
||||
|
||||
|
||||
if (!$order->isAllegroOrder() && !$delivery->isType('ppo') && !$delivery->isType('ppk') || $order->isAllegroOrder() && null === stPocztaPolskaClient::getServiceByAllegroDeliveryMethodId($order->getOrderDelivery()->getOptAllegroDeliveryMethodId()))
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
|
||||
$this->paczka = PocztaPolskaPaczkaPeer::retrieveByOrder($order);
|
||||
}
|
||||
|
||||
public function executeCreatePackageForm()
|
||||
{
|
||||
$this->service = $this->package->getService();
|
||||
|
||||
$this->bufor = $this->package->getBufor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
generator:
|
||||
class: stAdminGenerator
|
||||
param:
|
||||
model_class: PocztaPolskaBufor
|
||||
packages_model_class: PocztaPolskaPaczka
|
||||
sent_model_class: PocztaPolskaPaczka
|
||||
package_model_class: PocztaPolskaPaczka
|
||||
|
||||
theme: simple
|
||||
label: Poczta Polska
|
||||
route: "@stPocztaPolskaBackend"
|
||||
icon: stPocztaPolskaPlugin
|
||||
|
||||
documentation:
|
||||
pl: https://www.sote.pl/docs/poczta-polska-integracja
|
||||
en: https://www.sote.pl/docs/poczta-polska-integracja
|
||||
|
||||
custom_actions:
|
||||
list: [sent, packages]
|
||||
edit: [package]
|
||||
|
||||
config:
|
||||
use_javascript: ["/plugins/stPocztaPolskaPlugin/js/backend/script.js"]
|
||||
title: Konfiguracja
|
||||
menu: {use: list.menu}
|
||||
display:
|
||||
"Konfiguracja": [enabled, test_mode, login, password, _urzad_nadania, slownik, przesylka_biznesowa_gabaryt]
|
||||
"Informacje o nadawcy na paczce": [is_company, _company, name, surname, email, phone, address, zip_code, town, country, region]
|
||||
"Adres zwrotu": [return_address_enabled, return_address_name, return_address_address, return_address_zip_code, return_address_town]
|
||||
"Rachunek dla pobrania": [rachunek1, rachunek2, rachunek3]
|
||||
|
||||
fields:
|
||||
przesylka_biznesowa_gabaryt: {name: Przesyłka biznesowa - Gabaryt, callback: st_poczta_polska_przesylka_biznesowa_gabaryt_select_tag}
|
||||
info: {hide_label: true}
|
||||
enabled: {name: Włącz, type: checkbox}
|
||||
is_company: {name: Firma, type: checkbox}
|
||||
company: {name: Nazwa firmy, required: true}
|
||||
test_mode: {name: Tryb testowy, type: checkbox}
|
||||
login: {name: Login, required: true, params: autocomplete="new-password"}
|
||||
password: {name: Hasło, type: password, required: true, params: autocomplete="new-password"}
|
||||
name: {name: Imię, required: true}
|
||||
surname: {name: Nazwisko, required: true}
|
||||
region: {name: Województwo, required: true}
|
||||
zip_code: {name: Kod pocztowy, required: true}
|
||||
town: {name: Miasto, required: true}
|
||||
phone: {name: Telefon, required: true}
|
||||
address: {name: Adres, required: true}
|
||||
email: {name: Adres e-mail}
|
||||
urzad_nadania: {name: Domyślny urząd nadania}
|
||||
rachunek1: {name: Podstawowy numer rachunku, required: true, params: size=36}
|
||||
rachunek2: {name: Pomocniczy numer rachunku 1, params: size=36 }
|
||||
rachunek3: {name: Pomocniczy numer rachunku 2, params: size=36 }
|
||||
slownik: {name: Zawartość dla opisu przesyłki, help: Poszczególne wartości rozdzielić znakiem | (wartość 1 | wartość 2 | itd...), params: size=60}
|
||||
country: {name: Kraj, callback: st_poczta_polska_countries_select_tag, required: true}
|
||||
return_address_enabled: {name: "Włącz", type: checkbox_tag}
|
||||
return_address_name: {name: Nazwa, required: true}
|
||||
return_address_address: {name: Adres, required: true}
|
||||
return_address_zip_code: {name: Kod pocztowy, required: true}
|
||||
return_address_town: {name: Miasto, required: true}
|
||||
actions:
|
||||
_save: {name: Zapisz}
|
||||
|
||||
list:
|
||||
menu:
|
||||
display: [bufor_list, sent_list, config]
|
||||
fields:
|
||||
sent_list: {name: Wysłane, action: @stPocztaPolskaBackend?action=sentList}
|
||||
bufor_list: {name: Do wysłania, action: @stPocztaPolskaBackend?action=list}
|
||||
config: {name: Konfiguracja, action: @stPocztaPolskaBackend?action=config}
|
||||
use_helper: [stPocztaPolska]
|
||||
title: Do wysłania
|
||||
display: [=data_nadania, =urzad_nadania, =count_paczka]
|
||||
fields:
|
||||
data_nadania: {name: Data nadania, params: link_to="@stPocztaPolskaBackend?action=packagesList&bufor_id=%%bufor_id%%"}
|
||||
urzad_nadania: {name: Urząd nadania, callback: st_poczta_polska_list_urzad_nadania, params: link_to="@stPocztaPolskaBackend?action=packagesList&bufor_id=%%bufor_id%%"}
|
||||
count_paczka: {name: Ilość przesyłek, params: link_to="@stPocztaPolskaBackend?action=packagesList&bufor_id=%%bufor_id%%"}
|
||||
object_actions:
|
||||
send: {name: "Wyślij", action: "@stPocztaPolskaBackend?action=packagesList&bufor_id=%%bufor_id%%"}
|
||||
_delete: -
|
||||
select_actions: []
|
||||
custom_actions: []
|
||||
actions: []
|
||||
|
||||
packages_list:
|
||||
menu: -
|
||||
use_helper: [stPocztaPolska]
|
||||
forward_parameters: [bufor_id]
|
||||
build_options:
|
||||
related_id: forward_parameters.bufor_id
|
||||
related_class: PocztaPolskaBufor
|
||||
related_field: bufor_id
|
||||
title: Do wysłania
|
||||
display: [numer_nadania, guid, order_number, actions]
|
||||
fields:
|
||||
numer_nadania: {name: Numer nadania}
|
||||
order_number: {name: Zamówienie, callback: st_poczta_polska_list_order_number}
|
||||
actions: {name: "", callback: st_poczta_polska_package_list_actions, width: 1%}
|
||||
object_actions:
|
||||
_delete: -
|
||||
actions:
|
||||
_delete: -
|
||||
|
||||
|
||||
sent_list:
|
||||
use_helper: [stPocztaPolska]
|
||||
title: Wysłane
|
||||
display: [numer_nadania, order_number, actions]
|
||||
fields:
|
||||
numer_nadania: {name: Numer nadania}
|
||||
order_number: {name: Zamówienie, callback: st_poczta_polska_list_order_number}
|
||||
actions: {name: "", callback: st_poczta_polska_sent_list_actions, width: 1%}
|
||||
menu: {use: list.menu}
|
||||
|
||||
select_actions: []
|
||||
custom_actions: []
|
||||
actions: []
|
||||
|
||||
package_edit:
|
||||
title: Przygotowanie paczki
|
||||
forward_parameters: [order_id, bufor_id]
|
||||
|
||||
|
||||
@@ -0,0 +1,486 @@
|
||||
<?php
|
||||
|
||||
use_helper('stAdminGenerator', 'Countries');
|
||||
|
||||
function st_poczta_polska_list_order_number(PocztaPolskaPaczka $paczka)
|
||||
{
|
||||
return '<a href="'.st_url_for('@stOrder?action=edit&id='.$paczka->getOrderId()).'">'.$paczka->getOrder()->getNumber().'</a>';
|
||||
}
|
||||
|
||||
function st_poczta_polska_uslugi($name, $value, array $params = array())
|
||||
{
|
||||
$options = array();
|
||||
|
||||
$defaults = array('include_custom' => '---');
|
||||
|
||||
if ($params) {
|
||||
$params = array_merge($defaults, $params);
|
||||
} else {
|
||||
$params = $defaults;
|
||||
}
|
||||
|
||||
$deliveryPointOnly = isset($params['delivery_point_only']) && $params['delivery_point_only'];
|
||||
|
||||
$ppks = stPocztaPolskaClient::getCourierServiceList();
|
||||
|
||||
foreach (stPocztaPolskaClient::getServices() as $n => $service)
|
||||
{
|
||||
if ($deliveryPointOnly && in_array($n, $ppks)) continue;
|
||||
|
||||
$options[$n] = __($service['label'], null, 'stPocztaPolskaBackend');
|
||||
}
|
||||
|
||||
natsort($options);
|
||||
|
||||
return select_tag($name, options_for_select($options, $value, $params));
|
||||
}
|
||||
|
||||
function st_poczta_polska_adres_type($name, ?adresType $adres = null, array $params = [])
|
||||
{
|
||||
$zwrot = isset($params['zwrot']) ? $params['zwrot'] : null;
|
||||
$simple = isset($params['simple']) && $params['simple'];
|
||||
|
||||
if (null === $adres && $zwrot)
|
||||
{
|
||||
$adres = clone $zwrot;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
echo st_admin_get_form_field($name.'[nazwa]', __('Nazwisko/Imię/Nazwa'), $adres->nazwa, 'input_tag', array('size' => 40, 'maxlength' => 60));
|
||||
|
||||
if ($simple)
|
||||
{
|
||||
echo st_admin_get_form_field($name.'[nazwa2]', __('Nazwisko/Imię/Nazwa cd'), $adres->nazwa2, 'input_tag', array('size' => 40, 'maxlength' => 60));
|
||||
echo st_admin_get_form_field($name.'[email]', __('Adres e-mail'), $adres->email, 'input_tag', array('size' => 40, 'maxlength' => 50));
|
||||
echo st_admin_get_form_field($name.'[telefon]', __('Telefon'), $adres->telefon, 'input_tag');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (null === $zwrot)
|
||||
{
|
||||
echo st_admin_get_form_field($name.'[nazwa2]', __('Nazwisko/Imię/Nazwa cd'), $adres->nazwa2, 'input_tag', array('size' => 40, 'maxlength' => 60));
|
||||
}
|
||||
|
||||
$address = $adres->ulica;
|
||||
|
||||
if ($adres->numerDomu)
|
||||
{
|
||||
$address .= ' ' . $adres->numerDomu;
|
||||
|
||||
if ($adres->numerLokalu)
|
||||
{
|
||||
$address .= '/' . $adres->numerLokalu;
|
||||
}
|
||||
}
|
||||
|
||||
echo st_admin_get_form_field($name.'[ulica]', __('Adres'), trim($address), 'input_tag', array('size' => 40, 'maxlength' => 255));
|
||||
echo st_admin_get_form_field($name.'[kod_pocztowy]', __('Kod pocztowy'), $adres->kodPocztowy, 'input_tag');
|
||||
echo st_admin_get_form_field($name.'[miejscowosc]', __('Miejscowość'), $adres->miejscowosc, 'input_tag');
|
||||
|
||||
if (null === $zwrot)
|
||||
{
|
||||
echo st_admin_get_form_field($name.'[kraj]', __('Kraj'), $adres->kraj, 'st_poczta_polska_countries_select_tag');
|
||||
echo st_admin_get_form_field($name.'[mobile]', __('Telefon komórkowy'), $adres->mobile, 'input_tag');
|
||||
echo st_admin_get_form_field($name.'[email]', __('Adres e-mail'), $adres->email, 'input_tag', array('size' => 40, 'maxlength' => 50));
|
||||
echo st_admin_get_form_field($name.'[telefon]', __('Telefon'), $adres->telefon, 'input_tag');
|
||||
}
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function st_poczta_polska_zawartosc($name, $value)
|
||||
{
|
||||
$config = stConfig::getInstance('stPocztaPolskaBackend');
|
||||
$slownik = $config->get('slownik');
|
||||
$additionalOptions = [];
|
||||
|
||||
if (!empty($slownik))
|
||||
{
|
||||
foreach (explode("|", $slownik) as $label)
|
||||
{
|
||||
$label = trim($label);
|
||||
$additionalOptions[$label] = $label;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_object($value) || get_class($value) != zawartoscPocztex2021Type::class)
|
||||
{
|
||||
$options = [
|
||||
__('Standardowe') => array_map(function($label) {
|
||||
return __($label, null, 'stPocztaPolskaBackend');
|
||||
}, stPocztaPolskaClient::getPocztex1Zawartosc()),
|
||||
__('Własne') => $additionalOptions,
|
||||
];
|
||||
|
||||
return select_tag($name, options_for_select($options, $value));
|
||||
}
|
||||
|
||||
$options = [
|
||||
'' => __('Wybierz', null, 'stPocztaPolskaBackend'),
|
||||
__('Standardowe') => array_map(function($label) {
|
||||
return __($label, null, 'stPocztaPolskaBackend');
|
||||
}, stPocztaPolskaClient::getPocztex2Zawartosc()),
|
||||
__('Własne') => $additionalOptions,
|
||||
];
|
||||
|
||||
if (isset($additionalOptions[$value->zawartoscInna]))
|
||||
{
|
||||
$value->zawartoscSpecjalna = $value->zawartoscInna;
|
||||
$value->zawartoscInna = null;
|
||||
}
|
||||
|
||||
$content = select_tag($name . '[zawartoscSpecjalna]', options_for_select($options, null === $value->zawartoscSpecjalna ? 'NULL' : $value->zawartoscSpecjalna)) . ' ' . input_tag($name . '[zawartoscInna]', $value->zawartoscInna, ['class' => 'bs-d-none']);
|
||||
|
||||
$id = get_id_from_name($name . '[zawartoscSpecjalna]');
|
||||
|
||||
$idCustomInput = get_id_from_name($name . '[zawartoscInna]');
|
||||
|
||||
$content .=<<<JS
|
||||
<script>
|
||||
jQuery(function(\$) {
|
||||
\$('#$id').change(function() {
|
||||
const select = \$(this);
|
||||
|
||||
if ('NULL' == select.val()) {
|
||||
\$('#$idCustomInput').removeClass('bs-d-none');
|
||||
} else {
|
||||
\$('#$idCustomInput').addClass('bs-d-none');
|
||||
}
|
||||
}).change();
|
||||
});
|
||||
</script>
|
||||
JS;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_poczta_polska_ubezpieczenie($name, $value, $params)
|
||||
{
|
||||
$serviceName = $params['serviceName'];
|
||||
unset($params['serviceName']);
|
||||
|
||||
if (!isset($params['disabled']))
|
||||
{
|
||||
$params['disabled'] = null === $value || "" === $value;
|
||||
}
|
||||
|
||||
$options = array(
|
||||
1000 => '1000',
|
||||
5000 => '5000',
|
||||
10000 => '10000',
|
||||
20000 => '20000',
|
||||
50000 => '50000',
|
||||
"custom" => __('określona wartość', null, 'stPocztaPolskaBackend'),
|
||||
);
|
||||
|
||||
if ($value !== null && $value < 50001 && !isset($options[$value]))
|
||||
{
|
||||
foreach ($options as $val => $label)
|
||||
{
|
||||
if (is_numeric($val) && $value < $val)
|
||||
{
|
||||
$value = $val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = '';
|
||||
|
||||
$fieldContent = st_admin_checkbox_tag('', 1, !$params['disabled'], array(
|
||||
'id' => 'st_poczta_polska_ubezpieczenie_trigger'
|
||||
));
|
||||
|
||||
$fieldContent .= content_tag('div', select_tag($name, options_for_select($options, $value > 50000 ? "custom" : $value), array(
|
||||
'id' => 'st_poczta_polska_ubezpieczenie',
|
||||
'disabled' => $params['disabled'],
|
||||
)), array('class' => 'bs-d-inline-block bs-ms-2'));
|
||||
|
||||
$fieldContent .= ' '.input_tag($name, $value, array(
|
||||
'id' => 'st_poczta_polska_ubezpieczenie_custom',
|
||||
'disabled' => $params['disabled']
|
||||
));
|
||||
|
||||
$content .= content_tag('div', $fieldContent, array('class' => 'bs-d-inline-block'));
|
||||
|
||||
$content .=<<<JS
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
|
||||
var custom = $('#st_poczta_polska_ubezpieczenie_custom');
|
||||
|
||||
var select = $('#st_poczta_polska_ubezpieczenie');
|
||||
|
||||
select.change(function() {
|
||||
if (select.val() == "custom") {
|
||||
custom.show();
|
||||
custom.prop('disabled', false);
|
||||
custom.val(50001);
|
||||
select.removeAttr('name');
|
||||
} else {
|
||||
custom.hide();
|
||||
custom.prop('disabled', true);
|
||||
select.attr('name', custom.attr('name'));
|
||||
}
|
||||
}).change();
|
||||
|
||||
custom.change(function() {
|
||||
|
||||
custom.val(stPrice.fixNumberFormat(custom.val(), 0));
|
||||
var value = Number(custom.val());
|
||||
|
||||
if (value < 50001) {
|
||||
value = 50001;
|
||||
} else if (value > 250000) {
|
||||
value = 250000;
|
||||
}
|
||||
|
||||
custom.val(value);
|
||||
});
|
||||
|
||||
$('#st_poczta_polska_ubezpieczenie_trigger').change(function() {
|
||||
var checked = $(this).prop('checked');
|
||||
custom.prop('disabled', !checked);
|
||||
select.prop('disabled', !checked);
|
||||
select.selectBox('update');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
JS;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_poczta_polska_przesylka_biznesowa_gabaryt_select_tag($name, $selected = null, array $params = array())
|
||||
{
|
||||
return select_tag($name, options_for_select(stPocztaPolskaClient::getGabarytyBiznesowa(), $selected ? $selected : 'M'), $params);
|
||||
}
|
||||
|
||||
|
||||
function st_poczta_polska_countries_select_tag($name, $selected = null, array $params = array())
|
||||
{
|
||||
$params['country_name'] = true;
|
||||
return st_countries_select_tag($name, $selected, $params);
|
||||
}
|
||||
|
||||
function st_poczta_polska_sent_list_actions(PocztaPolskaPaczka $paczka)
|
||||
{
|
||||
$content = st_get_admin_button('download', __('Etykieta', null, 'stPocztaPolskaBackend'), '@stPocztaPolskaBackend?action=downloadAddressLabel&paczka_id='.$paczka->getId(), array(
|
||||
'size' => 'small',
|
||||
));
|
||||
$content .= st_get_admin_button('download', __('Książka adresowa', null, 'stPocztaPolskaBackend'), '@stPocztaPolskaBackend?action=downloadOutboxBook&paczka_id='.$paczka->getId(), array(
|
||||
'size' => 'small',
|
||||
));
|
||||
$content .= st_get_admin_button('default', __('Śledź przesyłkę', null, 'stPocztaPolskaBackend'), $paczka->getTrackingUrl(), array(
|
||||
'size' => 'small',
|
||||
));
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_poczta_polska_package_list_actions(PocztaPolskaPaczka $paczka)
|
||||
{
|
||||
$services = stPocztaPolskaClient::getServices();
|
||||
|
||||
$content = st_get_admin_button('download',__('Etykieta', null, 'stPocztaPolskaBackend'), '@stPocztaPolskaBackend?action=downloadParcelDocument&paczka_id='.$paczka->getId(), array(
|
||||
'size' => 'small',
|
||||
));
|
||||
|
||||
if ($paczka->getServiceName() && isset($services[$paczka->getServiceName()]))
|
||||
{
|
||||
$service = $services[$paczka->getServiceName()];
|
||||
|
||||
if (property_exists($service['class'], 'deklaracjaCelna2'))
|
||||
{
|
||||
$content .= st_get_admin_button('download',__('Deklaracja celna', null, 'stPocztaPolskaBackend'), '@stPocztaPolskaBackend?action=downloadParcelDocument&paczka_id='.$paczka->getId().'&kind='.PrintKindEnum::CUSTOMS_DECLARATION, array(
|
||||
'size' => 'small',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$content .= st_get_admin_button('download', __('Blankiety pobrań', null, 'stPocztaPolskaBackend'), '@stPocztaPolskaBackend?action=downloadParcelDocument&paczka_id='.$paczka->getId().'&kind='.PrintKindEnum::COLLECT_ON_DELIVERY_FORM, array(
|
||||
'size' => 'small',
|
||||
));
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
function st_poczta_polska_list_urzad_nadania(PocztaPolskaBufor $bufor)
|
||||
{
|
||||
$client = stPocztaPolskaClient::getInstance();
|
||||
|
||||
try
|
||||
{
|
||||
$options = $client->getUrzedyNadania();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$options = array();
|
||||
}
|
||||
|
||||
return isset($options[$bufor->getUrzadNadania()]) ? $options[$bufor->getUrzadNadania()] : null;
|
||||
}
|
||||
|
||||
function st_karty_select($name, $value)
|
||||
{
|
||||
$client = stPocztaPolskaClient::getInstance();
|
||||
|
||||
$options = array();
|
||||
|
||||
$selected = null;
|
||||
|
||||
if (sfContext::getInstance()->getRequest()->hasErrors())
|
||||
{
|
||||
$selected = sfContext::getInstance()->getRequest()->getRequestParameter($name);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
foreach ($client->getKarty() as $karta)
|
||||
{
|
||||
if (null === $selected && $karta->aktywna || $karta->idKarta == $selected)
|
||||
{
|
||||
$selected = $karta->idKarta;
|
||||
}
|
||||
|
||||
$options[$karta->idKarta] = $karta->idKarta;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
}
|
||||
|
||||
return select_tag($name, options_for_select($options, $selected, array('include_custom' => __('Wybierz', null, 'stPocztaPolskaBackend'))));
|
||||
}
|
||||
|
||||
function st_urzedy_nadania_select($name, $value)
|
||||
{
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
|
||||
if ($request->getMethod() == sfRequest::POST && $request->hasParameter('config'))
|
||||
{
|
||||
$data = $request->getParameter('config');
|
||||
$client = new stPocztaPolskaClient($data['login'], $data['password'], isset($data['test_mode']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$client = stPocztaPolskaClient::getInstance();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$disable_cache = $request->getMethod() == sfRequest::POST && $request->hasParameter('config');
|
||||
$options = $client->getUrzedyNadania(!$disable_cache);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$options = array();
|
||||
}
|
||||
|
||||
return select_tag($name, options_for_select($options, $value, array('include_custom' => __('Wybierz', null, 'stPocztaPolskaBackend'))));
|
||||
}
|
||||
|
||||
function st_poczta_polska_profile_select($name, $value)
|
||||
{
|
||||
$client = stPocztaPolskaClient::getInstance();
|
||||
|
||||
$response = $client->getProfilList(new getProfileList());
|
||||
}
|
||||
|
||||
function st_poczta_polska_optional_input($name, $value, $options)
|
||||
{
|
||||
return st_admin_optional_input($name, $value, $options);
|
||||
}
|
||||
|
||||
|
||||
function st_poczta_polska_rachunki($name, $value)
|
||||
{
|
||||
$config = stConfig::getInstance('stPocztaPolskaBackend');
|
||||
|
||||
$options = array();
|
||||
|
||||
if ($config->get('rachunek1'))
|
||||
{
|
||||
$options[str_replace(" ", "", $config->get('rachunek1'))] = $config->get('rachunek1');
|
||||
}
|
||||
|
||||
if ($config->get('rachunek2'))
|
||||
{
|
||||
$options[str_replace(" ", "", $config->get('rachunek2'))] = $config->get('rachunek2');
|
||||
}
|
||||
|
||||
if ($config->get('rachunek3'))
|
||||
{
|
||||
$options[str_replace(" ", "", $config->get('rachunek3'))] = $config->get('rachunek3');
|
||||
}
|
||||
|
||||
return select_tag($name, options_for_select($options, $value));
|
||||
}
|
||||
|
||||
function st_poczta_polska_punkt_odbioru($name, $pni, array $options)
|
||||
{
|
||||
$pointName = null;
|
||||
$id = get_id_from_name($name);
|
||||
$widget_id = 'punkt_odbioru_'.uniqid();
|
||||
$placowkaPocztowa = !empty($pni) ? stPocztaPolskaClient::getInstance()->getPlacowkaPocztowa($pni) : null;
|
||||
|
||||
if (null !== $placowkaPocztowa)
|
||||
{
|
||||
$pointName = stPocztaPolskaClient::getPointNameFromPlacowkaPocztowa($placowkaPocztowa);
|
||||
}
|
||||
|
||||
$content = input_tag($widget_id, $pointName , [
|
||||
'readonly' => true,
|
||||
'size' => 50,
|
||||
'data-point' => null !== $placowkaPocztowa ? json_encode([
|
||||
'name' => $placowkaPocztowa->nazwa,
|
||||
'street' => stPocztaPolskaClient::getStreetFromPlacowkaPocztowa($placowkaPocztowa),
|
||||
'city' => $placowkaPocztowa->miejscowosc,
|
||||
'zipCode' => $placowkaPocztowa->kodPocztowy,
|
||||
]) : null,
|
||||
]);
|
||||
|
||||
// $content .= '<br><a href="#" id="'.$id.'_choose" style="vertical-align: middle">'.__('Zmień punkt odbioru', null, 'stPocztaPolskaBackend').'</a>';
|
||||
|
||||
$content .= content_tag('div', st_get_admin_button('default', __('Zmień punkt odbioru', null, 'stPocztaPolskaBackend'), '#', array('id' => $id.'_choose', 'size' => 'small')), array('class' => 'bs-mt-2'));
|
||||
|
||||
$content .= input_hidden_tag($name, $pni);
|
||||
|
||||
$content .= '<script src="https://mapa.ecommerce.poczta-polska.pl/widget/scripts/ppwidget.js?v1"></script>';
|
||||
|
||||
$cod = $options['cod'];
|
||||
|
||||
|
||||
$content .= "
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
const cod = $cod;
|
||||
|
||||
const input = $('#$id');
|
||||
const widgetInput = $('#$widget_id');
|
||||
|
||||
const widgetOptions = {
|
||||
callback: function(point) {
|
||||
widgetInput.val(point.name + ', ' + point.street + ', ' + point.zipCode + ' ' + point.city);
|
||||
input.val(point.pni);
|
||||
},
|
||||
payOnPickup: Boolean(cod),
|
||||
payOnPickupMax: cod,
|
||||
};
|
||||
|
||||
$('#{$id}_choose').click(function() {
|
||||
if (widgetInput.val().length) {
|
||||
let address = widgetInput.val().split(',').slice(1).join(', ');
|
||||
widgetOptions.address = address;
|
||||
}
|
||||
|
||||
PPWidgetApp.toggleMap(widgetOptions);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
";
|
||||
|
||||
return $content;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class stPocztaPolskaBackendBreadcrumbsBuilder extends autoStPocztaPolskaBackendBreadcrumbsBuilder
|
||||
{
|
||||
/**
|
||||
* Okruszki chleba zamowienia
|
||||
*
|
||||
* @var stOrderBreadcrumbsBuilder
|
||||
*/
|
||||
protected $orderBreadcrumbsBuilder;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
stAdminGeneratorHelper::generate('stOrder');
|
||||
|
||||
$this->orderBreadcrumbsBuilder = new stOrderBreadcrumbsBuilder($this->context, $this->breadcrumbs);
|
||||
}
|
||||
|
||||
public function getDefaultBreadcrumbs()
|
||||
{
|
||||
if ($this->relatedObject instanceof Order)
|
||||
{
|
||||
if (null === $this->defaultBreadcrumbs)
|
||||
{
|
||||
$this->defaultBreadcrumbs = $this->orderBreadcrumbsBuilder->getEditBreadcrumbs($this->relatedObject);
|
||||
$this->defaultBreadcrumbs->add($this->appTitle, $this->appRoute);
|
||||
}
|
||||
|
||||
return $this->defaultBreadcrumbs;
|
||||
}
|
||||
|
||||
return parent::getDefaultBreadcrumbs();
|
||||
}
|
||||
|
||||
public function getPackageEditBreadcrumbs(PocztaPolskaPaczka $poczta_polska_paczka)
|
||||
{
|
||||
$this->listBreadcrumbsPackages = $this->getDefaultBreadcrumbs();
|
||||
return parent::getPackagesListBreadcrumbs();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php echo input_tag('config[company]', $config->get('company')); ?>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$('#config_is_company').change(function() {
|
||||
|
||||
if ($(this).prop('checked')) {
|
||||
console.log("show");
|
||||
$('.row_company').show();
|
||||
$('.row_name label, .row_surname label').removeClass('required');
|
||||
} else {
|
||||
console.log("hide");
|
||||
$('.row_company').hide();
|
||||
$('.row_name label, .row_surname label').addClass('required');
|
||||
}
|
||||
}).change();
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
/**
|
||||
* @var stPocztaPolskaPackage $package
|
||||
*/
|
||||
use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'VisualEffect', 'stAdminGenerator', 'stDate', 'stPocztaPolska', 'stPrice');
|
||||
?>
|
||||
|
||||
<fieldset>
|
||||
<div class="content">
|
||||
<?php echo st_admin_get_form_field('bufor[data_nadania]', __('Planowana data nadania'), $bufor->dataNadania, 'input_date_tag', array(
|
||||
'rich' => true,
|
||||
'withtime' => false,
|
||||
'calendar_button_img' => '/sf/sf_admin/images/date.png'
|
||||
)) ?>
|
||||
<?php echo st_admin_get_form_field('bufor[urzad_nadania]', __('Urząd nadania'), $bufor->urzadNadania, 'st_urzedy_nadania_select') ?>
|
||||
<?php if (property_exists($service, 'obszar')): ?>
|
||||
<?php echo st_admin_get_form_field('package[obszar]', __('Obszar'), stPocztaPolskaClient::getObszary(), 'select_tag', ['selected' => $service->obszar]) ?>
|
||||
<?php endif ?>
|
||||
<?php if (in_array($package->getServiceName(), array('przesylka_firmowa_polecona_ekonomiczna', 'przesylka_firmowa_polecona_priorytetowa'))): ?>
|
||||
<?php echo st_admin_get_form_field('package[gabaryt]', __('Gabaryt'), stPocztaPolskaClient::getGabarytyFirmowa(), 'select_tag', array('selected' => $service->gabaryt, 'style' => 'width: 50%')) ?>
|
||||
<?php elseif ($package->getServiceName() == 'przesylka_biznesowa'): ?>
|
||||
<?php echo st_admin_get_form_field('package[gabaryt]', __('Gabaryt'), stPocztaPolskaClient::getGabarytyBiznesowa(), 'select_tag', array('selected' => $service->gabaryt)) ?>
|
||||
<?php elseif (property_exists($service, 'format')): ?>
|
||||
<?php echo st_admin_get_form_field('package[format]', __('Format'), stPocztaPolskaClient::getFormaty($package->getServiceName()), 'select_tag', array('selected' => $service->format, 'style' => 'width: 50%')) ?>
|
||||
<?php elseif (property_exists($service, 'gabaryt')): ?>
|
||||
<?php echo st_admin_get_form_field('package[gabaryt]', __('Gabaryt'), stPocztaPolskaClient::getGabaryty(), 'select_tag', array('selected' => $service->gabaryt, 'style' => 'width: 50%')) ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'odleglosc')): ?>
|
||||
<?php echo st_admin_get_form_field('package[odleglosc]', __('Odległość'), $service->odleglosc, 'input_tag', array('size' => 9, 'postfix' => 'km', 'data-format' => 'integer')) ?>
|
||||
<?php endif ?>
|
||||
<?php echo st_admin_get_form_field('package[masa]', __('Masa'), !$service->masa ? "" : stPrice::round($service->masa / 1000), 'input_tag', array('postfix' => 'kg', 'size' => 9, 'class' => 'amount', 'data-allow-empty' => true)) ?>
|
||||
|
||||
<?php if (property_exists($service, 'punktNadania')): ?>
|
||||
<?php echo st_admin_get_form_field('package[punktNadania]', __('Miejsce nadania'), stPocztaPolskaClient::getPunktyNadania(), 'select_tag', array('selected' => $service->punktNadania && $service->punktNadania->id ? 'placowka_pocztowa' : null, 'style' => 'width: 50%')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (property_exists($service, 'pobranie') && $service->pobranie->sposobPobrania): ?>
|
||||
<?php echo st_admin_get_form_field('package[pobranie][kwota_pobrania]', __('Kwota pobrania'), stPrice::round($service->pobranie->kwotaPobrania / 100), 'input_tag', array('postfix' => 'PLN', 'size' => 9, 'class' => 'amount')) ?>
|
||||
<?php echo st_admin_get_form_field('package[pobranie][nrb]', __('Rachunek pobrania'), $service->pobranie->nrb, 'st_poczta_polska_rachunki') ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($package->getOrder()->getOrderDelivery()->isType('ppo')): ?>
|
||||
<?php if (property_exists($service, 'urzadWydaniaEPrzesylki')): ?>
|
||||
<?php echo st_admin_get_form_field('package[po]', __('Punkt odbioru'), !empty($service->urzadWydaniaEPrzesylki) ? $service->urzadWydaniaEPrzesylki->id : null, 'st_poczta_polska_punkt_odbioru', [
|
||||
'cod' => $package->getOrder()->getOrderPayment()->getPaymentType()->getIsCod() ? $package->getOrder()->getUnpaidAmount() : 0,
|
||||
]) ?>
|
||||
<?php elseif (property_exists($service, 'punktOdbioru')): ?>
|
||||
<?php echo st_admin_get_form_field('package[po]', __('Punkt odbioru'), !empty($service->punktOdbioru) ? $service->punktOdbioru->id : null, 'st_poczta_polska_punkt_odbioru', [
|
||||
'cod' => $package->getOrder()->getOrderPayment()->getPaymentType()->getIsCod() ? $package->getOrder()->getUnpaidAmount() : 0,
|
||||
]) ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (property_exists($service, 'opakowanie')): ?>
|
||||
<?php echo st_admin_get_form_field('package[opakowanie]', __('Opakowanie'), stPocztaPolskaClient::getOpakowania($package->getServiceName()), 'select_tag', array('selected' => $service->opakowanie)) ?>
|
||||
<?php endif ?>
|
||||
<?php if (in_array($package->getServiceName(), array('przesylka_firmowa_polecona_ekonomiczna', 'przesylka_firmowa_polecona_priorytetowa'))): ?>
|
||||
<?php echo st_admin_get_form_field('package[miejscowa]', __('Miejscowa/Zamiejscowa'), array(1 => __('Miejscowa'), 0 => __('Zamiejscowa')), 'select_tag', array('checked' => $service->miejscowa)) ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<h2><?php echo __('Adresat') ?></h2>
|
||||
<div class="content">
|
||||
<?php echo st_poczta_polska_adres_type('package[adres]', $service->adres, ['simple' => $package->getOrder()->getOrderDelivery()->isType('ppo')]) ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<?php if (property_exists($service, 'adresDlaZwrotu')): ?>
|
||||
<fieldset>
|
||||
<h2><?php echo __('Adres dla zwrotu') ?></h2>
|
||||
<div class="content">
|
||||
<?php echo st_admin_get_form_field('adres_zwrotu', __('Adres zwrotu'), true, 'checkbox_tag', ['checked' => null !== $service->adresDlaZwrotu]) ?>
|
||||
<?php echo st_poczta_polska_adres_type('package[adresDlaZwrotu]', $service->adresDlaZwrotu, ['zwrot' => $service->nadawca]) ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php endif ?>
|
||||
|
||||
<fieldset>
|
||||
<h2><?php echo __('Usługi dodatkowe') ?></h2>
|
||||
<div class="content">
|
||||
<?php if (property_exists($service, 'wartosc')): ?>
|
||||
<?php echo st_admin_get_form_field('package[wartosc]', __('Wartość'), $service->wartosc ? $service->wartosc / 100 : $package->getOrderAmount() / 100, 'st_poczta_polska_optional_input', array('postfix' => 'PLN', 'class' => 'amount', 'disabled' => $service->wartosc === null, 'size' => 8)) ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'ubezpieczenie')): ?>
|
||||
<?php echo st_admin_get_form_field('package[ubezpieczenie][kwota]', __('Ubezpieczenie'), $service->ubezpieczenie ? $service->ubezpieczenie->kwota / 100 : $package->getOrderAmount() / 100, 'st_poczta_polska_ubezpieczenie', array('postfix' => 'PLN', 'serviceName' => $package->getServiceName())) ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'ostroznie')): ?>
|
||||
<?php echo st_admin_get_form_field('package[ostroznie]', __('Ostrożnie'), 1, 'checkbox_tag', array('checked' => $service->ostroznie)) ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'ponadgabaryt')): ?>
|
||||
<?php echo st_admin_get_form_field('package[ponadgabaryt]', __('Przesyłka niestandardowa'), 1, 'checkbox_tag', array('checked' => $service->ponadgabaryt)) ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'iloscPotwierdzenOdbioru')): ?>
|
||||
<?php echo st_admin_get_form_field('package[iloscPotwierdzenOdbioru]', __('Potwierdzenie odbioru'), $service->iloscPotwierdzenOdbioru, 'st_poczta_polska_optional_input', array('postfix' => 'szt', 'disabled' => $service->iloscPotwierdzenOdbioru === null, 'size' => 4)) ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'doreczenie') && $service->doreczenie && property_exists($service->doreczenie, 'wSobote')): ?>
|
||||
<?php echo st_admin_get_form_field('package[iloscPotwierdzenOdbioru]', __('Potwierdzenie odbioru'), $service->iloscPotwierdzenOdbioru, 'st_poczta_polska_optional_input', array('postfix' => 'szt', 'disabled' => $service->iloscPotwierdzenOdbioru === null, 'size' => 4)) ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'odbiorWSobote')): ?>
|
||||
<?php echo st_admin_get_form_field('package[odbiorWSobote]', __('Odbiór w sobotę'), 1, 'checkbox_tag', array('checked' => $service->odbiorWSobote)) ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'epo')): ?>
|
||||
<?php echo st_admin_get_form_field('package[epo]', __('Elektroniczne potwierdzenie odbioru'), 1, 'checkbox_tag', array('checked' => $service->epo !== null)) ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<h2><?php echo __('Opis przesyłki') ?></h2>
|
||||
<div class="content">
|
||||
<?php if (property_exists($service, 'zawartosc')): ?>
|
||||
<?php echo st_admin_get_form_field('package[zawartosc]', __('Zawartość'), $service->zawartosc, 'st_poczta_polska_zawartosc') ?>
|
||||
<?php endif ?>
|
||||
<?php if (property_exists($service, 'opis')): ?>
|
||||
<?php echo st_admin_get_form_field('package[opis]', __('Dodatkowy opis przesyłki'), $service->opis, 'input_tag', array('maxlength' => 40, 'size' => 40, 'help' => __('To pole na wydruku zostanie skrócone do pierwszych 40 znaków'))) ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<?php if ($package->getServiceName() == 'paczka_zagraniczna' || $package->getServiceName() == 'paczka_zagraniczna_ue'): ?>
|
||||
<fieldset>
|
||||
<h2><?php echo __('Zwrot') ?></h2>
|
||||
<div class="content">
|
||||
<?php echo st_admin_get_form_field('package[zwrot][zwrot_po_liczbie_dni]', __('Zwrot po liczbie dni'), $service->zwrot->zwrotPoLiczbieDni, 'input_tag', array('class' => 'integer')) ?>
|
||||
<?php echo st_admin_get_form_field('package[zwrot][sposob_zwrotu]', __('Sposób zwrotu'), stPocztaPolskaClient::getSposobZwrotu($package->getServiceName()), 'select_tag', array('selected' => $service->zwrot->sposobZwrotu)) ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (property_exists($service, 'deklaracjaCelna2')):
|
||||
$deklaracjaCelna = $service->deklaracjaCelna2;
|
||||
$deklaracjaCelnaNamespace = 'package[deklaracja_celna2]';;
|
||||
?>
|
||||
<fieldset>
|
||||
<h2><?php echo __('Deklaracja celna') ?></h2>
|
||||
<div class="content">
|
||||
<?php echo st_admin_get_form_field('', __('Instrukcja deklaracji celnej'), link_to(__('Pobierz'), stPocztaPolskaClient::getInstrukcjaDeklaracjiCelnejUrl(), array('download' => '')), 'plain') ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[rodzaj]', __('Rodzaj'), $deklaracjaCelna->rodzaj, '_rodzaj_zagraniczna') ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[szczegoly_zawartosci_przesylki]', __('Szczegóły zawartości przesyłki'), $deklaracjaCelna->szczegolyZawartosciPrzesylki, '_deklaracja_celna_szczegoly', array('waluta' => $deklaracjaCelna->walutaKodISO)) ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[numer_referencyjny_celny]', __('Numer referencyjny celny'), $deklaracjaCelna->numerReferencyjnyCelny, 'input_tag', array('size' => 36)) ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[numer_referencyjny_importera]', __('Numer referencyjny importera'), $deklaracjaCelna->numerReferencyjnyImportera, 'input_tag', array('size' => 36)) ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[numer_telefonu_importera]', __('Numer telefonu importera'), $deklaracjaCelna->numerTelefonuImportera, 'input_tag', array('size' => 36)) ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[oplaty_pocztowe]', __('Opłaty pocztowe'), $deklaracjaCelna->oplatyPocztowe, 'input_tag', array('size' => 36)) ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[uwagi]', __('Uwagi'), $deklaracjaCelna->uwagi, 'textarea_tag', array('style' => 'width: 100%; height: 50px', 'help' => __('Opis dodatkowych informacji dotyczących rodzaju zawartości (np. towary podlegające kwarantannie/kontrolom sanitarnym lub innym ograniczeniom).'))) ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[zawartosc_przesylki]', __('Zawartość przesyłki'), $deklaracjaCelna->zawartoscPrzesylki, '_zawartosc_przesylki_zagranicznej') ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[wyjasnienie]', __('Wyjaśnienie'), $deklaracjaCelna->wyjasnienie, 'textarea_tag', array('style' => 'width: 100%; height: 50px', 'help' => __('Dodatkowe wyjaśnienia dotyczące zawartości przesyłki.'))) ?>
|
||||
|
||||
<?php echo st_admin_get_form_field($deklaracjaCelnaNamespace.'[dokumenty_towarzyszace]', __('Dokumenty towarzyszące'), $deklaracjaCelna->dokumentyTowarzyszace, '_dokumenty_towarzyszace') ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php endif ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$('.amount').change(function() {
|
||||
var input = $(this);
|
||||
var value = input.val();
|
||||
|
||||
if (value === "" && !input.data('allow-empty')) {
|
||||
value = "0";
|
||||
}
|
||||
|
||||
if (value !== "") {
|
||||
value = stPrice.fixNumberFormat(value, 2);
|
||||
|
||||
input.val(value);
|
||||
}
|
||||
}).change();
|
||||
|
||||
$('#adres_zwrotu').change(function() {
|
||||
const checkbox = $(this);
|
||||
checkbox.closest('fieldset').find('input,select').not(checkbox).prop('disabled', !checkbox.prop('checked'));
|
||||
}).change();
|
||||
|
||||
$('#package_obszar').change(function() {
|
||||
const select = $(this);
|
||||
|
||||
if ('<?php echo obszarType::KRAJ ?>' == select.val()) {
|
||||
$('.row.package_format').hide();
|
||||
$('.row.package_odleglosc').hide();
|
||||
} else {
|
||||
$('.row.package_format').show();
|
||||
$('.row.package_odleglosc').show();
|
||||
}
|
||||
}).change();
|
||||
|
||||
$('.integer').change(function() {
|
||||
var input = $(this);
|
||||
var value = input.val();
|
||||
|
||||
if (value === "" && !input.data('allow-empty')) {
|
||||
value = "0";
|
||||
}
|
||||
|
||||
if (value !== "") {
|
||||
value = stPrice.fixNumberFormat(value, 0);
|
||||
|
||||
input.val(value);
|
||||
}
|
||||
}).change();
|
||||
|
||||
$('#package_adres_kraj').change(function() {
|
||||
var select = $(this);
|
||||
$(document).trigger('preloader', 'show');
|
||||
$.get("<?php echo st_url_for('@stPocztaPolskaBackend?action=ajaxUpdateCreatePackageForm') ?>", { order_id: <?php echo $order->getId() ?>, service: $('#service_name').val(), country: select.val() }, function(content) {
|
||||
$('#package-form-container').html(content);
|
||||
$(document).trigger('preloader', 'close');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<table cellspacing="0" cellpadding="0" class="st_record_list record_list" style="width: 100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><b><?php echo __('Szczegółowe określenie zawartości') ?></b></th>
|
||||
<th><?php echo __('Ilość') ?></th>
|
||||
<th><?php echo __('Masa netto') ?></th>
|
||||
<th><b><?php echo __('Wartość') ?></b></th>
|
||||
<th><?php echo __('Numer taryfowy') ?></th>
|
||||
<th><?php echo __('Kraj pochodzenia towarów') ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th><?php echo __('kg') ?></th>
|
||||
<th><?php echo $params['waluta'] ?></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php for ($index = 0; $index < 5; $index++): $szczegoly = isset($value[$index]) ? $value[$index] : null ?>
|
||||
<tr>
|
||||
<td><?php echo input_tag($name.'['.$index.'][okreslenie_zawartosci]', $szczegoly ? $szczegoly->okreslenieZawartosci : null, array('style' => 'width: 100%; min-width: 250px')) ?></td>
|
||||
<td><?php echo input_tag($name.'['.$index.'][ilosc]', $szczegoly ? $szczegoly->ilosc : null, array('class' => 'amount', 'size' => 8)) ?></td>
|
||||
<td><?php echo input_tag($name.'['.$index.'][masa_netto]', $szczegoly ? $szczegoly->masaNetto / 1000 : null, array('class' => 'integer', 'size' => 8)) ?></td>
|
||||
<td><?php echo input_tag($name.'['.$index.'][wartosc]', $szczegoly ? $szczegoly->wartosc / 100 : null, array('class' => 'integer', 'size' => 8)) ?></td>
|
||||
<td><?php echo input_tag($name.'['.$index.'][numer_taryfy_hs]', $szczegoly ? $szczegoly->numerTaryfyHs : null, array('style' => 'width: 100%', 'maxlength' => 6)) ?></td>
|
||||
<td><?php echo st_poczta_polska_countries_select_tag($name.'['.$index.'][kraj_pochodzenia_kod_alfa2]', $szczegoly ? $szczegoly->krajPochodzeniaKodAlfa2 : 'PL', array('iso' => true, 'style' => 'width: 100%')) ?></td>
|
||||
</tr>
|
||||
<?php endfor ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,15 @@
|
||||
<table cellspacing="0" cellpadding="0" class="st_record_list record_list" style="width: 100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><b><?php echo __('Rodzaj') ?></b></th>
|
||||
<th><?php echo __('Numer') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php for ($index = 0; $index < 5; $index++): $dokument = isset($value[$index]) ? $value[$index] : null ?>
|
||||
<tr>
|
||||
<td><?php echo select_tag($name.'['.$index.'][rodzaj]', options_for_select(stPocztaPolskaClient::getDokumentTowarzyszacyRodzaje(), $dokument ? $dokument->rodzaj : null, array("include_custom" => '---')), array('style' => 'width: 100%')) ?></td>
|
||||
<td><?php echo input_tag($name.'['.$index.'][numer]', $dokument ? $dokument->numer : null, array('style' => 'width: 100%')) ?></td> </tr>
|
||||
<?php endfor ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// auto-generated by sfPropelAdmin
|
||||
// date: 2017/02/16 10:56:44
|
||||
?>
|
||||
<?php echo st_get_admin_head(array('@stPocztaPolskaBackend?action=list', __('Poczta Polska'), 'stPocztaPolskaPlugin'), $title, array('shortcuts' => NULL, 'culture' => isset($culture) ? $culture : null, 'route' => isset($route) ? $route : null)) ?>
|
||||
|
||||
<?php if ($sf_user->getParameter('bufor', null, 'soteshop/stPocztaPolska')): $bufor = $sf_user->getParameter('bufor', null, 'soteshop/stPocztaPolska') ?>
|
||||
<form action="<?php echo st_url_for('@stPocztaPolskaBackend?action=updateBufor&bufor_id='.$bufor->getBuforId()) ?>" method="post" class="admin_form" id="st_poczta_polska_bufor_form" style="margin: 0px 10px 10px 10px; position: relative;">
|
||||
<div class="save-ok" style="display: none">
|
||||
<h2><?php echo __('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin') ?><span></span></h2>
|
||||
</div>
|
||||
<fieldset>
|
||||
<div class="content">
|
||||
<?php echo st_admin_get_form_field('bufor[data_nadania]', __('Planowana data nadania'), $bufor->getDataNadania(), 'input_date_tag', array(
|
||||
'rich' => true,
|
||||
'withtime' => false,
|
||||
'calendar_button_img' => '/sf/sf_admin/images/date.png',
|
||||
'calendar_options' => "
|
||||
'onUpdate': function() {
|
||||
jQuery('#st_poczta_polska_bufor_form').submit();
|
||||
}
|
||||
"
|
||||
)) ?>
|
||||
<?php echo st_admin_get_form_field('bufor[urzad_nadania]', __('Urząd nadania'), $bufor->getUrzadNadania(), 'st_urzedy_nadania_select') ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php endif ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$('#bufor_urzad_nadania').change(function() {
|
||||
$('#st_poczta_polska_bufor_form').submit();
|
||||
});
|
||||
|
||||
$('#st_poczta_polska_bufor_form').submit(function() {
|
||||
var form = $(this);
|
||||
var message = form.find('.save-ok');
|
||||
|
||||
message.hide();
|
||||
|
||||
$.post(form.attr('action'), form.serialize(), function(data) {
|
||||
if (data.error) {
|
||||
message.find('span').html(" - "+data.error.errorDesc);
|
||||
} else {
|
||||
message.find('span').html('');
|
||||
}
|
||||
|
||||
message.show();
|
||||
|
||||
$(document).trigger('preloader', 'close');
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php if ($config->get('enabled')): ?>
|
||||
<style type="text/css">
|
||||
#sf_fieldset_none {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<?php endif ?>
|
||||
<div style="padding: 10px; background: #eee; ">
|
||||
<p><?php echo __("Jeżeli nie posiadasz loginu i hasła, wypełnij formularz, a my skontaktujemy się z Tobą.") ?></p>
|
||||
<a href="https://e-nadawca.poczta-polska.pl/?action=Register"><?php echo __("Wypełnij formularz") ?></a>
|
||||
</div>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php use_helper('stPocztaPolska') ?>
|
||||
<?php echo st_karty_select('config[karta]', $config->get('karta')); ?>
|
||||
@@ -0,0 +1,9 @@
|
||||
<div>
|
||||
<?php if ($paczka && $paczka->isSent()): ?>
|
||||
<a href="<?php echo $paczka->getTrackingUrl() ?>" target="_blank" style="display: inline-block; height: 30px; padding-right: 15px; background: #444; color: #fafafa; text-decoration: none"><img src="/plugins/stPocztaPolskaPlugin/images/poczta-polska.png" style="height: 30px; line-height: 0; vertical-align: middle; padding-right: 15px"; /><span style="vertical-align: middle;"><?php echo __('Śledź przesyłkę') ?></span></a>
|
||||
<?php elseif ($paczka): ?>
|
||||
<a href="<?php echo url_for('@stPocztaPolskaBackend?action=packagesList&bufor_id='.$paczka->getBuforId()) ?>" style="display: inline-block; height: 30px; padding-right: 15px; background: #444; color: #fafafa; text-decoration: none"><img src="/plugins/stPocztaPolskaPlugin/images/poczta-polska.png" style="height: 30px; line-height: 0; vertical-align: middle; padding-right: 15px"; /><span style="vertical-align: middle;"><?php echo __('Wyślij przesyłkę') ?></span></a>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo url_for('@stPocztaPolskaBackend?action=packageEdit&order_id='.$order->getId()) ?>" style="display: inline-block; height: 30px; padding-right: 15px; background: #444; color: #fafafa; text-decoration: none"><img src="/plugins/stPocztaPolskaPlugin/images/poczta-polska.png" style="height: 30px; line-height: 0; vertical-align: middle; padding-right: 15px"; /><span style="vertical-align: middle;"><?php echo __('Spakuj') ?></span></a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// auto-generated by sfPropelAdmin
|
||||
// date: 2021/09/03 10:14:04
|
||||
?>
|
||||
<?php st_view_slot_start('application-menu') ?>
|
||||
<div class="edit-menu">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?php echo st_url_for('stOrder/edit?id='.$forward_parameters['order_id']) ?>">
|
||||
<?php echo st_admin_get_icon('prev') ?>
|
||||
<span><?php echo __('Powrót', null, 'stAdminGeneratorPlugin') ?></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php st_include_component('stPocztaPolskaBackend', 'packageEditMenu', array(
|
||||
'forward_parameters' => isset($forward_parameters) ? $forward_parameters : array(),
|
||||
'related_object' => $related_object,
|
||||
)) ?>
|
||||
<?php st_view_slot_end() ?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// auto-generated by sfPropelAdmin
|
||||
// date: 2017/02/16 15:31:44
|
||||
?>
|
||||
|
||||
<?php if ($pager->getNbResults()): ?>
|
||||
<?php echo st_get_admin_actions_head('style="margin-top: 10px; float: right"') ?>
|
||||
<?php echo st_get_admin_action('download', __('Pobierz wszystkie etykiety'), '@stPocztaPolskaBackend?action=downloadParcelDocument&bufor_id='.$sf_request->getParameter('bufor_id'), array("name" => "create",)) ?>
|
||||
<?php echo st_get_admin_action('download', __('Pobierz wszystkie blankiety pobrań'), '@stPocztaPolskaBackend?action=downloadParcelDocument&bufor_id='.$sf_request->getParameter('bufor_id').'&kind='.PrintKindEnum::COLLECT_ON_DELIVERY_FORM, array("name" => "create",)) ?>
|
||||
<?php echo st_get_admin_action('save', __('Wyślij'), '@stPocztaPolskaBackend?action=send&bufor_id='.$sf_request->getParameter('bufor_id'), array("name" => "create",)) ?>
|
||||
<?php echo st_get_admin_actions_foot() ?>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php st_include_partial('stPocztaPolskaBackend/list_menu') ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php echo select_tag($name, options_for_select(stPocztaPolskaClient::getRodzajZagraniczna(), $value));
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php use_helper('stPocztaPolska') ?>
|
||||
<?php echo st_urzedy_nadania_select('config[urzad_nadania]', $config->get('urzad_nadania')); ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php echo select_tag($name, options_for_select(stPocztaPolskaClient::getZawartoscPrzesylkiZagranicznej(), $value));
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'VisualEffect', 'stAdminGenerator', 'stDate', 'stPocztaPolska', 'stPrice');
|
||||
sfLoader::loadHelpers('stOrder', 'stOrder');
|
||||
?>
|
||||
|
||||
<?php st_include_partial('stOrder/header', array('title' => __('Przygotowanie paczki'), 'route' => 'stOrder/edit?id='.$order->getId(), 'related_object' => $order)) ?>
|
||||
<?php st_include_partial('stPocztaPolskaBackend/package_edit_menu', array('related_object' => $order, 'forward_parameters' => $forward_parameters)) ?>
|
||||
|
||||
<div id="sf_admin_content" class="admin-content-edit">
|
||||
<?php st_include_partial('stAdminGenerator/message', array('labels' => $labels));?>
|
||||
|
||||
<?php echo form_tag('@stPocztaPolskaBackend?action=packageEdit&order_id='.$order->getId(), array('id' => 'sf_admin_config_form', 'name' => 'sf_admin_config_form', 'class' => 'admin_form'));?>
|
||||
<fieldset>
|
||||
<div class="content">
|
||||
<?php echo st_admin_get_form_field('service_name', __('Usługa'), $serviceName, 'st_poczta_polska_uslugi', array('include_custom' => null, 'delivery_point_only' => isset($po))) ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div id="package-form-container" class="bs-mx-0">
|
||||
<?php echo st_get_component('stPocztaPolskaBackend', 'createPackageForm', array('package' => $package, 'order' => $order)) ?>
|
||||
</div>
|
||||
<div id="list_actions">
|
||||
<?php echo st_get_admin_actions_head();?>
|
||||
<?php echo st_get_admin_action('save', __('Spakuj'), null, array('name' => 'save'));?>
|
||||
<?php echo st_get_admin_actions_foot();?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$('#service_name').change(function() {
|
||||
$(document).trigger('preloader', 'show');
|
||||
$.get("<?php echo st_url_for('@stPocztaPolskaBackend?action=ajaxUpdateCreatePackageForm') ?>", { order_id: <?php echo $order->getId() ?>, service: $(this).val() }, function(content) {
|
||||
$('#package-form-container').html(content);
|
||||
$(document).trigger('preloader', 'close');
|
||||
});
|
||||
});
|
||||
$('#list_actions').stickyBox();
|
||||
});
|
||||
</script>
|
||||
<?php st_include_partial('stOrder/footer') ?>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class stPocztaPolskaFrontendActions extends stActions
|
||||
{
|
||||
public function executeMapWidget()
|
||||
{
|
||||
$pickupPoint = stDeliveryTypePickupPoint::createFromJson($this->getRequestParameter('pickup_point'));
|
||||
|
||||
$this->smarty = new stSmarty($this->getModuleName());
|
||||
$this->smarty->assign('delivery_id', $this->getRequestParameter('delivery_id'));
|
||||
$this->smarty->assign('pickup_point', $pickupPoint);
|
||||
|
||||
sfConfig::set('sf_web_debug', false);
|
||||
|
||||
return $this->renderText($this->smarty->fetch('map_widget.html'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
class stPocztaPolskaFrontendComponents extends sfComponents
|
||||
{
|
||||
public function executeChooseDeliveryPoint()
|
||||
{
|
||||
if ($this->delivery->getTypeId() != DeliveryTypePeer::retrieveIdByType('ppo') || !stConfig::getInstance('stPocztaPolskaBackend')->get('enabled'))
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$smarty = new stSmarty('stPocztaPolskaFrontend');
|
||||
$points = $this->getUser()->getAttribute('delivery_point', array(), 'soteshop/stPocztaPolskaPlugin');
|
||||
|
||||
$config = stConfig::getInstance('stPocztaPolskaBackend');
|
||||
|
||||
$smarty->assign('point', $points && isset($points[$this->delivery->getId()]) ? $points[$this->delivery->getId()] : array());
|
||||
$smarty->assign('id', $this->delivery->getId());
|
||||
|
||||
return $smarty;
|
||||
}
|
||||
|
||||
public function executeHelper()
|
||||
{
|
||||
$ids = [];
|
||||
$smarty = new stSmarty('stPocztaPolskaFrontend');
|
||||
/**
|
||||
* @var stBasket
|
||||
*/
|
||||
$basket = $this->getUser()->getBasket();
|
||||
|
||||
foreach (PaymentTypePeer::doSelectCached() as $payment)
|
||||
{
|
||||
if ($payment->getIsCod())
|
||||
{
|
||||
$ids[] = $payment->getId();
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign('payments', json_encode($ids));
|
||||
$smarty->assign('pay_on_pickup_amount', $basket->getTotalAmount(true, true) + stDeliveryFrontend::getInstance($basket)->getTotalDeliveryCost(true, true));
|
||||
|
||||
return $smarty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php echo input_hidden_tag('user_data_billing[poczta_polska]'); ?>
|
||||
@@ -0,0 +1 @@
|
||||
<iframe src="{pickup_point_url internal_url='@stPocztaPolskaFrontend?action=mapWidget'}" style="width: 100%; min-height: 600px; top: 0; left: 0; border: none" allowfullscreen></iframe>
|
||||
@@ -0,0 +1,215 @@
|
||||
<script src="https://mapa.ecommerce.poczta-polska.pl/widget/scripts/ppwidget.js?v1"></script>
|
||||
|
||||
<div class="modal fade modal-vertical-centered" id="poczta-polska-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="Poczta Polska"}</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($) {
|
||||
$(document).on('poczta-polska-widget-init', function() {
|
||||
const deliveryPoints = $('.poczta-polska-container');
|
||||
{/literal}
|
||||
const payments = {$payments};
|
||||
const payOnPickupAmount = {$pay_on_pickup_amount};
|
||||
const revalidate = {$sf_request->getParameter('revalidate', 0)};
|
||||
const invalidPayOnPickupPoint = {$sf_request->getParameter('invalid_pay_on_pickup_point', 0)};
|
||||
{literal}
|
||||
const i18n = {
|
||||
{/literal}
|
||||
change_delivery_point: '{__ text="Wybrany punkt nie obsługuje płatności przy odbiorze.<br>Zmień płatność lub wybierz inny punkt odbioru."}',
|
||||
choose_delivery_point: '{__ text="Wybierz punkt odbioru"}',
|
||||
pay_on_pickup_amount: '{__ text="Wybrany punkt nie obsługuje płatności przy odbiorze większych niż %%amount%% zł"}',
|
||||
{literal}
|
||||
};
|
||||
let savedPoint = getParameter('poczta_polska_pickup_point');
|
||||
|
||||
function setParameter(name, value) {
|
||||
const 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(pocztaPolskaAddress, point) {
|
||||
pocztaPolskaAddress.html('<b>'+point.name+'</b><br>'+point.street+'<br>'+point.zipCode+' '+point.city).data('map', point.street+' '+point.zipCode+' '+point.city).data('type', point.type);
|
||||
$('#user_data_billing_poczta_polska').val(JSON.stringify(point));
|
||||
}
|
||||
|
||||
function showMessage(message, messageParams) {
|
||||
var modal = $('#poczta-polska-message-modal');
|
||||
if (messageParams) {
|
||||
for (const [key, value] of Object.entries(messageParams)) {
|
||||
message = message.replaceAll(key, value);
|
||||
}
|
||||
}
|
||||
modal.find('.modal-body').html(message);
|
||||
modal.modal('show');
|
||||
}
|
||||
|
||||
function validateDeliveryPoint(validateEmpty) {
|
||||
var container = $('#shopping-cart-delivery .delivery-radio:checked').parent();
|
||||
var payment_id = $('#shopping-cart-payment .radio input[type=radio]:checked').val();
|
||||
|
||||
var pocztaPolskaAddress = container.find('.poczta-polska-address');
|
||||
|
||||
if (pocztaPolskaAddress.length) {
|
||||
if (validateEmpty && !pocztaPolskaAddress.data('type')) {
|
||||
showMessage(i18n.choose_delivery_point);
|
||||
return false;
|
||||
} else if (!savedPoint.payOnPickup && (payments.indexOf(payment_id) > -1 || payments.indexOf(Number(payment_id)) > -1)) {
|
||||
showMessage(i18n.change_delivery_point);
|
||||
return false;
|
||||
} else if (savedPoint.payOnPickupAmount && savedPoint.payOnPickupAmount.value < payOnPickupAmount && (payments.indexOf(payment_id) > -1 || payments.indexOf(Number(payment_id)) > -1)) {
|
||||
showMessage(i18n.pay_on_pickup_amount, { '%%amount%%': savedPoint.payOnPickupAmount.value });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (invalidPayOnPickupPoint) {
|
||||
showMessage(i18n.change_delivery_point);
|
||||
}
|
||||
|
||||
$('#user_delivery_form').submit(function() {
|
||||
return validateDeliveryPoint(true);
|
||||
});
|
||||
|
||||
$('#shopping-cart-payment').on('change', 'input[type=radio]', function() {
|
||||
$('#basket-update-modal').one('hidden.bs.modal', function() {
|
||||
validateDeliveryPoint();
|
||||
});
|
||||
});
|
||||
|
||||
deliveryPoints.each(function() {
|
||||
var deliveryPoint = $(this);
|
||||
|
||||
if (deliveryPoint.data('init')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
deliveryPoint.data('init', true);
|
||||
|
||||
{/literal}
|
||||
var url = "{url_for internal='@stPocztaPolskaFrontend'}";
|
||||
var id = deliveryPoint.data('delivery-id');
|
||||
var shopping_cart_delivery = $('#shopping-cart-delivery');
|
||||
var selected = $('#shopping-cart-delivery .delivery-radio:checked').val() == id;
|
||||
var is_authenticated = {$sf_user->isAuthenticated()|string_format:"%d"};
|
||||
{literal}
|
||||
|
||||
if (savedPoint) {
|
||||
pointUpdate(deliveryPoint.children('.poczta-polska-address'), savedPoint);
|
||||
}
|
||||
|
||||
deliveryPoint.on("click", ".poczta-polska-delivery-point", function() {
|
||||
var clientAddress = undefined;
|
||||
|
||||
if ($('#different_delivery').prop('checked') || is_authenticated) {
|
||||
clientAddress = $('#code_delivery').val() ? $('#code_delivery').val() : $('#code_billing').val();
|
||||
} else {
|
||||
clientAddress = $('#code_billing').val();
|
||||
}
|
||||
|
||||
var link = $(this);
|
||||
var payment_id = $('#shopping-cart-payment .radio input[type=radio]:checked').val();
|
||||
var pobranie = (payments.indexOf(payment_id) > -1 || payments.indexOf(Number(payment_id)) > -1);
|
||||
var address = savedPoint ? savedPoint.street+' '+savedPoint.zipCode+' '+savedPoint.city : clientAddress;
|
||||
var pocztaPolskaAddress = deliveryPoint.children('.poczta-polska-address');
|
||||
|
||||
PPWidgetApp.toggleMap({
|
||||
callback: function(point) {
|
||||
var radio = link.closest('.radio').find('input[type="radio"]');
|
||||
pointUpdate(pocztaPolskaAddress, point);
|
||||
setParameter('poczta_polska_pickup_point', point);
|
||||
savedPoint = point;
|
||||
if (!radio.prop('checked')) {
|
||||
radio.prop('checked', true).change();
|
||||
}
|
||||
},
|
||||
'payOnPickup': pobranie,
|
||||
'address': address
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
function update() {
|
||||
var different_delivery = $('#different_delivery');
|
||||
|
||||
if (selected) {
|
||||
shopping_cart_delivery.data('delivery-type', 'poczta-polska');
|
||||
shopping_cart_delivery.attr('data-delivery-type', 'poczta-polska');
|
||||
}
|
||||
|
||||
var update = shopping_cart_delivery.data('delivery-type') == 'poczta-polska';
|
||||
|
||||
if (selected) {
|
||||
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');
|
||||
}
|
||||
}
|
||||
deliveryPoint.children('.poczta-polska-address').show();
|
||||
|
||||
if (revalidate) {
|
||||
validateDeliveryPoint(true);
|
||||
}
|
||||
} else {
|
||||
deliveryPoint.children('.poczta-polska-address').hide();
|
||||
|
||||
if (update) {
|
||||
different_delivery.prop('disabled', false);
|
||||
|
||||
if (is_authenticated) {
|
||||
$('#order_form_delivery').show();
|
||||
$('#order_form_billing').parent().removeClass('col-sm-push-6');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
shopping_cart_delivery.on('change', '.delivery-radio', function() {
|
||||
selected = $(this).val() == id;
|
||||
update();
|
||||
});
|
||||
|
||||
});
|
||||
}).ready(function() {
|
||||
$(this).trigger('poczta-polska-widget-init');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{__ text="Wybierz punkt odbioru"}</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
|
||||
<body style="height: 100%; width: 100%; padding: 0; margin: 0;">
|
||||
<div style="margin-top: -50px" id="poczta-polska-widget-map" data-pickup-point="{json_encode data=$pickup_point escape=true}" data-pay-on-pickup="{$pay_on_pickup}" data-is-user-authenticated="{$sf_user->isAuthenticated()|string_format:'%d'}"></div>
|
||||
|
||||
{literal}
|
||||
<script src="https://mapa.ecommerce.poczta-polska.pl/widget/scripts/ppwidget.js"></script>
|
||||
<script>
|
||||
window.parent.jQuery(function($) {
|
||||
let address = '';
|
||||
const widgetMapContainer = $(document).find('#poczta-polska-widget-map');
|
||||
const pickupPoint = widgetMapContainer.data('pickup-point');
|
||||
|
||||
if (window.parent.jQuery('#different_delivery').prop('checked') || widgetMapContainer.data('is-user-authenticated')) {
|
||||
address = $('#code_delivery').val() ? $('#code_delivery').val() : $('#code_billing').val();
|
||||
} else {
|
||||
address = $('#code_billing').val();
|
||||
}
|
||||
|
||||
if (pickupPoint) {
|
||||
address = pickupPoint.address.replace('ul. ', '') + ' ' + pickupPoint.postCode + ' ' + pickupPoint.city;
|
||||
}
|
||||
|
||||
PPWidgetApp.toggleMap({
|
||||
callback: function(point) {
|
||||
const weekendDelivery = point.description.indexOf('#soboty: placówka nieczynna') === -1;
|
||||
|
||||
$.delivery.updatePickupPoint(point.pni, point.name, point.street, point.zipCode, point.city, 'PL', point.payOnPickup, weekendDelivery, {
|
||||
payOnPickupAmount: point.payOnPickup ? point.payOnPickupAmount : null,
|
||||
});
|
||||
|
||||
},
|
||||
payOnPickup: widgetMapContainer.data('pay-on-pickup'),
|
||||
address: address,
|
||||
embeddedElementId: 'poczta-polska-widget-map',
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
{/literal}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user