From 3150dfa282f76798c55ba482093b13b14d52bd59 Mon Sep 17 00:00:00 2001 From: max-baranikov Date: Mon, 6 Dec 2021 14:37:43 +0300 Subject: [PATCH] Added table of the exported orders on the settings page --- .github/workflows/lint.yml | 2 +- .gitignore | 3 +- .php-cs-fixer.php | 54 ++- Makefile | 2 +- retailcrm/bootstrap.php | 8 +- retailcrm/cli.php | 8 +- .../RetailcrmAdminAbstractController.php | 82 ++++ .../admin/RetailcrmOrdersController.php | 75 ++++ .../admin/RetailcrmOrdersUploadController.php | 107 ++++++ .../admin/RetailcrmSettingsController.php | 81 ++++ retailcrm/controllers/admin/index.php | 45 +++ retailcrm/controllers/front/Consultant.php | 5 +- .../controllers/front/DaemonCollector.php | 5 +- retailcrm/controllers/front/Jobs.php | 5 +- retailcrm/controllers/front/index.php | 36 ++ retailcrm/controllers/index.php | 36 ++ retailcrm/index.php | 36 ++ retailcrm/lib/RetailcrmAbstractBuilder.php | 5 +- .../lib/RetailcrmAbstractDataBuilder.php | 5 +- retailcrm/lib/RetailcrmAddressBuilder.php | 5 +- retailcrm/lib/RetailcrmBuilderInterface.php | 5 +- .../lib/RetailcrmCachedSettingExtractor.php | 5 +- retailcrm/lib/RetailcrmCartUploader.php | 17 +- retailcrm/lib/RetailcrmCatalog.php | 10 +- retailcrm/lib/RetailcrmCatalogHelper.php | 10 +- retailcrm/lib/RetailcrmCli.php | 19 +- .../lib/RetailcrmConsultantRcctExtractor.php | 5 +- retailcrm/lib/RetailcrmContextSwitcher.php | 10 +- .../lib/RetailcrmCorporateCustomerBuilder.php | 5 +- .../lib/RetailcrmCustomerAddressBuilder.php | 6 +- retailcrm/lib/RetailcrmCustomerBuilder.php | 5 +- .../lib/RetailcrmCustomerBuilderResult.php | 5 +- retailcrm/lib/RetailcrmCustomerSwitcher.php | 5 +- retailcrm/lib/RetailcrmExport.php | 23 +- retailcrm/lib/RetailcrmExportOrdersHelper.php | 135 +++++++ retailcrm/lib/RetailcrmFilterInterface.php | 10 +- retailcrm/lib/RetailcrmHistory.php | 10 +- retailcrm/lib/RetailcrmHistoryHelper.php | 9 +- retailcrm/lib/RetailcrmIcml.php | 5 +- retailcrm/lib/RetailcrmInventories.php | 5 +- retailcrm/lib/RetailcrmJobManager.php | 21 +- retailcrm/lib/RetailcrmJsonResponse.php | 9 +- retailcrm/lib/RetailcrmLogger.php | 9 +- retailcrm/lib/RetailcrmOrderBuilder.php | 10 +- retailcrm/lib/RetailcrmPrestashopLoader.php | 11 +- retailcrm/lib/RetailcrmReferences.php | 5 +- retailcrm/lib/RetailcrmTools.php | 19 +- retailcrm/lib/api/CurlException.php | 5 +- retailcrm/lib/api/InvalidJsonException.php | 5 +- retailcrm/lib/api/RetailcrmApiClientV5.php | 5 +- retailcrm/lib/api/RetailcrmApiErrors.php | 5 +- .../lib/api/RetailcrmApiPaginatedRequest.php | 5 +- retailcrm/lib/api/RetailcrmApiRequest.php | 36 ++ retailcrm/lib/api/RetailcrmApiResponse.php | 5 +- retailcrm/lib/api/RetailcrmHttpClient.php | 5 +- retailcrm/lib/api/RetailcrmProxy.php | 7 +- retailcrm/lib/api/index.php | 36 ++ .../RetailcrmExceptionMiddleware.php | 9 +- .../RetailcrmExportOrdersMiddleware.php | 172 +++++++++ .../middleware/RetailcrmLoggerMiddleware.php | 10 +- .../RetailcrmReferenceMiddleware.php | 10 +- retailcrm/lib/api/middleware/index.php | 36 ++ .../pipeline/RetailcrmMiddlewareInterface.php | 36 ++ .../lib/api/pipeline/RetailcrmPipeline.php | 36 ++ retailcrm/lib/api/pipeline/index.php | 36 ++ .../events/RetailcrmAbandonedCartsEvent.php | 11 +- .../lib/events/RetailcrmAbstractEvent.php | 11 +- .../lib/events/RetailcrmClearLogsEvent.php | 7 +- .../lib/events/RetailcrmEventInterface.php | 9 +- retailcrm/lib/events/RetailcrmExportEvent.php | 11 +- retailcrm/lib/events/RetailcrmIcmlEvent.php | 7 +- .../events/RetailcrmIcmlUpdateUrlEvent.php | 11 +- .../lib/events/RetailcrmInventoriesEvent.php | 7 +- .../lib/events/RetailcrmMissingEvent.php | 7 +- retailcrm/lib/events/RetailcrmSyncEvent.php | 7 +- .../events/RetailcrmUpdateSinceIdEvent.php | 7 +- retailcrm/lib/events/index.php | 36 ++ .../RetailcrmJobManagerException.php | 5 +- retailcrm/lib/exceptions/index.php | 36 ++ retailcrm/lib/index.php | 36 ++ .../RetailcrmCustomerSwitcherResult.php | 5 +- .../models/RetailcrmCustomerSwitcherState.php | 5 +- retailcrm/lib/models/index.php | 36 ++ .../templates/RetailcrmAbstractTemplate.php | 5 +- .../lib/templates/RetailcrmBaseTemplate.php | 5 +- .../templates/RetailcrmSettingsTemplate.php | 15 +- .../templates/RetailcrmTemplateFactory.php | 5 +- retailcrm/lib/templates/index.php | 36 ++ retailcrm/retailcrm.php | 114 +++++- retailcrm/translations/es.php | 56 ++- retailcrm/translations/index.php | 38 +- retailcrm/translations/ru.php | 56 ++- retailcrm/upgrade/index.php | 36 ++ retailcrm/upgrade/upgrade-3.0.1.php | 5 +- retailcrm/upgrade/upgrade-3.0.2.php | 5 +- retailcrm/upgrade/upgrade-3.3.0.php | 9 +- retailcrm/upgrade/upgrade-3.3.2.php | 9 +- retailcrm/upgrade/upgrade-3.3.5.php | 57 +++ retailcrm/views/css/index.php | 36 ++ retailcrm/views/css/less/index.php | 36 ++ .../views/css/less/retailcrm-export.less | 12 +- .../views/css/less/retailcrm-orders.less | 192 ++++++++++ retailcrm/views/css/less/styles.less | 139 ++++++- retailcrm/views/css/retailcrm-export.min.css | 2 +- retailcrm/views/css/retailcrm-orders.min.css | 1 + retailcrm/views/css/styles.min.css | 2 +- retailcrm/views/fonts/OpenSans/index.php | 36 ++ retailcrm/views/fonts/OpenSansBold/index.php | 36 ++ retailcrm/views/fonts/index.php | 36 ++ retailcrm/views/img/index.php | 36 ++ retailcrm/views/index.php | 36 ++ retailcrm/views/js/index.php | 36 ++ retailcrm/views/js/retailcrm-orders.js | 360 ++++++++++++++++++ retailcrm/views/js/retailcrm-orders.min.js | 42 ++ retailcrm/views/js/retailcrm.js | 16 +- retailcrm/views/js/retailcrm.min.js | 2 +- retailcrm/views/js/vendor/index.php | 49 ++- retailcrm/views/templates/admin/index.php | 36 ++ .../templates/admin/module_translates.tpl | 42 ++ retailcrm/views/templates/admin/settings.tpl | 211 ++++++++-- retailcrm/views/templates/index.php | 36 ++ .../RetailcrmCorporateCustomerBuilderTest.php | 36 ++ tests/RetailcrmCustomerAddressBuilderTest.php | 36 ++ tests/RetailcrmCustomerBuilderTest.php | 36 ++ tests/RetailcrmOrderBuilderTest.php | 36 ++ tests/RetailcrmTest.php | 167 ++++---- tests/bootstrap.php | 36 ++ tests/helpers/RetailcrmTestCase.php | 36 ++ tests/helpers/RetailcrmTestHelper.php | 36 ++ tests/lib/RetailcrmAddressBuilderTest.php | 36 ++ tests/lib/RetailcrmCatalogTest.php | 36 ++ tests/lib/RetailcrmHistoryTest.php | 310 +++++++++------ tests/lib/RetailcrmInventoriesTest.php | 36 ++ tests/lib/RetailcrmReferencesTest.php | 36 ++ tests/lib/RetailcrmToolsTest.php | 36 ++ .../api/RetailcrmApiPaginatedRequestTest.php | 36 ++ .../api/RetailcrmExceptionMiddlewareTest.php | 36 ++ .../RetailcrmExportOrdersMiddlewareTest.php | 333 ++++++++++++++++ .../api/RetailcrmReferenceMiddlewareTest.php | 66 ++-- 139 files changed, 4400 insertions(+), 567 deletions(-) create mode 100644 retailcrm/controllers/admin/RetailcrmAdminAbstractController.php create mode 100644 retailcrm/controllers/admin/RetailcrmOrdersController.php create mode 100644 retailcrm/controllers/admin/RetailcrmOrdersUploadController.php create mode 100644 retailcrm/controllers/admin/RetailcrmSettingsController.php create mode 100644 retailcrm/controllers/admin/index.php create mode 100644 retailcrm/lib/RetailcrmExportOrdersHelper.php create mode 100644 retailcrm/lib/api/middleware/RetailcrmExportOrdersMiddleware.php create mode 100644 retailcrm/upgrade/upgrade-3.3.5.php create mode 100644 retailcrm/views/css/less/retailcrm-orders.less create mode 100644 retailcrm/views/css/retailcrm-orders.min.css create mode 100644 retailcrm/views/js/retailcrm-orders.js create mode 100644 retailcrm/views/js/retailcrm-orders.min.js create mode 100644 retailcrm/views/templates/admin/module_translates.tpl create mode 100644 tests/lib/api/RetailcrmExportOrdersMiddlewareTest.php diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d5797f8..4857572 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,5 @@ on: [push, pull_request] -name: Main +name: lint jobs: php-cs-fixer: name: PHP-CS-Fixer diff --git a/.gitignore b/.gitignore index f825fbf..ab6fba7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ retailcrm/views/css/*.map retailcrm/views/js/*.map retailcrm/config*.xml retailcrm/custom -coverage.xml \ No newline at end of file +coverage.xml +.php-cs-fixer.cache diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 6198d4f..a6bad44 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -1,12 +1,47 @@ in([ - __DIR__.'/retailcrm', - __DIR__.'/tests', + __DIR__ . '/retailcrm', + __DIR__ . '/tests', ]); +$licenseHeader = '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 + @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.'; + return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) ->setRules([ @@ -20,7 +55,7 @@ return (new PhpCsFixer\Config()) 'yoda_style' => [ 'equal' => true, 'identical' => true, - 'less_and_greater' => true + 'less_and_greater' => true, ], 'date_time_immutable' => true, @@ -71,6 +106,13 @@ return (new PhpCsFixer\Config()) 'logical_operators' => true, 'php_unit_test_case_static_method_calls' => ['call_type' => 'this'], 'multiline_whitespace_before_semicolons' => ['strategy' => 'new_line_for_chained_calls'], - + 'dir_constant' => false, + 'header_comment' => [ + 'header' => $licenseHeader, + 'comment_type' => 'PHPDoc', + 'location' => 'after_open', + 'separate' => 'bottom', + ], ]) - ->setFinder($finder); + ->setFinder($finder) +; diff --git a/Makefile b/Makefile index ac06d52..494bda4 100644 --- a/Makefile +++ b/Makefile @@ -67,4 +67,4 @@ else endif coverage: - wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml \ No newline at end of file + wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml diff --git a/retailcrm/bootstrap.php b/retailcrm/bootstrap.php index 69a0731..8a0ad40 100644 --- a/retailcrm/bootstrap.php +++ b/retailcrm/bootstrap.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,7 +29,7 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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 @@ -42,8 +42,6 @@ * A simple autoloader that loads class files recursively starting in the directory * where this class resides. Additional options can be provided to control the naming * convention of the class files. - * - * @license http://opensource.org/licenses/MIT MIT License */ class RetailcrmAutoloader { @@ -138,7 +136,7 @@ class RetailcrmAutoloader } } -RetailcrmAutoloader::setPath(realpath(__DIR__)); +RetailcrmAutoloader::setPath(realpath(dirname(__FILE__))); RetailcrmAutoloader::setPathCustom(realpath(_PS_MODULE_DIR_ . '/retailcrm/custom')); RetailcrmAutoloader::setFileExt('.php'); spl_autoload_register('RetailcrmAutoloader::loader'); diff --git a/retailcrm/cli.php b/retailcrm/cli.php index a79b946..279a26d 100644 --- a/retailcrm/cli.php +++ b/retailcrm/cli.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,7 +29,7 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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 @@ -46,7 +46,7 @@ if (!isset($_SERVER['REMOTE_ADDR'])) { $_SERVER['REMOTE_ADDR'] = '0.0.0.0'; } -require_once __DIR__ . '/lib/RetailcrmCli.php'; +require_once dirname(__FILE__) . '/lib/RetailcrmCli.php'; function retailcrmCliInterruptHandler($signo) { @@ -63,5 +63,5 @@ if ('cli' == php_sapi_name()) { $cli = new RetailcrmCli(__FILE__); $cli->execute('retailcrmCliInterruptHandler'); } else { - include_once __DIR__ . DIRECTORY_SEPARATOR . 'index.php'; + include_once dirname(__FILE__) . '/index.php'; } diff --git a/retailcrm/controllers/admin/RetailcrmAdminAbstractController.php b/retailcrm/controllers/admin/RetailcrmAdminAbstractController.php new file mode 100644 index 0000000..f25e6f7 --- /dev/null +++ b/retailcrm/controllers/admin/RetailcrmAdminAbstractController.php @@ -0,0 +1,82 @@ + + * @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. + */ + +class RetailcrmAdminAbstractController extends ModuleAdminController +{ + public static function getId() + { + $tabId = (int) Tab::getIdFromClassName(static::getClassName()); + + if (!$tabId) { + $tabId = null; + } + + return $tabId; + } + + public static function getParentId() + { + return -1; + } + + public static function getClassName() + { + return str_replace('Controller', '', static::class); + } + + public static function getName() + { + $name = []; + + foreach (Language::getLanguages(true) as $lang) { + $name[$lang['id_lang']] = static::getClassName(); + } + + return $name; + } + + public static function getIcon() + { + return null; + } + + public static function getPosition() + { + return null; + } +} diff --git a/retailcrm/controllers/admin/RetailcrmOrdersController.php b/retailcrm/controllers/admin/RetailcrmOrdersController.php new file mode 100644 index 0000000..019df9a --- /dev/null +++ b/retailcrm/controllers/admin/RetailcrmOrdersController.php @@ -0,0 +1,75 @@ + + * @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. + */ + +require_once dirname(__FILE__) . '/../../bootstrap.php'; + +class RetailcrmOrdersController extends RetailcrmAdminAbstractController +{ + public function postProcess() + { + $this->ajaxDie(json_encode($this->getData())); + } + + protected function getData() + { + $orders = Tools::getValue('orders', []); + $page = (int) (Tools::getValue('page', 1)); + + switch (Tools::getValue('filter')) { + case '1': + $withErrors = false; + break; + case '2': + $withErrors = true; + break; + default: + $withErrors = null; + } + + try { + return array_merge([ + 'success' => true, + ], RetailcrmExportOrdersHelper::getOrders($orders, $withErrors, $page)); + } catch (Exception $e) { + return [ + 'success' => false, + 'errorMsg' => $e->getMessage(), + ]; + } + } +} diff --git a/retailcrm/controllers/admin/RetailcrmOrdersUploadController.php b/retailcrm/controllers/admin/RetailcrmOrdersUploadController.php new file mode 100644 index 0000000..2d1ac87 --- /dev/null +++ b/retailcrm/controllers/admin/RetailcrmOrdersUploadController.php @@ -0,0 +1,107 @@ + + * @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. + */ + +require_once dirname(__FILE__) . '/../../bootstrap.php'; + +class RetailcrmOrdersUploadController extends RetailcrmAdminAbstractController +{ + private $api; + + public function __construct() + { + parent::__construct(); + + $this->api = RetailcrmTools::getApiClient(); + } + + public function postProcess() + { + $this->ajaxDie(json_encode($this->getData())); + } + + protected function getData() + { + if (!($this->api instanceof RetailcrmProxy)) { + return [ + 'success' => false, + 'errorMsg' => "Can't upload orders - set API key and API URL first!", + ]; + } + + $orderIds = Tools::getValue('orders'); + try { + $isSuccessful = true; + $skippedOrders = []; + $uploadedOrders = []; + $errors = []; + + RetailcrmExport::$api = $this->api; + foreach ($orderIds as $orderId) { + $id_order = (int) $orderId; + $response = false; + + try { + $response = RetailcrmExport::exportOrder($id_order); + + if ($response) { + $uploadedOrders[] = $id_order; + } + } catch (PrestaShopObjectNotFoundExceptionCore $e) { + $skippedOrders[] = $id_order; + } catch (Exception $e) { + $errors[$id_order][] = $e->getMessage(); + } + + $isSuccessful = $isSuccessful ? $response : false; + time_nanosleep(0, 50000000); + } + + return [ + 'success' => $isSuccessful, + 'uploadedOrders' => $uploadedOrders, + 'skippedOrders' => $skippedOrders, + 'errors' => $errors, + ]; + } catch (Exception $e) { + return [ + 'success' => false, + 'errorMsg' => $e->getMessage(), + ]; + } + } +} diff --git a/retailcrm/controllers/admin/RetailcrmSettingsController.php b/retailcrm/controllers/admin/RetailcrmSettingsController.php new file mode 100644 index 0000000..e22be5b --- /dev/null +++ b/retailcrm/controllers/admin/RetailcrmSettingsController.php @@ -0,0 +1,81 @@ + + * @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. + */ + +require_once dirname(__FILE__) . '/../../bootstrap.php'; + +class RetailcrmSettingsController extends RetailcrmAdminAbstractController +{ + public static function getParentId() + { + return (int) Tab::getIdFromClassName('IMPROVE'); + } + + public static function getIcon() + { + return 'shop'; + } + + public static function getPosition() + { + return 7; + } + + public static function getName() + { + $name = []; + + foreach (Language::getLanguages(true) as $lang) { + $name[$lang['id_lang']] = 'Simla.com'; + } + + return $name; + } + + public function postProcess() + { + $link = $this->context->link->getAdminLink('AdminModules', true, [], [ + 'configure' => 'retailcrm', + ]); + + if (version_compare(_PS_VERSION_, '1.7.0.3', '<')) { + $link .= '&module_name=retailcrm&configure=retailcrm'; + } + + $this->setRedirectAfter($link); + } +} diff --git a/retailcrm/controllers/admin/index.php b/retailcrm/controllers/admin/index.php new file mode 100644 index 0000000..4043a55 --- /dev/null +++ b/retailcrm/controllers/admin/index.php @@ -0,0 +1,45 @@ + + * @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; diff --git a/retailcrm/controllers/front/Consultant.php b/retailcrm/controllers/front/Consultant.php index 1d9725c..3312617 100644 --- a/retailcrm/controllers/front/Consultant.php +++ b/retailcrm/controllers/front/Consultant.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmConsultantModuleFrontController extends ModuleFrontController { /** diff --git a/retailcrm/controllers/front/DaemonCollector.php b/retailcrm/controllers/front/DaemonCollector.php index a5329ff..4ca86bb 100644 --- a/retailcrm/controllers/front/DaemonCollector.php +++ b/retailcrm/controllers/front/DaemonCollector.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmDaemonCollectorModuleFrontController extends ModuleFrontController { /** diff --git a/retailcrm/controllers/front/Jobs.php b/retailcrm/controllers/front/Jobs.php index dce5fd4..18abe7f 100644 --- a/retailcrm/controllers/front/Jobs.php +++ b/retailcrm/controllers/front/Jobs.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmJobsModuleFrontController extends ModuleFrontController { /** diff --git a/retailcrm/controllers/front/index.php b/retailcrm/controllers/front/index.php index 63eec81..4043a55 100644 --- a/retailcrm/controllers/front/index.php +++ b/retailcrm/controllers/front/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/controllers/index.php b/retailcrm/controllers/index.php index 63eec81..4043a55 100644 --- a/retailcrm/controllers/index.php +++ b/retailcrm/controllers/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/index.php b/retailcrm/index.php index 63eec81..4043a55 100644 --- a/retailcrm/index.php +++ b/retailcrm/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/lib/RetailcrmAbstractBuilder.php b/retailcrm/lib/RetailcrmAbstractBuilder.php index 0e6b5cb..1a3655b 100644 --- a/retailcrm/lib/RetailcrmAbstractBuilder.php +++ b/retailcrm/lib/RetailcrmAbstractBuilder.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + abstract class RetailcrmAbstractBuilder { /** diff --git a/retailcrm/lib/RetailcrmAbstractDataBuilder.php b/retailcrm/lib/RetailcrmAbstractDataBuilder.php index aabe741..1063e45 100644 --- a/retailcrm/lib/RetailcrmAbstractDataBuilder.php +++ b/retailcrm/lib/RetailcrmAbstractDataBuilder.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + abstract class RetailcrmAbstractDataBuilder { /** diff --git a/retailcrm/lib/RetailcrmAddressBuilder.php b/retailcrm/lib/RetailcrmAddressBuilder.php index 0f22c98..bb2f033 100644 --- a/retailcrm/lib/RetailcrmAddressBuilder.php +++ b/retailcrm/lib/RetailcrmAddressBuilder.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmAddressBuilder extends RetailcrmAbstractDataBuilder { /** diff --git a/retailcrm/lib/RetailcrmBuilderInterface.php b/retailcrm/lib/RetailcrmBuilderInterface.php index a3dcf5f..f3f57b3 100644 --- a/retailcrm/lib/RetailcrmBuilderInterface.php +++ b/retailcrm/lib/RetailcrmBuilderInterface.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + interface RetailcrmBuilderInterface { /** diff --git a/retailcrm/lib/RetailcrmCachedSettingExtractor.php b/retailcrm/lib/RetailcrmCachedSettingExtractor.php index e52888e..b42221a 100644 --- a/retailcrm/lib/RetailcrmCachedSettingExtractor.php +++ b/retailcrm/lib/RetailcrmCachedSettingExtractor.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCachedSettingExtractor extends RetailcrmAbstractDataBuilder { /** @var string */ diff --git a/retailcrm/lib/RetailcrmCartUploader.php b/retailcrm/lib/RetailcrmCartUploader.php index 18cfea0..1a4b7d0 100644 --- a/retailcrm/lib/RetailcrmCartUploader.php +++ b/retailcrm/lib/RetailcrmCartUploader.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCartUploader { /** @@ -106,7 +107,7 @@ class RetailcrmCartUploader static::$syncDelay = 0; static::$allowedUpdateInterval = 86400; static::$syncStatus = ''; - static::$now = new \DateTimeImmutable(); + static::$now = new DateTimeImmutable(); static::$context = Context::getContext(); } @@ -134,7 +135,7 @@ class RetailcrmCartUploader } if (!empty($cart->date_upd)) { - $cartLastUpdateDate = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $cart->date_upd); + $cartLastUpdateDate = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $cart->date_upd); } if (!static::isAbandonedCartShouldBeUpdated( @@ -306,7 +307,7 @@ class RetailcrmCartUploader * * @param int $cartId * - * @return \DateTime|false + * @return DateTimeImmutable|false|null */ private static function getAbandonedCartLastSync($cartId) { @@ -318,7 +319,7 @@ class RetailcrmCartUploader return null; } - return \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $when); + return DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $when); } /** @@ -345,8 +346,8 @@ class RetailcrmCartUploader /** * Returns true if abandoned cart should be uploaded * - * @param \DateTime|null $lastUploadDate - * @param \DateTime|null $lastUpdatedDate + * @param DateTimeImmutable|null $lastUploadDate + * @param DateTimeImmutable|null $lastUpdatedDate * * @return bool */ diff --git a/retailcrm/lib/RetailcrmCatalog.php b/retailcrm/lib/RetailcrmCatalog.php index b9b1914..cd45924 100644 --- a/retailcrm/lib/RetailcrmCatalog.php +++ b/retailcrm/lib/RetailcrmCatalog.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCatalog { public $default_lang; diff --git a/retailcrm/lib/RetailcrmCatalogHelper.php b/retailcrm/lib/RetailcrmCatalogHelper.php index a3625c8..ba04a03 100644 --- a/retailcrm/lib/RetailcrmCatalogHelper.php +++ b/retailcrm/lib/RetailcrmCatalogHelper.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCatalogHelper { const ICML_INFO_NAME = 'RETAILCRM_ICML_INFO'; diff --git a/retailcrm/lib/RetailcrmCli.php b/retailcrm/lib/RetailcrmCli.php index 4263e00..6a097f8 100644 --- a/retailcrm/lib/RetailcrmCli.php +++ b/retailcrm/lib/RetailcrmCli.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,20 +28,21 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) { date_default_timezone_set(@date_default_timezone_get()); } -require_once __DIR__ . '/../../../config/config.inc.php'; -require_once __DIR__ . '/../../../init.php'; -require_once __DIR__ . '/../bootstrap.php'; +require_once dirname(__FILE__) . '/../../../config/config.inc.php'; +require_once dirname(__FILE__) . '/../../../init.php'; +require_once dirname(__FILE__) . '/../bootstrap.php'; if (!defined('_PS_VERSION_')) { exit; @@ -255,7 +256,7 @@ class RetailcrmCli return; } - RetailcrmTools::setShopContext($shopId); + RetailcrmContextSwitcher::setShopContext($shopId); $this->loadConfiguration(); Configuration::updateValue(RetailCRM::ENABLE_WEB_JOBS, $state ? '1' : '0'); @@ -276,7 +277,7 @@ class RetailcrmCli return; } - RetailcrmTools::setShopContext($shopId); + RetailcrmContextSwitcher::setShopContext($shopId); $this->loadConfiguration(); RetailcrmLogger::output(sprintf( diff --git a/retailcrm/lib/RetailcrmConsultantRcctExtractor.php b/retailcrm/lib/RetailcrmConsultantRcctExtractor.php index b2e2161..ed5d90e 100644 --- a/retailcrm/lib/RetailcrmConsultantRcctExtractor.php +++ b/retailcrm/lib/RetailcrmConsultantRcctExtractor.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmConsultantRcctExtractor extends RetailcrmAbstractDataBuilder { /** @var string */ diff --git a/retailcrm/lib/RetailcrmContextSwitcher.php b/retailcrm/lib/RetailcrmContextSwitcher.php index a5e3a4e..48e2573 100644 --- a/retailcrm/lib/RetailcrmContextSwitcher.php +++ b/retailcrm/lib/RetailcrmContextSwitcher.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmContextSwitcher { /** diff --git a/retailcrm/lib/RetailcrmCorporateCustomerBuilder.php b/retailcrm/lib/RetailcrmCorporateCustomerBuilder.php index 62f92af..cf39f01 100644 --- a/retailcrm/lib/RetailcrmCorporateCustomerBuilder.php +++ b/retailcrm/lib/RetailcrmCorporateCustomerBuilder.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCorporateCustomerBuilder extends RetailcrmAbstractBuilder implements RetailcrmBuilderInterface { /** diff --git a/retailcrm/lib/RetailcrmCustomerAddressBuilder.php b/retailcrm/lib/RetailcrmCustomerAddressBuilder.php index eace106..c49a15d 100644 --- a/retailcrm/lib/RetailcrmCustomerAddressBuilder.php +++ b/retailcrm/lib/RetailcrmCustomerAddressBuilder.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCustomerAddressBuilder extends RetailcrmAbstractBuilder implements RetailcrmBuilderInterface { /** diff --git a/retailcrm/lib/RetailcrmCustomerBuilder.php b/retailcrm/lib/RetailcrmCustomerBuilder.php index 83ff5b1..2eeddee 100644 --- a/retailcrm/lib/RetailcrmCustomerBuilder.php +++ b/retailcrm/lib/RetailcrmCustomerBuilder.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCustomerBuilder extends RetailcrmAbstractBuilder implements RetailcrmBuilderInterface { /** @var Customer|CustomerCore Customer */ diff --git a/retailcrm/lib/RetailcrmCustomerBuilderResult.php b/retailcrm/lib/RetailcrmCustomerBuilderResult.php index c14d82d..15c0807 100644 --- a/retailcrm/lib/RetailcrmCustomerBuilderResult.php +++ b/retailcrm/lib/RetailcrmCustomerBuilderResult.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCustomerBuilderResult { /** @var Customer|CustomerCore */ diff --git a/retailcrm/lib/RetailcrmCustomerSwitcher.php b/retailcrm/lib/RetailcrmCustomerSwitcher.php index 3d312b5..cb1c37f 100644 --- a/retailcrm/lib/RetailcrmCustomerSwitcher.php +++ b/retailcrm/lib/RetailcrmCustomerSwitcher.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCustomerSwitcher implements RetailcrmBuilderInterface { /** diff --git a/retailcrm/lib/RetailcrmExport.php b/retailcrm/lib/RetailcrmExport.php index 4f1b27a..155271c 100644 --- a/retailcrm/lib/RetailcrmExport.php +++ b/retailcrm/lib/RetailcrmExport.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmExport { const RETAILCRM_EXPORT_ORDERS_STEP_SIZE_CLI = 5000; @@ -374,6 +374,7 @@ class RetailcrmExport * @throws PrestaShopObjectNotFoundExceptionCore * @throws PrestaShopDatabaseException * @throws PrestaShopException + * @throws Exception */ public static function exportOrder($id) { @@ -420,6 +421,18 @@ class RetailcrmExport } } + if (!$response->isSuccessful()) { + $errorMsg = ''; + if ($response->offsetExists('errorMsg')) { + $errorMsg = $response['errorMsg'] . ': '; + } + if ($response->offsetExists('errors')) { + $errorMsg .= implode('; ', $response['errors']); + } + + throw new Exception($errorMsg); + } + return $response->isSuccessful(); } diff --git a/retailcrm/lib/RetailcrmExportOrdersHelper.php b/retailcrm/lib/RetailcrmExportOrdersHelper.php new file mode 100644 index 0000000..2af1284 --- /dev/null +++ b/retailcrm/lib/RetailcrmExportOrdersHelper.php @@ -0,0 +1,135 @@ + + * @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. + */ + +class RetailcrmExportOrdersHelper +{ + const ROWS_PER_PAGE = 10; + + /** + * @param int $id_order + * @param int|null $id_order_crm + * @param array|null $errors + */ + public static function updateExportState($id_order, $id_order_crm = null, array $errors = null) + { + if (null === $id_order) { + return false; + } + + if (null === $id_order_crm) { + $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'retailcrm_exported_orders` + WHERE `id_order` = \'' . pSQL($id_order) . '\';'; + + $orderInfo = Db::getInstance()->executeS($sql); + if (0 < count($orderInfo) && isset($orderInfo[0]['id_order_crm'])) { + $id_order_crm = $orderInfo[0]['id_order_crm']; + } + } + + if (null !== $errors && 0 < count($errors)) { + $errors = json_encode($errors); + } + + $sql = 'INSERT INTO `' . _DB_PREFIX_ . 'retailcrm_exported_orders` + (`id_order`, `id_order_crm`, `errors`, `last_uploaded`) + VALUES( + ' . ($id_order ? '\'' . pSQL($id_order) . '\'' : 'NULL') . ', + ' . ($id_order_crm ? '\'' . pSQL($id_order_crm) . '\'' : 'NULL') . ', + ' . ($errors ? '\'' . pSQL($errors) . '\'' : 'NULL') . ', + \'' . pSQL(date('Y-m-d H:i:s')) . + '\') + ON DUPLICATE KEY UPDATE + `id_order` = ' . ($id_order ? '\'' . pSQL($id_order) . '\'' : 'NULL') . ', + `id_order_crm` = ' . ($id_order_crm ? '\'' . pSQL($id_order_crm) . '\'' : 'NULL') . ', + `errors` = ' . ($errors ? '\'' . pSQL($errors) . '\'' : 'NULL') . ', + `last_uploaded` = \'' . pSQL(date('Y-m-d H:i:s')) . '\';'; + + return Db::getInstance()->execute($sql); + } + + public static function getOrders($ordersIds = [], $withErrors = null, $page = 1) + { + if (0 > $page) { + return []; + } + + $sqlOrdersInfo = 'SELECT * FROM `' . _DB_PREFIX_ . 'retailcrm_exported_orders` WHERE 1'; + $sqlPagination = 'SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'retailcrm_exported_orders` WHERE 1'; + + if (0 < count($ordersIds)) { + $sqlOrdersInfo .= ' AND (`id_order` IN ( ' . pSQL(implode(', ', $ordersIds)) . ') + OR `id_order_crm` IN ( ' . pSQL(implode(', ', $ordersIds)) . ') + )'; + $sqlPagination .= ' AND (`id_order` IN ( ' . pSQL(implode(', ', $ordersIds)) . ') + OR `id_order_crm` IN ( ' . pSQL(implode(', ', $ordersIds)) . ') + )'; + } + + if (null !== $withErrors) { + $sqlOrdersInfo .= ' AND errors IS ' . ($withErrors ? 'NOT' : '') . ' NULL'; + $sqlPagination .= ' AND errors IS ' . ($withErrors ? 'NOT' : '') . ' NULL'; + } + + $totalCount = Db::getInstance()->getValue($sqlPagination); + + $pagination = [ + 'totalCount' => $totalCount, + 'currentPage' => $page, + 'totalPageCount' => ceil($totalCount / self::ROWS_PER_PAGE), + ]; + + if ($page > $pagination['totalPageCount']) { + $orderInfo = []; + } else { + $sqlOrdersInfo .= ' LIMIT ' . self::ROWS_PER_PAGE * ($page - 1) . ', ' . self::ROWS_PER_PAGE . ';'; + $orderInfo = Db::getInstance()->executeS($sqlOrdersInfo); + } + + return [ + 'orders' => $orderInfo, + 'pagination' => $pagination, + ]; + } + + public static function removeOrders() + { + $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'retailcrm_exported_orders` WHERE 1'; + + return Db::getInstance()->execute($sql); + } +} diff --git a/retailcrm/lib/RetailcrmFilterInterface.php b/retailcrm/lib/RetailcrmFilterInterface.php index a6fcaa0..5a45183 100644 --- a/retailcrm/lib/RetailcrmFilterInterface.php +++ b/retailcrm/lib/RetailcrmFilterInterface.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + interface RetailcrmFilterInterface { /** diff --git a/retailcrm/lib/RetailcrmHistory.php b/retailcrm/lib/RetailcrmHistory.php index 05a372f..03d7956 100644 --- a/retailcrm/lib/RetailcrmHistory.php +++ b/retailcrm/lib/RetailcrmHistory.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmHistory { /** @var \RetailcrmApiClientV5 */ diff --git a/retailcrm/lib/RetailcrmHistoryHelper.php b/retailcrm/lib/RetailcrmHistoryHelper.php index 19fe36b..283cca3 100644 --- a/retailcrm/lib/RetailcrmHistoryHelper.php +++ b/retailcrm/lib/RetailcrmHistoryHelper.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,18 +29,19 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmHistoryHelper { public static function assemblyOrder($orderHistory) { - if (file_exists(__DIR__ . '/../objects.xml')) { - $objects = simplexml_load_file(__DIR__ . '/../objects.xml'); + if (file_exists(dirname(__FILE__) . '/../objects.xml')) { + $objects = simplexml_load_file(dirname(__FILE__) . '/../objects.xml'); foreach ($objects->fields->field as $object) { $fields[(string) $object['group']][(string) $object['id']] = (string) $object; } diff --git a/retailcrm/lib/RetailcrmIcml.php b/retailcrm/lib/RetailcrmIcml.php index 79761ce..a5f7e99 100644 --- a/retailcrm/lib/RetailcrmIcml.php +++ b/retailcrm/lib/RetailcrmIcml.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmIcml { protected $shop; diff --git a/retailcrm/lib/RetailcrmInventories.php b/retailcrm/lib/RetailcrmInventories.php index caaa2f7..7bc889f 100644 --- a/retailcrm/lib/RetailcrmInventories.php +++ b/retailcrm/lib/RetailcrmInventories.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmInventories { /** diff --git a/retailcrm/lib/RetailcrmJobManager.php b/retailcrm/lib/RetailcrmJobManager.php index 502e19f..2493c82 100644 --- a/retailcrm/lib/RetailcrmJobManager.php +++ b/retailcrm/lib/RetailcrmJobManager.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,20 +28,21 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) { date_default_timezone_set(@date_default_timezone_get()); } -require_once __DIR__ . '/../../../config/config.inc.php'; -require_once __DIR__ . '/../../../init.php'; -require_once __DIR__ . '/../bootstrap.php'; +require_once dirname(__FILE__) . '/../../../config/config.inc.php'; +require_once dirname(__FILE__) . '/../../../init.php'; +require_once dirname(__FILE__) . '/../bootstrap.php'; if (!defined('_PS_VERSION_')) { exit; @@ -144,10 +145,10 @@ class RetailcrmJobManager $date2 = new \DateTimeImmutable(); if (null !== $diff1) { - $date1->add($diff1); + $date1 = $date1->add($diff1); } if (null !== $diff2) { - $date2->add($diff2); + $date2 = $date2->add($diff2); } if ($date1 == $date2) { @@ -163,7 +164,7 @@ class RetailcrmJobManager $shouldRunAt = clone $lastRuns[$job]; if ($diff instanceof DateInterval) { - $shouldRunAt->add($diff); + $shouldRunAt = $shouldRunAt->add($diff); } } else { $shouldRunAt = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00'); diff --git a/retailcrm/lib/RetailcrmJsonResponse.php b/retailcrm/lib/RetailcrmJsonResponse.php index 8699b8b..c4de223 100644 --- a/retailcrm/lib/RetailcrmJsonResponse.php +++ b/retailcrm/lib/RetailcrmJsonResponse.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,13 +28,14 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (!defined('_PS_VERSION_')) { exit; } diff --git a/retailcrm/lib/RetailcrmLogger.php b/retailcrm/lib/RetailcrmLogger.php index 6aa01dd..e6a5269 100755 --- a/retailcrm/lib/RetailcrmLogger.php +++ b/retailcrm/lib/RetailcrmLogger.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,13 +28,14 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (!defined('_PS_VERSION_')) { exit; } diff --git a/retailcrm/lib/RetailcrmOrderBuilder.php b/retailcrm/lib/RetailcrmOrderBuilder.php index d2b29ba..e1f8a46 100644 --- a/retailcrm/lib/RetailcrmOrderBuilder.php +++ b/retailcrm/lib/RetailcrmOrderBuilder.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmOrderBuilder { /** diff --git a/retailcrm/lib/RetailcrmPrestashopLoader.php b/retailcrm/lib/RetailcrmPrestashopLoader.php index 882a236..f4c7984 100644 --- a/retailcrm/lib/RetailcrmPrestashopLoader.php +++ b/retailcrm/lib/RetailcrmPrestashopLoader.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,14 +29,15 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + $_SERVER['HTTPS'] = 1; -require_once __DIR__ . '/../../../config/config.inc.php'; -require_once __DIR__ . '/../../../init.php'; -require_once __DIR__ . '/../bootstrap.php'; +require_once dirname(__FILE__) . '/../../../config/config.inc.php'; +require_once dirname(__FILE__) . '/../../../init.php'; +require_once dirname(__FILE__) . '/../bootstrap.php'; diff --git a/retailcrm/lib/RetailcrmReferences.php b/retailcrm/lib/RetailcrmReferences.php index 52fe77c..94322fb 100644 --- a/retailcrm/lib/RetailcrmReferences.php +++ b/retailcrm/lib/RetailcrmReferences.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmReferences { const GIFT_WRAPPING_ITEM_EXTERNAL_ID = 'giftWrappingCost'; diff --git a/retailcrm/lib/RetailcrmTools.php b/retailcrm/lib/RetailcrmTools.php index 3529a51..76b06a6 100644 --- a/retailcrm/lib/RetailcrmTools.php +++ b/retailcrm/lib/RetailcrmTools.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmTools { /** @@ -862,4 +863,18 @@ class RetailcrmTools return DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $config['date_add']); } + + /** + * @return string + */ + public static function getAdminControllerUrl($className) + { + $controllerName = str_replace('Controller', '', $className); + + return sprintf('%s%s/index.php?controller=%s&token=%s', + Tools::getAdminUrl(), + basename(_PS_ADMIN_DIR_), + $controllerName, + Tools::getAdminTokenLite($controllerName)); + } } diff --git a/retailcrm/lib/api/CurlException.php b/retailcrm/lib/api/CurlException.php index f254426..7fd5d43 100644 --- a/retailcrm/lib/api/CurlException.php +++ b/retailcrm/lib/api/CurlException.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class CurlException extends \RuntimeException { } diff --git a/retailcrm/lib/api/InvalidJsonException.php b/retailcrm/lib/api/InvalidJsonException.php index 6422239..652c53e 100644 --- a/retailcrm/lib/api/InvalidJsonException.php +++ b/retailcrm/lib/api/InvalidJsonException.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class InvalidJsonException extends \DomainException { } diff --git a/retailcrm/lib/api/RetailcrmApiClientV5.php b/retailcrm/lib/api/RetailcrmApiClientV5.php index da6c0dd..568d0e6 100644 --- a/retailcrm/lib/api/RetailcrmApiClientV5.php +++ b/retailcrm/lib/api/RetailcrmApiClientV5.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmApiClientV5 { const VERSION = 'v5'; diff --git a/retailcrm/lib/api/RetailcrmApiErrors.php b/retailcrm/lib/api/RetailcrmApiErrors.php index 550bad4..ff3ed36 100644 --- a/retailcrm/lib/api/RetailcrmApiErrors.php +++ b/retailcrm/lib/api/RetailcrmApiErrors.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmApiErrors { /** @var array */ diff --git a/retailcrm/lib/api/RetailcrmApiPaginatedRequest.php b/retailcrm/lib/api/RetailcrmApiPaginatedRequest.php index cc2e0d7..1af49e9 100644 --- a/retailcrm/lib/api/RetailcrmApiPaginatedRequest.php +++ b/retailcrm/lib/api/RetailcrmApiPaginatedRequest.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmApiPaginatedRequest { /** diff --git a/retailcrm/lib/api/RetailcrmApiRequest.php b/retailcrm/lib/api/RetailcrmApiRequest.php index 9385192..715aba5 100644 --- a/retailcrm/lib/api/RetailcrmApiRequest.php +++ b/retailcrm/lib/api/RetailcrmApiRequest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmApiRequest { diff --git a/retailcrm/lib/api/RetailcrmApiResponse.php b/retailcrm/lib/api/RetailcrmApiResponse.php index a7d21b0..b555bd2 100644 --- a/retailcrm/lib/api/RetailcrmApiResponse.php +++ b/retailcrm/lib/api/RetailcrmApiResponse.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmApiResponse implements \ArrayAccess { // HTTP response status code diff --git a/retailcrm/lib/api/RetailcrmHttpClient.php b/retailcrm/lib/api/RetailcrmHttpClient.php index 7b10aac..af489a1 100644 --- a/retailcrm/lib/api/RetailcrmHttpClient.php +++ b/retailcrm/lib/api/RetailcrmHttpClient.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmHttpClient { const METHOD_GET = 'GET'; diff --git a/retailcrm/lib/api/RetailcrmProxy.php b/retailcrm/lib/api/RetailcrmProxy.php index a4718cd..9ad11eb 100755 --- a/retailcrm/lib/api/RetailcrmProxy.php +++ b/retailcrm/lib/api/RetailcrmProxy.php @@ -1,9 +1,8 @@ - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmProxy { /** @@ -85,6 +85,7 @@ class RetailcrmProxy RetailcrmExceptionMiddleware::class, RetailcrmLoggerMiddleware::class, RetailcrmReferenceMiddleware::class, + RetailcrmExportOrdersMiddleware::class, ] ) ) diff --git a/retailcrm/lib/api/index.php b/retailcrm/lib/api/index.php index 63eec81..4043a55 100644 --- a/retailcrm/lib/api/index.php +++ b/retailcrm/lib/api/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/lib/api/middleware/RetailcrmExceptionMiddleware.php b/retailcrm/lib/api/middleware/RetailcrmExceptionMiddleware.php index 417c604..5a360b4 100644 --- a/retailcrm/lib/api/middleware/RetailcrmExceptionMiddleware.php +++ b/retailcrm/lib/api/middleware/RetailcrmExceptionMiddleware.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,13 +28,14 @@ * 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 - * @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmExceptionMiddleware implements RetailcrmMiddlewareInterface { /** diff --git a/retailcrm/lib/api/middleware/RetailcrmExportOrdersMiddleware.php b/retailcrm/lib/api/middleware/RetailcrmExportOrdersMiddleware.php new file mode 100644 index 0000000..49b412e --- /dev/null +++ b/retailcrm/lib/api/middleware/RetailcrmExportOrdersMiddleware.php @@ -0,0 +1,172 @@ + + * @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. + */ + +class RetailcrmExportOrdersMiddleware implements RetailcrmMiddlewareInterface +{ + /** + * {@inheritDoc} + * + * @throws Exception + */ + public function __invoke(RetailcrmApiRequest $request, callable $next = null) + { + if ('ordersCreate' === $request->getMethod() + || 'ordersEdit' === $request->getMethod() + ) { + return $this->handleOrdersCreateAndEdit($request, $next); + } + + if ('ordersUpload' === $request->getMethod()) { + return $this->handleOrdersUpload($request, $next); + } + + return $next($request); + } + + /** + * @param RetailcrmApiRequest $request + * @param callable $next + * + * @return RetailcrmApiResponse + * + * @throws Exception + */ + private function handleOrdersCreateAndEdit(RetailcrmApiRequest $request, callable $next) + { + $order = $request->getData()[0]; + + try { + $response = $next($request); + + if ($response->isSuccessful()) { + $crmOrderId = isset($response['id']) ? $response['id'] : null; + RetailcrmExportOrdersHelper::updateExportState($order['externalId'], $crmOrderId); + } else { + $errors = $response->offsetExists('errors') ? $response['errors'] : [$response['errorMsg']]; + RetailcrmExportOrdersHelper::updateExportState($order['externalId'], null, $errors); + } + + return $response; + } catch (Exception $e) { + if (isset($order['externalId'])) { + RetailcrmExportOrdersHelper::updateExportState($order['externalId'], null, [$e->getMessage()]); + } + + throw $e; + } + } + + /** + * @param RetailcrmApiRequest $request + * @param callable $next + * + * @return RetailcrmApiResponse + * + * @throws Exception + */ + private function handleOrdersUpload(RetailcrmApiRequest $request, callable $next) + { + $requestedOrders = array_map(function ($order) { + return $order['externalId']; + }, $request->getData()[0]); + + try { + $response = $next($request); + } catch (Exception $e) { + foreach ($requestedOrders as $id_order) { + RetailcrmExportOrdersHelper::updateExportState($id_order, null, [$e->getMessage()]); + } + + throw $e; + } + + if ($response->isSuccessful() && $response->offsetExists('uploadedOrders')) { + foreach ($response['uploadedOrders'] as $uploadedOrder) { + RetailcrmExportOrdersHelper::updateExportState($uploadedOrder['externalId'], $uploadedOrder['id']); + } + + return $response; + } + + $orders = $this->getUploadedOrders($request->getApi(), $requestedOrders); + + $uploadedOrders = []; + foreach ($orders as $order) { + RetailcrmExportOrdersHelper::updateExportState($order['externalId'], $order['id']); + $uploadedOrders[] = (int) ($order['externalId']); + } + + $notUploadedOrders = array_filter($requestedOrders, function ($orderId) use ($uploadedOrders) { + return !in_array($orderId, $uploadedOrders); + }); + + foreach ($notUploadedOrders as $id_order) { + RetailcrmExportOrdersHelper::updateExportState($id_order, null, ['Unknown error']); + } + + return new RetailcrmApiResponse($response->getStatusCode(), json_encode(array_merge( + json_decode($response->getRawResponse(), true), + [ + 'orders' => $orders, + 'uploadedOrders' => $uploadedOrders, + 'notUploadedOrders' => $notUploadedOrders, + ] + ))); + } + + /** + * @param RetailcrmApiClientV5 $api + * @param array $requestedOrders + * + * @return array + */ + private function getUploadedOrders(RetailcrmApiClientV5 $api, array $requestedOrders) + { + $orders = []; + + if (0 < count($requestedOrders)) { + $getResponse = $api->ordersList(['externalIds' => $requestedOrders], 1, 50); + + if ($getResponse->isSuccessful() && $getResponse->offsetExists('orders')) { + return $getResponse['orders']; + } + } + + return $orders; + } +} diff --git a/retailcrm/lib/api/middleware/RetailcrmLoggerMiddleware.php b/retailcrm/lib/api/middleware/RetailcrmLoggerMiddleware.php index f5fdbf6..8708dca 100644 --- a/retailcrm/lib/api/middleware/RetailcrmLoggerMiddleware.php +++ b/retailcrm/lib/api/middleware/RetailcrmLoggerMiddleware.php @@ -1,9 +1,8 @@ - * @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmLoggerMiddleware implements RetailcrmMiddlewareInterface { /** diff --git a/retailcrm/lib/api/middleware/RetailcrmReferenceMiddleware.php b/retailcrm/lib/api/middleware/RetailcrmReferenceMiddleware.php index b2183c2..4a4ec74 100644 --- a/retailcrm/lib/api/middleware/RetailcrmReferenceMiddleware.php +++ b/retailcrm/lib/api/middleware/RetailcrmReferenceMiddleware.php @@ -1,9 +1,8 @@ - * @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmReferenceMiddleware implements RetailcrmMiddlewareInterface { /** diff --git a/retailcrm/lib/api/middleware/index.php b/retailcrm/lib/api/middleware/index.php index 63eec81..4043a55 100644 --- a/retailcrm/lib/api/middleware/index.php +++ b/retailcrm/lib/api/middleware/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/lib/api/pipeline/RetailcrmMiddlewareInterface.php b/retailcrm/lib/api/pipeline/RetailcrmMiddlewareInterface.php index 7e80a97..18bb49d 100644 --- a/retailcrm/lib/api/pipeline/RetailcrmMiddlewareInterface.php +++ b/retailcrm/lib/api/pipeline/RetailcrmMiddlewareInterface.php @@ -1,4 +1,40 @@ + * @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. + */ interface RetailcrmMiddlewareInterface { diff --git a/retailcrm/lib/api/pipeline/RetailcrmPipeline.php b/retailcrm/lib/api/pipeline/RetailcrmPipeline.php index a4e70c4..63b0f3e 100644 --- a/retailcrm/lib/api/pipeline/RetailcrmPipeline.php +++ b/retailcrm/lib/api/pipeline/RetailcrmPipeline.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmPipeline { diff --git a/retailcrm/lib/api/pipeline/index.php b/retailcrm/lib/api/pipeline/index.php index 63eec81..4043a55 100644 --- a/retailcrm/lib/api/pipeline/index.php +++ b/retailcrm/lib/api/pipeline/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/lib/events/RetailcrmAbandonedCartsEvent.php b/retailcrm/lib/events/RetailcrmAbandonedCartsEvent.php index 4465bb2..86f9d32 100644 --- a/retailcrm/lib/events/RetailcrmAbandonedCartsEvent.php +++ b/retailcrm/lib/events/RetailcrmAbandonedCartsEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,14 +28,15 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmAbandonedCartsEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmAbstractEvent.php b/retailcrm/lib/events/RetailcrmAbstractEvent.php index 98c76ff..bf8e938 100644 --- a/retailcrm/lib/events/RetailcrmAbstractEvent.php +++ b/retailcrm/lib/events/RetailcrmAbstractEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,14 +28,15 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; abstract class RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmClearLogsEvent.php b/retailcrm/lib/events/RetailcrmClearLogsEvent.php index 6395cb8..235d164 100644 --- a/retailcrm/lib/events/RetailcrmClearLogsEvent.php +++ b/retailcrm/lib/events/RetailcrmClearLogsEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,13 +29,14 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmClearLogsEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmEventInterface.php b/retailcrm/lib/events/RetailcrmEventInterface.php index 0daf12b..ae751ab 100644 --- a/retailcrm/lib/events/RetailcrmEventInterface.php +++ b/retailcrm/lib/events/RetailcrmEventInterface.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,13 +28,14 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + interface RetailcrmEventInterface { /** diff --git a/retailcrm/lib/events/RetailcrmExportEvent.php b/retailcrm/lib/events/RetailcrmExportEvent.php index efd3c3a..aefc97a 100644 --- a/retailcrm/lib/events/RetailcrmExportEvent.php +++ b/retailcrm/lib/events/RetailcrmExportEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,14 +28,15 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmExportEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmIcmlEvent.php b/retailcrm/lib/events/RetailcrmIcmlEvent.php index a218190..ec55e83 100644 --- a/retailcrm/lib/events/RetailcrmIcmlEvent.php +++ b/retailcrm/lib/events/RetailcrmIcmlEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,13 +29,14 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmIcmlEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmIcmlUpdateUrlEvent.php b/retailcrm/lib/events/RetailcrmIcmlUpdateUrlEvent.php index 572f8b4..2b97dfc 100644 --- a/retailcrm/lib/events/RetailcrmIcmlUpdateUrlEvent.php +++ b/retailcrm/lib/events/RetailcrmIcmlUpdateUrlEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,14 +28,15 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmIcmlUpdateUrlEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmInventoriesEvent.php b/retailcrm/lib/events/RetailcrmInventoriesEvent.php index 74785c7..a349661 100644 --- a/retailcrm/lib/events/RetailcrmInventoriesEvent.php +++ b/retailcrm/lib/events/RetailcrmInventoriesEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,13 +29,14 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmInventoriesEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmMissingEvent.php b/retailcrm/lib/events/RetailcrmMissingEvent.php index 1e4b0f1..bd269ab 100644 --- a/retailcrm/lib/events/RetailcrmMissingEvent.php +++ b/retailcrm/lib/events/RetailcrmMissingEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,13 +29,14 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmMissingEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmSyncEvent.php b/retailcrm/lib/events/RetailcrmSyncEvent.php index c7df1e1..ba80b77 100644 --- a/retailcrm/lib/events/RetailcrmSyncEvent.php +++ b/retailcrm/lib/events/RetailcrmSyncEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,13 +29,14 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmSyncEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/RetailcrmUpdateSinceIdEvent.php b/retailcrm/lib/events/RetailcrmUpdateSinceIdEvent.php index 5610d74..e00e3ca 100644 --- a/retailcrm/lib/events/RetailcrmUpdateSinceIdEvent.php +++ b/retailcrm/lib/events/RetailcrmUpdateSinceIdEvent.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,13 +29,14 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ -require_once __DIR__ . '/../RetailcrmPrestashopLoader.php'; + +require_once dirname(__FILE__) . '/../RetailcrmPrestashopLoader.php'; class RetailcrmUpdateSinceIdEvent extends RetailcrmAbstractEvent implements RetailcrmEventInterface { diff --git a/retailcrm/lib/events/index.php b/retailcrm/lib/events/index.php index 63eec81..4043a55 100644 --- a/retailcrm/lib/events/index.php +++ b/retailcrm/lib/events/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/lib/exceptions/RetailcrmJobManagerException.php b/retailcrm/lib/exceptions/RetailcrmJobManagerException.php index 403d934..1624f53 100644 --- a/retailcrm/lib/exceptions/RetailcrmJobManagerException.php +++ b/retailcrm/lib/exceptions/RetailcrmJobManagerException.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmJobManagerException extends Exception { /** diff --git a/retailcrm/lib/exceptions/index.php b/retailcrm/lib/exceptions/index.php index 63eec81..4043a55 100644 --- a/retailcrm/lib/exceptions/index.php +++ b/retailcrm/lib/exceptions/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/lib/index.php b/retailcrm/lib/index.php index 63eec81..4043a55 100644 --- a/retailcrm/lib/index.php +++ b/retailcrm/lib/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/lib/models/RetailcrmCustomerSwitcherResult.php b/retailcrm/lib/models/RetailcrmCustomerSwitcherResult.php index e5278db..9ab457e 100644 --- a/retailcrm/lib/models/RetailcrmCustomerSwitcherResult.php +++ b/retailcrm/lib/models/RetailcrmCustomerSwitcherResult.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCustomerSwitcherResult { /** @var \Customer */ diff --git a/retailcrm/lib/models/RetailcrmCustomerSwitcherState.php b/retailcrm/lib/models/RetailcrmCustomerSwitcherState.php index 78d9f62..5b90017 100644 --- a/retailcrm/lib/models/RetailcrmCustomerSwitcherState.php +++ b/retailcrm/lib/models/RetailcrmCustomerSwitcherState.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmCustomerSwitcherState { /** @var \Order */ diff --git a/retailcrm/lib/models/index.php b/retailcrm/lib/models/index.php index 63eec81..4043a55 100644 --- a/retailcrm/lib/models/index.php +++ b/retailcrm/lib/models/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/lib/templates/RetailcrmAbstractTemplate.php b/retailcrm/lib/templates/RetailcrmAbstractTemplate.php index 486c466..69f35a9 100644 --- a/retailcrm/lib/templates/RetailcrmAbstractTemplate.php +++ b/retailcrm/lib/templates/RetailcrmAbstractTemplate.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + abstract class RetailcrmAbstractTemplate { /** @var Module|\RetailCRM */ diff --git a/retailcrm/lib/templates/RetailcrmBaseTemplate.php b/retailcrm/lib/templates/RetailcrmBaseTemplate.php index 9012a9c..e12483d 100644 --- a/retailcrm/lib/templates/RetailcrmBaseTemplate.php +++ b/retailcrm/lib/templates/RetailcrmBaseTemplate.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmBaseTemplate extends RetailcrmAbstractTemplate { protected function buildParams() diff --git a/retailcrm/lib/templates/RetailcrmSettingsTemplate.php b/retailcrm/lib/templates/RetailcrmSettingsTemplate.php index a7ac5a1..470db23 100644 --- a/retailcrm/lib/templates/RetailcrmSettingsTemplate.php +++ b/retailcrm/lib/templates/RetailcrmSettingsTemplate.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmSettingsTemplate extends RetailcrmAbstractTemplate { protected $settings; @@ -95,6 +96,16 @@ class RetailcrmSettingsTemplate extends RetailcrmAbstractTemplate $params['catalogInfoMultistore'] = RetailcrmCatalogHelper::getIcmlFileInfoMultistore(); $params['shopsInfo'] = RetailcrmContextSwitcher::getShops(); $params['errorTabs'] = $this->module->validateStoredSettings(); + + $params['retailControllerOrders'] = RetailcrmTools::getAdminControllerUrl( + RetailcrmOrdersController::class + ); + $params['retailControllerOrdersUpload'] = RetailcrmTools::getAdminControllerUrl( + RetailcrmOrdersUploadController::class + ); + $params['adminControllerOrders'] = RetailcrmTools::getAdminControllerUrl( + AdminOrdersController::class + ); } return $params; diff --git a/retailcrm/lib/templates/RetailcrmTemplateFactory.php b/retailcrm/lib/templates/RetailcrmTemplateFactory.php index 3cba055..77ce412 100644 --- a/retailcrm/lib/templates/RetailcrmTemplateFactory.php +++ b/retailcrm/lib/templates/RetailcrmTemplateFactory.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + class RetailcrmTemplateFactory { private $assets; diff --git a/retailcrm/lib/templates/index.php b/retailcrm/lib/templates/index.php index 63eec81..4043a55 100644 --- a/retailcrm/lib/templates/index.php +++ b/retailcrm/lib/templates/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/retailcrm.php b/retailcrm/retailcrm.php index ae41786..9579744 100644 --- a/retailcrm/retailcrm.php +++ b/retailcrm/retailcrm.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) { date_default_timezone_set(@date_default_timezone_get()); } @@ -43,7 +44,7 @@ if (!defined('_PS_VERSION_')) { exit; } -require_once __DIR__ . '/bootstrap.php'; +require_once dirname(__FILE__) . '/bootstrap.php'; class RetailCRM extends Module { @@ -99,6 +100,13 @@ class RetailCRM extends Module 'paymentDefault' => self::PAYMENT_DEFAULT, ]; + // todo dynamically define controller classes + const ADMIN_CONTROLLERS = [ + RetailcrmSettingsController::class, + RetailcrmOrdersController::class, + RetailcrmOrdersUploadController::class, + ]; + /** * @var array */ @@ -143,7 +151,7 @@ class RetailCRM extends Module { $this->name = 'retailcrm'; $this->tab = 'export'; - $this->version = '3.3.4'; + $this->version = '3.3.5'; $this->author = 'DIGITAL RETAIL TECHNOLOGIES SL'; $this->displayName = $this->l('Simla.com'); $this->description = $this->l('Integration module for Simla.com'); @@ -195,7 +203,60 @@ class RetailCRM extends Module && ($this->use_new_hooks ? $this->registerHook('actionCustomerAccountUpdate') : true) && ($this->use_new_hooks ? $this->registerHook('actionValidateCustomerAddressForm') : true) && $this->installDB() - ; + && $this->installTab() + ; + } + + /** + * Installs the tab for the admin controller + * + * @return bool + */ + public function installTab() + { + /** @var RetailcrmAdminAbstractController $controller */ + foreach (self::ADMIN_CONTROLLERS as $controller) { + $tab = new Tab(); + $tab->id = $controller::getId(); + $tab->id_parent = $controller::getParentId(); + $tab->class_name = $controller::getClassName(); + $tab->name = $controller::getName(); + $tab->icon = $controller::getIcon(); + $tab->position = $controller::getPosition(); + $tab->active = 1; + $tab->module = $this->name; + + if (!$tab->save()) { + return false; + } + } + + return true; + } + + /** + * @return bool + * + * @throws PrestaShopDatabaseException + * @throws PrestaShopException + */ + public function uninstallTab() + { + /** @var RetailcrmAdminAbstractController $controller */ + foreach (self::ADMIN_CONTROLLERS as $controller) { + $tabId = $controller::getId(); + if (!$tabId) { + continue; + } + + $tab = new Tab($tabId); + + if (!$tab->delete()) { + return false; + } + } + + return true; } public function hookHeader() @@ -258,7 +319,23 @@ class RetailCRM extends Module && Configuration::deleteByName(RetailcrmJobManager::IN_PROGRESS_NAME) && Configuration::deleteByName(RetailcrmJobManager::CURRENT_TASK) && Configuration::deleteByName(RetailcrmCli::CURRENT_TASK_CLI) - && $this->uninstallDB(); + && $this->uninstallDB() + && $this->uninstallTab() + ; + } + + public function enable($force_all = false) + { + return parent::enable($force_all) + && $this->installTab() + ; + } + + public function disable($force_all = false) + { + return parent::disable($force_all) + && $this->uninstallTab() + ; } public function installDB() @@ -270,13 +347,25 @@ class RetailCRM extends Module FOREIGN KEY (id_cart) REFERENCES ' . _DB_PREFIX_ . 'cart (id_cart) ON DELETE CASCADE ON UPDATE CASCADE + ) DEFAULT CHARSET=utf8; + CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'retailcrm_exported_orders` ( + `id_order` INT UNSIGNED UNIQUE NULL, + `id_order_crm` INT UNSIGNED UNIQUE NULL, + `errors` TEXT NULL, + `last_uploaded` DATETIME, + FOREIGN KEY (id_order) REFERENCES ' . _DB_PREFIX_ . 'orders (id_order) + ON DELETE CASCADE + ON UPDATE CASCADE ) DEFAULT CHARSET=utf8;' ); } public function uninstallDB() { - return Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'retailcrm_abandonedcarts`;'); + return Db::getInstance()->execute( + 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'retailcrm_abandonedcarts`; + DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'retailcrm_exported_orders`;' + ); } public function getContent() @@ -343,11 +432,9 @@ class RetailCRM extends Module } if (!($this->api instanceof RetailcrmProxy)) { - $apiUrl = Configuration::get(static::API_URL); - $apiKey = Configuration::get(static::API_KEY); - if (!empty($apiUrl) && !empty($apiKey)) { - $this->api = new RetailcrmProxy($apiUrl, $apiKey, _PS_ROOT_DIR_ . '/retailcrm.log'); - } else { + $this->api = RetailcrmTools::getApiClient(); + + if (!($this->api instanceof RetailcrmProxy)) { return $this->displayError($this->l("Can't upload orders - set API key and API URL first!")); } } @@ -776,8 +863,7 @@ class RetailCRM extends Module $externalId = false; foreach ($this->reference->getSystemPaymentModules() as $paymentCMS) { - if ( - $paymentCMS['name'] === $params['paymentCC']->payment_method + if ($paymentCMS['name'] === $params['paymentCC']->payment_method && array_key_exists($paymentCMS['code'], $payments) && !empty($payments[$paymentCMS['code']]) ) { diff --git a/retailcrm/translations/es.php b/retailcrm/translations/es.php index 213efe3..8c3ff2e 100644 --- a/retailcrm/translations/es.php +++ b/retailcrm/translations/es.php @@ -1,10 +1,47 @@ + * @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. + */ global $_MODULE; $_MODULE = []; $_MODULE['<{retailcrm}prestashop>retailcrm_9b1e2d4b35252401dbdab3cbad2735c4'] = 'Simla.com'; $_MODULE['<{retailcrm}prestashop>retailcrm_5e36a81536959d8cde52246dd15a6fca'] = 'Módulo de integración para Simla.com'; $_MODULE['<{retailcrm}prestashop>retailcrm_876f23178c29dc2552c0b48bf23cd9bd'] = '¿Está seguro de que desea eliminar el módulo?'; +$_MODULE['<{retailcrm}prestashop>retailcrm_5e66ee98e79567f8daf9454b5517f819'] = 'Se debe especificar al menos un ID de pedido'; $_MODULE['<{retailcrm}prestashop>retailcrm_6bd461d1fc51b3294c6513cecc24758d'] = 'Los pedidos han sido cargados con éxito'; $_MODULE['<{retailcrm}prestashop>retailcrm_9a7fc06b4b2359f1f26f75fbbe27a3e8'] = 'No todos los pedidos se han cargado con existo'; $_MODULE['<{retailcrm}prestashop>retailcrm_e7244a5e543ba692ebc495aee934ee9b'] = 'Orden omitida por inexistencia: %s'; @@ -82,6 +119,8 @@ $_MODULE['<{retailcrm}prestashop>index_95428f32e5c696cf71baccb776bc5c15'] = 'Tra $_MODULE['<{retailcrm}prestashop>index_e7f9e382dc50889098cbe56f2554c77b'] = 'Tarjeta bancaria'; $_MODULE['<{retailcrm}prestashop>index_7088f1d1d9c91d8b75e9882ffd78540c'] = 'Datos de contacto'; $_MODULE['<{retailcrm}prestashop>index_50f158e2507321f1a5b6f8fb9e350818'] = 'Escríbenos en caso de preguntas o dudas'; +$_MODULE['<{retailcrm}prestashop>module_translates_2207b29a762b5d7798e9794cad24f518'] = 'No se encontraron pedidos'; +$_MODULE['<{retailcrm}prestashop>module_translates_79b5ffb5b4868e9fc8b6c6e3efafd416'] = 'Ocurrió un error al buscar los pedidos. Inténtalo de nuevo'; $_MODULE['<{retailcrm}prestashop>settings_2b65c584b7b4d7bd19d36f7d2b690c6a'] = 'Catálogo Icml'; $_MODULE['<{retailcrm}prestashop>settings_c2cc7082a89c1ad6631a2f66af5f00c0'] = 'Conexión'; $_MODULE['<{retailcrm}prestashop>settings_065ab3a28ca4f16f55f103adc7d0226f'] = 'Los métodos del envío'; @@ -134,25 +173,32 @@ $_MODULE['<{retailcrm}prestashop>settings_a54a0e8a7a80b58ce5f8e2ef344bbf95'] = ' $_MODULE['<{retailcrm}prestashop>settings_65dd9f6e8bf4eaf54c3dc96f011dade1'] = 'Recibir las existencias del Simla.com'; $_MODULE['<{retailcrm}prestashop>settings_b55197a49e8c4cd8c314bc2aa39d6feb'] = 'Agotado'; $_MODULE['<{retailcrm}prestashop>settings_4c271a7beaf103049443085ccab1f03f'] = 'Cambio de estado del pedido si el producto está agotado y se deniega su pedido con stock cero.'; +$_MODULE['<{retailcrm}prestashop>settings_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Active'; +$_MODULE['<{retailcrm}prestashop>settings_f75d8fa5c89351544d372cf90528ccf2'] = 'Clave de la página web'; +$_MODULE['<{retailcrm}prestashop>settings_c9cc8cce247e49bae79f15173ce97354'] = 'Guardar'; $_MODULE['<{retailcrm}prestashop>settings_6f1f9a3e435963417d08849fbef139c1'] = 'Ingrese los ID de los pedidos para cargar en Simla.com, divididos por una coma. También puede especificar rangos, como \"1-10\". Se permite subir hasta 10 pedidos a la vez.'; $_MODULE['<{retailcrm}prestashop>settings_acfa058ec9e6e4745eddc0cae3f0f881'] = 'Identificador del pedido'; $_MODULE['<{retailcrm}prestashop>settings_91412465ea9169dfd901dd5e7c96dd99'] = 'Subir'; -$_MODULE['<{retailcrm}prestashop>settings_f4af7f6987dfee28741ce77ff2d09d46'] = 'Exportar pedidos y clientes'; $_MODULE['<{retailcrm}prestashop>settings_418faff1c9df0d297ff586ac3230be97'] = 'Puede exportar todos los pedidos y clientes de CMS a Simla.com presionando el botón \"Exportar\". Este proceso puede llevar mucho tiempo y es necesario que mantenga la pestaña abierta hasta que termine.'; $_MODULE['<{retailcrm}prestashop>settings_7442e29d7d53e549b78d93c46b8cdcfc'] = 'Pedidos'; $_MODULE['<{retailcrm}prestashop>settings_e6d0e1c8fc6a4fcf47869df87e04cd88'] = 'Clientes'; $_MODULE['<{retailcrm}prestashop>settings_f8f36c02fa6f370808135c66cfc788aa'] = 'Clientes sin pedidos'; $_MODULE['<{retailcrm}prestashop>settings_0095a9fa74d1713e43e370a7d7846224'] = 'Exportar'; -$_MODULE['<{retailcrm}prestashop>settings_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Active'; -$_MODULE['<{retailcrm}prestashop>settings_f75d8fa5c89351544d372cf90528ccf2'] = 'Clave de la página web'; -$_MODULE['<{retailcrm}prestashop>settings_c9cc8cce247e49bae79f15173ce97354'] = 'Guardar'; +$_MODULE['<{retailcrm}prestashop>settings_51348d86bbb5ef9d37b0cc340bcafd2d'] = 'Pedidos cargados'; +$_MODULE['<{retailcrm}prestashop>settings_7db8c329e031289c4bee5dc9628fbef7'] = 'En esta sección puede comprobar los resultados de exportación de pedidos y el pedido de carga manual a'; +$_MODULE['<{retailcrm}prestashop>settings_13348442cc6a27032d2b4aa28b75a5d3'] = 'Buscar'; +$_MODULE['<{retailcrm}prestashop>settings_b1c94ca2fbc3e78fc30069c8d0f01680'] = 'Todo'; +$_MODULE['<{retailcrm}prestashop>settings_fe8d588f340d7507265417633ccff16e'] = 'Subido'; +$_MODULE['<{retailcrm}prestashop>settings_902b0d55fddef6f8d651fe1035b7d4bd'] = 'Error'; +$_MODULE['<{retailcrm}prestashop>settings_da9c83250288c94613605b535c26c648'] = 'Fecha y Hora'; +$_MODULE['<{retailcrm}prestashop>settings_0b7fa7fc169b7d50df4dbe2303bfd201'] = 'ID en'; +$_MODULE['<{retailcrm}prestashop>settings_ec53a8c4f07baed5d8825072c89799be'] = 'Estado'; $_MODULE['<{retailcrm}prestashop>settings_4f18e3f1c9941a6ec5a38bc716c521b4'] = 'Código que necesita insertar en la web'; $_MODULE['<{retailcrm}prestashop>settings_ec3028a12402ab7f43962a6f3a667b6e'] = 'Modo de depuración'; $_MODULE['<{retailcrm}prestashop>settings_5465108dc7fdda5c9ee8f00136bbaa61'] = 'Web Jobs'; $_MODULE['<{retailcrm}prestashop>settings_9082f68bc90113d8950e4ed7fe8fa0a4'] = 'Administrador de tareas'; $_MODULE['<{retailcrm}prestashop>settings_9194de58ce560c095f02cefc1c1c61e6'] = 'Nombre de la tarea'; $_MODULE['<{retailcrm}prestashop>settings_05a3a24340b7b9cc8d4e08f0ef4f4dd9'] = 'Última ejecución'; -$_MODULE['<{retailcrm}prestashop>settings_ec53a8c4f07baed5d8825072c89799be'] = 'Estado'; $_MODULE['<{retailcrm}prestashop>settings_0be8406951cdfda82f00f79328cf4efc'] = 'Comentario'; $_MODULE['<{retailcrm}prestashop>settings_fe5b6cd4d7a31615bbec8d1505089d87'] = 'StackTrace'; $_MODULE['<{retailcrm}prestashop>settings_48b516cc37de64527a42da11c35d3ddc'] = 'Reset jobs'; diff --git a/retailcrm/translations/index.php b/retailcrm/translations/index.php index 7e187a2..28bee70 100644 --- a/retailcrm/translations/index.php +++ b/retailcrm/translations/index.php @@ -1,3 +1,37 @@ + * @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. + */ diff --git a/retailcrm/translations/ru.php b/retailcrm/translations/ru.php index fd626d1..68a3006 100644 --- a/retailcrm/translations/ru.php +++ b/retailcrm/translations/ru.php @@ -1,10 +1,47 @@ + * @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. + */ global $_MODULE; $_MODULE = []; $_MODULE['<{retailcrm}prestashop>retailcrm_9b1e2d4b35252401dbdab3cbad2735c4'] = 'Simla.com'; $_MODULE['<{retailcrm}prestashop>retailcrm_5e36a81536959d8cde52246dd15a6fca'] = 'Интеграционный модуль для Simla.com'; $_MODULE['<{retailcrm}prestashop>retailcrm_876f23178c29dc2552c0b48bf23cd9bd'] = 'Вы уверены, что хотите удалить модуль?'; +$_MODULE['<{retailcrm}prestashop>retailcrm_5e66ee98e79567f8daf9454b5517f819'] = 'Укажите хотя бы один идентификатор заказа'; $_MODULE['<{retailcrm}prestashop>retailcrm_6bd461d1fc51b3294c6513cecc24758d'] = 'Все заказы успешно загружены'; $_MODULE['<{retailcrm}prestashop>retailcrm_9a7fc06b4b2359f1f26f75fbbe27a3e8'] = 'Не все заказы загружены успешно'; $_MODULE['<{retailcrm}prestashop>retailcrm_e7244a5e543ba692ebc495aee934ee9b'] = 'Заказы не найдены и пропущены: %s'; @@ -82,6 +119,8 @@ $_MODULE['<{retailcrm}prestashop>index_95428f32e5c696cf71baccb776bc5c15'] = 'Б $_MODULE['<{retailcrm}prestashop>index_e7f9e382dc50889098cbe56f2554c77b'] = 'Кредитной картой'; $_MODULE['<{retailcrm}prestashop>index_7088f1d1d9c91d8b75e9882ffd78540c'] = 'Наши контакты'; $_MODULE['<{retailcrm}prestashop>index_50f158e2507321f1a5b6f8fb9e350818'] = 'Пишите нам если у Вас есть вопросы'; +$_MODULE['<{retailcrm}prestashop>module_translates_2207b29a762b5d7798e9794cad24f518'] = 'Заказы не найдены'; +$_MODULE['<{retailcrm}prestashop>module_translates_79b5ffb5b4868e9fc8b6c6e3efafd416'] = 'Возникла ошибка при попытке поиска заказов. Попробуйте еще раз'; $_MODULE['<{retailcrm}prestashop>settings_2b65c584b7b4d7bd19d36f7d2b690c6a'] = 'Каталог Icml'; $_MODULE['<{retailcrm}prestashop>settings_c2cc7082a89c1ad6631a2f66af5f00c0'] = 'Соединение'; $_MODULE['<{retailcrm}prestashop>settings_065ab3a28ca4f16f55f103adc7d0226f'] = 'Способы доставки'; @@ -134,25 +173,32 @@ $_MODULE['<{retailcrm}prestashop>settings_a54a0e8a7a80b58ce5f8e2ef344bbf95'] = ' $_MODULE['<{retailcrm}prestashop>settings_65dd9f6e8bf4eaf54c3dc96f011dade1'] = 'Получать остатки из Simla.com'; $_MODULE['<{retailcrm}prestashop>settings_b55197a49e8c4cd8c314bc2aa39d6feb'] = 'Нет в наличии'; $_MODULE['<{retailcrm}prestashop>settings_4c271a7beaf103049443085ccab1f03f'] = 'Изменять статус заказа, если товара нет в наличии и запрещена его покупка с нулевым остатком на складе.'; +$_MODULE['<{retailcrm}prestashop>settings_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Активно'; +$_MODULE['<{retailcrm}prestashop>settings_f75d8fa5c89351544d372cf90528ccf2'] = 'Ключ сайта'; +$_MODULE['<{retailcrm}prestashop>settings_c9cc8cce247e49bae79f15173ce97354'] = 'Сохранить'; $_MODULE['<{retailcrm}prestashop>settings_6f1f9a3e435963417d08849fbef139c1'] = 'Введите идентификаторы заказов для загрузки в Simla.com, разделив их запятыми. Вы также можете указать диапазоны, например \"1-10\". Одновременно можно загружать до 10 заказов.'; $_MODULE['<{retailcrm}prestashop>settings_acfa058ec9e6e4745eddc0cae3f0f881'] = 'ID заказов'; $_MODULE['<{retailcrm}prestashop>settings_91412465ea9169dfd901dd5e7c96dd99'] = 'Выгрузить'; -$_MODULE['<{retailcrm}prestashop>settings_f4af7f6987dfee28741ce77ff2d09d46'] = 'Экспортировать заказы и клиентов'; $_MODULE['<{retailcrm}prestashop>settings_418faff1c9df0d297ff586ac3230be97'] = 'Вы можете экспортировать все заказы и клиентов из CMS в Simla.com, нажав кнопку «Экспорт». Этот процесс может занять много времени, и до его завершения необходимо держать вкладку открытой.'; $_MODULE['<{retailcrm}prestashop>settings_7442e29d7d53e549b78d93c46b8cdcfc'] = 'Заказы'; $_MODULE['<{retailcrm}prestashop>settings_e6d0e1c8fc6a4fcf47869df87e04cd88'] = 'Клиенты'; $_MODULE['<{retailcrm}prestashop>settings_f8f36c02fa6f370808135c66cfc788aa'] = 'Клиенты без заказов'; $_MODULE['<{retailcrm}prestashop>settings_0095a9fa74d1713e43e370a7d7846224'] = 'Экспортировать'; -$_MODULE['<{retailcrm}prestashop>settings_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Активно'; -$_MODULE['<{retailcrm}prestashop>settings_f75d8fa5c89351544d372cf90528ccf2'] = 'Ключ сайта'; -$_MODULE['<{retailcrm}prestashop>settings_c9cc8cce247e49bae79f15173ce97354'] = 'Сохранить'; +$_MODULE['<{retailcrm}prestashop>settings_51348d86bbb5ef9d37b0cc340bcafd2d'] = 'Выгруженные заказы'; +$_MODULE['<{retailcrm}prestashop>settings_7db8c329e031289c4bee5dc9628fbef7'] = 'В этом разделе вы можете проверить результат выгрузки заказов, а также вручную выгрузить заказы в'; +$_MODULE['<{retailcrm}prestashop>settings_13348442cc6a27032d2b4aa28b75a5d3'] = 'Искать'; +$_MODULE['<{retailcrm}prestashop>settings_b1c94ca2fbc3e78fc30069c8d0f01680'] = 'Все'; +$_MODULE['<{retailcrm}prestashop>settings_fe8d588f340d7507265417633ccff16e'] = 'Выгружен'; +$_MODULE['<{retailcrm}prestashop>settings_902b0d55fddef6f8d651fe1035b7d4bd'] = 'Ошибка'; +$_MODULE['<{retailcrm}prestashop>settings_da9c83250288c94613605b535c26c648'] = 'Дата и Время'; +$_MODULE['<{retailcrm}prestashop>settings_0b7fa7fc169b7d50df4dbe2303bfd201'] = 'ID в'; +$_MODULE['<{retailcrm}prestashop>settings_ec53a8c4f07baed5d8825072c89799be'] = 'Статус'; $_MODULE['<{retailcrm}prestashop>settings_4f18e3f1c9941a6ec5a38bc716c521b4'] = 'Код для вставки на сайт'; $_MODULE['<{retailcrm}prestashop>settings_ec3028a12402ab7f43962a6f3a667b6e'] = 'Режим отладки'; $_MODULE['<{retailcrm}prestashop>settings_5465108dc7fdda5c9ee8f00136bbaa61'] = 'Web Jobs'; $_MODULE['<{retailcrm}prestashop>settings_9082f68bc90113d8950e4ed7fe8fa0a4'] = 'Менеджер задач'; $_MODULE['<{retailcrm}prestashop>settings_9194de58ce560c095f02cefc1c1c61e6'] = 'Имя задачи'; $_MODULE['<{retailcrm}prestashop>settings_05a3a24340b7b9cc8d4e08f0ef4f4dd9'] = 'Последний запуск'; -$_MODULE['<{retailcrm}prestashop>settings_ec53a8c4f07baed5d8825072c89799be'] = 'Статус'; $_MODULE['<{retailcrm}prestashop>settings_0be8406951cdfda82f00f79328cf4efc'] = 'Комментарий'; $_MODULE['<{retailcrm}prestashop>settings_fe5b6cd4d7a31615bbec8d1505089d87'] = 'StackTrace'; $_MODULE['<{retailcrm}prestashop>settings_48b516cc37de64527a42da11c35d3ddc'] = 'Сброс Jobs'; diff --git a/retailcrm/upgrade/index.php b/retailcrm/upgrade/index.php index 63eec81..4043a55 100644 --- a/retailcrm/upgrade/index.php +++ b/retailcrm/upgrade/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/upgrade/upgrade-3.0.1.php b/retailcrm/upgrade/upgrade-3.0.1.php index d7f3697..0a07568 100644 --- a/retailcrm/upgrade/upgrade-3.0.1.php +++ b/retailcrm/upgrade/upgrade-3.0.1.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (!defined('_PS_VERSION_')) { exit; } diff --git a/retailcrm/upgrade/upgrade-3.0.2.php b/retailcrm/upgrade/upgrade-3.0.2.php index a47d8bb..0d1079c 100644 --- a/retailcrm/upgrade/upgrade-3.0.2.php +++ b/retailcrm/upgrade/upgrade-3.0.2.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -29,12 +29,13 @@ * needs please refer to http://www.prestashop.com for more information. * * @author DIGITAL RETAIL TECHNOLOGIES SL - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (!defined('_PS_VERSION_')) { exit; } diff --git a/retailcrm/upgrade/upgrade-3.3.0.php b/retailcrm/upgrade/upgrade-3.3.0.php index c96b2f2..24dd7e6 100644 --- a/retailcrm/upgrade/upgrade-3.3.0.php +++ b/retailcrm/upgrade/upgrade-3.3.0.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,13 +28,14 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (!defined('_PS_VERSION_')) { exit; } diff --git a/retailcrm/upgrade/upgrade-3.3.2.php b/retailcrm/upgrade/upgrade-3.3.2.php index e492f8c..f88b088 100644 --- a/retailcrm/upgrade/upgrade-3.3.2.php +++ b/retailcrm/upgrade/upgrade-3.3.2.php @@ -2,7 +2,7 @@ /** * MIT License * - * Copyright (c) 2020 DIGITAL RETAIL TECHNOLOGIES SL + * 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 @@ -28,13 +28,14 @@ * 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 - * @copyright 2020 DIGITAL RETAIL TECHNOLOGIES SL - * @license https://opensource.org/licenses/MIT The MIT License + * @author DIGITAL RETAIL TECHNOLOGIES SL + * @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. */ + if (!defined('_PS_VERSION_')) { exit; } diff --git a/retailcrm/upgrade/upgrade-3.3.5.php b/retailcrm/upgrade/upgrade-3.3.5.php new file mode 100644 index 0000000..791bf5d --- /dev/null +++ b/retailcrm/upgrade/upgrade-3.3.5.php @@ -0,0 +1,57 @@ + + * @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. + */ + +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * Upgrade module to version 3.3.5 + * + * @param \RetailCRM $module + * + * @return bool + */ +function upgrade_module_3_3_5($module) +{ + if ('retailcrm' != $module->name) { + return false; + } + + return $module->installDB() && $module->installTab(); +} diff --git a/retailcrm/views/css/index.php b/retailcrm/views/css/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/css/index.php +++ b/retailcrm/views/css/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/views/css/less/index.php b/retailcrm/views/css/less/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/css/less/index.php +++ b/retailcrm/views/css/less/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/views/css/less/retailcrm-export.less b/retailcrm/views/css/less/retailcrm-export.less index 88dde45..3adb52c 100644 --- a/retailcrm/views/css/less/retailcrm-export.less +++ b/retailcrm/views/css/less/retailcrm-export.less @@ -5,20 +5,26 @@ text-align: center; padding: 20px; margin: 20px 0; + &__title { font-size: 18px; margin-bottom: 20px; } + &__content, - input&__content { + .retail input&__content, + .retail input[type="text"] &__content, + .retail input[readonly][type="text"] &__content { width: 120px; height: 120px; border-radius: 120px; text-align: center; font-size: 20px; line-height: 60px; + display: inline-block; } } + &-progress { border-radius: 60px; border: 1px solid rgba(122, 122, 122, 0.15); @@ -26,6 +32,7 @@ height: 60px; overflow: hidden; transition: height 0.25s ease; + &__loader { width: 0; border-radius: 60px; @@ -39,8 +46,9 @@ line-height: 60px; } } + &-hidden { visibility: hidden; - height: 0!important; + height: 0 !important; } } diff --git a/retailcrm/views/css/less/retailcrm-orders.less b/retailcrm/views/css/less/retailcrm-orders.less new file mode 100644 index 0000000..cce604e --- /dev/null +++ b/retailcrm/views/css/less/retailcrm-orders.less @@ -0,0 +1,192 @@ +#retail-search-orders-form { + .retail-form__area { + width: 30% !important; + } + + #search-orders-submit { + width: 15%; + } + + .retail-row__content { + width: 100%; + } + + .retail-table-filter { + display: inline-block; + vertical-align: top; + background: rgba(122, 122, 122, 0.1); + border-radius: 58px; + height: 60px; + line-height: 60px; + padding: 0; + font-size: 18px; + font-weight: 600; + text-align: center; + color: #0068FF; + text-decoration: none; + cursor: pointer; + appearance: none; + border: none; + box-shadow: none; + transition: .25s ease; + width: 45%; + margin-left: 9%; + + label.retail-table-filter-btn { + width: 33.333333%; + height: 60px; + margin: 0; + padding: 0; + display: block; + float: left; + text-align: center; + font-size: 16px; + text-shadow: none; + cursor: pointer; + transition-property: color, background-color; + transition-duration: .3s; + + &.active, &:hover { + color: white; + } + + &.active { + background: #0068FF; + } + + &:hover:not(.active) { + color: white; + background: #005add !important; + } + + &:first-child { + border-right: 1px solid gray; + border-bottom-left-radius: 58px; + border-top-left-radius: 58px; + } + + &:last-child { + border-left: 1px solid gray; + border-bottom-right-radius: 58px; + border-top-right-radius: 58px; + } + } + } + + input.search-orders-filter { + display: none; + } +} + +.retail-controller-link { + display: none; +} + +.retail-table-pagination { + &__item { + display: inline-flex; + align-items: center; + justify-content: center; + vertical-align: top; + min-width: 40px; + height: 40px; + background: rgba(122, 122, 122, 0.1); + font-weight: bold; + font-size: 16px; + color: #363A41; + text-decoration: none; + border: 0; + border-radius: 5px; + text-align: center; + transition: .25s ease; + padding: 10px; + margin: 10px; + + &.active, &:hover { + color: white; + } + + &.active { + background: #0068FF; + } + + &:hover { + background: #005add; + } + + &--divider { + background: transparent; + pointer-events: none; + } + } +} + +#retail-orders-table { + .retail-orders-table__status { + &:not(.error) .retail-orders-table__status--error { + + display: none; + } + + &.error .retail-orders-table__status--success { + display: none; + } + } + + .retail-orders-table__upload { + cursor: pointer; + + &:hover { + color: #0068ff; + fill: #0068ff; + } + } +} + +.retail-row { + &--foldable { + border-radius: 8px; + margin: 20px 0; + padding: 0 3%; + transition: .25s ease; + box-shadow: 0 2px 4px rgba(30, 34, 72, .16); + border: 2px solid #fff; + -webkit-box-shadow: 0 2px 4px rgba(30, 34, 72, .16); + + &:hover, &.active { + box-shadow: 0 8px 16px rgba(30, 34, 72, .16); + } + + &.active { + border-color: #005eeb; + + .retail-row__title { + cursor: initial; + } + + .retail-row__content { + display: block; + height: auto; + padding-bottom: 40px; + } + } + } + + &--foldable &__title, + &--foldable &__content { + margin: 0 !important; + } + + &--foldable &__title { + padding: 22px 0; + cursor: pointer; + } + + &--foldable &__content { + display: none; + height: 0; + overflow: hidden; + padding: 0; + transition: .25s ease; + } +} diff --git a/retailcrm/views/css/less/styles.less b/retailcrm/views/css/less/styles.less index 913eb45..1bd5e8a 100644 --- a/retailcrm/views/css/less/styles.less +++ b/retailcrm/views/css/less/styles.less @@ -31,21 +31,36 @@ body, html { visibility: hidden; } +.icon-RetailcrmSettings:before { + content: "\f07a"; +} + .retail { &-wrap { font-family: OpenSans, Arial, sans-serif; padding: 0 15px; height: 100%; + background: white; *, *::before, *::after { box-sizing: border-box; } } + + input[type=file], input[type=password], input[type=text], input[readonly][type=text], textarea { + -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .1) inset; + box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); + background-color: #fff; + border: 1px solid #ccc; + padding: 2px 4px; + } + &-container { margin: 0 auto; width: 100%; max-width: 950px; } + &-title { margin: 60px 0 0; font-weight: 400; @@ -58,15 +73,18 @@ body, html { margin-top: 40px; } } + &-txt { color: @gray; font-size: 18px; line-height: 26px; } + &-descript { margin-top: 45px; text-align: center; } + &-tab { &__enabled { display: block; @@ -76,6 +94,7 @@ body, html { display: none !important; } } + &-video { margin: 30px auto 0; text-align: center; @@ -118,6 +137,7 @@ body, html { } } } + &-btns { margin: 56px auto 0; display: flex; @@ -137,6 +157,7 @@ body, html { opacity: 0; } } + &-form { &__spacer { @@ -160,12 +181,14 @@ body, html { } } } + &__label { width: 100% !important; text-align: left !important; margin: 15px 12px; font-size: 15px; } + &__row { margin-top: 15px; @@ -173,6 +196,7 @@ body, html { margin-top: 23px; } } + &__message-warning { padding: 13px 18px; margin: 1px 13px; @@ -181,6 +205,7 @@ body, html { font-size: 1rem; box-shadow: 0px 0px 6px 0px @shadowGray; } + &__checkbox { display: flex; flex-direction: row; @@ -198,6 +223,7 @@ body, html { font-size: 16px; } } + &__area { display: inline-block !important; vertical-align: top; @@ -209,16 +235,28 @@ body, html { padding: 0 28px !important; line-height: normal; color: @gray !important; + background-color: white!important; font-size: 16px !important; appearance: none; &:focus { color: @darkGray; - &::-webkit-input-placeholder {color: @darkGray;} - &::-moz-placeholder {color: @darkGray;} - &:-moz-placeholder {color: @darkGray;} - &:-ms-input-placeholder {color: @darkGray;} + &::-webkit-input-placeholder { + color: @darkGray; + } + + &::-moz-placeholder { + color: @darkGray; + } + + &:-moz-placeholder { + color: @darkGray; + } + + &:-ms-input-placeholder { + color: @darkGray; + } } &_txt { @@ -247,6 +285,7 @@ body, html { } } } + &-tabs { margin-top: 60px; @@ -291,13 +330,16 @@ body, html { } } } + &__head { display: flex; justify-content: space-between; border-bottom: 1px solid @bord; } + &__body { padding-top: 18px; + p { margin-top: 23px; margin-bottom: 0; @@ -306,10 +348,12 @@ body, html { line-height: 24px; } } + &__item { display: none; } } + &-list { margin: 0; padding: 0; @@ -333,6 +377,7 @@ body, html { } } } + &-tile { display: flex; flex-wrap: wrap; @@ -344,10 +389,12 @@ body, html { &:nth-child(1) { width: 52%; } + &_contacts { padding-right: 0; } } + &__row { display: flex; justify-content: center; @@ -357,6 +404,7 @@ body, html { margin-bottom: 0; } } + &__item { margin-top: 34px; @@ -364,18 +412,21 @@ body, html { margin-top: 20px; } } + &__title { color: @darkGray; font-size: 16px; font-weight: 600; line-height: 24px; } + &__descript { color: @gray; font-size: 16px; line-height: 24px; margin-top: 10px; } + &__link { color: @blue; font-size: 16px; @@ -388,6 +439,7 @@ body, html { } } } + &-popup { position: absolute; width: 90%; @@ -421,9 +473,11 @@ body, html { width: 2px; background: white; } + &::before { transform: rotate(45deg); } + &::after { transform: rotate(-45deg); } @@ -432,17 +486,19 @@ body, html { &.open { transform: translate3d(0, 0, 0) scale(1); } + &-wrap { position: fixed; left: 0; right: 0; top: 0; bottom: 0; - background: rgba(0,0,0,0.6); + background: rgba(0, 0, 0, 0.6); z-index: 1000; display: none; } } + &-column { display: flex; max-width: 1389px; @@ -450,15 +506,21 @@ body, html { &__aside { width: 253px; - background: @grayBg;min-height: 300px; + background: @grayBg; + min-height: 300px; + + #content.bootstrap & { + margin: 10px 0; + } } + &__content { flex: 1 0 auto; padding: 0 58px; min-height: 300px; - } } + &-menu { padding: 8px 20px 8px 15px; @@ -504,6 +566,7 @@ body, html { background: @redHover !important; } } + &_error { color: white !important; background: @red !important; @@ -512,14 +575,17 @@ body, html { background: @redHover !important; } } + &_big { font-size: 18px; } + &_hidden { display: none; } } } + &-full-height { & { height: 100%; @@ -556,6 +622,7 @@ body, html { &_max { min-width: 356px; } + &_invert { background: @blue; color: white; @@ -568,6 +635,7 @@ body, html { background: @blueActive; } } + &_whatsapp { background: @green; color: white; @@ -577,37 +645,54 @@ body, html { background: @greenHover; } } + &_submit { min-width: 218px; } + &_warning { min-width: 218px; background: @yellow; + &:hover { background: @yellowActive; } } } + .toggle-box { display: none; } + &-table { width: 100%; border: none; border-radius: 20px; + + &.hidden { + display: none; + } + thead { th { background: rgba(122, 122, 122, 0.15); font-size: 16px; } } + tbody { tr { + &.alert, + &.alert td{ + line-height: 120px; + font-size: 16px; + } td { border-bottom: 1px solid #ccc; } } } + td, th { color: #333; font-size: 14px; @@ -615,34 +700,45 @@ body, html { padding: 4px 6px; max-width: 300px; vertical-align: middle; + } + &-wrapper { width: 100%; max-height: 500px; overflow-y: scroll; overflow-x: hidden; } + &__row { &-bold { font-weight: bold; } } + &-no-wrap { white-space: nowrap; } + &-center { - text-align: center; + &, & th { + text-align: center; + } } + &-right { text-align: right; } + &-sort { &__btn, &__switch { cursor: pointer; + &:hover { color: #005add; } } + &__btn { float: left; clear: both; @@ -652,26 +748,32 @@ body, html { padding-right: 10px; opacity: 0; transition: opacity 0.2s ease-out; + &-wrap { position: absolute; } } + &__asc { //padding-bottom: 0; } + &__desc { //padding-top: 0; } + & thead th:hover &__btn, & thead td:hover &__btn { opacity: 1; } } } + &-collapsible { &__input { display: none; } - label&__title { + + &__title, label&__title { cursor: pointer; font-weight: normal; text-align: center; @@ -679,21 +781,24 @@ body, html { position: relative; line-height: 1; width: 100%; + &:before { content: '\25B6'; opacity: 0; transition: opacity 0.2s ease-out; } + &:hover:before { opacity: 1; } } + &__content { text-align: left; font-size: 12px; line-height: 1.5; background: #fff; - border: 1px solid rgba(122,122,122,0.15); + border: 1px solid rgba(122, 122, 122, 0.15); position: absolute; z-index: 5; top: 20px; @@ -708,28 +813,34 @@ body, html { transition-property: max-height, visibility; visibility: hidden; } + &__input:checked + &__title &__content { max-height: 100vh; visibility: visible; } } + &-error-msg { &, &:after, &:before { color: #dd2e44; } } + &-alert { position: relative; height: 60px; padding: 0 50px; line-height: 30px; + &-text { font-size: 1.5em; } + &-note { color: @gray; font-size: 1.2em; } + &:before { display: block; position: absolute; @@ -738,29 +849,37 @@ body, html { padding: 10px 5px; font: normal normal normal 40px/1 FontAwesome; } + &-success:before { content: "\F058"; color: @green; } + &-warning:before { content: "\F06A"; color: @yellow; } + &-danger:before { content: "\F071"; color: @red; } + &-info:before { content: "\F059"; color: @blue; } } + &-btn-svg { width: 15px; + height: 15px; + display: inline-block; cursor: pointer; //transition: transform .3s ease-out; &_wrapper { cursor: pointer; + &:hover { //transform: scale(1.1); fill: @gray; diff --git a/retailcrm/views/css/retailcrm-export.min.css b/retailcrm/views/css/retailcrm-export.min.css index 09d255f..d2d0722 100644 --- a/retailcrm/views/css/retailcrm-export.min.css +++ b/retailcrm/views/css/retailcrm-export.min.css @@ -1 +1 @@ -.retail-circle{float:left;width:50%;text-align:center;padding:20px;margin:20px 0}.retail-circle__title{font-size:18px;margin-bottom:20px}.retail-circle__content,input.retail-circle__content{width:120px;height:120px;border-radius:120px;text-align:center;font-size:20px;line-height:60px}.retail-progress{border-radius:60px;border:1px solid rgba(122,122,122,0.15);width:100%;height:60px;overflow:hidden;transition:height .25s ease}.retail-progress__loader{width:0;border-radius:60px;background:#0068FF;color:white;text-align:center;padding:0 30px;font-size:18px;font-weight:600;transition:width .4s ease-in;line-height:60px}.retail-hidden{visibility:hidden;height:0!important} \ No newline at end of file +.retail-circle{float:left;width:50%;text-align:center;padding:20px;margin:20px 0}.retail-circle__title{font-size:18px;margin-bottom:20px}.retail input.retail-circle__content,.retail input[readonly][type=text] .retail-circle__content,.retail input[type=text] .retail-circle__content,.retail-circle__content{width:120px;height:120px;border-radius:120px;text-align:center;font-size:20px;line-height:60px;display:inline-block}.retail-progress{border-radius:60px;border:1px solid rgba(122,122,122,.15);width:100%;height:60px;overflow:hidden;transition:height .25s ease}.retail-progress__loader{width:0;border-radius:60px;background:#0068FF;color:#fff;text-align:center;padding:0 30px;font-size:18px;font-weight:600;transition:width .4s ease-in;line-height:60px}.retail-hidden{visibility:hidden;height:0!important}/*# sourceMappingURL=retailcrm-export.min.css.map */ \ No newline at end of file diff --git a/retailcrm/views/css/retailcrm-orders.min.css b/retailcrm/views/css/retailcrm-orders.min.css new file mode 100644 index 0000000..b75776e --- /dev/null +++ b/retailcrm/views/css/retailcrm-orders.min.css @@ -0,0 +1 @@ +#retail-search-orders-form .retail-form__area{width:30%!important}#retail-search-orders-form #search-orders-submit{width:15%}#retail-search-orders-form .retail-row__content{width:100%}#retail-search-orders-form .retail-table-filter{display:inline-block;vertical-align:top;background:rgba(122,122,122,.1);border-radius:58px;height:60px;line-height:60px;padding:0;font-size:18px;font-weight:600;text-align:center;color:#0068FF;text-decoration:none;cursor:pointer;appearance:none;border:none;box-shadow:none;transition:.25s ease;width:45%;margin-left:9%}#retail-search-orders-form .retail-table-filter label.retail-table-filter-btn{width:33.333333%;height:60px;margin:0;padding:0;display:block;float:left;text-align:center;font-size:16px;text-shadow:none;cursor:pointer;transition-property:color,background-color;transition-duration:.3s}#retail-search-orders-form .retail-table-filter label.retail-table-filter-btn.active,#retail-search-orders-form .retail-table-filter label.retail-table-filter-btn:hover{color:#fff}#retail-search-orders-form .retail-table-filter label.retail-table-filter-btn.active{background:#0068FF}#retail-search-orders-form .retail-table-filter label.retail-table-filter-btn:hover:not(.active){color:#fff;background:#005add!important}#retail-search-orders-form .retail-table-filter label.retail-table-filter-btn:first-child{border-right:1px solid gray;border-bottom-left-radius:58px;border-top-left-radius:58px}#retail-search-orders-form .retail-table-filter label.retail-table-filter-btn:last-child{border-left:1px solid gray;border-bottom-right-radius:58px;border-top-right-radius:58px}#retail-search-orders-form input.search-orders-filter{display:none}.retail-controller-link{display:none}.retail-table-pagination__item{display:inline-flex;align-items:center;justify-content:center;vertical-align:top;min-width:40px;height:40px;background:rgba(122,122,122,.1);font-weight:700;font-size:16px;color:#363A41;text-decoration:none;border:0;border-radius:5px;text-align:center;transition:.25s ease;padding:10px;margin:10px}.retail-table-pagination__item.active,.retail-table-pagination__item:hover{color:#fff}.retail-table-pagination__item.active{background:#0068FF}.retail-table-pagination__item:hover{background:#005add}.retail-table-pagination__item--divider{background:0 0;pointer-events:none}#retail-orders-table .retail-orders-table__status:not(.error) .retail-orders-table__status--error{display:none}#retail-orders-table .retail-orders-table__status.error .retail-orders-table__status--success{display:none}#retail-orders-table .retail-orders-table__upload{cursor:pointer}#retail-orders-table .retail-orders-table__upload:hover{color:#0068ff;fill:#0068ff}.retail-row--foldable{border-radius:8px;margin:20px 0;padding:0 3%;transition:.25s ease;box-shadow:0 2px 4px rgba(30,34,72,.16);border:2px solid #fff;-webkit-box-shadow:0 2px 4px rgba(30,34,72,.16)}.retail-row--foldable.active,.retail-row--foldable:hover{box-shadow:0 8px 16px rgba(30,34,72,.16)}.retail-row--foldable.active{border-color:#005eeb}.retail-row--foldable.active .retail-row__title{cursor:initial}.retail-row--foldable.active .retail-row__content{display:block;height:auto;padding-bottom:40px}.retail-row--foldable .retail-row__content,.retail-row--foldable .retail-row__title{margin:0!important}.retail-row--foldable .retail-row__title{padding:22px 0;cursor:pointer}.retail-row--foldable .retail-row__content{display:none;height:0;overflow:hidden;padding:0;transition:.25s ease}/*# sourceMappingURL=retailcrm-orders.min.css.map */ \ No newline at end of file diff --git a/retailcrm/views/css/styles.min.css b/retailcrm/views/css/styles.min.css index c256d80..5254f0d 100644 --- a/retailcrm/views/css/styles.min.css +++ b/retailcrm/views/css/styles.min.css @@ -1 +1 @@ -@font-face{font-family:'OpenSans';src:url('../fonts/OpenSans/opensans-regular.eot');src:url('../fonts/OpenSans/opensans-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/OpenSans/opensans-regular.woff2') format('woff2'),url('../fonts/OpenSans/opensans-regular.woff') format('woff'),url('../fonts/OpenSans/opensans-regular.ttf') format('truetype'),url('../fonts/OpenSans/opensans-regular.svg#open_sansregular') format('svg');font-weight:normal;font-style:normal}@font-face{font-family:'OpenSans';src:url('../fonts/OpenSansBold/opensans-bold.eot');src:url('../fonts/OpenSansBold/opensans-bold.eot?#iefix') format('embedded-opentype'),url('../fonts/OpenSansBold/opensans-bold.woff2') format('woff2'),url('../fonts/OpenSansBold/opensans-bold.woff') format('woff'),url('../fonts/OpenSansBold/opensans-bold.ttf') format('truetype'),url('../fonts/OpenSansBold/opensans-bold.svg#open_sansbold') format('svg');font-weight:600;font-style:normal}body,html{margin:0;padding:0;height:100%}.hidden{visibility:hidden}.retail-wrap{font-family:OpenSans,Arial,sans-serif;padding:0 15px;height:100%}.retail-wrap *,.retail-wrap *::before,.retail-wrap *::after{box-sizing:border-box}.retail-container{margin:0 auto;width:100%;max-width:950px}.retail-title{margin:60px 0 0;font-weight:400;text-align:center;font-size:28px;line-height:38px}.retail-title_content{text-align:left;margin-top:40px}.retail-txt{color:#7A7A7A;font-size:18px;line-height:26px}.retail-descript{margin-top:45px;text-align:center}.retail-tab__enabled{display:block}.retail-tab__disabled{display:none !important}.retail-video{margin:30px auto 0;text-align:center;position:relative}.retail-video-trigger{position:absolute;top:0;bottom:0;right:0;left:0;width:100%;height:100%;cursor:pointer}.retail-video iframe{pointer-events:none}.retail-video__btn{position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;width:100px;height:100px;cursor:pointer;opacity:.4;transition:.25s ease}.retail-video__btn svg{width:100%}.retail-video__btn:hover{opacity:.6}.retail-btns{margin:56px auto 0;display:flex;justify-content:space-between;max-width:815px;transition:.05s ease}.retail-btns__separate{padding:0 20px;display:flex;align-items:center;color:#7A7A7A;font-size:16px}.retail-btns_hide{opacity:0}.retail-form{margin-top:60px}.retail-form__title{font-size:16px;font-weight:600;line-height:24px;margin-bottom:22px}.retail-form__title_link{color:#0068FF;transition:.25s ease;float:right}.retail-form__title_link:hover{color:#005add}.retail-form__label{width:100% !important;text-align:left !important;margin:15px 12px;font-size:15px}.retail-form__row{margin-top:15px}.retail-form__row_submit{margin-top:23px}.retail-form__message-warning{padding:13px 18px;margin:1px 13px;border-radius:8px;border:1px solid #fcf3b5;font-size:1rem;box-shadow:0 0 6px 0 #fdd0d0}.retail-form__checkbox{display:flex;flex-direction:row;align-items:center;padding:4px 12px}.retail-form__checkbox input[type=checkbox]{width:24px;height:24px}.retail-form__checkbox label{width:auto;margin-left:8px;font-size:16px}.retail-form__area{display:inline-block !important;vertical-align:top;width:430px !important;height:60px !important;border:1px solid rgba(122,122,122,0.15) !important;box-shadow:none !important;border-radius:58px !important;padding:0 28px !important;line-height:normal;color:#7A7A7A !important;font-size:16px !important;appearance:none}.retail-form__area:focus{color:#363A41}.retail-form__area:focus::-webkit-input-placeholder{color:#363A41}.retail-form__area:focus::-moz-placeholder{color:#363A41}.retail-form__area:focus:-moz-placeholder{color:#363A41}.retail-form__area:focus:-ms-input-placeholder{color:#363A41}.retail-form__area_txt{padding:20px 28px !important;line-height:24px !important;height:487px !important;border-radius:20px !important;resize:none !important;font-family:OpenSans,Arial,sans-serif !important}.retail-form input:focus,.retail-form textarea:focus{outline:none !important}.retail-form_main{margin-top:34px;max-width:900px;width:100%}.retail-form_main .retail-form__area{width:100% !important}.retail-tabs{margin-top:60px}.retail-tabs__btn{display:inline-block;vertical-align:top;padding:19px 30px;font-size:16px;font-weight:600;line-height:22px;color:#7A7A7A;text-align:center;min-width:152px;text-decoration:none !important;position:relative;transition:.25s ease}.retail-tabs__btn:hover{color:#363A41}.retail-tabs__btn::after{content:"";height:3px;width:100%;position:absolute;bottom:-1px;left:0;right:0;opacity:0;visibility:hidden;background:#0068FF;transition:.25s ease}.retail-tabs__btn_active{color:#363A41}.retail-tabs__btn_active::after{opacity:1;visibility:visible}.retail-tabs__head{display:flex;justify-content:space-between;border-bottom:1px solid #DFDFDF}.retail-tabs__body{padding-top:18px}.retail-tabs__body p{margin-top:23px;margin-bottom:0;color:#7A7A7A;font-size:16px;line-height:24px}.retail-tabs__item{display:none}.retail-list{margin:0;padding:0;list-style:none}.retail-list__item{padding-left:2px;position:relative;color:#7A7A7A;font-size:16px;line-height:24px}.retail-list__item::before{content:"-";display:inline-block;vertical-align:top;color:#7A7A7A;font-size:16px;line-height:24px;margin-right:3px}.retail-tile{display:flex;flex-wrap:wrap}.retail-tile__col{width:48%;padding-right:35px}.retail-tile__col:nth-child(1){width:52%}.retail-tile__col_contacts{padding-right:0}.retail-tile__row{display:flex;justify-content:center;margin-bottom:30px}.retail-tile__row:nth-last-child(1){margin-bottom:0}.retail-tile__item{margin-top:34px}.retail-tile__item:nth-child(1){margin-top:20px}.retail-tile__title{color:#363A41;font-size:16px;font-weight:600;line-height:24px}.retail-tile__descript{color:#7A7A7A;font-size:16px;line-height:24px;margin-top:10px}.retail-tile__link{color:#0068FF;font-size:16px;font-weight:600;line-height:24px;transition:.25s ease}.retail-tile__link:hover{color:#005add}.retail-popup{position:absolute;width:90%;height:90%;background:white;left:0;right:0;top:0;bottom:0;margin:auto;transform:translate3d(0, -1000%, 0) scale(.1);transition:.25s ease}.retail-popup__close{position:absolute;top:-30px;right:-30px;width:30px;height:30px;cursor:pointer}.retail-popup__close::before,.retail-popup__close::after{content:"";position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;height:30px;width:2px;background:white}.retail-popup__close::before{transform:rotate(45deg)}.retail-popup__close::after{transform:rotate(-45deg)}.retail-popup.open{transform:translate3d(0, 0, 0) scale(1)}.retail-popup-wrap{position:fixed;left:0;right:0;top:0;bottom:0;background:rgba(0,0,0,0.6);z-index:1000;display:none}.retail-column{display:flex;max-width:1389px;height:100%}.retail-column__aside{width:253px;background:#EAEBEC;min-height:300px}.retail-column__content{flex:1 0 auto;padding:0 58px;min-height:300px}.retail-menu{padding:8px 20px 8px 15px}.retail-menu__btn{display:inline-flex;align-items:center;justify-content:center;vertical-align:top;width:100%;height:60px;background:rgba(122,122,122,0.1) !important;font-weight:bold;font-size:16px;color:#363A41 !important;text-decoration:none !important;padding:0 30px;margin-top:20px;border-radius:5px;text-align:center;transition:.25s ease}.retail-menu__btn span{display:block}.retail-menu__btn:hover{background:rgba(122,122,122,0.15) !important}.retail-menu__btn:nth-child(1){margin-top:0}.retail-menu__btn_active{color:white !important;background:#0068FF !important}.retail-menu__btn_active:hover{background:#005add !important}.retail-menu__btn_active.retail-menu__btn_error{background:#da4932 !important}.retail-menu__btn_error{color:white !important;background:#ff553b !important}.retail-menu__btn_error:hover{background:#da4932 !important}.retail-menu__btn_big{font-size:18px}.retail-menu__btn_hidden{display:none}.retail-full-height{height:100%}.retail .btn{display:inline-block;vertical-align:top;background:rgba(122,122,122,0.1);border-radius:58px;height:60px;line-height:60px;padding:0 30px;font-size:18px;font-weight:600;text-align:center;color:#0068FF;text-decoration:none;cursor:pointer;appearance:none;border:none;box-shadow:none;transition:.25s ease}.retail .btn:hover{background:rgba(122,122,122,0.15)}.retail .btn:active{background:rgba(122,122,122,0.25)}.retail .btn_max{min-width:356px}.retail .btn_invert{background:#0068FF;color:white}.retail .btn_invert:hover{background:#005add}.retail .btn_invert:active{background:#0045aa}.retail .btn_whatsapp{background:#33D16B;color:white;padding:0 62px}.retail .btn_whatsapp:hover{background:#22CA5D}.retail .btn_submit{min-width:218px}.retail .btn_warning{min-width:218px;background:#fcc94f}.retail .btn_warning:hover{background:#edbe4c}.retail .toggle-box{display:none}.retail-table{width:100%;border:none;border-radius:20px}.retail-table thead th{background:rgba(122,122,122,0.15);font-size:16px}.retail-table tbody tr td{border-bottom:1px solid #ccc}.retail-table td,.retail-table th{color:#333;font-size:14px;line-height:40px;padding:4px 6px;max-width:300px;vertical-align:middle}.retail-table-wrapper{width:100%;max-height:500px;overflow-y:scroll;overflow-x:hidden}.retail-table__row-bold{font-weight:bold}.retail-table-no-wrap{white-space:nowrap}.retail-table-center{text-align:center}.retail-table-right{text-align:right}.retail-table-sort__btn,.retail-table-sort__switch{cursor:pointer}.retail-table-sort__btn:hover,.retail-table-sort__switch:hover{color:#005add}.retail-table-sort__btn{float:left;clear:both;line-height:20px;font-size:20px;padding-left:10px;padding-right:10px;opacity:0;transition:opacity .2s ease-out}.retail-table-sort__btn-wrap{position:absolute}.retail-table-sort thead th:hover .retail-table-sort__btn,.retail-table-sort thead td:hover .retail-table-sort__btn{opacity:1}.retail-collapsible__input{display:none}label.retail-collapsible__title{cursor:pointer;font-weight:normal;text-align:center;padding:0;position:relative;line-height:1;width:100%}label.retail-collapsible__title:before{content:'\25B6';opacity:0;transition:opacity .2s ease-out}label.retail-collapsible__title:hover:before{opacity:1}.retail-collapsible__content{text-align:left;font-size:12px;line-height:1.5;background:#fff;border:1px solid rgba(122,122,122,0.15);position:absolute;z-index:5;top:20px;left:0;padding:18px;margin:0;border-radius:20px;overflow:hidden;max-height:0;transition-duration:.2s;transition-timing-function:ease-out;transition-property:max-height,visibility;visibility:hidden}.retail-collapsible__input:checked+.retail-collapsible__title .retail-collapsible__content{max-height:100vh;visibility:visible}.retail-error-msg,.retail-error-msg:after,.retail-error-msg:before{color:#dd2e44}.retail-alert{position:relative;height:60px;padding:0 50px;line-height:30px}.retail-alert-text{font-size:1.5em}.retail-alert-note{color:#7A7A7A;font-size:1.2em}.retail-alert:before{display:block;position:absolute;left:0;top:0;padding:10px 5px;font:normal normal normal 40px/1 FontAwesome}.retail-alert-success:before{content:"\F058";color:#33D16B}.retail-alert-warning:before{content:"\F06A";color:#fcc94f}.retail-alert-danger:before{content:"\F071";color:#ff553b}.retail-alert-info:before{content:"\F059";color:#0068FF}.retail-btn-svg{width:15px;cursor:pointer}.retail-btn-svg_wrapper{cursor:pointer}.retail-btn-svg_wrapper:hover{fill:#7A7A7A;color:#7A7A7A} \ No newline at end of file +@font-face{font-family:OpenSans;src:url(../fonts/OpenSans/opensans-regular.eot);src:url(../fonts/OpenSans/opensans-regular.eot?#iefix) format('embedded-opentype'),url(../fonts/OpenSans/opensans-regular.woff2) format('woff2'),url(../fonts/OpenSans/opensans-regular.woff) format('woff'),url(../fonts/OpenSans/opensans-regular.ttf) format('truetype'),url(../fonts/OpenSans/opensans-regular.svg#open_sansregular) format('svg');font-weight:400;font-style:normal}@font-face{font-family:OpenSans;src:url(../fonts/OpenSansBold/opensans-bold.eot);src:url(../fonts/OpenSansBold/opensans-bold.eot?#iefix) format('embedded-opentype'),url(../fonts/OpenSansBold/opensans-bold.woff2) format('woff2'),url(../fonts/OpenSansBold/opensans-bold.woff) format('woff'),url(../fonts/OpenSansBold/opensans-bold.ttf) format('truetype'),url(../fonts/OpenSansBold/opensans-bold.svg#open_sansbold) format('svg');font-weight:600;font-style:normal}body,html{margin:0;padding:0;height:100%}.hidden{visibility:hidden}.icon-RetailcrmSettings:before{content:"\f07a"}.retail-wrap{font-family:OpenSans,Arial,sans-serif;padding:0 15px;height:100%;background:#fff}.retail-wrap *,.retail-wrap ::after,.retail-wrap ::before{box-sizing:border-box}.retail input[readonly][type=text],.retail input[type=file],.retail input[type=password],.retail input[type=text],.retail textarea{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.1) inset;box-shadow:inset 0 1px 2px rgba(0,0,0,.1);background-color:#fff;border:1px solid #ccc;padding:2px 4px}.retail-container{margin:0 auto;width:100%;max-width:950px}.retail-title{margin:60px 0 0;font-weight:400;text-align:center;font-size:28px;line-height:38px}.retail-title_content{text-align:left;margin-top:40px}.retail-txt{color:#7A7A7A;font-size:18px;line-height:26px}.retail-descript{margin-top:45px;text-align:center}.retail-tab__enabled{display:block}.retail-tab__disabled{display:none!important}.retail-video{margin:30px auto 0;text-align:center;position:relative}.retail-video-trigger{position:absolute;top:0;bottom:0;right:0;left:0;width:100%;height:100%;cursor:pointer}.retail-video iframe{pointer-events:none}.retail-video__btn{position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;width:100px;height:100px;cursor:pointer;opacity:.4;transition:.25s ease}.retail-video__btn svg{width:100%}.retail-video__btn:hover{opacity:.6}.retail-btns{margin:56px auto 0;display:flex;justify-content:space-between;max-width:815px;transition:50ms ease}.retail-btns__separate{padding:0 20px;display:flex;align-items:center;color:#7A7A7A;font-size:16px}.retail-btns_hide{opacity:0}.retail-form{margin-top:60px}.retail-form__title{font-size:16px;font-weight:600;line-height:24px;margin-bottom:22px}.retail-form__title_link{color:#0068FF;transition:.25s ease;float:right}.retail-form__title_link:hover{color:#005add}.retail-form__label{width:100%!important;text-align:left!important;margin:15px 12px;font-size:15px}.retail-form__row{margin-top:15px}.retail-form__row_submit{margin-top:23px}.retail-form__message-warning{padding:13px 18px;margin:1px 13px;border-radius:8px;border:1px solid #fcf3b5;font-size:1rem;box-shadow:0 0 6px 0 #fdd0d0}.retail-form__checkbox{display:flex;flex-direction:row;align-items:center;padding:4px 12px}.retail-form__checkbox input[type=checkbox]{width:24px;height:24px}.retail-form__checkbox label{width:auto;margin-left:8px;font-size:16px}.retail-form__area{display:inline-block!important;vertical-align:top;width:430px!important;height:60px!important;border:1px solid rgba(122,122,122,.15)!important;box-shadow:none!important;border-radius:58px!important;padding:0 28px!important;line-height:normal;color:#7A7A7A!important;background-color:#fff!important;font-size:16px!important;appearance:none}.retail-form__area:focus{color:#363A41}.retail-form__area:focus::-webkit-input-placeholder{color:#363A41}.retail-form__area:focus::-moz-placeholder{color:#363A41}.retail-form__area:focus:-moz-placeholder{color:#363A41}.retail-form__area:focus:-ms-input-placeholder{color:#363A41}.retail-form__area_txt{padding:20px 28px!important;line-height:24px!important;height:487px!important;border-radius:20px!important;resize:none!important;font-family:OpenSans,Arial,sans-serif!important}.retail-form input:focus,.retail-form textarea:focus{outline:0!important}.retail-form_main{margin-top:34px;max-width:900px;width:100%}.retail-form_main .retail-form__area{width:100%!important}.retail-tabs{margin-top:60px}.retail-tabs__btn{display:inline-block;vertical-align:top;padding:19px 30px;font-size:16px;font-weight:600;line-height:22px;color:#7A7A7A;text-align:center;min-width:152px;text-decoration:none!important;position:relative;transition:.25s ease}.retail-tabs__btn:hover{color:#363A41}.retail-tabs__btn::after{content:"";height:3px;width:100%;position:absolute;bottom:-1px;left:0;right:0;opacity:0;visibility:hidden;background:#0068FF;transition:.25s ease}.retail-tabs__btn_active{color:#363A41}.retail-tabs__btn_active::after{opacity:1;visibility:visible}.retail-tabs__head{display:flex;justify-content:space-between;border-bottom:1px solid #DFDFDF}.retail-tabs__body{padding-top:18px}.retail-tabs__body p{margin-top:23px;margin-bottom:0;color:#7A7A7A;font-size:16px;line-height:24px}.retail-tabs__item{display:none}.retail-list{margin:0;padding:0;list-style:none}.retail-list__item{padding-left:2px;position:relative;color:#7A7A7A;font-size:16px;line-height:24px}.retail-list__item::before{content:"-";display:inline-block;vertical-align:top;color:#7A7A7A;font-size:16px;line-height:24px;margin-right:3px}.retail-tile{display:flex;flex-wrap:wrap}.retail-tile__col{width:48%;padding-right:35px}.retail-tile__col:nth-child(1){width:52%}.retail-tile__col_contacts{padding-right:0}.retail-tile__row{display:flex;justify-content:center;margin-bottom:30px}.retail-tile__row:nth-last-child(1){margin-bottom:0}.retail-tile__item{margin-top:34px}.retail-tile__item:nth-child(1){margin-top:20px}.retail-tile__title{color:#363A41;font-size:16px;font-weight:600;line-height:24px}.retail-tile__descript{color:#7A7A7A;font-size:16px;line-height:24px;margin-top:10px}.retail-tile__link{color:#0068FF;font-size:16px;font-weight:600;line-height:24px;transition:.25s ease}.retail-tile__link:hover{color:#005add}.retail-popup{position:absolute;width:90%;height:90%;background:#fff;left:0;right:0;top:0;bottom:0;margin:auto;transform:translate3d(0,-1000%,0) scale(.1);transition:.25s ease}.retail-popup__close{position:absolute;top:-30px;right:-30px;width:30px;height:30px;cursor:pointer}.retail-popup__close::after,.retail-popup__close::before{content:"";position:absolute;left:0;right:0;top:0;bottom:0;margin:auto;height:30px;width:2px;background:#fff}.retail-popup__close::before{transform:rotate(45deg)}.retail-popup__close::after{transform:rotate(-45deg)}.retail-popup.open{transform:translate3d(0,0,0) scale(1)}.retail-popup-wrap{position:fixed;left:0;right:0;top:0;bottom:0;background:rgba(0,0,0,.6);z-index:1000;display:none}.retail-column{display:flex;max-width:1389px;height:100%}.retail-column__aside{width:253px;background:#EAEBEC;min-height:300px}#content.bootstrap .retail-column__aside{margin:10px 0}.retail-column__content{flex:1 0 auto;padding:0 58px;min-height:300px}.retail-menu{padding:8px 20px 8px 15px}.retail-menu__btn{display:inline-flex;align-items:center;justify-content:center;vertical-align:top;width:100%;height:60px;background:rgba(122,122,122,.1)!important;font-weight:700;font-size:16px;color:#363A41!important;text-decoration:none!important;padding:0 30px;margin-top:20px;border-radius:5px;text-align:center;transition:.25s ease}.retail-menu__btn span{display:block}.retail-menu__btn:hover{background:rgba(122,122,122,.15)!important}.retail-menu__btn:nth-child(1){margin-top:0}.retail-menu__btn_active{color:#fff!important;background:#0068FF!important}.retail-menu__btn_active:hover{background:#005add!important}.retail-menu__btn_active.retail-menu__btn_error{background:#da4932!important}.retail-menu__btn_error{color:#fff!important;background:#ff553b!important}.retail-menu__btn_error:hover{background:#da4932!important}.retail-menu__btn_big{font-size:18px}.retail-menu__btn_hidden{display:none}.retail-full-height{height:100%}.retail .btn{display:inline-block;vertical-align:top;background:rgba(122,122,122,.1);border-radius:58px;height:60px;line-height:60px;padding:0 30px;font-size:18px;font-weight:600;text-align:center;color:#0068FF;text-decoration:none;cursor:pointer;appearance:none;border:none;box-shadow:none;transition:.25s ease}.retail .btn:hover{background:rgba(122,122,122,.15)}.retail .btn:active{background:rgba(122,122,122,.25)}.retail .btn_max{min-width:356px}.retail .btn_invert{background:#0068FF;color:#fff}.retail .btn_invert:hover{background:#005add}.retail .btn_invert:active{background:#0045aa}.retail .btn_whatsapp{background:#33D16B;color:#fff;padding:0 62px}.retail .btn_whatsapp:hover{background:#22CA5D}.retail .btn_submit{min-width:218px}.retail .btn_warning{min-width:218px;background:#fcc94f}.retail .btn_warning:hover{background:#edbe4c}.retail .toggle-box{display:none}.retail-table{width:100%;border:none;border-radius:20px}.retail-table.hidden{display:none}.retail-table thead th{background:rgba(122,122,122,.15);font-size:16px}.retail-table tbody tr.alert,.retail-table tbody tr.alert td{line-height:120px;font-size:16px}.retail-table tbody tr td{border-bottom:1px solid #ccc}.retail-table td,.retail-table th{color:#333;font-size:14px;line-height:40px;padding:4px 6px;max-width:300px;vertical-align:middle}.retail-table-wrapper{width:100%;max-height:500px;overflow-y:scroll;overflow-x:hidden}.retail-table__row-bold{font-weight:700}.retail-table-no-wrap{white-space:nowrap}.retail-table-center,.retail-table-center th{text-align:center}.retail-table-right{text-align:right}.retail-table-sort__btn,.retail-table-sort__switch{cursor:pointer}.retail-table-sort__btn:hover,.retail-table-sort__switch:hover{color:#005add}.retail-table-sort__btn{float:left;clear:both;line-height:20px;font-size:20px;padding-left:10px;padding-right:10px;opacity:0;transition:opacity .2s ease-out}.retail-table-sort__btn-wrap{position:absolute}.retail-table-sort thead td:hover .retail-table-sort__btn,.retail-table-sort thead th:hover .retail-table-sort__btn{opacity:1}.retail-collapsible__input{display:none}.retail-collapsible__title,label.retail-collapsible__title{cursor:pointer;font-weight:400;text-align:center;padding:0;position:relative;line-height:1;width:100%}.retail-collapsible__title:before,label.retail-collapsible__title:before{content:'\25B6';opacity:0;transition:opacity .2s ease-out}.retail-collapsible__title:hover:before,label.retail-collapsible__title:hover:before{opacity:1}.retail-collapsible__content{text-align:left;font-size:12px;line-height:1.5;background:#fff;border:1px solid rgba(122,122,122,.15);position:absolute;z-index:5;top:20px;left:0;padding:18px;margin:0;border-radius:20px;overflow:hidden;max-height:0;transition-duration:.2s;transition-timing-function:ease-out;transition-property:max-height,visibility;visibility:hidden}.retail-collapsible__input:checked+.retail-collapsible__title .retail-collapsible__content{max-height:100vh;visibility:visible}.retail-error-msg,.retail-error-msg:after,.retail-error-msg:before{color:#dd2e44}.retail-alert{position:relative;height:60px;padding:0 50px;line-height:30px}.retail-alert-text{font-size:1.5em}.retail-alert-note{color:#7A7A7A;font-size:1.2em}.retail-alert:before{display:block;position:absolute;left:0;top:0;padding:10px 5px;font:normal normal normal 40px/1 FontAwesome}.retail-alert-success:before{content:"\F058";color:#33D16B}.retail-alert-warning:before{content:"\F06A";color:#fcc94f}.retail-alert-danger:before{content:"\F071";color:#ff553b}.retail-alert-info:before{content:"\F059";color:#0068FF}.retail-btn-svg{width:15px;height:15px;display:inline-block;cursor:pointer}.retail-btn-svg_wrapper{cursor:pointer}.retail-btn-svg_wrapper:hover{fill:#7A7A7A;color:#7A7A7A}/*# sourceMappingURL=styles.min.css.map */ \ No newline at end of file diff --git a/retailcrm/views/fonts/OpenSans/index.php b/retailcrm/views/fonts/OpenSans/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/fonts/OpenSans/index.php +++ b/retailcrm/views/fonts/OpenSans/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/views/fonts/OpenSansBold/index.php b/retailcrm/views/fonts/OpenSansBold/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/fonts/OpenSansBold/index.php +++ b/retailcrm/views/fonts/OpenSansBold/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/views/fonts/index.php b/retailcrm/views/fonts/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/fonts/index.php +++ b/retailcrm/views/fonts/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/views/img/index.php b/retailcrm/views/img/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/img/index.php +++ b/retailcrm/views/img/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/views/index.php b/retailcrm/views/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/index.php +++ b/retailcrm/views/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/views/js/index.php b/retailcrm/views/js/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/js/index.php +++ b/retailcrm/views/js/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/retailcrm/views/js/retailcrm-orders.js b/retailcrm/views/js/retailcrm-orders.js new file mode 100644 index 0000000..70f8afb --- /dev/null +++ b/retailcrm/views/js/retailcrm-orders.js @@ -0,0 +1,360 @@ +/** + * 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 + * @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. + */ +$(function () { + function RetailcrmOrdersForm() { + this.form = $('#retail-search-orders-form').get(0); + + if (typeof this.form === 'undefined') { + return false; + } + + this.isInitiated = false; + this.initButton = $('#retail-uploaded-orders-tab .retail-row__title').get(0); + this.initAction = this.initAction.bind(this); + + this.submitButton = $(this.form).find('button[id="search-orders-submit"]').get(0); + this.submitAction = this.submitAction.bind(this); + + this.ordersTable = $('#retail-orders-table').get(0); + this.ordersTableBody = $(this.ordersTable).find('tbody').get(0); + this.rowSample = $(this.ordersTableBody).find('tr').clone(); + this.loadOrders = this.loadOrders.bind(this); + this.searchOrders = this.searchOrders.bind(this); + + this.pagesMenu = $('.retail-table-pagination').get(0); + this.loadPagination = this.loadPagination.bind(this); + + this.uploadLink = $('#retail-controller-orders-upload').attr('href'); + $('#retail-controller-orders-upload').remove(); + this.uploadOrder = this.uploadOrder.bind(this); + + this.partitionId = this.partitionId.bind(this); + this.setLoading = this.setLoading.bind(this); + this.showMessage = this.showMessage.bind(this); + + this.orders = []; + this.filter = null; + this.page = null; + + $(this.submitButton).click(this.submitAction); + $(this.initButton).click(this.initAction); + } + + RetailcrmOrdersForm.prototype.initAction = function (event) { + event.preventDefault(); + + if (!this.isInitiated) { + $(this.ordersTableBody).empty(); + $(this.pagesMenu).empty(); + + $('.retail-table-filter-btn').click(function (e) { + $('.retail-table-filter-btn').removeClass('active'); + $(this).addClass('active'); + }); + + this.searchOrders(); + this.isInitiated = true; + } + } + + RetailcrmOrdersForm.prototype.submitAction = function (event) { + event.preventDefault(); + let formData = $(this.form).serializeArray().reduce(function (obj, item) { + obj[item.name] = item.value; + return obj; + }, {}); + + let idString = formData['search-orders-value']; + this.orders = this.partitionId(idString.toString().replace(/\s+/g, '')); + this.filter = formData['search-orders-filter']; + + this.searchOrders(); + }; + + RetailcrmOrdersForm.prototype.searchOrders = function (page = 1) { + this.setLoading(true); + + let _this = this; + let data = { + orders: this.orders, + filter: this.filter, + page: page + }; + + $.ajax({ + url: this.form.action, + method: this.form.method, + dataType: 'json', + timeout: 0, + data: data + }) + .done(function (response) { + if (response.success !== undefined && response.success === false) { + _this.setLoading(false); + _this.showMessage('orders-table.error'); + console.warn(response); + return; + } + + if (response.orders !== undefined && response.orders.length > 0) { + _this.loadOrders(response.orders); + } else { + _this.showMessage('orders-table.empty'); + } + + if (response.pagination !== undefined) { + _this.loadPagination(response.pagination); + } + + _this.setLoading(false); + }) + .fail(function (response) { + _this.setLoading(false); + _this.showMessage('orders-table.error'); + console.warn(response); + }) + } + RetailcrmOrdersForm.prototype.loadOrders = function (orders) { + $(this.ordersTableBody).empty(); + $(this.ordersTable).removeClass('hidden'); + + let _this = this; + let crmOrderUrlTemplate = $(this.rowSample).find('td.retail-orders-table__id-crm a').attr('href'); + let cmsOrderUrlTemplate = $(this.rowSample).find('td.retail-orders-table__id-cms a').attr('href'); + + $.each(orders, function (key, item) { + let newRow = _this.rowSample.clone().get(0); + $(newRow).find('td.retail-orders-table__date').text(item.last_uploaded) + $(newRow).find('td.retail-orders-table__id-cms a').text(item.id_order) + .attr('href', cmsOrderUrlTemplate + '&vieworder=&id_order=' + item.id_order) + if (item.id_order_crm === null) { + $(newRow).find('td.retail-orders-table__id-crm').empty(); + } else { + $(newRow).find('td.retail-orders-table__id-crm a').text(item.id_order_crm) + .attr('href', crmOrderUrlTemplate + item.id_order_crm + '/edit') + } + + if (item.errors !== null) { + let statusDom = $(newRow).find('td.retail-orders-table__status'); + statusDom.addClass('error'); + + try { + let errors = JSON.parse(item.errors) + + statusDom.find('.retail-orders-table__error').append('
    '); + for (let error in errors) { + statusDom.find('.retail-orders-table__error').append('
  • ' + errors[error] + '
  • '); + } + statusDom.find('.retail-orders-table__error').append('
'); + } catch (e) { + console.log(e); + statusDom.find('.retail-orders-table__error').append(item.errors); + } + + statusDom.find('.retail-collapsible__input').attr('id', 'errors_' + item.id_order) + statusDom.find('.retail-collapsible__title').attr('for', 'errors_' + item.id_order) + } + $(newRow).find('td.retail-orders-table__upload').click(function (e) { + e.preventDefault(); + _this.uploadOrder(item.id_order); + } + ) + + $(_this.ordersTableBody).append(newRow); + }) + } + + RetailcrmOrdersForm.prototype.uploadOrder = function (id_order) { + this.setLoading(true); + let _this = this; + + $.ajax({ + url: this.uploadLink, + method: 'POST', + dataType: 'json', + timeout: 0, + data: { + orders: [id_order] + } + }) + .done(function (response) { + let message = ''; + + if (response.success === undefined || !response.success) { + message = 'Error uploading order: '; + if (response.errorMsg !== undefined) { + message += response.errorMsg; + } + if (response.errors !== undefined) { + for (orderErrors in response.errors) { + for (error in response.errors[orderErrors]) { + message += ' ' + response.errors[orderErrors][error] + ' '; + } + } + } + if (response.skippedOrders !== undefined) { + for (skippedOrder in response.skippedOrders) { + message += 'Order ' + skippedOrder + ' already exists'; + } + } + } else { + message = 'Order successfully uploaded'; + } + + _this.setLoading(false); + alert(message); + }) + .fail(function (response) { + console.warn(response); + _this.setLoading(false); + alert(retailcrmTranslates['orders-table.error']) + }); + } + + RetailcrmOrdersForm.prototype.loadPagination = function (pagination) { + $(this.pagesMenu).empty(); + let _this = this; + this.page = pagination.currentPage; + + let showFirst = false; + let showLast = false; + let pagesToShow = 10; + let pageFrom = 1; + let pageTo = pagination.totalPageCount; + + if (pagination.totalPageCount > pagesToShow) { + pageFrom = pagination.currentPage - (Math.floor(pagesToShow / 2)); + if (pageFrom > 0) { + showFirst = true; + } else { + pageFrom = 1; + } + + pageTo = pagination.currentPage + (Math.floor(pagesToShow / 2)); + if (pageTo < pagination.totalPageCount) { + showLast = true + } else { + pageTo = pagination.totalPageCount; + } + } + + if (showFirst) { + $(this.pagesMenu) + .append($(' - -
{l s='Export orders & customers' mod='retailcrm'}
-
{l s='You can export all the orders and customers from CMS to Simla.com by pressing "Export" button. This process can take a long time, and it\'s required that you keep the tab opened until it\'s done.' mod='retailcrm'}
-
-
-
{l s='Orders' mod='retailcrm'}
- - -
-
-
- {l s='Customers' mod='retailcrm'} -
- - - -
-
-
- -
-
- +
{l s='Daemon Collector' mod='retailcrm'}
@@ -384,6 +345,171 @@
+ +
+
+
+
{l s='Upload orders' mod='retailcrm'}
+
+
{l s='Enter order IDs to upload to Simla.com, divided by a comma. You can also specify ranges, like "1-10". It\'s allowed to upload to 10 orders at a time.' mod='retailcrm'}
+ +
+ + +
+ +
+
+ +
+
+
{l s='You can export all the orders and customers from CMS to Simla.com by pressing "Export" button. This process can take a long time, and it\'s required that you keep the tab opened until it\'s done.' mod='retailcrm'}
+ +
+
+
+
{l s='Orders' mod='retailcrm'}
+ + +
+
+
+ {l s='Customers' mod='retailcrm'} +
+ + + +
+
+
+ +
+
+
+
+
+
+
{l s='Uploaded orders' mod='retailcrm'}
+
+
{l s='In this section you can check the orders export results and manualy upload order to' mod='retailcrm'} {$systemName|escape:'htmlall':'UTF-8'}
+
+
+ + + + +
+ + + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ diff --git a/retailcrm/views/templates/index.php b/retailcrm/views/templates/index.php index 63eec81..4043a55 100644 --- a/retailcrm/views/templates/index.php +++ b/retailcrm/views/templates/index.php @@ -1,4 +1,40 @@ + * @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'); diff --git a/tests/RetailcrmCorporateCustomerBuilderTest.php b/tests/RetailcrmCorporateCustomerBuilderTest.php index 5a4a27d..db0682b 100644 --- a/tests/RetailcrmCorporateCustomerBuilderTest.php +++ b/tests/RetailcrmCorporateCustomerBuilderTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmCorporateCustomerBuilderTest extends RetailcrmTestCase { diff --git a/tests/RetailcrmCustomerAddressBuilderTest.php b/tests/RetailcrmCustomerAddressBuilderTest.php index 838223d..069e84e 100644 --- a/tests/RetailcrmCustomerAddressBuilderTest.php +++ b/tests/RetailcrmCustomerAddressBuilderTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmCustomerAddressBuilderTest extends RetailcrmTestCase { diff --git a/tests/RetailcrmCustomerBuilderTest.php b/tests/RetailcrmCustomerBuilderTest.php index c117021..6397820 100644 --- a/tests/RetailcrmCustomerBuilderTest.php +++ b/tests/RetailcrmCustomerBuilderTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmCustomerBuilderTest extends RetailcrmTestCase { diff --git a/tests/RetailcrmOrderBuilderTest.php b/tests/RetailcrmOrderBuilderTest.php index b5be4e8..9f168a9 100644 --- a/tests/RetailcrmOrderBuilderTest.php +++ b/tests/RetailcrmOrderBuilderTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmOrderBuilderTest extends RetailcrmTestCase { diff --git a/tests/RetailcrmTest.php b/tests/RetailcrmTest.php index 425ce70..7cad122 100644 --- a/tests/RetailcrmTest.php +++ b/tests/RetailcrmTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailCRMTest extends RetailcrmTestCase { @@ -25,29 +61,17 @@ class RetailCRMTest extends RetailcrmTestCase ); } - public function testUploadOrders() + private function mockMethodsForOrderUpload($crmId, $cmsId, $reference) { - Configuration::updateValue(RetailCRM::API_URL, 'https://test.test'); - Configuration::updateValue(RetailCRM::API_KEY, 'test_key'); - - $order = new Order(1); - $reference = $order->reference; - $updReference = 'test'; - - $this->apiClientMock->expects($this->any())->method('ordersGet')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'order' => [], - ]) - )); $this->apiClientMock->expects($this->any())->method('ordersCreate')->willReturn(new RetailcrmApiResponse( 200, json_encode([ 'success' => true, + 'id' => $crmId, 'order' => [ - 'externalId' => 1, - 'number' => $updReference, + 'externalId' => $cmsId, + 'id' => $crmId, + 'number' => $reference, ], ]) )); @@ -55,9 +79,11 @@ class RetailCRMTest extends RetailcrmTestCase 200, json_encode([ 'success' => true, + 'id' => $crmId, 'order' => [ - 'externalId' => 1, - 'number' => $updReference, + 'externalId' => $cmsId, + 'id' => $crmId, + 'number' => $reference, ], ]) )); @@ -82,6 +108,26 @@ class RetailCRMTest extends RetailcrmTestCase 'payment' => [], ]) )); + } + + public function testUploadOrders() + { + Configuration::updateValue(RetailCRM::API_URL, 'https://test.test'); + Configuration::updateValue(RetailCRM::API_KEY, 'test_key'); + + $order = new Order(1); + $reference = $order->reference; + $updReference = 'test'; + + $this->apiClientMock->expects($this->any())->method('ordersGet')->willReturn(new RetailcrmApiResponse( + 200, + json_encode([ + 'success' => true, + 'order' => [], + ]) + )); + + $this->mockMethodsForOrderUpload(1, 1, $updReference); Configuration::updateValue(RetailCRM::ENABLE_ORDER_NUMBER_RECEIVING, false); $this->retailcrmModule->uploadOrders([1]); @@ -161,45 +207,8 @@ class RetailCRMTest extends RetailcrmTestCase ], ]) )); - $this->apiClientMock->expects($this->any())->method('ordersCreate')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'order' => [ - 'number' => $updReference, - ], - ]) - )); - $this->apiClientMock->expects($this->any())->method('ordersEdit')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'order' => [ - 'number' => $updReference, - ], - ]) - )); - $this->apiClientMock->expects($this->any())->method('customersGet')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'customer' => [], - ]) - )); - $this->apiClientMock->expects($this->any())->method('customersCreate')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'customer' => [], - ]) - )); - $this->apiClientMock->expects($this->any())->method('ordersPaymentCreate')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'payment' => [], - ]) - )); + + $this->mockMethodsForOrderUpload(1, 1, $updReference); Configuration::updateValue(RetailCRM::ENABLE_ORDER_NUMBER_RECEIVING, false); @@ -255,47 +264,7 @@ class RetailCRMTest extends RetailcrmTestCase )); } - $this->apiClientMock->expects($this->any())->method('ordersCreate')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'order' => [ - 'externalId' => 1, - 'number' => $updReference, - ], - ]) - )); - $this->apiClientMock->expects($this->any())->method('ordersEdit')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'order' => [ - 'externalId' => 1, - 'number' => $updReference, - ], - ]) - )); - $this->apiClientMock->expects($this->any())->method('customersGet')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'customer' => [], - ]) - )); - $this->apiClientMock->expects($this->any())->method('customersCreate')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'customer' => [], - ]) - )); - $this->apiClientMock->expects($this->any())->method('ordersPaymentCreate')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'payment' => [], - ]) - )); + $this->mockMethodsForOrderUpload(1, 1, $updReference); Configuration::updateValue(RetailCRM::ENABLE_ORDER_NUMBER_RECEIVING, false); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2ba3461..af64aa3 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,40 @@ + * @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. + */ if (file_exists(__DIR__ . '/../../PrestaShop/tests-legacy')) { require_once __DIR__ . '/../../PrestaShop/tests-legacy/bootstrap.php'; diff --git a/tests/helpers/RetailcrmTestCase.php b/tests/helpers/RetailcrmTestCase.php index 49b3fd5..c611e25 100644 --- a/tests/helpers/RetailcrmTestCase.php +++ b/tests/helpers/RetailcrmTestCase.php @@ -1,4 +1,40 @@ + * @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. + */ if (class_exists('LegacyTests\Unit\ContextMocker')) { class_alias('LegacyTests\Unit\ContextMocker', 'Tests\Unit\ContextMocker'); diff --git a/tests/helpers/RetailcrmTestHelper.php b/tests/helpers/RetailcrmTestHelper.php index 17065d1..877ac3d 100644 --- a/tests/helpers/RetailcrmTestHelper.php +++ b/tests/helpers/RetailcrmTestHelper.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmTestHelper { diff --git a/tests/lib/RetailcrmAddressBuilderTest.php b/tests/lib/RetailcrmAddressBuilderTest.php index ddc3991..e530f2a 100644 --- a/tests/lib/RetailcrmAddressBuilderTest.php +++ b/tests/lib/RetailcrmAddressBuilderTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmAddressBuilderTest extends RetailcrmTestCase { diff --git a/tests/lib/RetailcrmCatalogTest.php b/tests/lib/RetailcrmCatalogTest.php index 33fa2a1..6b84137 100644 --- a/tests/lib/RetailcrmCatalogTest.php +++ b/tests/lib/RetailcrmCatalogTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmCatalogTest extends RetailcrmTestCase { diff --git a/tests/lib/RetailcrmHistoryTest.php b/tests/lib/RetailcrmHistoryTest.php index e7a2580..17757e4 100644 --- a/tests/lib/RetailcrmHistoryTest.php +++ b/tests/lib/RetailcrmHistoryTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmHistoryTest extends RetailcrmTestCase { @@ -9,22 +45,18 @@ class RetailcrmHistoryTest extends RetailcrmTestCase { parent::setUp(); - $this->apiMock = $this->getMockBuilder('RetailcrmProxy') - ->disableOriginalConstructor() - ->setMethods( - [ - 'customersHistory', - 'ordersHistory', - 'ordersGet', - 'ordersEdit', - 'customersGet', - 'customersFixExternalIds', - 'ordersFixExternalIds', - 'customersCorporateAddressesEdit', - ] - ) - ->getMock() - ; + $this->apiMock = $this->getApiMock( + [ + 'customersHistory', + 'ordersHistory', + 'ordersGet', + 'ordersEdit', + 'customersGet', + 'customersFixExternalIds', + 'ordersFixExternalIds', + 'customersCorporateAddressesEdit', + ] + ); $catalog = new RetailcrmCatalog(); $data = $catalog->getData(); @@ -38,7 +70,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase public function testCustomersHistory() { - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('customersHistory') ->willReturn( new RetailcrmApiResponse( @@ -50,7 +82,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('customersGet') ->willReturn( new RetailcrmApiResponse( @@ -101,7 +133,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase 'number' => $reference, ]; - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersHistory') ->willReturn( new RetailcrmApiResponse( @@ -113,7 +145,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersGet') ->willReturn( new RetailcrmApiResponse( @@ -127,7 +159,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; - $this->apiMock->expects($this->once()) + $this->apiClientMock->expects($this->once()) ->method('ordersEdit') ->with($checkArgs) ->willReturn( @@ -136,6 +168,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase json_encode( [ 'success' => true, + 'id' => $crmOrder['id'], 'order' => [ 'externalId' => $order->id, 'number' => $updReference, @@ -161,10 +194,75 @@ class RetailcrmHistoryTest extends RetailcrmTestCase $this->assertEquals($updReference, $secondUpdOrder->reference); } - private function orderCreate($apiMock, $orderData) + public function orderCreateDataProvider() { + return [ + [ + 'orderData' => $this->getApiOrder(), ], + [ + 'orderData' => $this->getApiOrderWitchCorporateCustomer(), + ], + ]; + } + + /** + * @dataProvider orderCreateDataProvider + */ + public function testOrderCreate($orderData) + { + $this->apiClientMock->expects($this->any()) + ->method('ordersHistory') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode( + $this->getHistoryDataNewOrder($orderData) + ) + ) + ) + ; + + $this->apiClientMock->expects($this->any()) + ->method('ordersGet') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode( + [ + 'order' => $orderData, + ] + ) + ) + ) + ; + + $this->apiClientMock->expects($this->any()) + ->method('ordersEdit') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode( + $this->getEditedOrder($orderData) + ) + ) + ) + ; + + $this->apiClientMock->expects($this->any()) + ->method('ordersFixExternalIds') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode([ + 'success' => true, + ] + ) + ) + ) + ; + RetailcrmHistory::$default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); - RetailcrmHistory::$api = $apiMock; + RetailcrmHistory::$api = $this->apiMock; $oldLastId = RetailcrmTestHelper::getMaxOrderId(); RetailcrmHistory::ordersHistory(); @@ -238,7 +336,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase public function testOrderSwitchCustomer() { - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersHistory') ->willReturn( new RetailcrmApiResponse( @@ -250,7 +348,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersGet') ->willReturn( new RetailcrmApiResponse( @@ -264,12 +362,24 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; + $this->apiClientMock->expects($this->any()) + ->method('ordersEdit') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode( + $this->getEditedOrder($this->getApiOrder()) + ) + ) + ) + ; + $this->switchCustomer(); } public function testOrderSwitchCorporateCustomer() { - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersHistory') ->willReturn( new RetailcrmApiResponse( @@ -281,7 +391,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersGet') ->willReturn( new RetailcrmApiResponse( @@ -295,104 +405,26 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; + $this->apiClientMock->expects($this->any()) + ->method('ordersEdit') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode( + $this->getEditedOrder($this->getApiOrderWitchCorporateCustomer()) + ) + ) + ) + ; + $this->switchCustomer(); } - public function testOrderCreate() - { - $orderData = $this->getApiOrder(); - - $this->apiMock->expects($this->any()) - ->method('ordersHistory') - ->willReturn( - new RetailcrmApiResponse( - '200', - json_encode( - $this->getHistoryDataNewOrder($orderData) - ) - ) - ) - ; - - $this->apiMock->expects($this->any()) - ->method('ordersGet') - ->willReturn( - new RetailcrmApiResponse( - '200', - json_encode( - [ - 'order' => $orderData, - ] - ) - ) - ) - ; - - $this->apiMock->expects($this->any()) - ->method('ordersEdit') - ->willReturn( - new RetailcrmApiResponse( - '200', - json_encode( - $this->getEditedOrder($orderData) - ) - ) - ) - ; - - $this->orderCreate($this->apiMock, $orderData); - } - - public function testOrderCreateWithCorporateCustomer() - { - $orderData = $this->getApiOrderWitchCorporateCustomer(); - - $this->apiMock->expects($this->any()) - ->method('ordersHistory') - ->willReturn( - new RetailcrmApiResponse( - '200', - json_encode( - $this->getHistoryDataNewOrder($orderData) - ) - ) - ) - ; - - $this->apiMock->expects($this->any()) - ->method('ordersGet') - ->willReturn( - new RetailcrmApiResponse( - '200', - json_encode( - [ - 'order' => $orderData, - ] - ) - ) - ) - ; - - $this->apiMock->expects($this->any()) - ->method('ordersEdit') - ->willReturn( - new RetailcrmApiResponse( - '200', - json_encode( - $this->getEditedOrder($orderData) - ) - ) - ) - ; - - $this->orderCreate($this->apiMock, $orderData); - } - public function testPaymentStatusUpdate() { $lastId = RetailcrmTestHelper::getMaxOrderId(); - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersHistory') ->willReturn( new RetailcrmApiResponse( @@ -404,6 +436,18 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; + $this->apiClientMock->expects($this->any()) + ->method('ordersEdit') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode( + $this->getEditedOrder($this->getApiOrder()) + ) + ) + ) + ; + RetailcrmHistory::$default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); RetailcrmHistory::$api = $this->apiMock; @@ -415,7 +459,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase $orderId = RetailcrmTestHelper::getMaxOrderId(); $crmOrder = $this->getApiOrderAddressUpdate($orderId); - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersHistory') ->willReturn( new RetailcrmApiResponse( @@ -427,7 +471,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersGet') ->willReturn( new RetailcrmApiResponse( @@ -441,6 +485,18 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; + $this->apiClientMock->expects($this->any()) + ->method('ordersEdit') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode( + $this->getEditedOrder($this->getApiOrder()) + ) + ) + ) + ; + RetailcrmHistory::$default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); RetailcrmHistory::$api = $this->apiMock; @@ -475,7 +531,7 @@ class RetailcrmHistoryTest extends RetailcrmTestCase $orderId = RetailcrmTestHelper::getMaxOrderId(); $crmOrder = $this->getApiOrderNameAndPhoneUpdate($orderId); - $this->apiMock->expects($this->any()) + $this->apiClientMock->expects($this->any()) ->method('ordersHistory') ->willReturn( new RetailcrmApiResponse( @@ -487,6 +543,18 @@ class RetailcrmHistoryTest extends RetailcrmTestCase ) ; + $this->apiClientMock->expects($this->any()) + ->method('ordersEdit') + ->willReturn( + new RetailcrmApiResponse( + '200', + json_encode( + $this->getEditedOrder($crmOrder) + ) + ) + ) + ; + RetailcrmHistory::$default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); RetailcrmHistory::$api = $this->apiMock; diff --git a/tests/lib/RetailcrmInventoriesTest.php b/tests/lib/RetailcrmInventoriesTest.php index 94087ac..df3656a 100644 --- a/tests/lib/RetailcrmInventoriesTest.php +++ b/tests/lib/RetailcrmInventoriesTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmInventoriesTest extends RetailcrmTestCase { diff --git a/tests/lib/RetailcrmReferencesTest.php b/tests/lib/RetailcrmReferencesTest.php index 299c5b1..c611d72 100644 --- a/tests/lib/RetailcrmReferencesTest.php +++ b/tests/lib/RetailcrmReferencesTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmReferencesTest extends RetailcrmTestCase { diff --git a/tests/lib/RetailcrmToolsTest.php b/tests/lib/RetailcrmToolsTest.php index 65397b8..f8f1ce4 100644 --- a/tests/lib/RetailcrmToolsTest.php +++ b/tests/lib/RetailcrmToolsTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmToolsTest extends RetailcrmTestCase { diff --git a/tests/lib/api/RetailcrmApiPaginatedRequestTest.php b/tests/lib/api/RetailcrmApiPaginatedRequestTest.php index bfcf308..18d65c2 100644 --- a/tests/lib/api/RetailcrmApiPaginatedRequestTest.php +++ b/tests/lib/api/RetailcrmApiPaginatedRequestTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmApiPaginatedRequestTest extends RetailcrmTestCase { diff --git a/tests/lib/api/RetailcrmExceptionMiddlewareTest.php b/tests/lib/api/RetailcrmExceptionMiddlewareTest.php index d553399..7a58380 100644 --- a/tests/lib/api/RetailcrmExceptionMiddlewareTest.php +++ b/tests/lib/api/RetailcrmExceptionMiddlewareTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmExceptionMiddlewareTest extends RetailcrmTestCase { diff --git a/tests/lib/api/RetailcrmExportOrdersMiddlewareTest.php b/tests/lib/api/RetailcrmExportOrdersMiddlewareTest.php new file mode 100644 index 0000000..a728f4b --- /dev/null +++ b/tests/lib/api/RetailcrmExportOrdersMiddlewareTest.php @@ -0,0 +1,333 @@ + + * @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. + */ + +class RetailcrmExportOrdersMiddlewareTest extends RetailcrmTestCase +{ + private $apiMock; + + protected function setUp() + { + parent::setUp(); + + $this->apiMock = $this->getApiMock( + [ + 'ordersCreate', + 'ordersEdit', + 'ordersUpload', + 'ordersList', + ] + ); + + RetailcrmExportOrdersHelper::removeOrders(); + } + + public function getRequests() + { + return [ + [ + 'method' => 'ordersCreate', + 'orderIdCMS' => 1, + 'orderIdCRM' => 111, + 'result' => true, + 'errors' => null, + 'errorMsg' => null, + ], + [ + 'method' => 'ordersCreate', + 'orderIdCMS' => 2, + 'orderIdCRM' => 222, + 'result' => false, + 'errors' => null, + 'errorMsg' => 'Test error', + ], + [ + 'method' => 'ordersCreate', + 'orderIdCMS' => 3, + 'orderIdCRM' => 333, + 'result' => false, + 'errors' => [ + 'Test error #1', + 'Test error #2', + ], + 'errorMsg' => 'Test error', + ], + [ + 'method' => 'ordersEdit', + 'orderIdCMS' => 1, + 'orderIdCRM' => 112, + 'result' => true, + 'errors' => null, + 'errorMsg' => null, + ], + [ + 'method' => 'ordersEdit', + 'orderIdCMS' => 1, + 'orderIdCRM' => 112, + 'result' => false, + 'errors' => null, + 'errorMsg' => 'Test error', + ], + [ + 'method' => 'ordersEdit', + 'orderIdCMS' => 1, + 'orderIdCRM' => 112, + 'result' => false, + 'errors' => [ + 'Test error #1', + 'Test error #2', + ], + 'errorMsg' => 'Test error', + ], + ]; + } + + /** + * @dataProvider getRequests + */ + public function testRequest($method, $orderIdCMS, $orderIdCRM, $result, $errors, $errorMsg) + { + $this->apiClientMock->expects($this->any())->method($method)->willReturn(new RetailcrmApiResponse( + $result ? 200 : 400, + json_encode([ + 'success' => $result, + 'id' => $orderIdCRM, + 'order' => [ + 'id' => $orderIdCRM, + 'externalId' => $orderIdCMS, + ], + 'errors' => $errors, + 'errorMsg' => $errorMsg, + ]) + )); + $this->makeRequestAndCheckResponse($method, ['externalId' => $orderIdCMS], $result); + + $orders = $this->getOrders([$orderIdCMS]); + + $exportResult = $orders['orders'][0]; + + $this->assertEquals($exportResult['id_order'], $orderIdCMS); + + if (null === $errors && null === $errorMsg) { + $this->assertEquals($exportResult['id_order_crm'], $orderIdCRM); + $this->assertNull($exportResult['errors']); + } else { + $this->assertNotNull($exportResult['errors']); + $exportResultErrors = json_decode($exportResult['errors'], true); + $this->assertNotNull($exportResultErrors); + + if (null == $errors) { + $this->assertCount(1, $exportResultErrors); + $this->assertEquals($errorMsg, $exportResultErrors[0]); + } else { + $this->assertCount(count($errors), $exportResultErrors); + $this->assertEquals($errors, $exportResultErrors); + } + } + } + + public function dataRequestsUpload() + { + return [ + [ + 'result' => true, + 'uploadRequest' => [ + 1 => [ + 'externalId' => 1, + ], + 2 => [ + 'externalId' => 2, + ], + 3 => [ + 'externalId' => 3, + ], + ], + 'uploadedOrders' => [ + 1 => [ + 'externalId' => 1, + 'id' => 111, + ], + 2 => [ + 'externalId' => 2, + 'id' => 222, + ], + 3 => [ + 'externalId' => 3, + 'id' => 333, + ], + ], + 'errors' => null, + ], + [ + 'result' => false, + 'uploadRequest' => [ + 1 => [ + 'externalId' => 1, + ], + 2 => [ + 'externalId' => 2, + ], + 3 => [ + 'externalId' => 3, + ], + ], + 'uploadedOrders' => null, + 'errors' => [ + 1 => 'Order with externalId=1 already exists.', + 2 => 'Order with externalId=2 already exists.', + 3 => 'Order with externalId=3 already exists.', + ], + ], + [ + 'result' => false, + 'uploadRequest' => [ + 1 => [ + 'externalId' => 1, + ], + 2 => [ + 'externalId' => 2, + ], + 3 => [ + 'externalId' => 3, + ], + ], + 'uploadedOrders' => [ + 1 => [ + 'externalId' => 1, + 'id' => 111, + ], + 3 => [ + 'externalId' => 3, + 'id' => 333, + ], + ], + 'errors' => [ + 1 => 'Order with externalId=1 already exists.', + 2 => 'Test error #2', + ], + ], + ]; + } + + /** + * @dataProvider dataRequestsUpload + */ + public function testRequestUploadUnsuccessful($result, $uploadRequest, $uploadedOrders, $errors) + { + $this->apiClientMock->expects($this->any())->method('ordersUpload')->willReturn(new RetailcrmApiResponse( + $result ? 200 : 400, + json_encode([ + 'success' => $result, + 'uploadedOrders' => $result ? $uploadedOrders : null, + 'errors' => $errors, + ]) + )); + + if (!$result) { + $this->apiClientMock->expects($this->any())->method('ordersList')->willReturn(new RetailcrmApiResponse( + 200, + json_encode([ + 'success' => true, + 'orders' => $uploadedOrders, + ]) + )); + } + + $this->makeRequestAndCheckResponse('ordersUpload', $uploadRequest, $result); + + $orders = $this->getOrders(array_keys($uploadRequest)); + + foreach ($orders['orders'] as $order) { + $this->assertNotEmpty($order); + + $orderFromCRM = null; + if (null !== $uploadedOrders && array_key_exists($order['id_order'], $uploadedOrders)) { + $orderFromCRM = $uploadedOrders[$order['id_order']]; + + $this->assertEquals($order['id_order'], $orderFromCRM['externalId']); + $this->assertEquals($order['id_order_crm'], $orderFromCRM['id']); + $this->assertNull($order['errors']); + + continue; + } + + if (null !== $errors && array_key_exists($order['id_order'], $errors)) { + if (false !== strpos($errors[$order['id_order']], 'Order with externalId')) { + continue; + } + + $exportResultErrors = json_decode($order['errors'], true); + $this->assertNotNull($exportResultErrors); + + $this->assertNull($order['id_order_crm']); + $this->assertNotNull($order['errors']); + $this->assertCount(1, $exportResultErrors); + $this->assertEquals('Unknown error', $exportResultErrors[0]); + } + } + } + + /** + * @param string $method + * @param array $params + * @param bool $result + */ + private function makeRequestAndCheckResponse($method, $params, $result) + { + /** @var RetailcrmApiResponse $response */ + $response = $this->apiMock->$method($params); + + $this->assertInstanceOf(RetailcrmApiResponse::class, $response); + $this->assertEquals($response->isSuccessful(), $result); + } + + /** + * @param $ordersIds + * + * @return array + */ + private function getOrders($ordersIds) + { + $orders = RetailcrmExportOrdersHelper::getOrders($ordersIds); + + $this->assertArrayHasKey('orders', $orders); + $this->assertArrayHasKey('pagination', $orders); + $this->assertCount(count($ordersIds), $orders['orders']); + + return $orders; + } +} diff --git a/tests/lib/api/RetailcrmReferenceMiddlewareTest.php b/tests/lib/api/RetailcrmReferenceMiddlewareTest.php index 8a54a00..a3af690 100644 --- a/tests/lib/api/RetailcrmReferenceMiddlewareTest.php +++ b/tests/lib/api/RetailcrmReferenceMiddlewareTest.php @@ -1,4 +1,40 @@ + * @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. + */ class RetailcrmReferenceMiddlewareTest extends RetailcrmTestCase { @@ -22,17 +58,17 @@ class RetailcrmReferenceMiddlewareTest extends RetailcrmTestCase return [ [ 'method' => 'ordersGet', - 'params' => [[]], + 'params' => [], 'reference' => 'reference', ], [ 'method' => 'ordersEdit', - 'params' => [['number' => 'test', 'externalId' => 1]], + 'params' => ['number' => 'test', 'externalId' => 1], 'reference' => 'test', ], [ 'method' => 'ordersCreate', - 'params' => [['number' => 'test', 'externalId' => 1]], + 'params' => ['number' => 'test', 'externalId' => 1], 'reference' => 'test', ], ]; @@ -43,32 +79,14 @@ class RetailcrmReferenceMiddlewareTest extends RetailcrmTestCase */ public function testRequest($method, $params, $reference) { - $this->apiClientMock->expects($this->any())->method('ordersCreate')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'order' => [ - 'number' => 'test', - 'externalId' => 1, - ], - ]) - )); - $this->apiClientMock->expects($this->any())->method('ordersEdit')->willReturn(new RetailcrmApiResponse( - 200, - json_encode([ - 'success' => true, - 'order' => [ - 'number' => 'test', - 'externalId' => 1, - ], - ]) - )); - $this->apiClientMock->expects($this->any())->method('ordersGet')->willReturn(new RetailcrmApiResponse( + $this->apiClientMock->expects($this->any())->method($method)->willReturn(new RetailcrmApiResponse( 200, json_encode([ 'success' => true, + 'id' => 1, 'order' => [ 'number' => 'test', + 'id' => 1, 'externalId' => 1, ], ])