Initial commit

This commit is contained in:
2020-10-07 10:37:15 +02:00
commit ce5f440392
28157 changed files with 4429172 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2020 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 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/afl-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-2020 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 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,61 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.0.1
*
* - Sender address: replace serialized value stored in Configuration table with json encoded value
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_0_1($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.0.1');
$senderAddresses = Configuration::getMultiShopValues('COLISSIMO_SENDER_ADDRESS');
foreach ($senderAddresses as $idShop => $senderAddress) {
if (!$senderAddress) {
continue;
}
$address = (array) unserialize($senderAddress);
if (!is_array($address) || empty($address)) {
continue;
}
Configuration::updateValue('COLISSIMO_SENDER_ADDRESS', json_encode($address), false, null, (int) $idShop);
}
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.0.2
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_0_2($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.0.2');
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.0.3
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_0_3($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.0.3');
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,81 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.0.4
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_0_4($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.0.4');
if (version_compare(_PS_VERSION_, '1.7', '>=')) {
$module->unregisterHook('actionCarrierProcess');
$module->logger->info('Unregister actionCarrierProcess');
} else {
$module->unregisterHook('actionValidateStepComplete');
$module->logger->info('Unregister actionValidateStepComplete');
}
$OMWithoutSignatureId = ColissimoService::getServiceIdByIdCarrierDestinationType(
Configuration::get('COLISSIMO_CARRIER_SANS_SIGNATURE'),
'OM'
);
if (!$OMWithoutSignatureId) {
$colissimoService = new ColissimoService();
$colissimoService->id_carrier = (int) Configuration::get('COLISSIMO_CARRIER_SANS_SIGNATURE');
$colissimoService->product_code = 'COM';
$colissimoService->commercial_name = 'OM - DOMICILE sans signature';
$colissimoService->destination_type = 'OM';
$colissimoService->is_signature = 0;
$colissimoService->is_pickup = 0;
$colissimoService->is_return = 0;
$colissimoService->type = 'SANS_SIGNATURE';
try {
$colissimoService->save();
$module->logger->info('COM service added.');
} catch (Exception $e) {
$module->logger->error('Cannot add OM without signature service.', array('message' => $e->getMessage()));
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
} else {
$module->logger->info('COM service already exists.');
}
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.0.5
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_0_5($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.0.5');
$europePickupPointId = ColissimoService::getServiceIdByProductCodeDestinationType('PCS', 'EUROPE');
if (!$europePickupPointId) {
$colissimoService = new ColissimoService();
$colissimoService->id_carrier = (int) Configuration::get('COLISSIMO_CARRIER_RELAIS');
$colissimoService->product_code = 'PCS';
$colissimoService->commercial_name = 'EU - POINT RETRAIT';
$colissimoService->destination_type = 'EUROPE';
$colissimoService->is_signature = 0;
$colissimoService->is_pickup = 1;
$colissimoService->is_return = 0;
$colissimoService->type = 'RELAIS';
try {
$colissimoService->save();
$module->logger->info('PCS service added.');
} catch (Exception $e) {
$module->logger->error('Cannot add PCS service.', array('message' => $e->getMessage()));
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
} else {
$module->logger->info('PCS service already exists.');
}
Configuration::updateGlobalValue('COLISSIMO_SHOW_WHATS_NEW', 1);
Configuration::updateGlobalValue('COLISSIMO_WIDGET_REMOTE', 1);
$module->logger->info('Clearing cache.');
Tools::clearCache();
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.0.6
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_0_6($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.0.6');
if (version_compare(_PS_VERSION_, '1.7', '<')) {
if (!$module->isRegisteredInHook('displayPaymentTop')) {
$module->registerHook('displayPaymentTop');
$module->logger->info('Register module on displayPaymentTop');
} else {
$module->logger->info('Module already registered on displayPaymentTop');
}
}
Configuration::updateGlobalValue('COLISSIMO_SHOW_WHATS_NEW', 0);
$module->logger->info('Clearing cache.');
Tools::clearCache();
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.1.0
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_1_0($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.1.0');
// Add new column in colissimo_label table if needed
try {
$columnExists = Db::getInstance()
->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.'colissimo_label` LIKE "insurance"');
} catch (Exception $e) {
$module->logger->error($e->getMessage());
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
if (empty($columnExists)) {
$result = Db::getInstance()
->execute(
'ALTER TABLE `'._DB_PREFIX_.'colissimo_label` ADD COLUMN `insurance` TINYINT(3) UNSIGNED NULL DEFAULT NULL AFTER `migration`'
);
if (!$result) {
$module->logger->error('Cannot add column in colissimo_label table.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$module->logger->info('New column in colissimo_label created.');
} else {
$module->logger->info('Column insurance already exists.');
}
// New statuses creation
try {
$module->installOrderStates();
$module->logger->info('New order states installed.');
} catch (Exception $e) {
$module->logger->error($e->getMessage());
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
// Default values for new configurations
Configuration::updateValue('COLISSIMO_USE_HANDLED_BY_CARRIER', 0);
Configuration::updateValue('COLISSIMO_USE_SHIPPING_IN_PROGRESS', 0);
$module->logger->info('Clearing cache.');
Tools::clearCache();
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
Configuration::updateGlobalValue('COLISSIMO_SHOW_WHATS_NEW', 1);
return true;
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.1.1
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_1_1($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.1.1');
// Add new column in colissimo_label table if needed
try {
$columnExists = Db::getInstance()
->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.'colissimo_label` LIKE "insurance"');
} catch (Exception $e) {
$module->logger->error($e->getMessage());
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
if (empty($columnExists)) {
$result = Db::getInstance()
->execute(
'ALTER TABLE `'._DB_PREFIX_.'colissimo_label` ADD COLUMN `insurance` TINYINT(3) UNSIGNED NULL DEFAULT NULL AFTER `migration`'
);
if (!$result) {
$module->logger->error('Cannot add column in colissimo_label table.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$module->logger->info('New column in colissimo_label created.');
} else {
$module->logger->info('Column insurance already exists.');
}
$module->logger->info('Clearing cache.');
Tools::clearCache();
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
Configuration::updateGlobalValue('COLISSIMO_SHOW_WHATS_NEW', 0);
return true;
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.1.2
*
* @param $module Colissimo
* @return bool
*/
function upgrade_module_1_1_2($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.1.2');
$module->logger->info('Clearing cache.');
Tools::clearCache();
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
Configuration::updateGlobalValue('COLISSIMO_SHOW_WHATS_NEW', 0);
return true;
}

View File

@@ -0,0 +1,211 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.2.0
*
* @param $module Colissimo
* @return bool
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
function upgrade_module_1_2_0($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.2.0');
// Create new tables
$colissimoCustomCategoryQuery = "CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'colissimo_custom_category` (
`id_colissimo_custom_category` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`id_category` INT(10) NULL DEFAULT 0,
`short_desc` VARCHAR(64) NULL DEFAULT NULL,
`id_country_origin` INT(10) NULL DEFAULT 0,
`hs_code` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`id_colissimo_custom_category`)
)";
$colissimoCustomCategory = Db::getInstance()
->execute($colissimoCustomCategoryQuery);
if (!$colissimoCustomCategory) {
$module->logger->error('Cannot create table colissimo_custom_category.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$colissimoCustomProductQuery = "CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'colissimo_custom_product` (
`id_colissimo_custom_product` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`id_product` INT(10) NULL DEFAULT 0,
`short_desc` VARCHAR(64) NULL DEFAULT NULL,
`id_country_origin` INT(10) NULL DEFAULT 0,
`hs_code` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`id_colissimo_custom_product`)
)";
$colissimoCustomProduct = Db::getInstance()
->execute($colissimoCustomProductQuery);
if (!$colissimoCustomProduct) {
$module->logger->error('Cannot create table colissimo_custom_product.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
// Add new hooks
if (!$module->isRegisteredInHook('displayAdminProductsExtra')) {
$module->registerHook('displayAdminProductsExtra');
$module->logger->info('Register module on displayAdminProductsExtra');
} else {
$module->logger->info('Module already registered on displayAdminProductsExtra');
}
if (!$module->isRegisteredInHook('actionProductUpdate')) {
$module->registerHook('actionProductUpdate');
$module->logger->info('Register module on actionProductUpdate');
} else {
$module->logger->info('Module already registered on actionProductUpdate');
}
if (!$module->isRegisteredInHook('actionAdminCategoriesControllerSaveAfter')) {
$module->registerHook('actionAdminCategoriesControllerSaveAfter');
$module->logger->info('Register module on actionAdminCategoriesControllerSaveAfter');
} else {
$module->logger->info('Module already registered on actionAdminCategoriesControllerSaveAfter');
}
if (!$module->isRegisteredInHook('actionAdminCategoriesFormModifier')) {
$module->registerHook('actionAdminCategoriesFormModifier');
$module->logger->info('Register module on actionAdminCategoriesFormModifier');
} else {
$module->logger->info('Module already registered on actionAdminCategoriesFormModifier');
}
if (!$module->isRegisteredInHook('actionCategoryFormBuilderModifier')) {
$module->registerHook('actionCategoryFormBuilderModifier');
$module->logger->info('Register module on actionCategoryFormBuilderModifier');
} else {
$module->logger->info('Module already registered on actionCategoryFormBuilderModifier');
}
if (!$module->isRegisteredInHook('actionAfterCreateCategoryFormHandler')) {
$module->registerHook('actionAfterCreateCategoryFormHandler');
$module->logger->info('Register module on actionAfterCreateCategoryFormHandler');
} else {
$module->logger->info('Module already registered on actionAfterCreateCategoryFormHandler');
}
if (!$module->isRegisteredInHook('actionAfterUpdateCategoryFormHandler')) {
$module->registerHook('actionAfterUpdateCategoryFormHandler');
$module->logger->info('Register module on actionAfterUpdateCategoryFormHandler');
} else {
$module->logger->info('Module already registered on actionAfterUpdateCategoryFormHandler');
}
// Add INTRA_DOM in destination_type value
$result = Db::getInstance()
->execute(
"ALTER TABLE `"._DB_PREFIX_."colissimo_service` MODIFY COLUMN `destination_type` ENUM('FRANCE','OM','EUROPE','WORLDWIDE','INTRA_DOM')"
);
if (!$result) {
$module->logger->error('Cannot update column destination_type in colissimo_service table.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$module->logger->info('Column destination_type in colissimo_service updated.');
// add services COLD et COL
$COLDService = ColissimoService::getServiceIdByIdCarrierDestinationType(
Configuration::get('COLISSIMO_CARRIER_SANS_SIGNATURE'),
'INTRA_DOM'
);
if (!$COLDService) {
$colissimoService = new ColissimoService();
$colissimoService->id_carrier = (int) Configuration::get('COLISSIMO_CARRIER_SANS_SIGNATURE');
$colissimoService->product_code = 'COLD';
$colissimoService->commercial_name = 'FR - DOMICILE sans signature';
$colissimoService->destination_type = 'INTRA_DOM';
$colissimoService->is_signature = 0;
$colissimoService->is_pickup = 0;
$colissimoService->is_return = 0;
$colissimoService->type = 'SANS_SIGNATURE';
try {
$colissimoService->save();
$module->logger->info('COLD service added.');
} catch (Exception $e) {
$module->logger->error('Cannot add COLD service.', array('message' => $e->getMessage()));
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
} else {
$module->logger->info('COLD service already exists.');
}
$COLService = ColissimoService::getServiceIdByIdCarrierDestinationType(
Configuration::get('COLISSIMO_CARRIER_AVEC_SIGNATURE'),
'INTRA_DOM'
);
if (!$COLService) {
$colissimoService = new ColissimoService();
$colissimoService->id_carrier = (int) Configuration::get('COLISSIMO_CARRIER_AVEC_SIGNATURE');
$colissimoService->product_code = 'COL';
$colissimoService->commercial_name = 'FR - DOMICILE avec signature';
$colissimoService->destination_type = 'INTRA_DOM';
$colissimoService->is_signature = 1;
$colissimoService->is_pickup = 0;
$colissimoService->is_return = 0;
$colissimoService->type = 'AVEC_SIGNATURE';
try {
$colissimoService->save();
$module->logger->info('COL service added.');
} catch (Exception $e) {
$module->logger->error('Cannot add COL service.', array('message' => $e->getMessage()));
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
} else {
$module->logger->info('COLD service already exists.');
}
//Add iso FR in sender address
$senderAddresses = Configuration::getMultiShopValues('COLISSIMO_SENDER_ADDRESS');
foreach ($senderAddresses as $idShop => $senderAddress) {
if (!$senderAddress) {
continue;
}
$address = (array) json_decode($senderAddress);
$address['sender_country'] = 'FR';
Configuration::updateValue('COLISSIMO_SENDER_ADDRESS', json_encode($address), false, null, (int) $idShop);
}
// Default values for new configurations
Configuration::updateValue('COLISSIMO_ENABLE_BREXIT', 0);
Configuration::updateValue('COLISSIMO_USE_RETURN_ADDRESS', 0);
Configuration::updateValue('COLISSIMO_RETURN_ADDRESS', '');
$module->logger->info('Clearing cache.');
Tools::clearCache();
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
Configuration::updateGlobalValue('COLISSIMO_SHOW_WHATS_NEW', 1);
return true;
}

View File

@@ -0,0 +1,95 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.2.1
*
* @param $module Colissimo
* @return bool
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
function upgrade_module_1_2_1($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.2.1');
$senderAddressGlobal = Configuration::getGlobalValue('COLISSIMO_SENDER_ADDRESS');
if ($senderAddressGlobal) {
$senderAddress = (array) json_decode($senderAddressGlobal);
$senderAddress['sender_country'] = 'FR';
Configuration::updateGlobalValue('COLISSIMO_SENDER_ADDRESS', json_encode($senderAddress));
}
// Create new tables
$colissimoCustomCategoryQuery = "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."colissimo_custom_category` (
`id_colissimo_custom_category` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`id_category` INT(10) NULL DEFAULT 0,
`short_desc` VARCHAR(64) NULL DEFAULT NULL,
`id_country_origin` INT(10) NULL DEFAULT 0,
`hs_code` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`id_colissimo_custom_category`)
)";
$colissimoCustomCategory = Db::getInstance()
->execute($colissimoCustomCategoryQuery);
if (!$colissimoCustomCategory) {
$module->logger->error('Cannot create table colissimo_custom_category.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$colissimoCustomProductQuery = "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."colissimo_custom_product` (
`id_colissimo_custom_product` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`id_product` INT(10) NULL DEFAULT 0,
`short_desc` VARCHAR(64) NULL DEFAULT NULL,
`id_country_origin` INT(10) NULL DEFAULT 0,
`hs_code` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`id_colissimo_custom_product`)
)";
$colissimoCustomProduct = Db::getInstance()
->execute($colissimoCustomProductQuery);
if (!$colissimoCustomProduct) {
$module->logger->error('Cannot create table colissimo_custom_product.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
Db::getInstance()->execute("DROP TABLE IF EXISTS `'._DB_PREFIX_.'colissimo_custom_product`");
Db::getInstance()->execute("DROP TABLE IF EXISTS `'._DB_PREFIX_.'colissimo_custom_category`");
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,112 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.3.0
*
* @param $module Colissimo
* @return bool
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
function upgrade_module_1_3_0($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.3.0');
// Add new column in colissimo_order table if needed
try {
$columnExists = Db::getInstance()
->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.'colissimo_order` LIKE "hidden"');
} catch (Exception $e) {
$module->logger->error($e->getMessage());
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
if (empty($columnExists)) {
$result = Db::getInstance()
->execute('ALTER TABLE `'._DB_PREFIX_.'colissimo_order` ADD COLUMN `hidden` TINYINT(3) UNSIGNED NULL DEFAULT \'0\' AFTER `migration`;');
if (!$result) {
$module->logger->error('Cannot add column in colissimo_order table.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$module->logger->info('New column in colissimo_order created.');
} else {
$module->logger->info('Column hidden already exists.');
}
$logsTab = Tab::getInstanceFromClassName('AdminColissimoLogs');
if (!Validate::isLoadedObject($logsTab)) {
try {
$module->installMenu(array(
'visible' => false,
'class_name' => 'AdminColissimoLogs',
));
} catch (Exception $e) {
$module->logger->error('Cannot install Logs menu.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
}
$COLDServiceId = ColissimoService::getServiceIdByProductCodeDestinationType(
'COLD',
ColissimoTools::DEST_INTRA_OM
);
if ($COLDServiceId) {
$COLDService = new ColissimoService((int) $COLDServiceId);
$COLDService->commercial_name = 'DOM - DOMICILE sans signature';
$COLDService->save();
}
$COLServiceId = ColissimoService::getServiceIdByProductCodeDestinationType(
'COL',
ColissimoTools::DEST_INTRA_OM
);
if ($COLServiceId) {
$COLService = new ColissimoService((int) $COLServiceId);
$COLService->commercial_name = 'DOM - DOMICILE avec signature';
$COLService->save();
}
Configuration::updateValue('COLISSIMO_ENABLE_PNA_MAIL', 1);
$module->registerHook('addWebserviceResources');
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.3.1
*
* @param $module Colissimo
* @return bool
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
function upgrade_module_1_3_1($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.3.1');
// Add new column in colissimo_order table if needed
try {
$columnExists = Db::getInstance()
->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.'colissimo_order` LIKE "hidden"');
} catch (Exception $e) {
$module->logger->error($e->getMessage());
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
if (empty($columnExists)) {
$result = Db::getInstance()
->execute('ALTER TABLE `'._DB_PREFIX_.'colissimo_order` ADD COLUMN `hidden` TINYINT(3) UNSIGNED NULL DEFAULT \'0\' AFTER `migration`;');
if (!$result) {
$module->logger->error('Cannot add column in colissimo_order table.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$module->logger->info('New column in colissimo_order created.');
} else {
$module->logger->info('Column hidden already exists.');
}
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}

View File

@@ -0,0 +1,106 @@
<?php
/**
* 2007-2020 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-2020 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 (!defined('_PS_VERSION_')) {
exit;
}
/**
* Upgrade to 1.4.0
*
* @param $module Colissimo
* @return bool
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
function upgrade_module_1_4_0($module)
{
$logsEnabled = Configuration::get('COLISSIMO_LOGS');
Configuration::updateValue('COLISSIMO_LOGS', 1);
$module->initLogger();
$module->logger->setChannel('ModuleUpgrade');
$module->logger->info('Module upgrade. Version 1.4.0');
if (Tools::version_compare(_PS_VERSION_, '1.7.7.0', '>=')) {
$module->logger->info('Hook / Unhook Admin Order');
$module->registerHook('displayAdminOrderMainBottom');
$module->unregisterHook('displayAdminOrder');
}
// Add new column in colissimo_order table if needed
try {
$columnExists = Db::getInstance()
->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.'colissimo_order` LIKE "hidden"');
} catch (Exception $e) {
$module->logger->error($e->getMessage());
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
if (empty($columnExists)) {
$result = Db::getInstance()
->execute('ALTER TABLE `'._DB_PREFIX_.'colissimo_order` ADD COLUMN `hidden` TINYINT(3) UNSIGNED NULL DEFAULT \'0\' AFTER `migration`;');
if (!$result) {
$module->logger->error('Cannot add column in colissimo_order table.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$module->logger->info('New column in colissimo_order created.');
} else {
$module->logger->info('Column hidden already exists.');
}
try {
$columnExists = Db::getInstance()
->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.'colissimo_label` LIKE "insurance"');
} catch (Exception $e) {
$module->logger->error($e->getMessage());
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
if (empty($columnExists)) {
$result = Db::getInstance()
->execute(
'ALTER TABLE `'._DB_PREFIX_.'colissimo_label` ADD COLUMN `insurance` TINYINT(3) UNSIGNED NULL DEFAULT NULL AFTER `migration`'
);
if (!$result) {
$module->logger->error('Cannot add column in colissimo_label table.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return false;
}
$module->logger->info('New column in colissimo_label created.');
} else {
$module->logger->info('Column insurance already exists.');
}
$module->logger->info('Module upgraded.');
Configuration::updateValue('COLISSIMO_LOGS', (int) $logsEnabled);
return true;
}