first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

8
modules/dpdpoland/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../../:\PROJEKTY\php\prestashop_1771\modules\dpdpoland\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

9
modules/dpdpoland/.idea/dpdpoland.iml generated Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

4
modules/dpdpoland/.idea/encodings.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PhpUnused" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
</profile>
</component>

6
modules/dpdpoland/.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

8
modules/dpdpoland/.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/dpdpoland.iml" filepath="$PROJECT_DIR$/.idea/dpdpoland.iml" />
</modules>
</component>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

View File

@@ -0,0 +1,241 @@
<?php
require_once(_PS_ADMIN_DIR_.'/tabs/AdminOrders.php');
/**
* Class AdminOrdersOverride used to make modifications in orders list on PS 1.4
*/
class AdminOrdersOverride extends AdminOrders
{
/**
* AdminOrdersOverride class constructor
*/
public function __construct()
{
parent::__construct();
$this->delete = true;
}
/**
* Displays additional buttons in orders list
*
* @param null|string $token BackOffice token
*/
public function displayListFooter($token = null)
{
echo '</table>';
echo '<p>
<input type="submit" class="button" name="submitBulkprint_a4order" value="'.$this->l('Print A4 format labels').'" onclick="return confirm(\''.$this->l('Print A4 format labels', __CLASS__, true, false).'\');" />
<input type="submit" class="button" name="submitBulkprint_labelorder" value="'.$this->l('Print A4 format labels').'" onclick="return confirm(\''.$this->l('Print A4 format labels', __CLASS__, true, false).'\');" />
</p>';
echo '
</td>
</tr>
</table>
<input type="hidden" name="token" value="'.($token ? $token : $this->token).'" />
</form>';
if (isset($this->_includeTab) && count($this->_includeTab))
echo '<br /><br />';
}
/**
* Displays orders list
*
* @param null|string $token BackOffice token
*/
public function displayListContent($token = null)
{
global $currentIndex, $cookie;
$currency = new Currency(_PS_CURRENCY_DEFAULT_);
$id_category = 1; // default categ
$irow = 0;
if ($this->_list AND isset($this->fieldsDisplay['position']))
{
$positions = array_map(create_function('$elem', 'return (int)($elem[\'position\']);'), $this->_list);
sort($positions);
}
if ($this->_list)
{
$isCms = false;
Module::getInstanceByName('dpdpoland');
$exceptions = DpdPolandPackage::getLabelExceptions();
if (preg_match('/cms/Ui', $this->identifier))
$isCms = true;
$keyToGet = 'id_'.($isCms ? 'cms_' : '').'category'.(in_array($this->identifier, array('id_category', 'id_cms_category')) ? '_parent' : '');
foreach ($this->_list as $tr)
{
$id = $tr[$this->identifier];
echo '<tr'.(array_key_exists($this->identifier,$this->identifiersDnd) ? ' id="tr_'.(($id_category = (int)(Tools::getValue('id_'.($isCms ? 'cms_' : '').'category', '1'))) ? $id_category : '').'_'.$id.'_'.$tr['position'].'"' : '').($irow++ % 2 ? ' class="alt_row"' : '').' '.((isset($tr['color']) AND $this->colorOnBackground) ? 'style="background-color: '.$tr['color'].'"' : '').'>
<td class="center">';
if ($this->delete AND (!isset($this->_listSkipDelete) OR !in_array($id, $this->_listSkipDelete)))
echo '<input type="checkbox" name="'.$this->table.'Box[]" value="'.$id.'" class="noborder" />';
echo '</td>';
foreach ($this->fieldsDisplay as $key => $params)
{
$tmp = explode('!', $key);
$key = isset($tmp[1]) ? $tmp[1] : $tmp[0];
echo '
<td '.(isset($params['position']) ? ' id="td_'.(isset($id_category) AND $id_category ? $id_category : 0).'_'.$id.'"' : '').' class="'.((!isset($this->noLink) OR !$this->noLink) ? 'pointer' : '').((isset($params['position']) AND $this->_orderBy == 'position')? ' dragHandle' : ''). (isset($params['align']) ? ' '.$params['align'] : '').'" ';
if (!isset($params['position']) AND (!isset($this->noLink) OR !$this->noLink))
echo ' onclick="document.location = \''.$currentIndex.'&'.$this->identifier.'='.$id.($this->view? '&view' : '&update').$this->table.'&token='.($token != null ? $token : $this->token).'\'">'.(isset($params['prefix']) ? $params['prefix'] : '');
else
echo '>';
if (isset($params['active']) AND isset($tr[$key]))
$this->_displayEnableLink($token, $id, $tr[$key], $params['active'], Tools::getValue('id_category'), Tools::getValue('id_product'));
elseif (isset($params['activeVisu']) AND isset($tr[$key]))
echo '<img src="../img/admin/'.($tr[$key] ? 'enabled.gif' : 'disabled.gif').'"
alt="'.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).'" title="'.($tr[$key] ? $this->l('Enabled') : $this->l('Disabled')).'" />';
elseif (isset($params['position']))
{
if ($this->_orderBy == 'position' AND $this->_orderWay != 'DESC')
{
echo '<a'.(!($tr[$key] != $positions[sizeof($positions) - 1]) ? ' style="display: none;"' : '').' href="'.$currentIndex.
'&'.$keyToGet.'='.(int)($id_category).'&'.$this->identifiersDnd[$this->identifier].'='.$id.'
&way=1&position='.(int)($tr['position'] + 1).'&token='.($token != null ? $token : $this->token).'">
<img src="../img/admin/'.($this->_orderWay == 'ASC' ? 'down' : 'up').'.gif"
alt="'.$this->l('Down').'" title="'.$this->l('Down').'" /></a>';
echo '<a'.(!($tr[$key] != $positions[0]) ? ' style="display: none;"' : '').' href="'.$currentIndex.
'&'.$keyToGet.'='.(int)($id_category).'&'.$this->identifiersDnd[$this->identifier].'='.$id.'
&way=0&position='.(int)($tr['position'] - 1).'&token='.($token != null ? $token : $this->token).'">
<img src="../img/admin/'.($this->_orderWay == 'ASC' ? 'up' : 'down').'.gif"
alt="'.$this->l('Up').'" title="'.$this->l('Up').'" /></a>'; }
else
echo (int)($tr[$key] + 1);
}
elseif (isset($params['image']))
{
// item_id is the product id in a product image context, else it is the image id.
$item_id = isset($params['image_id']) ? $tr[$params['image_id']] : $id;
// If it's a product image
if (isset($tr['id_image']))
{
$image = new Image((int)$tr['id_image']);
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$image->getExistingImgPath().'.'.$this->imageType;
}else
$path_to_image = _PS_IMG_DIR_.$params['image'].'/'.$item_id.(isset($tr['id_image']) ? '-'.(int)($tr['id_image']) : '').'.'.$this->imageType;
echo cacheImage($path_to_image, $this->table.'_mini_'.$item_id.'.'.$this->imageType, 45, $this->imageType);
}
elseif (isset($params['icon']) AND (isset($params['icon'][$tr[$key]]) OR isset($params['icon']['default'])))
echo '<img src="../img/admin/'.(isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'].'" alt="'.$tr[$key]).'" title="'.$tr[$key].'" />';
elseif (isset($params['price']))
echo Tools::displayPrice($tr[$key], (isset($params['currency']) ? Currency::getCurrencyInstance((int)($tr['id_currency'])) : $currency), false);
elseif (isset($params['float']))
echo rtrim(rtrim($tr[$key], '0'), '.');
elseif (isset($params['type']) AND $params['type'] == 'date')
echo Tools::displayDate($tr[$key], (int)$cookie->id_lang);
elseif (isset($params['type']) AND $params['type'] == 'datetime')
echo Tools::displayDate($tr[$key], (int)$cookie->id_lang, true);
elseif (isset($tr[$key]))
{
$echo = ($key == 'price' ? round($tr[$key], 2) : isset($params['maxlength']) ? Tools::substr($tr[$key], 0, $params['maxlength']).'...' : $tr[$key]);
echo isset($params['callback']) ? call_user_func_array(array($this->className, $params['callback']), array($echo, $tr)) : $echo;
}
else
echo '--';
echo (isset($params['suffix']) ? $params['suffix'] : '').
'</td>';
}
if ($this->edit OR $this->delete OR ($this->view AND $this->view !== 'noActionColumn'))
{
echo '<td class="center" style="white-space: nowrap;">';
if ($this->view)
$this->_displayViewLink($token, $id);
if (!in_array($id, $exceptions)) {
$this->_displayPrinta4Link($token, $id);
$this->_displayPrintlabelLink($token, $id);
}
echo '</td>';
}
echo '</tr>';
}
}
}
/**
* Displays link used to print A4 format label
*
* @param string $token BackOffice token
* @param int $id Order identifier
*/
private function _displayPrinta4Link($token, $id)
{
global $currentIndex;
$_cacheLang['printa4'] = $this->l('Print A4 format label');
Module::getInstanceByName('dpdpoland');
echo '
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&printa4formatlabel&token='.($token ? $token : $this->token).'">
<img src="'._DPDPOLAND_IMG_URI_.'download.gif" alt="'.$_cacheLang['printa4'].'" title="'.$_cacheLang['printa4'].'" /></a>';
}
/**
* Displays link used to print label format label
*
* @param string $token BackOffice token
* @param int $id Order identifier
*/
private function _displayPrintlabelLink($token, $id)
{
global $currentIndex;
$_cacheLang['printlabel'] = $this->l('Print label format label');
Module::getInstanceByName('dpdpoland');
echo '
<a href="'.$currentIndex.'&'.$this->identifier.'='.$id.'&printlabelformatlabel&token='.($token ? $token : $this->token).'">
<img src="'._DPDPOLAND_IMG_URI_.'download.gif" alt="'.$_cacheLang['printlabel'].'" title="'.$_cacheLang['printlabel'].'" /></a>';
}
/**
* Main controller (tab) function used to make actions in page
*/
public function postProcess()
{
parent::postProcess();
if (Tools::isSubmit('submitBulkprint_a4order')) {
$module_instance = Module::getInstanceByName('dpdpoland');
if ($errors = $module_instance->printMultipleLabels(DpdPolandConfiguration::PRINTOUT_FORMAT_A4)) {
$this->_errors = $errors;
}
}
if (Tools::isSubmit('submitBulkprint_labelorder')) {
$module_instance = Module::getInstanceByName('dpdpoland');
if ($errors = $module_instance->printMultipleLabels(DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL)) {
$this->_errors = $errors;
}
}
if (Tools::isSubmit('printa4formatlabel')) {
$module_instance = Module::getInstanceByName('dpdpoland');
if ($error = $module_instance->printSingleLabel(DpdPolandConfiguration::PRINTOUT_FORMAT_A4)) {
$this->_errors[] = $error;
}
}
if (Tools::isSubmit('printlabelformatlabel')) {
$module_instance = Module::getInstanceByName('dpdpoland');
if ($error = $module_instance->printSingleLabel(DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL)) {
$this->_errors[] = $error;
}
}
}
}

View File

@@ -0,0 +1 @@
.DS_Store

View File

@@ -0,0 +1,347 @@
<?php
/*
* 2007-2014 PrestaShop
*
* 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
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if ((bool)Configuration::get('PS_MOBILE_DEVICE'))
require_once(_PS_MODULE_DIR_ . '/mobile_theme/Mobile_Detect.php');
// Retro 1.3, 'class_exists' cause problem with autoload...
if (version_compare(_PS_VERSION_, '1.4', '<'))
{
// Not exist for 1.3
class Shop extends ObjectModel
{
public $id = 1;
public $id_shop_group = 1;
public function __construct()
{
}
public static function getShops()
{
return array(
array('id_shop' => 1, 'name' => 'Default shop')
);
}
public static function getCurrentShop()
{
return 1;
}
}
class Logger
{
public static function AddLog($message, $severity = 2)
{
$fp = fopen(dirname(__FILE__).'/../logs.txt', 'a+');
fwrite($fp, '['.(int)$severity.'] '.Tools::safeOutput($message));
fclose($fp);
}
}
}
// Not exist for 1.3 and 1.4
class Context
{
/**
* @var Context
*/
protected static $instance;
/**
* @var Cart
*/
public $cart;
/**
* @var Customer
*/
public $customer;
/**
* @var Cookie
*/
public $cookie;
/**
* @var Link
*/
public $link;
/**
* @var Country
*/
public $country;
/**
* @var Employee
*/
public $employee;
/**
* @var Controller
*/
public $controller;
/**
* @var Language
*/
public $language;
/**
* @var Currency
*/
public $currency;
/**
* @var AdminTab
*/
public $tab;
/**
* @var Shop
*/
public $shop;
/**
* @var Smarty
*/
public $smarty;
/**
* @ var Mobile Detect
*/
public $mobile_detect;
/**
* @var boolean|string mobile device of the customer
*/
protected $mobile_device;
public function __construct()
{
global $cookie, $cart, $smarty, $link;
$this->tab = null;
$this->cookie = $cookie;
$this->cart = $cart;
$this->smarty = $smarty;
$this->link = $link;
$this->controller = new ControllerBackwardModule();
if (is_object($cookie))
{
$this->currency = new Currency((int)$cookie->id_currency);
$this->language = new Language((int)$cookie->id_lang);
$this->country = new Country((int)$cookie->id_country);
$this->customer = new CustomerBackwardModule((int)$cookie->id_customer);
$this->employee = new Employee((int)$cookie->id_employee);
}
else
{
$this->currency = null;
$this->language = null;
$this->country = null;
$this->customer = null;
$this->employee = null;
}
$this->shop = new ShopBackwardModule();
if ((bool)Configuration::get('PS_MOBILE_DEVICE'))
$this->mobile_detect = new Mobile_Detect();
}
public function getMobileDevice()
{
if (is_null($this->mobile_device))
{
$this->mobile_device = false;
if ($this->checkMobileContext())
{
switch ((int)Configuration::get('PS_MOBILE_DEVICE'))
{
case 0: // Only for mobile device
if ($this->mobile_detect->isMobile() && !$this->mobile_detect->isTablet())
$this->mobile_device = true;
break;
case 1: // Only for touchpads
if ($this->mobile_detect->isTablet() && !$this->mobile_detect->isMobile())
$this->mobile_device = true;
break;
case 2: // For touchpad or mobile devices
if ($this->mobile_detect->isMobile() || $this->mobile_detect->isTablet())
$this->mobile_device = true;
break;
}
}
}
return $this->mobile_device;
}
protected function checkMobileContext()
{
return isset($_SERVER['HTTP_USER_AGENT'])
&& (bool)Configuration::get('PS_MOBILE_DEVICE')
&& !Context::getContext()->cookie->no_mobile;
}
/**
* Get a singleton context
*
* @return Context
*/
public static function getContext()
{
if (!isset(self::$instance))
self::$instance = new Context();
return self::$instance;
}
/**
* Clone current context
*
* @return Context
*/
public function cloneContext()
{
return clone($this);
}
/**
* @return int Shop context type (Shop::CONTEXT_ALL, etc.)
*/
public static function shop()
{
if (!self::$instance->shop->getContextType())
return ShopBackwardModule::CONTEXT_ALL;
return self::$instance->shop->getContextType();
}
}
/**
* Class Shop for Backward compatibility
*/
class ShopBackwardModule extends Shop
{
const CONTEXT_ALL = 1;
public $id = 1;
public $id_shop_group = 1;
public function getContextType()
{
return ShopBackwardModule::CONTEXT_ALL;
}
// Simulate shop for 1.3 / 1.4
public function getID()
{
return 1;
}
/**
* Get shop theme name
*
* @return string
*/
public function getTheme()
{
return _THEME_NAME_;
}
public function isFeatureActive()
{
return false;
}
}
/**
* Class Controller for a Backward compatibility
* Allow to use method declared in 1.5
*/
class ControllerBackwardModule
{
/**
* @param $js_uri
* @return void
*/
public function addJS($js_uri)
{
Tools::addJS($js_uri);
}
/**
* @param $css_uri
* @param string $css_media_type
* @return void
*/
public function addCSS($css_uri, $css_media_type = 'all')
{
Tools::addCSS($css_uri, $css_media_type);
}
public function addJquery()
{
if (_PS_VERSION_ < '1.5')
$this->addJS(_PS_JS_DIR_.'jquery/jquery-1.4.4.min.js');
elseif (_PS_VERSION_ >= '1.5')
$this->addJS(_PS_JS_DIR_.'jquery/jquery-1.7.2.min.js');
}
}
/**
* Class Customer for a Backward compatibility
* Allow to use method declared in 1.5
*/
class CustomerBackwardModule extends Customer
{
public $logged = false;
/**
* Check customer informations and return customer validity
*
* @since 1.5.0
* @param boolean $with_guest
* @return boolean customer validity
*/
public function isLogged($with_guest = false)
{
if (!$with_guest && $this->is_guest == 1)
return false;
/* Customer is valid only if it can be load and if object password is the same as database one */
if ($this->logged == 1 && $this->id && Validate::isUnsignedId($this->id) && Customer::checkPassword($this->id, $this->passwd))
return true;
return false;
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* 2007-2014 PrestaShop
*
* 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
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Class allow to display tpl on the FO
*/
class BWDisplay extends FrontController
{
// Assign template, on 1.4 create it else assign for 1.5
public function setTemplate($template)
{
if (_PS_VERSION_ >= '1.5')
parent::setTemplate($template);
else
$this->template = $template;
}
// Overload displayContent for 1.4
public function displayContent()
{
parent::displayContent();
echo Context::getContext()->smarty->fetch($this->template);
}
}

View File

@@ -0,0 +1 @@
version = 0.4

View File

@@ -0,0 +1,55 @@
<?php
/*
* 2007-2014 PrestaShop
*
* 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
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Backward function compatibility
* Need to be called for each module in 1.4
*/
// Get out if the context is already defined
if (!in_array('Context', get_declared_classes()))
require_once(dirname(__FILE__).'/Context.php');
// Get out if the Display (BWDisplay to avoid any conflict)) is already defined
if (!in_array('BWDisplay', get_declared_classes()))
require_once(dirname(__FILE__).'/Display.php');
// If not under an object we don't have to set the context
if (!isset($this))
return;
else if (isset($this->context))
{
// If we are under an 1.5 version and backoffice, we have to set some backward variable
if (_PS_VERSION_ >= '1.5' && isset($this->context->employee->id) && $this->context->employee->id && isset(AdminController::$currentIndex) && !empty(AdminController::$currentIndex))
{
global $currentIndex;
$currentIndex = AdminController::$currentIndex;
}
return;
}
$this->context = Context::getContext();
$this->smarty = $this->context->smarty;

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2014 PrestaShop
*
* 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
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,76 @@
# 1.4.5
Added:
- Text boxes for receiver address - order details
- Modify email address
- Addresses for guest account
# 1.4.4 [2021-02-28]
Added:
- Prestashop 1.7.7.X support
- Duty service
Changed:
- New tracking URL
- Retrieving a home or mobile phone number
# 1.4.3 [2020-12-06]
Fixed:
- Shipping price for selected currency
# 1.4.2 [2020-09-28]
Fixed:
- Print manifest with duplicated content
# 1.4.1 [2020-09-26]
Changed:
- Tracking URL
Fixed:
- Show addresses in admin order
- Finish order without pudo premissions
- Remove print_l for pickup order
- Show pickup map for prestashop 1.6.X - One-page checkout
# 1.4.0 [2020-09-13]
Added:
- Pickup history
- Ability to enable Error and Debug logs
- Ability to disable sending an email with shipping number
- Support for the {meta products} in the e-mail confirming the shipment
- Adaptation to prestashop 1.7.6.X
- Polish language translations
Fixed:
- Shipping price from csv price list
- Possibility of marking the delivery for the selected country
# 1.3.0 [2019-10-20]
Added:
- Missing Polish translations
- CLIENT PARAMETERS in "Arrange Pickup" tab
Removed:
- Printing labels from admin order list
- Remove unused Customer FID
Changed:
- WSDL environment changed from text to list
- Changed service WSDL generateSpedLabelsV1 to generateSpedLabelsV4
- Changed service WSDL generateProtocolV1 to generateProtocolV2
- Changed service WSDL packagesPickupCallV3 to packagesPickupCallV4
- Changed licence information
- Moved Master FID field
- CLIENT PARAMETERS not required
# 1.2.8 [2019-03-13]
Added:
- DPD Next Day and DPD Express services
Fixed:
- Phone not saving when selecting pickup point carrier
# 1.2.4
Fixed:
- A problem where if home phone was empty but had spaces in string it would be displayed in address instead of mobile phone
_________________________________________________________________
Added for new features.
Changed for changes in existing functionality.
Deprecated for once-stable features removed in upcoming releases.
Removed for deprecated features removed in this release.
Fixed for any bug fixes.
Security to invite users to upgrade in case of vulnerabilities.

View File

@@ -0,0 +1,280 @@
<?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 DpdPolandCSV Responsible for prices import management
*/
class DpdPolandCSV extends DpdPolandObjectModel
{
/**
* @var int Shop ID
*/
public $id_shop;
/**
* @var datetime Date when price rule was created
*/
public $date_add;
/**
* @var datetime Date when price rule was updated
*/
public $date_upd;
/**
* @var int CSV rule ID
*/
public $id_csv;
/**
* @var string Country ISO code
*/
public $iso_country;
/**
* @var float Price from which price rule is applied
*/
public $price_from;
/**
* @var float Price to which price rule is applied
*/
public $price_to;
/**
* @var float Weight from which price rule is applied
*/
public $weight_from;
/**
* @var float Weight to which price rule is applied
*/
public $weight_to;
/**
* @var float Shipment price
*/
public $parcel_price;
/**
* @var int DPD service (carrier) ID
*/
public $id_carrier;
/**
* @var float Additional COD carrier price
*/
public $cod_price;
/**
* Country column number in CSV file
*/
const COLUMN_COUNTRY = 0;
/**
* Price From column number in CSV file
*/
const COLUMN_PRICE_FROM = 1;
/**
* Price To column number in CSV file
*/
const COLUMN_PRICE_TO = 2;
/**
* Weight From column number in CSV file
*/
const COLUMN_WEIGHT_FROM = 3;
/**
* Weight To column number in CSV file
*/
const COLUMN_WEIGHT_TO = 4;
/**
* Shipment price column number in CSV file
*/
const COLUMN_PARCEL_PRICE = 5;
/**
* Carrier ID column number in CSV file
*/
const COLUMN_CARRIER = 6;
/**
* COD additional price column number in CSV file
*/
const COLUMN_COD_PRICE = 7;
/**
* File upload field name
*/
const CSV_FILE = 'DPD_GEOPOST_CSV_FILE';
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_PRICE_RULE_DB_,
'primary' => 'id_csv',
'multilang' => false,
'multishop' => true,
'fields' => array(
'id_csv' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'iso_country' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'price_from' => array('type' => self::TYPE_STRING, 'validate' => 'isFloat'),
'price_to' => array('type' => self::TYPE_STRING, 'validate' => 'isFloat'),
'weight_from' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'weight_to' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'parcel_price' => array('type' => self::TYPE_STRING, 'validate' => 'isFloat'),
'cod_price' => array('type' => self::TYPE_STRING, 'validate' => 'isFloat'),
'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Collects data from database about price rules
*
* @param string|int $start From which element data should be taken
* @param string|int $limit How many elements should be taken
* @return array|false|mysqli_result|null|PDOStatement|resource Price rules data
*/
public static function getAllData($start = '', $limit = '')
{
return DB::getInstance()->executeS('
SELECT `id_csv`, `iso_country`, `price_from`, `price_to`, `weight_from`, `weight_to`, `parcel_price`,
`cod_price`, `id_carrier`
FROM `'._DB_PREFIX_._DPDPOLAND_PRICE_RULE_DB_.'`
WHERE `id_shop` = "'.(int)Context::getContext()->shop->id.'"
'.($start && $limit ? 'LIMIT '.(int)$start.', '.(int)$limit : '')
);
}
/**
* Deletes all price rules for current shop
*
* @return bool Price rules deleted successfully
*/
public static function deleteAllData()
{
return DB::getInstance()->execute('
DELETE FROM `'._DB_PREFIX_._DPDPOLAND_PRICE_RULE_DB_.'`
WHERE `id_shop` = "'.(int)Context::getContext()->shop->id.'"
');
}
/**
* Collects price rules data of current shop
*
* @return array|false|mysqli_result|null|PDOStatement|resource Price rules data
*/
public static function getCSVData()
{
return DB::getInstance()->executeS('
SELECT `iso_country`, `price_from`, `price_to`, `weight_from`, `weight_to`, `parcel_price`, `id_carrier`,
`cod_price`
FROM `'._DB_PREFIX_._DPDPOLAND_PRICE_RULE_DB_.'`
WHERE `id_shop` = "'.(int)Context::getContext()->shop->id.'"
');
}
/**
* Returns carrier price according to cart products / parameters
*
* @param float $total_weight Sum of products weight
* @param int $id_carrier Carrier ID
* @param Cart $cart Cart object
* @return bool|int|float Carrier price
*/
public static function getPrice($total_weight, $id_carrier, Cart $cart)
{
if ($id_country = (int)Tools::getValue('id_country'))
$iso_country = Country::getIsoById($id_country);
else
{
$address = new Address((int)$cart->id_address_delivery);
$iso_country = Country::getIsoById((int)$address->id_country);
}
if(!$iso_country)
$iso_country = 'PL';
$cart_total_price = $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING);
$id_currency_pl = Currency::getIdByIsoCode(_DPDPOLAND_CURRENCY_ISO_, (int)Context::getContext()->shop->id);
$currency_from = new Currency((int)$cart->id_currency);
$currency_to = new Currency((int)$id_currency_pl);
$cart_total_price = Tools::convertPriceFull($cart_total_price, $currency_from, $currency_to);
$price_rules = DB::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_._DPDPOLAND_PRICE_RULE_DB_.'`
WHERE (`iso_country` = "'.pSQL($iso_country).'" OR `iso_country` = "*")
AND (`weight_from` <= "'.pSQL($total_weight).'"
AND `weight_to` >= "'.pSQL($total_weight).'"
OR `price_from` <= "'.pSQL($cart_total_price).'"
AND `price_to` >= "'.pSQL($cart_total_price).'")
AND `id_carrier` = "'.(int)$id_carrier.'"
AND `id_shop` = "'.(int)Context::getContext()->shop->id.'"
');
if (!$price_rules)
return false;
$available_prices_count = count($price_rules);
for ($i = 0; $i < $available_prices_count; $i++)
if ($price_rules[$i]['iso_country'] != '*' && !Country::getByIso($price_rules[$i]['iso_country'])) //if country is not deleted
unset($price_rules[$i]);
if (!$price_rules)
return false;
$matching_price_rule = null;
if (is_array($price_rules)) {
foreach ($price_rules as $price_rule) {
if ($price_rule['price_from'] <= $cart_total_price &&
$price_rule['price_to'] > $cart_total_price &&
$price_rule['weight_from'] <= $total_weight &&
$price_rule['weight_to'] > $total_weight
) {
$matching_price_rule = $price_rule;
break;
}
}
}
if (null == $matching_price_rule) {
$matching_price_rule = $price_rules[0]; //accept first matching rule
}
if (!$matching_price_rule['cod_price'])
$matching_price_rule['cod_price'] = 0; //CSV validation allows empty value of COD price
$price = $matching_price_rule['parcel_price'];
if ($id_carrier == _DPDPOLAND_STANDARD_COD_ID_)
$price += $matching_price_rule['cod_price'];
return $price;
}
}

View File

@@ -0,0 +1,100 @@
<?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 DpdPolandCarrier Responsible for DPD services (carriers) creation / deletion
*/
class DpdPolandCarrier extends DpdPolandObjectModel
{
/**
* @var int DPD carrier ID
*/
public $id_dpdpoland_carrier;
/**
* @var int Carrier ID in DPD system
*/
public $id_carrier;
/**
* @var int Carrier reference
*/
public $id_reference;
/**
* @var datetime Date when carrier was created
*/
public $date_add;
/**
* @var datetime Date when carrier was updated
*/
public $date_upd;
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_CARRIER_DB_,
'primary' => 'id_dpdpoland_carrier',
'multilang_shop' => true,
'multishop' => true,
'fields' => array(
'id_dpdpoland_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_reference' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Returns carrier reference according to it's current ID
*
* @param int $id_carrier Carrier ID
* @return false|null|string Carrier reference
*/
public static function getReferenceByIdCarrier($id_carrier)
{
return DB::getInstance()->getValue('
SELECT `id_reference`
FROM `'._DB_PREFIX_._DPDPOLAND_CARRIER_DB_.'`
WHERE `id_carrier` = "'.(int)$id_carrier.'"
');
}
/**
* Returns carrier newest ID according to it's reference
*
* @param int $id_reference Carrier reference
* @return false|null|string Carrier ID
*/
public static function getIdCarrierByReference($id_reference)
{
return DB::getInstance()->getValue('
SELECT MAX(`id_carrier`)
FROM `'._DB_PREFIX_._DPDPOLAND_CARRIER_DB_.'`
WHERE `id_reference` = "'.(int)$id_reference.'"
');
}
}

View File

@@ -0,0 +1,459 @@
<?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 DpdPolandConfiguration Responsible for module settings management
*/
class DpdPolandConfiguration
{
const WSDL_URL_LIVE = 'https://dpdservices.dpd.com.pl/DPDPackageObjServicesService/DPDPackageObjServices?wsdl';
const WSDL_URL_DEMO = 'https://dpdservicesdemo.dpd.com.pl/DPDPackageObjServicesService/DPDPackageObjServices?wsdl';
const LOGIN = 'DPDPOLAND_LOGIN';
const PASSWORD = 'DPDPOLAND_PASSWORD';
const CLIENT_NUMBER = 'DPDPOLAND_CLIENT_NUMBER';
const CLIENT_NAME = 'DPDPOLAND_CLIENT_NAME';
const NAME_SURNAME = 'DPDPOLAND_NAME_SURNAME';
const ADDRESS = 'DPDPOLAND_ADDRESS';
const POSTCODE = 'DPDPOLAND_POSTCODE';
const CITY = 'DPDPOLAND_CITY';
const EMAIL = 'DPDPOLAND_EMAIL';
const PHONE = 'DPDPOLAND_PHONE';
const CARRIER_STANDARD = 'DPDPOLAND_CARRIER_STANDARD';
const CARRIER_STANDARD_COD = 'DPDPOLAND_CARRIER_STANDARD_COD';
const CARRIER_CLASSIC = 'DPDPOLAND_CARRIER_CLASSIC';
const CARRIER_PUDO = 'DPDPOLAND_CARRIER_PUDO';
const PRICE_CALCULATION_TYPE = 'DPDPOLAND_PRICE_CALCULATION';
const WEIGHT_CONVERSATION_RATE = 'DPDPOLAND_WEIGHT_RATE';
const DIMENSION_CONVERSATION_RATE = 'DPDPOLAND_DIMENSION_RATE';
const WS_URL = 'DPDPOLAND_WS_URL';
const CARRIER_STANDARD_ID = 'DPDPOLAND_STANDARD_ID';
const CARRIER_STANDARD_COD_ID = 'DPDPOLAND_STANDARD_COD_ID';
const CARRIER_CLASSIC_ID = 'DPDPOLAND_CLASSIC_ID';
const CARRIER_PUDO_ID = 'DPDPOLAND_PUDO_ID';
const CUSTOMER_COMPANY = 'DPDPOLAND_CUSTOMER_COMPANY';
const CUSTOMER_NAME = 'DPDPOLAND_CUSTOMER_NAME';
const CUSTOMER_PHONE = 'DPDPOLAND_CUSTOMER_PHONE';
const CUSTOMER_FID = 'DPDPOLAND_CUSTOMER_FID';
const FILE_NAME = 'Configuration';
const MEASUREMENT_ROUND_VALUE = 6;
const COD_MODULE_PREFIX = 'DPDPOLAND_COD_';
const PRICE_CALCULATION_CSV = 'csv_calculation';
const PRICE_CALCULATION_PRESTASHOP = 'prestashop_calculation';
const PRINTOUT_FORMAT_A4 = 'A4';
const PRINTOUT_FORMAT_LABEL = 'LBL_PRINTER';
const ADDITIONAL_REF1 = 'DPDPOLAND_ADDITIONAL_REF1';
const ADDITIONAL_REF2 = 'DPDPOLAND_ADDITIONAL_REF2';
const ADDITIONAL_CUSTOMER_DATA_1 = 'DPDPOLAND_ADDITIONAL_DATA_1';
const ADDITIONAL_TYPE_NONE = 'DPDPOLAND_NONE';
const ADDITIONAL_TYPE_DYNAMIC = 'DPDPOLAND_DYNAMIC';
const ADDITIONAL_TYPE_STATIC = 'DPDPOLAND_STATIC';
const REF1_DYNAMIC = 'DPDPOLAND_REF1_DYNAMIC';
const REF1_STATIC = 'DPDPOLAND_REF1_STATIC';
const REF2_DYNAMIC = 'DPDPOLAND_REF2_DYNAMIC';
const REF2_STATIC = 'DPDPOLAND_REF2_STATIC';
const CUSTOMER_DATA_DYNAMIC = 'DPDPOLAND_CUSTOMER_DATA_DYNAMIC';
const CUSTOMER_DATA_STATIC = 'DPDPOLAND_CUSTOMER_DATA_STATIC';
const DYNAMIC_ORDER_ID = 'DPDPOLAND_DYNAMIC_ORDER_ID';
const DYNAMIC_ORDER_REFERENCE = 'DPDPOLAND_DYNAMIC_ORDER_REF';
const DYNAMIC_INVOICE_ID = 'DPDPOLAND_DYNAMIC_INVOICE_ID';
const DYNAMIC_SHIPPING_ADDRESS = 'DPDPOLAND_DYNAMIC_SHIPPING';
const DECLARED_VALUE = 'DPDPOLAND_DECLARED_VALUE';
const CUD = 'DPDPOLAND_CUD';
const ROD = 'DPDPOLAND_ROD';
const DPDE = 'DPDPOLAND_DPDE';
const DPDND = 'DPDPOLAND_DPDND';
const DUTY = 'DPDPOLAND_DUTY';
const LOG_MODE = 'DPDPOLAND_LOG_MODE';
const DISABLE_SEND_SHIPPING_MAIL = 'DPDPOLAND_DISABLE_SEND_SHIPPING_MAIL';
public $login = '';
public $password = '';
public $client_number = '';
public $client_name = '';
public $customer_name = '';
public $customer_company = '';
public $customer_phone = '';
public $customer_fid = '';
public $price_calculation_type = self::PRICE_CALCULATION_PRESTASHOP;
public $carrier_standard = 0;
public $carrier_standard_cod = 0;
public $carrier_classic = 0;
public $carrier_pudo = 0;
public $weight_conversation_rate = 1;
public $dimension_conversation_rate = 1;
public $ws_url = '';
public $ref1 = self::ADDITIONAL_TYPE_DYNAMIC;
public $ref2 = self::ADDITIONAL_TYPE_DYNAMIC;
public $customer_data_1 = self::ADDITIONAL_TYPE_NONE;
public $ref1_dynamic = self::DYNAMIC_ORDER_ID;
public $ref2_dynamic = self::DYNAMIC_INVOICE_ID;
public $customer_data_dynamic = self::DYNAMIC_SHIPPING_ADDRESS;
public $ref1_static = '';
public $ref2_static = '';
public $customer_data_static = '';
public $declared_value = 0;
public $cud = 0;
public $rod = 0;
public $dpde = 0;
public $dpdnd = 0;
public $duty = 0;
public $log_mode = '';
public $disable_send_shipping_mail = '';
/**
* DpdPolandConfiguration class constructor
*/
public function __construct()
{
$this->getSettings();
}
/**
* Saves module settings into database
*
* @return bool Module settings saved successfully
*/
public static function saveConfiguration()
{
$success = true;
$success &= Configuration::updateValue(self::LOGIN, Tools::getValue(self::LOGIN));
$success &= Configuration::updateValue(self::PASSWORD, Tools::getValue(self::PASSWORD));
$success &= Configuration::updateValue(self::CLIENT_NUMBER, Tools::getValue(self::CLIENT_NUMBER));
$client_name = DB::getInstance()->getValue('
SELECT `name`
FROM `' . _DB_PREFIX_ . _DPDPOLAND_PAYER_NUMBERS_DB_ . '`
WHERE `payer_number` = "' . pSQL(Configuration::get(self::CLIENT_NUMBER)) . '"
AND `id_shop` = "' . (int)Context::getContext()->shop->id . '"
');
$success &= Configuration::updateValue(self::CLIENT_NAME, $client_name);
$success &= Configuration::updateValue(self::NAME_SURNAME, Tools::getValue(self::NAME_SURNAME));
$success &= Configuration::updateValue(self::ADDRESS, Tools::getValue(self::ADDRESS));
$success &= Configuration::updateValue(self::POSTCODE, Tools::getValue(self::POSTCODE));
$success &= Configuration::updateValue(self::CITY, Tools::getValue(self::CITY));
$success &= Configuration::updateValue(self::EMAIL, Tools::getValue(self::EMAIL));
$success &= Configuration::updateValue(self::PHONE, Tools::getValue(self::PHONE));
$success &= Configuration::updateValue(self::CUSTOMER_COMPANY, Tools::getValue(self::CUSTOMER_COMPANY));
$success &= Configuration::updateValue(self::CUSTOMER_NAME, Tools::getValue(self::CUSTOMER_NAME));
$success &= Configuration::updateValue(self::CUSTOMER_PHONE, Tools::getValue(self::CUSTOMER_PHONE));
$success &= Configuration::updateValue(self::CUSTOMER_FID, Tools::getValue(self::CUSTOMER_FID));
$success &= Configuration::updateValue(self::PRICE_CALCULATION_TYPE, Tools::getValue(self::PRICE_CALCULATION_TYPE));
$success &= Configuration::updateValue(self::CARRIER_STANDARD, (int)Tools::isSubmit(self::CARRIER_STANDARD));
$success &= Configuration::updateValue(self::CARRIER_STANDARD_COD, (int)Tools::isSubmit(self::CARRIER_STANDARD_COD));
$success &= Configuration::updateValue(self::CARRIER_CLASSIC, (int)Tools::isSubmit(self::CARRIER_CLASSIC));
$success &= Configuration::updateValue(self::CARRIER_PUDO, (int)Tools::isSubmit(self::CARRIER_PUDO));
$success &= Configuration::updateValue(self::WEIGHT_CONVERSATION_RATE, Tools::getValue(self::WEIGHT_CONVERSATION_RATE));
$success &= Configuration::updateValue(self::DIMENSION_CONVERSATION_RATE, Tools::getValue(self::DIMENSION_CONVERSATION_RATE));
$success &= Configuration::updateValue(self::WS_URL, Tools::getValue(self::WS_URL));
$success &= Configuration::updateValue(self::ADDITIONAL_REF1, Tools::getValue(self::ADDITIONAL_REF1));
$success &= Configuration::updateValue(self::ADDITIONAL_REF2, Tools::getValue(self::ADDITIONAL_REF2));
$success &= Configuration::updateValue(self::ADDITIONAL_CUSTOMER_DATA_1, Tools::getValue(self::ADDITIONAL_CUSTOMER_DATA_1));
$success &= Configuration::updateValue(self::REF1_DYNAMIC, Tools::getValue(self::REF1_DYNAMIC));
$success &= Configuration::updateValue(self::REF2_DYNAMIC, Tools::getValue(self::REF2_DYNAMIC));
$success &= Configuration::updateValue(self::CUSTOMER_DATA_DYNAMIC, Tools::getValue(self::CUSTOMER_DATA_DYNAMIC));
$success &= Configuration::updateValue(self::REF1_STATIC, Tools::getValue(self::REF1_STATIC));
$success &= Configuration::updateValue(self::REF2_STATIC, Tools::getValue(self::REF2_STATIC));
$success &= Configuration::updateValue(self::CUSTOMER_DATA_STATIC, Tools::getValue(self::CUSTOMER_DATA_STATIC));
$success &= Configuration::updateValue(self::DECLARED_VALUE, Tools::getValue(self::DECLARED_VALUE));
$success &= Configuration::updateValue(self::CUD, Tools::getValue(self::CUD));
$success &= Configuration::updateValue(self::ROD, Tools::getValue(self::ROD));
$success &= Configuration::updateValue(self::DPDE, Tools::getValue(self::DPDE));
$success &= Configuration::updateValue(self::DPDND, Tools::getValue(self::DPDND));
$success &= Configuration::updateValue(self::DUTY, Tools::getValue(self::DUTY));
$success &= Configuration::updateValue(self::LOG_MODE, Tools::getValue(self::LOG_MODE));
$success &= Configuration::updateValue(self::DISABLE_SEND_SHIPPING_MAIL, Tools::getValue(self::DISABLE_SEND_SHIPPING_MAIL));
foreach (DpdPoland::getPaymentModules() as $payment_module)
$success &= Configuration::updateValue(
self::COD_MODULE_PREFIX . $payment_module['name'], (int)Tools::isSubmit(self::COD_MODULE_PREFIX . $payment_module['name'])
);
return $success;
}
/**
* Collects settings from database
* Assigns settings values for class variables
*/
private function getSettings()
{
$this->login = $this->getSetting(self::LOGIN, $this->login);
$this->password = $this->getSetting(self::PASSWORD, $this->password);
$this->client_number = $this->getSetting(self::CLIENT_NUMBER, $this->client_number);
$this->client_name = $this->getSetting(self::CLIENT_NAME, $this->client_name);
$this->customer_company = $this->getSetting(self::CUSTOMER_COMPANY, $this->customer_company);
$this->customer_name = $this->getSetting(self::CUSTOMER_NAME, $this->customer_name);
$this->customer_phone = $this->getSetting(self::CUSTOMER_PHONE, $this->customer_phone);
$this->customer_fid = $this->getSetting(self::CUSTOMER_FID, $this->customer_fid);
$this->price_calculation_type = $this->getSetting(self::PRICE_CALCULATION_TYPE, $this->price_calculation_type);
$this->carrier_standard = $this->getSetting(self::CARRIER_STANDARD, $this->carrier_standard);
$this->carrier_standard_cod = $this->getSetting(self::CARRIER_STANDARD_COD, $this->carrier_standard_cod);
$this->carrier_classic = $this->getSetting(self::CARRIER_CLASSIC, $this->carrier_classic);
$this->carrier_pudo = $this->getSetting(self::CARRIER_PUDO, $this->carrier_pudo);
$this->weight_conversation_rate = $this->getSetting(self::WEIGHT_CONVERSATION_RATE, $this->weight_conversation_rate);
$this->dimension_conversation_rate = $this->getSetting(self::DIMENSION_CONVERSATION_RATE, $this->dimension_conversation_rate);
$this->ws_url = $this->getSetting(self::WS_URL, $this->ws_url);
$this->ref1 = $this->getSetting(self::ADDITIONAL_REF1, $this->ref1);
$this->ref2 = $this->getSetting(self::ADDITIONAL_REF2, $this->ref2);
$this->customer_data_1 = $this->getSetting(self::ADDITIONAL_CUSTOMER_DATA_1, $this->customer_data_1);
$this->ref1_dynamic = $this->getSetting(self::REF1_DYNAMIC, $this->ref1_dynamic);
$this->ref2_dynamic = $this->getSetting(self::REF2_DYNAMIC, $this->ref2_dynamic);
$this->customer_data_dynamic = $this->getSetting(self::CUSTOMER_DATA_DYNAMIC, $this->customer_data_dynamic);
$this->ref1_static = $this->getSetting(self::REF1_STATIC, $this->ref1_static);
$this->ref2_static = $this->getSetting(self::REF2_STATIC, $this->ref2_static);
$this->customer_data_static = $this->getSetting(self::CUSTOMER_DATA_STATIC, $this->customer_data_static);
$this->declared_value = $this->getSetting(self::DECLARED_VALUE, $this->declared_value);
$this->cud = $this->getSetting(self::CUD, $this->cud);
$this->rod = $this->getSetting(self::ROD, $this->rod);
$this->dpde = $this->getSetting(self::DPDE, $this->dpde);
$this->dpdnd = $this->getSetting(self::DPDND, $this->dpdnd);
$this->duty = $this->getSetting(self::DUTY, $this->duty);
$this->log_mode = $this->getSetting(self::LOG_MODE, $this->log_mode);
$this->disable_send_shipping_mail = $this->getSetting(self::DISABLE_SEND_SHIPPING_MAIL, $this->disable_send_shipping_mail);
}
/**
* Returns a setting from database
*
* @param string $name Setting name
* @param string $default_value Default setting value
* @return string Setting value
*/
private function getSetting($name, $default_value)
{
return Configuration::get($name) !== false ? Configuration::get($name) : $default_value;
}
/**
* Deletes settings from database
*
* @return bool Settings deleted successfully
*/
public static function deleteConfiguration()
{
$success = true;
$success &= self::deleteByNames(array(
self::LOGIN, self::PASSWORD, self::CLIENT_NUMBER, self::CLIENT_NAME, self::NAME_SURNAME, self::ADDRESS,
self::POSTCODE, self::CITY, self::EMAIL, self::PHONE, self::CUSTOMER_COMPANY, self::CUSTOMER_NAME, self::CUSTOMER_PHONE,
self::CUSTOMER_FID, self::PRICE_CALCULATION_TYPE, self::CARRIER_STANDARD, self::CARRIER_STANDARD_COD,
self::CARRIER_CLASSIC, self::WEIGHT_CONVERSATION_RATE, self::DIMENSION_CONVERSATION_RATE, self::WS_URL, self::CARRIER_STANDARD_ID,
self::CARRIER_STANDARD_COD_ID, self::CARRIER_CLASSIC_ID, self::ADDITIONAL_REF1, self::ADDITIONAL_REF2, self::ADDITIONAL_CUSTOMER_DATA_1,
self::REF1_DYNAMIC, self::REF2_DYNAMIC, self::CUSTOMER_DATA_DYNAMIC, self::REF1_STATIC, self::REF2_STATIC, self::CUSTOMER_DATA_STATIC,
self::CARRIER_PUDO, self::CARRIER_PUDO_ID, self::DECLARED_VALUE, self::CUD, self::ROD, self::DPDE, self::DPDND, self::DUTY, self::LOG_MODE, self::DISABLE_SEND_SHIPPING_MAIL
));
foreach (DpdPoland::getPaymentModules() as $payment_module)
$success &= Configuration::deleteByName(self::COD_MODULE_PREFIX . $payment_module['name']);
return $success;
}
/**
* Deletes settings from database by their names
*
* @param array $names Settings names list
* @return bool Settings deleted successfully
*/
private static function deleteByNames($names)
{
$success = true;
foreach ($names as $name)
$success &= Configuration::deleteByName($name);
return $success;
}
/**
* Deletes a single setting from database
*
* @param string $name Setting name
* @return bool Setting deleted successfully
*/
public static function deleteByName($name)
{
return Configuration::deleteByName($name);
}
/**
* Checks if required settings are filled
*
* @return bool Required settings are filled
*/
public static function checkRequiredConfiguration()
{
$configuration_obj = new DpdPolandConfiguration();
if (!$configuration_obj->login ||
!$configuration_obj->password ||
!$configuration_obj->client_number ||
!$configuration_obj->client_name ||
!$configuration_obj->weight_conversation_rate ||
!$configuration_obj->dimension_conversation_rate ||
!$configuration_obj->ws_url ||
!$configuration_obj->customer_fid)
return false;
if (DpdPolandSenderAddress::getAddressesCount() <= 0) {
return false;
}
return true;
}
/**
* Returns zones which are assigned to a carrier
*
* @param int $id_carrier Carrier ID
* @return array|false|mysqli_result|null|PDOStatement|resource Carrier zones
*/
public static function getCarrierZones($id_carrier)
{
return DB::getInstance()->executeS('
SELECT `id_zone`
FROM `' . _DB_PREFIX_ . 'carrier_zone`
WHERE `id_carrier` = "' . (int)$id_carrier . '"
');
}
/**
* Assigns PrestaShop zones for DPD carriers
*
* @return bool Zones assigned successfully
*/
public static function saveZonesForCarriers()
{
$configuration = new DpdPolandConfiguration();
if ($configuration->carrier_classic) {
$id_carrier_classic = (int)Configuration::get(DpdPolandConfiguration::CARRIER_CLASSIC_ID);
$classic_carrier_obj = DpdPolandService::getCarrierByReference((int)$id_carrier_classic);
if (Validate::isLoadedObject($classic_carrier_obj))
$id_carrier_classic = $classic_carrier_obj->id;
if (!self::removeZonesForCarrier($id_carrier_classic) || !self::saveZoneForCarrier('classic', $id_carrier_classic))
return false;
}
if ($configuration->carrier_pudo) {
$id_carrier_pudo = (int)Configuration::get(DpdPolandConfiguration::CARRIER_PUDO_ID);
$pudo_carrier_obj = DpdPolandService::getCarrierByReference((int)$id_carrier_pudo);
if (Validate::isLoadedObject($pudo_carrier_obj))
$id_carrier_pudo = $pudo_carrier_obj->id;
if (!self::removeZonesForCarrier($id_carrier_pudo) || !self::saveZoneForCarrier('pudo', $id_carrier_pudo))
return false;
}
if ($configuration->carrier_standard) {
$id_carrier_standard = (int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_ID);
$carrier_standard_obj = DpdPolandService::getCarrierByReference((int)$id_carrier_standard);
if (Validate::isLoadedObject($carrier_standard_obj))
$id_carrier_standard = $carrier_standard_obj->id;
if (!self::removeZonesForCarrier($id_carrier_standard) || !self::saveZoneForCarrier('standard', $id_carrier_standard))
return false;
}
if ($configuration->carrier_standard_cod) {
$id_carrier_standard_cod = (int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID);
$carrier_standard_cod_obj = DpdPolandService::getCarrierByReference((int)$id_carrier_standard_cod);
if (Validate::isLoadedObject($carrier_standard_cod_obj))
$id_carrier_standard_cod = $carrier_standard_cod_obj->id;
if (!self::removeZonesForCarrier($id_carrier_standard_cod) || !self::saveZoneForCarrier('standard_cod', $id_carrier_standard_cod))
return false;
}
return true;
}
/**
* Removes zones for carrier
*
* @param int $id_carrier Carrier ID
* @return bool Zones removed from carrier
*/
private static function removeZonesForCarrier($id_carrier)
{
return DB::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'carrier_zone`
WHERE `id_carrier` = "' . (int)$id_carrier . '"
');
}
/**
* Saves zone for carrier into database
*
* @param string $type Service type
* @param int $id_carrier Carrier ID
* @return bool Carrier zones saved successfully
*/
private static function saveZoneForCarrier($type, $id_carrier)
{
foreach (Zone::getZones() as $zone) {
if (Tools::getValue($type . '_' . (int)$zone['id_zone'])) {
if (!DB::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'carrier_zone`
(`id_carrier`, `id_zone`)
VALUES
("' . (int)$id_carrier . '", "' . (int)$zone['id_zone'] . '")
')) {
return false;
}
}
}
return true;
}
}

View File

@@ -0,0 +1,192 @@
<?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 DpdPolandCountry Responsible for available countries management
*/
class DpdPolandCountry extends DpdPolandObjectModel
{
/**
* @var int Available country ID
*/
public $id_dpdpoland_country;
/**
* @var int PrestaShop country ID
*/
public $id_country;
/**
* @var int Shop ID
*/
public $id_shop;
/**
* @var datetime Date when available country was added
*/
public $date_add;
/**
* @var datetime Last date when available country was updated
*/
public $date_upd;
/**
* @var Country status
*/
public $enabled;
/**
* @var array ISO codes list of countries which are enabled by default
*/
public static $default_enabled_countries = array(
'AT', 'BE', 'BA', 'BG', 'HR', 'CZ', 'DK', 'EE', 'FI', 'FR', 'GR', 'ES', 'IE', 'LT', 'LU',
'LV', 'DE', 'NO', 'PT', 'RO', 'RS', 'SK', 'SI', 'SZ', 'SE', 'HU', 'GB', 'IT', 'NL'
);
/**
* DpdPolandCountry class constructor
* @param null|int $id_dpdpoland_country Available country ID
*/
public function __construct($id_dpdpoland_country = null)
{
parent::__construct($id_dpdpoland_country);
$this->id_shop = (int)Context::getContext()->shop->id;
}
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_COUNTRY_DB_,
'primary' => 'id_dpdpoland_country',
'multilang_shop' => true,
'multishop' => true,
'fields' => array(
'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'enabled' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Collects list data and prepares it to be displayed
*
* @param string $order_by List order by criteria
* @param string $order_way List sorting way (ascending, descending)
* @param string $filter Criteria by which list is filtered
* @param int $start From which element list will be displayed
* @param int $pagination How many elements will be displayed in list
* @return array|false|mysqli_result|null|PDOStatement|resource Collected list data
*/
public function getList($order_by, $order_way, $filter, $start, $pagination)
{
$order_way = Validate::isOrderWay($order_way) ? $order_way : 'ASC';
$id_shop = (int)Context::getContext()->shop->id;
$id_lang = (int)Context::getContext()->language->id;
if (version_compare(_PS_VERSION_, '1.5', '<'))
$countries = DB::getInstance()->executeS('
SELECT
c.`id_country` AS `id_country`,
cl.`name` AS `name`,
c.`iso_code` AS `iso_code`,
IF(dpdc.`enabled` IS NULL, 1, dpdc.`enabled`) AS `enabled`
FROM `'._DB_PREFIX_.'country` c
LEFT JOIN `'._DB_PREFIX_._DPDPOLAND_COUNTRY_DB_.'` dpdc ON (dpdc.`id_country` = c.`id_country` AND dpdc.`id_shop` = "'.(int)$id_shop.'")
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = c.`id_country` AND cl.`id_lang` = "'.(int)$id_lang.'")'
.$filter
.($order_by && $order_way ? ' ORDER BY `'.bqSQL($order_by).'` '.pSQL($order_way) : '')
.($start !== null && $pagination !== null ? ' LIMIT '.(int)$start.', '.(int)$pagination : '')
);
else
$countries = DB::getInstance()->executeS('
SELECT
c.`id_country` AS `id_country`,
cl.`name` AS `name`,
c.`iso_code` AS `iso_code`,
IF(dpdc.`enabled` IS NULL, 1, dpdc.`enabled`) AS `enabled`
FROM `'._DB_PREFIX_.'country` c
LEFT JOIN `'._DB_PREFIX_._DPDPOLAND_COUNTRY_DB_.'` dpdc ON (dpdc.`id_country` = c.`id_country` AND dpdc.`id_shop` = "'.(int)$id_shop.'")
LEFT JOIN `'._DB_PREFIX_.'country_shop` cs ON (cs.`id_country` = c.`id_country`)
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = c.`id_country` AND cl.`id_lang` = "'.(int)$id_lang.'")
WHERE cs.`id_shop` = "'.(int)$id_shop.'" '
.$filter
.($order_by && $order_way ? ' ORDER BY `'.bqSQL($order_by).'` '.pSQL($order_way) : '')
.($start !== null && $pagination !== null ? ' LIMIT '.(int)$start.', '.(int)$pagination : '')
);
if (!$countries)
$countries = array();
return $countries;
}
/**
* Returns DPD country ID according to PrestaShop country
*
* @param int $id_country PrestaShop country ID
* @return false|null|string DPD country ID
*/
public static function getIdByCountry($id_country)
{
$id_shop = (int)Context::getContext()->shop->id;
return DB::getInstance()->getValue('
SELECT `id_dpdpoland_country`
FROM `'._DB_PREFIX_._DPDPOLAND_COUNTRY_DB_.'`
WHERE `id_shop` = "'.(int)$id_shop.'"
AND `id_country` = "'.(int)$id_country.'"
');
}
/**
* Collects data about disabled countries
*
* @return array Disabled countries IDs
*/
public static function getDisabledCountriesIDs()
{
$id_shop = (int)Context::getContext()->shop->id;
$countries = DB::getInstance()->executeS('
SELECT `id_country`
FROM `'._DB_PREFIX_._DPDPOLAND_COUNTRY_DB_.'`
WHERE `id_shop` = "'.(int)$id_shop.'"
AND `enabled` = "0"
');
if (!$countries)
$countries = array();
$countries_array = array();
foreach ($countries as $country)
$countries_array[] = $country['id_country'];
return $countries_array;
}
}

View File

@@ -0,0 +1,34 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
require_once(_DPDPOLAND_CLASSES_DIR_.'Configuration.php');
require_once(_DPDPOLAND_MODULE_DIR_.'dpdpoland.php');
class DpdPolandLog
{
const LOG_DEBUG = 'LOG_DEBUG';
const LOG_ERROR = 'LOG_ERROR';
public static function addLog($message)
{
if(!in_array(Configuration::get(DpdPolandConfiguration::LOG_MODE), array(self::LOG_DEBUG)))
return;
$logger = new FileLogger(0);
$logger->setFilename(_DPDPOLAND_MODULE_DIR_."/log/logs.log");
$logger->logDebug($message);
}
public static function addError($message)
{
if(!in_array(Configuration::get(DpdPolandConfiguration::LOG_MODE), array(self::LOG_DEBUG, self::LOG_ERROR)))
return;
$logger = new FileLogger(0);
$logger->setFilename(_DPDPOLAND_MODULE_DIR_."/log/logs.log");
$logger->logError($message);
}
}

View File

@@ -0,0 +1,244 @@
<?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 DpdPolandManifest Responsible for manifests management
*/
class DpdPolandManifest extends DpdPolandObjectModel
{
/**
* @var int Manifest ID
*/
public $id_manifest;
/**
* @var string Manifest ID retrieved via webservices
*/
public $id_manifest_ws;
/**
* @var string|int Package ID
*/
public $id_package_ws;
/**
* @var datetime Date when manifest was created
*/
public $date_add;
/**
* @var datetime Date when record about manifest was updated
*/
public $date_upd;
/**
* @var object Manifest WebServices instance
*/
private $webservice;
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_MANIFEST_DB_,
'primary' => 'id_manifest',
'multilang' => false,
'multishop' => false,
'fields' => array(
'id_manifest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_manifest_ws' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_package_ws' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Collects list of packages IDs
*
* @return array Packages IDs
*/
public function getPackages()
{
$packages_ids = array();
$packages = Db::getInstance()->executeS('
SELECT `id_package_ws`
FROM `'._DB_PREFIX_._DPDPOLAND_MANIFEST_DB_.'`
WHERE `id_manifest_ws` = "'.(int)$this->id_manifest_ws.'"
');
foreach ($packages as $package)
$packages_ids[] = $package['id_package_ws'];
return $packages_ids;
}
/**
* Collects list data and prepares it to be displayed
*
* @param string $order_by List order by criteria
* @param string $order_way List sorting way (ascending, descending)
* @param string $filter Criteria by which list is filtered
* @param int $start From which element list will be displayed
* @param int $pagination How many elements will be displayed in list
* @return array|false|mysqli_result|null|PDOStatement|resource Collected list data
*/
public function getList($order_by, $order_way, $filter, $start, $pagination)
{
$order_way = Validate::isOrderWay($order_way) ? $order_way : 'ASC';
return Db::getInstance()->executeS('
SELECT m.`id_manifest_ws` AS `id_manifest_ws`,
COUNT(p.`id_parcel`) AS `count_parcels`,
COUNT(DISTINCT m.`id_package_ws`) AS `count_orders`,
m.`date_add` AS `date_add`
FROM `'._DB_PREFIX_._DPDPOLAND_MANIFEST_DB_.'` m
LEFT JOIN `'._DB_PREFIX_._DPDPOLAND_PARCEL_DB_.'` p ON (p.`id_package_ws` = m.`id_package_ws`)
GROUP BY `id_manifest_ws`
'.$filter.'
ORDER BY `'.bqSQL($order_by).'` '.pSQL($order_way).
($start !== null && $pagination !== null ? ' LIMIT '.(int)$start.', '.(int)$pagination : '')
);
}
/**
* Checks if all fields of sender addresses are valid
*
* @param array $package_ids Package IDs
* @return bool Sender addresses are valid
*/
public static function validateSenderAddresses($package_ids)
{
if (!is_array($package_ids))
return false;
$first_package = new DpdPolandPackage((int)$package_ids[0]);
$first_package_address = new Address((int)$first_package->id_address_sender);
$address_keys = array('country', 'company', 'lastname', 'firstname', 'address1', 'address2', 'postcode', 'city', 'phone');
$address = array();
foreach ($address_keys as $key)
if (isset($first_package_address->$key))
$address[$key] = $first_package_address->$key;
else
return false;
foreach ($package_ids as $package_id)
{
$package = new DpdPolandPackage((int)$package_id);
$sender_address = new Address((int)$package->id_address_sender);
$current_package_sender_address = array();
foreach ($address_keys as $key)
if (isset($sender_address->$key))
$current_package_sender_address[$key] = $sender_address->$key;
else
return false;
$differences = array_diff_assoc($address, $current_package_sender_address);
if (!empty($differences))
return false;
}
return true;
}
/**
* Returns manifest WebService ID according to package ID
*
* @param int|string $id_package_ws Package ID
* @return false|null|string Manifest ID
*/
public static function getManifestIdWsByPackageIdWs($id_package_ws)
{
return Db::getInstance()->getValue('
SELECT `id_manifest_ws`
FROM `'._DB_PREFIX_._DPDPOLAND_MANIFEST_DB_.'`
WHERE `id_package_ws` = "'.(int)$id_package_ws.'"
');
}
/**
* Returns package ID according to Manifest ID
*
* @param int|string $id_manifest_ws Manifest ID
* @return false|null|string Package ID
*/
public function getPackageIdWsByManifestIdWs($id_manifest_ws)
{
return Db::getInstance()->getValue('
SELECT `id_package_ws`
FROM `'._DB_PREFIX_._DPDPOLAND_MANIFEST_DB_.'`
WHERE `id_manifest_ws` = "'.(int)$id_manifest_ws.'"
');
}
/**
* Creates and returns package object instance
*
* @return DpdPolandPackage instance
*/
public function getPackageInstance()
{
if (!$this->id_package_ws)
$this->id_package_ws = $this->getPackageIdWsByManifestIdWs($this->id_manifest_ws);
return new DpdPolandPackage($this->id_package_ws);
}
/**
* Generates manifest
*
* @param string $output_doc_format Document format
* @param string $output_doc_page_format Document page format
* @param string $policy Policy type
* @return bool Manifest generated successfully
*/
public function generate($output_doc_format = 'PDF', $output_doc_page_format = 'LBL_PRINTER', $policy = 'STOP_ON_FIRST_ERROR')
{
if (!$this->webservice)
$this->webservice = new DpdPolandManifestWS;
return $this->webservice->generate($this, $output_doc_format, $output_doc_page_format, $policy);
}
/**
* Generates multiple manifests
*
* @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')
{
if (!$this->webservice)
$this->webservice = new DpdPolandManifestWS;
return $this->webservice->generateMultiple($package_ids, $output_doc_format, $output_doc_page_format, $policy);
}
}

View File

@@ -0,0 +1,148 @@
<?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 DpdPolandObjectModel Responsible for PrestaShop objects management
*/
class DpdPolandObjectModel extends ObjectModel
{
/**
* @var array Class variables and their validation types
*/
public static $definition = array();
protected $tables = array();
protected $table;
protected $fieldsValidate = array();
protected $fieldsRequired = array();
protected $fieldsSize = array();
protected $identifier;
const TYPE_INT = 1;
const TYPE_BOOL = 2;
const TYPE_STRING = 3;
const TYPE_FLOAT = 4;
const TYPE_DATE = 5;
const TYPE_HTML = 6;
const TYPE_NOTHING = 7;
/**
* DpdPolandObjectModel class constructor
* @param null|int $id Object ID
*/
public function __construct($id = null)
{
if (version_compare(_PS_VERSION_, '1.5', '<'))
{
$caller_class_name = $this->getCallerClassName(); // child class name
if (isset($caller_class_name::$definition))
{
$this->tables = array($caller_class_name::$definition['table']);
$this->table = $caller_class_name::$definition['table'];
$this->identifier = $caller_class_name::$definition['primary'];
foreach ($caller_class_name::$definition['fields'] as $field_name => $field)
{
if (!in_array($field_name, array('id_shop', 'date_upd', 'date_add')))
{
$validate_rule = (isset($field['validate'])) ? $field['validate'] : 'isAnything';
$this->fieldsValidate[$field_name] = $validate_rule;
if (isset($field['required']))
array_push($this->fieldsRequired, $field_name);
if (isset($field['size']))
$this->fieldsSize[$field_name] = $field['size'];
}
}
}
}
return parent::__construct($id);
}
/**
* Returns class name from which functions are called
*
* @return string Caller class name
*/
private function getCallerClassName()
{
return get_class($this);
}
/**
* Collects object fields data
*
* @return array Object fields data
*/
public function getFields()
{
if (version_compare(_PS_VERSION_, '1.5', '<'))
{
parent::validateFields();
$caller_class_name = $this->getCallerClassName(); // child class name
$fields = array();
if (isset($caller_class_name::$definition))
{
foreach ($caller_class_name::$definition['fields'] as $field_name => $field)
{
if ($field_name == $this->identifier && isset($this->$field_name))
$fields[$field_name] = $this->$field_name;
else
{
switch ($field['type'])
{
case 1:
$fields[$field_name] = (int)$this->$field_name;
break;
case 2:
$fields[$field_name] = (bool)$this->$field_name;
break;
case 3:
case 5:
case 6:
$fields[$field_name] = $this->$field_name;
break;
case 4:
$fields[$field_name] = (float)$this->$field_name;
break;
case 7:
$fields[$field_name] = $this->$field_name;
break;
}
}
}
}
return $fields;
}
else
return parent::getFields();
}
}

View File

@@ -0,0 +1,421 @@
<?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 DpdPolandPackage Responsible for DPD packages management
*/
class DpdPolandPackage extends DpdPolandObjectModel
{
public $id_package;
public $id_package_ws;
public $id_order;
public $sessionId;
public $sessionType;
public $payerNumber;
public $id_address_sender;
public $id_address_delivery;
public $cod_amount;
public $declaredValue_amount;
public $ref1;
public $ref2;
public $additional_info;
public $labels_printed = 0;
public $id_sender_address;
public $cud;
public $rod;
public $dpde;
public $dpdnd;
public $duty;
public $duty_amount;
public $duty_currency;
public $date_add;
public $date_upd;
/**
* @var object Package WebServices instance
*/
private $webservice;
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_PACKAGE_DB_,
'primary' => 'id_package',
'multilang' => false,
'multishop' => false,
'fields' => array(
'id_package' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_package_ws' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'sessionId' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'sessionType' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'payerNumber' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'id_address_sender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_address_delivery' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'cod_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'declaredValue_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'ref1' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'ref2' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'additional_info' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'labels_printed' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'id_sender_address' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'cud' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'rod' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'dpde' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'dpdnd' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'duty' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'duty_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
'duty_currency' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* DpdPolandPackage constructor
* Object identified by id_package_ws rather than id_package
*
* @param null|int $id_package_ws Used only as a primary field by ObjectModel
*/
public function __construct($id_package_ws = null)
{
$id_package = $this->getPackageIdByPackageIdWs($id_package_ws);
parent::__construct($id_package);
}
/**
* Returns package ID according to package ID received from WebServices
*
* @param int|string $id_package_ws Package WebServices ID
* @return false|null|string Package ID
*/
private function getPackageIdByPackageIdWs($id_package_ws)
{
return Db::getInstance()->getValue('
SELECT `id_package`
FROM `' . _DB_PREFIX_ . _DPDPOLAND_PACKAGE_DB_ . '`
WHERE `id_package_ws` = "' . (int)$id_package_ws . '"
');
}
/**
* Removes packages duplicates for order to have only one package
*
* @return bool Packages duplicates removed successfully
*/
public function removeOrderDuplicates()
{
$id_last_package_by_order = Db::getInstance()->getValue('
SELECT `id_package`
FROM `' . _DB_PREFIX_ . _DPDPOLAND_PACKAGE_DB_ . '`
WHERE `id_order` = "' . (int)$this->id_order . '"
ORDER BY `id_package` DESC
');
return Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . _DPDPOLAND_PACKAGE_DB_ . '`
WHERE `id_order` = "' . (int)$this->id_order . '"
AND `id_package` != "' . (int)$id_last_package_by_order . '"
');
}
/**
* Creates package instance according to order ID
*
* @param int $id_order Order ID
* @return DpdPolandPackage object instance
*/
public static function getInstanceByIdOrder($id_order)
{
$id_package_ws = Db::getInstance()->getValue('
SELECT `id_package_ws`
FROM `' . _DB_PREFIX_ . _DPDPOLAND_PACKAGE_DB_ . '`
WHERE `id_order` = "' . (int)$id_order . '"
ORDER BY `id_package` DESC
');
return new DpdPolandPackage($id_package_ws);
}
/**
* Checks if current package has printed labels
*
* @return int Printed labels count
*/
public function isManifestPrinted()
{
return (int)Db::getInstance()->getValue('
SELECT COUNT(`id_manifest_ws`)
FROM `' . _DB_PREFIX_ . _DPDPOLAND_MANIFEST_DB_ . '`
WHERE `id_package_ws`=' . (int)$this->id_package_ws
);
}
/**
* Returns formatted session type
*
* @return string Formatted session type
*/
public function getSessionType()
{
return $this->sessionType == 'international' ? 'INTERNATIONAL' : 'DOMESTIC';
}
/**
* Collects list data and prepares it to be displayed
*
* @param string $order_by List order by criteria
* @param string $order_way List sorting way (ascending, descending)
* @param string $filter Criteria by which list is filtered
* @param int $start From which element list will be displayed
* @param int $pagination How many elements will be displayed in list
* @return array|false|mysqli_result|null|PDOStatement|resource Collected list data
*/
public function getList($order_by, $order_way, $filter, $start, $pagination)
{
$order_way = Validate::isOrderWay($order_way) ? $order_way : 'ASC';
$id_shop = (int)Context::getContext()->shop->id;
$id_lang = (int)Context::getContext()->language->id;
$list = DB::getInstance()->executeS('
SELECT
p.`id_package_ws` AS `id_package_ws`,
p.`date_add` AS `date_add`,
p.`id_order` AS `id_order`,
(SELECT COUNT(par.`id_parcel`)
FROM `' . _DB_PREFIX_ . _DPDPOLAND_PARCEL_DB_ . '` par
WHERE par.`id_package_ws` = p.`id_package_ws`) AS `count_parcel`,
(SELECT parc.`waybill`
FROM `' . _DB_PREFIX_ . _DPDPOLAND_PARCEL_DB_ . '` parc
WHERE parc.`id_package_ws` = p.`id_package_ws`
ORDER BY parc.`id_parcel`
LIMIT 1) AS `package_number`,
CONCAT(a.`firstname`, " ", a.`lastname`) AS `receiver`,
cl.`name` AS `country`,
a.`postcode` AS `postcode`,
a.`city` AS `city`,
CONCAT(a.`address1`, " ", a.`address2`) AS `address`
FROM `' . _DB_PREFIX_ . _DPDPOLAND_PACKAGE_DB_ . '` p
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON (o.`id_order` = p.`id_order`)
LEFT JOIN `' . _DB_PREFIX_ . 'address` a ON (a.`id_address` = p.`id_address_delivery`)
LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = "' . (int)$id_lang . '")
WHERE ' . (version_compare(_PS_VERSION_, '1.5', '<') ? '' : 'o.`id_shop` = "' . (int)$id_shop . '" AND ') . '
NOT EXISTS(
SELECT m.`id_manifest_ws`
FROM `' . _DB_PREFIX_ . _DPDPOLAND_MANIFEST_DB_ . '` m
WHERE m.`id_package_ws` = p.`id_package_ws`
) ' .
$filter .
($order_by && $order_way ? ' ORDER BY `' . bqSQL($order_by) . '` ' . pSQL($order_way) : '') .
($start !== null && $pagination !== null ? ' LIMIT ' . (int)$start . ', ' . (int)$pagination : '')
);
if (!$list)
$list = array();
return $list;
}
/**
* Splits packages into groups
* according to session type
*
* @param array $ids Packages WebServices IDs
* @return array Formatted packages groups
*/
public static function separatePackagesBySession($ids)
{
$international_packages = array();
$domestic_packages = array();
foreach ($ids as $id_package_ws) {
$package = new DpdPolandPackage((int)$id_package_ws);
$session_type = $package->getSessionType();
if ($session_type == 'INTERNATIONAL')
$international_packages[] = (int)$id_package_ws;
elseif ($session_type == 'DOMESTIC')
$domestic_packages[] = (int)$id_package_ws;
}
return array('INTERNATIONAL' => $international_packages, 'DOMESTIC' => $domestic_packages);
}
/**
* Assigns parcel for package
*
* @param array $parcel Parcel data
* @param string $additional_info Order additional info
*/
public function addParcel($parcel, $additional_info)
{
if (!$this->webservice)
$this->webservice = new DpdPolandPackageWS;
$this->webservice->addParcel($parcel, $additional_info);
}
/**
* Creates package
*
* @return bool Package created successfully
*/
public function create()
{
if (!$this->webservice)
$this->webservice = new DpdPolandPackageWS;
return $this->webservice->create($this);
}
/**
* Generates multiple labels for selected packages
*
* @param array $waybills Packages waybills
* @param string $outputDocPageFormat Document page format
* @param string $session_type Session type (DOMESTIC, INTERNATIONAL)
* @param string $outputLabelType
* @return bool Multiple labels generated successfully
*/
public function generateMultipleLabels($waybills, $outputDocPageFormat = 'A4', $session_type = 'INTERNATIONAL', $outputLabelType = 'BIC3')
{
if (!$this->webservice)
$this->webservice = new DpdPolandPackageWS;
return $this->webservice->generateMultipleLabels($waybills, $outputDocPageFormat, $session_type, $outputLabelType);
}
/**
* Generates package labels
*
* @param string $outputDocFormat Document format
* @param string $outputDocPageFormat Document page format
* @param string $policy Policy type
* @param string $outputLabelType
* @return bool Labels generated successfully
*/
public function generateLabels($outputDocFormat = 'PDF', $outputDocPageFormat = 'A4', $policy = 'STOP_ON_FIRST_ERROR', $outputLabelType = 'BIC3')
{
if (!$this->webservice)
$this->webservice = new DpdPolandPackageWS;
return $this->webservice->generateLabels($this, $outputDocFormat, $outputDocPageFormat, $policy, $outputLabelType);
}
/**
* Generates labels for selected packages
*
* @param array $package_ids Packages IDs
* @param string $outputDocFormat Document format
* @param string $outputDocPageFormat Document page format
* @param string $policy Policy type
* @param string $outputLabelType
* @return bool Labels generated successfully
*/
public function generateLabelsForMultiplePackages($package_ids, $outputDocFormat = 'PDF', $outputDocPageFormat = 'LBL_PRINTER', $policy = 'STOP_ON_FIRST_ERROR', $outputLabelType = 'BIC3')
{
if (!$this->webservice)
$this->webservice = new DpdPolandPackageWS;
return $this->webservice->generateLabelsForMultiplePackages($package_ids, $outputDocFormat, $outputDocPageFormat, $policy, $outputLabelType);
}
/**
* Collects sender address according to package
*
* @param int|string $package_number Package number
* @return array Sender address data
*/
public function getSenderAddress()
{
if (!$this->webservice)
$this->webservice = new DpdPolandPackageWS;
return $this->webservice->getSenderAddress($this->id_sender_address);
}
/**
* Collects data about order which has no saved shipments
*
* @return array Orders which has no saved shipments
*/
public static function getLabelExceptions()
{
$orders = Db::getInstance()->executeS('
SELECT `id_order`
FROM `' . _DB_PREFIX_ . 'orders`
');
if (empty($orders)) {
return array();
}
$orders_ids = array();
foreach ($orders as $order) {
$orders_ids[] = (int)$order['id_order'];
}
$packages = Db::getInstance()->executeS('
SELECT `id_order`
FROM `' . _DB_PREFIX_ . _DPDPOLAND_PACKAGE_DB_ . '`
');
if (empty($packages)) {
return $orders_ids;
}
$package_orders_ids = array();
foreach ($packages as $package) {
$package_orders_ids[] = $package['id_order'];
}
return array_diff($orders_ids, $package_orders_ids);
}
}

View File

@@ -0,0 +1,230 @@
<?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 DpdPolandParcel Responsible for DPD parcels management
*/
class DpdPolandParcel extends DpdPolandObjectModel
{
/**
* @var int Parcel ID
*/
public $id_parcel;
/**
* @var int|string Parcel WebService ID
*/
public $id_package_ws;
/**
* @var string Parcel waybill
*/
public $waybill;
/**
* @var string Parcel content
*/
public $content;
/**
* @var float Parcel weight
*/
public $weight;
/**
* @var float Parcel height
*/
public $height;
/**
* @var float Parcel length
*/
public $length;
/**
* @var float Parcel width
*/
public $width;
/**
* @var int|string Parcel number
*/
public $number;
/**
* @var datetime Date when parcel was created
*/
public $date_add;
/**
* @var datetime Date when parcel data was updated
*/
public $date_upd;
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_PARCEL_DB_,
'primary' => 'id_parcel',
'multilang' => false,
'multishop' => false,
'fields' => array(
'id_parcel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_package_ws' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'waybill' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'content' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'weight' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'height' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'length' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'width' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'number' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Collects orders waybills data
*
* @param array $orders_ids Orders IDs
* @return array|false|mysqli_result|null|PDOStatement|resource Orders Waybills
*/
public static function getOrdersWaybills(array $orders_ids)
{
if (empty($orders_ids)) {
return array();
}
$waybills = Db::getInstance()->executeS('
SELECT parc.`waybill`, pack.`sessionType`
FROM `'._DB_PREFIX_._DPDPOLAND_PACKAGE_DB_.'` pack
LEFT JOIN `'._DB_PREFIX_._DPDPOLAND_PARCEL_DB_.'` parc
ON (parc.`id_package_ws` = pack.`id_package_ws`)
WHERE pack.`id_order` IN ('.implode(',', $orders_ids).')
');
return $waybills;
}
/**
* Collects parcels data for order
*
* @param int $id_order Order ID
* @param null|int|string $id_package_ws Package WebServices ID
* @return array|false|mysqli_result|null|PDOStatement|resource Order parcels
*/
public static function getParcels($id_order, $id_package_ws = null)
{
if ($id_package_ws)
{
$parcels = Db::getInstance()->executeS('
SELECT `id_parcel`, `content`, `weight`, `height`, `length`, `width`, `number`
FROM `'.bqSQL(_DB_PREFIX_.self::$definition['table']).'`
WHERE `id_package_ws`='.(int)$id_package_ws
);
return $parcels;
}
$products = DpdPolandParcelProduct::getShippedProducts($id_order);
$parcels = array();
$content = '';
$weight = $height = $length = $width = 0;
$products_count = count($products);
if ($products_count == 1)
{
$product = reset($products);
$height = DpdPoland::convertDimension($product['height']);
$length = DpdPoland::convertDimension($product['length']);
$width = DpdPoland::convertDimension($product['width']);
}
foreach ($products as $product)
{
$content .= $product['id_product'].'_'.$product['id_product_attribute'];
if (--$products_count)
$content .= ', ';
$weight += DpdPoland::convertWeight($product['weight']);
}
$parcels[] = array(
'number' => 1,
'content' => $content,
'weight' => $weight,
'height' => sprintf('%.6f', $height),
'length' => sprintf('%.6f', $length),
'width' => sprintf('%.6f', $width)
);
return $parcels;
}
/**
* Collects list data and prepares it to be displayed
*
* @param string $order_by List order by criteria
* @param string $order_way List sorting way (ascending, descending)
* @param string $filter Criteria by which list is filtered
* @param int $start From which element list will be displayed
* @param int $pagination How many elements will be displayed in list
* @return array|false|mysqli_result|null|PDOStatement|resource Collected list data
*/
public function getList($order_by, $order_way, $filter, $start, $pagination)
{
$order_way = Validate::isOrderWay($order_way) ? $order_way : 'ASC';
$id_shop = (int)Context::getContext()->shop->id;
$id_lang = (int)Context::getContext()->language->id;
$list = DB::getInstance()->executeS('
SELECT
p.`id_order` AS `id_order`,
par.`waybill` AS `id_parcel`,
CONCAT(a.`firstname`, " ", a.`lastname`) AS `receiver`,
cl.`name` AS `country`,
a.`postcode` AS `postcode`,
a.`city` AS `city`,
CONCAT(a.`address1`, " ", a.`address2`) AS `address`,
p.`date_add` AS `date_add`
FROM `'._DB_PREFIX_._DPDPOLAND_PARCEL_DB_.'` par
LEFT JOIN `'._DB_PREFIX_._DPDPOLAND_PACKAGE_DB_.'` p ON (p.`id_package_ws` = par.`id_package_ws`)
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = p.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'address` a ON (a.`id_address` = p.`id_address_delivery`)
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = "'.(int)$id_lang.'")'.
(version_compare(_PS_VERSION_, '1.5', '<') ? ' ' : 'WHERE o.`id_shop` = "'.(int)$id_shop.'" ').
$filter.
($order_by && $order_way ? ' ORDER BY `'.bqSQL($order_by).'` '.pSQL($order_way) : '').
($start !== null && $pagination !== null ? ' LIMIT '.(int)$start.', '.(int)$pagination : '')
);
if (!$list)
$list = array();
return $list;
}
}

View File

@@ -0,0 +1,250 @@
<?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 DpdPolandParcelProduct Responsible for parcel products management
*/
class DpdPolandParcelProduct extends DpdPolandObjectModel
{
/**
* @var int Parcel product ID
*/
public $id_parcel_product;
/**
* @var int Parcel ID
*/
public $id_parcel;
/**
* @var int Product ID
*/
public $id_product;
/**
* @var int Product attribute ID
*/
public $id_product_attribute;
/**
* @var string Product name
*/
public $name;
/**
* @var Product weight
*/
public $weight;
/**
* @var datetime Date when product was assigned for order
*/
public $date_add;
/**
* @var datetime Date when product data of assignation for order was updated
*/
public $date_upd;
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_PARCEL_PRODUCT_DB_,
'primary' => 'id_parcel_product',
'multilang' => false,
'multishop' => false,
'fields' => array(
'id_parcel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'weight' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Collects data about parcels products details
*
* @param array $parcels Parcels
* @return array Parcels products data
*/
public static function getProductDetailsByParcels($parcels)
{
$products = array();
foreach ($parcels as $parcel)
{
if (isset($parcel['id_parcel']))
{
if ($products_array = self::getProductByIdParcel($parcel['id_parcel']))
{
foreach ($products_array as $product)
{
if (self::isLabelPrinted($parcel['id_parcel']))
{
$product_data = self::getProductNameAndWeight($parcel['id_parcel'], $product['id_product'],
$product['id_product_attribute']);
$products[] = array_merge($product, array(
'name' => $product_data['name'],
'weight' => (float)$product_data['weight'],
'id_parcel' => (int)$parcel['id_parcel']
));
}
else
{
$product_obj = new Product($product['id_product']);
$combination = new Combination($product['id_product_attribute']);
$products[] = array_merge($product, array(
'name' => (version_compare(_PS_VERSION_, '1.5', '<') ?
$product_obj->name[(int)Context::getContext()->language->id] :
Product::getProductName($product['id_product'], $product['id_product_attribute'])),
'weight' => (float)$combination->weight + (float)$product_obj->weight,
'id_parcel' => (int)$parcel['id_parcel']
));
}
}
}
}
}
return $products;
}
/**
* Collects products IDs according to parcel
*
* @param int $id_parcel Parcel ID
* @return array|false|mysqli_result|null|PDOStatement|resource Parcel products IDs
*/
private static function getProductByIdParcel($id_parcel)
{
return Db::getInstance()->executeS('
SELECT `id_product`, `id_product_attribute`
FROM `'._DB_PREFIX_.bqSQL(self::$definition['table']).'`
WHERE `id_parcel`='.(int)$id_parcel
);
}
/**
* Collects and formats data about order shipped products
*
* @param int $id_order Order ID
* @param array $products Products information
* @return array Shipped products data
*/
public static function getShippedProducts($id_order, $products = array())
{
$order = is_object($id_order) ? $id_order : new Order((int)$id_order);
if (!$products)
$products = $order->getProductsDetail();
$shipped_products = array();
foreach ($products as $product)
{
if (isset($product['product_quantity']))
$quantity = (int)$product['product_quantity'];
elseif (isset($product['quantity']))
$quantity = (int)$product['quantity'];
else
$quantity = 1;
self::extractAndFormatProductData($product);
for ($i = 0; $i < $quantity; $i++)
$shipped_products[] = $product;
}
return $shipped_products;
}
/**
* Collects and formats needed products data
*
* @param array $product Product properties
*/
private static function extractAndFormatProductData(&$product)
{
$id_product = isset($product['product_id']) ? (int)$product['product_id'] : (int)$product['id_product'];
$id_product_attribute = isset($product['product_attribute_id']) ? (int)$product['product_attribute_id'] :
(int)$product['id_product_attribute'];
$product_name = isset($product['product_name']) ? $product['product_name'] : $product['name'];
$product_weight = isset($product['product_weight']) ? $product['product_weight'] : $product['weight'];
if (isset($product['id_parcel']))
$id_parcel = (int)$product['id_parcel'];
$product = array(
'id_product' => $id_product,
'id_product_attribute' => $id_product_attribute,
'name' => $product_name,
'weight' => DpdPoland::convertWeight($product_weight),
'width' => isset($product['width']) ? DpdPoland::convertDimension($product['width']) : null,
'height' => isset($product['height']) ? DpdPoland::convertDimension($product['height']) : null,
'length' => isset($product['height']) ? DpdPoland::convertDimension($product['depth']) : null
);
if (isset($id_parcel))
$product['id_parcel'] = $id_parcel;
}
/**
* Checks if label is printed and record about it was saved in database
*
* @param int $id_parcel Parcel ID
* @return bool Label was printed
*/
private static function isLabelPrinted($id_parcel)
{
return (bool)DB::getInstance()->getValue('
SELECT pac.`labels_printed`
FROM `'._DB_PREFIX_._DPDPOLAND_PARCEL_DB_.'` par
LEFT JOIN `'._DB_PREFIX_._DPDPOLAND_PACKAGE_DB_.'` pac ON (pac.`id_package_ws` = par.`id_package_ws`)
WHERE par.`id_parcel` = "'.(int)$id_parcel.'"
');
}
/**
* Collects product name and weight
*
* @param int $id_parcel Parcel ID
* @param int $id_product Product ID
* @param int $id_product_attribute Product combination ID
* @return array|bool|null|object Product name and weight
*/
private static function getProductNameAndWeight($id_parcel, $id_product, $id_product_attribute)
{
return DB::getInstance()->getRow('
SELECT `name`, `weight`
FROM `'._DB_PREFIX_._DPDPOLAND_PARCEL_PRODUCT_DB_.'`
WHERE `id_parcel` = "'.(int)$id_parcel.'"
AND `id_product` = "'.(int)$id_product.'"
AND `id_product_attribute` = "'.(int)$id_product_attribute.'"
');
}
}

View File

@@ -0,0 +1,123 @@
<?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 DpdPolandPayerNumber Responsible for payer number management
*/
class DpdPolandPayerNumber extends DpdPolandObjectModel
{
/**
* @var int Payer number ID
*/
public $id_dpdpoland_payer_number;
/**
* @var string|int Payer number
*/
public $payer_number;
/**
* @var string Payer number name
*/
public $name;
/**
* @var int Shop ID
*/
public $id_shop;
/**
* @var datetime Date when payer number was added
*/
public $date_add;
/**
* @var datetime Date when payer number was updated
*/
public $date_upd;
/**
* DpdPolandPayerNumber class constructor
* @param null|int $id_dpdpoland_payer_number DPD payer number ID
*/
public function __construct($id_dpdpoland_payer_number = null)
{
parent::__construct($id_dpdpoland_payer_number);
$this->id_shop = (int)Context::getContext()->shop->id;
}
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_PAYER_NUMBERS_DB_,
'primary' => 'id_dpdpoland_payer_number',
'multilang_shop' => true,
'multishop' => true,
'fields' => array(
'payer_number' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Checks if payer number exists in database
*
* @param string $number Payer number
* @param null|int $id_shop Shop ID
* @return bool Payer number exists in database
*/
public static function payerNumberExists($number, $id_shop = null)
{
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
return (bool)DB::getInstance()->getValue('
SELECT `id_dpdpoland_payer_number`
FROM `'._DB_PREFIX_._DPDPOLAND_PAYER_NUMBERS_DB_.'`
WHERE `payer_number` = "'.pSQL($number).'"
AND `id_shop` = "'.(int)$id_shop.'"
');
}
/**
* Collects data of merchant payer numbers saved in database
*
* @param null|int $id_shop Shop ID
* @return array|false|mysqli_result|null|PDOStatement|resource Payer numbers
*/
public static function getPayerNumbers($id_shop = null)
{
if ($id_shop === null)
$id_shop = (int)Context::getContext()->shop->id;
return DB::getInstance()->executeS('
SELECT `id_dpdpoland_payer_number`, `payer_number`, `name`
FROM `'._DB_PREFIX_._DPDPOLAND_PAYER_NUMBERS_DB_.'`
WHERE `id_shop` = "'.(int)$id_shop.'"
');
}
}

View File

@@ -0,0 +1,188 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
/**
* Class DpdPolandPickupHistory
*/
class DpdPolandPickupHistory extends DpdPolandObjectModel
{
/**
* @var int Courier order ID, incremental
*/
public $id_pickup_history;
/**
* @var string Order number
*/
public $order_number;
/**
* @var string Sender address
*/
public $sender_address;
/**
* @var string Sender company
*/
public $sender_company;
/**
* @var string Sender name
*/
public $sender_name;
/**
* @var string Sender phone
*/
public $sender_phone;
/**
* @var datetime Pickup date
*/
public $pickup_date;
/**
* @var string Pickup time range
*/
public $pickup_time;
/**
* @var string Type
*/
public $type;
/**
* @var int envelope
*/
public $envelope;
/**
* @var int package
*/
public $package;
/**
* @var decimal Package weight all
*/
public $package_weight_all;
/**
* @var decimal Package heaviest weight
*/
public $package_heaviest_weight;
/**
* @var decimal Package heaviest width
*/
public $package_heaviest_width;
/**
* @var decimal Package heaviest length
*/
public $package_heaviest_length;
/**
* @var decimal Package heaviest height
*/
public $package_heaviest_height;
/**
* @var int Pallet
*/
public $pallet;
/**
* @var decimal Pallet weight
*/
public $pallet_weight;
/**
* @var decimal Pallet heaviest weight
*/
public $pallet_heaviest_weight;
/**
* @var decimal Pallet heaviest height
*/
public $pallet_heaviest_height;
/**
* @var datetime Date when sender address was saved
*/
public $date_add;
/**
* @var datetime Date when sender address was updated
*/
public $date_upd;
/**
* @var int Shop ID
*/
public $id_shop;
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_PICKUP_HISTORY_DB_,
'primary' => 'id_pickup_history',
'multilang' => false,
'multishop' => true,
'fields' => array(
'order_number' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'sender_address' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'sender_company' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'sender_name' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'sender_phone' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'pickup_date' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'pickup_time' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'type' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything'),
'envelope' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'package' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'pallet' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Collects list data and prepares it to be displayed
*
* @param string $order_by List order by criteria
* @param string $order_way List sorting way (ascending, descending)
* @param string $filter Criteria by which list is filtered
* @param int $start From which element list will be displayed
* @param int $pagination How many elements will be displayed in list
* @return array|false|mysqli_result|null|PDOStatement|resource Collected list data
*/
public static function getList($order_by, $order_way, $filter, $start, $pagination)
{
return Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_._DPDPOLAND_PICKUP_HISTORY_DB_.'`
WHERE `id_shop` = "'.(int)Context::getContext()->shop->id.'"
'.$filter.'
ORDER BY `'.bqSQL($order_by).'` '.pSQL(Validate::isOrderWay($order_way) ? $order_way : 'ASC').
($start !== null && $pagination !== null ? ' LIMIT '.(int)$start.', '.(int)$pagination : '')
);
}
/**
* Calculates how many addresses are saved in current shop
*
* @return int count
*/
public static function getCourierOrderCount()
{
return (int)Db::getInstance()->getValue('
SELECT COUNT(`id_pickup_history`)
FROM `'._DB_PREFIX_._DPDPOLAND_PICKUP_HISTORY_DB_.'`
WHERE `id_shop` = "'.(int)Context::getContext()->shop->id.'"
');
}
}

View File

@@ -0,0 +1,175 @@
<?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 DpdPolandSenderAddress Responsible for sender addresses management
*/
class DpdPolandSenderAddress extends DpdPolandObjectModel
{
/**
* @var int Sender address ID, incremental
*/
public $id_sender_address;
/**
* @var string Sender address alias
*/
public $alias;
/**
* @var string Sender name
*/
public $name;
/**
* @var string Sender phone number
*/
public $phone;
/**
* @var string Sender address
*/
public $address;
/**
* @var string Sender city name
*/
public $city;
/**
* @var string Sender company name
*/
public $company;
/**
* @var string Sender email address
*/
public $email;
/**
* @var string Sender postcode
*/
public $postcode;
/**
* @var datetime Date when sender address was saved
*/
public $date_add;
/**
* @var datetime Date when sender address was updated
*/
public $date_upd;
/**
* @var int Shop ID
*/
public $id_shop;
/**
* @var array Class variables and their validation types
*/
public static $definition = array(
'table' => _DPDPOLAND_SENDER_ADDRESS_DB_,
'primary' => 'id_sender_address',
'multilang' => false,
'multishop' => false,
'fields' => array(
'alias' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber'),
'address' => array('type' => self::TYPE_STRING, 'validate' => 'isAddress'),
'city' => array('type' => self::TYPE_STRING, 'validate' => 'isCityName'),
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail'),
'postcode' => array('type' => self::TYPE_STRING, 'validate' => 'isPostCode'),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate')
)
);
/**
* Collects list data and prepares it to be displayed
*
* @param string $order_by List order by criteria
* @param string $order_way List sorting way (ascending, descending)
* @param string $filter Criteria by which list is filtered
* @param int $start From which element list will be displayed
* @param int $pagination How many elements will be displayed in list
* @return array|false|mysqli_result|null|PDOStatement|resource Collected list data
*/
public function getList($order_by, $order_way, $filter, $start, $pagination)
{
$order_way = Validate::isOrderWay($order_way) ? $order_way : 'ASC';
return Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_._DPDPOLAND_SENDER_ADDRESS_DB_.'`
WHERE `id_shop` = "'.(int)Context::getContext()->shop->id.'"
'.$filter.'
ORDER BY `'.bqSQL($order_by).'` '.pSQL($order_way).
($start !== null && $pagination !== null ? ' LIMIT '.(int)$start.', '.(int)$pagination : '')
);
}
/**
* Collects and returns data about sender addresses saved in current shop
*
* @return array Sender addresses
*/
public static function getAddresses()
{
$result = array();
$addresses = Db::getInstance()->executeS('
SELECT `id_sender_address`, `alias`
FROM `'._DB_PREFIX_._DPDPOLAND_SENDER_ADDRESS_DB_.'`
WHERE `id_shop` = "'.(int)Context::getContext()->shop->id.'"
');
if (!$addresses) {
return $result;
}
foreach ($addresses as $address) {
$result[$address['id_sender_address']] = $address['alias'];
}
return $result;
}
/**
* Calculates how many addresses are saved in current shop
*
* @return int Sender addresses count
*/
public static function getAddressesCount()
{
return (int)Db::getInstance()->getValue('
SELECT COUNT(`id_sender_address`)
FROM `'._DB_PREFIX_._DPDPOLAND_SENDER_ADDRESS_DB_.'`
WHERE `id_shop` = "'.(int)Context::getContext()->shop->id.'"
');
}
}

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,264 @@
<?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;
/* URI constants */
if (!defined('_DPDPOLAND_MODULE_URI_'))
/**
* URL to module directory
*/
define('_DPDPOLAND_MODULE_URI_', _MODULE_DIR_.'dpdpoland/');
if (!defined('_DPDPOLAND_LIBRARIES_DIR_'))
/**
* Path to module libraries directory
*/
define('_DPDPOLAND_LIBRARIES_DIR_', _PS_MODULE_DIR_.'dpdpoland/libraries/');
if (!defined('_DPDPOLAND_CSS_URI_'))
/**
* URL to module CSS files
*/
define('_DPDPOLAND_CSS_URI_', _DPDPOLAND_MODULE_URI_.'css/');
if (!defined('_DPDPOLAND_JS_URI_'))
/**
* URL to module JS files
*/
define('_DPDPOLAND_JS_URI_', _DPDPOLAND_MODULE_URI_.'js/');
if (!defined('_DPDPOLAND_IMG_URI_'))
/**
* URL to module images
*/
define('_DPDPOLAND_IMG_URI_', _DPDPOLAND_MODULE_URI_.'img/');
if (!defined('_DPDPOLAND_AJAX_URI_'))
/**
* URL to module AJAX file
*/
define('_DPDPOLAND_AJAX_URI_', _DPDPOLAND_MODULE_URI_.'dpdpoland.ajax.php');
if (!defined('_DPDPOLAND_PDF_URI_'))
/**
* URL to module file used for PDF files printing
*/
define('_DPDPOLAND_PDF_URI_', _DPDPOLAND_MODULE_URI_.'dpdpoland.pdf.php');
/* Directories constants */
if (!defined('_DPDPOLAND_CONTROLLERS_DIR_'))
/**
* Path to module controllers directory
*/
define('_DPDPOLAND_CONTROLLERS_DIR_', dirname(__FILE__).'/controllers/');
if (!defined('_DPDPOLAND_TPL_DIR_'))
/**
* Path to module templates directory
*/
define('_DPDPOLAND_TPL_DIR_', dirname(__FILE__).'/views/templates/');
if (!defined('_DPDPOLAND_CLASSES_DIR_'))
/**
* Path to module classes directory
*/
define('_DPDPOLAND_CLASSES_DIR_', dirname(__FILE__).'/classes/');
if (!defined('_DPDPOLAND_MODULE_DIR_'))
/**
* Path to module directory
*/
define('_DPDPOLAND_MODULE_DIR_', _PS_MODULE_DIR_.'dpdpoland/');
if (!defined('_DPDPOLAND_IMG_DIR_'))
/**
* Path to module images directory
*/
define('_DPDPOLAND_IMG_DIR_', _DPDPOLAND_MODULE_DIR_.'img/');
/* */
if (!defined('_DPDPOLAND_DEBUG_MODE_'))
/**
* Is debug mode enabled or not
*/
define('_DPDPOLAND_DEBUG_MODE_', false);
if (!defined('_DPDPOLAND_PRICE_RULE_DB_'))
/**
* Database table name for price rules data
*/
define('_DPDPOLAND_PRICE_RULE_DB_', 'dpdpoland_price_rule');
if (!defined('_DPDPOLAND_PAYER_NUMBERS_DB_'))
/**
* Database table name for payer numbers
*/
define('_DPDPOLAND_PAYER_NUMBERS_DB_', 'dpdpoland_payer_number');
if (!defined('_DPDPOLAND_COUNTRY_DB_'))
/**
* Database table name for available countries data
*/
define('_DPDPOLAND_COUNTRY_DB_', 'dpdpoland_country');
if (!defined('_DPDPOLAND_MANIFEST_DB_'))
/**
* Database table name for manifests data
*/
define('_DPDPOLAND_MANIFEST_DB_', 'dpdpoland_manifest');
if (!defined('_DPDPOLAND_SENDER_ADDRESS_DB_'))
/**
* Database table name for sender address data
*/
define('_DPDPOLAND_SENDER_ADDRESS_DB_', 'dpdpoland_sender_address');
if (!defined('_DPDPOLAND_PACKAGE_DB_'))
/**
* Database table name for packages data
*/
define('_DPDPOLAND_PACKAGE_DB_', 'dpdpoland_package');
if (!defined('_DPDPOLAND_PARCEL_DB_'))
/**
* Database table name for parcels data
*/
define('_DPDPOLAND_PARCEL_DB_', 'dpdpoland_parcel');
if (!defined('_DPDPOLAND_PARCEL_PRODUCT_DB_'))
/**
* Database table name for parcel products data
*/
define('_DPDPOLAND_PARCEL_PRODUCT_DB_', 'dpdpoland_parcel_product');
if (!defined('_DPDPOLAND_CARRIER_DB_'))
/**
* Database table name for carriers assignations to their references on PS 1.4
*/
define('_DPDPOLAND_CARRIER_DB_', 'dpdpoland_carrier');
if (!defined('_DPDPOLAND_PICKUP_HISTORY_DB_'))
/**
* Database table name for sender address data
*/
define('_DPDPOLAND_PICKUP_HISTORY_DB_', 'dpdpoland_pickup_history');
if (!defined('_DPDPOLAND_CSV_DELIMITER_'))
/**
* CSV file delimiter
*/
define('_DPDPOLAND_CSV_DELIMITER_', ';');
if (!defined('_DPDPOLAND_CSV_FILENAME_'))
/**
* CSV file name
*/
define('_DPDPOLAND_CSV_FILENAME_', 'dpdpoland');
if (!defined('_DPDPOLAND_STANDARD_ID_'))
/**
* Standard service (carrier) ID
*/
define('_DPDPOLAND_STANDARD_ID_', 1);
if (!defined('_DPDPOLAND_STANDARD_COD_ID_'))
/**
* Standard COD service (carrier) ID
*/
define('_DPDPOLAND_STANDARD_COD_ID_', 2);
if (!defined('_DPDPOLAND_CLASSIC_ID_'))
/**
* Classic / international service (carrier) ID
*/
define('_DPDPOLAND_CLASSIC_ID_', 3);
if (!defined('_DPDPOLAND_PUDO_ID_'))
/**
* Pickup point service (carrier) ID
*/
define('_DPDPOLAND_PUDO_ID_', 4);
if (!defined('_DPDPOLAND_CURRENCY_ISO_'))
/**
* DPD Poland currency
*/
define('_DPDPOLAND_CURRENCY_ISO_', 'PLN');
if (!defined('_DPDPOLAND_DEFAULT_WEIGHT_UNIT_'))
/**
* Weight unit
*/
define('_DPDPOLAND_DEFAULT_WEIGHT_UNIT_', 'kg');
if (!defined('_DPDPOLAND_DEFAULT_DIMENSION_UNIT_'))
/**
* Dimension unit
*/
define('_DPDPOLAND_DEFAULT_DIMENSION_UNIT_', 'cm');
if (!defined('_DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_'))
/**
* Weight divisor
*/
define('_DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_', 6000);
if (!defined('_DPDPOLAND_TRACKING_URL_'))
/**
* Tracking URL
*/
define('_DPDPOLAND_TRACKING_URL_',
'https://tracktrace.dpd.com.pl/parcelDetails?typ=1&p1=@');
if (!defined('_DPDPOLAND_PRICES_ZIP_URL_'))
/**
* Information about prices ZIP file URL address
*/
define('_DPDPOLAND_PRICES_ZIP_URL_', 'http://www.dpd.com.pl/EN/download/Cennik_uslug_krajowych_DPD_Polska_01_07_2013.zip');
if (!defined('_DPDPOLAND_CONTENT_HEADER_URL_'))
/**
* Link to DPD website
*/
define('_DPDPOLAND_CONTENT_HEADER_URL_', 'http://www.dpd.com.pl');
if (!defined('_DPDPOLAND_SUPPORT_URL_'))
/**
* Support form URL address
*/
define('_DPDPOLAND_SUPPORT_URL_', 'https://addons.prestashop.com/en/write-to-developper?id_product=17924');
if (!defined('_DPDPOLAND_REFERENCE3_'))
/**
* Reference #3 content
*/
define('_DPDPOLAND_REFERENCE3_', 'PSMODUL#');
if (!defined('_DPDPOLAND_COOKIE_'))
/**
* DPD module cookie name
*/
define('_DPDPOLAND_COOKIE_', 'dpdpoland_cookie');

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>dpdpoland</name>
<displayName><![CDATA[DPD Polska Sp. z o.o.]]></displayName>
<version><![CDATA[1.4.4]]></version>
<description><![CDATA[DPD Polska Sp. z o.o. shipping module]]></description>
<author><![CDATA[DPD Polska Sp. z o.o.]]></author>
<tab><![CDATA[shipping_logistics]]></tab>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>dpdpoland</name>
<displayName><![CDATA[DPD Polska Sp. z o.o.]]></displayName>
<version><![CDATA[1.4.4]]></version>
<description><![CDATA[DPD Polska Moduł Wysyłek]]></description>
<author><![CDATA[DPD Polska Sp. z o.o.]]></author>
<tab><![CDATA[shipping_logistics]]></tab>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,347 @@
<?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 DpdPolandArrangePickUpController Responsible for Arrange Pickup page view and actions
*/
class DpdPolandArrangePickUpController extends DpdPolandController
{
/**
* Current file name
*/
const FILENAME = 'arrange_pickup.controller';
/**
* @var array Pickup data
*/
private $data = array();
/**
* @var array Arrange Pickup fields visible in this page
*/
private $rules = array();
/**
* DpdPolandArrangePickUpController class constructor
*/
public function __construct()
{
parent::__construct();
$this->rules = array(
'customerCompany' => array(
'validate' => 'isAnything',
'fieldname' => $this->l('Customer company name'),
'required' => true
),
'customerName' => array(
'validate' => 'isAnything',
'fieldname' => $this->l('Customer name and surname'),
'required' => true
),
'customerPhone' => array(
'validate' => 'isAnything',
'fieldname' => $this->l('Customer tel. No.'),
'required' => true
),
'pickupDate' => array(
'validate' => 'isDate',
'fieldname' => $this->l('Date of pickup'),
'required' => true
),
'pickupTime' => array(
'validate' => 'isAnything',
'fieldname' => $this->l('Timeframe of pickup'),
'required' => true
),
'orderType' => array(
'validate' => 'isAnything',
'fieldname' => $this->l('Shipment type'),
'required' => true
),
'orderContent' => array(
'validate' => 'isAnything',
'fieldname' => $this->l('General shipment content'),
'required' => false
),
'dox' => array(
'validate' => 'isAnything',
'fieldname' => $this->l('Envelopes'),
'required' => false
),
'doxCount' => array(
'validate' => 'isUnsignedInt',
'fieldname' => $this->l('Number of envelopes'),
'required' => true,
'dependency' => 'dox'
),
'parcels' => array(
'validate' => 'isUnsignedInt',
'fieldname' => $this->l('Parcels'),
'required' => false
),
'parcelsCount' => array(
'validate' => 'isUnsignedInt',
'fieldname' => $this->l('Number of parcels'),
'required' => true,
'dependency' => 'parcels'
),
'parcelsWeight' => array(
'validate' => 'isUnsignedFloat',
'fieldname' => $this->l('Summary weight'),
'required' => true,
'dependency' => 'parcels'
),
'parcelMaxWeight' => array(
'validate' => 'isUnsignedFloat',
'fieldname' => $this->l('Weight of the heaviest item'),
'required' => true,
'dependency' => 'parcels'
),
'parcelMaxHeight' => array(
'validate' => 'isUnsignedFloat',
'fieldname' => $this->l('Height of the tallest item'),
'required' => true,
'dependency' => 'parcels'
),
'parcelMaxDepth' => array(
'validate' => 'isUnsignedFloat',
'fieldname' => $this->l('Length of the largest item'),
'required' => true,
'dependency' => 'parcels'
),
'parcelMaxWidth' => array(
'validate' => 'isUnsignedFloat',
'fieldname' => $this->l('Width of the longest item'),
'required' => true,
'dependency' => 'parcels'
),
'pallet' => array(
'validate' => 'isAnything',
'fieldname' => $this->l('Pallets'),
'required' => false
),
'palletsCount' => array(
'validate' => 'isUnsignedInt',
'fieldname' => $this->l('Number of pallets'),
'required' => true,
'dependency' => 'pallet'
),
'palletsWeight' => array(
'validate' => 'isUnsignedFloat',
'fieldname' => $this->l('Summary weight'),
'required' => true,
'dependency' => 'pallet'
),
'palletMaxWeight' => array(
'validate' => 'isUnsignedFloat',
'fieldname' => $this->l('Weight of the heaviest item'),
'required' => true,
'dependency' => 'pallet'
),
'palletMaxHeight' => array(
'validate' => 'isUnsignedFloat',
'fieldname' => $this->l('Height of the tallest item'),
'required' => true,
'dependency' => 'pallet'
)
);
}
/**
* Returns arrange pickup data parameter
*
* @param string $name Parameter name
* @return mixed|null Arrange pickup data value
*/
public function __get($name)
{
return isset($this->data[$name]) ? $this->data[$name] : null;
}
/**
* Checks if given date is weekend
*
* @param datetime $date Date
* @return bool Given date is weekend
*/
public static function isWeekend($date)
{
return (date('N', strtotime($date)) >= 6);
}
/**
* Displays Arrange Pickup page content
*
* @return string Page content in HTML
*/
public function getPage()
{
$date = date('Y-m-d');
$pickup_date = (Tools::getValue('pickupDate') ? Tools::getValue('pickupDate') :
($this->isWeekend($date) ? date('Y-m-d', strtotime('next monday')) : $date));
$sender_addresses = DpdPolandSenderAddress::getAddresses();
$this->context->smarty->assign(array(
'settings' => new DpdPolandConfiguration,
'pickupDate' => $pickup_date,
'sender_addresses' => $sender_addresses
));
if (version_compare(_PS_VERSION_, '1.6', '>='))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/arrange_pickup_16.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/arrange_pickup.tpl');
}
/**
* Checks if time frames are valid
*
* @param array $timeframes Time frames
* @param int $poland_time_in_seconds Poland country current time in seconds
* @param bool $is_today Is time frames of today
*/
public static function validateTimeframes(&$timeframes, $poland_time_in_seconds, $is_today)
{
$count_timeframes = count($timeframes);
for ($i = 0; $i < $count_timeframes; $i++)
{
if (!isset($timeframes[$i]['range']))
{
unset($timeframes[$i]);
continue;
}
$end_time = explode('-', $timeframes[$i]['range']);
$end_time = strtotime($end_time[1]);
if ($is_today && round(abs($end_time - $poland_time_in_seconds) / 60) < 120)
unset($timeframes[$i]);
}
}
/**
* Creates additional time frame which wraps other time frames from first to last
*
* @param array $pickup_timeframes Time frames
* @return bool|string Additional time frame
*/
public static function createExtraTimeframe($pickup_timeframes)
{
if (!$pickup_timeframes || !isset($pickup_timeframes[0]['range']))
return false;
$extra_time_from = null;
$extra_time_to = null;
foreach ($pickup_timeframes as $frame)
{
if (isset($frame['range']))
{
list($pickup_time_from, $pickup_time_to) = explode('-', $frame['range']);
if (!$extra_time_from || (str_replace(':', '', $pickup_time_from) < str_replace(':', '', $extra_time_from)))
$extra_time_from = $pickup_time_from;
if (!$extra_time_to || (str_replace(':', '', $pickup_time_to) > str_replace(':', '', $extra_time_to)))
$extra_time_to = $pickup_time_to;
}
}
if (!$extra_time_from || !$extra_time_to)
return false;
if ($extra_time_from.'-'.$extra_time_to == $pickup_timeframes[0]['range'])
return false;
return $extra_time_from.'-'.$extra_time_to;
}
/**
* Collects and returns Arrange Pickup data
*
* @return array Arrange Pickup data
*/
public function getData()
{
if (!$this->data)
foreach (array_keys($this->rules) as $element)
$this->data[$element] = Tools::getValue($element);
return $this->data;
}
/**
* Checks if Arrange Pickup parameters are valid
*
* @return bool Arrange Pickup parameters are valid
*/
public function validate()
{
$date = Tools::getValue('pickupDate');
if (!Validate::isDateFormat($date))
{
self::$errors[] = $this->l('Wrong date format');
return false;
}
if (strtotime($date) < strtotime(date('Y-m-d')))
{
self::$errors[] = $this->l('Date can not be earlier than').' '.date('Y-m-d');
return false;
}
if ($this->isWeekend($date))
{
self::$errors[] = $this->l('Weekends can not be chosen');
return false;
}
if (!$this->dox && !$this->parcels && !$this->pallet)
{
self::$errors[] = $this->l('At least one service must be selected');
return false;
}
foreach ($this->rules as $element => $rules)
{
if (!isset($rules['dependency']) || (isset($rules['dependency']) && $this->{$rules['dependency']}))
{
if ($rules['required'] && !$this->$element)
{
self::$errors[] = sprintf($this->l('The "%s" field is required.'), $rules['fieldname']);
return false;
}
elseif ($this->$element && method_exists('Validate', $rules['validate']) &&
!call_user_func(array('Validate', $rules['validate']), $this->$element))
{
self::$errors[] = sprintf($this->l('The "%s" field is invalid.'), $rules['fieldname']);
return false;
}
}
}
return true;
}
}

View File

@@ -0,0 +1,236 @@
<?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 DpdPolandConfigurationController Responsible for setting page view and actions
*/
class DpdPolandConfigurationController extends DpdPolandController
{
/**
* @var array Available services (carriers) IDs
*/
public $available_services_ids = array();
/**
* Name of settings saving action
*/
const SETTINGS_SAVE_ACTION = 'saveModuleSettings';
/**
* Current file name
*/
const FILENAME = 'configuration.controller';
/**
* Displays settings page content
*
* @return string Settings page content in HTML
*/
public function getSettingsPage()
{
$configuration_obj = new DpdPolandConfiguration();
$payment_modules = array();
foreach (DpdPoland::getPaymentModules() as $payment_module)
{
$module = Module::getInstanceByName($payment_module['name']);
if (!Validate::isLoadedObject($module))
continue;
$payment_modules[] = array(
'displayName' => $module->displayName,
'name' => $payment_module['name']
);
}
$this->context->smarty->assign(array(
'saveAction' => $this->module_instance->module_url,
'settings' => $configuration_obj,
'payer_numbers' => DpdPolandPayerNumber::getPayerNumbers(),
'payment_modules' => $payment_modules,
'zones' => Zone::getZones(),
'carrier_zones' => array(
'classic' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_CLASSIC_ID),
'standard' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_STANDARD_ID),
'standard_cod' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID),
'pudo' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_PUDO_ID)
)
));
if (version_compare(_PS_VERSION_, '1.6', '>='))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/configuration_16.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/configuration.tpl');
}
/**
* Collects and returns carrier zones
*
* @param int|string $carrier_type Carrier type
* @return array Carrier zones
*/
private function getZonesForCarrier($carrier_type)
{
require_once(_DPDPOLAND_CONTROLLERS_DIR_.'service.php');
$id_carrier = (int)Configuration::get($carrier_type);
$carrier = DpdPolandService::getCarrierByReference((int)$id_carrier);
if (Validate::isLoadedObject($carrier))
$id_carrier = $carrier->id;
$carrier_zones = DpdPolandConfiguration::getCarrierZones((int)$id_carrier);
$carrier_zones_list = array();
foreach ($carrier_zones as $zone)
$carrier_zones_list[] = $zone['id_zone'];
return $carrier_zones_list;
}
/**
* Creates selected DPD sevices (carriers)
* Deletes other DPD carriers
*/
public function createDeleteCarriers()
{
require_once(_DPDPOLAND_CONTROLLERS_DIR_.'service.php');
require_once(_DPDPOLAND_CONTROLLERS_DIR_.'dpd_classic.service.php');
require_once(_DPDPOLAND_CONTROLLERS_DIR_.'dpd_standard.service.php');
require_once(_DPDPOLAND_CONTROLLERS_DIR_.'dpd_standard_cod.service.php');
require_once(_DPDPOLAND_CONTROLLERS_DIR_.'dpd_pudo.service.php');
if (Tools::getValue(DpdPolandConfiguration::CARRIER_CLASSIC))
{
if (!DpdPolandCarrierClassicService::install())
self::$errors[] = $this->l('Could not save DPD international shipment (DPD Classic) service');
}
else
{
if (!DpdPolandCarrierClassicService::delete())
self::$errors[] = $this->l('Could not delete DPD international shipment (DPD Classic) service');
}
if (Tools::getValue(DpdPolandConfiguration::CARRIER_STANDARD))
{
if (!DpdPolandCarrierStandardService::install())
self::$errors[] = $this->l('Could not save DPD domestic shipment - Standard service');
}
else
{
if (!DpdPolandCarrierStandardService::delete())
self::$errors[] = $this->l('Could not delete DPD domestic shipment - Standard service');
}
if (Tools::getValue(DpdPolandConfiguration::CARRIER_STANDARD_COD))
{
if (!DpdPolandCarrierStandardCODService::install())
self::$errors[] = $this->l('Could not save DPD domestic shipment - Standard with COD service');
}
else
{
if (!DpdPolandCarrierStandardCODService::delete())
self::$errors[] = $this->l('Could not delete DPD domestic shipment - Standard with COD service');
}
if (Tools::getValue(DpdPolandConfiguration::CARRIER_PUDO))
{
if (!DpdPolandCarrierPudoService::install())
self::$errors[] = $this->l('Could not save DPD Poland Reception Point Pickup service');
}
else
{
if (!DpdPolandCarrierPudoService::delete())
self::$errors[] = $this->l('Could not delete DPD Poland Reception Point Pickup service');
}
}
/**
* Checks if settings are valid before saving them
*/
public function validateSettings()
{
if (!Tools::getValue(DpdPolandConfiguration::LOGIN))
self::$errors[] = $this->l('Login can not be empty');
if (!Tools::getValue(DpdPolandConfiguration::PASSWORD))
self::$errors[] = $this->l('Password can not be empty');
elseif (!Validate::isPasswd(Tools::getValue(DpdPolandConfiguration::PASSWORD)))
self::$errors[] = $this->l('Password is not valid');
if (!Tools::getValue(DpdPolandConfiguration::CLIENT_NUMBER))
self::$errors[] = $this->l('Default client number must be set');
if (Tools::isSubmit(DpdPolandConfiguration::CARRIER_STANDARD_COD))
{
$checked = false;
foreach (DpdPoland::getPaymentModules() as $payment_module)
if (Tools::isSubmit(DpdPolandConfiguration::COD_MODULE_PREFIX.$payment_module['name']))
$checked = true;
if (!$checked)
self::$errors[] = $this->l('At least one COD payment method must be checked');
}
if (!Tools::getValue(DpdPolandConfiguration::WEIGHT_CONVERSATION_RATE))
self::$errors[] = $this->l('Weight conversation rate can not be empty');
elseif (!Validate::isUnsignedFloat(Tools::getValue(DpdPolandConfiguration::WEIGHT_CONVERSATION_RATE)))
self::$errors[] = $this->l('Weight conversation rate is not valid');
if (!Tools::getValue(DpdPolandConfiguration::DIMENSION_CONVERSATION_RATE))
self::$errors[] = $this->l('Dimension conversation rate can not be empty');
elseif (!Validate::isUnsignedFloat(Tools::getValue(DpdPolandConfiguration::DIMENSION_CONVERSATION_RATE)))
self::$errors[] = $this->l('Dimension conversation rate is not valid');
if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_FID))
self::$errors[] = $this->l('Customer FID can not be empty');
elseif (!ctype_alnum(Tools::getValue(DpdPolandConfiguration::CUSTOMER_FID)))
self::$errors[] = $this->l('Customer FID is not valid');
if (!Tools::getValue(DpdPolandConfiguration::WS_URL))
self::$errors[] = $this->l('Web Services URL can not be empty');
elseif (!Validate::isUrl(Tools::getValue(DpdPolandConfiguration::WS_URL)))
self::$errors[] = $this->l('Web Services URL is not valid');
}
/**
* Saves settings into database
*/
public function saveSettings()
{
if (DpdPolandConfiguration::saveConfiguration())
{
if (!DpdPolandConfiguration::saveZonesForCarriers())
DpdPoland::addFlashError($this->l('Settings saved successfully but could not assign zones for carriers'));
else
{
DpdPoland::addFlashMessage($this->l('Settings saved successfully'));
Tools::redirectAdmin($this->module_instance->module_url.'&menu=configuration');
}
}
else
DpdPoland::addFlashError($this->l('Could not save settings'));
}
}

View File

@@ -0,0 +1,206 @@
<?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 DpdPolandController Responsible for view and actions in module pages
*/
class DpdPolandController
{
/**
* @var Context Context object
*/
protected $context;
/**
* @var Module Module instance
*/
protected $module_instance;
/**
* @var array Available paginations
*/
protected $pagination = array(10, 20, 50, 100, 300);
/**
* @var int Default pagination
*/
private $default_pagination = 50;
/**
* @var array Collected pages errors
*/
public static $errors = array();
/**
* @var array Collected pages notices
*/
public static $notices = array();
/**
* @var string Child class name
*/
private $child_class_name;
/**
* DpdPolandController class constructor
*/
public function __construct()
{
$this->context = Context::getContext();
$this->module_instance = Module::getInstanceByName('dpdpoland');
$this->child_class_name = get_class($this);
}
/**
* Translates texts
*
* @param string $text Text
* @return string Translated text
*/
protected function l($text)
{
$child_class_name = $this->child_class_name;
$reflection = new ReflectionClass($child_class_name);
$filename = $reflection->hasConstant('FILENAME') ?
$reflection->getConstant('FILENAME') : false;
return $this->module_instance->l($text, $filename);
}
/**
* Collects and formats lists filter parameters
*
* @param array $keys_array Filter keys
* @param string $table Database table name
* @return string Formatted filter query
*/
protected function getFilterQuery($keys_array = array(), $table)
{
$sql = '';
foreach ($keys_array as $key)
if ($this->context->cookie->__isset($table.'Filter_'.$key))
{
$value = $this->context->cookie->{$table.'Filter_'.$key};
if (Validate::isSerializedArray($value))
{
$date = $this->module_instance->unSerialize($value);
if (!empty($date[0]))
$sql .= '`'.bqSQL($key).'` > "'.pSQL($date[0]).'" AND ';
if (!empty($date[1]))
$sql .= '`'.bqSQL($key).'` < "'.pSQL($date[1]).'" AND ';
}
else
{
if ($value != '')
$sql .= '`'.bqSQL($key).'` LIKE "%'.pSQL($value).'%" AND ';
}
}
if ($sql)
$sql = ' HAVING '.Tools::substr($sql, 0, -4); // remove 'AND ' from the end of query
return $sql;
}
/**
* Prepares list data to be displayed in page
*
* @param array $keys_array Filter keys
* @param string $table Database table name
* @param string $model Class name
* @param string $default_order_by Default sorting value
* @param string $default_order_way Default sorting way value
* @param string $menu_page Current menu page
* @param null $selected_pagination
*/
public function prepareListData($keys_array, $table, $model, $default_order_by, $default_order_way, $menu_page)
{
if (Tools::isSubmit('submitFilterButton'.$table))
{
foreach ($_POST as $key => $value)
{
if (strpos($key, $table.'Filter_') !== false) // looking for filter values in $_POST
{
if (is_array($value))
$this->context->cookie->$key = serialize($value);
else
$this->context->cookie->$key = $value;
}
}
}
if (Tools::isSubmit('submitReset'.$table))
{
foreach ($keys_array as $key)
{
if ($this->context->cookie->__isset($table.'Filter_'.$key))
{
$this->context->cookie->__unset($table.'Filter_'.$key);
$_POST[$table.'Filter_'.$key] = null;
}
}
}
if (version_compare(_PS_VERSION_, '1.6', '>='))
$page = (int)Tools::getValue('submitFilterButton'.$table);
else
$page = (int)Tools::getValue('submitFilter'.$table);
if (!$page)
$page = 1;
$selected_pagination = (int)Tools::getValue('pagination', $this->default_pagination);
$start = ($selected_pagination * $page) - $selected_pagination;
$order_by = Tools::getValue($table.'OrderBy', $default_order_by);
$order_way = Tools::getValue($table.'OrderWay', $default_order_way);
$filter = $this->getFilterQuery($keys_array, $table);
$table_data = $model->getList($order_by, $order_way, $filter, $start, $selected_pagination);
$list_total = count($model->getList($order_by, $order_way, $filter, null, null));
$total_pages = ceil($list_total / $selected_pagination);
if (!$total_pages)
$total_pages = 1;
$this->context->smarty->assign(array(
'full_url' => $this->module_instance->module_url.'&menu='.$menu_page.'&'.$table.'OrderBy='.$order_by.'&'.$table.'OrderWay='.$order_way,
'table_data' => $table_data,
'page' => $page,
'selected_pagination' => $selected_pagination,
'pagination' => $this->pagination,
'total_pages' => $total_pages,
'list_total' => $list_total,
'filters_has_value' => (bool)$filter,
'order_by' => $order_by,
'order_way' => $order_way,
'order_link' => 'index.php?controller=AdminOrders&vieworder&token='.Tools::getAdminTokenLite('AdminOrders')
));
}
}

View File

@@ -0,0 +1,191 @@
<?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 DpdPolandCountryListController Responsible for DPD countries list view and actions
*/
class DpdPolandCountryListController extends DpdPolandController
{
/**
* Countries list order by value
*/
const DEFAULT_ORDER_BY = 'id_country';
/**
* Countries list order way value
*/
const DEFAULT_ORDER_WAY = 'asc';
/**
* Current file name
*/
const FILENAME = 'countryList.controller';
/**
* Success message after changing country enable / disable value
*/
public function displaySuccessStatusChangingMessage()
{
$page = (int)Tools::getValue('submitFilterCountries');
if (!$page)
$page = 1;
$selected_pagination = (int)Tools::getValue('pagination', $this->pagination[0]);
$order_by = Tools::getValue('CountryOrderBy', self::DEFAULT_ORDER_BY);
$order_way = Tools::getValue('CountryOrderWay', self::DEFAULT_ORDER_WAY);
DpdPoland::addFlashMessage($this->l('Country status changed successfully'));
$redirect_url = $this->module_instance->module_url;
$redirect_url .= '&menu=country_list&pagination='.$selected_pagination;
$redirect_url .= '&CountryOrderBy='.$order_by;
$redirect_url .= '&CountryOrderWay='.$order_way;
$redirect_url .= '&submitFilterCountries='.$page;
die(Tools::redirectAdmin($redirect_url));
}
/**
* Sets enable / disable value for multiple countries
*
* @param array $countries Selected countries
* @param bool $disable Is action to disable countries
*/
public function changeEnabledMultipleCountries($countries = array(), $disable = false)
{
foreach ($countries as $id_country)
if (!$this->changeEnabled((int)$id_country, $disable))
self::$errors[] = sprintf($this->l('Could not change country status, ID: %s'), $id_country);
if (!empty(self::$errors))
{
$this->module_instance->outputHTML(
$this->module_instance->displayErrors(
self::$errors
)
);
reset(self::$errors);
}
else
{
$page = (int)Tools::getValue('submitFilterCountries');
if (!$page)
$page = 1;
$selected_pagination = (int)Tools::getValue('pagination', $this->pagination[0]);
$order_by = Tools::getValue('CountryOrderBy', self::DEFAULT_ORDER_BY);
$order_way = Tools::getValue('CountryOrderWay', self::DEFAULT_ORDER_WAY);
DpdPoland::addFlashMessage($this->l('Selected countries statuses changed successfully'));
$redirect_url = $this->module_instance->module_url;
$redirect_url .= '&menu=country_list&pagination='.$selected_pagination;
$redirect_url .= '&CountryOrderBy='.$order_by;
$redirect_url .= '&CountryOrderWay='.$order_way;
$redirect_url .= '&submitFilterCountries='.$page;
die(Tools::redirectAdmin($redirect_url));
}
}
/**
* Changes country status
*
* @param int $id_country Country ID
* @param bool $disable Disable or enable action
* @return bool Status changed successfully
*/
public function changeEnabled($id_country, $disable = false)
{
$country_obj = new DpdPolandCountry(DpdPolandCountry::getIdByCountry((int)$id_country));
$country_obj->enabled = $disable ? 0 : 1;
$country_obj->id_country = (int)$id_country;
return $country_obj->save();
}
/**
* Prepares list data to be displayed in page
*
* @return string Page content in HTML
*/
public function getListHTML()
{
$keys_array = array('id_country', 'name', 'iso_code', 'enabled');
$this->prepareListData($keys_array, 'Countries', new DpdPolandCountry(), self::DEFAULT_ORDER_BY, self::DEFAULT_ORDER_WAY, 'country_list');
if (version_compare(_PS_VERSION_, '1.6', '>='))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/country_list_16.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/country_list.tpl');
}
/**
* Disables specific DPD countries during module installation
*
* @return bool Countries disabled successfully
*/
public static function disableDefaultCountries()
{
$context = Context::getContext();
if (version_compare(_PS_VERSION_, '1.5', '<'))
{
foreach (Country::getCountries((int)$context->language->id) as $country)
if (!in_array($country['iso_code'], DpdPolandCountry::$default_enabled_countries)
&& !self::disableCountryById($context, (int)$country['id_country']))
return false;
}
else
foreach (array_keys(Shop::getShops()) as $id_shop)
foreach (Country::getCountriesByIdShop($id_shop, Configuration::get('PS_LANG_DEFAULT')) as $country)
if (!in_array($country['iso_code'], DpdPolandCountry::$default_enabled_countries)
&& !self::disableCountryById($context, (int)$country['id_country'], (int)$id_shop))
return false;
return true;
}
/**
* Disables specific DPD country
*
* @param Context $context Context object
* @param int $id_country Country ID
* @param null|int $id_shop Shop ID
* @return bool Country disabled successfully
*/
private static function disableCountryById($context, $id_country, $id_shop = null)
{
if ($id_shop === null)
$id_shop = (int)$context->shop->id;
$dpdpoland_country = new DpdPolandCountry();
$dpdpoland_country->id_country = (int)$id_country;
$dpdpoland_country->id_shop = (int)$id_shop;
$dpdpoland_country->enabled = 0;
return $dpdpoland_country->save();
}
}

View File

@@ -0,0 +1,669 @@
<?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 DpdPolandCSVController Responsible for price rules page view and actions
*/
class DpdPolandCSVController extends DpdPolandController
{
/**
* Poland country ISO code
*/
const POLAND_ISO_CODE = 'PL';
/**
* @var array CSV file titles
*/
private $csv_titles = array();
/**
* Name of action to save CSV file
*/
const SETTINGS_SAVE_CSV_ACTION = 'saveModuleCSVSettings';
/**
* Name of action to download CSV file
*/
const SETTINGS_DOWNLOAD_CSV_ACTION = 'downloadModuleCSVSettings';
/**
* Name of action to delete price rules
*/
const SETTINGS_DELETE_CSV_ACTION = 'deleteModuleCSVSettings';
/**
* Current file name
*/
const FILENAME = 'csv.controller';
/**
* Index of CSV file first line where CSV rules are written (not titles)
*/
const DEFAULT_FIRST_LINE_INDEX = 2;
/**
* Error message type for invalid usage of star symbol
*/
const STAR_COUNTRY_ERROR = 1;
/**
* Invalid country error type
*/
const PRESTASHOP_COUNTRY_ERROR = 2;
/**
* Error type of invalid Poland country
*/
const PL_COUNTRY_ERROR = 3;
/**
* Error type for invalid countries which are not Poland
*/
const NOT_PL_COUNTRY_ERROR = 4;
/**
* DpdPolandCSVController class constructor
*/
public function __construct()
{
parent::__construct();
$this->setCSVTitles();
}
/**
* Prepares CSV file titles
*/
private function setCSVTitles()
{
$this->csv_titles = array(
'iso_country' => $this->l('Country'),
'price_from' => $this->l('Cart price from (PLN)'),
'price_to' => $this->l('Cart price to (PLN)'),
'weight_from' => $this->l('Parcel weight from (kg)'),
'weight_to' => $this->l('Parcel weight to (kg)'),
'parcel_price' => $this->l('Parcel price (PLN)'),
'id_carrier' => $this->l('Carrier'),
'cod_price' => $this->l('COD cost (PLN)')
);
}
/**
* Displays price rules page content
*
* @return string
*/
public function getCSVPage()
{
$selected_pagination = Tools::getValue('pagination', '20');
$page = Tools::getValue('current_page', '1');
$start = ($selected_pagination * $page) - $selected_pagination;
$selected_products_data = DpdPolandCSV::getAllData($start, $selected_pagination);
$list_total = count(DpdPolandCSV::getAllData());
$pagination = array(20, 50, 100, 300);
$total_pages = ceil($list_total / $selected_pagination);
if (!$total_pages)
$total_pages = 1;
$this->context->smarty->assign(array(
'saveAction' => $this->module_instance->module_url.'&menu=csv',
'csv_data' => $selected_products_data,
'page' => $page,
'total_pages' => $total_pages,
'pagination' => $pagination,
'list_total' => $list_total,
'selected_pagination' => $selected_pagination
));
if (version_compare(_PS_VERSION_, '1.6', '>='))
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/csv_16.tpl');
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_.'admin/csv.tpl');
}
/**
* Deletes all price rules for current shop
*/
public function deleteCSV()
{
if (DpdPolandCSV::deleteAllData())
DpdPoland::addFlashMessage($this->l('Price rules deleted successfully'));
else
DpdPoland::addFlashError($this->l('Price rules could not be deleted'));
Tools::redirectAdmin($this->module_instance->module_url.'&menu=csv');
}
/**
* Generates CSV file according to saved price rules
*/
public function generateCSV()
{
$csv_data = array($this->csv_titles);
$csv_data = array_merge($csv_data, DpdPolandCSV::getCSVData());
$this->arrayToCSV($csv_data, _DPDPOLAND_CSV_FILENAME_.'.csv', _DPDPOLAND_CSV_DELIMITER_);
}
/**
* Sets CSV rules to be downloadable as CSV data
*
* @param array $array Price rules
* @param string $filename CSV file name
* @param string $delimiter CSV file delimiter
*/
private function arrayToCSV($array, $filename, $delimiter)
{
// open raw memory as file so no temp files needed, you might run out of memory though
$f = fopen('php://memory', 'w');
// loop over the input array
foreach ($array as $line)
{
// generate csv lines from the inner arrays
fputcsv($f, $line, $delimiter);
}
// rewrind the "file" with the csv lines
fseek($f, 0);
// tell the browser it's going to be a csv file
header('Content-Type: application/csv; charset=utf-8');
// tell the browser we want to save it instead of displaying it
header('Content-Disposition: attachement; filename="'.$filename.'"');
// make php send the generated csv lines to the browser
fpassthru($f);
exit;
}
/**
* Validates uploaded CSV file data
*
* @param array $csv_data CSV data
* @return array|bool Error messages | CSV data is valid
*/
public function validateCSVData($csv_data)
{
$errors = array();
if (!$this->validateCSVStructure($csv_data))
{
$errors[] = $this->l('Wrong CSV file structure or empty lines');
return $errors;
}
if (!$this->validatePLNCurrency())
{
$errors[] = $this->l('PLN currency must be installed before CSV import.');
return $errors;
}
$countries_validation = $this->validateCSVCountries($csv_data);
if ($countries_validation !== true)
{
if (!empty($countries_validation[0]))
$errors[] = $this->l('Country: country code does not exist in your PrestaShop system. Invalid lines:').' '.$countries_validation[0];
if (!empty($countries_validation[1]))
$errors[] = sprintf($this->l('Country: country "*" can be used only with carrier ID %d. Invalid lines:'), _DPDPOLAND_CLASSIC_ID_).
' '.$countries_validation[1];
if (!empty($countries_validation[2]))
$errors[] = sprintf($this->l('Country: country code PL can be used only with carrier ID %1$d or %2$d. Invalid lines:'),
_DPDPOLAND_STANDARD_ID_, _DPDPOLAND_STANDARD_COD_ID_).' '.$countries_validation[2];
if (!empty($countries_validation[3]))
$errors[] = sprintf($this->l('Country: international shipping is compatible only with carrier ID %d. Invalid lines:'),
_DPDPOLAND_CLASSIC_ID_).' '.$countries_validation[3];
}
$price_from_validation = $this->validateCSVPriceFrom($csv_data);
if ($price_from_validation !== true)
$errors[] = $this->l('Price (From): invalid lines:').' '.$price_from_validation;
$price_to_validation = $this->validateCSVPriceTo($csv_data);
if ($price_to_validation !== true)
$errors[] = $this->l('Price (To): invalid lines:').' '.$price_to_validation;
$weight_from_validation = $this->validateCSVWeightFrom($csv_data);
if ($weight_from_validation !== true)
$errors[] = $this->l('Weight (From): invalid lines:').' '.$weight_from_validation;
$weight_to_validation = $this->validateCSVWeightTo($csv_data);
if ($weight_to_validation !== true)
$errors[] = $this->l('Weight (To): invalid lines:').' '.$weight_to_validation;
$parcel_prices_validation = $this->validateCSVParcelPrices($csv_data);
if ($parcel_prices_validation !== true)
$errors[] = $this->l('Parcel price (PLN): invalid lines:').' '.$parcel_prices_validation;
$carrier_validation = $this->validateCSVCarriers($csv_data);
if ($carrier_validation !== true)
$errors[] = $this->l('Carrier: invalid lines:').' '.$carrier_validation;
$cod_price = $this->validateCSVCODPrice($csv_data);
if ($cod_price !== true)
{
if (!empty($cod_price[0]))
$errors[] = $this->l('COD cost (PLN): Value should be >=0. Invalid lines:').' '.$cod_price[0];
if (!empty($cod_price[1]))
$errors[] = $this->l('COD cost (PLN): It\'s possible to use COD only with "DPD domestic shipment - Standard with COD". Leave empty COD field otherwise. Invalid lines:').' '.$cod_price[1];
if (!empty($cod_price[2]))
$errors[] = $this->l('COD cost (PLN): COD is available only in Poland. Leave empty COD field otherwise. Invalid lines:').' '.$cod_price[2];
}
if (!empty($errors))
return $errors;
return true;
}
/**
* Checks if PLN currency is installed
*
* @return bool PLN currency exists in PrestaShop
*/
private function validatePLNCurrency()
{
return (bool)Currency::getIdByIsoCode('PLN');
}
/**
* Checks if CSV file structure is valid
*
* @param array $csv_data CSV data
* @return bool CSV file structure is valid
*/
private function validateCSVStructure($csv_data)
{
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++)
if (!isset($csv_data[$i][DpdPolandCSV::COLUMN_COD_PRICE]))
return false;
return true;
}
/**
* Validates country column in CSV data
*
* @param array $csv_data CSV data
* @return array|bool Countries are valid
*/
private function validateCSVCountries($csv_data)
{
$csv_data_count = count($csv_data); //number of CSV data lines without titles
$wrong_countries = '';
$wrong_star_countries = '';
$wrong_pl_countries = '';
$wrong_not_pl_countries = '';
for ($i = 0; $i < $csv_data_count; $i++)
{
$country_validation = $this->validateCSVCountry($csv_data[$i][DpdPolandCSV::COLUMN_COUNTRY], $csv_data[$i][DpdPolandCSV::COLUMN_CARRIER]);
if ($country_validation !== true)
{
switch ($country_validation)
{
case self::STAR_COUNTRY_ERROR:
$wrong_star_countries .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
break;
case self::PRESTASHOP_COUNTRY_ERROR:
$wrong_countries .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
break;
case self::PL_COUNTRY_ERROR:
$wrong_pl_countries .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
break;
case self::NOT_PL_COUNTRY_ERROR:
$wrong_not_pl_countries .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
break;
default:
break;
}
}
}
if (!empty($wrong_countries))
$wrong_countries = Tools::substr($wrong_countries, 0, -2); //remove last two symbols (comma & space)
if (!empty($wrong_star_countries))
$wrong_star_countries = Tools::substr($wrong_star_countries, 0, -2); //remove last two symbols (comma & space)
if (!empty($wrong_pl_countries))
$wrong_pl_countries = Tools::substr($wrong_pl_countries, 0, -2); //remove last two symbols (comma & space)
if (!empty($wrong_not_pl_countries))
$wrong_not_pl_countries = Tools::substr($wrong_not_pl_countries, 0, -2); //remove last two symbols (comma & space)
return empty($wrong_countries) && empty($wrong_star_countries) && empty($wrong_pl_countries) && empty($wrong_not_pl_countries) ? true :
array($wrong_countries, $wrong_star_countries, $wrong_pl_countries, $wrong_not_pl_countries);
}
/**
* Validates CSV rule country
*
* @param string $iso_code Country ISO code
* @param int $id_carrier Carrier ID
* @return bool|int Country is valid
*/
private function validateCSVCountry($iso_code, $id_carrier)
{
if ($iso_code === '*')
if ($id_carrier == _DPDPOLAND_CLASSIC_ID_)
return true;
else
return self::STAR_COUNTRY_ERROR;
if (!Country::getByIso($iso_code))
return self::PRESTASHOP_COUNTRY_ERROR;
if ($iso_code == self::POLAND_ISO_CODE)
if ($id_carrier == _DPDPOLAND_STANDARD_ID_ ||
$id_carrier == _DPDPOLAND_STANDARD_COD_ID_ ||
$id_carrier == _DPDPOLAND_PUDO_ID_)
return true;
else
return self::PL_COUNTRY_ERROR;
else
if ($id_carrier == _DPDPOLAND_CLASSIC_ID_)
return true;
else
return self::NOT_PL_COUNTRY_ERROR;
}
/**
* Validates Price From field
*
* @param array $csv_data CSV file data
* @return bool|string Price From field is valid
*/
private function validateCSVPriceFrom($csv_data)
{
$wrong_prices = '';
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++)
if (!Validate::isFloat($csv_data[$i][DpdPolandCSV::COLUMN_PRICE_FROM]) ||
$csv_data[$i][DpdPolandCSV::COLUMN_PRICE_FROM] < 0)
$wrong_prices .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
if (!empty($wrong_prices))
$wrong_prices = Tools::substr($wrong_prices, 0, -2); //remove last two symbols (comma & space)
return empty($wrong_prices) ? true : $wrong_prices;
}
/**
* Validates Price To field
*
* @param array $csv_data CSV file data
* @return bool|string Price To field is valid
*/
private function validateCSVPriceTo($csv_data)
{
$wrong_prices = '';
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++)
if (!Validate::isFloat($csv_data[$i][DpdPolandCSV::COLUMN_PRICE_TO]) ||
$csv_data[$i][DpdPolandCSV::COLUMN_PRICE_TO] <= 0 ||
$csv_data[$i][DpdPolandCSV::COLUMN_PRICE_TO] < $csv_data[$i][DpdPolandCSV::COLUMN_PRICE_FROM])
$wrong_prices .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
if (!empty($wrong_prices))
$wrong_prices = Tools::substr($wrong_prices, 0, -2); //remove last two symbols (comma & space)
return empty($wrong_prices) ? true : $wrong_prices;
}
/**
* Validates Weight From field
*
* @param array $csv_data CSV file data
* @return bool|string Weight From field is valid
*/
private function validateCSVWeightFrom($csv_data)
{
$wrong_weights = '';
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++)
if (!Validate::isFloat($csv_data[$i][DpdPolandCSV::COLUMN_WEIGHT_FROM]) ||
$csv_data[$i][DpdPolandCSV::COLUMN_WEIGHT_FROM] < 0)
$wrong_weights .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
if (!empty($wrong_weights))
$wrong_weights = Tools::substr($wrong_weights, 0, -2); //remove last two symbols (comma & space)
return empty($wrong_weights) ? true : $wrong_weights;
}
/**
* Validates Weight To field
*
* @param array $csv_data CSV file data
* @return bool|string Weight To field is valid
*/
private function validateCSVWeightTo($csv_data)
{
$wrong_weights = '';
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++)
if (!Validate::isFloat($csv_data[$i][DpdPolandCSV::COLUMN_WEIGHT_TO]) ||
$csv_data[$i][DpdPolandCSV::COLUMN_WEIGHT_TO] <= 0 ||
$csv_data[$i][DpdPolandCSV::COLUMN_WEIGHT_TO] < $csv_data[$i][DpdPolandCSV::COLUMN_WEIGHT_FROM])
$wrong_weights .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
if (!empty($wrong_weights))
$wrong_weights = Tools::substr($wrong_weights, 0, -2); //remove last two symbols (comma & space)
return empty($wrong_weights) ? true : $wrong_weights;
}
/**
* Validates carrier price field
*
* @param array $csv_data CSV file data
* @return bool|string carrier price field is valid
*/
private function validateCSVParcelPrices($csv_data)
{
$wrong_prices = '';
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++)
if (!Validate::isFloat($csv_data[$i][DpdPolandCSV::COLUMN_PARCEL_PRICE]) ||
$csv_data[$i][DpdPolandCSV::COLUMN_PARCEL_PRICE] < 0)
$wrong_prices .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
if (!empty($wrong_prices))
$wrong_prices = Tools::substr($wrong_prices, 0, -2); //remove last two symbols (comma & space)
return empty($wrong_prices) ? true : $wrong_prices;
}
/**
* Validates carrier ID field
*
* @param array $csv_data CSV file data
* @return bool|string Carrier ID field is valid
*/
private function validateCSVCarriers($csv_data)
{
$available_methods = array(_DPDPOLAND_STANDARD_ID_, _DPDPOLAND_STANDARD_COD_ID_, _DPDPOLAND_CLASSIC_ID_, _DPDPOLAND_PUDO_ID_);
$wrong_methods = '';
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++)
if (!in_array($csv_data[$i][DpdPolandCSV::COLUMN_CARRIER], $available_methods) && $csv_data[$i][DpdPolandCSV::COLUMN_CARRIER] !== '*')
$wrong_methods .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
if (!empty($wrong_methods))
$wrong_methods = Tools::substr($wrong_methods, 0, -2); //remove last two symbols (comma & space)
return empty($wrong_methods) ? true : $wrong_methods;
}
/**
* Validates COD additional price field
*
* @param array $csv_data CSV file data
* @return array|bool COD additional price field is valid
*/
private function validateCSVCODPrice($csv_data)
{
$wrong_price = '';
$wrong_price_method = '';
$wrong_price_country = '';
$csv_data_count = count($csv_data);
for ($i = 0; $i < $csv_data_count; $i++)
{
if (!empty($csv_data[$i][DpdPolandCSV::COLUMN_COD_PRICE]))
{
if (!Validate::isFloat($csv_data[$i][DpdPolandCSV::COLUMN_COD_PRICE]) ||
$csv_data[$i][DpdPolandCSV::COLUMN_COD_PRICE] < 0)
$wrong_price .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
else
{
if ($csv_data[$i][DpdPolandCSV::COLUMN_CARRIER] != _DPDPOLAND_STANDARD_COD_ID_)
$wrong_price_method .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
if ($csv_data[$i][DpdPolandCSV::COLUMN_COUNTRY] !== self::POLAND_ISO_CODE)
$wrong_price_country .= ($i + self::DEFAULT_FIRST_LINE_INDEX).', ';
}
}
}
if (!empty($wrong_price))
$wrong_price = Tools::substr($wrong_price, 0, -2); //remove last two symbols (comma & space)
if (!empty($wrong_price_method))
$wrong_price_method = Tools::substr($wrong_price_method, 0, -2); //remove last two symbols (comma & space)
if (!empty($wrong_price_country))
$wrong_price_country = Tools::substr($wrong_price_country, 0, -2); //remove last two symbols (comma & space)
return empty($wrong_price) && empty($wrong_price_method) && empty($wrong_price_country) ? true :
array($wrong_price, $wrong_price_method, $wrong_price_country);
}
/**
* Checks if uploaded file has no errors and if extension is 'csv'.
*
* @param string $file_name File name
* @return bool Uploaded file is valid
*/
private function isUploadedCsvValid($file_name)
{
if (!isset($_FILES[$file_name]))
return false;
if (!empty($_FILES[$file_name]['error']))
return false;
if (!preg_match('/.*\.csv$/i', $_FILES[$file_name]['name']))
return false;
return true;
}
/**
* Reads CSV file line by line and collects it's data
*
* @return array|bool CSV file content
*/
public function readCSVData()
{
if (!$this->isUploadedCsvValid(DpdPolandCSV::CSV_FILE))
return false;
$csv_data = array();
$row = 0;
if (($handle = fopen($_FILES[DpdPolandCSV::CSV_FILE]['tmp_name'], 'r')) !== false) {
while (($data = fgetcsv($handle, 1000, _DPDPOLAND_CSV_DELIMITER_)) !== false) {
if (!$data) {
continue;
}
$csv_data_line = array();
$row++;
if ($row == 1) {
continue;
}
$num = count($data);
$row++;
for ($i = 0; $i < $num; $i++) {
$csv_data_line[] = $data[$i];
}
$csv_data[] = $csv_data_line;
}
fclose($handle);
}
return $csv_data;
}
/**
* Saves price rules into database
*
* @param array $csv_data Valid CSV data
* @return bool Price rules saved successfully
*/
public function saveCSVData($csv_data)
{
if (!DpdPolandCSV::deleteAllData()) {
return false;
}
foreach ($csv_data as $data)
{
$csv_obj = new DpdPolandCSV();
$csv_obj->id_shop = (int)$this->context->shop->id;
$csv_obj->iso_country = $data[DpdPolandCSV::COLUMN_COUNTRY];
$csv_obj->price_from = $data[DpdPolandCSV::COLUMN_PRICE_FROM];
$csv_obj->price_to = $data[DpdPolandCSV::COLUMN_PRICE_TO];
$csv_obj->weight_from = $data[DpdPolandCSV::COLUMN_WEIGHT_FROM];
$csv_obj->weight_to = $data[DpdPolandCSV::COLUMN_WEIGHT_TO];
$csv_obj->parcel_price = $data[DpdPolandCSV::COLUMN_PARCEL_PRICE];
$csv_obj->id_carrier = $data[DpdPolandCSV::COLUMN_CARRIER];
$csv_obj->cod_price = $data[DpdPolandCSV::COLUMN_COD_PRICE];
if (!$csv_obj->save()) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,120 @@
<?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 DpdPolandCarrierClassicService Responsible for specific DPD service (carrier) management
*/
class DpdPolandCarrierClassicService extends DpdPolandService
{
/**
* Current file name
*/
const FILENAME = 'dpd_classic.service';
/**
* Installs specific DPD service (carrier)
*
* @return bool Carrier installed successfully
*/
public static function install()
{
$id_carrier = (int)Configuration::get(DpdPolandConfiguration::CARRIER_CLASSIC_ID);
$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_classic = new DpdPolandCarrierClassicService();
$carrier = new Carrier();
$carrier->name = $carrier_classic->module_instance->l('DPD international shipment (DPD Classic)', 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_classic->module_instance->name;
$carrier->url = _DPDPOLAND_TRACKING_URL_;
$delay = array();
foreach (Language::getLanguages(false) as $language)
$delay[$language['id_lang']] = $carrier_classic->module_instance->l('DPD international shipment (DPD Classic)', 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_.DpdPolandCarrierClassicService::IMG_DIR.'/'._DPDPOLAND_CLASSIC_ID_.'.'.
DpdPolandCarrierClassicService::IMG_EXTENSION, _PS_SHIP_IMG_DIR_.'/'.(int)$carrier->id.'.jpg'))
return false;
$range_obj = $carrier->getRangeObject();
$range_obj->id_carrier = (int)$carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->save())
return false;
if (!self::assignCustomerGroupsForCarrier($carrier))
return false;
if (!Configuration::updateValue(DpdPolandConfiguration::CARRIER_CLASSIC_ID, (int)$carrier->id))
return false;
return true;
}
/**
* Deletes DPD carrier
*
* @return bool DPD carrier deleted successfully
*/
public static function delete()
{
return (bool)self::deleteCarrier((int)Configuration::get(DpdPolandConfiguration::CARRIER_CLASSIC_ID));
}
}

View File

@@ -0,0 +1,120 @@
<?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_carrier = (int)Configuration::get(DpdPolandConfiguration::CARRIER_PUDO_ID);
$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;
$range_obj = $carrier->getRangeObject();
$range_obj->id_carrier = (int)$carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->save())
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()
{
return (bool)self::deleteCarrier((int)Configuration::get(DpdPolandConfiguration::CARRIER_PUDO_ID));
}
}

View File

@@ -0,0 +1,120 @@
<?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_carrier = (int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_ID);
$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;
$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;
$range_obj = $carrier->getRangeObject();
$range_obj->id_carrier = (int)$carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->save())
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()
{
return (bool)self::deleteCarrier((int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_ID));
}
}

View File

@@ -0,0 +1,120 @@
<?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_carrier = (int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID);
$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;
$range_obj = $carrier->getRangeObject();
$range_obj->id_carrier = (int)$carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->save())
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()
{
return (bool)self::deleteCarrier((int)Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID));
}
}

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,586 @@
<?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 Parcels data used for WebServices
*/
private $parcels = array();
/**
* @var array Services data used for WebServices
*/
private $services = array();
/**
* @var array Sender data used for WebServices
*/
private $sender = array();
/**
* @var array Receiver data used for WebServices
*/
private $receiver = array();
/**
* Sets parcels data
*
* @param array $parcel Parcel data
* @param string $additional_info Additional shipment info
*/
public function addParcel($parcel, $additional_info)
{
$parcel = array(
'content' => $parcel['content'],
'customerData1' => $additional_info,
'customerData2' => null,
'customerData3' => null,
'reference' => Tools::strtoupper(Tools::passwdGen(9, 'NO_NUMERIC')).'_'.(int)$parcel['number'],
'sizeX' => (float)$parcel['length'],
'sizeY' => (float)$parcel['width'],
'sizeZ' => (float)$parcel['height'],
'weight' => (float)$parcel['weight']
);
$this->parcels[] = $parcel;
}
/**
* 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 DpdPolandPackage $package_obj Package object
* @return bool Package created successfully
*/
public function create(DpdPolandPackage $package_obj)
{
if ($result = $this->createRemotely($package_obj))
{
if (isset($result['Status']) && $result['Status'] == 'OK')
{
$package = $result['Packages']['Package'];
$package_obj->id_package_ws = (int)$package['PackageId'];
$package_obj->sessionId = (int)$result['SessionId'];
if (!$package_obj->save())
self::$errors[] = $this->l('Package was successfully created but we were unable to save its data locally');
return $package;
}
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 DpdPolandPackage $package_obj Package object
* @param string $payerType Payer type
* @return bool Package created successfully
*/
private function createRemotely(DpdPolandPackage $package_obj, $payerType = 'THIRD_PARTY')
{
if (!$this->prepareReceiverAddress($package_obj))
return false;
$payer_number = Tools::getValue('dpdpoland_PayerNumber');
$this->prepareSenderAddress($package_obj->id_sender_address);
$this->prepareServicesData($package_obj);
$params = array(
'openUMLFeV3' => array(
'packages' => array(
'parcels' => $this->parcels,
'payerType' => $payerType,
'thirdPartyFID' => $payer_number,
'receiver' => $this->receiver,
'ref1' => $package_obj->ref1,
'ref2' => $package_obj->ref2,
'ref3' => _DPDPOLAND_REFERENCE3_,
'reference' => null,
'sender' => $this->sender,
'services' => $this->services,
)
),
'pkgNumsGenerationPolicyV1' => 'STOP_ON_FIRST_ERROR',
'langCode' => 'PL'
);
return $this->generatePackagesNumbersV4($params);
}
/**
* Formats receiver address and prepares it to be used via WebServices
*
* @param DpdPolandPackage $package_obj Package object
* @return bool Receiver address prepared without errors
*/
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))
{
$this->receiver = array(
'address' => $address->address1.' '.$address->address2,
'city' => $address->city,
'company' => $address->company,
'countryCode' => Country::getIsoById((int)$address->id_country),
'email' => $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);
$this->sender = 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)
{
if ($package_obj->cod_amount !== null)
{
$this->services['cod'] = array(
'amount' => $package_obj->cod_amount,
'currency' => _DPDPOLAND_CURRENCY_ISO_
);
}
if ($package_obj->declaredValue_amount !== null)
{
$this->services['declaredValue'] = array(
'amount' => $package_obj->declaredValue_amount,
'currency' => _DPDPOLAND_CURRENCY_ISO_
);
}
if ($package_obj->cud)
{
$this->services['cud'] = 1;
}
if ($package_obj->rod)
{
$this->services['rod'] = 1;
}
if ($package_obj->dpde)
{
$this->services['dpdExpress'] = 1;
}
if ($package_obj->dpdnd)
{
$this->services['guarantee'] = array('type' => 'DPDNEXTDAY');
}
if ($package_obj->duty)
{
$this->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);
// First get pudo carrier id
$id_pudo_carrier = Configuration::get(DpdPolandConfiguration::CARRIER_PUDO_ID);
if (version_compare(_PS_VERSION_, '1.5', '<')) {
$id_order_carrier = (int)DpdPolandCarrier::getReferenceByIdCarrier((int)$order->id_carrier);
} else {
$carrier = new Carrier($order->id_carrier);
$id_order_carrier = $carrier->id_reference;
}
// Check if order has pudo service as carrier
if ($id_order_carrier == $id_pudo_carrier && Tools::getValue('dpdpoland_SessionType') == 'pudo') {
// 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.'
');
if ($pudoCode) {
$this->services['dpdPickup'] = array(
'pudo' => $pudoCode,
);
}
}
}
/**
* 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)
$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'])) {
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');
$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,345 @@
<?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');
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,335 @@
#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_cod_amount_container,
#dpdpoland_additional_info_container,
#dpdpoland_shipment_references_container,
#dpdpoland_declared_value_amount_container {
width: 420px;
}
.dpdpoland-ps16 #dpdpoland_recipient_address_container,
.dpdpoland-ps16 #dpdpoland_sender_address_container,
.dpdpoland-ps16 #dpdpoland_declared_value_amount_container label,
.dpdpoland-ps16 #dpdpoland_cod_amount_container label,
.dpdpoland-ps16 #dpdpoland_additional_info_container label
{
width: auto;
}
.dpdpoland-ps16 #dpdpoland_cod_amount_container,
.dpdpoland-ps16 #dpdpoland_declared_value_amount_container,
.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,
#dpdpoland_additional_info_container {
float: left;
}
#dpdpoland_declared_value_amount_container,
#dpdpoland_shipment_references_container {
float: right;
}
#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 span,
#dpdpoland_declared_value_amount_container span {
font-weight: bold;
}
#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;
}

View File

@@ -0,0 +1,261 @@
.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,4 @@
.pudo-map-container
{
display: 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;
}

View File

@@ -0,0 +1,120 @@
<?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.
*/
include_once(dirname(__FILE__).'/../../config/config.inc.php');
if (version_compare(_PS_VERSION_, '1.5', '<')) {
include_once(dirname(__FILE__).'/../../init.php');
}
/** @var DpdPoland $module_instance */
$module_instance = Module::getInstanceByName('dpdpoland');
if (!Tools::isSubmit('token') || (Tools::isSubmit('token')) && Tools::getValue('token') != sha1(_COOKIE_KEY_.$module_instance->name)) exit;
if (Tools::isSubmit('save_pudo_id')) {
echo $module_instance->savePudoMapCode();
exit;
}
if (Tools::isSubmit('getFormattedAddressHTML'))
{
$id_address = (int)Tools::getValue('id_address');
echo $module_instance->getFormattedAddressHTML($id_address);
exit;
}
if (Tools::isSubmit('getFormattedSenderAddressHTML'))
{
$id_address = (int)Tools::getValue('id_address');
echo $module_instance->getFormattedSenderAddressHTML($id_address);
exit;
}
if (Tools::isSubmit('getProducts'))
{
echo Tools::jsonEncode($module_instance->searchProducts(Tools::getValue('q')));
exit;
}
if (Tools::isSubmit('savePackagePrintLabels'))
{
if (!$id_package_ws = $module_instance->savePackageFromPost())
{
die(Tools::jsonEncode(array(
'error' => reset(DpdPoland::$errors)
)));
}
$printout_format = Tools::getValue('dpdpoland_printout_format');
if ($printout_format != DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL && $printout_format != DpdPolandConfiguration::PRINTOUT_FORMAT_A4)
$printout_format = DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL;
die(Tools::jsonEncode(array(
'error' => false,
'id_package_ws' => (int)$id_package_ws,
'link_to_labels_pdf' => '?printLabels&id_package_ws='.(int)$id_package_ws.'&printout_format='.$printout_format.'&token='.Tools::getValue('token')
)));
}
if (Tools::isSubmit('printLabels'))
{
$printout_format = Tools::getValue('dpdpoland_printout_format');
if ($printout_format != DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL && $printout_format != DpdPolandConfiguration::PRINTOUT_FORMAT_A4)
$printout_format = DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL;
die(Tools::jsonEncode(array(
'error' => false,
'link_to_labels_pdf' => '?printLabels&id_package_ws='.(int)Tools::getValue('id_package_ws').
'&printout_format='.$printout_format.'&token='.Tools::getValue('token')
)));
}
if (Tools::getValue('addDPDClientNumber'))
{
$result = $module_instance->addDPDClientNumber();
die(Tools::jsonEncode($result));
}
if (Tools::getValue('deleteDPDClientNumber'))
{
$result = $module_instance->deleteDPDClientNumber();
die(Tools::jsonEncode($result));
}
if (Tools::getValue('getPayerNumbersTableHTML'))
{
$html = $module_instance->getPayerNumbersTableHTML();
die(Tools::jsonEncode($html));
}
if (Tools::getValue('calculateTimeLeft'))
{
$time_left = $module_instance->calculateTimeLeft();
die(Tools::jsonEncode($time_left));
}
if (Tools::getValue('getTimeFrames'))
{
$html = $module_instance->getTimeFrames();
die(Tools::jsonEncode($html));
}

View File

@@ -0,0 +1,149 @@
<?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 DpdPolandLanguage Responsible for DPD module error messages translations
*/
class DpdPolandLanguage
{
const FILENAME = 'dpdpoland.lang';
private $translations = array();
private $module_instance;
/**
* DpdPolandLanguage class constructor
*/
public function __construct()
{
$this->module_instance = Module::getInstanceByName('dpdpoland');
$this->translations = array(
'1002' => $this->module_instance->l('ERROR_INCORRECT_WEIGHT_FOR_COUNTRY', self::FILENAME),
'1003' => $this->module_instance->l('ERROR_INCORRECT_PARCELS_COUNT_FOR_DOX', self::FILENAME),
'1004' => $this->module_instance->l('ERROR_GUARANTEE_TIMEFIXED_OUT_OF_RANGE', self::FILENAME),
'1005' => $this->module_instance->l('ERROR_DECLARED_VALUE_AMOUNT_OUT_OF_RANGE', self::FILENAME),
'1008' => $this->module_instance->l('ERROR_COD_AMOUNT_OUT_OF_RANGE', self::FILENAME),
'1009' => $this->module_instance->l('ERROR_INCORRECT_COD_CURRENCY_FOR_PL', self::FILENAME),
'1011' => $this->module_instance->l('ERROR_INCORRECT_WEIGHT', self::FILENAME),
'1013' => $this->module_instance->l('ERROR_PALLET_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1014' => $this->module_instance->l('ERROR_DUTY_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1015' => $this->module_instance->l('ERROR_CARRY_IN_NOT_AVAILABLE_FOR_PAYER_FID', self::FILENAME),
'1016' => $this->module_instance->l('ERROR_COD_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1017' => $this->module_instance->l('ERROR_ROD_NOT_AVAILBLE_FOR_COUNTRY', self::FILENAME),
'1018' => $this->module_instance->l('ERROR_CUD_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1019' => $this->module_instance->l('ERROR_CARRY_IN_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1020' => $this->module_instance->l('ERROR_IN_PERS_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1021' => $this->module_instance->l('ERROR_PRIV_PERS_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1022' => $this->module_instance->l('ERROR_DOX_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1023' => $this->module_instance->l('ERROR_SELF_COL_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1024' => $this->module_instance->l('ERROR_GUARANTEE_TIME0930_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1025' => $this->module_instance->l('ERROR_GUARANTEE_TIME1200_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1026' => $this->module_instance->l('ERROR_GUARANTEE_TIMEFIXED_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1028' => $this->module_instance->l('ERROR_GUARANTEE_SATURDAY_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1030' => $this->module_instance->l('ERROR_GUARANTEE_B2C_NOT_AVAILABLE_FOR_COUNTRY', self::FILENAME),
'1032' => $this->module_instance->l('ERROR_GUARANTEE_TIME0930_NOT_AVAILABLE_FOR_POSTAL_CODE', self::FILENAME),
'1033' => $this->module_instance->l('ERROR_GUARANTEE_TIME1200_NOT_AVAILABLE_FOR_POSTAL_CODE', self::FILENAME),
'1034' => $this->module_instance->l('ERROR_GUARANTEE_INTER_NOT_AVAILABLE_FOR_POSTAL_CODE', self::FILENAME),
'1036' => $this->module_instance->l('ERROR_PALLET_NOT_AVAILABLE_FOR_POSTAL_CODE', self::FILENAME),
'1037' => $this->module_instance->l('ERROR_CARRYIN_NOT_AVAILABLE_FOR_POSTAL_CODE', self::FILENAME),
'1038' => $this->module_instance->l('ERROR_GUARANTEE_B2C_NOT_AVAILABLE_FOR_PAYER_FID', self::FILENAME),
'1039' => $this->module_instance->l('ERROR_INCORRECT_GUARANTEE_B2C_RANGE', self::FILENAME),
'1042' => $this->module_instance->l('ERROR_INCORRECT_PAYMENT_TYPE', self::FILENAME),
'1043' => $this->module_instance->l('ERROR_INCORRECT_PARCELS_COUNT_FOR_CARRYIN', self::FILENAME),
'1044' => $this->module_instance->l('ERROR_INCORRECT_WEIGHT_FOR_CARRYIN', self::FILENAME),
'1045' => $this->module_instance->l('ERROR_PARCEL_SIZE_X_OUT_OF_RANGE', self::FILENAME),
'1046' => $this->module_instance->l('ERROR_PARCEL_SIZE_Y_OUT_OF_RANGE', self::FILENAME),
'1047' => $this->module_instance->l('ERROR_PARCEL_SIZE_Z_OUT_OF_RANGE', self::FILENAME),
'1048' => $this->module_instance->l('ERROR_PARCEL_SIZES_EXCEEDED_DIMENISIONS_80X120X180', self::FILENAME),
'1049' => $this->module_instance->l('ERROR_INT_PARCEL_SIZES_EXCEEDED_300', self::FILENAME),
'1051' => $this->module_instance->l('ERROR_PARCEL_SIZES_EXCEEDED_300', self::FILENAME),
'1052' => $this->module_instance->l('ERROR_PARCEL_CAPACITY_EXCEEDED', self::FILENAME),
'1053' => $this->module_instance->l('ERROR_PARCEL_SIZE_X_EXCEEDED', self::FILENAME),
'1054' => $this->module_instance->l('ERROR_PARCEL_SIZE_Y_EXCEEDED', self::FILENAME),
'1055' => $this->module_instance->l('ERROR_PARCEL_SIZE_Z_EXCEEDED', self::FILENAME),
'1056' => $this->module_instance->l('ERROR_RECEIVER_NAME_MAX_SIZE_EXCEEDED', self::FILENAME),
'1057' => $this->module_instance->l('ERROR_RECEIVER_COMPANY_MAX_SIZE_EXCEEDED', self::FILENAME),
'1058' => $this->module_instance->l('ERROR_RECEIVER_ADDRESS_MAX_SIZE_EXCEEDED', self::FILENAME),
'1059' => $this->module_instance->l('ERROR_RECEIVER_CITY_MAX_SIZE_EXCEEDED', self::FILENAME),
'1060' => $this->module_instance->l('ERROR_RECEIVER_EMAIL_MAX_SIZE_EXCEEDED', self::FILENAME),
'1061' => $this->module_instance->l('ERROR_RECEIVER_PHONE_MAX_SIZE_EXCEEDED', self::FILENAME),
'1062' => $this->module_instance->l('ERROR_EMPTY_RECEIVER_ADDRESS', self::FILENAME),
'1063' => $this->module_instance->l('ERROR_EMPTY_RECEIVER_CITY', self::FILENAME),
'1064' => $this->module_instance->l('ERROR_EMPTY_RECEIVER_NAME_AND_COMPANY', self::FILENAME),
'1065' => $this->module_instance->l('ERROR_SENDER_NAME_MAX_SIZE_EXCEEDED', self::FILENAME),
'1066' => $this->module_instance->l('ERROR_SENDER_COMPANY_MAX_SIZE_EXCEEDED', self::FILENAME),
'1067' => $this->module_instance->l('ERROR_SENDER_ADDRESS_MAX_SIZE_EXCEEDED', self::FILENAME),
'1068' => $this->module_instance->l('ERROR_SENDER_CITY_MAX_SIZE_EXCEEDED', self::FILENAME),
'1069' => $this->module_instance->l('ERROR_SENDER_EMAIL_MAX_SIZE_EXCEEDED', self::FILENAME),
'1070' => $this->module_instance->l('ERROR_SENDER_PHONE_MAX_SIZE_EXCEEDED', self::FILENAME),
'1071' => $this->module_instance->l('ERROR_EMPTY_SENDER_ADDRESS', self::FILENAME),
'1072' => $this->module_instance->l('ERROR_EMPTY_SENDER_CITY', self::FILENAME),
'1073' => $this->module_instance->l('ERROR_EMPTY_SENDER_NAME_AND_COMPANY', self::FILENAME),
'1074' => $this->module_instance->l('ERROR_REF1_MAX_SIZE_EXCEEDED', self::FILENAME),
'1075' => $this->module_instance->l('ERROR_REF2_MAX_SIZE_EXCEEDED', self::FILENAME),
'1076' => $this->module_instance->l('ERROR_REF3_MAX_SIZE_EXCEEDED', self::FILENAME),
'1077' => $this->module_instance->l('ERROR_PARCEL_CONTENT_MAX_SIZE_EXCEEDED', self::FILENAME),
'1078' => $this->module_instance->l('ERROR_PARCEL_CUSTOMER_DATA1_MAX_SIZE_EXCEEDED', self::FILENAME),
'1079' => $this->module_instance->l('ERROR_PARCEL_CUSTOMER_DATA2_MAX_SIZE_EXCEEDED', self::FILENAME),
'1080' => $this->module_instance->l('ERROR_PARCEL_CUSTOMER_DATA3_MAX_SIZE_EXCEEDED', self::FILENAME),
'1081' => $this->module_instance->l('ERROR_INCORRECT_SENDER_COUNTRY', self::FILENAME),
'1082' => $this->module_instance->l('ERROR_INCORRECT_RECEIVER_COUNTRY', self::FILENAME),
'1085' => $this->module_instance->l('ERROR_GUARANTEE_TIMEFIXED_INCORRECT_FORMAT', self::FILENAME),
'1086' => $this->module_instance->l('ERROR_CARRY_IN_FOR_GABARIT_WEIGHT', self::FILENAME),
'1087' => $this->module_instance->l('ERROR_IN_PERS_REQUIRES_RECEIVER_NAME', self::FILENAME),
'1088' => $this->module_instance->l('ERROR_PALLET_INCORRECT_FOR_WEIGHT', self::FILENAME),
'1110' => $this->module_instance->l('ERROR_SIZE_X_OUT_OF_RANGE', self::FILENAME),
'1111' => $this->module_instance->l('ERROR_SIZE_Y_OUT_OF_RANGE', self::FILENAME),
'1112' => $this->module_instance->l('ERROR_SIZE_Z_OUT_OF_RANGE', self::FILENAME),
'2005' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_CUD_EXCLUDING', self::FILENAME),
'2006' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_CARRY_IN_EXCLUDING', self::FILENAME),
'2007' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_COD_EXCLUDING', self::FILENAME),
'2008' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_DECL_VALUE_EXCLUDING', self::FILENAME),
'2009' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_DOX_EXCLUDING', self::FILENAME),
'2010' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_DUTY_EXCLUDING', self::FILENAME),
'2011' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_IN_PERS_EXCLUDING', self::FILENAME),
'2012' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_PALLET_EXCLUDING', self::FILENAME),
'2013' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_PRIV_PERS_EXCLUDING', self::FILENAME),
'2014' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_ROD_EXCLUDING', self::FILENAME),
'2015' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_SELF_COL_EXCLUDING', self::FILENAME),
'2016' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_TIME0930_EXCLUDING', self::FILENAME),
'2017' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_TIME1200_EXCLUDING', self::FILENAME),
'2018' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_TIMEFIXED_EXCLUDING', self::FILENAME),
'2019' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_OVERTIME2_EXCLUDING', self::FILENAME),
'2020' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_B2C_EXCLUDING', self::FILENAME),
'2021' => $this->module_instance->l('ERROR_DEDICATED_DELIVERY_TIRES_EXCLUDING', self::FILENAME)
);
}
/**
* Returns translated error message according to error code
*
* @param int $id_translation Error code from WebServices
* @return mixed|string Error message
*/
public function getTranslation($id_translation)
{
if (isset($this->translations[(int)$id_translation]))
return $this->translations[(int)$id_translation];
return '';
}
}

View File

@@ -0,0 +1,75 @@
<?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.
*/
include_once(dirname(__FILE__).'/../../config/config.inc.php');
include_once(dirname(__FILE__).'/../../init.php');
$module_instance = Module::getInstanceByName('dpdpoland');
if (!Tools::isSubmit('token') || (Tools::isSubmit('token')) && Tools::getValue('token') != sha1(_COOKIE_KEY_.$module_instance->name)) exit;
if (Tools::isSubmit('printLabels'))
{
$cookie = new Cookie(_DPDPOLAND_COOKIE_);
if (isset($cookie->dpdpoland_package_id))
{
$package_id = $cookie->dpdpoland_package_id;
$printout_format = $cookie->dpdpoland_printout_format;
unset($cookie->dpdpoland_package_id);
unset($cookie->dpdpoland_printout_format);
$cookie->write();
$package = new DpdPolandPackage((int)$package_id);
$pdf_file_contents = $package->generateLabels('PDF', $printout_format);
ob_end_clean();
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="package_labels_'.(int)Tools::getValue('id_package_ws').'.pdf"');
echo $pdf_file_contents;
exit;
}
$package = new DpdPolandPackage((int)Tools::getValue('id_package_ws'));
if ($pdf_file_contents = $package->generateLabels())
{
$cookie->dpdpoland_package_id = (int)Tools::getValue('id_package_ws');
$printout_format = Tools::getValue('printout_format');
if (!in_array($printout_format, array(DpdPolandConfiguration::PRINTOUT_FORMAT_A4, DpdPolandConfiguration::PRINTOUT_FORMAT_LABEL)))
$printout_format = DpdPolandConfiguration::PRINTOUT_FORMAT_A4;
$cookie->dpdpoland_printout_format = $printout_format;
Tools::redirectAdmin(Tools::getValue('returnOnErrorTo').'&scrollToShipment');
exit;
}
else
{
DpdPoland::addFlashError(reset(DpdPolandPackageWS::$errors));
Tools::redirectAdmin(Tools::getValue('returnOnErrorTo').'&scrollToShipment');
exit;
}
}
if (Tools::isSubmit('downloadModuleCSVSettings'))
{
include_once(_DPDPOLAND_CONTROLLERS_DIR_.'csv.controller.php');
$controller = new DpdPolandCSVController;
$controller->generateCSV();
}

File diff suppressed because it is too large Load Diff

397
modules/dpdpoland/en.php Normal file
View File

@@ -0,0 +1,397 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{dpdpoland}prestashop>dpdpoland_e14e32e9af6abe9075e171d1e699d2b1'] = 'DPD Polska sp. z o.o.';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_cf6bdbe90ce14e8574b95617ddecd62b'] = 'DPD Polska sp. z o.o. shipping module';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_95834a67fc218c91e0dac20af36dbf0a'] = 'DPD domestic shipment - Standard';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_b78bc3c561d92a0e21c15bebcb5a096c'] = 'DPD domestic shipment - Standard with COD';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_d2069e632908fea7573dca46cc582f17'] = 'DPD international shipment (DPD Classic)';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_d0949e93073cf252d5687ee5714e98fe'] = 'Module is in DEBUG mode';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_2e780f41b60cc7adce7ec82c077b1328'] = 'View debug file';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_6881bfc8704c70e00cdccd3a889c656e'] = 'PL country and PLN currency must be installed; CURL must be enabled';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_b9ef6fb0879ec82c0446bda7233f01a2'] = 'Module is not configured yet. Please check required settings';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_df6c55d89e6ab2b9bb40dac719af0ad3'] = 'Arrange PickUp';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_f4f70727dc34561dfde1a3c529b6205c'] = 'Settings';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_c02d804fa902ea3b9cf1372e91c6c07d'] = 'CSV prices import';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_17472ee8349195ad503c351f0707635d'] = 'CSV management is disabled when all shops or group of shops are selected';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_6a26f548831e6a8c26bfbbd9f6ec61e0'] = 'Help';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_7be24e7f2e42a87f6eed6461ee6019c3'] = 'Manifest list';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_133b95b4eff09dd92f6fb89365cfc5c9'] = 'Manifests functionality is disabled when all shops or group of shops are chosen';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_defa603474fa0b26abf74e04cf3f37dc'] = 'Parcels history';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_76eabb488f3d8677aa8456f6cf8e3cd6'] = 'Parcels functionality is disabled when all shops or group of shops are chosen';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_9e4af51bbda475a4c3f1be6d0d8ca79b'] = 'Shipment countries';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_adf178668a06fd135f315626c64cfcab'] = 'Countries functionality is disabled when all shops or group of shops are chosen';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_27fe4eb3edbaff8f250e2d51f7462681'] = 'Packages';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_662903aaf4484465ea3685e7eda39631'] = 'Packages functionality is disabled when all shops or group of shops are chosen';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_1fc78230db5bda0cce0fe26f8308b0e1'] = 'Parcel #%d does not exists';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_185f3a44910c149fb3932fe466a67c39'] = 'Unable to save product #%s to parcel #%d';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_2fe4721acab2b52c4ed95fffbbc5d56e'] = 'You have chosen a group of shops, all the changes will be set for all shops in this group';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_437e0167a401ddea924849640e08bfe0'] = 'You have chosen all shops, all the changes will be set for all shops';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_dc5982c9e79b6dfbd6f2b0bbdaddb972'] = 'DPD client number is required';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_1e00bbef535c75b71d1763a3580a1e5e'] = 'DPD client number is not valid';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_b2a5b30126d6c7beef59e4c719ebcb11'] = 'Client name is required';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_f99abd737754e44ba1954da710986e94'] = 'Client name is not valid';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_9b36b4083416f24c568a5db65cefb775'] = 'DPD client number already exists';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_bb5edb204502b74d1dc141b4c4d5c8ca'] = 'DPD client number / name could not be saved';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_c8ef9bdc2f02d07dc6079c73c2a63266'] = 'DPD client number / name saved successfully';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_346a047982b951c1884d870bdde83732'] = 'Could not delete DPD client number / name';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_27ec7e6bbcee87d7bcaee9bdefc45e09'] = 'Could not delete default client number setting';
$_MODULE['<{dpdpoland}prestashop>dpdpoland_3bf8fa7e6f2443cc31ed07a933f7f265'] = 'DPD client number / name deleted successfully';
$_MODULE['<{dpdpoland}prestashop>dpdpoland.ws_0de36710a01a183e825821bd8c114678'] = 'Could not connect to webservice server. Please check webservice URL';
$_MODULE['<{dpdpoland}prestashop>dpdpoland.ws_34e10ce9a0142bdf21b53c412f9b8971'] = 'Missing WebServices configuration data';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_557ce4d7ebf32761d89025560b39988e'] = 'Date of pickup';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_b01578a8d93f59f03da1295d41224835'] = 'Timeframe of pickup';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_f4b4439e9f3732ee91a5321a88fca1d0'] = 'Shipment type';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_417e0d7ca5c467a90ad6281f8dbdc902'] = 'General shipment content';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_fa9218f2927bf28f67029569c2c86b58'] = 'Envelopes';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_188512a8e454a4459576581f17c4cf24'] = 'Number of envelopes';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_3e9e1484cdd872f48f218fcf0a0ac882'] = 'Parcels';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_8c74ac4eaa2b297614fb822143339da2'] = 'Number of parcels';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_d0af198cb80a8b9fb791ecfe537ae058'] = 'Summary weight';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_5ad6a9b6909709fda6a6260140a577f2'] = 'Weight of the heaviest item';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_b566a0262a11710fec1bdefe70a9af75'] = 'Height of the tallest item';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_8cd26badce05229f3b4aef08e937e45f'] = 'Length of the largest item';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_63e5bd6e3ba8c6f7b3673adb344b0acb'] = 'Width of the longest item';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_3f9cff795224f5232cca142b122d6d46'] = 'Pallets';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_4e68f204aa87d54877bae0682c91e945'] = 'Number of pallets';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_2d3e1556af332fb39dbb336b7dbd815c'] = 'Pickup was successfully arranged. Number of order is: %d';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_e9db232320d68ed823146c578c4e57e8'] = 'At least one service must be selected';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_ca032b19074848f60a64765cf1a2b902'] = 'The \"%s\" field is required.';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup.controller_d3351a5a321eff4a2b2dd23f91014a09'] = 'The \"%s\" field is invalid.';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_6295e9fb03aee799ad17c1a7051bce54'] = 'Could not save DPD international shipment (DPD Classic) service';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_81f6684cb92278192ea83e1e2d52b1a5'] = 'Could not delete DPD international shipment (DPD Classic) service';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_d86de4cac15afc1d6bde5b95679e6bf5'] = 'Could not save DPD domestic shipment - Standard service';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_4095eb6e01f03f08bec8a018d6af4e42'] = 'Could not delete DPD domestic shipment - Standard service';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_e60eef2b54e550e3aa0765a8534bf851'] = 'Could not save DPD domestic shipment - Standard with COD service';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_096d9693810ab908011699bc2683d8b4'] = 'Could not delete DPD domestic shipment - Standard with COD service';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_2a691c13904a57bf08a9a97d6a29bb73'] = 'Login can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_50ae1a2cad21b6d7b4b8caa4df0ee128'] = 'Password can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_f1bc76917b4b9eefae0a2c2f249eae3e'] = 'Password is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_516f2bab6ea17ccfb2881d2d7244f2d0'] = 'Default client number must be set';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_43a51a7515589e5d0da53d6d34d92165'] = 'Company name can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_f1010bd631c658108fb79ee8a8e15b48'] = 'Company name is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_2630937e141eb50884534de42d5e5ee2'] = 'Name and Surname can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_60f899abeec0138f8c0eb005baa445ec'] = 'Name and surname are not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_aa8d12747028e054f46691ff7356dfcd'] = 'Address can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_024d391fbc28c4feae076f242b5e9663'] = 'Address is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_7b83329279ee90c78179e9bca6e71e36'] = 'Postal code not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_a3d30200506ef2f8f64f9da626fab198'] = 'Postal code is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_d1935ae9107bc14513878b353a40ad66'] = 'City can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_caff49a1a94d0a314aeb172fefe2c6b5'] = 'City is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_2e33dfccd5912a2b071d30460bd072dd'] = 'Email can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_a1d11f0c167629d356bc2cbdbbf9950f'] = 'Email is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_b9f7e2d6505c78b639bbf411b1fdf53d'] = 'Tel. No. can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_e3d6fd38c0970a247a2efe6135189b26'] = 'Tel. No. is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_ab86bd3c2acbfe84e03c9f25ddfec749'] = 'At least one COD payment method must be checked';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_352dc479bd09930c3741d4d2b08f52ad'] = 'Weight conversation rate can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_6d2fcce4872f354734a5ab22522bbc22'] = 'Weight conversation rate is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_02cc06808d47444a9b6070a70223937d'] = 'Dimension conversation rate can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_d6069dd010a2c50fbbd7b1e0c05def48'] = 'Dimension conversation rate is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_d8731cfb7b2fcc4d4a9a6d93a15b340f'] = 'Customer company name can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_10a5edb2f28bbeadcbe2ceb7452dd21b'] = 'Customer company name is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_d744cb91532d27fc295efb095ca35a7a'] = 'Customer name and surname can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_36eab302759930b2e87b5f58c82038b8'] = 'Customer name and surname is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_aa897175306dbf694b3c8aecc348820c'] = 'Customer tel. No. can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_c67952f0dd83b2025c62ae00d7d11e2a'] = 'Customer tel. No. is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_49164735e5be270db81a0b37c22c32b0'] = 'Customer FID can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_8189ae3b628cd0a0a01b9e85516163dc'] = 'Customer FID is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_d6534487cf5e32f16491d0177581cf40'] = 'Master FID can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_d57cce4f5f6024b838e22710d8b23baa'] = 'Master FID is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_ab4e2671faf3a670e8e0c59beffb9529'] = 'Web Services URL can not be empty';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_e4f36ce03f2b1d1c4c875ace06a7de2c'] = 'Web Services URL is not valid';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_fe016d3b990c2a9dd72ab6b45892f2ae'] = 'Settings saved successfully';
$_MODULE['<{dpdpoland}prestashop>configuration.controller_95fc952eb3f8cdf77b8fd878ec312099'] = 'Could not save settings';
$_MODULE['<{dpdpoland}prestashop>countrylist.controller_a108e14a7baadb5f412289e78e6e8cd4'] = 'Could not change country status';
$_MODULE['<{dpdpoland}prestashop>countrylist.controller_dcadd34de7e627ea1da1dfe62b6cf424'] = 'No selected countries';
$_MODULE['<{dpdpoland}prestashop>countrylist.controller_811e14e4f6a0a810bd7134b0efee372c'] = 'Country status changed successfully';
$_MODULE['<{dpdpoland}prestashop>countrylist.controller_5d9b9872005f3cf1a4def3fb3528eba9'] = 'Could not change country status, ID: %s';
$_MODULE['<{dpdpoland}prestashop>countrylist.controller_243911a3d5a8cd0425b6445f1226409c'] = 'Selected countries statuses changed successfully';
$_MODULE['<{dpdpoland}prestashop>csv.controller_59716c97497eb9694541f7c3d37b1a4d'] = 'Country';
$_MODULE['<{dpdpoland}prestashop>csv.controller_192faee3a49294fda6d13c0b121a1e4f'] = 'Parcel weight from (kg)';
$_MODULE['<{dpdpoland}prestashop>csv.controller_60ae6f36eeef0bd69b3589cb4197ea29'] = 'Parcel weight to (kg)';
$_MODULE['<{dpdpoland}prestashop>csv.controller_5a3110fd78c7e72bf6f793bbb22f1a27'] = 'Parcel price (PLN)';
$_MODULE['<{dpdpoland}prestashop>csv.controller_914419aa32f04011357d3b604a86d7eb'] = 'Carrier';
$_MODULE['<{dpdpoland}prestashop>csv.controller_cc22f9c1c006612224c8f14fcb8618a9'] = 'COD cost (PLN)';
$_MODULE['<{dpdpoland}prestashop>csv.controller_8d751864a3f79a19d2e06e2acf4234f2'] = 'Wrong CSV file';
$_MODULE['<{dpdpoland}prestashop>csv.controller_e3fb87f38c7ff3e310a8206daa79f82a'] = 'CSV data was successfully saved';
$_MODULE['<{dpdpoland}prestashop>csv.controller_37dc8118fa211f43b2ca2a52a6ee787d'] = 'CSV data could not be saved';
$_MODULE['<{dpdpoland}prestashop>csv.controller_db913c2ee13ffcfa8220f9082f55555d'] = 'Price rules deleted successfully';
$_MODULE['<{dpdpoland}prestashop>csv.controller_7d2d424cfc11ed9b4428825cd834b1fd'] = 'Price rules could not be deleted';
$_MODULE['<{dpdpoland}prestashop>csv.controller_7a93533b6e32e4c65ccd7f3785a4d086'] = 'Wrong CSV file structure or empty lines';
$_MODULE['<{dpdpoland}prestashop>csv.controller_45d626539112348088b22e53c8f42c31'] = 'PLN currency must be installed before CSV import.';
$_MODULE['<{dpdpoland}prestashop>csv.controller_269b83bdcdbede79ca4372e4cca0b550'] = 'Country: country code does not exists in your PrestaShop system - invalid lines:';
$_MODULE['<{dpdpoland}prestashop>csv.controller_f1f970c877f6b5d05c0b06114f6e8d51'] = 'Weight (From): invalid lines:';
$_MODULE['<{dpdpoland}prestashop>csv.controller_d2a7fae53a6ad2f729990f1f5d3a329d'] = 'Weight (To): invalid lines:';
$_MODULE['<{dpdpoland}prestashop>csv.controller_d8c27219c58175bf167fe761745c7b18'] = 'Parcel price (PLN): invalid lines:';
$_MODULE['<{dpdpoland}prestashop>csv.controller_5eebaf4c4354c2fa66c9a23f8625be48'] = 'Carrier: invalid lines:';
$_MODULE['<{dpdpoland}prestashop>csv.controller_2b1254f68ef36bf8144fe8f5d3998b9b'] = 'COD cost (PLN): Value should be >=0. Invalid lines:';
$_MODULE['<{dpdpoland}prestashop>csv.controller_fa7efd29ee54335b8eee557c0896272e'] = 'COD cost (PLN): It\'s possible to use COD only with \"DPD domestic shipment - Standard with COD\". Leave empty COD field otherwise. Invalid lines:';
$_MODULE['<{dpdpoland}prestashop>csv.controller_abdd02f527c5fea88a2f261f966d97e6'] = 'COD cost (PLN): COD is available only in Poland. Leave empty COD field otherwise. Invalid lines:';
$_MODULE['<{dpdpoland}prestashop>dpd_classic.service_d2069e632908fea7573dca46cc582f17'] = 'DPD international shipment (DPD Classic)';
$_MODULE['<{dpdpoland}prestashop>dpd_standard.service_95834a67fc218c91e0dac20af36dbf0a'] = 'DPD domestic shipment - Standard';
$_MODULE['<{dpdpoland}prestashop>dpd_standard_cod.service_b78bc3c561d92a0e21c15bebcb5a096c'] = 'DPD domestic shipment - Standard with COD';
$_MODULE['<{dpdpoland}prestashop>manifest_a7927259433038cdaab4fedd3891fc2c'] = 'Manifests of DOMESTIC shipments cannot be mixed with INTERNATIONAL shipments';
$_MODULE['<{dpdpoland}prestashop>package_fb14705e99f84ade2bbdb747ab45c028'] = 'Customer does not exists';
$_MODULE['<{dpdpoland}prestashop>package_83ef8de8a773717790a7db47d7893c22'] = 'Receiver address does not exists';
$_MODULE['<{dpdpoland}prestashop>package_706aefe3f1a249726beddd13681060d3'] = 'Package was successfully created but we were unable to save its data locally';
$_MODULE['<{dpdpoland}prestashop>package_a7927259433038cdaab4fedd3891fc2c'] = 'Manifests of DOMESTIC shipments cannot be mixed with INTERNATIONAL shipments';
$_MODULE['<{dpdpoland}prestashop>pickup_88f4da5ddbc4666535176a1251cb4d8f'] = 'Error code: %s, fields: %s';
$_MODULE['<{dpdpoland}prestashop>pickup_443a89770439e69c92ec317079d15fbb'] = 'Order number is undefined';
$_MODULE['<{dpdpoland}prestashop>pickup_789d957565edc09c2a436fca63b30c03'] = 'Cannot get TimeFrames from webservices. Please check if sender\'s postal code is typed in correctly';
$_MODULE['<{dpdpoland}prestashop>address_5e116ceb48a98fb755f22df7ea1e2396'] = 'Company name:';
$_MODULE['<{dpdpoland}prestashop>address_2e07aecf995754708a89dd0766cce085'] = 'Name and surname:';
$_MODULE['<{dpdpoland}prestashop>address_72b6d26677f7289a541e4fdbf4c8ca53'] = 'Street and house no.:';
$_MODULE['<{dpdpoland}prestashop>address_da67a6777d9e5451375f8ab27e15af8b'] = 'Postal code:';
$_MODULE['<{dpdpoland}prestashop>address_bffb711ec36f280459d11dce315da72f'] = 'City:';
$_MODULE['<{dpdpoland}prestashop>address_f64be5eef68442a8f50cf535b92ad3e4'] = 'Country:';
$_MODULE['<{dpdpoland}prestashop>address_df1555fe48479f594280a2e03f9a8186'] = 'E-mail:';
$_MODULE['<{dpdpoland}prestashop>address_0936b8d13555e80a1e3b4382274f06bd'] = 'Tel. No.';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_7d06182c98480873fd25664fb3f7a698'] = 'Sender address';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_94880bda83bda77c5692876700711f15'] = 'Poland';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_3f2bbf3ee64eb0d86ebe7730b3c6ccde'] = 'Sender address must be specified in settings first';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_40f404095c708619cdd4d0f808a9570e'] = 'Date and time for pickup';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_d76cabde06a3b3f49b88d0bedfd64928'] = 'Date of pickup:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_2f88c2f48e2eaa600cb461062abc5db7'] = 'Order placement is possible only on working days, if you select non working day your order will be realized on first available working day';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_cdaf42bc870c754a964420ba2ac49b02'] = 'Timeframe of pickup:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_209802fb858e2c83205027dbbb5d9e6c'] = 'Package';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_325a369b3c10840846bf208b09e42685'] = 'Shipment type:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_86760af0540a2a6d4b4ca61ef3d6187c'] = 'Domestic';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_8189ecf686157db0c0274c1f49373318'] = 'International';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_e1ed989ed1284aedc6dba9b1680fefaf'] = 'Envelopes:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_ab7702eaa2e0331f91205686efa40d69'] = 'Number of envelopes:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_e1f142b36e05805b333c1e038d95b0d8'] = 'Parcels:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_9fda8e6e97311e1f7d755ac477dea38f'] = 'Number of parcels:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_c4c3afb13f59f8ede266475851fbfbac'] = 'Summary weight (in kg):';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_1abfd647ddf71e80424f3fc60b50e60c'] = 'Weight of the heaviest item (in kg):';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_730b2819f18ff8dd9d1bf5df925f64eb'] = 'Height of the tallest item (in cm):';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_a54fde62a06b28e231fc7fbeb0690abd'] = 'Length of the largest item (in cm):';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_6c5cbb81d5b2cff0dbc530681dafdcc2'] = 'Width of the longest item (in cm):';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_902d421176a411f4d956205e7d5c8059'] = 'Pallets:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_8995f444a649d88c69c5580131df1177'] = 'Number of pallets:';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_94966d90747b97d1f0f206c98a8b1ac3'] = 'Send';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_332dc7ba3252c80249de22d335d1ccf3'] = 'Some text for merchants information - to be agreed on.';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_973ddc69a5ff591471c0376488db8579'] = 'Arrange Pickup';
$_MODULE['<{dpdpoland}prestashop>arrange_pickup_ea4788705e6873b424c65e91c2846b19'] = 'Cancel';
$_MODULE['<{dpdpoland}prestashop>configuration_f4f70727dc34561dfde1a3c529b6205c'] = 'Settings';
$_MODULE['<{dpdpoland}prestashop>configuration_d7ee719da6f2c80eaf00d5538a2517bd'] = 'DPD credentials';
$_MODULE['<{dpdpoland}prestashop>configuration_051672911a3f1f05efba78a553ef6fe2'] = 'Login:';
$_MODULE['<{dpdpoland}prestashop>configuration_b341a59d5636ed3d6a819137495b08a0'] = 'Password:';
$_MODULE['<{dpdpoland}prestashop>configuration_49fbab040daede070f6af9e1da021fad'] = 'DPD client number:';
$_MODULE['<{dpdpoland}prestashop>configuration_de8df59907fdac33cd15aa585a4cef84'] = 'Client name:';
$_MODULE['<{dpdpoland}prestashop>configuration_ec211f7c20af43e742bf2570c3cb84f9'] = 'Add';
$_MODULE['<{dpdpoland}prestashop>configuration_436a25178dc1cd89996743d657142bd2'] = 'Default client number:';
$_MODULE['<{dpdpoland}prestashop>configuration_c9cc8cce247e49bae79f15173ce97354'] = 'Save';
$_MODULE['<{dpdpoland}prestashop>configuration_19f823c6453c2b1ffd09cb715214813d'] = 'Required field';
$_MODULE['<{dpdpoland}prestashop>configuration_58d579673df0c3e3c03a9692e1263952'] = 'Senders data';
$_MODULE['<{dpdpoland}prestashop>configuration_5e116ceb48a98fb755f22df7ea1e2396'] = 'Company name:';
$_MODULE['<{dpdpoland}prestashop>configuration_2e07aecf995754708a89dd0766cce085'] = 'Name and surname:';
$_MODULE['<{dpdpoland}prestashop>configuration_2bf1d5fae1c321d594fdedf05058f709'] = 'Address:';
$_MODULE['<{dpdpoland}prestashop>configuration_3011ea97a695e0d9ea2a9a38bb60f8e4'] = 'Company name or First and surname is mandatory';
$_MODULE['<{dpdpoland}prestashop>configuration_da67a6777d9e5451375f8ab27e15af8b'] = 'Postal code:';
$_MODULE['<{dpdpoland}prestashop>configuration_bffb711ec36f280459d11dce315da72f'] = 'City:';
$_MODULE['<{dpdpoland}prestashop>configuration_59716c97497eb9694541f7c3d37b1a4d'] = 'Country';
$_MODULE['<{dpdpoland}prestashop>configuration_94880bda83bda77c5692876700711f15'] = 'Poland';
$_MODULE['<{dpdpoland}prestashop>configuration_df1555fe48479f594280a2e03f9a8186'] = 'E-mail:';
$_MODULE['<{dpdpoland}prestashop>configuration_230ff5a82d6f00782ac18f7d7dd594e8'] = 'Tel. No.:';
$_MODULE['<{dpdpoland}prestashop>configuration_a000119beed256188e530a804bb79ef4'] = 'Active shiping services';
$_MODULE['<{dpdpoland}prestashop>configuration_4aeaca207f10d8b2a25475f3f135a4ac'] = 'DPD domestic shipment - Standard:';
$_MODULE['<{dpdpoland}prestashop>configuration_f03584af7399afb18d478900e06b025c'] = 'DPD domestic shipment - Standard with COD:';
$_MODULE['<{dpdpoland}prestashop>configuration_b78bc3c561d92a0e21c15bebcb5a096c'] = 'DPD domestic shipment - Standard with COD';
$_MODULE['<{dpdpoland}prestashop>configuration_d66f656d939860707d874607f42500f9'] = 'RULE: DPD Polska sp. z o.o. allows payment on the delivery ONLY by cash. In your payment modules you have available this types of payment, please mark those payment methods that support this rule.';
$_MODULE['<{dpdpoland}prestashop>configuration_961489f954ec2135d8094496df2ac259'] = 'DPD international shipment (DPD Classic):';
$_MODULE['<{dpdpoland}prestashop>configuration_d2069e632908fea7573dca46cc582f17'] = 'DPD international shipment (DPD Classic)';
$_MODULE['<{dpdpoland}prestashop>configuration_c2ce0e9a6aa6854e42ce2354208bfc1e'] = 'Please note that after module installation carriers are not created.';
$_MODULE['<{dpdpoland}prestashop>configuration_d6576c8f0f67964194302b2fe773b9b9'] = 'Price calculation';
$_MODULE['<{dpdpoland}prestashop>configuration_42d054e877c92fa2201f38d2159cd490'] = 'Shipping price calculation method:';
$_MODULE['<{dpdpoland}prestashop>configuration_5cd4346a553c6168b4d296232d24ad65'] = 'Weight measurement units conversation';
$_MODULE['<{dpdpoland}prestashop>configuration_c31a6a651c1080cb4c1716eadfe856cd'] = 'System default weight units:';
$_MODULE['<{dpdpoland}prestashop>configuration_10df976caf081bfa86d39f626456e1da'] = 'DPD weight units:';
$_MODULE['<{dpdpoland}prestashop>configuration_5d984b2060bfae52a2abe2e9f05def92'] = 'Conversation rate:';
$_MODULE['<{dpdpoland}prestashop>configuration_3d98ce8c59b0f830f296f902efe42ef0'] = 'Conversation rate from system to DPD weight units. If your system uses the same weight units as DPD then leave this field blank.';
$_MODULE['<{dpdpoland}prestashop>configuration_086688900e2a055c719faebe0bfe0c38'] = 'Dimension measurement units conversation';
$_MODULE['<{dpdpoland}prestashop>configuration_ac594a3e6f56f10169ab633f27eb0e9f'] = 'System default dimension units:';
$_MODULE['<{dpdpoland}prestashop>configuration_60f05f3f2847d78f32849479929b7ddd'] = 'DPD dimension units:';
$_MODULE['<{dpdpoland}prestashop>configuration_21a258f58e4e128f018e82bcbc74e64f'] = 'Conversatoin rate from system to DPD dimension units. If your system uses the same dimension units as DPD then leave this field blank.';
$_MODULE['<{dpdpoland}prestashop>configuration_4473b41d1a4095be325afd76182eeb4f'] = 'General WS parameters';
$_MODULE['<{dpdpoland}prestashop>configuration_d56e808757f47edcf82ff3fec2a93704'] = 'Customer company name:';
$_MODULE['<{dpdpoland}prestashop>configuration_65de6f35022d3cf8490f9a0c5efc2643'] = 'Customer name and surname:';
$_MODULE['<{dpdpoland}prestashop>configuration_13d7b53519833fc35b46e1f5eb08cead'] = 'Customer tel. No.:';
$_MODULE['<{dpdpoland}prestashop>configuration_5cd9a6211e54713fa09670b9a06a7820'] = 'Customer FID:';
$_MODULE['<{dpdpoland}prestashop>configuration_d0424144fb77191573ef83a495abb98f'] = 'Master FID:';
$_MODULE['<{dpdpoland}prestashop>configuration_6c0729f778568e67fcc9cc9297240283'] = 'Web Services URL';
$_MODULE['<{dpdpoland}prestashop>configuration_2ca9c180d73e6abdfa19c2d207e5ea0e'] = 'Web Services URL:';
$_MODULE['<{dpdpoland}prestashop>configuration_5ec828cf7c89f7cb7735abdf8629b844'] = 'Standard URL: http://egproduction.dpd.com/IT4EMWebServices/eshop/';
$_MODULE['<{dpdpoland}prestashop>country_list_193cfc9be3b995831c6af2fea6650e60'] = 'Page';
$_MODULE['<{dpdpoland}prestashop>country_list_b9987a246a537f4fe86f1f2e3d10dbdb'] = 'Display';
$_MODULE['<{dpdpoland}prestashop>country_list_dd8921b41e0279a02c6a26a509241700'] = 'result(s)';
$_MODULE['<{dpdpoland}prestashop>country_list_d7778d0c64b6ba21494c97f77a66885a'] = 'Filter';
$_MODULE['<{dpdpoland}prestashop>country_list_526d688f37a86d3c3f27d0c5016eb71d'] = 'Reset';
$_MODULE['<{dpdpoland}prestashop>country_list_b718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_MODULE['<{dpdpoland}prestashop>country_list_59716c97497eb9694541f7c3d37b1a4d'] = 'Country';
$_MODULE['<{dpdpoland}prestashop>country_list_ad68f9bafd9bf2dcf3865dac55662fd5'] = 'ISO code';
$_MODULE['<{dpdpoland}prestashop>country_list_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Enabled';
$_MODULE['<{dpdpoland}prestashop>country_list_93cba07454f06a4a960172bbd6e2a435'] = 'Yes';
$_MODULE['<{dpdpoland}prestashop>country_list_bafd7322c6e97d25b6299b5d6fe8920b'] = 'No';
$_MODULE['<{dpdpoland}prestashop>country_list_b9f5c797ebbf55adccdd8539a65a0241'] = 'Disabled';
$_MODULE['<{dpdpoland}prestashop>country_list_e1ba5c602cbc3752cca2f0f80ee0117f'] = 'No countries';
$_MODULE['<{dpdpoland}prestashop>country_list_729a51874fe901b092899e9e8b31c97a'] = 'Are you sure?';
$_MODULE['<{dpdpoland}prestashop>country_list_ab7fd6e250b64a46027a996088fdff74'] = 'Disable selection';
$_MODULE['<{dpdpoland}prestashop>country_list_ede4759c9afae620fd586628789fa304'] = 'Enable selection';
$_MODULE['<{dpdpoland}prestashop>csv_f9b167f250a964c308cfe8575dab99de'] = 'Settings |';
$_MODULE['<{dpdpoland}prestashop>csv_88a2abe73767716fd72aed8725591da5'] = 'Price rules import';
$_MODULE['<{dpdpoland}prestashop>csv_bebd96a4a11b7c01ff97a513a821c574'] = 'Upload CSV:';
$_MODULE['<{dpdpoland}prestashop>csv_91412465ea9169dfd901dd5e7c96dd99'] = 'Upload';
$_MODULE['<{dpdpoland}prestashop>csv_4b56bed0c2ecdfb749ae7dfa7349fd86'] = 'Download CSV:';
$_MODULE['<{dpdpoland}prestashop>csv_801ab24683a4a8c433c6eb40c48bcd9d'] = 'Download';
$_MODULE['<{dpdpoland}prestashop>csv_881110e35ba1f9ba37aef045e655c1ed'] = 'Preview imported prices:';
$_MODULE['<{dpdpoland}prestashop>csv_78945de8de090e90045d299651a68a9b'] = 'Available';
$_MODULE['<{dpdpoland}prestashop>csv_b6b0216b599f49e6af80a5b55a909734'] = 'carriers';
$_MODULE['<{dpdpoland}prestashop>csv_78eef451236c53b445e7ba6d5b902f8c'] = '(shipping methods) and their ID\'s:';
$_MODULE['<{dpdpoland}prestashop>csv_fe2002b422737cfc0766df87109c750a'] = '* DPD domestic shipment - Standard with COD:';
$_MODULE['<{dpdpoland}prestashop>csv_0dcd5647184d1731b71bc2b4b62f18c7'] = '* DPD international shipment (DPD Classic):';
$_MODULE['<{dpdpoland}prestashop>csv_59716c97497eb9694541f7c3d37b1a4d'] = 'Country';
$_MODULE['<{dpdpoland}prestashop>csv_3a0de12ea59c2c247ab7837d15ade991'] = '- this column should contain the full name of the country (the letters are not case sensitive, or as an abbreviation, e.g. PL, DE, GB.';
$_MODULE['<{dpdpoland}prestashop>csv_8bcdc441379cbf584638b0589a3f9adb'] = 'Postcode';
$_MODULE['<{dpdpoland}prestashop>csv_4bcb934420a471b412c662631b9fed5e'] = '- this column includes the post code - the application should accept the domestic post codes in the format of (00-000 or 00000) and international postcodes in the format of numbers + letters up to 7 characters, e.g. inor in Ireland 1.';
$_MODULE['<{dpdpoland}prestashop>csv_4b08bbe48e297bff8c60c10f17cc4856'] = 'Parcel weight from';
$_MODULE['<{dpdpoland}prestashop>csv_654242ec1434474a9f528677139a5386'] = '- this column contains the parcel weight which is the lower limit of the weight range for the specified price.';
$_MODULE['<{dpdpoland}prestashop>csv_4b9664bced247a7e3d5820398dbe02a9'] = 'Parcel weight to';
$_MODULE['<{dpdpoland}prestashop>csv_35df0b639b79320c9a3746f4a0585915'] = '- this column contains the parcel weight which is the upper limit of the weight range for the specified price.';
$_MODULE['<{dpdpoland}prestashop>csv_5c792b7fcda62b33ae8d5805718964b9'] = 'Parcel price';
$_MODULE['<{dpdpoland}prestashop>csv_308d7003f4ba2d580e461848548ab5ae'] = '- in this column the user enters the price in PLN which will be charged to the client for dispatch of one parcel with the weight within the specified weight range.';
$_MODULE['<{dpdpoland}prestashop>csv_2e01b86887d023c873d0ebb2811e3bd8'] = 'First page';
$_MODULE['<{dpdpoland}prestashop>csv_16ded2dc32322d80ce2362a47f4d7ef4'] = 'Previous page';
$_MODULE['<{dpdpoland}prestashop>csv_374bea6cf8bd1e8fd64570b629cc6562'] = 'Next page';
$_MODULE['<{dpdpoland}prestashop>csv_339aaf6f96935365023a6e4c95c0ba95'] = 'Last page';
$_MODULE['<{dpdpoland}prestashop>csv_192faee3a49294fda6d13c0b121a1e4f'] = 'Parcel weight from (kg)';
$_MODULE['<{dpdpoland}prestashop>csv_60ae6f36eeef0bd69b3589cb4197ea29'] = 'Parcel weight to (kg)';
$_MODULE['<{dpdpoland}prestashop>csv_5a3110fd78c7e72bf6f793bbb22f1a27'] = 'Parcel price (PLN)';
$_MODULE['<{dpdpoland}prestashop>csv_914419aa32f04011357d3b604a86d7eb'] = 'Carrier';
$_MODULE['<{dpdpoland}prestashop>csv_cc22f9c1c006612224c8f14fcb8618a9'] = 'COD cost (PLN)';
$_MODULE['<{dpdpoland}prestashop>csv_f564528cd4716fd14397b32ca0c345bd'] = 'No prices';
$_MODULE['<{dpdpoland}prestashop>csv_58ed7fc51269deb0030cc40b55e47fb3'] = 'Delete all prices';
$_MODULE['<{dpdpoland}prestashop>errors_2169b4627df97333ed94d1e30a9b8148'] = '%d errors';
$_MODULE['<{dpdpoland}prestashop>global_variables_099eb94b23ca0630da8a84205da91ad6'] = 'No COD modules found';
$_MODULE['<{dpdpoland}prestashop>manifest_list_193cfc9be3b995831c6af2fea6650e60'] = 'Page';
$_MODULE['<{dpdpoland}prestashop>manifest_list_b9987a246a537f4fe86f1f2e3d10dbdb'] = 'Display';
$_MODULE['<{dpdpoland}prestashop>manifest_list_dd8921b41e0279a02c6a26a509241700'] = 'result(s)';
$_MODULE['<{dpdpoland}prestashop>manifest_list_d7778d0c64b6ba21494c97f77a66885a'] = 'Filter';
$_MODULE['<{dpdpoland}prestashop>manifest_list_526d688f37a86d3c3f27d0c5016eb71d'] = 'Reset';
$_MODULE['<{dpdpoland}prestashop>manifest_list_7b26b01c4e5deea6764e23f57f859a31'] = 'Manifest Number';
$_MODULE['<{dpdpoland}prestashop>manifest_list_e7c5549bbf8d3f401303b4440534501a'] = 'Number of Parcels';
$_MODULE['<{dpdpoland}prestashop>manifest_list_ad70456116fb04deb6ee65334cf02bd1'] = 'Number of Orders';
$_MODULE['<{dpdpoland}prestashop>manifest_list_bea2be7035c3c22f3081d02d160f676c'] = 'Date of printout';
$_MODULE['<{dpdpoland}prestashop>manifest_list_06df33001c1d7187fdd81ea1f5b277aa'] = 'Actions';
$_MODULE['<{dpdpoland}prestashop>manifest_list_5da618e8e4b89c66fe86e32cdafde142'] = 'From';
$_MODULE['<{dpdpoland}prestashop>manifest_list_e12167aa0a7698e6ebc92b4ce3909b53'] = 'To';
$_MODULE['<{dpdpoland}prestashop>manifest_list_862e7e2976be83770203c5a8197c8eea'] = 'Print manifest';
$_MODULE['<{dpdpoland}prestashop>manifest_list_d60f54ec9bb09f0d8a16dd7a23c79eef'] = 'There are no manifests yet';
$_MODULE['<{dpdpoland}prestashop>navigation_973ddc69a5ff591471c0376488db8579'] = 'Arrange Pickup';
$_MODULE['<{dpdpoland}prestashop>navigation_1959f2f4256262bfcfccb049920df476'] = 'Packages list';
$_MODULE['<{dpdpoland}prestashop>navigation_7be24e7f2e42a87f6eed6461ee6019c3'] = 'Manifest list';
$_MODULE['<{dpdpoland}prestashop>navigation_defa603474fa0b26abf74e04cf3f37dc'] = 'Parcels history';
$_MODULE['<{dpdpoland}prestashop>navigation_9e4af51bbda475a4c3f1be6d0d8ca79b'] = 'Shipment countries';
$_MODULE['<{dpdpoland}prestashop>navigation_c02d804fa902ea3b9cf1372e91c6c07d'] = 'CSV prices import';
$_MODULE['<{dpdpoland}prestashop>navigation_f4f70727dc34561dfde1a3c529b6205c'] = 'Settings';
$_MODULE['<{dpdpoland}prestashop>navigation_6a26f548831e6a8c26bfbbd9f6ec61e0'] = 'Help';
$_MODULE['<{dpdpoland}prestashop>package_list_193cfc9be3b995831c6af2fea6650e60'] = 'Page';
$_MODULE['<{dpdpoland}prestashop>package_list_b9987a246a537f4fe86f1f2e3d10dbdb'] = 'Display';
$_MODULE['<{dpdpoland}prestashop>package_list_dd8921b41e0279a02c6a26a509241700'] = 'result(s)';
$_MODULE['<{dpdpoland}prestashop>package_list_d7778d0c64b6ba21494c97f77a66885a'] = 'Filter';
$_MODULE['<{dpdpoland}prestashop>package_list_526d688f37a86d3c3f27d0c5016eb71d'] = 'Reset';
$_MODULE['<{dpdpoland}prestashop>package_list_c004ddb608f079bc80ce406f6d27724c'] = 'Printout date';
$_MODULE['<{dpdpoland}prestashop>package_list_4049d979b8e6b7d78194e96c3208a5a5'] = 'Order number';
$_MODULE['<{dpdpoland}prestashop>package_list_e7c5549bbf8d3f401303b4440534501a'] = 'Number of Parcels';
$_MODULE['<{dpdpoland}prestashop>package_list_a9d093d11bc6e98b0c8e586ffa545c85'] = 'Receiver';
$_MODULE['<{dpdpoland}prestashop>package_list_59716c97497eb9694541f7c3d37b1a4d'] = 'Country';
$_MODULE['<{dpdpoland}prestashop>package_list_572ed696f21038e6cc6c86bb272a3222'] = 'Postal code';
$_MODULE['<{dpdpoland}prestashop>package_list_57d056ed0984166336b7879c2af3657f'] = 'City';
$_MODULE['<{dpdpoland}prestashop>package_list_dd7bf230fde8d4836917806aff6a6b27'] = 'Address';
$_MODULE['<{dpdpoland}prestashop>package_list_06df33001c1d7187fdd81ea1f5b277aa'] = 'Actions';
$_MODULE['<{dpdpoland}prestashop>package_list_5da618e8e4b89c66fe86e32cdafde142'] = 'From';
$_MODULE['<{dpdpoland}prestashop>package_list_e12167aa0a7698e6ebc92b4ce3909b53'] = 'To';
$_MODULE['<{dpdpoland}prestashop>package_list_4351cfebe4b61d8aa5efa1d020710005'] = 'View';
$_MODULE['<{dpdpoland}prestashop>package_list_cef29e3a250ad945dced5a825c58278e'] = 'No packages';
$_MODULE['<{dpdpoland}prestashop>package_list_f217fbfafa30da1967ecd3da1f9a45df'] = 'Print selected manifest(s)?';
$_MODULE['<{dpdpoland}prestashop>package_list_5ad8adf8bcb1c359b87c0f3fb4a87bb7'] = 'Manifest printout';
$_MODULE['<{dpdpoland}prestashop>package_list_3b2d2f8475efad88c145a284b814010a'] = 'Label duplicate printout';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_193cfc9be3b995831c6af2fea6650e60'] = 'Page';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_b9987a246a537f4fe86f1f2e3d10dbdb'] = 'Display';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_dd8921b41e0279a02c6a26a509241700'] = 'result(s)';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_d7778d0c64b6ba21494c97f77a66885a'] = 'Filter';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_526d688f37a86d3c3f27d0c5016eb71d'] = 'Reset';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_d79cf3f429596f77db95c65074663a54'] = 'Order ID';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_c5513c96dedd85c20b7c8ce4d89c1a46'] = 'Parcel Number';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_a9d093d11bc6e98b0c8e586ffa545c85'] = 'Receiver';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_59716c97497eb9694541f7c3d37b1a4d'] = 'Country';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_572ed696f21038e6cc6c86bb272a3222'] = 'Postal code';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_57d056ed0984166336b7879c2af3657f'] = 'City';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_dd7bf230fde8d4836917806aff6a6b27'] = 'Address';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_3513b3d0b07729be9d4649b113728a69'] = 'Shipment date';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_06df33001c1d7187fdd81ea1f5b277aa'] = 'Actions';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_5da618e8e4b89c66fe86e32cdafde142'] = 'From';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_e12167aa0a7698e6ebc92b4ce3909b53'] = 'To';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_4351cfebe4b61d8aa5efa1d020710005'] = 'View';
$_MODULE['<{dpdpoland}prestashop>parcel_history_list_766072dc9c8227c158885c628ef15f37'] = 'No parcels history';
$_MODULE['<{dpdpoland}prestashop>payer_numbers_table_94a07a8c84a4738d80d30bdb4f3c5f45'] = 'Client number';
$_MODULE['<{dpdpoland}prestashop>payer_numbers_table_0d380be17f8c1b5508dddc0ff5bf8dc6'] = 'Client name';
$_MODULE['<{dpdpoland}prestashop>payer_numbers_table_7a1920d61156abc05a60135aefe8bc67'] = 'Default';
$_MODULE['<{dpdpoland}prestashop>payer_numbers_table_f2a6c498fb90ee345d997f888fce3b18'] = 'Delete';
$_MODULE['<{dpdpoland}prestashop>payer_numbers_table_892a8778e8ee9a7fafc3e7b5c18e4507'] = 'Delete selected client numbers?';
$_MODULE['<{dpdpoland}prestashop>payer_numbers_table_9e8e981726883fc8124a14c27877db87'] = 'No numbers';
$_MODULE['<{dpdpoland}prestashop>warnings_b4372757bcd49be89af758f485f8666f'] = '%d warnings';
$_MODULE['<{dpdpoland}prestashop>adminorder_aad9c2452ad2af0a0731c349e4308f1f'] = 'All products should be assigned to a particular parcel!';
$_MODULE['<{dpdpoland}prestashop>adminorder_459d31643ac6afd02cb05e37b4cd62c2'] = 'DPD Polska sp. z o.o. shipping';
$_MODULE['<{dpdpoland}prestashop>adminorder_1a721faf2df53972bfd0831c64b6146d'] = 'collapse';
$_MODULE['<{dpdpoland}prestashop>adminorder_31407b18c5a9dd810565caedda2d0e42'] = 'expand';
$_MODULE['<{dpdpoland}prestashop>adminorder_d0949e93073cf252d5687ee5714e98fe'] = 'Module is in DEBUG mode';
$_MODULE['<{dpdpoland}prestashop>adminorder_2e780f41b60cc7adce7ec82c077b1328'] = 'View debug file';
$_MODULE['<{dpdpoland}prestashop>adminorder_092052146ff023c4bd1f904846dfc00c'] = 'Shipment mode:';
$_MODULE['<{dpdpoland}prestashop>adminorder_95834a67fc218c91e0dac20af36dbf0a'] = 'DPD domestic shipment - Standard';
$_MODULE['<{dpdpoland}prestashop>adminorder_b78bc3c561d92a0e21c15bebcb5a096c'] = 'DPD domestic shipment - Standard with COD';
$_MODULE['<{dpdpoland}prestashop>adminorder_d2069e632908fea7573dca46cc582f17'] = 'DPD international shipment (DPD Classic)';
$_MODULE['<{dpdpoland}prestashop>adminorder_c171a57242868e49d3608da466642580'] = 'DPD client number (Payer):';
$_MODULE['<{dpdpoland}prestashop>adminorder_c66d035abc5a2df1dded3f17486ed89c'] = 'Sender:';
$_MODULE['<{dpdpoland}prestashop>adminorder_c3e885b15c648365e50fc2126d698f7e'] = 'Sender address can be changed in module settings page.';
$_MODULE['<{dpdpoland}prestashop>adminorder_3841356b3344dcaf14dbccbe6e2b6fae'] = 'Recipient:';
$_MODULE['<{dpdpoland}prestashop>adminorder_5e69f9d5bc6e6f0d29abb4990c21595d'] = 'Recipient address:';
$_MODULE['<{dpdpoland}prestashop>adminorder_eb6a633d6af6b5e6819f4ed4884c9bb3'] = 'COD:';
$_MODULE['<{dpdpoland}prestashop>adminorder_72d691a9e17cc6098782639bf0538184'] = 'Enter the amount of COD';
$_MODULE['<{dpdpoland}prestashop>adminorder_fd9d62700b7f3063c3e08b6266e5bf43'] = 'Valuable parcel:';
$_MODULE['<{dpdpoland}prestashop>adminorder_3821d89292f0543e98ac2c7cd0779e43'] = 'Leave blank if service is not needed';
$_MODULE['<{dpdpoland}prestashop>adminorder_1e3578cde9a2a7d29fd8fe188dde1a20'] = 'Additional shipment information:';
$_MODULE['<{dpdpoland}prestashop>adminorder_83fa39a28a4d159061c408fbd6a249e7'] = 'Order ID:';
$_MODULE['<{dpdpoland}prestashop>adminorder_129142cc236a68ed5288614ce1f911fb'] = 'Reference number 1';
$_MODULE['<{dpdpoland}prestashop>adminorder_db2d9ca9b008f4cdb2c5902adaa84fdc'] = 'Invoice number:';
$_MODULE['<{dpdpoland}prestashop>adminorder_4ab7be371a4f201c7a97a876ed0d59b3'] = 'Reference number 2';
$_MODULE['<{dpdpoland}prestashop>adminorder_9cbf474d9a3d5deae6e47a2cede2f536'] = 'Group the products in your shipment into parcels';
$_MODULE['<{dpdpoland}prestashop>adminorder_ca92c5cc1d3c1d7d0a5336511faf61ec'] = 'This module lets you organize your products into parcels using the table below. Select parcel number.';
$_MODULE['<{dpdpoland}prestashop>adminorder_b718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_MODULE['<{dpdpoland}prestashop>adminorder_deb10517653c255364175796ace3553f'] = 'Product';
$_MODULE['<{dpdpoland}prestashop>adminorder_8c489d0946f66d17d73f26366a4bf620'] = 'Weight';
$_MODULE['<{dpdpoland}prestashop>adminorder_f38e9081d395bb971dd1bf81f65f22e6'] = 'Parcel';
$_MODULE['<{dpdpoland}prestashop>adminorder_11a738dd0c48f1401a059bca54bc119c'] = 'Add product';
$_MODULE['<{dpdpoland}prestashop>adminorder_d31e97ad5d951fd5703d588011ccd63a'] = 'Begin typing the first letters of the product name, then select the product from the drop-down list.';
$_MODULE['<{dpdpoland}prestashop>adminorder_0b55aebbd8b86751f6c70c6cf91094b1'] = 'Manage parcels';
$_MODULE['<{dpdpoland}prestashop>adminorder_adfb1922c661200f46a4a5fee00720fc'] = 'Here you can change parcel parameters, create new parcels';
$_MODULE['<{dpdpoland}prestashop>adminorder_74d206f6125b574f5156627cac72de0d'] = 'Content of parcel';
$_MODULE['<{dpdpoland}prestashop>adminorder_91721604210524b7051d99c4c8478715'] = 'Weight (kg)';
$_MODULE['<{dpdpoland}prestashop>adminorder_20fbaa7c1bf32aa91ed46514737a0687'] = 'Height (cm)';
$_MODULE['<{dpdpoland}prestashop>adminorder_d39e1498c3bd289bb7ed63f790adfb0d'] = 'Length (cm)';
$_MODULE['<{dpdpoland}prestashop>adminorder_3d0ed3e9145be53d081d10fe37c93290'] = 'Width (cm)';
$_MODULE['<{dpdpoland}prestashop>adminorder_d4250cdd2996e67db50a1fa27ca4379b'] = 'Dimension weight';
$_MODULE['<{dpdpoland}prestashop>adminorder_89dcc0ff4130fb8e1d64c5ee3c4bb4fc'] = 'When adding new parcel: Additional fee will be charged by DPD PL depending on your DPD PL contract. Price for shipment that was shown to your customer always includes only one parcel per order.';
$_MODULE['<{dpdpoland}prestashop>adminorder_af0924a4a04778667c6e5afb3024f8da'] = 'Add parcel';
$_MODULE['<{dpdpoland}prestashop>adminorder_119e5a3da4a4debfbcb786d189d2605d'] = 'It will not be possible to edit shipment after printintig labels.';
$_MODULE['<{dpdpoland}prestashop>adminorder_5359e0d1b7e3d42fded6e0a420dbaffc'] = 'Save and print labels';
$_MODULE['<{dpdpoland}prestashop>adminorder_c879cb3351593188d1178647eb2032fe'] = 'Print labels';
$_MODULE['<{dpdpoland}prestashop>adminorder_f9134937ba5da4d91eead723aee72481'] = 'Current status';
$_MODULE['<{dpdpoland}prestashop>adminorder_004bf6c9a40003140292e97330236c53'] = 'Action';
$_MODULE['<{dpdpoland}prestashop>adminorder_ec53a8c4f07baed5d8825072c89799be'] = 'Status';
$_MODULE['<{dpdpoland}prestashop>adminorder_611528c50da4256e1df65bc386518d70'] = 'Labels printed';
$_MODULE['<{dpdpoland}prestashop>adminorder_93cba07454f06a4a960172bbd6e2a435'] = 'Yes';
$_MODULE['<{dpdpoland}prestashop>adminorder_bafd7322c6e97d25b6299b5d6fe8920b'] = 'No';
$_MODULE['<{dpdpoland}prestashop>adminorder_c91d3279341507c91f2de83a3b174638'] = 'Manifest printed';
$_MODULE['<{dpdpoland}prestashop>adminorder_b9ef6fb0879ec82c0446bda7233f01a2'] = 'Module is not configured yet. Please check required settings';
$_MODULE['<{dpdpoland}prestashop>adminorder_6c92285fa6d3e827b198d120ea3ac674'] = 'here';

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: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 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: 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

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,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,639 @@
/**
* 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_recipient_address_selection').live('change', function(){
$('#ajax_running').slideDown();
$('#dpdpoland_recipient_address_container .dpdpoland_address').fadeOut('fast');
var 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(){
var max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').attr('value');
var new_parcel_number = Number(max_parcel_number)+1;
var $tr_parcel = $('<tr />');
var $input_parcel_number = $('<input />').attr({'type' : 'hidden', 'name' : 'parcels['+new_parcel_number+'][number]'}).val(new_parcel_number);
var $td_parcel_number = $('<td />').addClass('center').append(new_parcel_number).append($input_parcel_number);
$tr_parcel.append($td_parcel_number);
var $input_content_hidden = $('<input />').attr({'type' : 'hidden', 'name' : 'parcels['+new_parcel_number+'][content]'});
var $input_content = $('<input />').attr({'type' : 'text', 'size' : '46', 'name' : 'parcels['+new_parcel_number+'][content]'});
var $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 $input_weight = $('<input />').attr({'type' : 'text', 'size' : '10', 'name' : 'parcels['+new_parcel_number+'][weight]', 'value' : '0.000000'});
var $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);
var $input_height = $('<input />').attr({'type' : 'text', 'size' : '10', 'name' : 'parcels['+new_parcel_number+'][height]', 'value' : '0.000000'});
var $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);
var $input_length = $('<input />').attr({'type' : 'text', 'size' : '10', 'name' : 'parcels['+new_parcel_number+'][length]', 'value' : '0.000000'});
var $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);
var $input_width = $('<input />').attr({'type' : 'text', 'size' : '10', 'name' : 'parcels['+new_parcel_number+'][width]', 'value' : '0.000000'});
var $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);
var $td_delete_parcel = $('<td />');
var $img_delete_parcel = $('<img />').attr({'src' : '../img/admin/delete.gif'}).addClass('delete_parcel').appendTo($td_delete_parcel);
$tr_parcel.append($td_delete_parcel);
$('#dpdpoland_shipment_parcels tbody tr:last').after($tr_parcel);
var $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(){
var $tr_parcel = $(this).parent().parent();
var deleted_parcel_number = $tr_parcel.find('input[name$="[number]"]').attr('value');
var 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) {
var products = [];
if (typeof(data.products) != 'undefined')
for (var 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_weight').attr('value', data.weight);
$('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value', data.name);
});
$('#dpdpoland_add_product').live('click', function(){
var id_product = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value');
if (Number(id_product))
{
var id_product_attribute = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value');
var weight_numeric = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value');
var weight = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value');
var product_name = $('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value');
var $tr_product = $('<tr />');
var new_product_index = $('#dpdpoland_shipment_products tbody tr').length;
var $input_id_product = $('<input />').attr({'type' : 'hidden', 'name' : 'dpdpoland_products['+new_product_index+'][id_product]', 'value' : id_product});
var $input_id_product_attribute = $('<input />').attr({'type' : 'hidden', 'name' : 'dpdpoland_products['+new_product_index+'][id_product_attribute]', 'value' : id_product_attribute});
var $td_parcel_reference = $('<td />').addClass('parcel_reference').append($input_id_product, $input_id_product_attribute, id_product+'_'+id_product_attribute);
$td_parcel_reference.appendTo($tr_product);
var $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);
var $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);
var $td_delete_product = $('<td />');
var $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_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(){
var 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('');
var pudo_code = $('#dpdpoland_pudo_code_input').val();
var 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(){
var 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('');
var pudo_code = $('#dpdpoland_pudo_code_input').val();
var 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(){
var default_value = 0;
var $inputs_container = $(this).parents('tr:first');
var height = $inputs_container.find('input[name$="[height]"]').attr('value');
var length = $inputs_container.find('input[name$="[length]"]').attr('value');
var width = $inputs_container.find('input[name$="[width]"]').attr('value');
var 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);
});
var 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) {
var cod_container = $('#dpdpoland_cod_amount_container');
var dpd_next_day_container = $('#dpdpoland_dpdnd_container');
var dpd_express_container = $('#dpdpoland_dpde_container');
if ( shipment_mode == 'domestic_with_cod') {
cod_container.fadeIn();
} 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();
} 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();
} else {
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
dpd_express_container.fadeOut();
dpd_next_day_container.fadeOut();
}
}
function updateParcelsListData()
{
var attr = $('#dpdpoland_shipment_creation select[name="dpdpoland_SessionType"]').attr('disabled');
if (typeof attr !== 'undefined' && attr !== false) {
return;
}
var default_value = 0;
var 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(3) 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(){
var product_weight = $(this).parent().find('td:nth-child(3)').find('input[type="hidden"]').val();
product_weight = Number(product_weight);
var product_id = $(this).find('input[type="hidden"]:nth-child(1)').val();
if ($(this).find('input[type="hidden"]:nth-child(2)').val() != '')
{
product_id = product_id + '_' + $(this).find('input[type="hidden"]:nth-child(2)').val();
}
var parcel_id = $(this).siblings().find('select').val();
var description = '';
var $parcel_description_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child('+parcel_id+') td:nth-child(2)').find('input[type="text"]');
var $parcel_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child('+parcel_id+') td:nth-child(3)').find('input[type="text"]');
var $parcel_height_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child('+parcel_id+') td:nth-child(4)').find('input[type="text"]');
var $parcel_lenght_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child('+parcel_id+') td:nth-child(5)').find('input[type="text"]');
var $parcel_width_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child('+parcel_id+') td:nth-child(6)').find('input[type="text"]');
var $parcel_dimension_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child('+parcel_id+') td:nth-child(7)');
var $parcel_description_safe = $parcel_description_field.siblings('input[type="hidden"]:first');
var weights = $parcel_weight_field.val();
weights = Number(weights);
weights = weights + product_weight;
if ($parcel_description_safe.attr('value') == '')
description = product_id;
else
description = $parcel_description_safe.attr('value') + ', ' + product_id;
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(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(6) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(7)').not('.modified').text(default_value.toFixed(3));
$parcel_height_field.attr('value', $('#product_height').val());
$parcel_lenght_field.attr('value', $('#product_length').val());
$parcel_width_field.attr('value', $('#product_width').val());
if (!$parcel_height_field.hasClass('modified') &&
!$parcel_lenght_field.hasClass('modified') &&
!$parcel_width_field.hasClass('modified')
)
{
var value = $parcel_height_field.val() * $parcel_lenght_field.val() * $parcel_width_field.val() / _DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_;
$parcel_dimension_weight_field.text(value.toFixed(3));
}
}
});
}
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(){
var parcel_number = Number($(this).attr('value'));
if(parcel_number > deleted_parcel_number)
{
var updated_parcel_number = parcel_number-1;
var $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()
{
var $display_cont = $('#dpdpoland_shipment_creation');
var $legend = $display_cont.siblings('legend').find('a');
var fieldset_title_substitution = $legend.attr('rel');
var current_fieldset_title = $legend.text();
var $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);
}
var animation_speed = 'fast';
function togglePudoMap()
{
var selected_carrier = $('select[name="dpdpoland_SessionType"] option:selected').val();
if (typeof selected_carrier == 'undefined') {
return;
}
if (selected_carrier == 'pudo') {
$('.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');
var 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)
{
var block = $('.js-result[data-point-id="'+id_point+'"]');
console.log(block.text());
}

View File

@@ -0,0 +1,630 @@
/**
* 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_recipient_address_selection').on('change', function () {
$('#ajax_running').slideDown();
$('#dpdpoland_recipient_address_container .dpdpoland_address').fadeOut('fast');
var 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 () {
var max_parcel_number = $('#dpdpoland_shipment_parcels tbody').find('input[name$="[number]"]:last').attr('value');
var new_parcel_number = Number(max_parcel_number) + 1;
var $tr_parcel = $('<tr />');
var $input_parcel_number = $('<input />').attr({
'type': 'hidden',
'name': 'parcels[' + new_parcel_number + '][number]'
}).val(new_parcel_number);
var $td_parcel_number = $('<td />').addClass('center').append(new_parcel_number).append($input_parcel_number);
$tr_parcel.append($td_parcel_number);
var $input_content_hidden = $('<input />').attr({
'type': 'hidden',
'name': 'parcels[' + new_parcel_number + '][content]'
});
var $input_content = $('<input />').attr({
'type': 'text',
'size': '46',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][content]'
});
var $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 $input_weight = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][weight]',
'value': '0.000000'
});
var $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);
var $input_height = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][height]',
'value': '0.000000'
});
var $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);
var $input_length = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][length]',
'value': '0.000000'
});
var $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);
var $input_width = $('<input />').attr({
'type': 'text',
'size': '10',
'class': 'form-control',
'name': 'parcels[' + new_parcel_number + '][width]',
'value': '0.000000'
});
var $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);
var $td_delete_parcel = $('<td />');
var $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);
var $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 () {
var $tr_parcel = $(this).parent().parent();
var deleted_parcel_number = $tr_parcel.find('input[name$="[number]"]').attr('value');
var 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 () {
var id_product = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product').attr('value');
if (Number(id_product)) {
var id_product_attribute = $('#dpdpoland_add_product_container #dpdpoland_selected_product_id_product_attribute').attr('value');
var weight_numeric = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight_numeric').attr('value');
var weight = $('#dpdpoland_add_product_container #dpdpoland_selected_product_weight').attr('value');
var product_name = $('#dpdpoland_add_product_container #dpdpoland_selected_product_name').attr('value');
var $tr_product = $('<tr />');
var new_product_index = $('#dpdpoland_shipment_products tbody tr').length;
var $input_id_product = $('<input />').attr({
'type': 'hidden',
'name': 'dpdpoland_products[' + new_product_index + '][id_product]',
'value': id_product
});
var $input_id_product_attribute = $('<input />').attr({
'type': 'hidden',
'name': 'dpdpoland_products[' + new_product_index + '][id_product_attribute]',
'value': id_product_attribute
});
var $td_parcel_reference = $('<td />').addClass('parcel_reference').append($input_id_product, $input_id_product_attribute, id_product + '_' + id_product_attribute);
$td_parcel_reference.appendTo($tr_product);
var $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);
var $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);
var $td_delete_product = $('<td />');
var $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_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 () {
var 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('');
var pudo_code = $('#dpdpoland_pudo_code_input').val();
var 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 () {
var 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('');
var pudo_code = $('#dpdpoland_pudo_code_input').val();
var pudo_data = "";
if (pudo_code.length > 0) {
pudo_data = "&dpdpoland_pudo_code=" + pudo_code;
}
console.log("id_order");
console.log(id_order);
$.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 () {
var default_value = 0;
var $inputs_container = $(this).parents('tr:first');
var height = $inputs_container.find('input[name$="[height]"]').attr('value');
var length = $inputs_container.find('input[name$="[length]"]').attr('value');
var width = $inputs_container.find('input[name$="[width]"]').attr('value');
var 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);
});
var 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) {
var cod_container = $('#dpdpoland_cod_amount_container');
var dpd_next_day_container = $('#dpdpoland_dpdnd_container');
var dpd_express_container = $('#dpdpoland_dpde_container');
if (shipment_mode == 'domestic_with_cod') {
cod_container.fadeIn();
} 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();
} 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();
} else {
dpd_express_container.find('input#dpdpoland_dpde').prop('checked', false);
dpd_next_day_container.find('input#dpdpoland_dpdnd').prop('checked', false);
dpd_express_container.fadeOut();
dpd_next_day_container.fadeOut();
}
}
function updateParcelsListData() {
var attr = $('#dpdpoland_shipment_creation select[name="dpdpoland_SessionType"]').attr('disabled');
if (typeof attr !== 'undefined' && attr !== false) {
return;
}
var default_value = 0;
var 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(3) 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 () {
var product_weight = $(this).parent().find('td:nth-child(3)').find('input[type="hidden"]').val();
product_weight = Number(product_weight);
var product_id = $(this).find('input[type="hidden"]:nth-child(1)').val();
if ($(this).find('input[type="hidden"]:nth-child(2)').val() != '') {
product_id = product_id + '_' + $(this).find('input[type="hidden"]:nth-child(2)').val();
}
var parcel_id = $(this).siblings().find('select').val();
var description = '';
var $parcel_description_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(2)').find('input[type="text"]');
var $parcel_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(3)').find('input[type="text"]');
var $parcel_height_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(4)').find('input[type="text"]');
var $parcel_lenght_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(5)').find('input[type="text"]');
var $parcel_width_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(6)').find('input[type="text"]');
var $parcel_dimension_weight_field = $('#dpdpoland_shipment_parcels tbody tr:nth-child(' + parcel_id + ') td:nth-child(7)');
var $parcel_description_safe = $parcel_description_field.siblings('input[type="hidden"]:first');
var weights = $parcel_weight_field.val();
weights = Number(weights);
weights = weights + product_weight;
if ($parcel_description_safe.attr('value') == '')
description = product_id;
else
description = $parcel_description_safe.attr('value') + ', ' + product_id;
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(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(6) input[type="text"]').not('.modified').attr('value', default_value.toFixed(6));
$('#dpdpoland_shipment_parcels td:nth-child(7)').not('.modified').text(default_value.toFixed(3));
$parcel_height_field.attr('value', $('#product_height').val());
$parcel_lenght_field.attr('value', $('#product_length').val());
$parcel_width_field.attr('value', $('#product_width').val());
if (!$parcel_height_field.hasClass('modified') &&
!$parcel_lenght_field.hasClass('modified') &&
!$parcel_width_field.hasClass('modified')
) {
var value = $parcel_height_field.val() * $parcel_lenght_field.val() * $parcel_width_field.val() / _DPDPOLAND_DIMENTION_WEIGHT_DIVISOR_;
$parcel_dimension_weight_field.text(value.toFixed(3));
}
}
});
}
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 () {
var parcel_number = Number($(this).attr('value'));
if (parcel_number > deleted_parcel_number) {
var updated_parcel_number = parcel_number - 1;
var $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() {
var $display_cont = $('#dpdpoland_shipment_creation');
var $legend = $display_cont.siblings('legend').find('a');
var fieldset_title_substitution = $legend.attr('rel');
var current_fieldset_title = $legend.text();
var $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);
}
var animation_speed = 'fast';
function togglePudoMap() {
var selected_carrier = $('select[name="dpdpoland_SessionType"] option:selected').val();
if (typeof selected_carrier == 'undefined') {
return;
}
if (selected_carrier == 'pudo') {
$('.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');
var 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) {
var 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,297 @@
/**
* 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 () {
if ($('#credentials').length != 0) { //in configuration page only
showHideCODModulesList();
}
$('#addClientNumber').click(function () {
addClientNumber();
});
$('#dpd_standard_cod').change(function () {
showHideCODModulesList();
enableDisableZones();
});
$('#dpd_standard').change(function () {
enableDisableZones();
});
$('#dpd_classic').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_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');
}
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 showHideCODModulesList() {
if ($('#dpd_standard_cod').is(':checked')) {
$('.payment_modules_container').slideDown('fast');
} else {
$('.payment_modules_container').slideUp('fast');
}
}
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,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,121 @@
/**
* 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.
*/
var animation_speed = 'fast';
var dpdPolandPointId = 0;
$(document).ready(function () {
togglePudoMap();
togglePudoMap17();
togglePudoMap14();
$(document).on('click', '.delivery_option_radio', togglePudoMap);
$(document).on('click', 'input[name^="delivery_option"]', togglePudoMap17);
$(document).on('click', 'input[name="id_carrier"]', togglePudoMap14);
$(document).ajaxStop(function () {
togglePudoMap();
});
});
function toggleCheckoutButton(idSelectedCarrier) {
if (idSelectedCarrier == id_pudo_carrier && dpdPolandPointId == 0) {
$('button[name="processCarrier"]').attr('disabled');
}
if (idSelectedCarrier != id_pudo_carrier || dpdPolandPointId != 0) {
$('button[name="processCarrier"]').removeAttr('disabled');
}
}
function togglePudoMap() {
var id_selected_carrier = $('.delivery_option_radio:checked').val();
if (typeof id_selected_carrier == 'undefined') {
return;
}
id_selected_carrier = id_selected_carrier.replace(',', '');
if (typeof id_selected_carrier == 'undefined' || id_selected_carrier == 0) {
return;
}
if (id_selected_carrier == id_pudo_carrier) {
$('.pudo-map-container').slideDown(animation_speed);
} else {
$('.pudo-map-container').slideUp(animation_speed);
}
if (id_selected_carrier == id_pudo_carrier && dpdPolandPointId == 0) {
$('button[name="processCarrier"]').attr('disabled', 'disabled');
}
if (id_selected_carrier != id_pudo_carrier || dpdPolandPointId != 0) {
$('button[name="processCarrier"]').removeAttr('disabled');
}
}
function togglePudoMap17() {
var id_selected_carrier_ps17 = $('input[name^="delivery_option"]:checked').val();
if (typeof id_selected_carrier_ps17 == 'undefined') {
return;
}
id_selected_carrier_ps17 = id_selected_carrier_ps17.replace(',', '');
if (typeof id_selected_carrier_ps17 == 'undefined' || id_selected_carrier_ps17 == 0) {
return;
}
if (id_selected_carrier_ps17 == id_pudo_carrier) {
$('.pudo-map-container').slideDown(animation_speed);
} else {
$('.pudo-map-container').slideUp(animation_speed);
}
if (id_selected_carrier_ps17 == id_pudo_carrier && dpdPolandPointId == 0) {
$('button[name="confirmDeliveryOption"]').attr('disabled', 'disabled');
}
if (id_selected_carrier_ps17 != id_pudo_carrier || dpdPolandPointId != 0) {
$('button[name="confirmDeliveryOption"]').removeAttr('disabled');
}
}
function togglePudoMap14() {
var id_selected_carrier_ps14 = $('input[name="id_carrier"]:checked').val();
if (typeof id_selected_carrier_ps14 == 'undefined') {
return;
}
id_selected_carrier_ps14 = id_selected_carrier_ps14.replace(',', '');
if (typeof id_selected_carrier_ps14 == 'undefined' || id_selected_carrier_ps14 == 0) {
return;
}
if (id_selected_carrier_ps14 == id_pudo_carrier) {
$('.pudo-map-container').slideDown(animation_speed);
} else {
$('.pudo-map-container').slideUp(animation_speed);
}
}

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