2017-08-30 11:37:48 +02:00

76 lines
2.5 KiB
PHP

<?php
/**
* TNT OFFICIAL MODULE FOR PRESTASHOP
*
* @author GFI Informatique <www.gfi.fr>
* @copyright 2016-2017 GFI Informatique, 2016-2017 TNT
* @license https://opensource.org/licenses/MIT MIT License
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_2_13($objTNT)
{
$templateOverrides = array(
array(
'fileName' => 'view.tpl',
'directorySrc' => 'views/templates/admin/override/controllers/admin/templates/orders/helpers/view/',
'directoryDst' => 'controllers/admin/templates/orders/helpers/view/',
),
);
foreach ($templateOverrides as $template) {
try {
$directoryDst = _PS_OVERRIDE_DIR_.$template['directoryDst'];
if (!is_dir($directoryDst)) {
mkdir($directoryDst, 0777, true);
}
$overrideDestination = $directoryDst.$template['fileName'];
if (file_exists($overrideDestination)) {
unlink($overrideDestination);
}
} catch (Exception $objException) {
$logger = new FileLogger();
$logger->setFilename(_PS_ROOT_DIR_.'/log/'.date('Ymd').'_tnt_exception.log');
$logger->log($objException->getMessage(), 3);
return false;
}
try {
$directoryDst = _PS_OVERRIDE_DIR_.$template['directoryDst'];
if (!is_dir($directoryDst)) {
mkdir($directoryDst, 0777, true);
}
$overrideSrc = $objTNT->getLocalPath().$template['directorySrc'].$template['fileName'];
$overrideDestination = $directoryDst.$template['fileName'];
copy($overrideSrc, $overrideDestination);
} catch (Exception $objException) {
$logger = new FileLogger();
$logger->setFilename(_PS_ROOT_DIR_.'/log/'.date('Ymd').'_tnt_exception.log');
$logger->log($objException->getMessage(), 3);
return false;
}
}
// Reinstall Overrides
if (!$objTNT->uninstallOverrides()) {
return false;
}
if (!$objTNT->installOverrides()) {
return false;
}
$intCarrierIDTNT = Configuration::get('TNT_CARRIER_ID');
if ($intCarrierIDTNT > 0) {
Db::getInstance()->execute('
UPDATE '._DB_PREFIX_.'carrier
SET max_weight = 0.0
WHERE id_carrier = '.(int)$intCarrierIDTNT);
}
return true;
}