This commit is contained in:
2026-03-31 22:07:39 +02:00
parent 6547bcff1e
commit aaaabef4eb
279 changed files with 34614 additions and 2 deletions

View File

@@ -133,3 +133,17 @@ line_ending:
# list of regex patterns which, when matched, mark a memory entry as readonly. # list of regex patterns which, when matched, mark a memory entry as readonly.
# Extends the list from the global configuration, merging the two lists. # Extends the list from the global configuration, merging the two lists.
read_only_memory_patterns: [] read_only_memory_patterns: []
# advanced configuration option allowing to configure language server-specific options.
# Maps the language key to the options.
# Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
# No documentation on options means no options are available.
ls_specific_settings: {}
# list of regex patterns for memories to completely ignore.
# Matching memories will not appear in list_memories or activate_project output
# and cannot be accessed via read_memory or write_memory.
# To access ignored memory files, use the read_file tool on the raw file path.
# Extends the list from the global configuration, merging the two lists.
# Example: ["_archive/.*", "_episodes/.*"]
ignored_memory_patterns: []

3
.vscode/ftp-kr.json vendored
View File

@@ -16,6 +16,7 @@
"/.serena", "/.serena",
"/.claude", "/.claude",
"CLAUDE.md", "CLAUDE.md",
"/changelog" "/changelog",
"AGENTS.md"
] ]
} }

View File

@@ -40,6 +40,7 @@
"modified": false "modified": false
}, },
"cache": {}, "cache": {},
"changelog": {},
"classes": {}, "classes": {},
"composer.lock": { "composer.lock": {
"type": "-", "type": "-",

47
AGENTS.md Normal file
View File

@@ -0,0 +1,47 @@
# Repository Guidelines
## Project Structure & Module Organization
This repository is a live **PrestaShop 1.7.x** shop instance. Core application code is in `classes/`, `controllers/`, `src/`, and `app/`. Customizations should usually go in `modules/`, `override/`, and `themes/InterBlue/`.
Key paths:
- `themes/InterBlue/` - custom storefront theme (`assets/css/*.scss`, `templates/**/*.tpl`)
- `modules/` - PrestaShop modules (custom and vendor)
- `override/` - class/controller overrides (high-impact; change carefully)
- `xml/`, `custom/`, root `*.php` scripts - feed/export/import integrations
- `changelog/` - dated maintenance notes
## Build, Test, and Development Commands
There is no single root build pipeline; use targeted commands.
- `php -l path\to\file.php` - quick PHP syntax check before commit.
- `php .\import-products.php` - run product import script locally (only with safe test data).
- `php .\modules\ps_facetedsearch\vendor\bin\phpunit -c .\modules\ps_facetedsearch\tests\phpunit.xml` - run module tests where bundled.
- SCSS workflow: edit `themes/InterBlue/assets/css/custom.scss`; VSCode Live Sass Compiler (see `.vscode/settings.json`) compiles CSS on save.
After PHP/template/override changes, clear PrestaShop cache (`var/cache/*`) from Back Office Performance settings.
## Coding Style & Naming Conventions
- Follow existing PrestaShop PHP conventions: 4-space indentation, `ClassNameCore` extension pattern in overrides, hook-first integrations.
- Keep module strings translatable (`$this->l('...')`).
- Use snake_case for script files (`custom-cron.php`) and PrestaShop-standard class/file names elsewhere.
- Avoid direct core edits when a hook or module override can solve it.
## Testing Guidelines
Automated test coverage is partial and module-specific. For custom changes, combine:
- syntax checks (`php -l`),
- targeted module PHPUnit when available,
- manual Back Office + storefront regression checks (checkout, product page, cart rules, mail templates).
Document what you tested in PR notes.
## Commit & Pull Request Guidelines
Recent history mixes generic (`update`) and descriptive commits; prefer descriptive, scoped messages, e.g. `Fix product import stock sync for XML feed`.
PRs should include:
- purpose and affected paths,
- deployment/cache-clear notes,
- screenshots for UI/theme/admin changes,
- linked issue/task and rollback considerations.
## Security & Configuration Tips
Treat `.vscode/ftp-kr.json`, `app/config/parameters.yml`, and similar files as sensitive. Never introduce new credentials or tokens in commits.

View File

@@ -0,0 +1,41 @@
# Plan naprawy DPD Pickup (checkout)
## Cel
Zablokować możliwość złożenia zamówienia bez wybranego punktu dla metody **DPD Pickup automaty paczkowe** na checkout `https://www.interblue.pl/zam%C3%B3wienie`.
## 1. Potwierdzenie scenariusza i trybu checkout
- Sprawdzić aktywny tryb `CUSTOM_CART` w module `dpdpoland` (najpewniej `opc_prestateam_1_7` z `onepagecheckoutps`).
- Odtworzyć błąd: wybór DPD Pickup bez wyboru punktu i próba kliknięcia `#btn_place_order`.
## 2. Naprawa walidacji JS po stronie DPD
Pliki:
- `modules/dpdpoland/js/pudo-opc-prestateam-1.7.js`
- `modules/dpdpoland/js/pudo-opc-prestateam-8.js`
Zakres:
- Zamienić wywołanie nieistniejącej funkcji `handleDpdShippingPudo()` na istniejącą `handleDpdPudo()`.
- Dodać ponowną inicjalizację po przeładowaniu sekcji przewoźników (`opc-load-carrier:completed`, `opc-update-carrier:completed`).
## 3. Dodatkowa walidacja przy kliknięciu "Złóż zamówienie" (OPC)
Plik:
- `modules/onepagecheckoutps/views/js/front/onepagecheckoutps.js`
Zakres:
- W `Review.placeOrder` dodać warunek: jeśli wybrany carrier to DPD Pickup/SwipBox i punkt nie jest ustawiony, przerwać submit i pokazać komunikat.
- Zabezpieczyć przypadki, gdzie sama blokada przycisku mogłaby zostać ominięta.
## 4. Walidacja backendowa (twarda blokada)
Plik:
- `modules/onepagecheckoutps/onepagecheckoutps.php`
Zakres:
- Przed finalnym utworzeniem zamówienia sprawdzić:
- czy wybrany przewoźnik to DPD Pickup/SwipBox,
- czy istnieje wpis `pudo_code` dla bieżącego koszyka w `ps_dpdpoland_pudo_cart`.
- Przy braku punktu: zwrócić błąd i zatrzymać proces zamówienia.
## 5. Testy regresji
- DPD Pickup bez punktu -> zamówienie zablokowane.
- DPD Pickup z punktem -> zamówienie przechodzi.
- Inni przewoźnicy -> bez regresji.
- Zmiana przewoźnika (tam/powrót) -> poprawny stan walidacji i przycisku.

60
docs/dpd.md Normal file
View File

@@ -0,0 +1,60 @@
# DPD Pickup - zmiany lokalne (do odtworzenia po aktualizacji)
Data: 2026-03-31
## Cel zmiany
Zablokowanie możliwości złożenia zamówienia bez wyboru punktu dla metod:
- DPD Pickup
- DPD Pickup COD
- DPD SwipBox
## Zmienione pliki
1. `modules/dpdpoland/js/pudo-opc-prestateam-1.7.js`
2. `modules/dpdpoland/js/pudo-opc-prestateam-8.js`
3. `modules/onepagecheckoutps/views/js/front/onepagecheckoutps.js`
4. `modules/onepagecheckoutps/onepagecheckoutps.php`
## Dokładnie co zmieniono
### 1) `modules/dpdpoland/js/pudo-opc-prestateam-1.7.js`
- Naprawiono błędne wywołanie:
- było: `handleDpdShippingPudo()`
- jest: `handleDpdPudo()` (przez wrapper `refreshDpdPudoState`)
- Dodano ponowną inicjalizację stanu po dynamicznym przeładowaniu carrierów OPC:
- nasłuch: `opc-load-carrier:completed`
- nasłuch: `opc-update-carrier:completed`
### 2) `modules/dpdpoland/js/pudo-opc-prestateam-8.js`
- Te same zmiany jak wyżej (identyczna logika naprawy i re-init).
### 3) `modules/onepagecheckoutps/views/js/front/onepagecheckoutps.js`
- W `Review.placeOrder` dodano walidację dla aktywnej opcji dostawy:
- jeżeli zaznaczony carrier zawiera kontenery DPD (`.dpdpoland-pudo-container`, `.dpdpoland-pudo-cod-container`, `.dpdpoland-swipbox-container`)
- i nie ma widocznego wybranego punktu (`*.selected-point:visible`),
- proces jest przerywany (`return false`),
- pokazywany jest komunikat `need_select_pickup_point`,
- wykonywany jest click na przycisku wyboru/zmiany punktu (otwarcie mapy).
### 4) `modules/onepagecheckoutps/onepagecheckoutps.php`
- Dodano metodę: `validateDpdPickupPointSelection()`.
- Metoda:
- sprawdza czy aktualny carrier koszyka to DPD Pickup / Pickup COD / SwipBox (po `id_reference`),
- pobiera `pudo_code` z tabeli `ps_dpdpoland_pudo_cart` dla bieżącego `id_cart`,
- gdy brak kodu, dodaje błąd:
- `Wybierz punkt DPD Pickup przed złożeniem zamówienia.`
- Wywołania metody dodano w dwóch miejscach w `placeOrder()`:
- przed zwrotem odpowiedzi `isSaved => true` (ścieżka dla nowego klienta),
- przed końcowym `return array(...)` (ścieżka wspólna).
## Dlaczego to jest potrzebne
- Walidacja wyłącznie po stronie JS mogła być ominięta.
- `hookActionValidateOrder` w DPD działa zbyt późno (po utworzeniu zamówienia) do blokowania checkoutu.
- Obecnie blokada działa zarówno na froncie (UX), jak i na backendzie (hard stop).
## Po aktualizacji modułów sprawdź
1. Czy powyższe 4 pliki nie zostały nadpisane.
2. Czy w plikach DPD nadal nie ma wywołania `handleDpdShippingPudo()`.
3. Czy metoda `validateDpdPickupPointSelection()` nadal istnieje i jest wywoływana w `placeOrder()`.
4. Test manualny:
- DPD Pickup bez punktu -> zamówienie zablokowane.
- DPD Pickup z punktem -> zamówienie przechodzi.

View File

@@ -0,0 +1,129 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandCarrierPudoService Responsible for specific DPD service (carrier) management
*/
class DpdPolandCarrierPudoService extends DpdPolandService
{
/**
* Current file name
*/
const FILENAME = 'dpd_pudo.service';
/**
* Installs specific DPD service (carrier)
*
* @return bool Carrier installed successfully
*/
public static function install()
{
$id_shop = Shop::getContextShopID(true);
$id_shop_group = Shop::getContextShopGroupID(true);
$id_carrier = (int)Configuration::get(DpdPolandConfiguration::CARRIER_PUDO_ID, null, $id_shop_group, $id_shop);
$carrier = self::getCarrierByReference((int)$id_carrier);
if ($id_carrier && Validate::isLoadedObject($carrier))
if (!$carrier->deleted)
return true;
else {
$carrier->deleted = 0;
return (bool)$carrier->save();
}
$carrier_pudo = new DpdPolandCarrierPudoService();
$carrier = new Carrier();
$carrier->name = $carrier_pudo->module_instance->l('DPD Poland Reception Point Pickup', self::FILENAME);
$carrier->active = 1;
$carrier->is_free = 0;
$carrier->shipping_handling = 1;
$carrier->shipping_external = 1;
$carrier->shipping_method = 1;
$carrier->max_width = 0;
$carrier->max_height = 0;
$carrier->max_depth = 0;
$carrier->max_weight = 0;
$carrier->grade = 0;
$carrier->is_module = 1;
$carrier->need_range = 1;
$carrier->range_behavior = 1;
$carrier->external_module_name = $carrier_pudo->module_instance->name;
$carrier->url = _DPDPOLAND_TRACKING_URL_;
$delay = array();
foreach (Language::getLanguages(false) as $language)
$delay[$language['id_lang']] = $carrier_pudo->module_instance->l('DPD Poland Reception Point Pickup', self::FILENAME);
$carrier->delay = $delay;
if (!$carrier->save())
return false;
$dpdpoland_carrier = new DpdPolandCarrier();
$dpdpoland_carrier->id_carrier = (int)$carrier->id;
$dpdpoland_carrier->id_reference = (int)$carrier->id;
if (!$dpdpoland_carrier->save())
return false;
if (!copy(_DPDPOLAND_IMG_DIR_ . DpdPolandCarrierPudoService::IMG_DIR . '/' . _DPDPOLAND_PUDO_ID_ . '.' .
DpdPolandCarrierPudoService::IMG_EXTENSION, _PS_SHIP_IMG_DIR_ . '/' . (int)$carrier->id . '.jpg'))
return false;
$zones = Zone::getZones(false);
foreach ($zones as $zone)
$carrier->addZone((int)$zone["id_zone"]);
if (!$range_obj = $carrier->getRangeObject())
return false;
$range_obj->id_carrier = (int)$carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->add())
return false;
if (!self::assignCustomerGroupsForCarrier($carrier))
return false;
if (!Configuration::updateValue(DpdPolandConfiguration::CARRIER_PUDO_ID, (int)$carrier->id))
return false;
return true;
}
/**
* Deletes DPD carrier
*
* @return bool DPD carrier deleted successfully
*/
public static function delete()
{
$id_shop = Shop::getContextShopID(true);
$id_shop_group = Shop::getContextShopGroupID(true);
return (bool)self::deleteCarrier((int)Configuration::get(DpdPolandConfiguration::CARRIER_PUDO_ID, null, $id_shop_group, $id_shop));
}
}

View File

@@ -0,0 +1,129 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandCarrierStandardService Responsible for specific DPD service (carrier) management
*/
class DpdPolandCarrierStandardService extends DpdPolandService
{
/**
* Current file name
*/
const FILENAME = 'dpd_standard.service';
/**
* Installs specific DPD service (carrier)
*
* @return bool Carrier installed successfully
*/
public static function install()
{
$id_shop = Shop::getContextShopID(true);
$id_shop_group = Shop::getContextShopGroupID(true);
$id_carrier = (int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_ID, null, $id_shop_group, $id_shop);
$carrier = self::getCarrierByReference((int)$id_carrier);
if ($id_carrier && Validate::isLoadedObject($carrier))
if (!$carrier->deleted)
return true;
else {
$carrier->deleted = 0;
return (bool)$carrier->save();
}
$carrier_standard = new DpdPolandCarrierStandardService();
$carrier = new Carrier();
$carrier->name = $carrier_standard->module_instance->l('DPD domestic shipment - Standard', self::FILENAME);
$carrier->active = 1;
$carrier->is_free = 0;
$carrier->shipping_handling = 1;
$carrier->shipping_external = 1;
$carrier->shipping_method = 1;
$carrier->max_width = 0;
$carrier->max_height = 0;
$carrier->max_depth = 0;
$carrier->max_weight = 0;
$carrier->grade = 0;
$carrier->is_module = 1;
$carrier->need_range = 1;
$carrier->range_behavior = 1;
$carrier->external_module_name = $carrier_standard->module_instance->name;
$carrier->url = _DPDPOLAND_TRACKING_URL_;
$delay = array();
foreach (Language::getLanguages(false) as $language)
$delay[$language['id_lang']] = $carrier_standard->module_instance->l('DPD domestic shipment - Standard', self::FILENAME);
$carrier->delay = $delay;
if (!$carrier->save())
return false;
$carrier = self::getCarrierByReference((int)$carrier->id);
$dpdpoland_carrier = new DpdPolandCarrier();
$dpdpoland_carrier->id_carrier = (int)$carrier->id;
$dpdpoland_carrier->id_reference = (int)$carrier->id;
if (!$dpdpoland_carrier->save())
return false;
if (!copy(_DPDPOLAND_IMG_DIR_ . DpdPolandCarrierStandardService::IMG_DIR . '/' . _DPDPOLAND_STANDARD_ID_ . '.' .
DpdPolandCarrierStandardService::IMG_EXTENSION, _PS_SHIP_IMG_DIR_ . '/' . (int)$carrier->id . '.jpg'))
return false;
$zones = Zone::getZones(false);
foreach ($zones as $zone)
$carrier->addZone((int)$zone["id_zone"]);
if (!$range_obj = $carrier->getRangeObject())
return false;
$range_obj->id_carrier = (int)$carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->add())
return false;
if (!self::assignCustomerGroupsForCarrier($carrier))
return false;
if (!Configuration::updateValue(DpdPolandConfiguration::CARRIER_STANDARD_ID, (int)$carrier->id))
return false;
return true;
}
/**
* Deletes DPD carrier
*
* @return bool DPD carrier deleted successfully
*/
public static function delete()
{
$id_shop = Shop::getContextShopID(true);
$id_shop_group = Shop::getContextShopGroupID(true);
return (bool)self::deleteCarrier((int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_ID, null, $id_shop_group, $id_shop));
}
}

View File

@@ -0,0 +1,129 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandCarrierStandardCODService Responsible for specific DPD service (carrier) management
*/
class DpdPolandCarrierStandardCODService extends DpdPolandService
{
/**
* Current file name
*/
const FILENAME = 'dpd_standard_cod.service';
/**
* Installs specific DPD service (carrier)
*
* @return bool Carrier installed successfully
*/
public static function install()
{
$id_shop = Shop::getContextShopID(true);
$id_shop_group = Shop::getContextShopGroupID(true);
$id_carrier = (int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID, null, $id_shop_group, $id_shop);
$carrier = self::getCarrierByReference((int)$id_carrier);
if ($id_carrier && Validate::isLoadedObject($carrier))
if (!$carrier->deleted)
return true;
else {
$carrier->deleted = 0;
return (bool)$carrier->save();
}
$carrier_standard_cod = new DpdPolandCarrierStandardCODService();
$carrier = new Carrier();
$carrier->name = $carrier_standard_cod->module_instance->l('DPD domestic shipment - Standard with COD', self::FILENAME);
$carrier->active = 1;
$carrier->is_free = 0;
$carrier->shipping_handling = 1;
$carrier->shipping_external = 1;
$carrier->shipping_method = 1;
$carrier->max_width = 0;
$carrier->max_height = 0;
$carrier->max_depth = 0;
$carrier->max_weight = 0;
$carrier->grade = 0;
$carrier->is_module = 1;
$carrier->need_range = 1;
$carrier->range_behavior = 1;
$carrier->external_module_name = $carrier_standard_cod->module_instance->name;
$carrier->url = _DPDPOLAND_TRACKING_URL_;
$delay = array();
foreach (Language::getLanguages(false) as $language)
$delay[$language['id_lang']] = $carrier_standard_cod->module_instance->l('DPD domestic shipment - Standard with COD', self::FILENAME);
$carrier->delay = $delay;
if (!$carrier->save())
return false;
$dpdpoland_carrier = new DpdPolandCarrier();
$dpdpoland_carrier->id_carrier = (int)$carrier->id;
$dpdpoland_carrier->id_reference = (int)$carrier->id;
if (!$dpdpoland_carrier->save())
return false;
if (!copy(_DPDPOLAND_IMG_DIR_ . DpdPolandCarrierStandardCODService::IMG_DIR . '/' . _DPDPOLAND_STANDARD_COD_ID_ . '.' .
DpdPolandCarrierStandardCODService::IMG_EXTENSION, _PS_SHIP_IMG_DIR_ . '/' . (int)$carrier->id . '.jpg'))
return false;
$zones = Zone::getZones(false);
foreach ($zones as $zone)
$carrier->addZone((int)$zone["id_zone"]);
if (!$range_obj = $carrier->getRangeObject())
return false;
$range_obj->id_carrier = (int)$carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->add())
return false;
if (!self::assignCustomerGroupsForCarrier($carrier))
return false;
if (!Configuration::updateValue(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID, (int)$carrier->id))
return false;
return true;
}
/**
* Deletes DPD carrier
*
* @return bool DPD carrier deleted successfully
*/
public static function delete()
{
$id_shop = Shop::getContextShopID(true);
$id_shop_group = Shop::getContextShopGroupID(true);
return (bool)self::deleteCarrier((int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID, null, $id_shop_group, $id_shop));
}
}

View File

@@ -0,0 +1,131 @@
<?php
/**
* 2022 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
require_once(_DPDPOLAND_CONTROLLERS_DIR_.'service.php');
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandCarrierSwipBoxService Responsible for specific DPD service (carrier) management
*/
class DpdPolandCarrierSwipBoxService extends DpdPolandService
{
/**
* Current file name
*/
const FILENAME = 'dpd_swipbox.service';
/**
* Installs specific DPD service (carrier)
*
* @return bool Carrier installed successfully
*/
public static function install()
{
$id_shop = Shop::getContextShopID(true);
$id_shop_group = Shop::getContextShopGroupID(true);
$id_carrier = (int)Configuration::get(DpdPolandConfiguration::CARRIER_SWIPBOX_ID, null, $id_shop_group, $id_shop);
$carrier = self::getCarrierByReference((int)$id_carrier);
if ($id_carrier && Validate::isLoadedObject($carrier))
if (!$carrier->deleted)
return true;
else {
$carrier->deleted = 0;
return (bool)$carrier->save();
}
$carrier_pudo = new DpdPolandCarrierSwipBoxService();
$carrier = new Carrier();
$carrier->name = $carrier_pudo->module_instance->l('DPD Poland - Swip box', self::FILENAME);
$carrier->active = 1;
$carrier->is_free = 0;
$carrier->shipping_handling = 1;
$carrier->shipping_external = 1;
$carrier->shipping_method = 1;
$carrier->max_width = 0;
$carrier->max_height = 0;
$carrier->max_depth = 0;
$carrier->max_weight = 0;
$carrier->grade = 0;
$carrier->is_module = 1;
$carrier->need_range = 1;
$carrier->range_behavior = 1;
$carrier->external_module_name = $carrier_pudo->module_instance->name;
$carrier->url = _DPDPOLAND_TRACKING_URL_;
$delay = array();
foreach (Language::getLanguages(false) as $language)
$delay[$language['id_lang']] = $carrier_pudo->module_instance->l('DPD Poland - Swip box', self::FILENAME);
$carrier->delay = $delay;
if (!$carrier->save())
return false;
$dpdpoland_carrier = new DpdPolandCarrier();
$dpdpoland_carrier->id_carrier = (int)$carrier->id;
$dpdpoland_carrier->id_reference = (int)$carrier->id;
if (!$dpdpoland_carrier->save())
return false;
if (!copy(_DPDPOLAND_IMG_DIR_ . DpdPolandCarrierSwipBoxService::IMG_DIR . '/' . _DPDPOLAND_SWIPBOX_ID_ . '.' .
DpdPolandCarrierSwipBoxService::IMG_EXTENSION, _PS_SHIP_IMG_DIR_ . '/' . (int)$carrier->id . '.jpg'))
return false;
$zones = Zone::getZones(false);
foreach ($zones as $zone)
$carrier->addZone((int)$zone["id_zone"]);
if (!$range_obj = $carrier->getRangeObject())
return false;
$range_obj->id_carrier = (int)$carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->add())
return false;
if (!self::assignCustomerGroupsForCarrier($carrier))
return false;
if (!Configuration::updateValue(DpdPolandConfiguration::CARRIER_SWIPBOX_ID, (int)$carrier->id))
return false;
return true;
}
/**
* Deletes DPD carrier
*
* @return bool DPD carrier deleted successfully
*/
public static function delete()
{
$id_shop = Shop::getContextShopID(true);
$id_shop_group = Shop::getContextShopGroupID(true);
return (bool)self::deleteCarrier((int)Configuration::get(DpdPolandConfiguration::CARRIER_SWIPBOX_ID, null, $id_shop_group, $id_shop));
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,167 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandManifestWS Responsible for manifest management
*/
class DpdPolandManifestWS extends DpdPolandWS
{
/**
* Generates manifest
*
* @param DpdPolandManifest $manifest Manifest object
* @param string $output_doc_format Document format
* @param string $output_doc_page_format Document page format
* @param string $policy Policy type
* @return bool
*/
public function generate(DpdPolandManifest $manifest, $output_doc_format, $output_doc_page_format, $policy)
{
$package = $manifest->getPackageInstance();
$packages = $manifest->getPackages();
$package_number = null;
foreach ($packages as $id_package_ws)
{
$current_package = new DpdPolandPackage((int)$id_package_ws);
if ($package_number === null)
$package_number = $current_package->payerNumber;
elseif ($package_number !== $current_package->payerNumber)
$package_number = 'null';
}
$params = array(
'dpdServicesParamsV1' => array(
'pickupAddress' => $package->getSenderAddress(),
'policy' => $policy,
'session' => array(
'sessionId' => (int)$package->sessionId,
'sessionType' => $package->getSessionType()
)
),
'outputDocFormatV1' => $output_doc_format,
'outputDocPageFormatV1' => $output_doc_page_format
);
if ($manifest->id_manifest_ws)
$params['dpdServicesParamsV1']['documentId'] = (int)$manifest->id_manifest_ws;
$result = $this->generateProtocolV2($params);
if (isset($result['documentData']) ||
(isset($result['session']) && isset($result['session']['statusInfo']) && $result['session']['statusInfo']['status'] == 'OK'))
{
if (!$manifest->id_manifest_ws)
$manifest->id_manifest_ws = (int)$result['documentId'];
if (!$manifest->getPackageIdWsByManifestIdWs($manifest->id_manifest_ws) && !$manifest->save())
return false;
return $result['documentData'];
}
else
return false;
}
/**
* Generates multiple manifests for selected packages
*
* @param array $package_ids Packages IDs
* @param string $output_doc_format Document format
* @param string $output_doc_page_format Document page format
* @param string $policy Policy type
* @return bool Multiple manifests generated successfully
*/
public function generateMultiple($package_ids, $output_doc_format = 'PDF', $output_doc_page_format = 'LBL_PRINTER', $policy = 'STOP_ON_FIRST_ERROR')
{
$session_type = '';
$package_number = null;
foreach ($package_ids as $id_package_ws)
{
$package = new DpdPolandPackage((int)$id_package_ws);
if (!$session_type || $session_type == $package->getSessionType())
{
$session_type = $package->getSessionType();
if ($package_number === null)
$package_number = $package->payerNumber;
elseif ($package_number !== $package->payerNumber)
$package_number = 'null';
}
else
{
self::$errors[] = $this->l('Manifests of DOMESTIC shipments cannot be mixed with INTERNATIONAL shipments');
return false;
}
}
$params = array(
'dpdServicesParamsV1' => array(
'pickupAddress' => $package->getSenderAddress(),
'policy' => $policy,
'session' => array(
'sessionType' => $session_type,
'packages' => array()
)
),
'outputDocFormatV1' => $output_doc_format,
'outputDocPageFormatV1' => $output_doc_page_format
);
foreach ($package_ids as $id_package_ws)
{
$params['dpdServicesParamsV1']['session']['packages'][] = array(
'packageId' => (int)$id_package_ws
);
}
$result = $this->generateProtocolV2($params);
if (isset($result['session']) && isset($result['session']['statusInfo']) && $result['session']['statusInfo']['status'] == 'OK')
{
foreach ($package_ids as $id_package_ws)
{
$manifest = new DpdPolandManifest;
$manifest->id_manifest_ws = (int)$result['documentId'];
$manifest->id_package_ws = (int)$id_package_ws;
if (!$manifest->save())
return false;
}
return $result['documentData'];
}
else
{
if (isset($result['session']['statusInfo']['description']))
self::$errors[] = $result['session']['statusInfo']['description'];
elseif (isset($result['session']['statusInfo']['status']))
self::$errors[] = $result['session']['statusInfo']['status'];
return false;
}
}
}

View File

@@ -0,0 +1,201 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandManifestListController Responsible for manifests list view and management
*/
class DpdPolandManifestListController extends DpdPolandController
{
/**
* Default list sorting type
*/
const DEFAULT_ORDER_BY = 'date_add';
/**
* Default list sorting way
*/
const DEFAULT_ORDER_WAY = 'desc';
/**
* Current file name
*/
const FILENAME = 'manifestList.controller';
/**
* Prints a single manifest
*
* @param int|string $id_manifest_ws Manifest ID
* @return bool Manifest printed successfully
*/
public function printManifest($id_manifest_ws)
{
if (is_array($id_manifest_ws))
{
if (empty($id_manifest_ws))
return false;
if (file_exists(_PS_MODULE_DIR_.'dpdpoland/manifest_duplicated.pdf') &&
!unlink(_PS_MODULE_DIR_.'dpdpoland/manifest_duplicated.pdf'))
{
$error_message = $this->l('Could not delete old PDF file. Please check module permissions');
$error = $this->module_instance->displayError($error_message);
return $this->module_instance->outputHTML($error);
}
foreach ($id_manifest_ws as $id)
{
$manifest = new DpdPolandManifest;
$manifest->id_manifest_ws = $id;
if ($pdf_file_contents = $manifest->generate())
{
if (file_exists(_PS_MODULE_DIR_.'dpdpoland/manifest_'.(int)$id.'.pdf') &&
!unlink(_PS_MODULE_DIR_.'dpdpoland/manifest_'.(int)$id.'.pdf'))
{
$error_message = $this->l('Could not delete old PDF file. Please check module permissions');
$error = $this->module_instance->displayError($error_message);
return $this->module_instance->outputHTML($error);
}
$fp = fopen(_PS_MODULE_DIR_.'dpdpoland/manifest_'.(int)$id.'.pdf', 'a');
if (!$fp)
{
$error_message = $this->l('Could not create PDF file. Please check module folder permissions');
$error = $this->module_instance->displayError($error_message);
return $this->module_instance->outputHTML($error);
}
fwrite($fp, $pdf_file_contents);
fclose($fp);
}
else
{
$error_message = $this->module_instance->displayError(reset(DpdPolandManifestWS::$errors));
return $this->module_instance->outputHTML($error_message);
}
}
include_once(_PS_MODULE_DIR_.'dpdpoland/libraries/PDFMerger/PDFMerger.php');
$pdf = new PDFMerger;
foreach ($id_manifest_ws as $id)
{
$manifest_pdf_path = _PS_MODULE_DIR_.'dpdpoland/manifest_'.(int)$id.'.pdf';
$pdf->addPDF($manifest_pdf_path, 'all');
}
$pdf->merge('file', _PS_MODULE_DIR_.'dpdpoland/manifest_duplicated.pdf');
ob_end_clean();
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="manifests_'.time().'.pdf"');
readfile(_PS_MODULE_DIR_.'dpdpoland/manifest_duplicated.pdf');
$this->deletePDFFiles($id_manifest_ws);
exit;
}
$manifest = new DpdPolandManifest;
$manifest->id_manifest_ws = $id_manifest_ws;
if ($pdf_file_contents = $manifest->generate())
{
if (file_exists(_PS_MODULE_DIR_.'dpdpoland/manifest.pdf') && !unlink(_PS_MODULE_DIR_.'dpdpoland/manifest.pdf'))
{
$error_message = $this->l('Could not delete old PDF file. Please check module permissions');
$error = $this->module_instance->displayError($error_message);
return $this->module_instance->outputHTML($error);
}
if (file_exists(_PS_MODULE_DIR_.'dpdpoland/manifest_duplicated.pdf') && !unlink(_PS_MODULE_DIR_.'dpdpoland/manifest_duplicated.pdf'))
{
$error_message = $this->l('Could not delete old PDF file. Please check module permissions');
$error = $this->module_instance->displayError($error_message);
return $this->module_instance->outputHTML($error);
}
$fp = fopen(_PS_MODULE_DIR_.'dpdpoland/manifest.pdf', 'a');
if (!$fp)
{
$error_message = $this->l('Could not create PDF file. Please check module folder permissions');
$error = $this->module_instance->displayError($error_message);
return $this->module_instance->outputHTML($error);
}
fwrite($fp, $pdf_file_contents);
fclose($fp);
include_once(_PS_MODULE_DIR_.'dpdpoland/libraries/PDFMerger/PDFMerger.php');
$pdf = new PDFMerger;
$pdf->addPDF(_PS_MODULE_DIR_.'dpdpoland/manifest.pdf', 'all');
$pdf->merge('file', _PS_MODULE_DIR_.'dpdpoland/manifest_duplicated.pdf');
ob_end_clean();
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="manifests_'.time().'.pdf"');
readfile(_PS_MODULE_DIR_.'dpdpoland/manifest_duplicated.pdf');
$this->deletePDFFiles($id_manifest_ws);
exit;
}
else
$this->module_instance->outputHTML($this->module_instance->displayError(reset(DpdPolandManifestWS::$errors)));
}
/**
* Deletes generated PDF files after merging them into a single document
*
* @param int|string $id_manifest_ws Manifest ID
*/
private function deletePDFFiles($id_manifest_ws)
{
$manifests = array('manifest', 'manifest_duplicated');
if (is_array($id_manifest_ws))
foreach ($id_manifest_ws as $id)
$manifests[] = 'manifest_'.(int)$id;
else
$manifests[] = 'manifest_'.(int)$id_manifest_ws;
foreach ($manifests as $manifest)
if (file_exists(_PS_MODULE_DIR_.'dpdpoland/'.$manifest.'.pdf') && is_writable(_PS_MODULE_DIR_.'dpdpoland/'.$manifest.'.pdf'))
unlink(_PS_MODULE_DIR_.'dpdpoland/'.$manifest.'.pdf');
}
/**
* Displays manifests list content
*
* @return string Manifests list content in HTML
*/
public function getListHTML()
{
$keys_array = array('id_manifest_ws', 'count_parcels', 'count_orders', 'date_add');
$this->prepareListData($keys_array, 'Manifests', new DpdPolandManifest, self::DEFAULT_ORDER_BY, self::DEFAULT_ORDER_WAY, 'manifest_list');
if (version_compare(_PS_VERSION_, '1.6', '<'))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/manifest_list.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/manifest_list_16.tpl');
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
/**
* Class DpdPolandMessagesController Responsible for flash messages management
*/
class DpdPolandMessagesController extends DpdPolandController
{
/**
* Name of success message saved in cookie
*/
const DPD_POLAND_SUCCESS_MESSAGE = 'dpd_poland_success_message';
/**
* Name of error message saved in cookie
*/
const DPD_POLAND_ERROR_MESSAGE = 'dpd_poland_error_message';
/**
* @var Cookie Cookie object instance
*/
private $cookie;
/**
* DpdPolandMessagesController class constructor
*/
public function __construct()
{
parent::__construct();
$this->cookie = new Cookie(_DPDPOLAND_COOKIE_);
}
/**
* Saves success message into Cookie
*
* @param string $message Success message text
*/
public function setSuccessMessage($message)
{
if (!is_array($message))
$this->cookie->{self::DPD_POLAND_SUCCESS_MESSAGE} = $message;
}
/**
* Saves error message into Cookie
*
* @param string $message Error message text
*/
public function setErrorMessage($message)
{
$old_message = $this->cookie->{self::DPD_POLAND_ERROR_MESSAGE};
if ($old_message && Validate::isSerializedArray($old_message))
{
if (version_compare(_PS_VERSION_, '1.5', '<'))
$old_message = unserialize($old_message);
else
$old_message = Tools::unSerialize($old_message);
$message = array_merge($message, $old_message);
}
if (is_array($message))
$this->context->cookie->{self::DPD_POLAND_ERROR_MESSAGE} = serialize($message);
else
$this->cookie->{self::DPD_POLAND_ERROR_MESSAGE} = $message;
}
/**
* Collects and returns success message
* Removes success message from Cookie
*
* @return string Success message
*/
public function getSuccessMessage()
{
$message = $this->cookie->{self::DPD_POLAND_SUCCESS_MESSAGE};
$this->cookie->__unset(self::DPD_POLAND_SUCCESS_MESSAGE);
return $message ? $message : '';
}
/**
* Collects and returns error message
* Removes error message from Cookie
*
* @return array|string Error message(s)
*/
public function getErrorMessage()
{
$message = $this->cookie->{self::DPD_POLAND_ERROR_MESSAGE};
if (Validate::isSerializedArray($message))
if (version_compare(_PS_VERSION_, '1.5', '<'))
$message = unserialize($message);
else
$message = Tools::unSerialize($message);
$this->cookie->__unset(self::DPD_POLAND_ERROR_MESSAGE);
if (is_array($message))
return array_unique($message);
return $message ? array($message) : '';
}
}

View File

@@ -0,0 +1,538 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandPackageWS Responsible for management via WebServices
*/
class DpdPolandPackageWS extends DpdPolandWS
{
/**
* Current file name
*/
const FILENAME = 'Package';
/**
* @var array Sender data used for WebServices
*/
private $sender = array();
/**
* Collects error messages from WebServices
*
* @param array $response Response from WebServices
* @param string $error_key Error code
* @param array $errors Collected errors
* @return array Error messages
*/
private function getErrorsByKey($response, $error_key, $errors = array())
{
if (!empty($response))
foreach ($response as $key => $value)
if (is_object($value) || is_array($value))
$errors = $this->getErrorsByKey($value, $error_key, $errors);
elseif ($key == $error_key)
$errors[] = $value;
return $errors;
}
/**
* Creates package
*
* @param array $package_obj Package object
* @return bool Package created successfully
*/
public function create($package_obj, $payerNumber)
{
if ($result = $this->createRemotely($package_obj, 'THIRD_PARTY', $payerNumber)) {
if (isset($result['Status']) && $result['Status'] == 'OK') {
$packages = $result['Packages']['Package'];
$isMultiShipping = !isset($result['Packages']['Package']['PackageId']);
if ($isMultiShipping) {
foreach ($packages as $key => $package) {
$package_obj[$key]->id_package_ws = (int)$package['PackageId'];
$package_obj[$key]->sessionId = (int)$result['SessionId'];
if (!$package_obj[$key]->save())
self::$errors[] = $this->l('Package was successfully created but we were unable to save its data locally');
}
} else {
$package_obj[0]->id_package_ws = (int)$result['Packages']['Package']['PackageId'];
$package_obj[0]->sessionId = (int)$result['SessionId'];
if (!$package_obj[0]->save())
self::$errors[] = $this->l('Package was successfully created but we were unable to save its data locally');
}
return $packages;
} else {
if (isset($result['Packages']['InvalidFields']))
$errors = $result['Packages']['InvalidFields'];
elseif (isset($result['Packages']['Package']['ValidationDetails']))
$errors = $result['Packages']['Package']['ValidationDetails'];
elseif (isset($result['faultcode']) && isset($result['faultstring']))
$errors = $result['faultcode'] . ' : ' . $result['faultstring'];
else {
$errors = array();
if ($error_ids = $this->getErrorsByKey($result, 'ErrorId')) {
$language = new DpdPolandLanguage();
foreach ($error_ids as $id_error)
$errors[] = $language->getTranslation($id_error);
} elseif ($error_messages = $this->getErrorsByKey($result, 'Info')) {
foreach ($error_messages as $message)
$errors[] = $message;
}
$errors = reset($errors);
if (!$errors)
$errors = $this->module_instance->displayName . ' : ' . $this->l('Unknown error');
}
if ($errors) {
$errors = (array)$errors;
$errors = (array_values($errors) === $errors) ? $errors : array($errors); // array must be multidimentional
foreach ($errors as $error) {
if (isset($error['ValidationInfo']['Info']))
self::$errors[] = $error['ValidationInfo']['Info'];
elseif (isset($error['info']))
self::$errors[] = $error['info'];
elseif (isset($error['ValidationInfo']) && is_array($error['ValidationInfo'])) {
$errors_formatted = reset($error['ValidationInfo']);
if (isset($errors_formatted['ErrorId'])) {
$language = new DpdPolandLanguage();
$error_message = $language->getTranslation($errors_formatted['ErrorId']);
if (!$error_message) {
$error_message = isset($errors_formatted['Info']) ? $errors_formatted['Info'] :
$this->l('Unknown error occured');
}
self::$errors[] = $error_message;
} elseif (isset($errors_formatted['Info'])) {
self::$errors[] = $errors_formatted['Info'];
}
} else {
self::$errors[] = $error;
}
}
} else
self::$errors[] = $errors;
DpdPolandLog::addError($errors);
return false;
}
}
return false;
}
/**
* Creates package remotely
*
* @param array $package_obj Package object
* @param string $payerType Payer type
* @return bool Package created successfully
*/
private function createRemotely($package_obj, $payerType, $payerNumber)
{
$params = array(
'openUMLFeV9' => array('packages' => []),
'pkgNumsGenerationPolicyV1' => 'STOP_ON_FIRST_ERROR',
'langCode' => 'PL'
);
foreach ($package_obj as $item) {
$receiver = $this->prepareReceiverAddress($item);
if (!$receiver)
return false;
$package = [
'parcels' => $item->parcels,
'payerType' => $payerType,
'thirdPartyFID' => $payerNumber,
'receiver' => $receiver,
'ref1' => $item->ref1,
'ref2' => $item->ref2,
'ref3' => _DPDPOLAND_REFERENCE3_,
'reference' => null,
'sender' => $this->prepareSenderAddress($item->id_sender_address),
'services' => $this->prepareServicesData($item),
];
array_push($params['openUMLFeV9']['packages'], $package);
}
return $this->generatePackagesNumbersV8($params);
}
/**
* Formats receiver address and prepares it to be used via WebServices
*
* @param DpdPolandPackage $package_obj Package object
* @return array|bool
*/
private function prepareReceiverAddress(DpdPolandPackage $package_obj)
{
$address = new Address((int)$package_obj->id_address_delivery);
if (Validate::isLoadedObject($address)) {
$customer = new Customer((int)$address->id_customer);
if (Validate::isLoadedObject($customer)) {
return array(
'address' => $address->address1 . ' ' . $address->address2,
'city' => $address->city,
'company' => $address->company,
'countryCode' => Country::getIsoById((int)$address->id_country),
'email' => isset($address->other) && !empty(trim($address->other)) ? $address->other : $customer->email,
'fid' => null,
'name' => $address->firstname . ' ' . $address->lastname,
'phone' => isset($address->phone) && !empty(trim($address->phone)) ? $address->phone : $address->phone_mobile,
'postalCode' => DpdPoland::convertPostcode($address->postcode)
);
} else {
self::$errors[] = $this->l('Customer does not exists');
return false;
}
} else {
self::$errors[] = $this->l('Receiver address does not exists');
return false;
}
return true;
}
/**
* Formats sender address and prepares it to be used via WebServices
*
* @param null|int $id_sender_address Address ID
*/
private function prepareSenderAddress($id_sender_address = null)
{
$sender_address = new DpdPolandSenderAddress((int)$id_sender_address);
return array(
'address' => $sender_address->address,
'city' => $sender_address->city,
'company' => $sender_address->company,
'countryCode' => DpdPoland::POLAND_ISO_CODE,
'email' => $sender_address->email,
'name' => $sender_address->name,
'phone' => $sender_address->phone,
'postalCode' => DpdPoland::convertPostcode($sender_address->postcode)
);
}
/**
* Formats data and prepares it to be used via WebServices
*
* @param DpdPolandPackage $package_obj Package object
*/
private function prepareServicesData(DpdPolandPackage $package_obj)
{
$services = array();
if ($package_obj->cod_amount !== null || $package_obj->sessionType == 'domestic_with_cod' || $package_obj->sessionType == 'pudo_cod') {
if ($package_obj->cod_amount !== null) {
$services['cod'] = array(
'amount' => $package_obj->cod_amount,
'currency' => _DPDPOLAND_CURRENCY_ISO_
);
} else {
$services['cod'] = array(
'amount' => 0,
'currency' => _DPDPOLAND_CURRENCY_ISO_
);
}
}
if ($package_obj->declaredValue_amount !== null) {
$services['declaredValue'] = array(
'amount' => $package_obj->declaredValue_amount,
'currency' => _DPDPOLAND_CURRENCY_ISO_
);
}
if ($package_obj->cud) {
$services['cud'] = 1;
}
if ($package_obj->rod) {
$services['rod'] = 1;
}
if ($package_obj->dpde) {
$services['dpdExpress'] = 1;
}
if ($package_obj->dpdnd) {
$services['guarantee'] = array('type' => 'DPDNEXTDAY');
}
if ($package_obj->dpdtoday) {
$services['guarantee'] = array('type' => 'DPDTODAY');
}
if ($package_obj->dpdfood) {
$services['dpdFood'] = array('limitDate' => $package_obj->dpdfood_limit_date);
}
if ($package_obj->dpdsaturday) {
$services['guarantee'] = array('type' => 'SATURDAY');
}
if ($package_obj->dpdlq) {
$services['dpdLQ'] = 1;
}
if ($package_obj->duty) {
$services['duty'] = array(
'amount' => $package_obj->duty_amount,
'currency' => $package_obj->duty_currency
);
}
// DPD PUDO SERVICE DATA PREPARATION
$order = new Order($package_obj->id_order);
// Check if order has pudo service as carrier
if ($package_obj->sessionType == 'pudo' || $package_obj->sessionType == 'pudo_cod') {
// Get pudo code from pudo_cart mappings table
$pudoCode = Db::getInstance()->getValue('
SELECT `pudo_code`
FROM `' . _DB_PREFIX_ . 'dpdpoland_pudo_cart`
WHERE `id_cart` = ' . (int)$order->id_cart . '
');
$services['dpdPickup'] = array(
'pudo' => $pudoCode,
);
}
return $services;
}
/**
* Collects and returns sender address
*
* @param null|int $id_sender_address Sender address ID
* @return array Sender address
*/
public function getSenderAddress($id_sender_address = null)
{
if (!$this->sender)
return $this->prepareSenderAddress($id_sender_address);
return $this->sender;
}
/**
* Generates multiple labels for selected packages
*
* @param array $waybills Packages waybills
* @param string $outputDocPageFormat Document page format
* @param string $session_type Session type
* @return bool Multiple labels generated successfully
*/
public function generateMultipleLabels($waybills, $outputDocPageFormat, $session_type, $outputLabelType)
{
if (!in_array($outputDocPageFormat, array(DpdPolandConfiguration::PRINTOUT_FORMAT_A4, DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL)))
$outputDocPageFormat = DpdPolandConfiguration::PRINTOUT_FORMAT_A4;
$this->prepareSenderAddress();
$session = array(
'packages' => array(
'parcels' => array()
),
'sessionType' => $session_type
);
foreach ($waybills as $waybill) {
$session['packages']['parcels'][] = array('waybill' => $waybill);
}
$params = array(
'dpdServicesParamsV1' => array(
'policy' => 'IGNORE_ERRORS',
'session' => $session
),
'outputDocFormatV1' => 'PDF',
'outputDocPageFormatV1' => $outputDocPageFormat,
'outputLabelType' => $outputLabelType,
'pickupAddress' => $this->sender
);
if (!$result = $this->generateSpedLabelsV4($params)) {
return false;
}
if (isset($result['session']) && $result['session']['statusInfo']['status'] == 'OK') {
return $result['documentData'];
} else {
if (isset($result['session']['statusInfo']['status'])) {
self::$errors[] = $result['session']['statusInfo']['status'];
return false;
}
$error = isset($result['session']['packages']['statusInfo']['description']) ?
$result['session']['packages']['statusInfo']['description'] :
$result['session']['statusInfo']['description'];
self::$errors[] = $error;
return false;
}
}
/**
* Generates labels for package
*
* @param DpdPolandPackage $package Package object
* @param string $outputDocFormat Document format
* @param string $outputDocPageFormat Document page format
* @param $outputLabelType
* @param string $policy Policy type
* @return bool Labels generated successfully
*/
public function generateLabels(DpdPolandPackage $package, $outputDocFormat, $outputDocPageFormat, $policy, $outputLabelType)
{
if (!in_array($outputDocPageFormat, array(DpdPolandConfiguration::PRINTOUT_FORMAT_A4, DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL)))
$outputDocPageFormat = DpdPolandConfiguration::PRINTOUT_FORMAT_A4;
$this->prepareSenderAddress();
$params = array(
'dpdServicesParamsV1' => array(
'policy' => $policy,
'session' => array(
'sessionId' => (int)$package->sessionId,
'sessionType' => $package->getSessionType()
)
),
'outputDocFormatV1' => $outputDocFormat,
'outputDocPageFormatV1' => $outputDocPageFormat,
'outputLabelType' => $outputLabelType,
'pickupAddress' => $this->sender
);
if (!$result = $this->generateSpedLabelsV4($params))
return false;
if (isset($result['session']) && $result['session']['statusInfo']['status'] == 'OK') {
$package->labels_printed = 1;
$package->update();
return $result['documentData'];
} else {
if (isset($result['session']['statusInfo']['status'])) {
if ($result['session']['statusInfo']['status'] === "NOT_FOUND") {
self::$errors[] = (new DpdPolandLanguage())->getTranslationByCode($result['session']['statusInfo']['status']);
return false;
}
self::$errors[] = $result['session']['statusInfo']['status'];
return false;
}
$error = isset($result['session']['packages']['statusInfo']['description']) ?
$result['session']['packages']['statusInfo']['description'] :
$result['session']['statusInfo']['description'];
self::$errors[] = $error;
return false;
}
}
/**
* Generates multiple labels for selected packages
*
* @param array $package_ids Packages IDs
* @param string $outputDocFormat Document format
* @param string $outputDocPageFormat Document page format
* @param $outputLabelType
* @param string $policy Policy type
* @return bool Labels generated successfully
*/
public function generateLabelsForMultiplePackages($package_ids, $outputDocFormat, $outputDocPageFormat, $policy, $outputLabelType)
{
$sessionType = '';
$packages = array();
foreach ($package_ids as $id_package_ws) {
$package = new DpdPolandPackage((int)$id_package_ws);
if (!$sessionType || $sessionType == $package->getSessionType())
$sessionType = $package->getSessionType();
else {
self::$errors[] = $this->l('Manifests of DOMESTIC shipments cannot be mixed with INTERNATIONAL shipments');
return false;
}
$packages[] = array(
'packageId' => (int)$id_package_ws
);
}
$this->prepareSenderAddress();
$params = array(
'dpdServicesParamsV1' => array(
'policy' => $policy,
'session' => array(
'packages' => $packages,
'sessionType' => $sessionType
)
),
'outputDocFormatV1' => $outputDocFormat,
'outputDocPageFormatV1' => $outputDocPageFormat,
'outputLabelType' => $outputLabelType,
'pickupAddress' => $this->sender
);
if (!$result = $this->generateSpedLabelsV4($params))
return false;
if (isset($result['session']['statusInfo']['status']) && $result['session']['statusInfo']['status'] == 'OK') {
foreach ($packages as $id_package_ws) {
$package = new DpdPolandPackage($id_package_ws);
$package->labels_printed = 1;
$package->update();
}
return $result['documentData'];
} else {
$packages = $result['session']['statusInfo'];
$packages = (array_values($packages) === $packages) ? $packages : array($packages); // array must be multidimentional
foreach ($packages as $package)
if (isset($package['description']))
self::$errors[] = $package['description'];
elseif (isset($package['status']))
self::$errors[] = $package['status'];
return false;
}
}
}

View File

@@ -0,0 +1,273 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandPackageListController Responsible for packages list view and actions
*/
class DpdPolandPackageListController extends DpdPolandController
{
/**
* Default list sorting criteria
*/
const DEFAULT_ORDER_BY = 'date_add';
/**
* Default list sorting way
*/
const DEFAULT_ORDER_WAY = 'desc';
/**
* Current file name
*/
const FILENAME = 'packageList.controller';
/**
* Prints manifests from packages list
*
* @param object $module_instance Module instance
* @return bool Manifest printed successfully
*/
public static function printManifest($module_instance)
{
$cookie = Context::getContext()->cookie;
if (isset($cookie->dpdpoland_packages_ids))
{
if (version_compare(_PS_VERSION_, '1.5', '<'))
$package_ids = unserialize(Context::getContext()->cookie->dpdpoland_packages_ids);
else
$package_ids = Tools::unSerialize(Context::getContext()->cookie->dpdpoland_packages_ids);
unset($cookie->dpdpoland_packages_ids);
$cookie->write();
$separated_packages = DpdPolandPackage::separatePackagesBySession($package_ids);
$international_packages = $separated_packages['INTERNATIONAL'];
$domestic_packages = $separated_packages['DOMESTIC'];
$manifest_ids = array();
if ($international_packages)
$manifest_ids[] = DpdPolandManifest::getManifestIdWsByPackageIdWs($international_packages[0]);
if ($domestic_packages)
$manifest_ids[] = DpdPolandManifest::getManifestIdWsByPackageIdWs($domestic_packages[0]);
require_once(_DPDPOLAND_CONTROLLERS_DIR_.'manifestList.controller.php');
$manifest_controller = new DpdPolandManifestListController();
return $manifest_controller->printManifest($manifest_ids);
}
if ($package_ids = Tools::getValue('PackagesBox'))
{
if (!DpdPolandManifest::validateSenderAddresses($package_ids))
{
$error_message = $module_instance->l('Manifests can not have different sender addresses', self::FILENAME);
$error = $module_instance->displayError($error_message);
return $module_instance->outputHTML($error);
}
$separated_packages = DpdPolandPackage::separatePackagesBySession($package_ids);
$international_packages = $separated_packages['INTERNATIONAL'];
$domestic_packages = $separated_packages['DOMESTIC'];
if ($international_packages)
{
$manifest = new DpdPolandManifest;
if (!$manifest->generateMultiple($international_packages))
{
$error = $module_instance->displayError(reset(DpdPolandManifestWS::$errors));
return $module_instance->outputHTML($error);
}
}
if ($domestic_packages)
{
$manifest = new DpdPolandManifest;
if (!$manifest->generateMultiple($domestic_packages))
{
$error = $module_instance->displayError(reset(DpdPolandManifestWS::$errors));
return $module_instance->outputHTML($error);
}
}
$cookie->dpdpoland_packages_ids = serialize($package_ids);
$redirect_uri = $module_instance->module_url.'&menu=packages_list';
die(Tools::redirectAdmin($redirect_uri));
}
}
/**
* Creates label from packages list
*
* @param object $package Package object
* @param object $module_instance Module instance
* @param array $packages Packages IDs
* @param string $printout_format Printout format (label, A4)
* @param string $filename Label file name
* @return bool Label created successfully
*/
private static function createLabelPDFDocument($package, $module_instance, $packages, $printout_format, $filename)
{
if (!$pdf_file_contents = $package->generateLabelsForMultiplePackages($packages, 'PDF', $printout_format))
{
$error = $module_instance->displayError(reset(DpdPolandPackageWS::$errors));
return $error;
}
if (file_exists(_PS_MODULE_DIR_.'dpdpoland/'.$filename) && !unlink(_PS_MODULE_DIR_.'dpdpoland/'.$filename))
{
$error_message = $module_instance->l('Could not delete old PDF file. Please check module folder permissions', self::FILENAME);
$error = $module_instance->displayError($error_message);
return $error;
}
$international_pdf = fopen(_PS_MODULE_DIR_.'dpdpoland/'.$filename, 'w');
if (!$international_pdf)
{
$error_message = $module_instance->l('Could not create PDF file. Please check module folder permissions', self::FILENAME);
$error = $module_instance->displayError($error_message);
return $error;
}
fwrite($international_pdf, $pdf_file_contents);
fclose($international_pdf);
return true;
}
/**
* Prints multiple label for selected packages
*
* @param string $printout_format Printout format (label, A4)
* @return mixed Error messages
*/
public static function printLabels($printout_format)
{
$module_instance = Module::getinstanceByName('dpdpoland');
if ($package_ids = Tools::getValue('PackagesBox'))
{
$package = new DpdPolandPackage;
$separated_packages = DpdPolandPackage::separatePackagesBySession($package_ids);
$international_packages = $separated_packages['INTERNATIONAL'];
$domestic_packages = $separated_packages['DOMESTIC'];
if ($international_packages)
{
$result = self::createLabelPDFDocument($package, $module_instance, $international_packages, $printout_format, 'international_labels.pdf');
if ($result !== true)
return $module_instance->outputHTML($result);
}
if ($domestic_packages)
{
$result = self::createLabelPDFDocument($package, $module_instance, $domestic_packages, $printout_format, 'domestic_labels.pdf');
if ($result !== true)
return $module_instance->outputHTML($result);
}
include_once(_PS_MODULE_DIR_.'dpdpoland/libraries/PDFMerger/PDFMerger.php');
$pdf = new PDFMerger;
if ($international_packages && $domestic_packages)
{
if (file_exists(_PS_MODULE_DIR_.'dpdpoland/labels_multisession.pdf') && !unlink(_PS_MODULE_DIR_.'dpdpoland/labels_multisession.pdf'))
{
$error_message = $module_instance->l('Could not delete old PDF file. Please check module folder permissions', self::FILENAME);
$error = $module_instance->displayError($error_message);
return $module_instance->outputHTML($error);
}
$international_pdf_path = _PS_MODULE_DIR_.'dpdpoland/international_labels.pdf';
$domestic_pdf_path = _PS_MODULE_DIR_.'dpdpoland/domestic_labels.pdf';
$multisession_pdf_path = _PS_MODULE_DIR_.'dpdpoland/labels_multisession.pdf';
$pdf->addPDF($international_pdf_path, 'all')->addPDF($domestic_pdf_path, 'all')->merge('file', $multisession_pdf_path);
}
ob_end_clean();
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="labels_'.time().'.pdf"');
if ($international_packages && $domestic_packages)
readfile(_PS_MODULE_DIR_.'dpdpoland/labels_multisession.pdf');
elseif ($international_packages)
readfile(_PS_MODULE_DIR_.'dpdpoland/international_labels.pdf');
elseif ($domestic_packages)
readfile(_PS_MODULE_DIR_.'dpdpoland/domestic_labels.pdf');
else
{
$error_message = $module_instance->l('No labels were found', self::FILENAME);
$error = $module_instance->displayError($error_message);
return $module_instance->outputHTML($error);
}
self::deletePDFFiles();
}
}
/**
* Deletes existing PDF files which were used to merge them onto a single document
*/
private static function deletePDFFiles()
{
$labels = array('labels_multisession', 'international_labels', 'domestic_labels');
foreach ($labels as $label)
if (file_exists(_PS_MODULE_DIR_.'dpdpoland/'.$label.'.pdf') && is_writable(_PS_MODULE_DIR_.'dpdpoland/'.$label.'.pdf'))
unlink(_PS_MODULE_DIR_.'dpdpoland/'.$label.'.pdf');
}
/**
* Prepares list data to be displayed in page
*
* @return string Page content in HTML
*/
public function getList()
{
$keys_array = array('date_add', 'id_order', 'package_number', 'count_parcel', 'receiver', 'country', 'postcode', 'city', 'address', 'ref1', 'ref2', 'additional_info');
$this->prepareListData($keys_array, 'Packages', new DpdPolandPackage, self::DEFAULT_ORDER_BY, self::DEFAULT_ORDER_WAY, 'packages_list');
$this->context->smarty->assign('order_link', 'index.php?controller=AdminOrders&vieworder&token='.Tools::getAdminTokenLite('AdminOrders'));
if (version_compare(_PS_VERSION_, '1.6', '>='))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/package_list_16.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/package_list.tpl');
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandParcelHistoryController Responsible for parcel history list page view and actions
*/
class DpdPolandParcelHistoryController extends DpdPolandController
{
/**
* Default list sorting criteria
*/
const DEFAULT_ORDER_BY = 'date_add';
/**
* Default list sorting way
*/
const DEFAULT_ORDER_WAY = 'desc';
/**
* @var string Tracking URL address
*/
private $tracking_link = 'https://tracktrace.dpd.com.pl/parcelDetails?typ=1&p1=';
/**
* Prepares list data to be displayed in page
*
* @return string Page content in HTML
*/
public function getList()
{
$keys_array = array('id_order', 'id_parcel', 'receiver', 'country', 'postcode', 'city', 'address', 'date_add');
$this->prepareListData($keys_array, 'ParcelHistories', new DpdPolandParcel(),
self::DEFAULT_ORDER_BY, self::DEFAULT_ORDER_WAY, 'parcel_history_list');
$this->context->smarty->assign('tracking_link', $this->tracking_link);
if (version_compare(_PS_VERSION_, '1.6', '<'))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/parcel_history_list.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/parcel_history_list_16.tpl');
}
}

View File

@@ -0,0 +1,348 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandPickup Responsible for Arrange Pickup actions management
*/
class DpdPolandPickup extends DpdPolandWS
{
/**
* @var int Pickup ID
*/
public $id_pickup;
/**
* @var date|string Pickup date
*/
public $pickupDate;
/**
* @var date|string Pickup time
*/
public $pickupTime;
/**
* @var string Order type (international, domestic)
*/
public $orderType;
/**
* @var bool Pickup for envelope
*/
public $dox = false;
/**
* @var int|string Documents count
*/
public $doxCount;
/**
* @var bool Pickup for parcels
*/
public $parcels = false;
/**
* @var int|string Parcels count
*/
public $parcelsCount;
/**
* @var float|string Parcels weight
*/
public $parcelsWeight;
/**
* @var float|string Parcel max weight
*/
public $parcelMaxWeight;
/**
* @var float|string Parcel max height
*/
public $parcelMaxHeight;
/**
* @var float|string Parcel max depth
*/
public $parcelMaxDepth;
/**
* @var float|string Parcel max width
*/
public $parcelMaxWidth;
/**
* @var bool Pickup for pallet
*/
public $pallet = false;
/**
* @var int|string Pallets count
*/
public $palletsCount;
/**
* @var float|string Pallets weight
*/
public $palletsWeight;
/**
* @var float|string Pallet max weight
*/
public $palletMaxWeight;
/**
* @var float|string Pallet max height
*/
public $palletMaxHeight;
public $customerName;
public $customerCompany;
public $customerPhone;
/**
* Is it a standard parcel
* Always must be true
*/
const STANDARD_PARCEL = true;
/**
* Makes web services call to arrange a pickup
*
* @param string $operationType Operation type
* @param bool $waybillsReady Are waybills ready
* @return bool Pickup arranged successfully
*/
public function arrange($operationType = 'INSERT', $waybillsReady = true)
{
list($pickupTimeFrom, $pickupTimeTo) = explode('-', $this->pickupTime);
$settings = new DpdPolandConfiguration;
$params = array(
'dpdPickupParamsV3' => array(
'operationType' => $operationType,
'orderType' => $this->orderType,
'pickupCallSimplifiedDetails' => array(
'packagesParams' => $this->getPackagesParams(),
'pickupCustomer' => array(
'customerFullName' => $this->customerName,
'customerName' => $this->customerCompany,
'customerPhone' => $this->customerPhone
),
'pickupPayer' => array(
'payerName' => $settings->client_name,
'payerNumber' => $settings->client_number
),
'pickupSender' => $this->getSenderAddress()
),
'pickupDate' => $this->pickupDate,
'pickupTimeFrom' => $pickupTimeFrom,
'pickupTimeTo' => $pickupTimeTo,
'waybillsReady' => $waybillsReady
)
);
$result = $this->packagesPickupCallV4($params);
if (isset($result['statusInfo']) && isset($result['statusInfo']['errorDetails']))
{
$errors = $result['statusInfo']['errorDetails'];
$errors = (array_values($errors) === $errors) ? $errors : array($errors); // array must be multidimentional
foreach ($errors as $error)
self::$errors[] = sprintf($this->l('Error code: %s, fields: %s'), $error['code'], $error['fields']);
return false;
}
if (isset($result['orderNumber']))
{
$this->id_pickup = (int)$result['orderNumber'];
Configuration::updateValue('DPDPOLAND_CONFIGURATION_OK', true);
return true;
}
self::$errors[] = $this->l('Order number is undefined');
return false;
}
/**
* Returns formatted sender address
*
* @return array Sender address
*/
private function getSenderAddress()
{
$id_sender_address = (int)Tools::getValue('sender_address_selection');
$sender_address = new DpdPolandSenderAddress((int)$id_sender_address);
return array(
'senderAddress' => $sender_address->address,
'senderCity' => $sender_address->city,
'senderFullName' => $sender_address->name,
'senderName' => $sender_address->name,
'senderPhone' => $sender_address->phone,
'senderPostalCode' => DpdPoland::convertPostcode($sender_address->postcode),
);
}
/**
* Create array with pickup packages (envelopes, pallets or parcels) data for web services call
*
* @return array Formatted WebServices parameters
*/
private function getPackagesParams()
{
return array_merge(
$this->getEnvelopesParams(),
$this->getPalletsParams(),
$this->getParcelsParams()
);
}
/**
* Returns array with envelopes data prepared for web services call
* In order to send envelopes, both conditions must be met:
* 1. Envelopes chosen
* 2. Envelopes count > 0
* Otherwise envelopes count will be 0.
* 'dox' parameter always must bet set to 0 - requirement by DPD Poland
*
* @return array Envelopes parameters
*/
private function getEnvelopesParams()
{
$result = array(
'dox' => 0, // always false even if envelopes are sent
'doxCount' => 0
);
if ($this->dox && (int)$this->doxCount)
$result['doxCount'] = (int)$this->doxCount;
return $result;
}
/**
* Returns array with envelopes data prepared for web services call
* In order to send pallets, both conditions must be met:
* 1. Pallets chosen
* 2. Pallets count > 0
*
* @return array Pallets parameters
*/
private function getPalletsParams()
{
$result = array(
'pallet' => 0,
'palletMaxHeight' => '',
'palletMaxWeight' => '',
'palletsCount' => 0,
'palletsWeight' => ''
);
if ($this->pallet && (int)$this->palletsCount)
{
$result['pallet'] = 1;
$result['palletMaxHeight'] = $this->palletMaxHeight;
$result['palletMaxWeight'] = $this->palletMaxWeight;
$result['palletsCount'] = (int)$this->palletsCount;
$result['palletsWeight'] = $this->palletsWeight;
}
return $result;
}
/**
* Returns array with parcels data prepared for web services call
* If envelopes or pallets are sent without parcels then parcels should have all params set to 1
* In order to send parcels, both conditions must be met:
* 1. Parcels chosen
* 2. Parcels count > 0
*
* @return array Parcels parameters
*/
private function getParcelsParams()
{
$result = array(
'parcelsCount' => 0,
'standardParcel' => self::STANDARD_PARCEL, // Always must be true
'parcelMaxDepth' => '',
'parcelMaxHeight' => '',
'parcelMaxWeight' => '',
'parcelMaxWidth' => '',
'parcelsWeight' => ''
);
// If no parcels but envelopes or pallets are chosen then parcels all values should be 1
if (!$this->parcels && ($this->dox || $this->pallet))
{
$result['parcelsCount'] = 1;
$result['standardParcel'] = self::STANDARD_PARCEL; // Always must be true
$result['parcelMaxDepth'] = 1;
$result['parcelMaxHeight'] = 1;
$result['parcelMaxWeight'] = 1;
$result['parcelMaxWidth'] = 1;
$result['parcelsWeight'] = 1;
}
elseif ($this->parcels && (int)$this->parcelsCount)
{
$result['parcelsCount'] = (int)$this->parcelsCount;
$result['standardParcel'] = self::STANDARD_PARCEL; // Always must be true
$result['parcelMaxDepth'] = $this->parcelMaxDepth;
$result['parcelMaxHeight'] = $this->parcelMaxHeight;
$result['parcelMaxWeight'] = $this->parcelMaxWeight;
$result['parcelMaxWidth'] = $this->parcelMaxWidth;
$result['parcelsWeight'] = $this->parcelsWeight;
}
return $result;
}
/**
* Get available pickup time frames for a particular date
*
* @return bool Are any available time frames
*/
public function getCourierTimeframes()
{
$id_sender_address = (int)Tools::getValue('sender_address_selection');
$sender_address = new DpdPolandSenderAddress((int)$id_sender_address);
$params = array(
'senderPlaceV1' => array(
'countryCode' => DpdPoland::POLAND_ISO_CODE,
'zipCode' => DpdPoland::convertPostcode($sender_address->postcode)
)
);
$result = $this->getCourierOrderAvailabilityV1($params);
if (!isset($result['ranges']) && !self::$errors)
self::$errors[] = $this->l('Cannot get TimeFrames from webservices. Please check if sender\'s postal code is typed in correctly');
if(isset($result['ranges']) && isset($result['ranges']['offset']))
return array($result['ranges']);
return (isset($result['ranges'])) ? $result['ranges'] : false;
}
}

View File

@@ -0,0 +1,96 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandSenderAddressListController Responsible for
*/
class DpdPolandPickupHistoryListController extends DpdPolandController
{
/**
* Default list sorting criteria
*/
const DEFAULT_ORDER_BY = 'order_number';
/**
* Default list sorting way
*/
const DEFAULT_ORDER_WAY = 'desc';
/**
* Current file name
*/
const FILENAME = 'manifestList.controller';
/**
* Prepares list data to be displayed in page
*
* @return string Page content in HTML
*/
public function getListHTML()
{
$keys_array = array('id_pickup_history', 'order_number', 'sender_address', 'sender_company', 'sender_name', 'sender_phone', 'pickup_date', 'pickup_time', 'type', 'envelope', 'package', 'pallet');
$this->prepareListData($keys_array, 'PickupHistory', new DpdPolandPickupHistory, self::DEFAULT_ORDER_BY, self::DEFAULT_ORDER_WAY, 'pickup_history');
$this->context->smarty->assign('form_url', $this->module_instance->module_url . '&menu=pickup_history_form');
if (version_compare(_PS_VERSION_, '1.6', '<'))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_ . 'admin/pickup_history_list.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_ . 'admin/pickup_history_list_16.tpl');
}
/**
* Save pickup
* @param $pickup
* @param $id_sender_address
* @throws PrestaShopException
*/
public function save($pickup)
{
$id_sender_address = (int)Tools::getValue('sender_address_selection');
$sender_address = new DpdPolandSenderAddress((int)$id_sender_address);
$pickup_history = new DpdPolandPickupHistory;
$pickup_history->order_number = $pickup->id_pickup;
$pickup_history->sender_address = $sender_address->alias;
$pickup_history->sender_company = $pickup->customerCompany;
$pickup_history->sender_name = $pickup->customerName;
$pickup_history->sender_phone = $pickup->customerPhone;
$pickup_history->pickup_date = $pickup->pickupDate;
$pickup_history->pickup_time = $pickup->pickupTime;
$pickup_history->type = $pickup->orderType;
$pickup_history->envelope = $pickup->doxCount;
$pickup_history->package = $pickup->parcelsCount;
$pickup_history->package_weight_all = $pickup->parcelsWeight;
$pickup_history->package_heaviest_weight = $pickup->parcelMaxWeight;
$pickup_history->package_heaviest_width = $pickup->parcelMaxWidth;
$pickup_history->package_heaviest_length = $pickup->parcelMaxDepth;
$pickup_history->package_heaviest_height = $pickup->parcelMaxHeight;
$pickup_history->pallet = $pickup->palletsCount;
$pickup_history->pallet_weight = $pickup->palletsWeight;
$pickup_history->pallet_heaviest_weight = $pickup->palletMaxWeight;
$pickup_history->pallet_heaviest_height = $pickup->palletMaxHeight;
$pickup_history->id_shop = (int)$this->context->shop->id;
$pickup_history->save();
}
}

View File

@@ -0,0 +1,183 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandSenderAddressFormController Responsible for sender address form page view and actions
*/
class DpdPolandSenderAddressFormController extends DpdPolandController
{
/**
* Current file name
*/
const FILENAME = 'configuration.controller';
/**
* @var int Sender address
*/
private $id_sender_address = 0;
/**
* DpdPolandSenderAddressFormController class constructor
*/
public function __construct()
{
parent::__construct();
if (Tools::isSubmit('editSenderAddress')) {
$this->id_sender_address = (int)Tools::getValue('id_sender_address');
}
}
/**
* Reacts at page actions
*/
public function controllerActions()
{
if (Tools::isSubmit('saveSenderAddress')) {
$this->saveSenderAddress();
}
}
/**
* Prepares form data to be displayed in page
*
* @return string Form data in HTML
*/
public function getForm()
{
$sender_address = new DpdPolandSenderAddress((int)$this->id_sender_address);
$this->context->smarty->assign(array(
'object' => $sender_address,
'saveAction' => $this->module_instance->module_url.'&menu=sender_address_form'
));
if (version_compare(_PS_VERSION_, '1.6', '>='))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/sender_address_form_16.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/sender_address_form.tpl');
}
/**
* Saves sender address in database
*/
private function saveSenderAddress()
{
$id_sender_address = (int)Tools::getValue('id_sender_address');
$address = new DpdPolandSenderAddress((int)$id_sender_address);
$address->alias = Tools::getValue('alias');
$address->company = Tools::getValue('company');
$address->name = Tools::getValue('name');
$address->phone = Tools::getValue('phone');
$address->postcode = Tools::getValue('postcode');
$address->city = Tools::getValue('city');
$address->address = Tools::getValue('address');
$address->email = Tools::getValue('email');
$address->id_shop = (int)$this->context->shop->id;
if ($this->validateSenderAddress($address)) {
$messages_controller = new DpdPolandMessagesController();
if ($address->save()) {
$messages_controller->setSuccessMessage(
$this->module_instance->l('Address saved successfully', self::FILENAME)
);
} else {
$messages_controller->setErrorMessage(
$this->module_instance->l('Could not save address', self::FILENAME)
);
}
}
Tools::redirectAdmin($this->module_instance->module_url.'&menu=sender_address');
}
/**
* Checks if sender address fields are valid
*
* @param DpdPolandSenderAddress $address Sender address object
* @return bool Sender address is valid
*/
private function validateSenderAddress(DpdPolandSenderAddress $address)
{
$errors = array();
if ($address->alias === '') {
$errors[] = $this->module_instance->l('Alias name is required', self::FILENAME);
} elseif (!Validate::isGenericName($address->alias)) {
$errors[] = $this->module_instance->l('Alias name is invalid', self::FILENAME);
}
if ($address->company === '') {
$errors[] = $this->module_instance->l('Company name is required', self::FILENAME);
} elseif (!Validate::isGenericName($address->company)) {
$errors[] = $this->module_instance->l('Company name is invalid', self::FILENAME);
}
if ($address->name === '') {
$errors[] = $this->module_instance->l('Name / Surname is required', self::FILENAME);
} elseif (!Validate::isName($address->name)) {
$errors[] = $this->module_instance->l('Name / Surname is invalid', self::FILENAME);
}
if ($address->phone === '') {
$errors[] = $this->module_instance->l('Phone is required', self::FILENAME);
} elseif (!Validate::isPhoneNumber($address->phone)) {
$errors[] = $this->module_instance->l('Phone number is invalid', self::FILENAME);
}
if ($address->postcode === '') {
$errors[] = $this->module_instance->l('Postcode is required', self::FILENAME);
} elseif (!Validate::isPostCode($address->postcode)) {
$errors[] = $this->module_instance->l('Postcode is invalid', self::FILENAME);
}
if ($address->city === '') {
$errors[] = $this->module_instance->l('City is required', self::FILENAME);
} elseif (!Validate::isCityName($address->city)) {
$errors[] = $this->module_instance->l('City is invalid', self::FILENAME);
}
if ($address->address === '') {
$errors[] = $this->module_instance->l('Address is required', self::FILENAME);
} elseif (!Validate::isAddress($address->address)) {
$errors[] = $this->module_instance->l('Address is invalid', self::FILENAME);
}
if ($address->email === '') {
$errors[] = $this->module_instance->l('Email is required', self::FILENAME);
} elseif (!Validate::isEmail($address->email)) {
$errors[] = $this->module_instance->l('Email is invalid', self::FILENAME);
}
if ($errors) {
$messages_controller = new DpdPolandMessagesController();
$messages_controller->setErrorMessage(serialize($errors));
return false;
}
return true;
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandSenderAddressListController Responsible for
*/
class DpdPolandSenderAddressListController extends DpdPolandController
{
/**
* Default list sorting criteria
*/
const DEFAULT_ORDER_BY = 'date_add';
/**
* Default list sorting way
*/
const DEFAULT_ORDER_WAY = 'desc';
/**
* Current file name
*/
const FILENAME = 'manifestList.controller';
/**
* Reacts at page actions
*/
public function controllerActions()
{
if (Tools::isSubmit('deleteSenderAddress')) {
$this->deleteSenderAddress();
}
}
/**
* Prepares list data to be displayed in page
*
* @return string Page content in HTML
*/
public function getListHTML()
{
$keys_array = array('id_sender_address', 'company', 'name', 'city', 'email', 'alias');
$this->prepareListData($keys_array, 'SenderAddress', new DpdPolandSenderAddress, self::DEFAULT_ORDER_BY, self::DEFAULT_ORDER_WAY, 'sender_address');
$this->context->smarty->assign('form_url', $this->module_instance->module_url.'&menu=sender_address_form');
if (version_compare(_PS_VERSION_, '1.6', '<'))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/sender_address_list.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/sender_address_list_16.tpl');
}
/**
* Deletes sender address
*/
private function deleteSenderAddress()
{
$id_sender_address = (int)Tools::getValue('id_sender_address');
$sender_address = new DpdPolandSenderAddress((int)$id_sender_address);
$messages_controller = new DpdPolandMessagesController();
if ($sender_address->delete()) {
$messages_controller->setSuccessMessage(
$this->module_instance->l('Address deleted successfully', self::FILENAME)
);
} else {
$messages_controller->setErrorMessage(
$this->module_instance->l('Could not delete address', self::FILENAME)
);
}
Tools::redirectAdmin($this->module_instance->module_url.'&menu=sender_address');
}
}

View File

@@ -0,0 +1,146 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandService Responsible for DPD services (carriers) management
*/
class DpdPolandService
{
/**
* DPD carriers images directory name
*/
const IMG_DIR = 'DPD_services';
/**
* DPD carriers images extension
*/
const IMG_EXTENSION = 'jpg';
/**
* @var Module Module instance
*/
protected $module_instance;
/**
* DpdPolandService class constructor
*/
public function __construct()
{
$this->module_instance = Module::getInstanceByName('dpdpoland');
}
/**
* Delete existing carrier
*
* @param int $id_carrier ID of carrier to delete
* @return boolean Carrier deleted successfully
*/
protected static function deleteCarrier($id_carrier)
{
if (!$id_carrier)
return true;
if (version_compare(_PS_VERSION_, '1.5', '<'))
{
$id_carrier = (int)DpdPolandCarrier::getIdCarrierByReference((int)$id_carrier);
$carrier = new Carrier((int)$id_carrier);
}
else
$carrier = Carrier::getCarrierByReference($id_carrier);
if (!Validate::isLoadedObject($carrier))
return true;
if ($carrier->deleted)
return true;
$carrier->deleted = 1;
return (bool)$carrier->save();
}
/**
* Assigns PrestaShop customer groups for carrier on PS 1.4
*
* @param int $id_carrier Carrier ID
* @param array $groups Groups IDs
* @return bool Groups successfully assigned for carrier
*/
protected static function setGroups14($id_carrier, $groups)
{
foreach ($groups as $id_group)
if (!Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'carrier_group`
(`id_carrier`, `id_group`)
VALUES
("'.(int)$id_carrier.'", "'.(int)$id_group.'")
'))
return false;
return true;
}
/**
* Assigns customer groups for carrier on PS 1.5 and PS 1.6
*
* @param Carrier $carrier Carrier object
* @return bool Customer groups successfully assigned for carrier
*/
protected static function assignCustomerGroupsForCarrier($carrier)
{
$groups = array();
foreach (Group::getGroups((int)Context::getContext()->language->id) as $group)
$groups[] = $group['id_group'];
if (version_compare(_PS_VERSION_, '1.5.5', '<'))
{
if (!self::setGroups14((int)$carrier->id, $groups))
return false;
}
else
if (!$carrier->setGroups($groups))
return false;
return true;
}
/**
* Returns carrier according to it's reference
*
* @param string|int $reference Carrier reference
* @return bool|Carrier Carrier object
*/
public static function getCarrierByReference($reference)
{
if (version_compare(_PS_VERSION_, '1.5', '<'))
{
$id_carrier = (int)DpdPolandCarrier::getIdCarrierByReference($reference);
$carrier = new Carrier((int)$id_carrier);
}
else
$carrier = Carrier::getCarrierByReference((int)$reference);
return $carrier;
}
}

View File

@@ -0,0 +1,295 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
if (!defined('_PS_VERSION_'))
exit;
require_once(_PS_MODULE_DIR_.'dpdpoland/dpdpoland.lang.php');
require_once(_DPDPOLAND_CLASSES_DIR_.'Log.php');
/**
* Class DpdPolandWS Responsible for WebService calls management
*/
class DpdPolandWS extends DpdPolandController
{
/**
* @var SoapClient Instance of SoapClient class
*/
private $client;
/**
* @var array WebServices parameters
*/
private $params = array();
/**
* @var string Last called function payload
*/
private $lastCalledFunctionPayload;
/**
* @var string Last called function name
*/
private $lastCalledFunctionName;
/**
* @var array Last called function arguments
*/
private $lastCalledFunctionArgs = array();
/**
* Current file name
*/
const FILENAME = 'dpdpoland.ws';
/**
* Debug file name setting name
*/
const DEBUG_FILENAME = 'DPDPOLAND_DEBUG_FILENAME';
/**
* Bool Debug data should be displayed in PopUp window or logs file
*/
const DEBUG_POPUP = false;
/**
* Debug file name symbols count
*/
const DEBUG_FILENAME_LENGTH = 16;
/**
* DpdPolandWS class constructor
*/
public function __construct()
{
parent::__construct();
$settings = new DpdPolandConfiguration;
$this->params = array(
'authDataV1' => array(
'login' => $settings->login,
'masterFid' => $settings->customer_fid,
'password' => $settings->password
)
);
try
{
$this->client = new SoapClient($settings->ws_url, array('trace' => true));
return $this->client;
}
catch (Exception $e)
{
DpdPolandLog::addError('URL: '.$settings->ws_url.' - '.$e->getMessage());
self::$errors[] = $e->getMessage();
}
return false;
}
/**
* Main function used to make a request via WebServices
*
* @param string $function_name Function name
* @param array $arguments Function arguments
* @return array|bool Response
*/
public function __call($function_name, $arguments)
{
$result = null;
$this->lastCalledFunctionName = $function_name;
$this->lastCalledFunctionArgs = $arguments;
if (isset($arguments[0]) && is_array($arguments[0]))
{
$this->params = array_merge($this->params, $arguments[0]);
try
{
if (!$result = $this->client->$function_name($this->params))
self::$errors[] = $this->l('Could not connect to webservice server. Please check webservice URL');
}
catch (Exception $e)
{
DpdPolandLog::addError('function_name: '.$function_name.' - message: '.$e->getMessage());
self::$errors[] = $e->getMessage();
}
if (isset($result->return))
$result = $result->return;
if (isset($result->faultstring))
self::$errors[] = $result->faultstring;
if (_DPDPOLAND_DEBUG_MODE_)
$this->debug($result);
return $this->objectToArray($result);
}
return false;
}
/**
* Response should be used as array
*
* @param object|array $response Response from WebServices
* @return array Formatted response
*/
private function objectToArray($response)
{
if (!is_object($response) && !is_array($response))
return $response;
return array_map(array($this, 'objectToArray'), (array)$response);
}
/**
* Creates debug file if it is still not created
*
* @return string Debug file name
*/
private function createDebugFileIfNotExists()
{
if ((!$debug_filename = Configuration::get(self::DEBUG_FILENAME)) || !$this->isDebugFileName($debug_filename))
{
$debug_filename = Tools::passwdGen(self::DEBUG_FILENAME_LENGTH).'.html';
Configuration::updateValue(self::DEBUG_FILENAME, $debug_filename);
}
if (!file_exists(_DPDPOLAND_MODULE_DIR_.$debug_filename))
{
$file = fopen(_DPDPOLAND_MODULE_DIR_.$debug_filename, 'w');
fclose($file);
}
return $debug_filename;
}
/**
* Checks if string can be used as debug file name
*
* @param string $debug_filename Debug file name
* @return bool String can be used as debug file name
*/
private function isDebugFileName($debug_filename)
{
return Tools::strlen($debug_filename) == (int)self::DEBUG_FILENAME_LENGTH + 5 && preg_match('#^[a-zA-Z0-9]+\.html$#', $debug_filename);
}
/**
* Adds data into debug file
*
* @param null $result Request / Response / Errors from / to WebsServices
*/
private function debug($result = null)
{
$debug_html = '';
if ($this->lastCalledFunctionName)
{
$debug_html .= '<h2 style="padding: 10px 0 10px 0; display: block; border-top: solid 2px #000000; border-bottom: solid 2px #000000;">
['.date('Y-m-d H:i:s').']</h2><h2>Function \''.$this->lastCalledFunctionName.'\' params
</h2><pre>';
$debug_html .= print_r($this->lastCalledFunctionArgs, true);
$debug_html .= '</pre>';
}
if ($this->lastCalledFunctionPayload = (string)$this->client->__getLastRequest())
$debug_html .= '<h2>Request</h2><pre>'.$this->displayPayload().'</pre>';
if ($result)
{
if ($err = $this->getError())
$debug_html .= '<h2>Error</h2><pre>'.$err.'</pre>';
else
{
$result = print_r($result, true);
$debug_html .= '<h2>Response</h2><pre>';
$debug_html .= strip_tags($result);
$debug_html .= '</pre>';
}
}
else
$debug_html .= '<h2>Errors</h2><pre>'.print_r(self::$errors, true).'</pre>';
if ($debug_html)
{
$debug_filename = $this->createDebugFileIfNotExists();
$current_content = Tools::file_get_contents(_DPDPOLAND_MODULE_DIR_.$debug_filename);
@file_put_contents(_DPDPOLAND_MODULE_DIR_.$debug_filename, $debug_html.$current_content, LOCK_EX);
if (self::DEBUG_POPUP)
{
echo '
<div id="_invertus_ws_console" style="display:none">
'.$debug_html.'
</div>
<script language=javascript>
_invertus_ws_console = window.open("","Invertus WS debugging console","width=680,height=600,resizable,scrollbars=yes");
_invertus_ws_console.document.write("<HTML><TITLE>Invertus WS debugging console</TITLE><BODY bgcolor=#ffffff>");
_invertus_ws_console.document.write(document.getElementById("_invertus_ws_console").innerHTML);
_invertus_ws_console.document.write("</BODY></HTML>");
_invertus_ws_console.document.close();
document.getElementById("_invertus_ws_console").remove();
</script>';
}
}
}
/**
* Only for debugging purposes
*
* @return string Last called function payload
*/
private function displayPayload()
{
$xml = preg_replace('/(>)(<)(\/*)/', "$1\n$2$3", $this->lastCalledFunctionPayload);
$token = strtok($xml, "\n");
$result = '';
$pad = 0;
$matches = array();
while ($token !== false)
{
if (preg_match('/.+<\/\w[^>]*>$/', $token, $matches))
$indent = 0;
elseif (preg_match('/^<\/\w/', $token, $matches))
{
$pad -= 4;
$indent = 0;
}
elseif (preg_match('/^<\w[^>]*[^\/]>.*$/', $token, $matches))
$indent = 4;
else
$indent = 0;
$line = str_pad($token, Tools::strlen($token) + $pad, ' ', STR_PAD_LEFT);
$result .= $line."\n";
$token = strtok("\n");
$pad += $indent;
}
return htmlentities($result);
}
}

View File

@@ -0,0 +1,318 @@
#dpdpoland
{
position: relative;
width: 400px;
z-index: 100;
}
#dpdpoland.dpdpoland-ps16
{
width: auto;
}
#dpdpoland legend a
{
padding-left:5px;
}
#dpdpoland #dpdpoland_shipment_creation
{
width: 880px;
display:none;
}
#dpdpoland.dpdpoland-ps16 #dpdpoland_shipment_creation
{
width: auto;
}
#dpdpoland_shipment_creation #add_parcel
{
float: right;
}
#dpdpoland_shipment_creation #save_and_print_labels,
#dpdpoland_shipment_creation #print_labels,
#dpdpoland_shipment_creation #save_labels
{
float:right;
margin-top: 15px;
}
#dpdpoland #print_labels,
#dpdpoland #save_labels
{
margin-right: 10px;
}
.dpdpoland-ps16 #dpdpoland_shipment_creation #save_and_print_labels,
.dpdpoland-ps16 #dpdpoland_shipment_creation #print_labels,
.dpdpoland-ps16 #dpdpoland_shipment_creation #save_labels
{
float: none;
margin-top: 0;
}
#dpdpoland_shipment_creation .infoContainer
{
float:left;
margin-right:10px;
}
#dpdpoland_sender_address_container,
#dpdpoland_recipient_address_container,
#dpdpoland_additional_info_container,
#dpdpoland_shipment_references_container{
width: 420px;
}
.dpdpoland-ps16 #dpdpoland_recipient_address_container,
.dpdpoland-ps16 #dpdpoland_sender_address_container,
.dpdpoland-ps16 #dpdpoland_additional_info_container label
{
width: auto;
}
.dpdpoland-ps16 #dpdpoland_additional_info_container,
.dpdpoland-ps16 #dpdpoland_shipment_references_container
{
width: 50%;
}
#dpdpoland_sender_address_container
{
float: left;
padding-right: 10px;
margin-right: 20px;
border-right: 1px solid #CCCCCC;
}
#dpdpoland_recipient_address_container
{
float: right;
}
.dpdpoland-ps16 #dpdpoland_recipient_address_container, .dpdpoland-ps16 #dpdpoland_sender_address_container
{
float: none;
margin-right: 0;
}
#dpdpoland_sender_address_container h3,
#dpdpoland_recipient_address_container h3
{
margin: 0 0 5px 0;
}
.dpdpoland-ps14 #dpdpoland_sender_address_container label, .dpdpoland-ps15 #dpdpoland_sender_address_container label,
.dpdpoland-ps14 #dpdpoland_recipient_address_container label, .dpdpoland-ps15 #dpdpoland_recipient_address_container label,
.dpdpoland-ps14 #dpdpoland_cod_amount_container label, .dpdpoland-ps15 #dpdpoland_cod_amount_container label,
.dpdpoland-ps14 #dpdpoland_declared_value_amount_container label, .dpdpoland-ps15 #dpdpoland_declared_value_amount_container label,
.dpdpoland-ps14 #dpdpoland_additional_info_container label, .dpdpoland-ps15 #dpdpoland_additional_info_container label,
.dpdpoland-ps14 #dpdpoland_shipment_references_container label, .dpdpoland-ps15 #dpdpoland_shipment_references_container label
{
width: 155px;
}
#dpdpoland_sender_address_container .margin-form,
#dpdpoland_recipient_address_container .margin-form
{
font-size: 1em;
padding: 3px 0 3px 170px;
height: 15px;
width: 260px;
}
.dpdpoland-ps16 #dpdpoland_sender_address_container .margin-form,
.dpdpoland-ps16 #dpdpoland_recipient_address_container .margin-form
{
display: inline-block;
padding:3px 0 3px 20px;
width: 230px;
}
#dpdpoland_cod_amount_container .margin-form,
#dpdpoland_declared_value_amount_container .margin-form,
#dpdpoland_additional_info_container .margin-form,
#dpdpoland_shipment_references_container .margin-form
{
padding: 3px 0 3px 170px;
width: 260px;
}
#dpdpoland_cod_amount_container p,
#dpdpoland_declared_value_amount_container p,
#dpdpoland_additional_info_container p,
#dpdpoland_shipment_references_container p
{
margin: 0;
}
#dpdpoland #dpdpoland_shipment_creation .dpdpoland_address
{
padding-top: 5px;
height: 168px;
}
#dpdpoland.dpdpoland-ps16 #dpdpoland_shipment_creation .dpdpoland_address
{
height: auto;
}
.dpdpoland-ps16 #dpdpoland_recipient_address_container .dpdpoland_address
{
margin-top: 36px;
}
#dpdpoland_recipient_address_selection_container
{
margin-top: 10px;
margin-bottom: 22px;
}
.dpdpoland-ps14 #dpdpoland_recipient_address_selection,
.dpdpoland-ps15 #dpdpoland_recipient_address_selection
{
width: 250px;
}
#dpdpoland_shipment_parcels .delete_parcel,
#dpdpoland_shipment_products .delete_product {
cursor: pointer;
}
#dpdpoland_add_product_container p
{
font-size: 0.85em;
margin-top: 3px;
}
#dpdpoland_add_product
{
margin-left: 8px;
}
.dpdpoland-ps16 #dpdpoland_add_product
{
margin-left: 0;
}
div.ac_results
{
z-index: 200;
}
div.ac_results ul
{
margin: 0;
}
.separation {
background-color: #CCCCCC;
border-bottom: 1px solid #FFFFFF;
height: 1px;
margin: 10px 0;
width: 100%;
}
select.client_number_select
{
width: 120px;
}
fieldset#dpdpoland.extended
{
width: 880px;
}
div#printout_format_container
{
display: block;
float: right;
margin-top: 15px;
margin-right: 15px;
}
.dpdpoland-ps16 div#printout_format_container
{
float: none;
margin-top: inherit;
margin-right: inherit;
}
label.printout_format_label
{
float: right;
width: auto;
margin-top: 15px;
}
.dpdpoland-ps16 label.printout_format_label
{
float: none;
margin-top: inherit;
}
.margin-top-5
{
margin-top: 5px;
}
#dpdpoland_shipment_parcels_container
{
overflow-x: auto;
overflow-y: hidden;
}
#dpdpoland_sender_address_container .info
{
display:block;
}
#dpdpoland .hidden-element
{
display: none;
}
#dpdpoland.dpdpoland-ps14 .displayed-element
{
display: block;
}
#dpdpoland .preference_description
{
display: none;
width: auto;
}
#dpdpoland.dpdpoland-ps14 #parcel_addition_container .infoContainer
{
display:block;
}
#dpdpoland.dpdpoland-ps14 #parcel_addition_container .infoContainer.first
{
width: 751px;
}
#dpdpoland #dpdpoland_current_status_accordion
{
margin-top:10px;
}
#dpdpoland.dpdpoland-ps14 #dpdpoland_current_status_accordion h3
{
margin-bottom:0;
}
#dpdpoland_cud, #dpdpoland_rod, #dpdpoland_dpde{
margin-top: 10px;
}
#dpdpoland_duty{
margin: 10px 0 10px 0;
}
#dpdpoland_shipment_creation .control-label .col-lg-3{
text-align: left;
}

View File

@@ -0,0 +1,215 @@
.process-icon-help {
background-image: url("../img/toolbar/help.png");
}
.process-icon-settings {
background-image: url("../img/toolbar/setting_tools.png");
}
.process-icon-csv {
background-image: url("../img/toolbar/csv_tools.png");
}
.process-icon-arrange_pickup {
background-image: url("../img/toolbar/arrange_pickup.png");
}
.process-icon-packages_list {
background-image: url("../img/toolbar/packages_list.png");
}
.process-icon-manifest_list {
background-image: url("../img/toolbar/manifest_list.png");
}
.process-icon-add_new {
background-image: url("../img/toolbar/process-icon-new.png");
}
.process-icon-parcel_history_list {
background-image: url("../img/toolbar/parcels_history.png");
}
.process-icon-country_list {
background-image: url("../img/toolbar/shipment_countries.png");
}
.process-icon-sender_address {
background-image: url("../img/toolbar/sender_address.png");
}
/* hides prestashop help button */
li.help-context-AdminModules, li.help-context-adminmodules {
display: none !important;
}
#custom_web_service_container {
display: none;
}
p.connection_message {
display: none;
}
.csv_information_block {
margin-left: 100px;
}
img.pagination_image {
margin-bottom: 4px;
}
table#packages_list tr.nodrag.nodrop a,
table#packages_list tr.nodrag.nodrop a:hover,
table#manifests_list tr.nodrag.nodrop a,
table#manifests_list tr.nodrag.nodrop a:hover,
table#parcel_history_list tr.nodrag.nodrop a,
table#parcel_history_list tr.nodrag.nodrop a:hover,
table#country_list tr.nodrag.nodrop a,
table#country_list tr.nodrag.nodrop a:hover,
table#sender_address_list tr.nodrag.nodrop a,
table#sender_address_list tr.nodrag.nodrop a:hover {
text-decoration: none;
}
.payment_modules_container {
border: 1px solid #CCCCCC;
width: auto;
float: left;
padding: 10px;
}
.payment_modules_container label {
width: auto;
float: none;
}
form table#country_list,
form table#manifests_list,
form table#sender_address_list,
form table.sender_address_list {
width: 100%;
}
#help_container a {
text-decoration: underline;
}
#help_container a:hover {
text-decoration: none;
}
#zones_table_container,
#client_numbers_table_container,
#csv_list_table_container {
overflow-x: auto;
overflow-y: hidden;
}
#ws_url p.help-block {
word-break: break-all;
}
.relative {
position: relative;
}
.hidden-element {
display: none;
}
.visible-element {
display: block;
}
.float-left {
float: left;
}
.add-client-number-button-container {
float: left;
margin-left: 20px;
}
#configuration_form #zones_table {
max-width: 100%;
}
.bottom {
vertical-align: bottom;
}
.float-right {
float: right;
}
table.table.Countries,
table.table.document,
table.table.Manifests,
table.table.Packages,
table.table.ParcelHistories {
width: 100%;
margin-bottom: 10px;
}
table.table.document.numbers-table {
width: 90%;
margin-bottom: 10px;
}
table tr.titles-row {
height: 40px;
}
table tr.filter-row {
height: 35px;
}
table tr.filter-row input {
width: 95%;
}
table tr.filter-row .right input {
width: 70px;
}
td.no-border {
border: none;
}
.manifest-list-buttons,
.packages-list-buttons,
.parcel-history-list-buttons {
white-space: nowrap;
}
#current_obj {
font-weight: normal;
}
#current_obj img {
margin-right: 5px;
}
#navbar-collapse ul li a span {
margin-right: 5px;
}
.payer-number-delete-button {
cursor: pointer;
}
.list-style-type-circle {
list-style-type: disc;
padding-left: 40px;
}
#content_header img {
float: left;
margin-right: 20px;
margin-bottom: 8px;
}
#content_header p.description {
float: left;
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,26 @@
.dpdpoland-pudo-container, .dpdpoland-pudo-cod-container, .dpdpoland-swipbox-container {
padding: 0 0 15px 0;
}
.dpdpoland-pudo-container span, .dpdpoland-pudo-cod-container span, .dpdpoland-swipbox-container span {
color: #464646;
}
@media (min-width: 1299px) {
.modal-dpd-xl {
max-width: 1200px;
}
}
.modal-dpd-body {
padding: 5px 5px 0 5px;
}
.modal-dpd-content {
padding: 0 !important;
margin: 0;
}
.modal-dpd-footer {
padding: 5px;
}

View File

@@ -0,0 +1,37 @@
.dpdpoland-pudo-open-map-btn, .dpdpoland-swipbox-open-map-btn {
margin-left: 5px;
font-weight: normal;
text-transform: none;
font-size: 13px;
}
.dpdpoland-pudo-change-map-btn, .dpdpoland-swipbox-change-map-btn {
font-weight: normal;
text-transform: none;
font-size: 13px;
}
.dpdpoland-pudo-cod-new-point, .dpdpoland-pudo-new-point, .dpdpoland-pudo-selected-point p, .dpdpoland-pudo-cod-selected-point p,
.dpdpoland-swipbox-new-point, .dpdpoland-swipbox-new-point, .dpdpoland-swipbox-selected-point p, .dpdpoland-swipbox-cod-selected-point p
{
padding: 0;
font-size: 13px;
margin: 10px 0 0 0;
}
.dpdpoland-pudo-cod-open-map-btn, .dpdpoland-swipbox-open-map-btn {
margin-left: 5px;
font-weight: normal;
text-transform: none;
font-size: 13px;
}
.dpdpoland-pudo-cod-change-map-btn, .dpdpoland-swipbox-change-map-btn {
font-weight: normal;
text-transform: none;
font-size: 13px;
}
.container_dpdpoland_pudo_cod_warning, .container_dpdpoland_swipbox_warning {
margin-top: 10px;
}

View File

@@ -0,0 +1,22 @@
.dpdpoland-pudo-open-map-btn, .dpdpoland-swipbox-open-map-btn {
margin-left: 5px;
font-weight: normal;
text-transform: none;
}
.dpdpoland-pudo-change-map-btn, .dpdpoland-pudo-cod-change-map-btn, .dpdpoland-swipbox-change-map-btn {
margin-right:15px;
font-weight: normal;
text-transform: none;
}
.dpdpoland-pudo-cod-new-point, .dpdpoland-pudo-new-point, .dpdpoland-pudo-selected-point p, .dpdpoland-pudo-cod-selected-point p,
.dpdpoland-swipbox-new-point, .dpdpoland-swipbox-new-point, .dpdpoland-swipbox-selected-point p, .dpdpoland-swipbox-selected-point p {
padding: 0 0 0 15px;
}
.dpdpoland-pudo-cod-open-map-btn, .dpdpoland-swipbox-open-map-btn {
margin-left: 5px;
font-weight: normal;
text-transform: none;
}

View File

@@ -0,0 +1,61 @@
.toolbarBox {
background-color: #F8F8F8;
border: 1px solid #CCCCCC;
border-radius: 3px 3px 3px 3px;
margin-bottom: 10px;
padding: 10px 0;
}
.toolbarBox .pageTitle {
line-height: 48px;
margin-left: 10px;
}
.toolbarBox .pageTitle h3 {
font-size: 2em;
font-weight: bold;
line-height: 48px;
margin: 0;
padding: 0;
}
.toolbarBox ul.cc_button {
float: right;
margin: 0;
padding: 0;
}
.toolbarBox ul.cc_button li {
color: #666666;
float: left;
height: 48px;
list-style: none outside none;
padding: 1px 1px 3px 4px;
text-align: center;
}
.toolbarBox a.toolbar_btn {
border-width: 1px;
cursor: pointer;
display: block;
float: left;
min-width: 50px;
font-size: 11px;
padding: 1px 5px;
text-shadow: 0 1px 0 #FFFFFF;
white-space: nowrap;
border: 1px solid #F8F8F8;
}
.toolbarBox .toolbar_btn span {
display: block;
float: none;
height: 32px;
margin: 0 auto;
width: 32px;
}
.toolbarBox .process-icon-new, .toolbarBox .process-icon-newAttributes {
background-image: url("../img/process-icon-new.png");
}
.toolbarBox a.toolbar_btn:hover {
background-color: #FFFFFF;
border: 1px inset #CCCCCC;
border-radius: 3px 3px 3px 3px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,764 @@
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
togglePudoMap();
if (redirect_and_open) {
toggleShipmentCreationDisplay();
window.location = dpdpoland_pdf_uri + '?printLabels&id_package_ws=' + redirect_and_open + '&printout_format=' + printout_format + '&token=' + encodeURIComponent(dpdpoland_token) +
'&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
}
updateParcelsListData();
$('#dpdpoland_shipment_parcels input[type="text"]').live('keypress', function () {
$(this).addClass('modified');
$(this).siblings('p.preference_description').slideDown('fast');
});
$('#dpdpoland_shipment_parcels input[type="text"]').live('on', 'paste', function () {
$(this).addClass('modified');
$(this).siblings('p.preference_description').slideDown('fast');
});
$('#dpdpoland_shipment_parcels input[type="text"]').live('on', 'input', function () {
$(this).addClass('modified');
$(this).siblings('p.preference_description').slideDown('fast');
});
$('#dpdpoland_duty').on('change', function () {
if (this.checked)
$('#dpdpoland_duty_container').removeClass("hidden");
else
$('#dpdpoland_duty_container').addClass("hidden");
})
$('#dpdpoland_dpdfood').on('change', function () {
if (this.checked)
$('#dpdfood_limit_date_container').removeClass("hidden");
else
$('#dpdfood_limit_date_container').addClass("hidden");
})
$('#dpdpoland_dpdlq').on('change', function () {
if (this.checked) {
$('.adr-package').removeClass("hidden-element");
$('.adr-package input').prop("checked", true)
} else {
$('.adr-package').addClass("hidden-element");
}
})
$('#dpdpoland_recipient_address_selection').live('change', function () {
$('#ajax_running').slideDown();
$('#dpdpoland_recipient_address_container .dpdpoland_address').fadeOut('fast');
const id_address = $(this).val();
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "html",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&getFormattedAddressHTML=true" +
"&id_address=" + encodeURIComponent(id_address),
success: function (address_html) {
$('#ajax_running').slideUp();
$('#dpdpoland_recipient_address_container .dpdpoland_address').html(address_html).fadeIn('fast');
},
error: function () {
$('#ajax_running').slideUp();
}
});
});
setDPDSenderAddress();
$('#sender_address_selection').live('change', function () {
setDPDSenderAddress();
});
$('#dpdpoland_shipment_creation #add_parcel').click(function () {
const max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').attr('value');
const new_parcel_number = Number(max_parcel_number) + 1;
const $tr_parcel = $('<tr />');
const $input_parcel_number = $('<input />').attr({
'type': 'hidden',
'name': 'parcels[' + new_parcel_number + '][number]'
}).val(new_parcel_number);
const $td_parcel_number = $('<td />').addClass('center').append(new_parcel_number).append($input_parcel_number);
$tr_parcel.append($td_parcel_number);
const $input_content_hidden = $('<input />').attr({
'type': 'hidden',
'name': 'parcels[' + new_parcel_number + '][content]'
});
const $input_content = $('<input />').attr({
'type': 'text',
'size': '46',
'name': 'parcels[' + new_parcel_number + '][content]'
});
const $td_content = $('<td />').append($input_content_hidden);
$td_content.append($input_content);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_content.append($modified_message);
$tr_parcel.append($td_content);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
const $adrVisibility = $("#dpdpoland_dpdlq").is(':checked') ? '' : 'hidden-element'
const $input_adr = $('<input />').attr({
'type': 'checkbox',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][adr]',
'checked': 'true'
});
const $td_adr = $('<td />').attr({
'class': 'adr-package ' + $adrVisibility,
}).append($input_adr);
$modified_message.append(modified_field_message);
$td_adr.append($modified_message);
$tr_parcel.append($td_adr);
const $input_weight_adr = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][weight_adr]',
'value': '0.000000'
});
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
const $td_weight_adr = $('<td />').attr({
'class': 'adr-package ' + $adrVisibility,
}).append($input_weight_adr);
$modified_message.append(modified_field_message);
$td_weight_adr.append($modified_message);
$tr_parcel.append($td_weight_adr);
const $input_weight = $('<input />').attr({
'type': 'text',
'size': '10',
'name': 'parcels[' + new_parcel_number + '][weight]',
'value': '0.000000'
});
const $td_weight = $('<td />').append($input_weight);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_weight.append($modified_message);
$tr_parcel.append($td_weight);
const $input_height = $('<input />').attr({
'type': 'text',
'size': '10',
'name': 'parcels[' + new_parcel_number + '][height]',
'value': '0.000000'
});
const $td_height = $('<td />').append($input_height);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_height.append($modified_message);
$tr_parcel.append($td_height);
const $input_length = $('<input />').attr({
'type': 'text',
'size': '10',
'name': 'parcels[' + new_parcel_number + '][length]',
'value': '0.000000'
});
const $td_length = $('<td />').append($input_length);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_length.append($modified_message);
$tr_parcel.append($td_length);
const $input_width = $('<input />').attr({
'type': 'text',
'size': '10',
'name': 'parcels[' + new_parcel_number + '][width]',
'value': '0.000000'
});
const $td_width = $('<td />').append($input_width);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_width.append($modified_message);
$tr_parcel.append($td_width);
$('<td />').addClass('parcel_dimension_weight').text('0.000').appendTo($tr_parcel);
const $td_delete_parcel = $('<td><img src="../img/admin/delete.gif" class="delete_parcel"></td>');
$tr_parcel.append($td_delete_parcel);
$('#dpdpoland_shipment_parcels tbody tr:last').after($tr_parcel);
const $new_parcel_option = $('<option />').val(new_parcel_number).text(new_parcel_number);
$('#dpdpoland_shipment_products').find('select.parcel_selection').append($new_parcel_option);
});
$('#dpdpoland_shipment_parcels .delete_parcel').live('click', function () {
const $tr_parcel = $(this).parent().parent();
const deleted_parcel_number = $tr_parcel.find('input[name$="[number]"]').attr('value');
const max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').val();
$('#dpdpoland_shipment_products select.parcel_selection option[value="' + deleted_parcel_number + '"]').remove();
/* deleting parcel from the middle of list */
if (deleted_parcel_number !== max_parcel_number)
recalculateParcels(deleted_parcel_number);
$tr_parcel.remove();
});
$("#dpdpoland_select_product").autocomplete(dpdpoland_ajax_uri,
{
minChars: 3,
max: 10,
width: 500,
selectFirst: false,
scroll: false,
dataType: "json",
highlightItem: true,
formatItem: function (data, i, max, value, term) {
return value;
},
parse: function (data) {
const products = [];
if (typeof (data.products) != 'undefined')
for (let i = 0; i < data.products.length; i++)
products[i] = {data: data.products[i], value: data.products[i].name};
return products;
},
extraParams: {
ajax: true,
token: dpdpoland_token,
getProducts: 'true',
id_lang: dpdpoland_id_lang,
id_shop: dpdpoland_id_shop
}
}
)
.result(function (event, data, formatted) {
$(this).val(formatted);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value', data.id_product);
if (!data.id_product_attribute) {
data.id_product_attribute = 0;
}
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value', data.id_product_attribute);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value', data.weight_numeric);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value', data.parcel_content);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value', data.weight);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value', data.name);
});
$('#dpdpoland_add_product').live('click', function () {
const id_product = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value');
if (Number(id_product)) {
const id_product_attribute = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value');
const weight_numeric = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value');
const parcel_content = $('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value');
const weight = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value');
const product_name = $('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value');
const $tr_product = $('<tr />');
const new_product_index = $('#dpdpoland_shipment_products tbody tr').length;
const $input_id_product = $('<input />').attr({
'type': 'hidden',
'name': 'dpdpoland_products[' + new_product_index + '][id_product]',
'value': id_product
});
const $input_id_product_attribute = $('<input />').attr({
'type': 'hidden',
'name': 'dpdpoland_products[' + new_product_index + '][id_product_attribute]',
'value': id_product_attribute
});
const $td_parcel_reference = $('<td />').addClass('parcel_reference').append($input_id_product, $input_id_product_attribute, parcel_content);
$td_parcel_reference.appendTo($tr_product);
const $input_weight_hidden = $('<input />').attr({
'type': 'hidden',
'name': 'parcel_weight',
'value': weight_numeric
});
$('<td />').addClass('product_name').text(product_name).appendTo($tr_product);
$('<td />').addClass('parcel_weight').append($input_weight_hidden, weight).appendTo($tr_product);
const $parcels_selection = $('#dpdpoland_shipment_products select.parcel_selection:first').clone();
$parcels_selection.attr('name', 'dpdpoland_products[' + new_product_index + '][parcel]').find('option:first').attr('selected', 'selected');
$('<td />').append($parcels_selection).appendTo($tr_product);
const $td_delete_product = $('<td />');
const $img_delete_parcel = $('<img />').attr({'src': '../img/admin/delete.gif'}).addClass('delete_product').appendTo($td_delete_product);
$tr_product.append($td_delete_product);
$('#dpdpoland_shipment_products tbody tr:last').after($tr_product);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value', 0);
$('#dpdpoland_select_product').attr('value', '');
}
});
$('#dpdpoland_shipment_products .delete_product').live('click', function () {
$(this).parents('tr:first').remove();
});
$('#save_and_print_labels').click(function () {
let available = true;
$('#dpdpoland_shipment_products .parcel_selection').each(function () {
if ($(this).val() === '' || $(this).val() === 0) {
available = false;
alert(dpdpoland_parcels_error_message);
}
});
if (!available)
return false;
$('#ajax_running').slideDown();
$('#dpdpoland_msg_container').slideUp().html('');
const pudo_code = $('#dpdpoland_pudo_code_input').val();
let pudo_data = "";
if (pudo_code.length > 0) {
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
}
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_order=" + encodeURIComponent(id_order) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
"&savePackagePrintLabels=true&" + $('#dpdpoland :input').serialize() +
pudo_data,
success: function (resp) {
if (resp.error) {
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
$.scrollTo('#dpdpoland', 400, {offset: {top: -100}});
} else {
id_package_ws = resp.id_package_ws;
window.location = dpdpoland_pdf_uri + resp.link_to_labels_pdf + '&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
}
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
});
$('#save_labels').click(function () {
let available = true;
$('#dpdpoland_shipment_products .parcel_selection').each(function () {
if ($(this).val() === '' || $(this).val() === 0) {
available = false;
alert(dpdpoland_parcels_error_message);
}
});
if (!available)
return false;
$('#ajax_running').slideDown();
$('#dpdpoland_msg_container').slideUp().html('');
const pudo_code = $('#dpdpoland_pudo_code_input').val();
let pudo_data = "";
if (pudo_code.length > 0) {
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
}
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_order=" + encodeURIComponent(id_order) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&sender_address_selection=" + $('#sender_address_selection').val() +
"&printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
"&savePackagePrintLabels=true&" + $('#dpdpoland :input').serialize() +
pudo_data,
success: function (resp) {
if (resp.error) {
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
$.scrollTo('#dpdpoland', 400, {offset: {top: -100}});
} else {
current_order_uri = current_order_uri.replace(/&amp;/g, '&') + '&scrollToShipment';
window.location = current_order_uri;
}
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
});
$('#print_labels').live('click', function () {
$('#ajax_running').slideDown();
$('#dpdpoland_msg_container').slideUp().html('');
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_order=" + encodeURIComponent(id_order) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&printLabels=true" +
"&dpdpoland_printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
"&id_package_ws=" + encodeURIComponent(id_package_ws) +
"&_PS_ADMIN_DIR_=" + encodeURIComponent(_PS_ADMIN_DIR_),
success: function (resp) {
if (resp.error) {
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
} else {
window.location = dpdpoland_pdf_uri + resp.link_to_labels_pdf + '&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
}
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
});
$("#dpdpoland_shipment_parcels input").live("change keyup paste", function () {
const default_value = 0;
const $inputs_container = $(this).parents('tr:first');
const height = $inputs_container.find('input[name$="[height]"]').attr('value');
const length = $inputs_container.find('input[name$="[length]"]').attr('value');
const width = $inputs_container.find('input[name$="[width]"]').attr('value');
let dimention_weight = Number(length) * Number(width) * Number(height) / Number(_DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_);
if (dimention_weight > 0) {
dimention_weight = dimention_weight.toFixed(3);
} else {
dimention_weight = default_value.toFixed(3);
}
$inputs_container.find('td.parcel_dimension_weight').text(dimention_weight);
});
const shipment_mode_select = $('select[name="dpdpoland_SessionType"]');
toggleServiceInputs(shipment_mode_select.val());
shipment_mode_select.change(function () {
togglePudoMap();
toggleServiceInputs($(this).val());
});
$('#dpdpoland_shipment_products select.parcel_selection').live('change', function () {
updateParcelsListData();
});
});
function toggleServiceInputs(shipment_mode) {
const cod_container = $('#dpdpoland_cod_amount_container');
const dpd_next_day_container = $('#dpdpoland_dpdnd_container');
const dpd_express_container = $('#dpdpoland_dpde_container');
const dpd_food_container = $('.dpdpoland_dpdfood_container');
const dpd_today_container = $('.dpdpoland_dpdtoday_container');
const dpd_saturday_container = $('.dpdpoland_dpdsaturday_container');
const isCodPaymentMethod = $('#dpdpoland_is_cod_payment_method').val();
if (shipment_mode === 'domestic_with_cod' || shipment_mode === 'pudo_cod' || isCodPaymentMethod === '1') {
cod_container.fadeIn();
cod_container.show();
} else {
cod_container.fadeOut();
}
if (shipment_mode === 'international') {
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
dpd_next_day_container.hide();
dpd_express_container.fadeIn();
dpd_food_container.fadeIn();
dpd_today_container.fadeIn();
dpd_saturday_container.fadeIn();
} else if (shipment_mode === 'domestic' || shipment_mode === 'domestic_with_cod') {
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
dpd_express_container.hide();
dpd_next_day_container.fadeIn();
dpd_food_container.fadeIn();
dpd_today_container.fadeIn();
dpd_saturday_container.fadeIn();
} else {
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
dpd_today_container.find('input#dpdpoland_dpdtoday').prop('checked', false);
dpd_saturday_container.find('input#dpdpoland_dpdsaturday').prop('checked', false);
dpd_food_container.find('input#dpdpoland_dpdfood').prop('checked', false);
dpd_express_container.fadeOut();
dpd_next_day_container.fadeOut();
dpd_food_container.fadeOut();
dpd_today_container.fadeOut();
dpd_saturday_container.fadeOut();
}
if ($("#dpdpoland_dpdlq").is(':checked')) {
$('.adr-package').removeClass("hidden-element")
$('.adr-package input').prop("checked", true)
} else {
$('.adr-package').addClass("hidden-element")
}
}
function updateParcelsListData() {
const attr = $('#dpdpoland_shipment_creation select[name="dpdpoland_SessionType"]').attr('disabled');
if (typeof attr !== 'undefined' && attr !== false) {
return;
}
const default_value = 0;
const products_count = $('#dpdpoland_shipment_products .parcel_reference').length;
$('#dpdpoland_shipment_parcels td:nth-child(2) input[type="text"]').not('.modified').attr('value', '');
$('#dpdpoland_shipment_parcels td:nth-child(4) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(5) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(2) input[type="hidden"]').attr('value', '');
$('#dpdpoland_shipment_products .parcel_reference').each(function () {
let product_weight = $(this).parent().find('td:nth-child(3)').find('input[type="hidden"]').val();
product_weight = Number(product_weight);
let product_id = $(this).find('input[type="hidden"]:nth-child(1)').val();
let product_attr_id = $(this).find('input[type="hidden"]:nth-child(2)').val();
const product_reference = $(this).find('input[type="hidden"]:nth-child(3)').val()
const product_name = $(this).find('input[type="hidden"]:nth-child(4)').val()
const productContent = getProductContent(product_id, product_attr_id, product_reference, product_name)
const parcel_id = $(this).siblings().find('select').val();
const parcel_description_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(2)').find('input[type="text"]');
const parcel_adr_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(3)').find('input[type="text"]');
const parcel_weight_adr_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(4)').find('input[type="text"]');
const parcel_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(5)').find('input[type="text"]');
const parcel_height_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(6)').find('input[type="text"]');
const parcel_length_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(7)').find('input[type="text"]');
const parcel_width_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(8)').find('input[type="text"]');
const parcel_dimension_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(9)');
const parcel_description_safe = parcel_description_field.siblings('input[type="hidden"]:first');
let weights = parcel_weight_field.val();
weights = Number(weights);
weights = weights + product_weight;
const description = getProductDescription(parcel_description_safe, productContent)
if (!parcel_weight_field.hasClass('modified')) {
parcel_weight_field.attr('value', weights.toFixed(6));
}
if (!parcel_description_field.hasClass('modified')) {
parcel_description_field.attr('value', description);
parcel_description_safe.attr('value', description);
}
if (products_count === 1) {
$('#dpdpoland_shipment_parcels td:nth-child(6) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(7) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(8) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(9)').not('.modified').text(default_value.toFixed(3));
parcel_height_field.attr('value', $('#product_height').val());
parcel_length_field.attr('value', $('#product_length').val());
parcel_width_field.attr('value', $('#product_width').val());
if (!parcel_height_field.hasClass('modified') &&
!parcel_length_field.hasClass('modified') &&
!parcel_width_field.hasClass('modified')
) {
const value = parcel_height_field.val() * parcel_length_field.val() * parcel_width_field.val() / _DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_;
parcel_dimension_weight_field.text(value.toFixed(3));
}
}
});
}
function getProductContent(product_id, product_attr_id, product_reference, product_name) {
const parcel_content_source = $('input[name="dpdpoland_parcel_content_type"]').val()
switch (parcel_content_source) {
case "PARCEL_CONTENT_SOURCE_SKU":
return product_reference
case "PARCEL_CONTENT_SOURCE_PRODUCT_ID":
return product_id + "_" + product_attr_id
case "PARCEL_CONTENT_SOURCE_PRODUCT_NAME":
return product_name
}
return product_id + "_" + product_attr_id;
}
function getProductDescription(parcel_description_safe, newContent) {
const current_value = parcel_description_safe.attr('value')
if (!current_value || current_value === '' || current_value.indexOf(newContent) >= 0)
if (current_value === null || current_value === undefined || current_value === '')
return newContent;
if(current_value.indexOf(newContent) >= 0)
return current_value;
return current_value + ', ' + newContent;
}
function displayErrorInShipmentArea(errorText) {
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + errorTextr + '</p>').slideDown();
}
function recalculateParcels(deleted_parcel_number) {
$('#dpdpoland_shipment_parcels input[name$="[number]"]').each(function () {
const parcel_number = Number($(this).attr('value'));
if (parcel_number > deleted_parcel_number) {
const updated_parcel_number = parcel_number - 1;
const $input = $(this).attr('value', updated_parcel_number);
$(this).parent().text(updated_parcel_number).append($input);
$(this).parent().parent().find('input[name^="parcels"]').each(function () {
$(this).attr('name', $(this).attr('name').replace(parcel_number, updated_parcel_number));
});
$('#dpdpoland_shipment_products select.parcel_selection option[value="' + parcel_number + '"]').attr('value', updated_parcel_number).text(updated_parcel_number);
}
});
}
function toggleShipmentCreationDisplay() {
const $display_cont = $('#dpdpoland_shipment_creation');
const $legend = $display_cont.siblings('legend').find('a');
const fieldset_title_substitution = $legend.attr('rel');
const current_fieldset_title = $legend.text();
const $dpd_fieldset = $('fieldset#dpdpoland');
if ($dpd_fieldset.hasClass('extended')) {
$display_cont.slideToggle(function () {
$dpd_fieldset.removeClass('extended');
});
} else {
$dpd_fieldset.addClass('extended');
$display_cont.slideToggle();
}
$legend.attr('rel', current_fieldset_title).text(fieldset_title_substitution);
}
const animation_speed = 'fast';
function togglePudoMap() {
const selected_carrier = $('select[name="dpdpoland_SessionType"] option:selected').val();
if (typeof selected_carrier == 'undefined') {
return;
}
if (selected_carrier === 'pudo' || selected_carrier === 'pudo_cod' || selected_carrier === 'swipbox') {
$('.pudo-map-container').slideDown(animation_speed);
} else {
$('.pudo-map-container').slideUp(animation_speed);
}
}
function setDPDSenderAddress() {
$('#ajax_running').slideDown();
$('#dpdpoland_sender_address_container .dpdpoland_address').fadeOut('fast');
const id_address = $('#sender_address_selection').val();
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "html",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&getFormattedSenderAddressHTML=true" +
"&id_address=" + encodeURIComponent(id_address),
success: function (address_html) {
$('#ajax_running').slideUp();
$('#dpdpoland_sender_address_container .dpdpoland_address').html(address_html).fadeIn('fast');
},
error: function () {
$('#ajax_running').slideUp();
}
});
}
function savePickupPointAddress(id_point) {
const block = $('.js-result[data-point-id="' + id_point + '"]');
console.log(block.text());
}

View File

@@ -0,0 +1,738 @@
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
togglePudoMap();
if (redirect_and_open) {
toggleShipmentCreationDisplay();
window.location = dpdpoland_pdf_uri + '?printLabels&id_package_ws=' + redirect_and_open + '&printout_format=' + printout_format + '&token=' + encodeURIComponent(dpdpoland_token) +
'&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
}
updateParcelsListData();
$('#dpdpoland_shipment_parcels').on('keypress', function () {
$(this).addClass('modified');
$(this).siblings('p.preference_description').slideDown('fast');
});
$('#dpdpoland_shipment_parcels').on('paste', 'input[type="text"]', function () {
$(this).addClass('modified');
$(this).siblings('p.preference_description').slideDown('fast');
});
$('#dpdpoland_shipment_parcels').on('input', 'input[type="text"]', function () {
$(this).addClass('modified');
$(this).siblings('p.preference_description').slideDown('fast');
});
$('#dpdpoland_duty').on('change', function () {
if (this.checked)
$('#dpdpoland_duty_container').removeClass("d-none");
else
$('#dpdpoland_duty_container').addClass("d-none");
})
$('#dpdpoland_dpdfood').on('change', function () {
if (this.checked)
$('#dpdfood_limit_date_container').removeClass("d-none");
else
$('#dpdfood_limit_date_container').addClass("d-none");
})
$('#dpdpoland_dpdlq').on('change', function () {
if (this.checked) {
$('.adr-package').removeClass("d-none");
$('.adr-package input').prop("checked", true)
} else {
$('.adr-package').addClass("d-none");
}
})
$('#dpdpoland_recipient_address_selection').on('change', function () {
$('#ajax_running').slideDown();
$('#dpdpoland_recipient_address_container .dpdpoland_address').fadeOut('fast');
const id_address = $(this).val();
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "html",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&getFormattedAddressHTML=true" +
"&id_address=" + encodeURIComponent(id_address),
success: function (address_html) {
$('#ajax_running').slideUp();
$('#dpdpoland_recipient_address_container .dpdpoland_address').html(address_html).fadeIn('fast');
},
error: function () {
$('#ajax_running').slideUp();
}
});
});
setDPDSenderAddress();
$('#sender_address_selection').on('change', function () {
setDPDSenderAddress();
});
$('#dpdpoland_shipment_creation #add_parcel').on('click', function () {
const max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').attr('value');
const new_parcel_number = Number(max_parcel_number) + 1;
const $tr_parcel = $('<tr />');
const $input_parcel_number = $('<input />').attr({
'type': 'hidden',
'name': 'parcels[' + new_parcel_number + '][number]'
}).val(new_parcel_number);
const $td_parcel_number = $('<td />').addClass('center').append(new_parcel_number).append($input_parcel_number);
$tr_parcel.append($td_parcel_number);
const $input_content_hidden = $('<input />').attr({
'type': 'hidden',
'name': 'parcels[' + new_parcel_number + '][content]'
});
const $input_content = $('<input />').attr({
'type': 'text',
'size': '46',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][content]'
});
const $td_content = $('<td />').append($input_content_hidden);
$td_content.append($input_content);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_content.append($modified_message);
$tr_parcel.append($td_content);
const $adrVisibility = $("#dpdpoland_dpdlq").is(':checked') ? '' : 'd-none'
const $input_adr = $('<input />').attr({
'type': 'checkbox',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][adr]',
'checked': 'true'
});
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
const $td_adr = $('<td />').attr({
'class': 'adr-package ' + $adrVisibility,
}).append($input_adr);
$modified_message.append(modified_field_message);
$td_adr.append($modified_message);
$tr_parcel.append($td_adr);
const $input_weight_adr = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][weight_adr]',
'value': '0.000000'
});
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
const $td_weight_adr = $('<td />').attr({
'class': 'adr-package ' + $adrVisibility,
}).append($input_weight_adr);
$modified_message.append(modified_field_message);
$td_weight_adr.append($modified_message);
$tr_parcel.append($td_weight_adr);
const $input_weight = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][weight]',
'value': '0.000000'
});
const $td_weight = $('<td />').append($input_weight);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_weight.append($modified_message);
$tr_parcel.append($td_weight);
const $input_height = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][height]',
'value': '0.000000'
});
const $td_height = $('<td />').append($input_height);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_height.append($modified_message);
$tr_parcel.append($td_height);
const $input_length = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][length]',
'value': '0.000000'
});
const $td_length = $('<td />').append($input_length);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_length.append($modified_message);
$tr_parcel.append($td_length);
const $input_width = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][width]',
'value': '0.000000'
});
const $td_width = $('<td />').append($input_width);
var $modified_message = $('<p />').attr({
'class': 'preference_description clear',
'style': 'display: none; width: auto;'
});
$modified_message.append(modified_field_message);
$td_width.append($modified_message);
$tr_parcel.append($td_width);
$('<td />').addClass('parcel_dimension_weight').text('0.000').appendTo($tr_parcel);
const $td_delete_parcel = $('<td />');
const $delete_btn = $('<input />').attr({
'type': 'button',
'size': '10',
'value': 'X'
});
$delete_btn.addClass('delete_parcel').appendTo($td_delete_parcel);
$tr_parcel.append($td_delete_parcel);
$('#dpdpoland_shipment_parcels tbody tr:last').after($tr_parcel);
const $new_parcel_option = $('<option />').val(new_parcel_number).text(new_parcel_number);
$('#dpdpoland_shipment_products').find('select.parcel_selection').append($new_parcel_option);
});
$('#dpdpoland_shipment_parcels').on('click', '.delete_parcel', function () {
const $tr_parcel = $(this).parent().parent();
const deleted_parcel_number = $tr_parcel.find('input[name$="[number]"]').attr('value');
const max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').val();
$('#dpdpoland_shipment_products select.parcel_selection option[value="' + deleted_parcel_number + '"]').remove();
/* deleting parcel from the middle of list */
if (deleted_parcel_number != max_parcel_number)
recalculateParcels(deleted_parcel_number);
$tr_parcel.remove();
});
$('#dpdpoland_add_product').on('click', function () {
const id_product = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value');
if (Number(id_product)) {
const id_product_attribute = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value');
const weight_numeric = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value');
const parcel_content = $('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value');
const weight = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value');
const product_name = $('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value');
const $tr_product = $('<tr />');
const new_product_index = $('#dpdpoland_shipment_products tbody tr').length;
const $input_id_product = $('<input />').attr({
'type': 'hidden',
'name': 'dpdpoland_products[' + new_product_index + '][id_product]',
'value': id_product
});
const $input_id_product_attribute = $('<input />').attr({
'type': 'hidden',
'name': 'dpdpoland_products[' + new_product_index + '][id_product_attribute]',
'value': id_product_attribute
});
const $td_parcel_reference = $('<td />').addClass('parcel_reference').append($input_id_product, $input_id_product_attribute, parcel_content);
$td_parcel_reference.appendTo($tr_product);
const $input_weight_hidden = $('<input />').attr({
'type': 'hidden',
'name': 'parcel_weight',
'value': weight_numeric
});
$('<td />').addClass('product_name').text(product_name).appendTo($tr_product);
$('<td />').addClass('parcel_weight').append($input_weight_hidden, weight).appendTo($tr_product);
const $parcels_selection = $('#dpdpoland_shipment_products select.parcel_selection:first').clone();
$parcels_selection.attr('name', 'dpdpoland_products[' + new_product_index + '][parcel]').find('option:first').attr('selected', 'selected');
$('<td />').append($parcels_selection).appendTo($tr_product);
const $td_delete_product = $('<td />');
const $img_delete_parcel = $('<p />').attr({'src': '../img/admin/delete.gif'}).addClass('delete_product').appendTo($td_delete_product);
$tr_product.append($td_delete_product);
$('#dpdpoland_shipment_products tbody tr:last').after($tr_product);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_parcel_content').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value', 0);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value', 0);
$('#dpdpoland_select_product').attr('value', '');
}
});
$('#dpdpoland_shipment_products').on('click', '.delete_product', function () {
$(this).parents('tr:first').remove();
});
$('#save_and_print_labels').click(function () {
let available = true;
$('#dpdpoland_shipment_products .parcel_selection').each(function () {
if ($(this).val() == '' || $(this).val() == 0) {
available = false;
alert(dpdpoland_parcels_error_message);
}
});
if (!available)
return false;
$('#ajax_running').slideDown();
$('#dpdpoland_msg_container').slideUp().html('');
const pudo_code = $('#dpdpoland_pudo_code_input').val();
let pudo_data = "";
if (pudo_code.length > 0) {
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
}
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_order=" + encodeURIComponent(id_order) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
"&savePackagePrintLabels=true&" + $('#dpdpoland :input').serialize() +
pudo_data,
success: function (resp) {
if (resp.error) {
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
$([document.documentElement, document.body]).animate({
scrollTop: $("#dpdpoland").offset().top - 150
}, 400);
} else {
id_package_ws = resp.id_package_ws;
window.location = dpdpoland_pdf_uri + resp.link_to_labels_pdf + '&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
}
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
});
$('#save_labels').click(function () {
let available = true;
$('#dpdpoland_shipment_products .parcel_selection').each(function () {
if ($(this).val() == '' || $(this).val() == 0) {
available = false;
alert(dpdpoland_parcels_error_message);
}
});
if (!available)
return false;
$('#ajax_running').slideDown();
$('#dpdpoland_msg_container').slideUp().html('');
const pudo_code = $('#dpdpoland_pudo_code_input').val();
let pudo_data = "";
if (pudo_code.length > 0) {
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
}
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_order=" + encodeURIComponent(id_order) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&sender_address_selection=" + $('#sender_address_selection').val() +
"&printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
"&savePackagePrintLabels=true&" + $('#dpdpoland :input').serialize() +
pudo_data,
success: function (resp) {
if (resp.error) {
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
$([document.documentElement, document.body]).animate({
scrollTop: $("#dpdpoland").offset().top - 150
}, 400);
} else {
current_order_uri = current_order_uri.replace(/&amp;/g, '&') + '&scrollToShipment';
window.location = current_order_uri;
}
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
});
$('#print_labels').on('click', function () {
$('#ajax_running').slideDown();
$('#dpdpoland_msg_container').slideUp().html('');
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_order=" + encodeURIComponent(id_order) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&printLabels=true" +
"&dpdpoland_printout_format=" + encodeURIComponent($('input[name="dpdpoland_printout_format"]:checked').val()) +
"&id_package_ws=" + encodeURIComponent(id_package_ws) +
"&_PS_ADMIN_DIR_=" + encodeURIComponent(_PS_ADMIN_DIR_),
success: function (resp) {
if (resp.error) {
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + resp.error + '</p>').slideDown();
} else {
window.location = dpdpoland_pdf_uri + resp.link_to_labels_pdf + '&_PS_ADMIN_DIR_=' + encodeURIComponent(_PS_ADMIN_DIR_) + '&returnOnErrorTo=' + encodeURIComponent(window.location.href);
}
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
});
$("#dpdpoland_shipment_parcels input").on("change keyup paste", function () {
const default_value = 0;
const $inputs_container = $(this).parents('tr:first');
const height = $inputs_container.find('input[name$="[height]"]').attr('value');
const length = $inputs_container.find('input[name$="[length]"]').attr('value');
const width = $inputs_container.find('input[name$="[width]"]').attr('value');
let dimention_weight = Number(length) * Number(width) * Number(height) / Number(_DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_);
if (dimention_weight > 0) {
dimention_weight = dimention_weight.toFixed(3);
} else {
dimention_weight = default_value.toFixed(3);
}
$inputs_container.find('td.parcel_dimension_weight').text(dimention_weight);
});
const shipment_mode_select = $('select[name="dpdpoland_SessionType"]');
toggleServiceInputs(shipment_mode_select.val());
shipment_mode_select.change(function () {
togglePudoMap();
toggleServiceInputs($(this).val());
});
$('#dpdpoland_shipment_products select.parcel_selection').on('change', function () {
updateParcelsListData();
});
});
function toggleServiceInputs(shipment_mode) {
const cod_container = $('#dpdpoland_cod_amount_container');
const dpd_next_day_container = $('#dpdpoland_dpdnd_container');
const dpd_express_container = $('#dpdpoland_dpde_container');
const dpd_food_container = $('.dpdpoland_dpdfood_container');
const dpd_today_container = $('.dpdpoland_dpdtoday_container');
const dpd_saturday_container = $('.dpdpoland_dpdsaturday_container');
const isCodPaymentMethod = $('#dpdpoland_is_cod_payment_method').val();
if (shipment_mode === 'domestic_with_cod' || shipment_mode === 'pudo_cod' || isCodPaymentMethod === '1') {
cod_container.fadeIn();
cod_container.show();
} else {
cod_container.fadeOut();
}
if (shipment_mode === 'international') {
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
dpd_next_day_container.hide();
dpd_express_container.fadeIn();
dpd_food_container.fadeIn();
dpd_today_container.fadeIn();
dpd_saturday_container.fadeIn();
} else if (shipment_mode === 'domestic' || shipment_mode === 'domestic_with_cod') {
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
dpd_express_container.hide();
dpd_next_day_container.fadeIn();
dpd_food_container.fadeIn();
dpd_today_container.fadeIn();
dpd_saturday_container.fadeIn();
} else {
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
dpd_today_container.find('input#dpdpoland_dpdtoday').prop('checked', false);
dpd_saturday_container.find('input#dpdpoland_dpdsaturday').prop('checked', false);
dpd_food_container.find('input#dpdpoland_dpdfood').prop('checked', false);
dpd_express_container.fadeOut();
dpd_next_day_container.fadeOut();
dpd_food_container.fadeOut();
dpd_today_container.fadeOut();
dpd_saturday_container.fadeOut();
}
if ($("#dpdpoland_dpdlq").is(':checked')) {
$('.adr-package').removeClass("d-none")
$('.adr-package input').prop("checked", true)
} else {
$('.adr-package').addClass("d-none")
}
}
function updateParcelsListData() {
const attr = $('#dpdpoland_shipment_creation select[name="dpdpoland_SessionType"]').attr('disabled');
if (typeof attr !== 'undefined' && attr !== false) {
return;
}
const default_value = 0;
const products_count = $('#dpdpoland_shipment_products .parcel_reference').length;
$('#dpdpoland_shipment_parcels td:nth-child(2) input[type="text"]').not('.modified').attr('value', '');
$('#dpdpoland_shipment_parcels td:nth-child(4) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(5) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(2) input[type="hidden"]').attr('value', '');
$('#dpdpoland_shipment_products .parcel_reference').each(function () {
let product_weight = $(this).parent().find('td:nth-child(3)').find('input[type="hidden"]').val();
product_weight = Number(product_weight);
let product_id = $(this).find('input[type="hidden"]:nth-child(1)').val();
let product_attr_id = $(this).find('input[type="hidden"]:nth-child(2)').val();
const product_reference = $(this).find('input[type="hidden"]:nth-child(3)').val()
const product_name = $(this).find('input[type="hidden"]:nth-child(4)').val()
const productContent = getProductContent(product_id, product_attr_id, product_reference, product_name)
const parcel_id = $(this).siblings().find('select').val();
const parcel_description_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(2)').find('input[type="text"]');
const parcel_adr_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(3)').find('input[type="text"]');
const parcel_weight_adr_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(4)').find('input[type="text"]');
const parcel_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(5)').find('input[type="text"]');
const parcel_height_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(6)').find('input[type="text"]');
const parcel_length_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(7)').find('input[type="text"]');
const parcel_width_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(8)').find('input[type="text"]');
const parcel_dimension_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(9)');
const parcel_description_safe = parcel_description_field.siblings('input[type="hidden"]:first');
let weights = parcel_weight_field.val();
weights = Number(weights);
weights = weights + product_weight;
const description = getProductDescription(parcel_description_safe, productContent)
if (!parcel_weight_field.hasClass('modified')) {
parcel_weight_field.attr('value', weights.toFixed(6));
}
if (!parcel_description_field.hasClass('modified')) {
parcel_description_field.attr('value', description);
parcel_description_safe.attr('value', description);
}
if (products_count === 1) {
$('#dpdpoland_shipment_parcels td:nth-child(6) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(7) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(8) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(9)').not('.modified').text(default_value.toFixed(3));
parcel_height_field.attr('value', $('#product_height').val());
parcel_length_field.attr('value', $('#product_length').val());
parcel_width_field.attr('value', $('#product_width').val());
if (!parcel_height_field.hasClass('modified') &&
!parcel_length_field.hasClass('modified') &&
!parcel_width_field.hasClass('modified')
) {
const value = parcel_height_field.val() * parcel_length_field.val() * parcel_width_field.val() / _DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_;
parcel_dimension_weight_field.text(value.toFixed(3));
}
}
});
}
function getProductContent(product_id, product_attr_id, product_reference, product_name) {
const parcel_content_source = $('input[name="dpdpoland_parcel_content_type"]').val()
switch (parcel_content_source) {
case "PARCEL_CONTENT_SOURCE_SKU":
return product_reference
case "PARCEL_CONTENT_SOURCE_PRODUCT_ID":
return product_id + "_" + product_attr_id
case "PARCEL_CONTENT_SOURCE_PRODUCT_NAME":
return product_name
}
return product_id + "_" + product_attr_id;
}
function getProductDescription(parcel_description_safe, newContent) {
const current_value = parcel_description_safe.attr('value')
if (current_value === null || current_value === undefined || current_value === '')
return newContent;
if(current_value.indexOf(newContent) >= 0)
return current_value;
return current_value + ', ' + newContent;
}
function displayErrorInShipmentArea(errorText) {
$('#dpdpoland_msg_container').hide().html('<p class="error alert alert-danger">' + errorTextr + '</p>').slideDown();
}
function recalculateParcels(deleted_parcel_number) {
$('#dpdpoland_shipment_parcels input[name$="[number]"]').each(function () {
const parcel_number = Number($(this).attr('value'));
if (parcel_number > deleted_parcel_number) {
const updated_parcel_number = parcel_number - 1;
const $input = $(this).attr('value', updated_parcel_number);
$(this).parent().text(updated_parcel_number).append($input);
$(this).parent().parent().find('input[name^="parcels"]').each(function () {
$(this).attr('name', $(this).attr('name').replace(parcel_number, updated_parcel_number));
});
$('#dpdpoland_shipment_products select.parcel_selection option[value="' + parcel_number + '"]').attr('value', updated_parcel_number).text(updated_parcel_number);
}
});
}
function toggleShipmentCreationDisplay() {
const $display_cont = $('#dpdpoland_shipment_creation');
const $legend = $display_cont.siblings('legend').find('a');
const fieldset_title_substitution = $legend.attr('rel');
const current_fieldset_title = $legend.text();
const $dpd_fieldset = $('fieldset#dpdpoland');
if ($dpd_fieldset.hasClass('extended')) {
$display_cont.slideToggle(function () {
$dpd_fieldset.removeClass('extended');
});
} else {
$dpd_fieldset.addClass('extended');
$display_cont.slideToggle();
}
$legend.attr('rel', current_fieldset_title).text(fieldset_title_substitution);
}
const animation_speed = 'fast';
function togglePudoMap() {
const selected_carrier = $('select[name="dpdpoland_SessionType"] option:selected').val();
if (typeof selected_carrier == 'undefined') {
return;
}
if (selected_carrier === 'pudo' || selected_carrier === 'pudo_cod' || selected_carrier === 'swipbox') {
$('.pudo-map-container').slideDown(animation_speed);
} else {
$('.pudo-map-container').slideUp(animation_speed);
}
}
function setDPDSenderAddress() {
$('#ajax_running').slideDown();
$('#dpdpoland_sender_address_container .dpdpoland_address').fadeOut('fast');
const id_address = $('#sender_address_selection').val();
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "html",
global: false,
data: "ajax=true&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang) +
"&getFormattedSenderAddressHTML=true" +
"&id_address=" + encodeURIComponent(id_address),
success: function (address_html) {
$('#ajax_running').slideUp();
$('#dpdpoland_sender_address_container .dpdpoland_address').html(address_html).fadeIn('fast');
},
error: function () {
$('#ajax_running').slideUp();
}
});
}
function savePickupPointAddress(id_point) {
const block = $('.js-result[data-point-id="' + id_point + '"]');
console.log(block.text());
}

View File

@@ -0,0 +1,51 @@
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function(){
$('#form-order').on('click', '.bulk-actions a', function(event){
event.preventDefault();
var selector = $(this);
if (selector.find('i').hasClass('dpd-label')) {
var current_url = $('#form-order').attr('action');
var new_url = current_url.replace('&submitBulkprint_a4order', '');
$('#form-order').attr('action', new_url);
$('#form-order').submit();
return true;
}
if (selector.find('i').hasClass('dpd-a4')) {
var current_url = $('#form-order').attr('action');
var new_url = current_url.replace('&submitBulkprint_labelorder', '');
$('#form-order').attr('action', new_url);
$('#form-order').submit();
return true;
}
var current_url = $('#form-order').attr('action');
var new_url = current_url.replace('&submitBulkprint_labelorder', '');
new_url = new_url.replace('&submitBulkprint_a4order', '');
$('#form-order').attr('action', new_url);
return true;
});
});

View File

@@ -0,0 +1,312 @@
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
$('#addClientNumber').click(function () {
addClientNumber();
});
$('#dpd_swipbox').change(function () {
enableDisableZones();
});
$('#dpd_standard_cod').change(function () {
enableDisableZones();
});
$('#dpd_standard').change(function () {
enableDisableZones();
});
$('#dpd_classic').change(function () {
enableDisableZones();
});
$('#dpd_pudo').change(function () {
enableDisableZones();
});
$('#dpd_pudo_cod').change(function () {
enableDisableZones();
});
$('select[name="pickupTime"]').live('change', function () {
calculateTimeLeftForArrangePickup();
});
$('#pickupDate').live("change keyup paste", function () {
getTimeFramesByDate();
});
$('#sender_address_selection').live("change", function () {
getTimeFramesByDate();
});
$('input[name="downloadModuleCSVSettings"]').click(function () {
window.location = dpdpoland_pdf_uri + "?downloadModuleCSVSettings&token=" + encodeURIComponent(dpdpoland_token);
return false;
});
toggleEnvelope();
toggleParcel();
togglePallet();
enableDisableZones();
if ($('#pickup_date').length)
getTimeFramesByDate();
$('#toggleEnvelope').change(function () {
toggleEnvelope();
});
$('#toggleParcel').change(function () {
toggleParcel();
});
$('#togglePallet').change(function () {
togglePallet();
});
toggleAdditionalSettings();
$('#additional_settings .radio input[type="radio"]').on('change', function () {
toggleAdditionalSettings();
});
$('#duty').on('change', function () {
if (this.checked)
$('#declared_value').prop('checked', true);
})
});
function toggleAdditionalSettings() {
$('#additional_settings .hidable').slideUp(0);
$('#additional_settings input[type="radio"]:checked').closest('.radio').find('.hidable').slideDown(0);
}
function enableDisableZones() {
if ($('#dpd_swipbox').is(':checked'))
$('.swipbox_zone').removeAttr('disabled');
else
$('.swipbox_zone').attr('disabled', 'disabled');
if ($('#dpd_standard').is(':checked'))
$('.domestic_zone').removeAttr('disabled');
else
$('.domestic_zone').attr('disabled', 'disabled');
if ($('#dpd_standard_cod').is(':checked'))
$('.domestic_cod_zone').removeAttr('disabled');
else
$('.domestic_cod_zone').attr('disabled', 'disabled');
if ($('#dpd_classic').is(':checked'))
$('.classic_zone').removeAttr('disabled');
else
$('.classic_zone').attr('disabled', 'disabled');
if ($('#dpd_pudo').is(':checked'))
$('.pudo_zone').removeAttr('disabled');
else
$('.pudo_zone').attr('disabled', 'disabled');
if ($('#dpd_pudo_cod').is(':checked'))
$('.pudo_cod_zone').removeAttr('disabled');
else
$('.pudo_cod_zone').attr('disabled', 'disabled');
}
function toggleEnvelope() {
if ($('#toggleEnvelope').is(':checked'))
$('#envelopes_container').slideDown();
else
$('#envelopes_container').slideUp();
}
function toggleParcel() {
if ($('#toggleParcel').is(':checked'))
$('#parcels_container').slideDown();
else
$('#parcels_container').slideUp();
}
function togglePallet() {
if ($('#togglePallet').is(':checked'))
$('#pallets_container').slideDown();
else
$('#pallets_container').slideUp();
}
function getTimeFramesByDate() {
$('#ajax_running').slideDown();
var current_date = $('#pickupDate').val();
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: "getTimeFrames=true&date=" + encodeURIComponent(current_date) +
"&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&sender_address_selection=" + $('#sender_address_selection').val() +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
success: function (resp) {
$('#timeframe_container').html(resp);
calculateTimeLeftForArrangePickup();
},
error: function () {
$('#ajax_running').slideUp();
}
});
}
function calculateTimeLeftForArrangePickup() {
if (!$('#ajax_running').is(':visible'))
$('#ajax_running').slideDown();
var current_timeframe = $('select[name="pickupTime"]').val();
var current_date = $('#pickupDate').val();
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: "calculateTimeLeft=true&timeframe=" + encodeURIComponent(current_timeframe) +
"&date=" + encodeURIComponent(current_date) +
"&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
success: function (resp) {
$('#timeframe_container span.time_left').text(resp);
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
}
function addClientNumber() {
if (typeof (dpdpoland_16) == 'undefined') {
$('#ajax_running').slideDown();
}
$('#error_message').slideUp();
$('#success_message').slideUp();
var ajax_request_params = 'ajax=true&addDPDClientNumber=true';
var client_number = $('#client_number').val();
var client_name = $('#client_name').val();
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: ajax_request_params +
"&client_number=" + encodeURIComponent(client_number) +
"&name=" + encodeURIComponent(client_name) +
"&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
success: function (resp) {
if (resp.error) {
$('#error_message').html(resp.error).slideDown('fast');
} else
$('#success_message').html(resp.message).slideDown('fast');
displayPayerNumbersTable();
if (typeof (dpdpoland_16) == 'undefined') {
$('#ajax_running').slideUp();
}
},
error: function () {
if (typeof (dpdpoland_16) == 'undefined') {
$('#ajax_running').slideUp();
}
}
});
}
function deleteClientNumber(id_client_number) {
$('#ajax_running').slideDown();
$('#error_message').slideUp();
$('#success_message').slideUp();
var ajax_request_params = 'ajax=true&deleteDPDClientNumber=true';
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: ajax_request_params +
"&client_number=" + encodeURIComponent(id_client_number) +
"&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
success: function (resp) {
if (resp.error) {
$('#error_message').html(resp.error).slideDown('fast');
} else
$('#success_message').html(resp.message).slideDown('fast');
displayPayerNumbersTable();
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
}
function displayPayerNumbersTable() {
$('#ajax_running').slideDown();
var ajax_request_params = 'ajax=true&getPayerNumbersTableHTML=true';
$.ajax({
type: "POST",
async: true,
url: dpdpoland_ajax_uri,
dataType: "json",
global: false,
data: ajax_request_params +
"&token=" + encodeURIComponent(dpdpoland_token) +
"&id_shop=" + encodeURIComponent(dpdpoland_id_shop) +
"&id_lang=" + encodeURIComponent(dpdpoland_id_lang),
success: function (resp) {
$('#client_numbers_table_container').html(resp);
$('#ajax_running').slideUp();
},
error: function () {
$('#ajax_running').slideUp();
}
});
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2024 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* Licensed under the EUPL-1.2 or later.
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* It is also bundled with this package in the file LICENSE.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an AS IS basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions
* and limitations under the Licence.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2024 DPD Polska Sp. z o.o.
* @license https://joinup.ec.europa.eu/software/page/eupl
*/
// noinspection JSUnresolvedReference
if (typeof dpdPolandCodEventCreated == 'undefined') {
var dpdPolandCodEventCreated = false;
}
var dpdPolandCod_iframe = document.createElement("iframe");
dpdPolandCod_iframe.setAttribute("id", "dpdpoland-widget-pudo-cod-iframe");
dpdPolandCod_iframe.setAttribute("allow", "geolocation");
dpdPolandCod_iframe.src = dpdpoland_iframe_cod_url;
dpdPolandCod_iframe.style.width = "100%";
dpdPolandCod_iframe.style.border = "none";
dpdPolandCod_iframe.style.minHeight = "400px";
dpdPolandCod_iframe.style.height = "768px";
var dpdPolandCod_script = document.getElementById("dpdpoland-widget-pudo-cod");
if (dpdPolandCod_script)
dpdPolandCod_script.parentNode.insertBefore(dpdPolandCod_iframe, dpdPolandCod_script);
if (!dpdPolandCodEventCreated) {
var dpdPolandCod_eventListener = window[window.addEventListener ? "addEventListener" : "attachEvent"];
var dpdPolandCod_messageEvent = ("attachEvent" === dpdPolandCod_eventListener) ? "onmessage" : "message";
dpdPolandCod_eventListener(dpdPolandCod_messageEvent, function (a) {
if (getDpdPolandIdPudoCodCarrier() === getDpdPolandSelectedCarrier()) {
if (a.data.height && !isNaN(a.data.height)) {
dpdPolandCod_iframe.style.height = a.data.height + "px"
} else if (a.data.point_id)
dpdPolandCodPointSelected(a.data.point_id);
}
}, !1);
dpdPolandCodEventCreated = true
}
function dpdPolandCodPointSelected(pudoCode) {
$('.container_dpdpoland_pudo_cod_error').css("display", "none");
$('.dpdpoland-pudo-cod-new-point').css("display", "none");
$('.dpdpoland-pudo-cod-selected-point').css("display", "block");
dpdPolandSavePudoCode(pudoCode, $('#dpdpolandPudoCodModal'));
dpdPolandGetPudoAddress(pudoCode, $('.dpdpoland-cod-selected-point'))
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2024 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* Licensed under the EUPL-1.2 or later.
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* It is also bundled with this package in the file LICENSE.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an AS IS basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions
* and limitations under the Licence.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2024 DPD Polska Sp. z o.o.
* @license https://joinup.ec.europa.eu/software/page/eupl
*/
// noinspection JSUnresolvedReference
if (typeof dpdpolandEventCreated == 'undefined') {
var dpdpolandEventCreated = false;
}
var dpdpoland_iframe = document.createElement("iframe");
dpdpoland_iframe.setAttribute("id", "dpdpoland-widget-pudo-iframe");
dpdpoland_iframe.setAttribute("allow", "geolocation");
dpdpoland_iframe.src = dpdpoland_iframe_url;
dpdpoland_iframe.style.width = "100%";
dpdpoland_iframe.style.border = "none";
dpdpoland_iframe.style.minHeight = "400px";
dpdpoland_iframe.style.height = "768px";
var dpdpoland_script = document.getElementById("dpdpoland-widget-pudo");
if (dpdpoland_script)
dpdpoland_script.parentNode.insertBefore(dpdpoland_iframe, dpdpoland_script);
if (!dpdpolandEventCreated) {
var dpdpoland_eventListener = window[window.addEventListener ? "addEventListener" : "attachEvent"];
var dpdpoland_messageEvent = ("attachEvent" === dpdpoland_eventListener) ? "onmessage" : "message";
dpdpoland_eventListener(dpdpoland_messageEvent, function (a) {
if (getDpdPolandIdPudoCarrier() === getDpdPolandSelectedCarrier()) {
if (a.data.height && !isNaN(a.data.height)) {
dpdpoland_iframe.style.height = a.data.height + "px"
} else if (a.data.point_id)
dpdPolandPointSelected(a.data.point_id);
}
}, !1);
dpdpolandEventCreated = true
}
function dpdPolandPointSelected(pudoCode) {
$('.container_dpdpoland_pudo_error').css("display", "none");
$('.dpdpoland-pudo-new-point').css("display", "none");
$('.dpdpoland-pudo-selected-point').css("display", "block");
dpdPolandSavePudoCode(pudoCode, $('#dpdpolandPudoModal'));
dpdPolandGetPudoAddress(pudoCode, $('.dpdpoland-selected-point'))
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright 2025 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* Licensed under the EUPL-1.2 or later.
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* It is also bundled with this package in the file LICENSE.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an AS IS basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions
* and limitations under the Licence.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2025 DPD Polska Sp. z o.o.
* @license https://joinup.ec.europa.eu/software/page/eupl
*/
// noinspection JSUnresolvedReference
if (typeof dpdpolandSwipBoxEventCreated == 'undefined') {
var dpdpolandSwipBoxEventCreated = false;
}
var dpdpoland_swipbox_iframe = document.createElement("iframe");
dpdpoland_swipbox_iframe.setAttribute("id", "dpdpoland-widget-swipbox-iframe");
dpdpoland_swipbox_iframe.setAttribute("allow", "geolocation");
dpdpoland_swipbox_iframe.src = dpdpoland_iframe_swipbox_url;
dpdpoland_swipbox_iframe.style.width = "100%";
dpdpoland_swipbox_iframe.style.border = "none";
dpdpoland_swipbox_iframe.style.minHeight = "400px";
dpdpoland_swipbox_iframe.style.height = "768px";
var dpdpoland_swipbox_script = document.getElementById("dpdpoland-widget-swipbox");
if (dpdpoland_swipbox_script)
dpdpoland_swipbox_script.parentNode.insertBefore(dpdpoland_swipbox_iframe, dpdpoland_swipbox_script);
if (!dpdpolandSwipBoxEventCreated) {
var dpdpoland_swipbox_eventListener = window[window.addEventListener ? "addEventListener" : "attachEvent"];
var dpdpoland_swipbox_messageEvent = ("attachEvent" === dpdpoland_swipbox_eventListener) ? "onmessage" : "message";
dpdpoland_swipbox_eventListener(dpdpoland_swipbox_messageEvent, function (a) {
console.log('hit' + getDpdPolandIdSwipBoxCarrier() +' ' + getDpdPolandSelectedCarrier())
if (getDpdPolandIdSwipBoxCarrier() === getDpdPolandSelectedCarrier()) {
if (a.data.height && !isNaN(a.data.height)) {
dpdpoland_swipbox_iframe.style.height = a.data.height + "px"
} else if (a.data.point_id)
dpdPolandPointSelected(a.data.point_id);
}
}, !1);
dpdpolandSwipBoxEventCreated = true
}
function dpdPolandPointSelected(pudoCode) {
$('.container_dpdpoland_swipbox_error').css("display", "none");
$('.dpdpoland-swipbox-new-point').css("display", "none");
$('.dpdpoland-swipbox-selected-point').css("display", "block");
dpdPolandSavePudoCode(pudoCode, $('#dpdpolandSwipboxModal'));
dpdPolandGetPudoAddress(pudoCode, $('.dpdpoland-selected-point'))
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
/*================================================================================
* @name: bPopup - if you can't get it up, use bPopup
* @author: (c)Bjoern Klinggaard (twitter@bklinggaard)
* @demo: http://dinbror.dk/bpopup
* @version: 0.9.4.min
================================================================================*/
(function(b){b.fn.bPopup=function(z,F){function K(){a.contentContainer=b(a.contentContainer||c);switch(a.content){case "iframe":var h=b('<iframe class="b-iframe" '+a.iframeAttr+"></iframe>");h.appendTo(a.contentContainer);r=c.outerHeight(!0);s=c.outerWidth(!0);A();h.attr("src",a.loadUrl);k(a.loadCallback);break;case "image":A();b("<img />").load(function(){k(a.loadCallback);G(b(this))}).attr("src",a.loadUrl).hide().appendTo(a.contentContainer);break;default:A(),b('<div class="b-ajax-wrapper"></div>').load(a.loadUrl,a.loadData,function(){k(a.loadCallback);G(b(this))}).hide().appendTo(a.contentContainer)}}function A(){a.modal&&b('<div class="b-modal '+e+'"></div>').css({backgroundColor:a.modalColor,position:"fixed",top:0,right:0,bottom:0,left:0,opacity:0,zIndex:a.zIndex+t}).appendTo(a.appendTo).fadeTo(a.speed,a.opacity);D();c.data("bPopup",a).data("id",e).css({left:"slideIn"==a.transition||"slideBack"==a.transition?"slideBack"==a.transition?g.scrollLeft()+u:-1*(v+s):l(!(!a.follow[0]&&m||f)),position:a.positionStyle||"absolute",top:"slideDown"==a.transition||"slideUp"==a.transition?"slideUp"==a.transition?g.scrollTop()+w:x+-1*r:n(!(!a.follow[1]&&p||f)),"z-index":a.zIndex+t+1}).each(function(){a.appending&&b(this).appendTo(a.appendTo)});H(!0)}function q(){a.modal&&b(".b-modal."+c.data("id")).fadeTo(a.speed,0,function(){b(this).remove()});a.scrollBar||b("html").css("overflow","auto");b(".b-modal."+e).unbind("click");g.unbind("keydown."+e);d.unbind("."+e).data("bPopup",0<d.data("bPopup")-1?d.data("bPopup")-1:null);c.undelegate(".bClose, ."+a.closeClass,"click."+e,q).data("bPopup",null);H();return!1}function G(h){var b=h.width(),e=h.height(),d={};a.contentContainer.css({height:e,width:b});e>=c.height()&&(d.height=c.height());b>=c.width()&&(d.width=c.width());r=c.outerHeight(!0);s=c.outerWidth(!0);D();a.contentContainer.css({height:"auto",width:"auto"});d.left=l(!(!a.follow[0]&&m||f));d.top=n(!(!a.follow[1]&&p||f));c.animate(d,250,function(){h.show();B=E()})}function L(){d.data("bPopup",t);c.delegate(".bClose, ."+a.closeClass,"click."+e,q);a.modalClose&&b(".b-modal."+e).css("cursor","pointer").bind("click",q);M||!a.follow[0]&&!a.follow[1]||d.bind("scroll."+e,function(){B&&c.dequeue().animate({left:a.follow[0]?l(!f):"auto",top:a.follow[1]?n(!f):"auto"},a.followSpeed,a.followEasing)}).bind("resize."+e,function(){w=y.innerHeight||d.height();u=y.innerWidth||d.width();if(B=E())clearTimeout(I),I=setTimeout(function(){D();c.dequeue().each(function(){f?b(this).css({left:v,top:x}):b(this).animate({left:a.follow[0]?l(!0):"auto",top:a.follow[1]?n(!0):"auto"},a.followSpeed,a.followEasing)})},50)});a.escClose&&g.bind("keydown."+e,function(a){27==a.which&&q()})}function H(b){function d(e){c.css({display:"block",opacity:1}).animate(e,a.speed,a.easing,function(){J(b)})}switch(b?a.transition:a.transitionClose||a.transition){case "slideIn":d({left:b?l(!(!a.follow[0]&&m||f)):g.scrollLeft()-(s||c.outerWidth(!0))-C});break;case "slideBack":d({left:b?l(!(!a.follow[0]&&m||f)):g.scrollLeft()+u+C});break;case "slideDown":d({top:b?n(!(!a.follow[1]&&p||f)):g.scrollTop()-(r||c.outerHeight(!0))-C});break;case "slideUp":d({top:b?n(!(!a.follow[1]&&p||f)):g.scrollTop()+w+C});break;default:c.stop().fadeTo(a.speed,b?1:0,function(){J(b)})}}function J(b){b?(L(),k(F),a.autoClose&&setTimeout(q,a.autoClose)):(c.hide(),k(a.onClose),a.loadUrl&&(a.contentContainer.empty(),c.css({height:"auto",width:"auto"})))}function l(a){return a?v+g.scrollLeft():v}function n(a){return a?x+g.scrollTop():x}function k(a){b.isFunction(a)&&a.call(c)}function D(){x=p?a.position[1]:Math.max(0,(w-c.outerHeight(!0))/2-a.amsl);v=m?a.position[0]:(u-c.outerWidth(!0))/2;B=E()}function E(){return w>c.outerHeight(!0)&&u>c.outerWidth(!0)}b.isFunction(z)&&(F=z,z=null);var a=b.extend({},b.fn.bPopup.defaults,z);a.scrollBar||b("html").css("overflow","hidden");var c=this,g=b(document),y=window,d=b(y),w=y.innerHeight||d.height(),u=y.innerWidth||d.width(),M=/OS 6(_\d)+/i.test(navigator.userAgent),C=200,t=0,e,B,p,m,f,x,v,r,s,I;c.close=function(){a=this.data("bPopup");e="__b-popup"+d.data("bPopup")+"__";q()};return c.each(function(){b(this).data("bPopup")||(k(a.onOpen),t=(d.data("bPopup")||0)+1,e="__b-popup"+t+"__",p="auto"!==a.position[1],m="auto"!==a.position[0],f="fixed"===a.positionStyle,r=c.outerHeight(!0),s=c.outerWidth(!0),a.loadUrl?K():A())})};b.fn.bPopup.defaults={amsl:50,appending:!0,appendTo:"body",autoClose:!1,closeClass:"b-close",content:"ajax",contentContainer:!1,easing:"swing",escClose:!0,follow:[!0,!0],followEasing:"swing",followSpeed:500,iframeAttr:'scrolling="no" frameborder="0"',loadCallback:!1,loadData:!1,loadUrl:!1,modal:!0,modalClose:!0,modalColor:"#000",onClose:!1,onOpen:!1,opacity:0.7,position:["auto","auto"],positionStyle:"absolute",scrollBar:!0,speed:250,transition:"fadeIn",transitionClose:!1,zIndex:9997}})(jQuery);

View File

@@ -0,0 +1,167 @@
/**
* 2024 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2024 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
handleDpdPudo();
$(document).on('click', '.delivery_option_radio', handleDpdPudo);
$(document).on('click', 'input[name^="delivery_option"]', handleDpdPudo);
$('.dpdpoland-pudo-container').parent().css('border-right', '0');
$('.dpdpoland-pudo-cod-container').parent().css('border-right', '0');
$('.dpdpoland-swipbox-container').parent().css('border-right', '0');
$(document).on('click', '.dpdpoland-swipbox-open-map-btn', (e) => showModal(e, '#dpdpolandSwipboxModal'));
$(document).on('click', '.dpdpoland-swipbox-change-map-btn', (e) => showModal(e, '#dpdpolandSwipboxModal'));
$(document).on('click', '.dpdpoland-pudo-open-map-btn', (e) => showModal(e, '#dpdpolandPudoModal'));
$(document).on('click', '.dpdpoland-pudo-change-map-btn', (e) => showModal(e, '#dpdpolandPudoModal'));
$(document).on('click', '.dpdpoland-pudo-cod-open-map-btn', (e) => showModal(e, '#dpdpolandPudoCodModal'));
$(document).on('click', '.dpdpoland-pudo-cod-change-map-btn', (e) => showModal(e, '#dpdpolandPudoCodModal'));
});
function dpdPolandSavePudoCode(pudoCode, modal) {
$.ajax({
url: dpdpoland_ajax_uri,
type: 'POST',
data: {
'pudo_code': pudoCode,
'save_pudo_id': 1,
'token': dpdpoland_token,
'id_cart': dpdpoland_cart,
'session': dpdpoland_session
},
success: function (response) {
if (Number(response) === 1) {
$('.dpdpoland-pudo-new-point').css("display", "none");
$('.dpdpoland-pudo-selected-point').css("display", "block");
enableDpdPolandOrderProcessBtn();
} else {
$('.container_dpdpoland_pudo_error').css("display", "block");
disableDpdPolandOrderProcessBtn();
console.error('Error:', response);
}
hideModal(modal);
},
error: function (error) {
console.error('Error:', error);
hideModal(modal);
}
});
function hideModal(modal) {
setTimeout(() => {
modal.modal('toggle');
$(".modal-backdrop").hide();
}, 500);
}
}
function dpdPolandGetPudoAddress(pudoCode, input) {
$.ajax({
url: dpdpoland_ajax_uri,
type: 'GET',
data: {
'pudo_code': pudoCode,
'call_pudo_address': 1,
'token': dpdpoland_token,
'id_cart': dpdpoland_cart
},
success: function (response) {
input.text(response);
},
error: function (error) {
console.error('Error:', error);
}
});
}
function showModal(event, modalDiv) {
event.preventDefault();
event.stopPropagation();
$(modalDiv).modal({
backdrop: 'static',
keyboard: false
})
handleDpdPudo();
}
function handleDpdPudo() {
$('.container_dpdpoland_pudo_cod_error').css("display", "none");
$('.container_dpdpoland_pudo_cod_warning').css("display", "none");
if (getDpdPolandSelectedCarrier() === getDpdPolandIdPudoCarrier()) {
$('.dpdpoland-pudo-new-point').css("display", "block");
$('.dpdpoland-pudo-selected-point').css("display", "none");
$('.dpdpoland-selected-point').text("");
const dpdPolandWidgetPudoIframe = $("#dpd-widget-pudo-iframe")
dpdPolandWidgetPudoIframe.attr("src", dpdPolandWidgetPudoIframe.attr("src"));
disableDpdPolandOrderProcessBtn();
} else if (getDpdPolandSelectedCarrier() === getDpdPolandIdPudoCodCarrier()) {
$('.dpdpoland-pudo-cod-selected-point').css("display", "none");
$('.dpdpoland-pudo-cod-new-point').css("display", "block");
$('.dpdpoland-selected-point-cod').text("");
const dpdPolandWidgetPudoCodIframe = $("#dpd-widget-pudo-cod-iframe")
dpdPolandWidgetPudoCodIframe.attr("src", dpdPolandWidgetPudoCodIframe.attr("src"));
disableDpdPolandOrderProcessBtn();
} else if (getDpdPolandSelectedCarrier() === getDpdPolandIdSwipBoxCarrier()) {
$('.dpdpoland-swipbox-selected-point').css("display", "none");
$('.dpdpoland-swipbox-new-point').css("display", "block");
$('.dpdpoland-selected-point-swipbox').text("");
const dpdPolandWidgetSwipBoxIframe = $("#dpd-widget-swipbox-iframe")
dpdPolandWidgetSwipBoxIframe.attr("src", dpdPolandWidgetSwipBoxIframe.attr("src"));
disableDpdPolandOrderProcessBtn();
} else {
enableDpdPolandOrderProcessBtn();
}
}
function getDpdPolandIdPudoCarrier() {
return Number(dpdpoland_id_pudo_carrier);
}
function getDpdPolandIdPudoCodCarrier() {
return Number(dpdpoland_id_pudo_cod_carrier);
}
function getDpdPolandIdSwipBoxCarrier() {
return Number(dpdpoland_id_swipbox_carrier);
}
function getDpdPolandSelectedCarrier() {
let idDpdPolandSelectedCarrier = $('input[name^="delivery_option"]:checked').val();
if (typeof idDpdPolandSelectedCarrier == 'undefined')
return null;
idDpdPolandSelectedCarrier = idDpdPolandSelectedCarrier.replace(',', '');
if (typeof idDpdPolandSelectedCarrier == 'undefined' || idDpdPolandSelectedCarrier === 0)
return null;
return Number(idDpdPolandSelectedCarrier);
}

View File

@@ -0,0 +1,26 @@
/**
* 2024 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2024 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
function disableDpdPolandOrderProcessBtn() {
$('button[name="confirmDeliveryOption"]').attr('disabled', 'disabled');
}
function enableDpdPolandOrderProcessBtn() {
$('button[name="confirmDeliveryOption"]').removeAttr('disabled');
}

View File

@@ -0,0 +1,34 @@
/**
* 2025 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2025 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
setTimeout(() => {
handleDpdShippingPudo()
}, 2000);
})
function disableDpdPolandOrderProcessBtn() {
$("#payment-confirmation button").prop("disabled", true);
$("#payment-confirmation a").addClass("disabled").attr("aria-disabled", "true");
}
function enableDpdPolandOrderProcessBtn() {
$("#payment-confirmation button").prop("disabled", false);
$("#payment-confirmation a").removeClass("disabled").removeAttr("aria-disabled");
}

View File

@@ -0,0 +1,33 @@
/**
* 2025 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2025 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
setTimeout(() => {
handleDpdShippingPudo()
}, 2000);
})
function disableDpdPolandOrderProcessBtn() {
$("#confirm_order").css("pointer-events", "none");
}
function enableDpdPolandOrderProcessBtn() {
$("#confirm_order").css("pointer-events", "auto");
}

View File

@@ -0,0 +1,42 @@
/**
* 2025 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2025 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
const refreshDpdPudoState = () => {
if (typeof handleDpdPudo === 'function') {
handleDpdPudo();
}
};
setTimeout(() => {
refreshDpdPudoState();
}, 2000);
$(document).on('opc-load-carrier:completed opc-update-carrier:completed', () => {
setTimeout(refreshDpdPudoState, 100);
});
})
function disableDpdPolandOrderProcessBtn() {
$("#btn_place_order").css("pointer-events", "none");
}
function enableDpdPolandOrderProcessBtn() {
$("#btn_place_order").css("pointer-events", "auto");
}

View File

@@ -0,0 +1,42 @@
/**
* 2025 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2025 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
const refreshDpdPudoState = () => {
if (typeof handleDpdPudo === 'function') {
handleDpdPudo();
}
};
setTimeout(() => {
refreshDpdPudoState();
}, 2000);
$(document).on('opc-load-carrier:completed opc-update-carrier:completed', () => {
setTimeout(refreshDpdPudoState, 100);
});
})
function disableDpdPolandOrderProcessBtn() {
$("#opc_step_shipping_footer, #opc_step_payment_header").css("pointer-events", "none");
}
function enableDpdPolandOrderProcessBtn() {
$("#opc_step_shipping_footer, #opc_step_payment_header").css("pointer-events", "auto");
}

View File

@@ -0,0 +1,34 @@
/**
* 2025 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2025 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
setTimeout(() => {
handleDpdPudo()
}, 2000);
})
function disableDpdPolandOrderProcessBtn() {
$('#supercheckout_confirm_order').attr('disabled', 'disabled');
$('#supercheckout_confirm_order').css('pointer-events', 'none');
}
function enableDpdPolandOrderProcessBtn() {
$('#supercheckout_confirm_order').removeAttr('disabled');
$('#supercheckout_confirm_order').css('pointer-events', '');
}

View File

@@ -0,0 +1,33 @@
/**
* 2025 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2025 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
$(document).ready(function () {
setTimeout(() => {
handleDpdShippingPudo()
}, 2000);
})
function disableDpdPolandOrderProcessBtn() {
$("#confirm_order").css("pointer-events", "none");
}
function enableDpdPolandOrderProcessBtn() {
$("#confirm_order").css("pointer-events", "auto");
}

View File

@@ -0,0 +1,193 @@
<?php
/**
* PDFMerger created by Jarrod Nettles December 2009
* jarrod@squarecrow.com
*
* v1.0
*
* Class for easily merging PDFs (or specific pages of PDFs) together into one. Output to a file, browser, download, or return as a string.
* Unfortunately, this class does not preserve many of the enhancements your original PDF might contain. It treats
* your PDF page as an image and then concatenates them all together.
*
* Note that your PDFs are merged in the order that you provide them using the addPDF function, same as the pages.
* If you put pages 12-14 before 1-5 then 12-15 will be placed first in the output.
*
*
* Uses FPDI 1.3.1 from Setasign
* Uses FPDF 1.6 by Olivier Plathey with FPDF_TPL extension 1.1.3 by Setasign
*
* Both of these packages are free and open source software, bundled with this class for ease of use.
* They are not modified in any way. PDFMerger has all the limitations of the FPDI package - essentially, it cannot import dynamic content
* such as form fields, links or page annotations (anything not a part of the page content stream).
*
*/
class PDFMerger
{
private $_files; //['form.pdf'] ["1,2,4, 5-19"]
private $_fpdi;
/**
* Merge PDFs.
* @return void
*/
public function __construct()
{
require_once(_PS_MODULE_DIR_.'dpdpoland/libraries/PDFMerger/fpdf/fpdf.php');
require_once(_PS_MODULE_DIR_.'dpdpoland/libraries/PDFMerger/fpdi/fpdi.php');
}
/**
* Add a PDF for inclusion in the merge with a valid file path. Pages should be formatted: 1,3,6, 12-16.
* @param $filepath
* @param $pages
* @return void
*/
public function addPDF($filepath, $pages = 'all')
{
if(file_exists($filepath))
{
if(strtolower($pages) != 'all')
{
$pages = $this->_rewritepages($pages);
}
$this->_files[] = array($filepath, $pages);
}
else
{
throw new exception("Could not locate PDF on '$filepath'");
}
return $this;
}
/**
* Merges your provided PDFs and outputs to specified location.
* @param $outputmode
* @param $outputname
* @return PDF
*/
public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf')
{
if(!isset($this->_files) || !is_array($this->_files)): throw new exception("No PDFs to merge."); endif;
$fpdi = new FPDI;
//merger operations
foreach($this->_files as $file)
{
$filename = $file[0];
$filepages = $file[1];
$count = $fpdi->setSourceFile($filename);
//add the pages
if($filepages == 'all')
{
for($i=1; $i<=$count; $i++)
{
$template = $fpdi->importPage($i);
$size = $fpdi->getTemplateSize($template);
$fpdi->AddPage('P', array($size['w'], $size['h']));
$fpdi->useTemplate($template);
}
}
else
{
foreach($filepages as $page)
{
if(!$template = $fpdi->importPage($page)): throw new exception("Could not load page '$page' in PDF '$filename'. Check that the page exists."); endif;
$size = $fpdi->getTemplateSize($template);
$fpdi->AddPage('P', array($size['w'], $size['h']));
$fpdi->useTemplate($template);
}
}
}
//output operations
$mode = $this->_switchmode($outputmode);
if($mode == 'S')
{
return $fpdi->Output($outputpath, 'S');
}
else
{
if($fpdi->Output($outputpath, $mode))
{
return true;
}
else
{
throw new exception("Error outputting PDF to '$outputmode'.");
return false;
}
}
}
/**
* FPDI uses single characters for specifying the output location. Change our more descriptive string into proper format.
* @param $mode
* @return Character
*/
private function _switchmode($mode)
{
switch(strtolower($mode))
{
case 'download':
return 'D';
break;
case 'browser':
return 'I';
break;
case 'file':
return 'F';
break;
case 'string':
return 'S';
break;
default:
return 'I';
break;
}
}
/**
* Takes our provided pages in the form of 1,3,4,16-50 and creates an array of all pages
* @param $pages
* @return unknown_type
*/
private function _rewritepages($pages)
{
$pages = str_replace(' ', '', $pages);
$part = explode(',', $pages);
//parse hyphens
foreach($part as $i)
{
$ind = explode('-', $i);
if(count($ind) == 2)
{
$x = $ind[0]; //start page
$y = $ind[1]; //end page
if($x > $y): throw new exception("Starting page, '$x' is greater than ending page '$y'."); return false; endif;
//add middle pages
while($x <= $y): $newpages[] = (int) $x; $x++; endwhile;
}
else
{
$newpages[] = (int) $ind[0];
}
}
return $newpages;
}
}

View File

@@ -0,0 +1,341 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>FAQ</title>
<link type="text/css" rel="stylesheet" href="fpdf.css">
<style type="text/css">
ul {list-style-type:none; margin:0; padding:0}
ul#answers li {margin-top:1.8em}
.question {font-weight:bold; color:#900000}
</style>
</head>
<body>
<h1>FAQ</h1>
<ul>
<li><b>1.</b> <a href='#q1'>What's exactly the license of FPDF? Are there any usage restrictions?</a></li>
<li><b>2.</b> <a href='#q2'>When I try to create a PDF, a lot of weird characters show on the screen. Why?</a></li>
<li><b>3.</b> <a href='#q3'>I try to generate a PDF and IE displays a blank page. What happens?</a></li>
<li><b>4.</b> <a href='#q4'>I can't make line breaks work. I put \n in the string printed by MultiCell but it doesn't work.</a></li>
<li><b>5.</b> <a href='#q5'>I try to display a variable in the Header method but nothing prints.</a></li>
<li><b>6.</b> <a href='#q6'>I defined the Header and Footer methods in my PDF class but nothing appears.</a></li>
<li><b>7.</b> <a href='#q7'>Accented characters are replaced by some strange characters like é.</a></li>
<li><b>8.</b> <a href='#q8'>I try to display the Euro symbol but it doesn't work.</a></li>
<li><b>9.</b> <a href='#q9'>I get the following error when I try to generate a PDF: Some data has already been output, can't send PDF file</a></li>
<li><b>10.</b> <a href='#q10'>I draw a frame with very precise dimensions, but when printed I notice some differences.</a></li>
<li><b>11.</b> <a href='#q11'>I'd like to use the whole surface of the page, but when printed I always have some margins. How can I get rid of them?</a></li>
<li><b>12.</b> <a href='#q12'>How can I put a background in my PDF?</a></li>
<li><b>13.</b> <a href='#q13'>How can I set a specific header or footer on the first page?</a></li>
<li><b>14.</b> <a href='#q14'>I'd like to use extensions provided by different scripts. How can I combine them?</a></li>
<li><b>15.</b> <a href='#q15'>How can I send the PDF by email?</a></li>
<li><b>16.</b> <a href='#q16'>What's the limit of the file sizes I can generate with FPDF?</a></li>
<li><b>17.</b> <a href='#q17'>Can I modify a PDF with FPDF?</a></li>
<li><b>18.</b> <a href='#q18'>I'd like to make a search engine in PHP and index PDF files. Can I do it with FPDF?</a></li>
<li><b>19.</b> <a href='#q19'>Can I convert an HTML page to PDF with FPDF?</a></li>
<li><b>20.</b> <a href='#q20'>Can I concatenate PDF files with FPDF?</a></li>
</ul>
<ul id='answers'>
<li id='q1'>
<p><b>1.</b> <span class='question'>What's exactly the license of FPDF? Are there any usage restrictions?</span></p>
FPDF is released under a permissive license: there is no usage restriction. You may embed it
freely in your application (commercial or not), with or without modifications.
</li>
<li id='q2'>
<p><b>2.</b> <span class='question'>When I try to create a PDF, a lot of weird characters show on the screen. Why?</span></p>
These "weird" characters are in fact the actual content of your PDF. This behavior is a bug of
IE6. When it first receives an HTML page, then a PDF from the same URL, it displays it directly
without launching Acrobat. This happens frequently during the development stage: on the least
script error, an HTML page is sent, and after correction, the PDF arrives.
<br>
To solve the problem, simply quit and restart IE. You can also go to another URL and come
back.
<br>
To avoid this kind of inconvenience during the development, you can generate the PDF directly
to a file and open it through the explorer.
</li>
<li id='q3'>
<p><b>3.</b> <span class='question'>I try to generate a PDF and IE displays a blank page. What happens?</span></p>
First of all, check that you send nothing to the browser after the PDF (not even a space or a
carriage return). You can put an exit statement just after the call to the Output() method to
be sure. If it still doesn't work, it means you're a victim of the "blank page syndrome". IE
used in conjunction with the Acrobat plug-in suffers from many bugs. To avoid these problems
in a reliable manner, two main techniques exist:
<br>
<br>
- Disable the plug-in and use Acrobat as a helper application. To do this, launch Acrobat, go
to the Edit menu, Preferences, Internet, and uncheck "Display PDF in browser". Then, the next
time you load a PDF in IE, it displays the dialog box "Open it" or "Save it to disk". Uncheck
the option "Always ask before opening this type of file" and choose Open. From now on, PDF files
will open automatically in an external Acrobat window.
<br>
The drawback of the method is that you need to alter the client configuration, which you can do
in an intranet environment but not for the Internet.
<br>
<br>
- Use a redirection technique. It consists in generating the PDF in a temporary file on the server
and redirect the client to it. For example, at the end of the script, you can put the following:
<div class="doc-source">
<pre><code>//Determine a temporary file name in the current directory
$file = basename(tempnam('.', 'tmp'));
rename($file, $file.'.pdf');
$file .= '.pdf';
//Save PDF to file
$pdf-&gt;Output($file, 'F');
//Redirect
header('Location: '.$file);</code></pre>
</div>
This method turns the dynamic PDF into a static one and avoids all troubles. But you have to do
some cleaning in order to delete the temporary files. For example:
<div class="doc-source">
<pre><code>function CleanFiles($dir)
{
//Delete temporary files
$t = time();
$h = opendir($dir);
while($file=readdir($h))
{
if(substr($file,0,3)=='tmp' &amp;&amp; substr($file,-4)=='.pdf')
{
$path = $dir.'/'.$file;
if($t-filemtime($path)&gt;3600)
@unlink($path);
}
}
closedir($h);
}</code></pre>
</div>
This function deletes all files of the form tmp*.pdf older than an hour in the specified
directory. You may call it where you want, for example in the script which generates the PDF.
</li>
<li id='q4'>
<p><b>4.</b> <span class='question'>I can't make line breaks work. I put \n in the string printed by MultiCell but it doesn't work.</span></p>
You have to enclose your string with double quotes, not single ones.
</li>
<li id='q5'>
<p><b>5.</b> <span class='question'>I try to display a variable in the Header method but nothing prints.</span></p>
You have to use the <code>global</code> keyword to access global variables, for example:
<div class="doc-source">
<pre><code>function Header()
{
global $title;
$this-&gt;SetFont('Arial', 'B', 15);
$this-&gt;Cell(0, 10, $title, 1, 1, 'C');
}
$title = 'My title';</code></pre>
</div>
Alternatively, you can use an object property:
<div class="doc-source">
<pre><code>function Header()
{
$this-&gt;SetFont('Arial', 'B', 15);
$this-&gt;Cell(0, 10, $this-&gt;title, 1, 1, 'C');
}
$pdf-&gt;title = 'My title';</code></pre>
</div>
</li>
<li id='q6'>
<p><b>6.</b> <span class='question'>I defined the Header and Footer methods in my PDF class but nothing appears.</span></p>
You have to create an object from the PDF class, not FPDF:
<div class="doc-source">
<pre><code>$pdf = new PDF();</code></pre>
</div>
</li>
<li id='q7'>
<p><b>7.</b> <span class='question'>Accented characters are replaced by some strange characters like é.</span></p>
Don't use UTF-8 encoding. Standard FPDF fonts use ISO-8859-1 or Windows-1252.
It is possible to perform a conversion to ISO-8859-1 with utf8_decode():
<div class="doc-source">
<pre><code>$str = utf8_decode($str);</code></pre>
</div>
But some characters such as Euro won't be translated correctly. If the iconv extension is available, the
right way to do it is the following:
<div class="doc-source">
<pre><code>$str = iconv('UTF-8', 'windows-1252', $str);</code></pre>
</div>
</li>
<li id='q8'>
<p><b>8.</b> <span class='question'>I try to display the Euro symbol but it doesn't work.</span></p>
The standard fonts have the Euro character at position 128. You can define a constant like this
for convenience:
<div class="doc-source">
<pre><code>define('EURO', chr(128));</code></pre>
</div>
</li>
<li id='q9'>
<p><b>9.</b> <span class='question'>I get the following error when I try to generate a PDF: Some data has already been output, can't send PDF file</span></p>
You must send nothing to the browser except the PDF itself: no HTML, no space, no carriage return. A common
case is having extra blank at the end of an included script file.<br>
If you can't figure out where the problem comes from, this other message appearing just before can help you:<br>
<br>
<b>Warning:</b> Cannot modify header information - headers already sent by (output started at script.php:X)<br>
<br>
It means that script.php outputs something at line X. Go to this line and fix it.
In case the message doesn't show, first check that you didn't disable warnings, then add this at the very
beginning of your script:
<div class="doc-source">
<pre><code>ob_end_clean();</code></pre>
</div>
If you still don't see it, disable zlib.output_compression in your php.ini and it should appear.
</li>
<li id='q10'>
<p><b>10.</b> <span class='question'>I draw a frame with very precise dimensions, but when printed I notice some differences.</span></p>
To respect dimensions, select "None" for the Page Scaling setting instead of "Shrink to Printable Area" in the print dialog box.
</li>
<li id='q11'>
<p><b>11.</b> <span class='question'>I'd like to use the whole surface of the page, but when printed I always have some margins. How can I get rid of them?</span></p>
Printers have physical margins (different depending on the models); it is therefore impossible to remove
them and print on the whole surface of the paper.
</li>
<li id='q12'>
<p><b>12.</b> <span class='question'>How can I put a background in my PDF?</span></p>
For a picture, call Image() in the Header() method, before any other output. To set a background color, use Rect().
</li>
<li id='q13'>
<p><b>13.</b> <span class='question'>How can I set a specific header or footer on the first page?</span></p>
Simply test the page number:
<div class="doc-source">
<pre><code>function Header()
{
if($this-&gt;PageNo()==1)
{
//First page
...
}
else
{
//Other pages
...
}
}</code></pre>
</div>
</li>
<li id='q14'>
<p><b>14.</b> <span class='question'>I'd like to use extensions provided by different scripts. How can I combine them?</span></p>
Use an inheritance chain. If you have two classes, say A in a.php:
<div class="doc-source">
<pre><code>require('fpdf.php');
class A extends FPDF
{
...
}</code></pre>
</div>
and B in b.php:
<div class="doc-source">
<pre><code>require('fpdf.php');
class B extends FPDF
{
...
}</code></pre>
</div>
then make B extend A:
<div class="doc-source">
<pre><code>require('a.php');
class B extends A
{
...
}</code></pre>
</div>
and make your own class extend B:
<div class="doc-source">
<pre><code>require('b.php');
class PDF extends B
{
...
}
$pdf = new PDF();</code></pre>
</div>
</li>
<li id='q15'>
<p><b>15.</b> <span class='question'>How can I send the PDF by email?</span></p>
As any other file, but an easy way is to use <a href="http://phpmailer.codeworxtech.com">PHPMailer</a> and
its in-memory attachment:
<div class="doc-source">
<pre><code>$mail = new PHPMailer();
...
$doc = $pdf-&gt;Output('', 'S');
$mail-&gt;AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf');
$mail-&gt;Send();</code></pre>
</div>
</li>
<li id='q16'>
<p><b>16.</b> <span class='question'>What's the limit of the file sizes I can generate with FPDF?</span></p>
There is no particular limit. There are some constraints, however:
<br>
<br>
- The maximum memory size allocated to PHP scripts is usually 8MB. For very big documents,
especially with images, this limit may be reached (the file being built into memory). The
parameter is configured in the php.ini file.
<br>
<br>
- The maximum execution time allocated defaults to 30 seconds. This limit can of course be easily
reached. It is configured in php.ini and may be altered dynamically with set_time_limit().
<br>
<br>
- Browsers generally have a 5 minute time-out. If you send the PDF directly to the browser and
reach the limit, it will be lost. It is therefore advised for very big documents to
generate them in a file, and to send some data to the browser from time to time (with a call
to flush() to force the output). When the document is finished, you can send a redirection to
it or create a link.
<br>
Remark: even if the browser times out, the script may continue to run on the server.
</li>
<li id='q17'>
<p><b>17.</b> <span class='question'>Can I modify a PDF with FPDF?</span></p>
It is possible to import pages from an existing PDF document thanks to the FPDI extension:<br>
<br>
<a href="http://www.setasign.de/products/pdf-php-solutions/fpdi/" target="_blank">http://www.setasign.de/products/pdf-php-solutions/fpdi/</a><br>
<br>
You can then add some content to them.
</li>
<li id='q18'>
<p><b>18.</b> <span class='question'>I'd like to make a search engine in PHP and index PDF files. Can I do it with FPDF?</span></p>
No. But a GPL C utility does exist, pdftotext, which is able to extract the textual content from
a PDF. It is provided with the Xpdf package:<br>
<br>
<a href="http://www.foolabs.com/xpdf/" target="_blank">http://www.foolabs.com/xpdf/</a>
</li>
<li id='q19'>
<p><b>19.</b> <span class='question'>Can I convert an HTML page to PDF with FPDF?</span></p>
Not real-world pages. But a GPL C utility does exist, htmldoc, which allows to do it and gives good results:<br>
<br>
<a href="http://www.htmldoc.org" target="_blank">http://www.htmldoc.org</a>
</li>
<li id='q20'>
<p><b>20.</b> <span class='question'>Can I concatenate PDF files with FPDF?</span></p>
Not directly, but it is possible to use <a href="http://www.setasign.de/products/pdf-php-solutions/fpdi/demos/concatenate-fake/" target="_blank">FPDI</a>
to perform this task. Some free command-line tools also exist:<br>
<br>
<a href="http://thierry.schmit.free.fr/spip/spip.php?article15&amp;lang=en" target="_blank">mbtPdfAsm</a><br>
<a href="http://www.accesspdf.com/pdftk/" target="_blank">pdftk</a>
</li>
</ul>
</body>
</html>

View File

@@ -0,0 +1,63 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>AcceptPageBreak</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>AcceptPageBreak</h1>
<code><b>boolean</b> AcceptPageBreak()</code>
<h2>Description</h2>
Whenever a page break condition is met, the method is called, and the break is issued or not
depending on the returned value. The default implementation returns a value according to the
mode selected by SetAutoPageBreak().
<br>
This method is called automatically and should not be called directly by the application.
<h2>Example</h2>
The method is overriden in an inherited class in order to obtain a 3 column layout:
<div class="doc-source">
<pre><code>class PDF extends FPDF
{
var $col=0;
function SetCol($col)
{
//Move position to a column
$this-&gt;col=$col;
$x=10+$col*65;
$this-&gt;SetLeftMargin($x);
$this-&gt;SetX($x);
}
function AcceptPageBreak()
{
if($this-&gt;col&lt;2)
{
//Go to next column
$this-&gt;SetCol($this-&gt;col+1);
$this-&gt;SetY(10);
return false;
}
else
{
//Go back to first column and issue page break
$this-&gt;SetCol(0);
return true;
}
}
}
$pdf=new PDF();
$pdf-&gt;AddPage();
$pdf-&gt;SetFont('Arial','',12);
for($i=1;$i&lt;=300;$i++)
$pdf-&gt;Cell(0,5,&quot;Line $i&quot;,0,1);
$pdf-&gt;Output();</code></pre>
</div>
<h2>See also</h2>
<a href="setautopagebreak.htm">SetAutoPageBreak()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>AddFont</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>AddFont</h1>
<code>AddFont(<b>string</b> family [, <b>string</b> style [, <b>string</b> file]])</code>
<h2>Description</h2>
Imports a TrueType or Type1 font and makes it available. It is necessary to generate a font
definition file first with the makefont.php utility.
<br>
The definition file (and the font file itself when embedding) must be present in the font directory.
If it is not found, the error "Could not include font definition file" is generated.
<h2>Parameters</h2>
<dl class="param">
<dt><code>family</code></dt>
<dd>
Font family. The name can be chosen arbitrarily. If it is a standard family name, it will
override the corresponding font.
</dd>
<dt><code>style</code></dt>
<dd>
Font style. Possible values are (case insensitive):
<ul>
<li>empty string: regular</li>
<li><code>B</code>: bold</li>
<li><code>I</code>: italic</li>
<li><code>BI</code> or <code>IB</code>: bold italic</li>
</ul>
The default value is regular.
</dd>
<dt><code>file</code></dt>
<dd>
The font definition file.
<br>
By default, the name is built from the family and style, in lower case with no space.
</dd>
</dl>
<h2>Example</h2>
<div class="doc-source">
<pre><code>$pdf-&gt;AddFont('Comic','I');</code></pre>
</div>
is equivalent to:
<div class="doc-source">
<pre><code>$pdf-&gt;AddFont('Comic','I','comici.php');</code></pre>
</div>
<h2>See also</h2>
<a href="setfont.htm">SetFont()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>AddLink</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>AddLink</h1>
<code><b>int</b> AddLink()</code>
<h2>Description</h2>
Creates a new internal link and returns its identifier. An internal link is a clickable area
which directs to another place within the document.
<br>
The identifier can then be passed to Cell(), Write(), Image() or Link(). The destination is
defined with SetLink().
<h2>See also</h2>
<a href="cell.htm">Cell()</a>,
<a href="write.htm">Write()</a>,
<a href="image.htm">Image()</a>,
<a href="link.htm">Link()</a>,
<a href="setlink.htm">SetLink()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,56 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>AddPage</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>AddPage</h1>
<code>AddPage([<b>string</b> orientation ,[ <b>mixed</b> format]])</code>
<h2>Description</h2>
Adds a new page to the document. If a page is already present, the Footer() method is called
first to output the footer. Then the page is added, the current position set to the top-left
corner according to the left and top margins, and Header() is called to display the header.
<br>
The font which was set before calling is automatically restored. There is no need to call
SetFont() again if you want to continue with the same font. The same is true for colors and
line width.
<br>
The origin of the coordinate system is at the top-left corner and increasing ordinates go
downwards.
<h2>Parameters</h2>
<dl class="param">
<dt><code>orientation</code></dt>
<dd>
Page orientation. Possible values are (case insensitive):
<ul>
<li><code>P</code> or <code>Portrait</code></li>
<li><code>L</code> or <code>Landscape</code></li>
</ul>
The default value is the one passed to the constructor.
</dd>
<dt><code>format</code></dt>
<dd>
Page format. It can be either one of the following values (case insensitive):
<ul>
<li><code>A3</code></li>
<li><code>A4</code></li>
<li><code>A5</code></li>
<li><code>Letter</code></li>
<li><code>Legal</code></li>
</ul>
or an array containing the width and the height (expressed in user unit).<br>
<br>
The default value is the one passed to the constructor.
</dd>
</dl>
<h2>See also</h2>
<a href="fpdf.htm">FPDF()</a>,
<a href="header.htm">Header()</a>,
<a href="footer.htm">Footer()</a>,
<a href="setmargins.htm">SetMargins()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,45 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>AliasNbPages</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>AliasNbPages</h1>
<code>AliasNbPages([<b>string</b> alias])</code>
<h2>Description</h2>
Defines an alias for the total number of pages. It will be substituted as the document is
closed.
<h2>Parameters</h2>
<dl class="param">
<dt><code>alias</code></dt>
<dd>
The alias. Default value: <code>{nb}</code>.
</dd>
</dl>
<h2>Example</h2>
<div class="doc-source">
<pre><code>class PDF extends FPDF
{
function Footer()
{
//Go to 1.5 cm from bottom
$this-&gt;SetY(-15);
//Select Arial italic 8
$this-&gt;SetFont('Arial','I',8);
//Print current and total page numbers
$this-&gt;Cell(0,10,'Page '.$this-&gt;PageNo().'/{nb}',0,0,'C');
}
}
$pdf=new PDF();
$pdf-&gt;AliasNbPages();</code></pre>
</div>
<h2>See also</h2>
<a href="pageno.htm">PageNo()</a>,
<a href="footer.htm">Footer()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,104 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Cell</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Cell</h1>
<code>Cell(<b>float</b> w [, <b>float</b> h [, <b>string</b> txt [, <b>mixed</b> border [, <b>int</b> ln [, <b>string</b> align [, <b>boolean</b> fill [, <b>mixed</b> link]]]]]]])</code>
<h2>Description</h2>
Prints a cell (rectangular area) with optional borders, background color and character string.
The upper-left corner of the cell corresponds to the current position. The text can be aligned
or centered. After the call, the current position moves to the right or to the next line. It is
possible to put a link on the text.
<br>
If automatic page breaking is enabled and the cell goes beyond the limit, a page break is
done before outputting.
<h2>Parameters</h2>
<dl class="param">
<dt><code>w</code></dt>
<dd>
Cell width. If <code>0</code>, the cell extends up to the right margin.
</dd>
<dt><code>h</code></dt>
<dd>
Cell height.
Default value: <code>0</code>.
</dd>
<dt><code>txt</code></dt>
<dd>
String to print.
Default value: empty string.
</dd>
<dt><code>border</code></dt>
<dd>
Indicates if borders must be drawn around the cell. The value can be either a number:
<ul>
<li><code>0</code>: no border</li>
<li><code>1</code>: frame</li>
</ul>
or a string containing some or all of the following characters (in any order):
<ul>
<li><code>L</code>: left</li>
<li><code>T</code>: top</li>
<li><code>R</code>: right</li>
<li><code>B</code>: bottom</li>
</ul>
Default value: <code>0</code>.
</dd>
<dt><code>ln</code></dt>
<dd>
Indicates where the current position should go after the call. Possible values are:
<ul>
<li><code>0</code>: to the right</li>
<li><code>1</code>: to the beginning of the next line</li>
<li><code>2</code>: below</li>
</ul>
Putting <code>1</code> is equivalent to putting <code>0</code> and calling Ln() just after.
Default value: <code>0</code>.
</dd>
<dt><code>align</code></dt>
<dd>
Allows to center or align the text. Possible values are:
<ul>
<li><code>L</code> or empty string: left align (default value)</li>
<li><code>C</code>: center</li>
<li><code>R</code>: right align</li>
</ul>
</dd>
<dt><code>fill</code></dt>
<dd>
Indicates if the cell background must be painted (<code>true</code>) or transparent (<code>false</code>).
Default value: <code>false</code>.
</dd>
<dt><code>link</code></dt>
<dd>
URL or identifier returned by AddLink().
</dd>
</dl>
<h2>Example</h2>
<div class="doc-source">
<pre><code>//Set font
$pdf-&gt;SetFont('Arial','B',16);
//Move to 8 cm to the right
$pdf-&gt;Cell(80);
//Centered text in a framed 20*10 mm cell and line break
$pdf-&gt;Cell(20,10,'Title',1,1,'C');</code></pre>
</div>
<h2>See also</h2>
<a href="setfont.htm">SetFont()</a>,
<a href="setdrawcolor.htm">SetDrawColor()</a>,
<a href="setfillcolor.htm">SetFillColor()</a>,
<a href="settextcolor.htm">SetTextColor()</a>,
<a href="setlinewidth.htm">SetLineWidth()</a>,
<a href="addlink.htm">AddLink()</a>,
<a href="ln.htm">Ln()</a>,
<a href="multicell.htm">MultiCell()</a>,
<a href="write.htm">Write()</a>,
<a href="setautopagebreak.htm">SetAutoPageBreak()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,21 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Close</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Close</h1>
<code>Close()</code>
<h2>Description</h2>
Terminates the PDF document. It is not necessary to call this method explicitly because Output()
does it automatically.
<br>
If the document contains no page, AddPage() is called to prevent from getting an invalid document.
<h2>See also</h2>
<a href="output.htm">Output()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Error</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Error</h1>
<code>Error(<b>string</b> msg)</code>
<h2>Description</h2>
This method is automatically called in case of fatal error; it simply outputs the message
and halts the execution. An inherited class may override it to customize the error handling
but should always halt the script, or the resulting document would probably be invalid.
<h2>Parameters</h2>
<dl class="param">
<dt><code>msg</code></dt>
<dd>
The error message.
</dd>
</dl>
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Footer</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Footer</h1>
<code>Footer()</code>
<h2>Description</h2>
This method is used to render the page footer. It is automatically called by AddPage() and
Close() and should not be called directly by the application. The implementation in FPDF is
empty, so you have to subclass it and override the method if you want a specific processing.
<h2>Example</h2>
<div class="doc-source">
<pre><code>class PDF extends FPDF
{
function Footer()
{
//Go to 1.5 cm from bottom
$this-&gt;SetY(-15);
//Select Arial italic 8
$this-&gt;SetFont('Arial','I',8);
//Print centered page number
$this-&gt;Cell(0,10,'Page '.$this-&gt;PageNo(),0,0,'C');
}
}</code></pre>
</div>
<h2>See also</h2>
<a href="header.htm">Header()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,63 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>FPDF</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>FPDF</h1>
<code>FPDF([<b>string</b> orientation [, <b>string</b> unit [, <b>mixed</b> format]]])</code>
<h2>Description</h2>
This is the class constructor. It allows to set up the page format, the orientation and the
unit of measure used in all methods (except for font sizes).
<h2>Parameters</h2>
<dl class="param">
<dt><code>orientation</code></dt>
<dd>
Default page orientation. Possible values are (case insensitive):
<ul>
<li><code>P</code> or <code>Portrait</code></li>
<li><code>L</code> or <code>Landscape</code></li>
</ul>
Default value is <code>P</code>.
</dd>
<dt><code>unit</code></dt>
<dd>
User unit. Possible values are:
<ul>
<li><code>pt</code>: point</li>
<li><code>mm</code>: millimeter</li>
<li><code>cm</code>: centimeter</li>
<li><code>in</code>: inch</li>
</ul>
A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This
is a very common unit in typography; font sizes are expressed in that unit.
<br>
<br>
Default value is <code>mm</code>.
</dd>
<dt><code>format</code></dt>
<dd>
The format used for pages. It can be either one of the following values (case insensitive):
<ul>
<li><code>A3</code></li>
<li><code>A4</code></li>
<li><code>A5</code></li>
<li><code>Letter</code></li>
<li><code>Legal</code></li>
</ul>
or an array containing the width and the height (expressed in the unit given by <code>unit</code>).<br>
<br>
Default value is <code>A4</code>.
</dd>
</dl>
<h2>Example</h2>
Example with a custom 100x150 mm page format:
<div class="doc-source">
<pre><code>$pdf = new FPDF('P', 'mm', array(100,150));</code></pre>
</div>
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>GetStringWidth</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>GetStringWidth</h1>
<code><b>float</b> GetStringWidth(<b>string</b> s)</code>
<h2>Description</h2>
Returns the length of a string in user unit. A font must be selected.
<h2>Parameters</h2>
<dl class="param">
<dt><code>s</code></dt>
<dd>
The string whose length is to be computed.
</dd>
</dl>
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>GetX</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>GetX</h1>
<code><b>float</b> GetX()</code>
<h2>Description</h2>
Returns the abscissa of the current position.
<h2>See also</h2>
<a href="setx.htm">SetX()</a>,
<a href="gety.htm">GetY()</a>,
<a href="sety.htm">SetY()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>GetY</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>GetY</h1>
<code><b>float</b> GetY()</code>
<h2>Description</h2>
Returns the ordinate of the current position.
<h2>See also</h2>
<a href="sety.htm">SetY()</a>,
<a href="getx.htm">GetX()</a>,
<a href="setx.htm">SetX()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Header</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Header</h1>
<code>Header()</code>
<h2>Description</h2>
This method is used to render the page header. It is automatically called by AddPage() and
should not be called directly by the application. The implementation in FPDF is empty, so
you have to subclass it and override the method if you want a specific processing.
<h2>Example</h2>
<div class="doc-source">
<pre><code>class PDF extends FPDF
{
function Header()
{
//Select Arial bold 15
$this-&gt;SetFont('Arial','B',15);
//Move to the right
$this-&gt;Cell(80);
//Framed title
$this-&gt;Cell(30,10,'Title',1,0,'C');
//Line break
$this-&gt;Ln(20);
}
}</code></pre>
</div>
<h2>See also</h2>
<a href="footer.htm">Footer()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,86 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Image</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Image</h1>
<code>Image(<b>string</b> file [, <b>float</b> x [, <b>float</b> y [, <b>float</b> w [, <b>float</b> h [, <b>string</b> type [, <b>mixed</b> link]]]]]])</code>
<h2>Description</h2>
Puts an image. The size it will take on the page can be specified in different ways:
<ul>
<li>explicit width and height (expressed in user unit)</li>
<li>one explicit dimension, the other being calculated automatically in order to keep the original proportions</li>
<li>no explicit dimension, in which case the image is put at 72 dpi</li>
</ul>
Supported formats are JPEG, PNG and GIF. The GD extension is required for GIF.
<br>
<br>
For JPEGs, all flavors are allowed:
<ul>
<li>gray scales</li>
<li>true colors (24 bits)</li>
<li>CMYK (32 bits)</li>
</ul>
For PNGs, are allowed:
<ul>
<li>gray scales on at most 8 bits (256 levels)</li>
<li>indexed colors</li>
<li>true colors (24 bits)</li>
</ul>
but are not supported:
<ul>
<li>Interlacing</li>
<li>Alpha channel</li>
</ul>
For GIFs: in case of an animated GIF, only the first frame is used.<br>
<br>
If a transparent color is defined, it is taken into account.<br>
<br>
The format can be specified explicitly or inferred from the file extension.<br>
It is possible to put a link on the image.<br>
<br>
Remark: if an image is used several times, only one copy is embedded in the file.
<h2>Parameters</h2>
<dl class="param">
<dt><code>file</code></dt>
<dd>
Path or URL of the image.
</dd>
<dt><code>x</code></dt>
<dd>
Abscissa of the upper-left corner. If not specified or equal to <code>null</code>, the current abscissa
is used.
</dd>
<dt><code>y</code></dt>
<dd>
Ordinate of the upper-left corner. If not specified or equal to <code>null</code>, the current ordinate
is used; moreover, a page break is triggered first if necessary (in case automatic page breaking is enabled)
and, after the call, the current ordinate is moved to the bottom of the image.
</dd>
<dt><code>w</code></dt>
<dd>
Width of the image in the page. If not specified or equal to zero, it is automatically calculated.
</dd>
<dt><code>h</code></dt>
<dd>
Height of the image in the page. If not specified or equal to zero, it is automatically calculated.
</dd>
<dt><code>type</code></dt>
<dd>
Image format. Possible values are (case insensitive): <code>JPG</code>, <code>JPEG</code>, <code>PNG</code> and <code>GIF</code>.
If not specified, the type is inferred from the file extension.
</dd>
<dt><code>link</code></dt>
<dd>
URL or identifier returned by AddLink().
</dd>
</dl>
<h2>See also</h2>
<a href="addlink.htm">AddLink()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,57 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>FPDF 1.6 Reference Manual</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>FPDF 1.6 Reference Manual</h1>
<a href="acceptpagebreak.htm">AcceptPageBreak</a> - accept or not automatic page break<br>
<a href="addfont.htm">AddFont</a> - add a new font<br>
<a href="addlink.htm">AddLink</a> - create an internal link<br>
<a href="addpage.htm">AddPage</a> - add a new page<br>
<a href="aliasnbpages.htm">AliasNbPages</a> - define an alias for number of pages<br>
<a href="cell.htm">Cell</a> - print a cell<br>
<a href="close.htm">Close</a> - terminate the document<br>
<a href="error.htm">Error</a> - fatal error<br>
<a href="footer.htm">Footer</a> - page footer<br>
<a href="fpdf.htm">FPDF</a> - constructor<br>
<a href="getstringwidth.htm">GetStringWidth</a> - compute string length<br>
<a href="getx.htm">GetX</a> - get current x position<br>
<a href="gety.htm">GetY</a> - get current y position<br>
<a href="header.htm">Header</a> - page header<br>
<a href="image.htm">Image</a> - output an image<br>
<a href="line.htm">Line</a> - draw a line<br>
<a href="link.htm">Link</a> - put a link<br>
<a href="ln.htm">Ln</a> - line break<br>
<a href="multicell.htm">MultiCell</a> - print text with line breaks<br>
<a href="output.htm">Output</a> - save or send the document<br>
<a href="pageno.htm">PageNo</a> - page number<br>
<a href="rect.htm">Rect</a> - draw a rectangle<br>
<a href="setauthor.htm">SetAuthor</a> - set the document author<br>
<a href="setautopagebreak.htm">SetAutoPageBreak</a> - set the automatic page breaking mode<br>
<a href="setcompression.htm">SetCompression</a> - turn compression on or off<br>
<a href="setcreator.htm">SetCreator</a> - set document creator<br>
<a href="setdisplaymode.htm">SetDisplayMode</a> - set display mode<br>
<a href="setdrawcolor.htm">SetDrawColor</a> - set drawing color<br>
<a href="setfillcolor.htm">SetFillColor</a> - set filling color<br>
<a href="setfont.htm">SetFont</a> - set font<br>
<a href="setfontsize.htm">SetFontSize</a> - set font size<br>
<a href="setkeywords.htm">SetKeywords</a> - associate keywords with document<br>
<a href="setleftmargin.htm">SetLeftMargin</a> - set left margin<br>
<a href="setlinewidth.htm">SetLineWidth</a> - set line width<br>
<a href="setlink.htm">SetLink</a> - set internal link destination<br>
<a href="setmargins.htm">SetMargins</a> - set margins<br>
<a href="setrightmargin.htm">SetRightMargin</a> - set right margin<br>
<a href="setsubject.htm">SetSubject</a> - set document subject<br>
<a href="settextcolor.htm">SetTextColor</a> - set text color<br>
<a href="settitle.htm">SetTitle</a> - set document title<br>
<a href="settopmargin.htm">SetTopMargin</a> - set top margin<br>
<a href="setx.htm">SetX</a> - set current x position<br>
<a href="setxy.htm">SetXY</a> - set current x and y positions<br>
<a href="sety.htm">SetY</a> - set current y position<br>
<a href="text.htm">Text</a> - print a string<br>
<a href="write.htm">Write</a> - print flowing text<br>
</body>
</html>

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2019 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* prestashop@dpd.com.pl so we can send you a copy immediately.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2019 DPD Polska Sp. z o.o.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of DPD Polska Sp. z o.o.
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Line</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Line</h1>
<code>Line(<b>float</b> x1, <b>float</b> y1, <b>float</b> x2, <b>float</b> y2)</code>
<h2>Description</h2>
Draws a line between two points.
<h2>Parameters</h2>
<dl class="param">
<dt><code>x1</code></dt>
<dd>
Abscissa of first point.
</dd>
<dt><code>y1</code></dt>
<dd>
Ordinate of first point.
</dd>
<dt><code>x2</code></dt>
<dd>
Abscissa of second point.
</dd>
<dt><code>y2</code></dt>
<dd>
Ordinate of second point.
</dd>
</dl>
<h2>See also</h2>
<a href="setlinewidth.htm">SetLineWidth()</a>,
<a href="setdrawcolor.htm">SetDrawColor()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,46 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Link</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Link</h1>
<code>Link(<b>float</b> x, <b>float</b> y, <b>float</b> w, <b>float</b> h, <b>mixed</b> link)</code>
<h2>Description</h2>
Puts a link on a rectangular area of the page. Text or image links are generally put via Cell(),
Write() or Image(), but this method can be useful for instance to define a clickable area inside
an image.
<h2>Parameters</h2>
<dl class="param">
<dt><code>x</code></dt>
<dd>
Abscissa of the upper-left corner of the rectangle.
</dd>
<dt><code>y</code></dt>
<dd>
Ordinate of the upper-left corner of the rectangle.
</dd>
<dt><code>w</code></dt>
<dd>
Width of the rectangle.
</dd>
<dt><code>h</code></dt>
<dd>
Height of the rectangle.
</dd>
<dt><code>link</code></dt>
<dd>
URL or identifier returned by AddLink().
</dd>
</dl>
<h2>See also</h2>
<a href="addlink.htm">AddLink()</a>,
<a href="cell.htm">Cell()</a>,
<a href="write.htm">Write()</a>,
<a href="image.htm">Image()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

View File

@@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Ln</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Ln</h1>
<code>Ln([<b>float</b> h])</code>
<h2>Description</h2>
Performs a line break. The current abscissa goes back to the left margin and the ordinate
increases by the amount passed in parameter.
<h2>Parameters</h2>
<dl class="param">
<dt><code>h</code></dt>
<dd>
The height of the break.
<br>
By default, the value equals the height of the last printed cell.
</dd>
</dl>
<h2>See also</h2>
<a href="cell.htm">Cell()</a>.
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More