Fixed styles on old PS versions. Sort the logs by modified date in the settings

This commit is contained in:
max-baranikov 2022-06-03 17:49:00 +03:00 committed by GitHub
parent ed2e48f88b
commit 1fe840d96f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 189 additions and 36 deletions

View File

@ -1,3 +1,7 @@
## v3.4.1
* Исправлено стили страницы настроек для старых версий PS
* Исправлена сортировка файлов журналов на странице настроек
## v3.4.0
* Обновлен дизайн настроек модуля
* Добавлена возможность выгружать в CRM только невыгруженные заказы

View File

@ -1 +1 @@
3.4.0
3.4.1

View File

@ -540,7 +540,9 @@ class RetailcrmExport
private static function handleError($entityId, $exception)
{
RetailcrmLogger::writeException('export', $exception, sprintf(
'Error while building %s: %s', $entityId, $exception->getMessage()
'Error while building %s: %s',
$entityId,
$exception->getMessage()
), true);
RetailcrmLogger::output($exception->getMessage());
}

View File

@ -122,8 +122,7 @@ class RetailcrmHistory
if (isset($customerHistory['externalId'])) {
$crmCustomerResponse = self::$api->customersGet($customerHistory['externalId']);
if (
null === $crmCustomerResponse
if (null === $crmCustomerResponse
|| !$crmCustomerResponse->isSuccessful()
|| !$crmCustomerResponse->offsetExists('customer')
) {
@ -498,8 +497,7 @@ class RetailcrmHistory
{
$crmOrderResponse = self::$api->ordersGet($id, $by);
if (
null !== $crmOrderResponse
if (null !== $crmOrderResponse
&& $crmOrderResponse->isSuccessful()
&& $crmOrderResponse->offsetExists('order')
) {
@ -693,15 +691,13 @@ class RetailcrmHistory
WHERE id_order = ' . pSQL((int) $order_id) . '
AND product_id = ' . pSQL((int) $product_id) . '
AND product_attribute_id = ' . pSQL((int) $product_attribute_id) . '
AND id_order_detail = ' . pSQL((int) $id_order_detail)
);
AND id_order_detail = ' . pSQL((int) $id_order_detail));
}
private static function getNewOrderDetailId()
{
return Db::getInstance()->getRow('
SELECT MAX(id_order_detail) FROM ' . _DB_PREFIX_ . 'order_detail'
);
SELECT MAX(id_order_detail) FROM ' . _DB_PREFIX_ . 'order_detail');
}
/**
@ -798,8 +794,7 @@ class RetailcrmHistory
$notOurChanges[$externalId] = [];
}
if (
'api' == $entry['source']
if ('api' == $entry['source']
&& isset($entry['apiKey']['current'])
&& true == $entry['apiKey']['current']
) {
@ -1072,12 +1067,11 @@ class RetailcrmHistory
try {
RetailcrmLogger::writeDebug(__METHOD__, sprintf(
'<Customer ID: %d> %s::%s',
$newOrder->id_customer,
get_class($newOrder),
'add'
)
);
'<Customer ID: %d> %s::%s',
$newOrder->id_customer,
get_class($newOrder),
'add'
));
$newOrder->add(false, false);
$newOrderHistoryRecord = new OrderHistory(null, static::$default_lang, Context::getContext()->shop->id);
@ -1265,8 +1259,7 @@ class RetailcrmHistory
$orderAddressCrm = isset($order['delivery']['address']) ? $order['delivery']['address'] : [];
$orderPhone = $orderAddress->phone;
if (
RetailcrmHistoryHelper::isAddressLineChanged($orderAddressCrm)
if (RetailcrmHistoryHelper::isAddressLineChanged($orderAddressCrm)
|| !Validate::isLoadedObject($orderAddress)
) {
$infoOrder = self::getOrderFromCrm($order['externalId']);
@ -1320,8 +1313,7 @@ class RetailcrmHistory
$orderDeliveryCode = !empty($order['delivery']['code']) ? $order['delivery']['code'] : null;
$orderDeliveryCost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : null;
if (
(
if ((
null !== $orderDeliveryCode
&& isset(self::$deliveries[$orderDeliveryCode])
&& null !== self::$deliveries[$orderDeliveryCode]
@ -1389,7 +1381,8 @@ class RetailcrmHistory
$orderPayment->amount = isset($payment['amount']) ? $payment['amount'] : $orderToUpdate->total_paid;
$orderPayment->date_add = isset($payment['paidAt']) ? $payment['paidAt'] : date('Y-m-d H:i:s');
RetailcrmLogger::writeDebug(__METHOD__,
RetailcrmLogger::writeDebug(
__METHOD__,
sprintf(
'<Order Reference: %s> %s::%s',
$orderToUpdate->reference,

View File

@ -86,7 +86,8 @@ class RetailcrmExceptionMiddleware implements RetailcrmMiddlewareInterface
RetailcrmLogger::writeNoCaller($exception->getTraceAsString());
return new RetailcrmApiResponse(
500, json_encode([
500,
json_encode([
'success' => false,
'errorMsg' => $errorMsg,
])

View File

@ -181,7 +181,9 @@ class RetailcrmExportOrdersMiddleware implements RetailcrmMiddlewareInterface
{
if (isset($order['externalId'])) {
RetailcrmExportOrdersHelper::updateExportState(
$order['externalId'], null, [$e->getMessage()]
$order['externalId'],
null,
[$e->getMessage()]
);
}

View File

@ -46,8 +46,7 @@ class RetailcrmReferenceMiddleware implements RetailcrmMiddlewareInterface
/** @var RetailcrmApiResponse $response */
$response = $next($request);
if (
null !== $response
if (null !== $response
&& $response->isSuccessful()
&& (
'ordersCreate' === $request->getMethod()
@ -57,8 +56,7 @@ class RetailcrmReferenceMiddleware implements RetailcrmMiddlewareInterface
$receiveOrderNumber = (bool) (Configuration::get(RetailCRM::ENABLE_ORDER_NUMBER_RECEIVING));
$crmOrder = $response->order;
if (
$receiveOrderNumber
if ($receiveOrderNumber
&& isset($crmOrder['externalId'], $crmOrder['number'])
) {
$object = new Order($crmOrder['externalId']);

View File

@ -81,6 +81,17 @@ class RetailcrmSettingsHelper
];
}
$orderBy = 'modified';
$orderDirection = SORT_DESC;
array_multisort(
array_map(function ($item) use ($orderBy) {
return $item[$orderBy];
}, $fileNames),
$orderDirection,
$fileNames
);
return $fileNames;
}

View File

@ -111,7 +111,7 @@ class RetailCRM extends Module
{
$this->name = 'retailcrm';
$this->tab = 'export';
$this->version = '3.4.0';
$this->version = '3.4.1';
$this->author = 'DIGITAL RETAIL TECHNOLOGIES SL';
$this->displayName = $this->l('Simla.com');
$this->description = $this->l('Integration module for Simla.com');
@ -235,7 +235,8 @@ class RetailCRM extends Module
$tab->delete();
} catch (PrestaShopException $e) {
RetailcrmLogger::writeCaller(
__METHOD__, sprintf('Error while deleting old tabs: %s', $e->getMessage())
__METHOD__,
sprintf('Error while deleting old tabs: %s', $e->getMessage())
);
RetailcrmLogger::writeDebug(__METHOD__, $e->getTraceAsString());
@ -369,7 +370,9 @@ class RetailCRM extends Module
$relativePath = str_replace('retailcrm/', '', $file);
$fullPath = sprintf(
'%s/%s', __DIR__, $relativePath
'%s/%s',
__DIR__,
$relativePath
);
if (!file_exists($fullPath)) {
@ -377,7 +380,8 @@ class RetailCRM extends Module
}
RetailcrmLogger::writeCaller(
__METHOD__, sprintf('Remove `%s`', $file)
__METHOD__,
sprintf('Remove `%s`', $file)
);
unlink($fullPath); // todo maybe check and remove empty directories

View File

@ -98,7 +98,9 @@ function upgrade_module_3_0_2_remove_old_files($files)
}
$fullPath = sprintf(
'%s/../%s', __DIR__, str_replace('retailcrm/', '', $file)
'%s/../%s',
dirname(__FILE__),
str_replace('retailcrm/', '', $file)
);
if (!file_exists($fullPath)) {
@ -106,7 +108,8 @@ function upgrade_module_3_0_2_remove_old_files($files)
}
RetailcrmLogger::writeCaller(
__METHOD__, sprintf('Remove `%s`', $file)
__METHOD__,
sprintf('Remove `%s`', $file)
);
unlink($fullPath);

View File

@ -0,0 +1,45 @@
<?php
/**
* MIT License
*
* Copyright (c) 2021 DIGITAL RETAIL TECHNOLOGIES SL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* 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 DIGITAL RETAIL TECHNOLOGIES SL <mail@simlachat.com>
* @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL
* @license https://opensource.org/licenses/MIT The MIT License
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
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,45 @@
<?php
/**
* MIT License
*
* Copyright (c) 2021 DIGITAL RETAIL TECHNOLOGIES SL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* 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 DIGITAL RETAIL TECHNOLOGIES SL <mail@simlachat.com>
* @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL
* @license https://opensource.org/licenses/MIT The MIT License
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
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: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,45 @@
<?php
/**
* MIT License
*
* Copyright (c) 2021 DIGITAL RETAIL TECHNOLOGIES SL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* 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 DIGITAL RETAIL TECHNOLOGIES SL <mail@simlachat.com>
* @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL
* @license https://opensource.org/licenses/MIT The MIT License
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
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

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

File diff suppressed because one or more lines are too long