├── .gitignore ├── README.md ├── composer.json ├── composer.lock ├── default_option.php ├── description.ru ├── include.php ├── install ├── components │ └── mindbox │ │ ├── auth.sms │ │ ├── .description.php │ │ ├── .parameters.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── lang │ │ │ ├── en │ │ │ │ └── template.php │ │ │ └── ru │ │ │ │ └── template.php │ │ │ ├── script.js │ │ │ └── template.php │ │ ├── bonus.history │ │ ├── .description.php │ │ ├── .parameters.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── lang │ │ │ ├── en │ │ │ │ └── template.php │ │ │ └── ru │ │ │ │ └── template.php │ │ │ ├── script.js │ │ │ └── template.php │ │ ├── cart │ │ ├── .description.php │ │ ├── .parameters.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── lang │ │ │ ├── en │ │ │ │ └── template.php │ │ │ └── ru │ │ │ │ └── template.php │ │ │ ├── script.js │ │ │ └── template.php │ │ ├── catalog.tracking │ │ ├── .description.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ └── template.php │ │ ├── discount.card │ │ ├── .description.php │ │ ├── .parameters.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── lang │ │ │ ├── en │ │ │ │ └── template.php │ │ │ └── ru │ │ │ │ └── template.php │ │ │ ├── script.js │ │ │ └── template.php │ │ ├── email.confirm │ │ ├── .description.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── lang │ │ │ ├── en │ │ │ │ └── template.php │ │ │ └── ru │ │ │ │ └── template.php │ │ │ ├── script.js │ │ │ └── template.php │ │ ├── order.history │ │ ├── .description.php │ │ ├── .parameters.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ ├── .parameters.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── lang │ │ │ ├── en │ │ │ │ └── template.php │ │ │ └── ru │ │ │ │ └── template.php │ │ │ ├── script.js │ │ │ └── template.php │ │ ├── phone.confirm │ │ ├── .description.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── lang │ │ │ ├── en │ │ │ │ └── template.php │ │ │ └── ru │ │ │ │ └── template.php │ │ │ ├── script.js │ │ │ └── template.php │ │ ├── product.bonus │ │ ├── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── script.js │ │ │ ├── style.css │ │ │ ├── template.php │ │ │ └── view.php │ │ ├── product.price │ │ ├── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── script.js │ │ │ ├── style.css │ │ │ └── template.php │ │ ├── sub.edit │ │ ├── .description.php │ │ ├── class.php │ │ ├── lang │ │ │ ├── en │ │ │ │ ├── .description.php │ │ │ │ └── class.php │ │ │ └── ru │ │ │ │ ├── .description.php │ │ │ │ └── class.php │ │ └── templates │ │ │ └── .default │ │ │ ├── lang │ │ │ ├── en │ │ │ │ └── template.php │ │ │ └── ru │ │ │ │ └── template.php │ │ │ ├── script.js │ │ │ └── template.php │ │ └── subscription │ │ ├── .description.php │ │ ├── class.php │ │ ├── lang │ │ ├── en │ │ │ ├── .description.php │ │ │ └── class.php │ │ └── ru │ │ │ ├── .description.php │ │ │ └── class.php │ │ └── templates │ │ └── .default │ │ ├── lang │ │ ├── en │ │ │ └── template.php │ │ └── ru │ │ │ └── template.php │ │ ├── script.js │ │ └── template.php ├── css │ └── style.css ├── images │ └── loader.gif ├── index.php ├── js │ ├── jquery-3.3.1.min.js │ ├── jquery.inputmask.bundle.js │ ├── script.js │ ├── tracker.js │ └── tracker.js.orig ├── step1.php ├── unstep1.php ├── unstep2.php └── version.php ├── lang ├── en │ ├── install │ │ ├── index.php │ │ ├── step1.php │ │ └── version.php │ ├── lib │ │ ├── AccessLogs.php │ │ ├── Discount │ │ │ └── MindboxDeliveryDiscountAction.php │ │ ├── Event.php │ │ ├── ExtensionCartRulesActions.php │ │ ├── Helper.php │ │ ├── Installer │ │ │ └── OrderPropertiesInstaller.php │ │ └── Templates │ │ │ └── AdminLayouts.php │ └── options.php └── ru │ ├── install │ ├── index.php │ ├── step1.php │ └── version.php │ ├── lib │ ├── AccessLogs.php │ ├── Discount │ │ └── MindboxDeliveryDiscountAction.php │ ├── Event.php │ ├── EventController.php │ ├── ExtensionCartRulesActions.php │ ├── Helper.php │ ├── Installer │ │ └── OrderPropertiesInstaller.php │ └── Templates │ │ └── AdminLayouts.php │ └── options.php ├── lib ├── AccessLogs.php ├── Ajax.php ├── Components │ └── CalculateProductData.php ├── Core.php ├── DataBase │ ├── MindboxTransactionTable.php │ └── ModuleToModuleTable.php ├── Discount │ ├── DeliveryDiscountEntity.php │ ├── MindboxDeliveryDiscountAction.php │ └── MindboxDiscountActions.php ├── Event.php ├── EventController.php ├── ExtensionCartRulesActions.php ├── Handlers │ ├── Basket.php │ ├── Order.php │ └── User.php ├── Helper.php ├── Installer │ ├── CartRuleInstaller.php │ ├── DeliveryCartRuleInstaller.php │ ├── OrderPropertiesInstaller.php │ └── ProductCartRuleInstaller.php ├── LogsRotation.php ├── Options.php ├── QueueTable.php ├── Templates │ └── AdminLayouts.php ├── Transaction.php └── YmlFeedMindbox.php ├── logs ├── .htaccess └── index.php ├── options.php ├── phpcs.xml └── updater.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /lib/SDK/ 3 | /tmp/ 4 | .idea -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mindbox/marketing", 3 | "type": "bitrix-module", 4 | "license": "MIT", 5 | "minimum-stability": "stable", 6 | "require": { 7 | "mindbox/sdk": "1.0.7" 8 | }, 9 | "autoload": { 10 | "psr-4": { 11 | "Mindbox\\": "lib/" 12 | } 13 | }, 14 | "require-dev": { 15 | "squizlabs/php_codesniffer": "^3.6" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "9a22928ca903820be13131eeba3b56ba", 8 | "packages": [ 9 | { 10 | "name": "mindbox/sdk", 11 | "version": "1.0.7", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/mindbox-moscow/php-sdk.git", 15 | "reference": "465216bb10e16432b9b490b295b82bae3980aa89" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/mindbox-moscow/php-sdk/zipball/465216bb10e16432b9b490b295b82bae3980aa89", 20 | "reference": "465216bb10e16432b9b490b295b82bae3980aa89", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-json": "*", 25 | "ext-libxml": "*", 26 | "ext-simplexml": "*", 27 | "php": "^5.6|^7.0", 28 | "psr/log": "^1.1" 29 | }, 30 | "require-dev": { 31 | "mikey179/vfsstream": "*", 32 | "phpunit/phpunit": "^5", 33 | "squizlabs/php_codesniffer": "^3.4" 34 | }, 35 | "suggest": { 36 | "ext-curl": "*" 37 | }, 38 | "type": "library", 39 | "autoload": { 40 | "psr-4": { 41 | "Mindbox\\": "src/" 42 | } 43 | }, 44 | "notification-url": "https://packagist.org/downloads/", 45 | "description": "Mindbox SDK for PHP", 46 | "keywords": [ 47 | "mindbox", 48 | "sdk" 49 | ], 50 | "time": "2022-04-12T09:18:30+00:00" 51 | }, 52 | { 53 | "name": "psr/log", 54 | "version": "1.1.4", 55 | "source": { 56 | "type": "git", 57 | "url": "https://github.com/php-fig/log.git", 58 | "reference": "d49695b909c3b7628b6289db5479a1c204601f11" 59 | }, 60 | "dist": { 61 | "type": "zip", 62 | "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", 63 | "reference": "d49695b909c3b7628b6289db5479a1c204601f11", 64 | "shasum": "" 65 | }, 66 | "require": { 67 | "php": ">=5.3.0" 68 | }, 69 | "type": "library", 70 | "extra": { 71 | "branch-alias": { 72 | "dev-master": "1.1.x-dev" 73 | } 74 | }, 75 | "autoload": { 76 | "psr-4": { 77 | "Psr\\Log\\": "Psr/Log/" 78 | } 79 | }, 80 | "notification-url": "https://packagist.org/downloads/", 81 | "license": [ 82 | "MIT" 83 | ], 84 | "authors": [ 85 | { 86 | "name": "PHP-FIG", 87 | "homepage": "https://www.php-fig.org/" 88 | } 89 | ], 90 | "description": "Common interface for logging libraries", 91 | "homepage": "https://github.com/php-fig/log", 92 | "keywords": [ 93 | "log", 94 | "psr", 95 | "psr-3" 96 | ], 97 | "time": "2021-05-03T11:20:27+00:00" 98 | } 99 | ], 100 | "packages-dev": [ 101 | { 102 | "name": "squizlabs/php_codesniffer", 103 | "version": "3.6.2", 104 | "source": { 105 | "type": "git", 106 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", 107 | "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" 108 | }, 109 | "dist": { 110 | "type": "zip", 111 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", 112 | "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", 113 | "shasum": "" 114 | }, 115 | "require": { 116 | "ext-simplexml": "*", 117 | "ext-tokenizer": "*", 118 | "ext-xmlwriter": "*", 119 | "php": ">=5.4.0" 120 | }, 121 | "require-dev": { 122 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" 123 | }, 124 | "bin": [ 125 | "bin/phpcs", 126 | "bin/phpcbf" 127 | ], 128 | "type": "library", 129 | "extra": { 130 | "branch-alias": { 131 | "dev-master": "3.x-dev" 132 | } 133 | }, 134 | "notification-url": "https://packagist.org/downloads/", 135 | "license": [ 136 | "BSD-3-Clause" 137 | ], 138 | "authors": [ 139 | { 140 | "name": "Greg Sherwood", 141 | "role": "lead" 142 | } 143 | ], 144 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 145 | "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", 146 | "keywords": [ 147 | "phpcs", 148 | "standards" 149 | ], 150 | "time": "2021-12-12T21:44:58+00:00" 151 | } 152 | ], 153 | "aliases": [], 154 | "minimum-stability": "stable", 155 | "stability-flags": [], 156 | "prefer-stable": false, 157 | "prefer-lowest": false, 158 | "platform": [], 159 | "platform-dev": [], 160 | "plugin-api-version": "1.1.0" 161 | } 162 | -------------------------------------------------------------------------------- /default_option.php: -------------------------------------------------------------------------------- 1 | '', 5 | 'DOMAIN' => '', 6 | 'SECRET_KEY' => '', 7 | 'LOG_PATH' => $_SERVER['DOCUMENT_ROOT'] .'/logs/', 8 | 'HTTP_CLIENT' => '', 9 | 'TIMEOUT' => 5, 10 | 'QUEUE_TIMEOUT' => 30, 11 | 'WEBSITE_PREFIX' => '', 12 | 'TRANSACTION_ID' => '', 13 | 'CATALOG_IBLOCK_ID' => '', 14 | 'YML_NAME' => 'upload/mindbox.xml', 15 | 'EXTERNAL_SYSTEM' => '', 16 | 'WEBSITE_ID' => '', 17 | 'CATALOG_PROPS' => '', 18 | 'CATALOG_OFFER_PROPS' => '', 19 | 'TRACKER_JS_FILENAME' => '/bitrix/js/mindbox/tracker.js', 20 | 'TRACKER_JS_FILENAME_ORIGINAL' => '/bitrix/js/mindbox/tracker.js.orig' 21 | ]; 22 | -------------------------------------------------------------------------------- /description.ru: -------------------------------------------------------------------------------- 1 | Обновление 1.4.1 2 | -------------------------------------------------------------------------------- /include.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/auth.sms/.parameters.php: -------------------------------------------------------------------------------- 1 | [ 8 | "PERSONAL_PAGE_URL" => [ 9 | "PARENT" => "BASE", 10 | "NAME" => GetMessage('PERSONAL_PAGE_URL'), 11 | "TYPE" => "STRING", 12 | "DEFAULT" => SITE_DIR . '/' 13 | ], 14 | "FILLUP_FORM_FIELDS" => [ 15 | "PARENT" => "BASE", 16 | "NAME" => GetMessage('FILLUP_FORM_FIELDS'), 17 | "TYPE" => "LIST", 18 | "MULTIPLE" => "Y", 19 | "VALUES" => [ 20 | 'NAME' => GetMessage('NAME'), 21 | 'LAST_NAME' => GetMessage('LAST_NAME'), 22 | 'EMAIL' => GetMessage('EMAIL'), 23 | 'MOBILE_PHONE' => GetMessage('MOBILE_PHONE'), 24 | 'PASSWORD' => GetMessage('PASSWORD'), 25 | 'BIRTH_DATE' => GetMessage('BIRTH_DATE'), 26 | 'GENDER' => GetMessage('GENDER') 27 | ], 28 | "DEFAULT" => 'EMAIL' 29 | ] 30 | ] 31 | ]; 32 | 33 | -------------------------------------------------------------------------------- /install/components/mindbox/auth.sms/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/bonus.history/.parameters.php: -------------------------------------------------------------------------------- 1 | [ 6 | "PAGE_SIZE" => [ 7 | "PARENT" => "BASE", 8 | "NAME" => GetMessage('PAGE_SIZE'), 9 | "TYPE" => "STRING", 10 | "DEFAULT" => 5 11 | ] 12 | ] 13 | ]; 14 | 15 | -------------------------------------------------------------------------------- /install/components/mindbox/bonus.history/class.php: -------------------------------------------------------------------------------- 1 | 'mindbox.marketing'])); 36 | return; 37 | } 38 | } catch (LoaderException $e) { 39 | ShowError(GetMessage('MB_BH_MODULE_NOT_INCLUDED', ['#MODULE#' => 'mindbox.marketing'])); 40 | return; 41 | } 42 | 43 | $this->mindbox = Options::getConfig(); 44 | } 45 | 46 | public function configureActions() 47 | { 48 | return Ajax::configureActions($this->actions); 49 | } 50 | 51 | public function pageAction($page) 52 | { 53 | if (!$this->mindbox) { 54 | return Ajax::errorResponse('Incorrect module settings'); 55 | } 56 | $page = intval($page); 57 | $this->arParams = Ajax::loadParams(self::getName()); 58 | $size = isset($this->arParams['PAGE_SIZE']) ? $this->arParams['PAGE_SIZE'] : 0; 59 | 60 | try { 61 | $orders = $this->getHistory($page); 62 | $showMore = count($orders) === intval($size); 63 | 64 | return [ 65 | 'type' => 'success', 66 | 'page' => $page, 67 | 'html' => $this->getHtml($orders), 68 | 'more' => $showMore 69 | ]; 70 | } catch (Mindbox\Exceptions\MindboxException $e) { 71 | return Ajax::errorResponse('Can\'t load requested page'); 72 | } 73 | } 74 | 75 | 76 | /** 77 | * @param $page 78 | * @return array 79 | * @throws MindboxException 80 | */ 81 | public function getHistory($page) 82 | { 83 | global $USER; 84 | if (!$USER->IsAuthorized()) { 85 | throw new MindboxException(GetMessage('MB_BH_ERROR_MESSAGE')); 86 | } 87 | 88 | if (!$this->mindbox) { 89 | throw new MindboxException('Incorrect module settings'); 90 | } 91 | $page = intval($page); 92 | $history = []; 93 | $mindboxId = $this->getMindboxId(); 94 | if (!$mindboxId) { 95 | throw new MindboxException(GetMessage('MB_BH_ERROR_MESSAGE')); 96 | } 97 | $operation = Options::getOperationName('getBonusPointsHistory'); 98 | 99 | $pageDTO = new PageRequestDTO(); 100 | $pageDTO->setItemsPerPage($this->arParams['PAGE_SIZE']); 101 | $pageDTO->setPageNumber($page); 102 | 103 | $customer = new CustomerRequestDTO(); 104 | $customer->setId('mindboxId', $mindboxId); 105 | 106 | try { 107 | $response = $this->mindbox->customer()->getBonusPointsHistory( 108 | $customer, 109 | $pageDTO, 110 | $operation 111 | )->sendRequest(); 112 | } catch (Exception $e) { 113 | throw new MindboxException(GetMessage('MB_BH_ERROR_MESSAGE')); 114 | } 115 | 116 | $result = $response->getResult(); 117 | 118 | if (!$result->getCustomerActions()) { 119 | throw new MindboxException(GetMessage('MB_BH_ERROR_MESSAGE')); 120 | } 121 | 122 | 123 | foreach ($result->getCustomerActions() as $action) { 124 | foreach ($action->getCustomerBalanceChanges() as $customerBalanceChanges) { 125 | $comment = $customerBalanceChanges->getField('comment'); 126 | 127 | if (empty($comment)) { 128 | $type = $customerBalanceChanges->getField('balanceChangeKind')->getField('systemName'); 129 | $isPositive = (int)$customerBalanceChanges->getField('changeAmount') > 0; 130 | $orderData = $action->getOrder(); 131 | 132 | $comment = ''; 133 | $orderId = false; 134 | 135 | if (!empty($orderData) && is_object($orderData)) { 136 | $orderId = array_pop($orderData->getField('ids')); 137 | } 138 | 139 | if ($type === 'RetailOrderBonus') { 140 | if ($isPositive) { 141 | $comment = GetMessage('MB_EARN_POINTS'); 142 | } else { 143 | $comment = GetMessage('MB_RETURN_POINTS'); 144 | } 145 | } elseif ($type === 'RetailOrderPayment') { 146 | if ($isPositive) { 147 | $comment = GetMessage('MB_SPEND_POINTS'); 148 | } else { 149 | $comment = GetMessage('MB_REFUND_POINTS'); 150 | } 151 | } 152 | 153 | if (!empty($comment)) { 154 | $comment .= $orderId; 155 | } 156 | } 157 | 158 | $history[] = [ 159 | 'start' => $this->formatTime($action->getDateTimeUtc()), 160 | 'size' => $customerBalanceChanges->getChangeAmount(), 161 | 'name' => $comment, 162 | 'end' => $this->formatTime($customerBalanceChanges->getExpirationDateTimeUtc()) 163 | ]; 164 | } 165 | } 166 | 167 | if (!$this->getMindboxId()) { 168 | return $history; 169 | } 170 | 171 | $request = $this->mindbox->getClientV3()->prepareRequest( 172 | 'POST', 173 | Options::getOperationName('getCustomerInfo'), 174 | new DTO(['customer' => ['ids' => ['mindboxId' => $this->getMindboxId()]]]) 175 | ); 176 | 177 | try { 178 | $response = $request->sendRequest()->getResult(); 179 | $arBalances = reset($response->getBalances()->getFieldsAsArray()); 180 | $this->arResult['BALANCE'] = [ 181 | 'available' => $arBalances['available'], 182 | 'blocked' => $arBalances['blocked'] 183 | ]; 184 | } catch (MindboxClientException $e) { 185 | throw new MindboxException($e->getMessage()); 186 | } 187 | 188 | return $history; 189 | } 190 | 191 | public function formatTime($utc) 192 | { 193 | return (new DateTime($utc))->format('Y-m-d H:i:s'); 194 | } 195 | 196 | public function executeComponent() 197 | { 198 | $_SESSION[self::getName()] = $this->arParams; 199 | $this->prepareResult(); 200 | $this->includeComponentTemplate(); 201 | } 202 | 203 | public function prepareResult() 204 | { 205 | $page = 1; 206 | 207 | try { 208 | $this->arResult['HISTORY'] = $this->getHistory($page); 209 | } catch (MindboxException $e) { 210 | $this->arResult['ERROR'] = $e->getMessage(); 211 | } 212 | } 213 | 214 | protected function getHtml($history) 215 | { 216 | $html = ''; 217 | 218 | foreach ($history as $change) { 219 | $html .= GetMessage( 220 | 'MB_BH_BALANCE_HTML', 221 | [ 222 | '#START#' => $change['start'], 223 | '#SIZE#' => $change['size'], 224 | '#END#' => $change['end'], 225 | '#NAME#' => $change['name'] 226 | ] 227 | ); 228 | } 229 | 230 | return $html; 231 | } 232 | 233 | private function getMindboxId() 234 | { 235 | global $USER; 236 | 237 | return Helper::getMindboxId($USER->GetID()); 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /install/components/mindbox/bonus.history/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | #START##SIZE##NAME##END#'; 5 | $MESS['MB_BH_ERROR_MESSAGE'] = 'Bonus history is temporarily unavailable'; 6 | $MESS['MB_EARN_POINTS'] = 'Earning points for an order '; 7 | $MESS['MB_RETURN_POINTS'] = 'Return points for an order '; 8 | $MESS['MB_SPEND_POINTS'] = 'Spend points for an order '; 9 | $MESS['MB_REFUND_POINTS'] = 'Refund of points for an order '; 10 | -------------------------------------------------------------------------------- /install/components/mindbox/bonus.history/lang/ru/.description.php: -------------------------------------------------------------------------------- 1 | #START##SIZE##NAME##END#'; 5 | $MESS['MB_BH_ERROR_MESSAGE'] = 'История бонусов временно недоступна'; 6 | $MESS['MB_EARN_POINTS'] = 'Начисление баллов за заказ '; 7 | $MESS['MB_RETURN_POINTS'] = 'Списание начисленных баллов за заказ '; 8 | $MESS['MB_SPEND_POINTS'] = 'Оплата заказа '; 9 | $MESS['MB_REFUND_POINTS'] = 'Возврат баллов '; 10 | -------------------------------------------------------------------------------- /install/components/mindbox/bonus.history/templates/.default/lang/en/template.php: -------------------------------------------------------------------------------- 1 | addJs("/bitrix/js/mindbox/jquery.inputmask.bundle.js"); 10 | Asset::getInstance()->addJs("/bitrix/js/mindbox/script.js"); 11 | Asset::getInstance()->addCss("/bitrix/css/mindbox/style.css"); 12 | ?> 13 | 14 | IsAuthorized()) 15 | { 16 | $APPLICATION->AuthForm("", false, false, 'N', false); 17 | } else { 18 | ?> 19 | ' . $arResult['ERROR'] . ''; 21 | } else { 22 | ?> 23 |

24 | . 25 |

26 | 27 |

28 | . 29 |

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 | 47 |
48 |
49 |
50 | 51 | -------------------------------------------------------------------------------- /install/components/mindbox/cart/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/cart/.parameters.php: -------------------------------------------------------------------------------- 1 | [ 6 | "USE_BONUSES" => [ 7 | "PARENT" => "BASE", 8 | "NAME" => GetMessage('USE_BONUSES'), 9 | "TYPE" => "CHECKBOX", 10 | "DEFAULT" => "Y" 11 | ] 12 | ] 13 | ]; 14 | 15 | -------------------------------------------------------------------------------- /install/components/mindbox/cart/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | limit) { 66 | $('#mindbox-cart-success').hide(); 67 | 68 | $('#mindbox-cart-error').text(limitMessage).show(); 69 | 70 | return; 71 | } 72 | 73 | let $targetForLoadder = $('#mindbox-cart'); 74 | 75 | loader.show($targetForLoadder); 76 | 77 | let request = BX.ajax.runComponentAction('mindbox:cart', 'applyBonuses', { 78 | mode: 'class', 79 | data: { 80 | bonuses: bonuses 81 | } 82 | }); 83 | 84 | request.then(function (response) { 85 | loader.hide($targetForLoadder); 86 | 87 | if (response.data.type === 'success') { 88 | window.location.reload(); 89 | } 90 | }); 91 | }); 92 | 93 | $('#mindbox-cart-clear-bonus').on('click', function () { 94 | $('#mindbox-pay-bonuses').trigger('click'); 95 | }); 96 | 97 | $('#mindbox-clear-code').on('click', function () { 98 | $('#mindbox-cart-error').hide(); 99 | $('#mindbox-promocode-submit').trigger('click'); 100 | }) 101 | }); 102 | -------------------------------------------------------------------------------- /install/components/mindbox/cart/templates/.default/template.php: -------------------------------------------------------------------------------- 1 | addJs("/bitrix/js/mindbox/jquery.inputmask.bundle.js"); 11 | Asset::getInstance()->addJs("/bitrix/js/mindbox/script.js"); 12 | Asset::getInstance()->addCss("/bitrix/css/mindbox/style.css"); 13 | ?> 14 | 15 |
16 |
17 | 18 |
19 |
20 | 21 |
22 |
23 |
24 |
25 | 26 |
27 | 28 |
29 |
30 |
31 | 32 | 33 | 34 |
35 | 36 | 37 |
38 |
39 | 40 |
41 | 42 |
43 | - . 44 |
45 | 46 |
47 |
48 | 49 | 50 | 51 |
52 |
53 | 54 |
55 | 56 |
57 |
58 |
59 | 61 | 62 | 63 |
64 | 65 |
66 |
67 |
68 | 69 |
70 |
-------------------------------------------------------------------------------- /install/components/mindbox/catalog.tracking/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/catalog.tracking/class.php: -------------------------------------------------------------------------------- 1 | loadModule()) { 17 | return; 18 | } 19 | } 20 | 21 | public function executeComponent() 22 | { 23 | $this->includeComponentTemplate(); 24 | } 25 | 26 | private function loadModule() 27 | { 28 | try { 29 | return Loader::includeModule('mindbox.marketing'); 30 | } catch (LoaderException $e) { 31 | return false; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /install/components/mindbox/catalog.tracking/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 38 | -------------------------------------------------------------------------------- /install/components/mindbox/discount.card/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/discount.card/.parameters.php: -------------------------------------------------------------------------------- 1 | [ 6 | "PERSONAL_PAGE_URL" => [ 7 | "PARENT" => "BASE", 8 | "NAME" => GetMessage('PERSONAL_PAGE_URL'), 9 | "TYPE" => "STRING", 10 | "DEFAULT" => SITE_DIR . '/' 11 | ] 12 | ] 13 | ]; 14 | 15 | -------------------------------------------------------------------------------- /install/components/mindbox/discount.card/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | addJs("/bitrix/js/mindbox/jquery.inputmask.bundle.js"); 11 | Asset::getInstance()->addJs("/bitrix/js/mindbox/script.js"); 12 | Asset::getInstance()->addCss("/bitrix/css/mindbox/style.css"); 13 | ?> 14 | 15 | IsAuthorized()) { 16 | $APPLICATION->AuthForm("", false, false, 'N', false); 17 | } else { 18 | ?> 19 |
20 |
21 | 22 |
23 |
24 | 25 |
26 |
27 |
28 |
29 | 30 |
31 | 32 |
33 | 34 |
35 |
36 | 37 |
38 |
39 | 40 |
41 |
42 |
43 | 79 |
80 | -------------------------------------------------------------------------------- /install/components/mindbox/email.confirm/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/email.confirm/class.php: -------------------------------------------------------------------------------- 1 | 'mindbox.marketing'])); 40 | return; 41 | } 42 | } catch (LoaderException $e) { 43 | ShowError(GetMessage('MB_EC_MODULE_NOT_INCLUDED', ['#MODULE#' => 'mindbox.marketing'])); 44 | return; 45 | } 46 | 47 | $this->userInfo = $this->getUser(); 48 | if (!$this->userInfo['UF_EMAIL_CONFIRMED'] && !empty($this->userInfo['EMAIL'])) { 49 | $this->mindbox = Options::getConfig(); 50 | } 51 | } 52 | 53 | public function executeComponent() 54 | { 55 | 56 | if (!$this->userInfo['UF_EMAIL_CONFIRMED'] && !empty($this->userInfo['EMAIL'])) { 57 | $this->checkEmailConfirm(); 58 | } 59 | $this->arResult['USER_INFO']['UF_EMAIL_CONFIRMED'] = $this->userInfo['UF_EMAIL_CONFIRMED']; 60 | $this->arResult['USER_INFO']['EMAIL'] = $this->userInfo['EMAIL']; 61 | $this->includeComponentTemplate(); 62 | } 63 | 64 | 65 | public function configureActions() 66 | { 67 | return Ajax::configureActions($this->actions); 68 | } 69 | 70 | public function checkEmailConfirm() 71 | { 72 | global $USER; 73 | 74 | if(!$this->getMindboxId()) { 75 | return; 76 | } 77 | 78 | $request = $this->mindbox->getClientV3()->prepareRequest('POST', 79 | Options::getOperationName('getCustomerInfo'), 80 | new DTO(['customer' => ['ids' => ['mindboxId' => $this->getMindboxId()]]])); 81 | 82 | try { 83 | $response = $request->sendRequest(); 84 | } catch (MindboxClientException $e) { 85 | return; 86 | } 87 | $customer = $response->getResult()->getCustomer(); 88 | if ($customer && $customer->getProcessingStatus() === 'Found') { 89 | if (!empty($customer->getIsEmailConfirmed()) && empty($customer->getPendingEmail())) { 90 | $USER->Update($this->userInfo['ID'], ['UF_EMAIL_CONFIRMED' => '1']); 91 | } 92 | } 93 | 94 | } 95 | 96 | public function resendAction() 97 | { 98 | if (!$this->mindbox) { 99 | return Ajax::errorResponse(GetMessage('MB_EC_BAD_MODULE_SETTING')); 100 | } 101 | $customer = new CustomerRequestDTO(['ids' => ['mindboxId' => $this->getMindboxId()]]); 102 | try { 103 | $this->mindbox->customer()->resendConfirmationCode($customer, 104 | Options::getOperationName('resendEmailConfirm'))->sendRequest(); 105 | } catch (MindboxClientException $e) { 106 | return Ajax::errorResponse($e); 107 | } 108 | } 109 | 110 | protected function getUser() 111 | { 112 | global $USER; 113 | 114 | $rsUser = UserTable::getList( 115 | [ 116 | 'select' => ['EMAIL', 'UF_MINDBOX_ID', 'ID', 'UF_EMAIL_CONFIRMED'], 117 | 'filter' => ['ID' => $USER->GetID()] 118 | ] 119 | )->fetch(); 120 | 121 | return $rsUser; 122 | } 123 | 124 | private function getMindboxId() 125 | { 126 | global $USER; 127 | 128 | return Helper::getMindboxId($USER->GetID()); 129 | } 130 | } -------------------------------------------------------------------------------- /install/components/mindbox/email.confirm/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | #EMAIL# successfully verified'; 4 | $MESS['MB_EC_RESEND_BUTTON'] = 'Resend'; 5 | $MESS['MB_EC_RESEND_LABEL'] = 'Didn\'t receive a confirmation email?'; -------------------------------------------------------------------------------- /install/components/mindbox/email.confirm/templates/.default/lang/ru/template.php: -------------------------------------------------------------------------------- 1 | #EMAIL#, успешно подтвержден'; 4 | $MESS['MB_EC_RESEND_BUTTON'] = 'Переотправить'; 5 | $MESS['MB_EC_RESEND_LABEL'] = 'Не получили письмо с подтверждением?'; 6 | -------------------------------------------------------------------------------- /install/components/mindbox/email.confirm/templates/.default/script.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | $('#mindbox-email-confirm--resend').on('click', function () { 3 | let request = BX.ajax.runComponentAction('mindbox:email.confirm', 'resend', { 4 | mode:'class', 5 | }); 6 | 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /install/components/mindbox/email.confirm/templates/.default/template.php: -------------------------------------------------------------------------------- 1 | addJs("/bitrix/js/mindbox/jquery.inputmask.bundle.js"); 11 | Asset::getInstance()->addJs("/bitrix/js/mindbox/script.js"); 12 | Asset::getInstance()->addCss("/bitrix/css/mindbox/style.css"); 13 | ?> 14 | 15 | IsAuthorized()): ?> 16 |
17 | 18 |
19 | 20 |
21 | 22 |
23 | $arResult['USER_INFO']['EMAIL']]) ?> 24 |
25 | 26 |
27 | 29 |
30 |
31 | 33 |
34 |
35 |
36 | 37 |
38 |
39 | 43 |
44 |
45 | 46 |
47 | 48 | -------------------------------------------------------------------------------- /install/components/mindbox/order.history/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/order.history/.parameters.php: -------------------------------------------------------------------------------- 1 | [ 6 | "PAGE_SIZE" => [ 7 | "PARENT" => "BASE", 8 | "NAME" => GetMessage('PAGE_SIZE'), 9 | "TYPE" => "STRING", 10 | "DEFAULT" => 5 11 | ] 12 | ] 13 | ]; 14 | 15 | -------------------------------------------------------------------------------- /install/components/mindbox/order.history/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | Order № #ID# от #CREATED#.

'; 4 | $MESS['ORDER_SPENT'] = 'To pay for the order was used #SPENT# point#END#.'; 5 | $MESS['ORDER_ACUIRED'] = 'For the order accrued #ACUIRED# point#END#.'; 6 | $MESS['ENDINGS_ARRAY'] = ['s', 's', 's']; 7 | $MESS['ORDER_END_HEAD'] = '

'; 8 | $MESS['ORDER_START_HEAD'] = '

'; 9 | $MESS['ORDER_START_TABLE'] = ''; 10 | $MESS['ORDER_END_TABLE'] = '
Product NamePrice
'; 11 | $MESS['ORDER_LINE'] = '#NAME##PRICE#'; 12 | $MESS['ORDER_ERROR_MESSAGE'] = 'Bonus history is temporarily unavailable'; 13 | -------------------------------------------------------------------------------- /install/components/mindbox/order.history/lang/ru/.description.php: -------------------------------------------------------------------------------- 1 | Заказ № #ID# от #CREATED#.

'; 4 | $MESS['ORDER_SPENT'] = 'Для оплаты заказа было использовано #SPENT# балл#END#.'; 5 | $MESS['ORDER_ACUIRED'] = 'За заказ начислено #ACUIRED# балл#END#.'; 6 | $MESS['ENDINGS_ARRAY'] = ['', 'а', 'ов']; 7 | $MESS['ORDER_END_HEAD'] = '

'; 8 | $MESS['ORDER_START_HEAD'] = '

'; 9 | $MESS['ORDER_START_TABLE'] = ''; 10 | $MESS['ORDER_END_TABLE'] = '
Название товараЦена
'; 11 | $MESS['ORDER_LINE'] = '#NAME##PRICE#'; 12 | $MESS['ORDER_ERROR_MESSAGE'] = 'История бонусов временно недоступна'; 13 | -------------------------------------------------------------------------------- /install/components/mindbox/order.history/templates/.default/lang/en/template.php: -------------------------------------------------------------------------------- 1 | Order № #ID# from #CREATED#.

'; 11 | $MESS['MB_OH_ORDER_SPENT'] = 'To pay for the order was used #SPENT# point#END#.'; 12 | $MESS['MB_OH_ORDER_ACUIRED'] = 'For the order accrued #ACUIRED# point#END#.'; 13 | $MESS['MB_OH_ENDINGS_ARRAY'] = ['', 'а', 'ов']; 14 | $MESS['MB_OH_ORDER_LINE'] = '#NAME##PRICE#'; 15 | $MESS['MB_OH_ITEM_NAME'] = 'Product Name'; 16 | $MESS['MB_OH_ITEM_PRICE'] = 'Price'; 17 | $MESS['MB_OH_MORE'] = 'Still'; 18 | -------------------------------------------------------------------------------- /install/components/mindbox/order.history/templates/.default/lang/ru/template.php: -------------------------------------------------------------------------------- 1 | Заказ № #ID# от #CREATED#.

'; 11 | $MESS['MB_OH_ORDER_SPENT'] = 'Для оплаты заказа было использовано #SPENT# балл#END#.'; 12 | $MESS['MB_OH_ORDER_ACUIRED'] = 'За заказ начислено #ACUIRED# балл#END#.'; 13 | $MESS['MB_OH_ENDINGS_ARRAY'] = ['', 'а', 'ов']; 14 | $MESS['MB_OH_ORDER_LINE'] = '#NAME##PRICE#'; 15 | $MESS['MB_OH_ITEM_NAME'] = 'Название товара'; 16 | $MESS['MB_OH_ITEM_PRICE'] = 'Цена'; 17 | $MESS['MB_OH_MORE'] = 'Ещё'; 18 | -------------------------------------------------------------------------------- /install/components/mindbox/order.history/templates/.default/script.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | $('#mindbox-order-history--load-more').on('click', function () { 3 | let $moreButton = $('#mindbox-order-more'); 4 | let $targetForLoader = $moreButton; 5 | 6 | loader.show($targetForLoader); 7 | 8 | let page = parseInt($moreButton.data('page')) + 1; 9 | 10 | let request = BX.ajax.runComponentAction('mindbox:order.history', 'page', { 11 | mode: 'class', 12 | data: { 13 | page: page, 14 | } 15 | }); 16 | 17 | request.then(function (response) { 18 | loader.hide($targetForLoader); 19 | 20 | if (response.data.type === 'error') { 21 | $moreButton.hide(); 22 | } 23 | 24 | if (response.data.type === 'success') { 25 | $moreButton.data('page', response.data.page); 26 | 27 | if (response.data.html === '') { 28 | $moreButton.hide(); 29 | } 30 | 31 | if (response.data.more === false) { 32 | $moreButton.hide(); 33 | } 34 | 35 | $('#mindbox-orders-history').append(response.data.html); 36 | } 37 | }); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /install/components/mindbox/order.history/templates/.default/template.php: -------------------------------------------------------------------------------- 1 | addJs("/bitrix/js/mindbox/jquery.inputmask.bundle.js"); 14 | Asset::getInstance()->addJs("/bitrix/js/mindbox/script.js"); 15 | Asset::getInstance()->addCss("/bitrix/css/mindbox/style.css"); 16 | ?> 17 | 18 |

19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | $order['id'], '#CREATED#' => $order['created']]) ?> 28 | 29 |

30 | 31 | $order['spentBonuses'], 33 | '#END#' => Helper::getNumEnding( 34 | $order['spentBonuses'], 35 | GetMessage('MB_OH_ENDINGS_ARRAY') 36 | ) 37 | ]); ?> 38 | 39 | 40 | $order['acuiredBonuses'], 42 | '#END#' => Helper::getNumEnding( 43 | $order['acuiredBonuses'], 44 | GetMessage('MB_OH_ENDINGS_ARRAY') 45 | ) 46 | ]); ?> 47 | 48 |

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | $line['link'], '#NAME#' => $line['name'], '#PRICE#' => $line['price']] 59 | ); ?> 60 | 61 |
62 | 63 |
64 | 65 |
66 |
67 |
68 | 69 | 70 | 71 |
-------------------------------------------------------------------------------- /install/components/mindbox/phone.confirm/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/phone.confirm/class.php: -------------------------------------------------------------------------------- 1 | 'mindbox.marketing'])); 41 | return; 42 | } 43 | } catch (LoaderException $e) { 44 | ShowError(GetMessage('MB_PC_MODULE_NOT_INCLUDED', ['#MODULE#' => 'mindbox.marketing'])); 45 | return; 46 | } 47 | 48 | $this->userInfo = $this->getUser(); 49 | if (!$this->userInfo['UF_PHONE_CONFIRMED'] && !empty($this->userInfo['PERSONAL_PHONE'])) { 50 | $this->mindbox = Options::getConfig(); 51 | } 52 | } 53 | 54 | public function executeComponent() 55 | { 56 | $this->arResult['USER_INFO']['UF_PHONE_CONFIRMED'] = $this->userInfo['UF_PHONE_CONFIRMED']; 57 | $this->arResult['USER_INFO']['PERSONAL_PHONE'] = $this->userInfo['PERSONAL_PHONE']; 58 | $this->includeComponentTemplate(); 59 | } 60 | 61 | 62 | public function configureActions() 63 | { 64 | return Ajax::configureActions($this->actions); 65 | } 66 | 67 | public function checkCodeAction($code) 68 | { 69 | if (!$this->mindbox) { 70 | return Ajax::errorResponse(GetMessage('MB_PC_BAD_MODULE_SETTING')); 71 | } 72 | 73 | $code = htmlspecialcharsEx(trim($code)); 74 | if (!$code) { 75 | return Ajax::errorResponse(GetMessage('MB_PC_EMPTY')); 76 | } 77 | 78 | global $USER; 79 | $customer = new CustomerRequestDTO(['ids' => ['mindboxId' => $this->getMindboxId()]]); 80 | $sms = new SmsConfirmationRequestDTO(['code' => $code]); 81 | 82 | try { 83 | $check = $this->mindbox->customer() 84 | ->confirmMobile($customer, $sms, Options::getOperationName('confirmMobile'))->sendRequest(); 85 | } catch (MindboxClientException $e) { 86 | return Ajax::errorResponse(GetMessage('MB_PC_ERROR_CONFIRM')); 87 | } 88 | 89 | $confirmation = $check->getResult()->getSmsConfirmation(); 90 | if(!$confirmation) { 91 | return Ajax::errorResponse(GetMessage('MB_PC_EMPTY')); 92 | } 93 | $status = $confirmation->getProcessingStatus(); 94 | 95 | if ($status === 'MobilePhoneConfirmed') { 96 | $USER->Update($this->userInfo['ID'], ['UF_PHONE_CONFIRMED' => '1']); 97 | return [ 98 | 'type' => 'success', 99 | 'message' => GetMessage('MB_PC_SUCCESS_CONFIRM') 100 | ]; 101 | } 102 | 103 | return [ 104 | 'type' => 'error', 105 | 'message' => GetMessage('MB_PC_INCORRECT_CODE') 106 | ]; 107 | } 108 | 109 | public function resendCodeAction() 110 | { 111 | if (!$this->mindbox) { 112 | return Ajax::errorResponse(GetMessage('MB_PC_BAD_MODULE_SETTING')); 113 | } 114 | $customer = new CustomerRequestDTO(['ids' => ['mindboxId' => $this->getMindboxId()]]); 115 | try { 116 | $this->mindbox->customer()->resendConfirmationCode($customer, 117 | Options::getOperationName('resendConfirmationCode'))->sendRequest(); 118 | } catch (MindboxClientException $e) { 119 | return Ajax::errorResponse($e); 120 | } 121 | } 122 | 123 | protected function getUser() 124 | { 125 | global $USER; 126 | 127 | $rsUser = UserTable::getList( 128 | [ 129 | 'select' => ['PERSONAL_PHONE', 'UF_MINDBOX_ID', 'UF_PHONE_CONFIRMED', 'ID'], 130 | 'filter' => ['ID' => $USER->GetID()] 131 | ] 132 | )->fetch(); 133 | 134 | 135 | if(!$this->getMindboxId()) { 136 | return $rsUser; 137 | } 138 | 139 | 140 | $mindbox = Options::getConfig(); 141 | $request = $mindbox->getClientV3()->prepareRequest('POST', 142 | Options::getOperationName('getCustomerInfo'), 143 | new DTO([ 144 | 'customer' => [ 145 | 'ids' => [ 146 | 'mindboxId' => $this->getMindboxId() 147 | ] 148 | ] 149 | ])); 150 | 151 | try { 152 | $response = $request->sendRequest()->getResult(); 153 | } catch (MindboxClientException $e) { 154 | return $rsUser; 155 | } 156 | 157 | $customer = $response->getCustomer(); 158 | if ($customer && $customer->getProcessingStatus() === 'Found') { 159 | $pending = $customer->getPendingMobilePhone(); 160 | if ($pending) { 161 | $rsUser[ 'UF_PHONE_CONFIRMED' ] = false; 162 | } else { 163 | $rsUser[ 'UF_PHONE_CONFIRMED' ] = $customer->getIsMobilePhoneConfirmed(); 164 | } 165 | } 166 | 167 | 168 | return $rsUser; 169 | } 170 | 171 | private function getMindboxId() 172 | { 173 | global $USER; 174 | 175 | return Helper::getMindboxId($USER->GetID()); 176 | } 177 | } -------------------------------------------------------------------------------- /install/components/mindbox/phone.confirm/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | #PHONE# successfully verified'; 4 | $MESS['MB_PC_CONFIRM_CODE'] = 'Confirmation code'; 5 | $MESS['MB_PC_RESEND_BUTTON'] = 'Resend'; 6 | $MESS['MB_PC_CHECK_CODE'] = 'Check code'; -------------------------------------------------------------------------------- /install/components/mindbox/phone.confirm/templates/.default/lang/ru/template.php: -------------------------------------------------------------------------------- 1 | #PHONE#, успешно подтвержден'; 4 | $MESS['MB_PC_CONFIRM_CODE'] = 'Код подтверждения'; 5 | $MESS['MB_PC_RESEND_BUTTON'] = 'Переотправить'; 6 | $MESS['MB_PC_CHECK_CODE'] = 'Проверить код'; 7 | -------------------------------------------------------------------------------- /install/components/mindbox/phone.confirm/templates/.default/script.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | $('#mindbox-phone-confirm--resend').on('click', function () { 3 | let request = BX.ajax.runComponentAction('mindbox:phone.confirm', 'resendCode', { 4 | mode: 'class', 5 | }); 6 | }); 7 | 8 | $('#mindbox-phone-confirm #submit-button').on('click', function (e) { 9 | e.preventDefault(); 10 | 11 | loader.show($('#mindbox-phone-confirm')); 12 | 13 | let code = $('#mindbox-code').val(); 14 | 15 | let request = BX.ajax.runComponentAction('mindbox:phone.confirm', 'checkCode', { 16 | mode: 'class', 17 | data: { 18 | code: code 19 | } 20 | }); 21 | 22 | request.then(function (response) { 23 | loader.hide($('#mindbox-phone-confirm')); 24 | 25 | if (response.data.type === 'error') { 26 | $('#mindbox-phone-confirm-error').text(response.data.message).show(); 27 | } else if (response.data.type === 'success') { 28 | $('#mindbox-phone-confirm-error').hide(); 29 | $('#mindbox-phone-confirm-success').text(response.data.message).show(); 30 | } 31 | }) 32 | }) 33 | }); -------------------------------------------------------------------------------- /install/components/mindbox/phone.confirm/templates/.default/template.php: -------------------------------------------------------------------------------- 1 | addJs("/bitrix/js/mindbox/jquery.inputmask.bundle.js"); 13 | Asset::getInstance()->addJs("/bitrix/js/mindbox/script.js"); 14 | Asset::getInstance()->addCss("/bitrix/css/mindbox/style.css"); 15 | ?> 16 | 17 | IsAuthorized()) : ?> 18 |
19 | 20 |
21 | 22 |
23 | 24 |
25 | $arResult['USER_INFO']['PERSONAL_PHONE']])?> 26 |
27 | 28 |
29 | 30 |
31 |
32 | 33 |
34 |
35 |
36 |
37 | 38 |
39 | 40 |
41 |
42 | 43 | 44 | 48 |
49 |
50 |
51 | 52 |
53 |
54 |
55 | 56 |
57 |
58 |
59 |
60 | 61 |
62 | -------------------------------------------------------------------------------- /install/components/mindbox/product.bonus/class.php: -------------------------------------------------------------------------------- 1 | 'mindbox.marketing'])); 28 | return; 29 | } 30 | } catch (LoaderException $e) { 31 | ShowError(GetMessage('MB_AUS_MODULE_NOT_INCLUDED', ['#MODULE#' => 'mindbox.marketing'])); 32 | ; 33 | return; 34 | } 35 | } 36 | 37 | public function configureActions() 38 | { 39 | return Ajax::configureActions($this->actions); 40 | } 41 | 42 | public function onPrepareComponentParams($arParams) 43 | { 44 | return $arParams; 45 | } 46 | 47 | public function changeProductAction($productId, $price) 48 | { 49 | $productCache = \Mindbox\Components\CalculateProductData::getProductCache($productId); 50 | 51 | if (!empty($productCache)) { 52 | $return = [ 53 | 'MINDBOX_BONUS' => $productCache['MINDBOX_BONUS'], 54 | ]; 55 | } else { 56 | $objCalculateProductData = new \Mindbox\Components\CalculateProductData(); 57 | $calcData = $objCalculateProductData->getCalculateProductsData([ 58 | $productId => ['price' => $price, 'id' => $productId] 59 | ]); 60 | 61 | $return = current($calcData); 62 | } 63 | 64 | return [ 65 | 'type' => 'success', 66 | 'return' => $return, 67 | ]; 68 | } 69 | 70 | protected function createPlaceholder() 71 | { 72 | $prefix = self::PLACEHOLDER_PREFIX; 73 | return "{{{$prefix}|{$this->arParams['ID']}|{$this->arParams['PRICE']}|{$this->getLabelHtml()}|{$this->getValueHtml()}}}"; 74 | } 75 | 76 | protected function getLabelHtml() 77 | { 78 | return self::LABEL_POSITION . '::' . $this->arParams['LABEL'] . ''; 79 | } 80 | 81 | protected function getValueHtml() 82 | { 83 | return ':value:'; 84 | } 85 | 86 | public function executeComponent() 87 | { 88 | $productCache = \Mindbox\Components\CalculateProductData::getHtmlProductCache($this->arParams['ID'], 'MINDBOX_BONUS'); 89 | 90 | if (!empty($productCache)) { 91 | $this->arResult['MINDBOX_BONUS'] = $productCache['MINDBOX_BONUS']; 92 | } else { 93 | $this->arResult['MINDBOX_BONUS'] = $this->createPlaceholder(); 94 | } 95 | 96 | $this->includeComponentTemplate(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /install/components/mindbox/product.bonus/templates/.default/script.js: -------------------------------------------------------------------------------- 1 | if (typeof window.loadMindboxProductBonusComponent === 'undefined') { 2 | window.loadMindboxProductBonusComponent = true; 3 | 4 | document.addEventListener('DOMContentLoaded', function(){ 5 | let productPriceItems = document.querySelectorAll('.mindbox-product-bonus'); 6 | 7 | productPriceItems.forEach(function (item) { 8 | item.addEventListener("changeProductBonus", function(event) { 9 | let target = event.target; 10 | let productParams = event.detail; 11 | let request = BX.ajax.runComponentAction('mindbox:product.bonus', 'changeProduct', { 12 | mode:'class', 13 | data: { 14 | productId: productParams.productId, 15 | price: productParams.price, 16 | } 17 | }); 18 | 19 | request.then(function (response) { 20 | 21 | if (response.data.type === 'success') { 22 | if (response.data.return.hasOwnProperty('MINDBOX_BONUS')) { 23 | target.querySelector('.mindbox-product-bonus__value').innerText = response.data.return['MINDBOX_BONUS']; 24 | } 25 | } 26 | }); 27 | }); 28 | }); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /install/components/mindbox/product.bonus/templates/.default/style.css: -------------------------------------------------------------------------------- 1 | .mindbox-product-bonus { 2 | font-size: 13px; 3 | text-align: center; 4 | } 5 | 6 | .mindbox-product-bonus__value { 7 | font-weight: bold; 8 | color: #62be1f; 9 | } 10 | 11 | .mindbox-product-bonus__label { 12 | color: #000; 13 | font-size: 13px; 14 | text-align: center; 15 | font-weight: normal; 16 | } -------------------------------------------------------------------------------- /install/components/mindbox/product.bonus/templates/.default/template.php: -------------------------------------------------------------------------------- 1 | 8 |
9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /install/components/mindbox/product.bonus/templates/.default/view.php: -------------------------------------------------------------------------------- 1 | ShowViewContent($arResult['INTEGRATION_KEY']); 8 | } 9 | -------------------------------------------------------------------------------- /install/components/mindbox/product.price/class.php: -------------------------------------------------------------------------------- 1 | 'mindbox.marketing'])); 31 | return; 32 | } 33 | } catch (LoaderException $e) { 34 | ShowError(GetMessage('MB_AUS_MODULE_NOT_INCLUDED', ['#MODULE#' => 'mindbox.marketing'])); 35 | ; 36 | return; 37 | } 38 | } 39 | 40 | public function configureActions() 41 | { 42 | return Ajax::configureActions($this->actions); 43 | } 44 | 45 | public function onPrepareComponentParams($arParams) 46 | { 47 | return $arParams; 48 | } 49 | 50 | public function changeProductAction($productId, $price) 51 | { 52 | $productCache = \Mindbox\Components\CalculateProductData::getProductCache($productId); 53 | $useCache = false; 54 | 55 | if (!empty($productCache)) { 56 | $useCache = true; 57 | 58 | $return = [ 59 | 'MINDBOX_PRICE' => $productCache['MINDBOX_PRICE'], 60 | 'MINDBOX_OLD_PRICE' => $productCache['MINDBOX_OLD_PRICE'] 61 | ]; 62 | } else { 63 | $objCalculateProductData = new \Mindbox\Components\CalculateProductData(); 64 | $calcData = $objCalculateProductData->getCalculateProductsData([ 65 | $productId => ['price' => $price, 'id' => $productId] 66 | ]); 67 | 68 | $return = current($calcData); 69 | } 70 | 71 | return [ 72 | 'type' => 'success', 73 | 'return' => $return, 74 | 'cache' => $useCache 75 | ]; 76 | } 77 | 78 | protected function createPlaceholder($prefix): string 79 | { 80 | return "{{{$prefix}|{$this->arParams['ID']}|{$this->arParams['PRICE']}}}"; 81 | } 82 | 83 | protected function createPricePlaceholder(): string 84 | { 85 | $prefix = self::PLACEHOLDER_PRICE_PREFIX; 86 | return "{{{$prefix}|{$this->arParams['ID']}|{$this->arParams['PRICE']}|{$this->getLabelHtml()}|{$this->getPriceValueHtml()}}}"; 87 | } 88 | 89 | protected function createOldPricePlaceholder(): string 90 | { 91 | $prefix = self::PLACEHOLDER_OLD_PRICE_PREFIX; 92 | return "{{{$prefix}|{$this->arParams['ID']}|{$this->arParams['PRICE']}|after::|{$this->getOldPriceValueHtml()}}}"; 93 | } 94 | 95 | protected function getLabelHtml() 96 | { 97 | return self::LABEL_POSITION . '::' . $this->arParams['CURRENCY'] . ''; 98 | } 99 | 100 | protected function getPriceValueHtml(): string 101 | { 102 | return ':value:'; 103 | } 104 | 105 | protected function getOldPriceValueHtml(): string 106 | { 107 | return ':value:'; 108 | } 109 | 110 | 111 | public function executeComponent() 112 | { 113 | $productCache = CalculateProductData::getHtmlProductCache($this->arParams['ID'], 'MINDBOX_PRICE'); 114 | $this->arResult['PRODUCT_ID'] = $this->arParams['ID']; 115 | 116 | if (!empty($productCache)) { 117 | $this->arResult['MINDBOX_PRICE'] = $productCache; 118 | $this->arResult['MINDBOX_OLD_PRICE'] = CalculateProductData::getHtmlProductCache($this->arParams['ID'], 'MINDBOX_OLD_PRICE'); 119 | } else { 120 | $this->arResult['MINDBOX_PRICE'] = $this->createPricePlaceholder(); 121 | $this->arResult['MINDBOX_OLD_PRICE'] = $this->createOldPricePlaceholder(); 122 | } 123 | 124 | $this->includeComponentTemplate(); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /install/components/mindbox/product.price/templates/.default/script.js: -------------------------------------------------------------------------------- 1 | if (typeof window.loadMindboxProductPriceComponent === 'undefined') { 2 | window.loadMindboxProductPriceComponent = true; 3 | 4 | document.addEventListener('DOMContentLoaded', function(){ 5 | let productPriceItems = document.querySelectorAll('.mindbox-product-price'); 6 | 7 | productPriceItems.forEach(function (item) { 8 | item.addEventListener("changeProductPrice", function(event) { 9 | let target = event.target; 10 | let productParams = event.detail; 11 | let request = BX.ajax.runComponentAction('mindbox:product.price', 'changeProduct', { 12 | mode:'class', 13 | data: { 14 | productId: productParams.productId, 15 | price: productParams.price, 16 | 17 | } 18 | }); 19 | 20 | request.then(function (response) { 21 | 22 | if (response.data.type === 'success') { 23 | if (response.data.return.hasOwnProperty('MINDBOX_PRICE')) { 24 | target.querySelector('.mindbox-product-price__price').innerText = response.data.return['MINDBOX_PRICE']; 25 | } 26 | 27 | if (!response.data.return.hasOwnProperty('MINDBOX_OLD_PRICE')) { 28 | target.querySelector('.mindbox-product-price__discount').innerText = ''; 29 | } else { 30 | target.querySelector('.mindbox-product-price__discount').innerText = response.data.return['MINDBOX_OLD_PRICE']; 31 | } 32 | } 33 | }); 34 | }); 35 | }); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /install/components/mindbox/product.price/templates/.default/style.css: -------------------------------------------------------------------------------- 1 | .mindbox-product-price { 2 | font-size: 18px; 3 | font-weight: bold; 4 | line-height: 15px; 5 | color: #1d2029; 6 | } 7 | 8 | .mindbox-product-price__discount { 9 | text-decoration: line-through; 10 | font-size: 14px; 11 | font-weight: normal; 12 | } -------------------------------------------------------------------------------- /install/components/mindbox/product.price/templates/.default/template.php: -------------------------------------------------------------------------------- 1 | 8 |
9 | 10 | 11 | 12 |
13 | -------------------------------------------------------------------------------- /install/components/mindbox/sub.edit/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/sub.edit/class.php: -------------------------------------------------------------------------------- 1 | 'mindbox.marketing'])); 41 | return; 42 | } 43 | } catch (LoaderException $e) { 44 | ShowError(GetMessage('MB_SE_MODULE_NOT_INCLUDED', ['#MODULE#' => 'mindbox.marketing'])); 45 | return; 46 | } 47 | 48 | $this->userInfo = $this->getUser(); 49 | $this->mindbox = Options::getConfig(); 50 | } 51 | 52 | public function configureActions() 53 | { 54 | return Ajax::configureActions($this->actions); 55 | } 56 | 57 | public function saveAction($fields) 58 | { 59 | if (!$this->mindbox) { 60 | return Ajax::errorResponse(GetMessage('MB_SE_BAD_MODULE_SETTING')); 61 | } 62 | $customer = new CustomerRequestDTO([ 63 | 'ids' => ['mindboxId' => $this->getMindboxId()], 64 | ]); 65 | 66 | $subscriptions = [ 67 | new SubscriptionRequestDTO([ 68 | 'pointOfContact' => 'Email', 69 | 'isSubscribed' => $fields['SUBSCRIPTIONS']['Email'] 70 | ]), 71 | 72 | new SubscriptionRequestDTO([ 73 | 'pointOfContact' => 'Sms', 74 | 'isSubscribed' => $fields['SUBSCRIPTIONS']['Sms'] 75 | ]), 76 | ]; 77 | 78 | $customer->setSubscriptions($subscriptions); 79 | 80 | try { 81 | $this->mindbox->customer()->edit($customer, Options::getOperationName('edit'), true, true)->sendRequest(); 82 | } catch (MindboxUnavailableException $e) { 83 | $lastResponse = $this->mindbox->customer()->getLastResponse(); 84 | 85 | if ($lastResponse) { 86 | $request = $lastResponse->getRequest(); 87 | QueueTable::push($request); 88 | } 89 | } catch (MindboxClientException $e) { 90 | return Ajax::errorResponse(GetMessage('MB_SE_ERROR_SUB')); 91 | } 92 | 93 | return [ 94 | 'type' => 'success', 95 | 'message' => GetMessage('MB_SE_SUCCESS_SUB') 96 | ]; 97 | } 98 | 99 | protected function getSubscriptions() 100 | { 101 | $subscriptions = ['Email' => false, 'Sms' => false]; 102 | 103 | $request = $this->mindbox->getClientV3()->prepareRequest( 104 | 'POST', 105 | Options::getOperationName('getSubscriptions'), 106 | new DTO(['customer' => ['email' => $this->userInfo['EMAIL']]]) 107 | ); 108 | 109 | try { 110 | $response = $request->sendRequest()->getResult(); 111 | if ($response->getCustomer()) { 112 | foreach ($response->getCustomer()->getSubscriptions() as $subscription) { 113 | $pointOfContact = $subscription->getPointOfContact(); 114 | $isSubscribed = $subscription->getIsSubscribed(); 115 | if ($isSubscribed) { 116 | $subscriptions[$pointOfContact] = true; 117 | } 118 | } 119 | } 120 | } catch (MindboxClientException $e) { 121 | } 122 | 123 | $this->arResult['SUBSCRIPTIONS'] = $subscriptions; 124 | } 125 | 126 | protected function getUser() 127 | { 128 | global $USER; 129 | 130 | $rsUser = UserTable::getList( 131 | [ 132 | 'select' => ['UF_MINDBOX_ID', 'EMAIL', 'ID'], 133 | 'filter' => ['ID' => $USER->GetID()] 134 | ] 135 | )->fetch(); 136 | 137 | return $rsUser; 138 | } 139 | 140 | public function executeComponent() 141 | { 142 | $this->getSubscriptions(); 143 | $this->includeComponentTemplate(); 144 | } 145 | 146 | private function getMindboxId() 147 | { 148 | global $USER; 149 | 150 | return Helper::getMindboxId($USER->GetID()); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /install/components/mindbox/sub.edit/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | addJs("/bitrix/js/mindbox/jquery.inputmask.bundle.js"); 10 | Asset::getInstance()->addJs("/bitrix/js/mindbox/script.js"); 11 | Asset::getInstance()->addCss("/bitrix/css/mindbox/style.css"); 12 | ?> 13 | 14 | IsAuthorized()): ?> 15 |
16 |
17 |
18 |
19 | 20 |
21 | 22 |
23 |
24 | 29 |
30 |
31 | 36 |
37 |
38 |
39 | 40 |
41 |
42 | 43 |
44 |
45 |
46 |
47 | 48 |
49 |
50 | -------------------------------------------------------------------------------- /install/components/mindbox/subscription/.description.php: -------------------------------------------------------------------------------- 1 | GetMessage('NAME'), 6 | "DESCRIPTION" => "", 7 | "SORT" => 10, 8 | "CACHE_PATH" => "Y", 9 | "PATH" => array( 10 | "ID" => "mindbox", 11 | ), 12 | "COMPLEX" => "N", 13 | ); 14 | -------------------------------------------------------------------------------- /install/components/mindbox/subscription/class.php: -------------------------------------------------------------------------------- 1 | 'mindbox.marketing']));; 42 | return; 43 | } 44 | } catch (LoaderException $e) { 45 | ShowError(GetMessage('MB_SU_MODULE_NOT_INCLUDED', ['#MODULE#' => 'mindbox.marketing']));; 46 | return; 47 | } 48 | 49 | $this->mindbox = Options::getConfig(); 50 | } 51 | 52 | public function configureActions() 53 | { 54 | return Ajax::configureActions($this->actions); 55 | } 56 | 57 | public function subscribeAction($email) 58 | { 59 | if (!$this->mindbox) { 60 | return Ajax::errorResponse(GetMessage('MB_SU_BAD_MODULE_SETTING')); 61 | } 62 | $email = htmlspecialcharsEx(trim($email)); 63 | if (empty($email)) { 64 | return Ajax::errorResponse('Incorrect email'); 65 | } 66 | 67 | $customer = new CustomerRequestDTO(['email' => $email]); 68 | $subscripton = new SubscriptionRequestDTO(['pointOfContact' => 'Email']); 69 | $customer->setSubscriptions([$subscripton]); 70 | try { 71 | $this->mindbox->customer()->subscribe($customer, 72 | Options::getOperationName('subscribe'), true)->sendRequest(); 73 | 74 | return [ 75 | 'type' => 'success', 76 | 'message' => GetMessage('MB_SU_SUCCESS') 77 | ]; 78 | } catch (MindboxClientException $e) { 79 | $request = $this->mindbox->customer()->getRequest(); 80 | if ($request) { 81 | QueueTable::push($request); 82 | } 83 | return [ 84 | 'type' => 'queue', 85 | 'message' => GetMessage('MB_SU_QUEUE') 86 | ]; 87 | } 88 | 89 | } 90 | 91 | public function executeComponent() 92 | { 93 | $this->includeComponentTemplate(); 94 | } 95 | } -------------------------------------------------------------------------------- /install/components/mindbox/subscription/lang/en/.description.php: -------------------------------------------------------------------------------- 1 | addJs("/bitrix/js/mindbox/jquery.inputmask.bundle.js"); 11 | Asset::getInstance()->addJs("/bitrix/js/mindbox/script.js"); 12 | Asset::getInstance()->addCss("/bitrix/css/mindbox/style.css"); 13 | ?> 14 | 15 |
16 |
17 |
18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 |
26 |
27 |
28 | 29 |
30 |
31 | -------------------------------------------------------------------------------- /install/images/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mindbox-cloud/bitrix/c399ebc64aafab633dc04ded16154db67849e233/install/images/loader.gif -------------------------------------------------------------------------------- /install/js/script.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | var mindboxSettingDefault = { 3 | jsMask: function () { 4 | $('.js-mask').each(function () { 5 | let $input = $(this), 6 | inputType = $input.data('type'), 7 | maskOptions = {}; 8 | 9 | switch (inputType) { 10 | case 'phone': { 11 | maskOptions.mask = '+7 (999) 999-99-99'; 12 | 13 | break; 14 | } 15 | case 'email': { 16 | maskOptions.alias = 'email'; 17 | maskOptions.showMaskOnHover = false; 18 | maskOptions.placeholder = ''; 19 | maskOptions.jitMasking = true; 20 | 21 | break; 22 | } 23 | case 'decimal': { 24 | maskOptions.alias = 'decimal'; 25 | maskOptions.groupSeparator = ''; 26 | maskOptions.autoGroup = true; 27 | maskOptions.rightAlign = false; 28 | 29 | break; 30 | } 31 | case 'date': { 32 | maskOptions.alias = 'datetime'; 33 | maskOptions.inputFormat = 'dd.mm.yyyy'; 34 | } 35 | } 36 | 37 | $input.inputmask(maskOptions); 38 | }); 39 | }, 40 | 41 | jsTimer: function () { 42 | let _this = this; 43 | 44 | $('.js-auth-code').each(function () { 45 | let authButton = {}; 46 | 47 | authButton.$elem = $(this), 48 | authButton.$elemText = authButton.$elem.find('.js-auth-code-text'), 49 | authButton.$elemTimer = authButton.$elem.find('.js-auth-code-timer'); 50 | 51 | authButton.$elem.on('click', function () { 52 | let lastTime = new Date().getTime(); 53 | 54 | _this._timer(lastTime, authButton); 55 | }); 56 | }); 57 | }, 58 | 59 | _timer: function (lastTime, authButton) { 60 | if (!lastTime) return; 61 | 62 | let intervalID; 63 | 64 | startTimer(lastTime); 65 | 66 | function startTimer(lastTime) { 67 | authButton.$elem.attr('disabled', true); 68 | authButton.$elemTimer.html('(30)'); 69 | 70 | intervalID = setInterval(function () { 71 | timer(lastTime); 72 | }, 1000); 73 | } 74 | 75 | function timer(endTime) { 76 | let nowTime = new Date().getTime(), 77 | secondsLeft = Math.floor((nowTime - lastTime) / 1000), 78 | secondsRemaining = 30 - secondsLeft; 79 | 80 | if (secondsRemaining) { 81 | authButton.$elemTimer.html('(' + secondsRemaining + ')'); 82 | } else { 83 | clearInterval(intervalID); 84 | authButton.$elemTimer.html(''); 85 | authButton.$elem.attr('disabled', false); 86 | } 87 | } 88 | }, 89 | 90 | jsClearField: function () { 91 | $('.js-clear-field').each(function () { 92 | let $clearField = $(this), 93 | $clearInput = $clearField.find('.js-clear-field-input'), 94 | $clearBtn = $clearField.find('.js-clear-field-btn'); 95 | 96 | toggleValue($clearInput, $clearBtn); 97 | 98 | $clearInput.on('input', function () { 99 | toggleValue($(this), $clearBtn); 100 | }); 101 | 102 | $clearBtn.on('click', function () { 103 | $clearInput.val(''); 104 | $(this).hide(); 105 | }); 106 | }); 107 | } 108 | }; 109 | 110 | function toggleValue($clearInput, $clearBtn) { 111 | let value = $clearInput.val(); 112 | 113 | if (value) { 114 | $clearBtn.show(); 115 | } else { 116 | $clearBtn.hide(); 117 | } 118 | } 119 | 120 | window.loader = { 121 | show: function ($target) { 122 | $('
', {class: 'loader'}).appendTo($target); 123 | }, 124 | 125 | hide: function ($target) { 126 | $target.find('.loader').remove(); 127 | } 128 | }; 129 | 130 | mindboxSettingDefault.jsMask(); 131 | mindboxSettingDefault.jsTimer(); 132 | mindboxSettingDefault.jsClearField(); 133 | }); -------------------------------------------------------------------------------- /install/js/tracker.js: -------------------------------------------------------------------------------- 1 | mindbox = window.mindbox || function() { mindbox.queue.push(arguments); }; 2 | mindbox.queue = mindbox.queue || []; 3 | mindbox('create', { 4 | endpointId: '#endpointId#' 5 | }); 6 | -------------------------------------------------------------------------------- /install/js/tracker.js.orig: -------------------------------------------------------------------------------- 1 | mindbox = window.mindbox || function() { mindbox.queue.push(arguments); }; 2 | mindbox.queue = mindbox.queue || []; 3 | mindbox('create', { 4 | endpointId: '#endpointId#' 5 | }); -------------------------------------------------------------------------------- /install/step1.php: -------------------------------------------------------------------------------- 1 | GetException()) { 9 | echo CAdminMessage::ShowMessage(Array( 10 | "TYPE" => "ERROR", 11 | "MESSAGE" => GetMessage("MOD_INST_ERR"), 12 | "DETAILS" => $ex->GetString(), 13 | "HTML" => true, 14 | )); 15 | } else { 16 | echo CAdminMessage::ShowNote(GetMessage("MOD_INST_OK")); 17 | echo CAdminMessage::ShowMessage(array( 18 | "TYPE" => "WARNING", 19 | "MESSAGE" => GetMessage("SETTINGS_REMINDER"), 20 | "DETAILS" => '', 21 | "HTML" => true, 22 | )); 23 | } 24 | ?> 25 |
26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 |
-------------------------------------------------------------------------------- /install/unstep1.php: -------------------------------------------------------------------------------- 1 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 |

17 | "> 18 |
19 | -------------------------------------------------------------------------------- /install/unstep2.php: -------------------------------------------------------------------------------- 1 | GetException()) 7 | echo CAdminMessage::ShowMessage(array( 8 | "TYPE" => "ERROR", 9 | "MESSAGE" => GetMessage("MOD_UNINST_ERR"), 10 | "DETAILS" => $ex->GetString(), 11 | "HTML" => true, 12 | )); 13 | else 14 | echo CAdminMessage::ShowNote(GetMessage("MOD_UNINST_OK")); 15 | ?> 16 | 17 |
18 | 19 | "> 20 | -------------------------------------------------------------------------------- /install/version.php: -------------------------------------------------------------------------------- 1 | "2.7.0", 4 | "VERSION_DATE" => "2021-04-13 10:00:00", 5 | "MODULE_NAME" => GetMessage("MINDBOX_MODULE_NAME"), 6 | "MODULE_DESCRIPTION" => GetMessage("MODULE_DESCRIPTION") 7 | ); 8 | -------------------------------------------------------------------------------- /lang/en/install/index.php: -------------------------------------------------------------------------------- 1 | refresh the page to update prices.'; 13 | $MESS['MB_ORDER_CANNOT_BE_CHANGED'] = 'A paid order cannot be changed'; 14 | -------------------------------------------------------------------------------- /lang/en/lib/ExtensionCartRulesActions.php: -------------------------------------------------------------------------------- 1 | module. Docs for Mindbox API'; 23 | $MESS['MODE'] = "Mode"; 24 | $MESS['BRAND'] = "Brand"; 25 | $MESS['IDENTIFIERS'] = "Identifiers"; 26 | $MESS['EVENT_LIST_GROUP'] = 'Event list'; 27 | $MESS['ENABLE_EVENT_LIST'] = 'Enable events'; 28 | $MESS['CONNECTION_SETTINGS'] = "Connection settings"; 29 | $MESS['PRODUCT_SETTINGS'] = "Products settings"; 30 | $MESS['SITE_PROTOCOL'] = 'Use HTTPS when exporting'; 31 | $MESS['CATALOG_PROPS'] = 'Product properties includes in yml'; 32 | $MESS['CATALOG_OFFER_PROPS'] = 'Offer properties includes in yml'; 33 | $MESS['ORDER_SETTINGS'] = 'Order settings'; 34 | $MESS['BITRIX_FIELDS'] = 'Bitrix Field'; 35 | $MESS['MINDBOX_FIELDS'] = 'Mindbox Field'; 36 | $MESS['BUTTON_ADD'] = 'Add'; 37 | $MESS['BUTTON_DELETE'] = 'Delete'; 38 | $MESS['MODULE_VERSION'] = 'Module version '; 39 | $MESS['STANDARD'] = 'Standard'; 40 | $MESS['BRAND'] = "Brand"; 41 | $MESS['SYSTEM_NAME'] = "System name"; 42 | $MESS['LOYALTY'] = 'Loyality'; 43 | $MESS['SAVE'] = 'Save'; 44 | $MESS['CLIENTS'] = 'Clients settings'; 45 | $MESS['API_DOMAIN'] = 'API Domain'; 46 | $MESS['COMMON_SETTINGS'] = 'Common settings'; 47 | $MESS['FEED'] = 'Yml-feed settings'; 48 | $MESS['YML_CHUNK_SIZE'] = 'Number of items to upload in one step'; 49 | $MESS['CLIENTS'] = 'Clients settings'; 50 | $MESS['ORDERS'] = 'Orders settings'; 51 | $MESS['ADDITIONAL_FIELDS_SETTINGS'] = 'Additional fields settings'; 52 | $MESS['CONTINUE_USER_GROUPS'] = 'Disable order processing for a group of users'; 53 | $MESS['CONTINUE_USER_GROUPS_TOOLTIP'] = 'Users of these groups will not participate in processing '; 54 | -------------------------------------------------------------------------------- /lang/ru/install/index.php: -------------------------------------------------------------------------------- 1 | обновите страницу для актуализации цен.'; 13 | $MESS['MB_ORDER_CANNOT_BE_CHANGED'] = 'Заказ с проведенной оплатой не может быть изменен'; 14 | $MESS['MB_CART_PROMOCODE_NOT_FOUND'] = 'Промокод не найден'; 15 | $MESS['MB_CART_PROMOCODE_ERR'] = 'Нельзя применить данный промокод'; 16 | $MESS['MB_CART_PROMO_USED'] = 'Промокод был использован ранее'; 17 | -------------------------------------------------------------------------------- /lang/ru/lib/EventController.php: -------------------------------------------------------------------------------- 1 | модулю. Документация Mindbox API'; 23 | $MESS['MODE'] = "Режим работы"; 24 | $MESS['IDENTIFIERS'] = 'Идентификаторы'; 25 | $MESS['EVENT_LIST_GROUP'] = 'Обработчики событий'; 26 | $MESS['ENABLE_EVENT_LIST'] = 'Активные обработчики'; 27 | $MESS['CONNECTION_SETTINGS'] = 'Настройки подключения'; 28 | $MESS['PRODUCT_SETTINGS'] = 'Настройки продуктов'; 29 | $MESS['ORDER_SETTINGS'] = 'Настройки заказов'; 30 | $MESS['BITRIX_FIELDS'] = 'Поле в Bitrix'; 31 | $MESS['MINDBOX_FIELDS'] = 'Поле в Mindbox'; 32 | $MESS['BUTTON_ADD'] = 'Добавить'; 33 | $MESS['BUTTON_DELETE'] = 'Удалить'; 34 | $MESS['SITE_PROTOCOL'] = 'Использовать в фиде протокол https'; 35 | $MESS['CATALOG_PROPS'] = 'Свойства товаров, которые попадут в yml фид'; 36 | $MESS['CATALOG_OFFER_PROPS'] = 'Свойства торговых предложений, которые попадут в yml фид'; 37 | $MESS['BRAND'] = "Бренд"; 38 | $MESS['SYSTEM_NAME'] = "Системное имя"; 39 | $MESS['STANDARD'] = 'Стандартный'; 40 | $MESS['LOYALTY'] = 'Лояльность '. html_entity_decode('β'); 41 | $MESS['SAVE'] = 'Сохранить'; 42 | $MESS['MODULE_VERSION'] = 'Версия модуля '; 43 | $MESS['CLIENTS'] = 'Настройки клиентов'; 44 | $MESS['API_DOMAIN'] = 'Домен API'; 45 | $MESS['COMMON_SETTINGS'] = 'Общие настройки'; 46 | $MESS['FEED'] = 'Настройки yml-фида'; 47 | $MESS['YML_CHUNK_SIZE'] = 'Количество элементов выгружаемых за один шаг'; 48 | $MESS['CLIENTS'] = 'Настройки клиентов'; 49 | $MESS['ORDERS'] = 'Настройки заказов'; 50 | $MESS['ADDITIONAL_FIELDS_SETTINGS'] = 'Настройка дополнительных полей'; 51 | $MESS['CONTINUE_USER_GROUPS'] = 'Отключить процессинг заказов для группы пользователей'; 52 | $MESS['CONTINUE_USER_GROUPS_TOOLTIP'] = 'Пользователи данных груп не будут учавствовать в процессинге '; 53 | $MESS['ORDER_STATUS_SETTINGS'] = 'Настройка статусов заказа'; 54 | $MESS['ORDER_STATUS_BITRIX_LIST'] = 'Статус в Bitrix'; 55 | $MESS['ORDER_STATUS_MINDBOX_LIST'] = 'Статус в Mindbox'; 56 | 57 | -------------------------------------------------------------------------------- /lib/AccessLogs.php: -------------------------------------------------------------------------------- 1 | GetUserGroupArray(); 46 | if ($USER->IsAuthorized() && in_array(self::ADMIN_GROUP_ID, $arGroups) 47 | && file_exists($mindboxFilename) 48 | && is_file($mindboxFilename) 49 | && strpos($mindboxFilename, $_SERVER['PHP_SELF']) === false 50 | ) { 51 | $APPLICATION->RestartBuffer(); 52 | echo "
" . htmlspecialchars(file_get_contents($mindboxFilename)) . "
"; 53 | exit; 54 | } else { 55 | ShowMessage(GetMessage('LOG_DENIED_ERROR_MESSAGE')); 56 | } 57 | // phpcs:enable 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/Ajax.php: -------------------------------------------------------------------------------- 1 | []]; 16 | } 17 | return $actionConfig; 18 | } 19 | 20 | public static function errorResponse($error) 21 | { 22 | $response['type'] = 'error'; 23 | if(is_subclass_of($error, \Exception::class)) { 24 | $response['message'] = $error->getMessage(); 25 | } else { 26 | $response['message'] = $error; 27 | } 28 | 29 | return $response; 30 | } 31 | 32 | public static function loadParams($componentName) 33 | { 34 | $params = []; 35 | 36 | if(isset($_SESSION[$componentName]) && is_array($_SESSION[$componentName])) { 37 | $params = $_SESSION[$componentName]; 38 | } 39 | 40 | return $params; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /lib/Core.php: -------------------------------------------------------------------------------- 1 | true, 41 | 'primary' => true, 42 | ] 43 | ), 44 | new IntegerField( 45 | 'order_id', 46 | [ 47 | 'required' => true, 48 | ] 49 | ), 50 | new StringField( 51 | 'transaction', 52 | [ 53 | 'required' => true, 54 | ] 55 | ), 56 | new IntegerField( 57 | 'close', 58 | [ 59 | 'default' => 0, 60 | ] 61 | ), 62 | ]; 63 | } 64 | 65 | public function createTable() 66 | { 67 | if (!Application::getConnection()->isTableExists($this->getTableName())) { 68 | Base::getInstance(__CLASS__)->createDBTable(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /lib/DataBase/ModuleToModuleTable.php: -------------------------------------------------------------------------------- 1 | true, 60 | 'autocomplete' => true, 61 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_ID_FIELD') 62 | ] 63 | ), 64 | new DatetimeField( 65 | 'TIMESTAMP_X', 66 | [ 67 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_TIMESTAMP_X_FIELD') 68 | ] 69 | ), 70 | new IntegerField( 71 | 'SORT', 72 | [ 73 | 'default' => 100, 74 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_SORT_FIELD') 75 | ] 76 | ), 77 | new StringField( 78 | 'FROM_MODULE_ID', 79 | [ 80 | 'required' => true, 81 | 'validation' => [__CLASS__, 'validateFromModuleId'], 82 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_FROM_MODULE_ID_FIELD') 83 | ] 84 | ), 85 | new StringField( 86 | 'MESSAGE_ID', 87 | [ 88 | 'required' => true, 89 | 'validation' => [__CLASS__, 'validateMessageId'], 90 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_MESSAGE_ID_FIELD') 91 | ] 92 | ), 93 | new StringField( 94 | 'TO_MODULE_ID', 95 | [ 96 | 'required' => true, 97 | 'validation' => [__CLASS__, 'validateToModuleId'], 98 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_TO_MODULE_ID_FIELD') 99 | ] 100 | ), 101 | new StringField( 102 | 'TO_PATH', 103 | [ 104 | 'validation' => [__CLASS__, 'validateToPath'], 105 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_TO_PATH_FIELD') 106 | ] 107 | ), 108 | new StringField( 109 | 'TO_CLASS', 110 | [ 111 | 'validation' => [__CLASS__, 'validateToClass'], 112 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_TO_CLASS_FIELD') 113 | ] 114 | ), 115 | new StringField( 116 | 'TO_METHOD', 117 | [ 118 | 'validation' => [__CLASS__, 'validateToMethod'], 119 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_TO_METHOD_FIELD') 120 | ] 121 | ), 122 | new StringField( 123 | 'TO_METHOD_ARG', 124 | [ 125 | 'validation' => [__CLASS__, 'validateToMethodArg'], 126 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_TO_METHOD_ARG_FIELD') 127 | ] 128 | ), 129 | new IntegerField( 130 | 'VERSION', 131 | [ 132 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_VERSION_FIELD') 133 | ] 134 | ), 135 | /* new StringField( 136 | 'UNIQUE_ID', 137 | [ 138 | 'required' => true, 139 | 'validation' => [__CLASS__, 'validateUniqueId'], 140 | 'title' => Loc::getMessage('TO_MODULE_ENTITY_UNIQUE_ID_FIELD') 141 | ] 142 | ),*/ 143 | ]; 144 | } 145 | 146 | /** 147 | * Returns validators for FROM_MODULE_ID field. 148 | * 149 | * @return array 150 | */ 151 | public static function validateFromModuleId() 152 | { 153 | return [ 154 | new LengthValidator(null, 50), 155 | ]; 156 | } 157 | 158 | /** 159 | * Returns validators for MESSAGE_ID field. 160 | * 161 | * @return array 162 | */ 163 | public static function validateMessageId() 164 | { 165 | return [ 166 | new LengthValidator(null, 255), 167 | ]; 168 | } 169 | 170 | /** 171 | * Returns validators for TO_MODULE_ID field. 172 | * 173 | * @return array 174 | */ 175 | public static function validateToModuleId() 176 | { 177 | return [ 178 | new LengthValidator(null, 50), 179 | ]; 180 | } 181 | 182 | /** 183 | * Returns validators for TO_PATH field. 184 | * 185 | * @return array 186 | */ 187 | public static function validateToPath() 188 | { 189 | return [ 190 | new LengthValidator(null, 255), 191 | ]; 192 | } 193 | 194 | /** 195 | * Returns validators for TO_CLASS field. 196 | * 197 | * @return array 198 | */ 199 | public static function validateToClass() 200 | { 201 | return [ 202 | new LengthValidator(null, 255), 203 | ]; 204 | } 205 | 206 | /** 207 | * Returns validators for TO_METHOD field. 208 | * 209 | * @return array 210 | */ 211 | public static function validateToMethod() 212 | { 213 | return [ 214 | new LengthValidator(null, 255), 215 | ]; 216 | } 217 | 218 | /** 219 | * Returns validators for TO_METHOD_ARG field. 220 | * 221 | * @return array 222 | */ 223 | public static function validateToMethodArg() 224 | { 225 | return [ 226 | new LengthValidator(null, 255), 227 | ]; 228 | } 229 | 230 | /** 231 | * Returns validators for UNIQUE_ID field. 232 | * 233 | * @return array 234 | */ 235 | public static function validateUniqueId() 236 | { 237 | return [ 238 | new LengthValidator(null, 32), 239 | ]; 240 | } 241 | } -------------------------------------------------------------------------------- /lib/Discount/DeliveryDiscountEntity.php: -------------------------------------------------------------------------------- 1 | setEntity(); 24 | } 25 | 26 | protected function setEntity() 27 | { 28 | if ($this->entity === null) { 29 | $hlblock = HighloadBlockTable::getList(['filter' => ['=NAME' => self::HL_NAME], 'limit' => 1])->fetch(); 30 | 31 | if ($hlblock) { 32 | $this->entity = HighloadBlockTable::compileEntity($hlblock); 33 | } else { 34 | throw new ObjectNotFoundException("Object DeliveryDiscountEntity not found"); 35 | } 36 | } 37 | 38 | return $this->entity; 39 | } 40 | 41 | public function getDataClass() 42 | { 43 | return $this->entity->getDataClass(); 44 | } 45 | 46 | public function query() 47 | { 48 | return new \Bitrix\Main\Entity\Query($this->entity); 49 | } 50 | 51 | public function add(array $arFields) 52 | { 53 | return $this->getDataClass()::add($arFields); 54 | } 55 | 56 | public function update(int $id, array $arFields) 57 | { 58 | return $this->getDataClass()::update($id, $arFields); 59 | } 60 | 61 | public function getRowByFilter(array $filter) 62 | { 63 | if (empty(array_values($filter))) { 64 | return false; 65 | } 66 | 67 | $iterator = $this->getDataClass()::getList([ 68 | 'filter' => $filter, 69 | 'limit' => 1, 70 | 'select' => ['*'] 71 | ]); 72 | 73 | return $iterator->fetch(); 74 | } 75 | 76 | public function deleteByFilter(array $filter) 77 | { 78 | if (empty(array_values($filter))) { 79 | return; 80 | } 81 | 82 | $iterator = $this->getDataClass()::getList([ 83 | 'filter' => $filter, 84 | 'select' => ['ID'] 85 | ]); 86 | 87 | while ($item = $iterator->fetch()) { 88 | $this->getDataClass()::delete($item['ID']); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /lib/Discount/MindboxDeliveryDiscountAction.php: -------------------------------------------------------------------------------- 1 | static::GetControlID(), 31 | 'group' => false, 32 | 'label' => Loc::getMessage('APPLY_DISCOUNT_FROM_MINDBOX_DELIVERY'), 33 | 'defaultText' => '', 34 | 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']), 35 | 'control' => [ 36 | Loc::getMessage('APPLY_DISCOUNT_FROM_MINDBOX_DELIVERY'), 37 | $arAtoms['HLB'] 38 | ] 39 | ]; 40 | 41 | return $arResult; 42 | } 43 | 44 | public static function GetAtomsEx($strControlID = false, $boolEx = false) 45 | { 46 | $boolEx = true === $boolEx; 47 | $hlbList = []; 48 | if (Loader::includeModule('highloadblock')) { 49 | $dbRes = HLB::GetList([]); 50 | 51 | while ($el = $dbRes->fetch()) { 52 | $hlbList[$el['ID']] = $el['NAME']; 53 | } 54 | 55 | $res = HighloadBlockLangTable::GetList(['filter' => ['=LID' => LANGUAGE_ID]]); 56 | 57 | while ($el = $res->fetch()) { 58 | if ($hlbList[$el['ID']]) { 59 | $hlbList[$el['ID']] = $el['NAME'] . ' [' . $hlbList[$el['ID']] . ']'; 60 | } 61 | } 62 | } 63 | 64 | $arAtomList = [ 65 | 'HLB' => [ 66 | 'JS' => [ 67 | 'id' => 'HLB', 68 | 'name' => 'extra', 69 | 'type' => 'select', 70 | 'values' => $hlbList, 71 | 'defaultText' => '...', 72 | 'defaultValue' => '', 73 | 'first_option' => '...' 74 | ], 75 | 'ATOM' => [ 76 | 'ID' => 'HLB', 77 | 'FIELD_TYPE' => 'string', 78 | 'FIELD_LENGTH' => 255, 79 | 'MULTIPLE' => 'N', 80 | 'VALIDATE' => 'list' 81 | ] 82 | ], 83 | ]; 84 | 85 | if (!$boolEx) { 86 | foreach ($arAtomList as &$arOneAtom) { 87 | $arOneAtom = $arOneAtom['JS']; 88 | } 89 | if (isset($arOneAtom)) { 90 | unset($arOneAtom); 91 | } 92 | } 93 | 94 | return $arAtomList; 95 | } 96 | 97 | public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false) 98 | { 99 | $options = [ 100 | 'HLB' => $arOneCondition['HLB'], 101 | ]; 102 | 103 | $mxResult = '\\'. __NAMESPACE__ . '\\MindboxDiscountActions::applyToDelivery(' 104 | . $arParams['ORDER'] . ', ' 105 | . var_export($options, true) 106 | . ');'; 107 | 108 | return $mxResult; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /lib/Discount/MindboxDiscountActions.php: -------------------------------------------------------------------------------- 1 | fetch(); 32 | 33 | if (!$hlblock) { 34 | return; 35 | } 36 | 37 | $entity = HighloadBlockTable::compileEntity($hlblock); 38 | $entityClass = $entity->getDataClass(); 39 | 40 | $filter = []; 41 | $filter['UF_DELIVERY_ID'] = (int)$arOrder['DELIVERY_ID']; 42 | 43 | if ((int)$arOrder['ID'] > 0) { 44 | $filter['UF_ORDER_ID'] = (int)$arOrder['ID']; 45 | } else { 46 | if ($USER->IsAuthorized() && (int)$arOrder['USER_ID'] > 0) { 47 | $fuserId = Fuser::getIdByUserId((int)$arOrder['USER_ID']); 48 | } elseif ($USER->IsAuthorized() && (int)$USER->GetID() > 0) { 49 | $fuserId = Fuser::getIdByUserId((int)$USER->GetID()); 50 | } else { 51 | $fuserId = Fuser::getId(); 52 | } 53 | 54 | if (empty($fuserId)) { 55 | return; 56 | } 57 | 58 | $filter['UF_FUSER_ID'] = $fuserId; 59 | } 60 | 61 | $discount = $entityClass::getList([ 62 | 'filter' => $filter, 63 | 'select' => ['UF_DISCOUNTED_PRICE'], 64 | 'limit' => 1 65 | ])->fetch(); 66 | 67 | if (!$discount) { 68 | return; 69 | } 70 | 71 | $value = (float)$discount['UF_DISCOUNTED_PRICE']; 72 | 73 | $action['VALUE'] = -1 * ($arOrder['PRICE_DELIVERY'] - $value); 74 | $action['UNIT'] = self::VALUE_TYPE_FIX; 75 | $action['CURRENCY'] = static::getCurrency(); 76 | 77 | parent::applyToDelivery($arOrder, $action); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/ExtensionCartRulesActions.php: -------------------------------------------------------------------------------- 1 | static::GetControlID(), 38 | "group" => false, 39 | "label" => Loc::getMessage('APPLY_DISCOUNT_FROM_HIGHLOAD_BLOCK'), 40 | "defaultText" => "", 41 | "showIn" => static::GetShowIn($arParams["SHOW_IN_GROUPS"]), 42 | "control" => [ 43 | Loc::getMessage('APPLY_DISCOUNT_FROM_HIGHLOAD_BLOCK'), 44 | $arAtoms["HLB"] 45 | ] 46 | ]; 47 | 48 | return $arResult; 49 | } 50 | 51 | public static function GetAtomsEx($strControlID = false, $boolEx = false) 52 | { 53 | $boolEx = true === $boolEx; 54 | $hlbList = []; 55 | if (\Bitrix\Main\Loader::includeModule('highloadblock')) { 56 | $dbRes = HLB::GetList([]); 57 | while ($el = $dbRes->fetch()) { 58 | $hlbList[$el['ID']] = $el['NAME']; 59 | } 60 | $res = HighloadBlockLangTable::GetList(['filter' => ['=LID' => LANGUAGE_ID]]); 61 | while ($el = $res->fetch()) { 62 | if ($hlbList[$el['ID']]) { 63 | $hlbList[$el['ID']] = $el['NAME'] . " [" . $hlbList[$el['ID']] . "]"; 64 | } 65 | } 66 | } 67 | $arAtomList = [ 68 | "HLB" => [ 69 | "JS" => [ 70 | "id" => "HLB", 71 | "name" => "extra", 72 | "type" => "select", 73 | "values" => $hlbList, 74 | "defaultText" => "...", 75 | "defaultValue" => "", 76 | "first_option" => "..." 77 | ], 78 | "ATOM" => [ 79 | "ID" => "HLB", 80 | "FIELD_TYPE" => "string", 81 | "FIELD_LENGTH" => 255, 82 | "MULTIPLE" => "N", 83 | "VALIDATE" => "list" 84 | ] 85 | ], 86 | ]; 87 | if (!$boolEx) { 88 | foreach ($arAtomList as &$arOneAtom) { 89 | $arOneAtom = $arOneAtom["JS"]; 90 | } 91 | if (isset($arOneAtom)) { 92 | unset($arOneAtom); 93 | } 94 | } 95 | return $arAtomList; 96 | } 97 | 98 | public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false) 99 | { 100 | $mxResult = __CLASS__ . "::applyProductDiscount(" . $arParams["ORDER"] . ", " . "\"" . $arOneCondition["HLB"] . "\"" . ");"; 101 | 102 | return $mxResult; 103 | } 104 | 105 | /** 106 | * Применяет скидку из справочника к товарам из корзины 107 | * @param $arOrder 108 | * @param $hlb - Highload block 109 | */ 110 | public static function applyProductDiscount(&$arOrder, $hlb) 111 | { 112 | $userId = $arOrder['USER_ID']; 113 | if ($userId && \Bitrix\Main\Loader::includeModule('highloadblock')) { 114 | $arBasketId = []; 115 | foreach ($arOrder['BASKET_ITEMS'] as &$product) { 116 | $arBasketId[] = $product['ID']; 117 | } 118 | unset($product); 119 | $hlblock = HLB::getById($hlb)->fetch(); 120 | if (!$hlblock) { 121 | return; 122 | } 123 | $entity = HLB::compileEntity($hlblock); 124 | $entityClass = $entity->getDataClass(); 125 | //Находим записи в справочнике с нужными параметрами - товар/пользователь 126 | $dbRes = $entityClass::getList([ 127 | 'filter' => [ 128 | '=UF_BASKET_ID' => $arBasketId, 129 | ], 130 | 'order' => [ 131 | 'ID' => 'DESC' 132 | ] 133 | ]); 134 | $discounts = []; 135 | while ($el = $dbRes->fetch()) { 136 | if (!$discounts[$el['UF_PRODUCT']]) { 137 | $discounts[$el['UF_BASKET_ID']] = $el; 138 | } 139 | } 140 | 141 | //Применяем скидку 142 | foreach ($arOrder['BASKET_ITEMS'] as &$product) { 143 | $basketId = $product['ID']; 144 | if ($discounts[$basketId]) { 145 | if ($discounts[$basketId]['UF_DISCOUNTED_PRICE'] >= 0) { 146 | $discountPrice = $product['PRICE'] - $discounts[$basketId]['UF_DISCOUNTED_PRICE']; 147 | } 148 | 149 | $product['DISCOUNT_PRICE'] = $product['DISCOUNT_PRICE'] + $discountPrice; 150 | $product['PRICE'] = $discounts[$basketId]['UF_DISCOUNTED_PRICE']; 151 | } 152 | } 153 | unset($product); 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /lib/Installer/CartRuleInstaller.php: -------------------------------------------------------------------------------- 1 | 'Mindbox', 16 | 'en' => 'Mindbox' 17 | ]; 18 | 19 | public function __construct() 20 | { 21 | Loader::IncludeModule('highloadblock'); 22 | Loader::IncludeModule('sale'); 23 | } 24 | 25 | public function createHighLoadBlock() 26 | { 27 | } 28 | 29 | public function createCartRule($hlBlockId) 30 | { 31 | } 32 | 33 | public function deleteHighLoadBlock() 34 | { 35 | $hlBlockExist = $this->checkExistHighLoadBlock(); 36 | 37 | if (!empty($hlBlockExist)) { 38 | HL\HighloadBlockTable::delete($hlBlockExist); 39 | } 40 | } 41 | 42 | public function checkExistHighLoadBlock() 43 | { 44 | $getHlBlock = HL\HighloadBlockTable::getList([ 45 | 'filter' => ['=NAME' => static::HL_NAME] 46 | ])->fetch(); 47 | 48 | return (!empty($getHlBlock) && is_array($getHlBlock)) ? $getHlBlock['ID'] : false; 49 | } 50 | 51 | protected function deleteCartRule() 52 | { 53 | $exist = $this->checkExistCartRule(); 54 | 55 | if (!empty($exist) && is_array($exist) && $exist['NAME'] === static::DISCOUNT_NAME) { 56 | \CSaleDiscount::Delete($exist['ID']); 57 | } 58 | } 59 | 60 | public function checkExistCartRule() 61 | { 62 | $return = false; 63 | $getDiscount = \CSaleDiscount::GetList([], ['NAME' => static::DISCOUNT_NAME]); 64 | 65 | if ($discount = $getDiscount->Fetch()) { 66 | $return = $discount; 67 | } 68 | 69 | return $return; 70 | } 71 | 72 | public function getUserGroupsIds() 73 | { 74 | $return = []; 75 | $getUserGroups = \CGroup::GetList(($by='c_sort'), ($order='desc'), ['ACTIVE' => 'Y']); 76 | 77 | while ($group = $getUserGroups->Fetch()) { 78 | $return[] = $group['ID']; 79 | } 80 | 81 | return $return; 82 | } 83 | 84 | protected function getActiveSite() 85 | { 86 | $return = false; 87 | $rsSites = \Bitrix\Main\SiteTable::getList(['filter' => ['ACTIVE' => 'Y', 'DEF' => 'Y']]); 88 | 89 | if ($arSite = $rsSites->fetch()) { 90 | $return = $arSite['LID']; 91 | } 92 | 93 | return $return; 94 | } 95 | 96 | public function install() 97 | { 98 | $hlBlockExist = $this->checkExistHighLoadBlock(); 99 | 100 | if (!empty($hlBlockExist) && (int)$hlBlockExist > 0) { 101 | $hlBlockId = $hlBlockExist; 102 | } else { 103 | $hlBlockId = $this->createHighLoadBlock(); 104 | } 105 | 106 | if (!empty($hlBlockId)) { 107 | $existRule = $this->checkExistCartRule(); 108 | 109 | if ($existRule === false) { 110 | $this->createCartRule($hlBlockId); 111 | } 112 | } 113 | } 114 | 115 | public function unInstall() 116 | { 117 | $this->deleteCartRule(); 118 | $this->deleteHighLoadBlock(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /lib/Installer/DeliveryCartRuleInstaller.php: -------------------------------------------------------------------------------- 1 | 'MindboxDelivery', 17 | 'en' => 'MindboxDelivery' 18 | ]; 19 | 20 | public function createHighLoadBlock() 21 | { 22 | $create = HL\HighloadBlockTable::add([ 23 | 'NAME' => static::HL_NAME, 24 | 'TABLE_NAME' => static::HL_TABLE, 25 | ]); 26 | 27 | if ($create->isSuccess()) { 28 | $id = $create->getId(); 29 | 30 | foreach ($this->hlNames as $key => $val) { 31 | HL\HighloadBlockLangTable::add([ 32 | 'ID' => $id, 33 | 'LID' => $key, 34 | 'NAME' => $val 35 | ]); 36 | } 37 | 38 | $userFieldObject = 'HLBLOCK_' . $id; 39 | 40 | $fields = [ 41 | 'UF_DISCOUNTED_PRICE' => [ 42 | 'ENTITY_ID' => $userFieldObject, 43 | 'FIELD_NAME' => 'UF_DISCOUNTED_PRICE', 44 | 'USER_TYPE_ID' => 'double', 45 | 'MANDATORY' => 'N', 46 | 'EDIT_FORM_LABEL' => ['ru' => '', 'en' => ''], 47 | 'LIST_COLUMN_LABEL' => ['ru' => '', 'en' => ''], 48 | 'LIST_FILTER_LABEL' => ['ru' => '', 'en' => ''], 49 | 'ERROR_MESSAGE' => ['ru' => '', 'en' => ''], 50 | 'HELP_MESSAGE' => ['ru' => '', 'en' => ''], 51 | ], 52 | 'UF_DELIVERY_ID' => [ 53 | 'ENTITY_ID' => $userFieldObject, 54 | 'FIELD_NAME' => 'UF_DELIVERY_ID', 55 | 'USER_TYPE_ID' => 'integer', 56 | 'MANDATORY' => 'N', 57 | 'EDIT_FORM_LABEL' => ['ru' => '', 'en' => ''], 58 | 'LIST_COLUMN_LABEL' => ['ru' => '', 'en' => ''], 59 | 'LIST_FILTER_LABEL' => ['ru' => '', 'en' => ''], 60 | 'ERROR_MESSAGE' => ['ru' => '', 'en' => ''], 61 | 'HELP_MESSAGE' => ['ru' => '', 'en' => ''], 62 | ], 63 | 'UF_ORDER_ID' => [ 64 | 'ENTITY_ID' => $userFieldObject, 65 | 'FIELD_NAME' => 'UF_ORDER_ID', 66 | 'USER_TYPE_ID' => 'integer', 67 | 'MANDATORY' => 'N', 68 | 'EDIT_FORM_LABEL' => ['ru' => '', 'en' => ''], 69 | 'LIST_COLUMN_LABEL' => ['ru' => '', 'en' => ''], 70 | 'LIST_FILTER_LABEL' => ['ru' => '', 'en' => ''], 71 | 'ERROR_MESSAGE' => ['ru' => '', 'en' => ''], 72 | 'HELP_MESSAGE' => ['ru' => '', 'en' => ''], 73 | ], 74 | 'UF_FUSER_ID' => [ 75 | 'ENTITY_ID' => $userFieldObject, 76 | 'FIELD_NAME' => 'UF_FUSER_ID', 77 | 'USER_TYPE_ID' => 'integer', 78 | 'MANDATORY' => 'N', 79 | 'EDIT_FORM_LABEL' => ['ru' => '', 'en' => ''], 80 | 'LIST_COLUMN_LABEL' => ['ru' => '', 'en' => ''], 81 | 'LIST_FILTER_LABEL' => ['ru' => '', 'en' => ''], 82 | 'ERROR_MESSAGE' => ['ru' => '', 'en' => ''], 83 | 'HELP_MESSAGE' => ['ru' => '', 'en' => ''], 84 | ], 85 | ]; 86 | 87 | foreach ($fields as $field) { 88 | $obUserField = new \CUserTypeEntity; 89 | $obUserField->Add($field); 90 | } 91 | 92 | return $id; 93 | } else { 94 | $errors = $create->getErrorMessages(); 95 | } 96 | } 97 | 98 | public function createCartRule($hlBlockId) 99 | { 100 | $siteId = $this->getActiveSite(); 101 | $siteUserGroups = $this->getUserGroupsIds(); 102 | 103 | $discountFields = [ 104 | 'LID' => $siteId, 105 | 'SITE_ID' => $siteId, 106 | 'NAME' => static::DISCOUNT_NAME, 107 | 'PRIORITY' => 100, 108 | 'SORT' => 100, 109 | 'DISCOUNT_VALUE' => 'mindbox', 110 | 'DISCOUNT_TYPE' => 'P', 111 | 'LAST_LEVEL_DISCOUNT' => 'N', 112 | 'LAST_DISCOUNT' => 'N', 113 | 'ACTIVE' => 'Y', 114 | 'CURRENCY' => 'RUR', 115 | 'USER_GROUPS' => $siteUserGroups, 116 | 'ACTIONS' => [ 117 | 'CLASS_ID' => 'CondGroup', 118 | 'DATA' => 119 | [ 120 | 'All' => 'AND', 121 | ], 122 | 'CHILDREN' => 123 | [ 124 | 0 => [ 125 | 'CLASS_ID' => MindboxDeliveryDiscountAction::GetControlID(), 126 | 'DATA' => ['HLB' => $hlBlockId], 127 | 'CHILDREN' => [], 128 | ], 129 | ], 130 | ], 131 | 'CONDITIONS' => [ 132 | 'CLASS_ID' => 'CondGroup', 133 | 'DATA' => 134 | [ 135 | 'All' => 'AND', 136 | 'True' => 'True', 137 | ], 138 | 'CHILDREN' => [] 139 | ] 140 | ]; 141 | 142 | \CSaleDiscount::Add($discountFields); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /lib/Installer/OrderPropertiesInstaller.php: -------------------------------------------------------------------------------- 1 | [ 49 | 'NAME' => Loc::getMessage('ORDER_PROMO_CODE_PROPERTY_NAME'), 50 | 'TYPE' => 'TEXT', 51 | 'CODE' => self::PROPERTY_PROMO_CODE, 52 | 'REQUIED' => 'N', 53 | 'UTIL' => 'Y' 54 | ], 55 | self::PROPERTY_BONUS => [ 56 | 'NAME' => Loc::getMessage('ORDER_BONUS_PROPERTY_NAME'), 57 | 'TYPE' => 'TEXT', 58 | 'CODE' => self::PROPERTY_BONUS, 59 | 'REQUIED' => 'N', 60 | 'UTIL' => 'Y' 61 | ], 62 | ]; 63 | 64 | return $config[$propertyCode]; 65 | } 66 | 67 | /** 68 | * Массив допустимых свойств при установке и удалении 69 | * @return string[] 70 | */ 71 | protected function getMindboxProperiesCodes() 72 | { 73 | return [self::PROPERTY_BONUS, self::PROPERTY_PROMO_CODE]; 74 | } 75 | 76 | /** 77 | * Метод запускающий установку. Проверяет существование необходимых групп свойств и свойств. 78 | * Если элементы отсутствуют, то создает их. 79 | */ 80 | public function install() 81 | { 82 | $getPersonTypeList = $this->getSitePersonType(); 83 | $getPropertiesGroup = $this->getPropertiesGroupList(); 84 | 85 | foreach ($getPersonTypeList as $personItem) { 86 | if (!array_key_exists($personItem['ID'], $getPropertiesGroup)) { 87 | $addGroup = $this->addPropertyGroup($personItem['ID']); 88 | 89 | if ((int)$addGroup > 0) { 90 | $getPropertiesGroup[$personItem['ID']] = \CSaleOrderPropsGroup::GetByID($addGroup); 91 | } 92 | } 93 | } 94 | 95 | $personTypesIds = array_keys($getPersonTypeList); 96 | $mindboxPropertiesCodes = $this->getMindboxProperiesCodes(); 97 | $propertiesList = $this->getPropertiesList(); 98 | 99 | if (!empty($personTypesIds)) { 100 | foreach ($personTypesIds as $personTypesId) { 101 | foreach ($mindboxPropertiesCodes as $propCode) { 102 | $needInstall = true; 103 | 104 | foreach ($propertiesList as $propertyItem) { 105 | if ($propertyItem['PERSON_TYPE_ID'] == $personTypesId && $propertyItem['CODE'] === $propCode) { 106 | $needInstall = false; 107 | } 108 | } 109 | 110 | if ($needInstall) { 111 | $addFields = [ 112 | 'CODE' => $propCode, 113 | 'PERSON_TYPE_ID' => $personTypesId, 114 | ]; 115 | 116 | $selectPropGroup = $getPropertiesGroup[$personTypesId]['ID']; 117 | 118 | if (!empty($selectPropGroup)) { 119 | $addFields['PROPS_GROUP_ID'] = $selectPropGroup; 120 | } 121 | 122 | $this->addProperty($addFields); 123 | } 124 | } 125 | } 126 | } 127 | } 128 | 129 | /** 130 | * Удаление групп свойств и свойств 131 | */ 132 | public function uninstall() 133 | { 134 | $this->deletePropertiesGroups(); 135 | $this->deleteProperties(); 136 | } 137 | 138 | /** 139 | * Получение списка всех типов плательщика для всех активных сайтов на проекте 140 | * @return array 141 | */ 142 | protected function getSitePersonType(): array 143 | { 144 | $return = []; 145 | 146 | $projectActiveSites = Helper::getSiteList(true); 147 | $getPersonType = \CSalePersonType::GetList([], ['LID' => $projectActiveSites, 'ACTIVE' => 'Y']); 148 | 149 | while ($item = $getPersonType->Fetch()) { 150 | $return[$item['ID']] = $item; 151 | } 152 | 153 | return $return; 154 | } 155 | 156 | /** 157 | * Получение списка групп свойств Mindbox 158 | * @return array 159 | */ 160 | protected function getPropertiesGroupList() 161 | { 162 | $return = []; 163 | $getGroups = \CSaleOrderPropsGroup::GetList([], [ 164 | 'NAME' => self::PROPERTIES_GROUP_NAME 165 | ]); 166 | 167 | while ($item = $getGroups->Fetch()) { 168 | $return[$item['PERSON_TYPE_ID']] = $item; 169 | } 170 | 171 | return $return; 172 | } 173 | 174 | /** 175 | * Добавление новой группы с именем self::PROPERTIES_GROUP_NAME 176 | * @param $personType 177 | * @return false 178 | */ 179 | protected function addPropertyGroup($personType) 180 | { 181 | $return = false; 182 | 183 | if (!empty($personType)) { 184 | $return = \CSaleOrderPropsGroup::Add([ 185 | 'PERSON_TYPE_ID' => $personType, 186 | 'NAME' => self::PROPERTIES_GROUP_NAME 187 | ]); 188 | } 189 | 190 | return $return; 191 | } 192 | 193 | /** 194 | * Удаление всех групп свойств с имененем self::PROPERTIES_GROUP_NAME 195 | */ 196 | protected function deletePropertiesGroups() 197 | { 198 | $list = $this->getPropertiesGroupList(); 199 | 200 | if (!empty($list) && is_array($list)) { 201 | foreach ($list as $item) { 202 | \CSaleOrderPropsGroup::Delete($item['ID']); 203 | } 204 | } 205 | } 206 | 207 | /** 208 | * Получение списка свойств Mindbox. Фильтр строится на основе массива getMindboxProperiesCodes() 209 | * @return array 210 | */ 211 | protected function getPropertiesList() 212 | { 213 | $propsCodes = $this->getMindboxProperiesCodes(); 214 | $return = []; 215 | 216 | if (!empty($propsCodes)) { 217 | $getProperty = \CSaleOrderProps::GetList([], [ 218 | 'CODE' => $propsCodes, 219 | ]); 220 | 221 | while ($propData = $getProperty->Fetch()) { 222 | $return[$propData['ID']] = $propData; 223 | } 224 | } 225 | 226 | return $return; 227 | } 228 | 229 | /** 230 | * Добавление нового свойства 231 | * @param $fields 232 | */ 233 | protected function addProperty($fields) 234 | { 235 | $addPropertyFields = $this->getInstallProperiesConfig($fields['CODE']); 236 | 237 | if ($addPropertyFields) { 238 | $addPropertyFields = array_merge($addPropertyFields, $fields); 239 | } 240 | 241 | \CSaleOrderProps::Add($addPropertyFields); 242 | } 243 | 244 | /** 245 | * Удаление свойств 246 | */ 247 | protected function deleteProperties() 248 | { 249 | $list = $this->getPropertiesList(); 250 | 251 | if (!empty($list) && is_array($list)) { 252 | foreach ($list as $item) { 253 | \CSaleOrderProps::Delete($item['ID']); 254 | } 255 | } 256 | } 257 | } -------------------------------------------------------------------------------- /lib/Installer/ProductCartRuleInstaller.php: -------------------------------------------------------------------------------- 1 | 'Mindbox', 16 | 'en' => 'Mindbox' 17 | ]; 18 | 19 | public function createHighLoadBlock() 20 | { 21 | $create = HL\HighloadBlockTable::add([ 22 | 'NAME' => static::HL_NAME, 23 | 'TABLE_NAME' => static::HL_TABLE, 24 | ]); 25 | 26 | if ($create->isSuccess()) { 27 | $id = $create->getId(); 28 | 29 | foreach ($this->hlNames as $key => $val) { 30 | HL\HighloadBlockLangTable::add([ 31 | 'ID' => $id, 32 | 'LID' => $key, 33 | 'NAME' => $val 34 | ]); 35 | } 36 | 37 | $userFieldObject = 'HLBLOCK_' . $id; 38 | 39 | $fields = [ 40 | 'UF_DISCOUNTED_PRICE' => [ 41 | 'ENTITY_ID' => $userFieldObject, 42 | 'FIELD_NAME' => 'UF_DISCOUNTED_PRICE', 43 | 'USER_TYPE_ID' => 'double', 44 | 'MANDATORY' => 'N', 45 | 'EDIT_FORM_LABEL' => ['ru' => '', 'en' => ''], 46 | 'LIST_COLUMN_LABEL' => ['ru' => '', 'en' => ''], 47 | 'LIST_FILTER_LABEL' => ['ru' => '', 'en' => ''], 48 | 'ERROR_MESSAGE' => ['ru' => '', 'en' => ''], 49 | 'HELP_MESSAGE' => ['ru' => '', 'en' => ''], 50 | ], 51 | 'UF_BASKET_ID' => [ 52 | 'ENTITY_ID' => $userFieldObject, 53 | 'FIELD_NAME' => 'UF_BASKET_ID', 54 | 'USER_TYPE_ID' => 'integer', 55 | 'MANDATORY' => 'N', 56 | 'EDIT_FORM_LABEL' => ['ru' => '', 'en' => ''], 57 | 'LIST_COLUMN_LABEL' => ['ru' => '', 'en' => ''], 58 | 'LIST_FILTER_LABEL' => ['ru' => '', 'en' => ''], 59 | 'ERROR_MESSAGE' => ['ru' => '', 'en' => ''], 60 | 'HELP_MESSAGE' => ['ru' => '', 'en' => ''], 61 | ], 62 | ]; 63 | 64 | foreach ($fields as $field) { 65 | $obUserField = new \CUserTypeEntity; 66 | $obUserField->Add($field); 67 | } 68 | 69 | return $id; 70 | } else { 71 | $errors = $create->getErrorMessages(); 72 | } 73 | } 74 | 75 | public function createCartRule($hlBlockId) 76 | { 77 | $siteId = $this->getActiveSite(); 78 | $siteUserGroups = $this->getUserGroupsIds(); 79 | 80 | $discountFields = [ 81 | 'LID' => $siteId, 82 | 'SITE_ID' => $siteId, 83 | 'NAME' => static::DISCOUNT_NAME, 84 | 'DISCOUNT_VALUE' => 'mindbox', 85 | 'DISCOUNT_TYPE' => 'P', 86 | 'LAST_LEVEL_DISCOUNT' => 'Y', 87 | 'LAST_DISCOUNT' => 'Y', 88 | 'ACTIVE' => 'Y', 89 | 'CURRENCY' => 'RUR', 90 | 'USER_GROUPS' => $siteUserGroups, 91 | 'ACTIONS' => [ 92 | 'CLASS_ID' => 'CondGroup', 93 | 'DATA' => 94 | [ 95 | 'All' => 'AND', 96 | ], 97 | 'CHILDREN' => 98 | [ 99 | 0 => [ 100 | 'CLASS_ID' => 'DiscountFromDirectory', 101 | 'DATA' => ['HLB' => $hlBlockId], 102 | 'CHILDREN' => [], 103 | ], 104 | ], 105 | ], 106 | 'CONDITIONS' => [ 107 | 'CLASS_ID' => 'CondGroup', 108 | 'DATA' => 109 | [ 110 | 'All' => 'AND', 111 | 'True' => 'True', 112 | ], 113 | 'CHILDREN' => [] 114 | ] 115 | ]; 116 | 117 | \CSaleDiscount::Add($discountFields); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /lib/Options.php: -------------------------------------------------------------------------------- 1 | 'AuthorizeCustomer', 13 | 'addToCart' => 'AddToCart', 14 | 'autoConfirmMobile' => 'AutoConfirmMobilePhone', 15 | 'calculateCart' => 'CalculateCart', 16 | 'calculateAuthorizedCart' => 'CalculateAuthorizedCart', 17 | 'calculateUnauthorizedCart' => 'CalculateUnauthorizedCart', 18 | 'calculateAuthorizedCartAdmin' => 'CalculateAuthorizedCartAdmin', 19 | 'cancelOrder' => 'CancelOrder', 20 | 'checkActive' => 'CheckCustomerIsInLoyalityProgram', 21 | 'checkAuthorizationCode' => 'CheckMobilePhoneAuthorizationCode', 22 | 'checkByPhone' => 'CheckCustomerByMobilePhone', 23 | 'checkByMail' => 'CheckCustomerByEmail', 24 | 'check' => 'CheckCustomer', 25 | 'confirmOrder' => 'ConfirmOrder', 26 | 'confirmMobile' => 'ConfirmMobilePhone', 27 | 'createOrder' => 'CreateOrder', 28 | 'beginUnauthorizedOrderTransaction' => 'BeginUnauthorizedOrderTransaction', 29 | 'beginAuthorizedOrderTransaction' => 'BeginAuthorizedOrderTransaction', 30 | 'beginAuthorizedOrderTransactionAdmin' => 'BeginAuthorizedOrderTransactionAdmin', 31 | 'createAuthorizedOrder' => 'CreateAuthorizedOrder', 32 | 'createUnauthorizedOrder' => 'CreateUnauthorizedOrder', 33 | 'edit' => 'EditCustomer', 34 | 'fill' => 'FillCustomerProfile', 35 | 'getBalance' => 'GetCustomerBalance', 36 | 'getBonusPointsHistory' => 'GetCustomerBonusPointsHistory', 37 | 'getDataByDiscountCard' => 'GetCustomerDataByDiscountCard', 38 | 'getCustomerInfo' => 'GetCustomerInfo', 39 | 'getOrders' => 'GetCustomerOrders', 40 | 'getSubscriptions' => 'GetCustomerSubscriptions', 41 | 'merge' => 'MergeCustomers', 42 | 'offlineOrder' => 'OfflineOrder', 43 | 'register' => 'RegisterCustomer', 44 | 'registerFromAnonymousOrder' => 'RegisterCustomerFromAnonymousOrder', 45 | 'removeFromCart' => 'RemoveProduct', 46 | 'resendConfirmationCode' => 'ResendMobilePhoneConfirmationCode', 47 | 'resendEmailConfirm' => 'ResendEmailConfirmation', 48 | 'sendAuthorizationCode' => 'SendMobilePhoneAuthorizationCode', 49 | 'setProductList' => 'SetCart', 50 | 'subscribe' => 'SubscribeCustomer', 51 | 'viewProduct' => 'ViewProduct', 52 | 'viewCategory' => 'ViewCategory', 53 | 'commitOrderTransaction' => 'CommitOrderTransaction', 54 | 'commitOrderTransactionAdmin' => 'CommitOrderTransactionAdmin', 55 | 'rollbackOrderTransaction' => 'RollbackOrderTransaction', 56 | 'rollbackOrderTransactionAdmin' => 'RollbackOrderTransactionAdmin', 57 | 'saveOfflineOrder' => 'SaveOfflineOrder', 58 | 'setWishList' => 'SetWishList', 59 | 'clearWishList' => 'ClearWishList', 60 | 'clearCart' => 'ClearCart', 61 | 'updateOrderItemsStatus' => 'UpdateOrderItemsStatus', 62 | 'updateOrderStatus' => 'UpdateOrderStatus', 63 | 'updateOrderItems' => 'UpdateOrderItems', 64 | 'getOrdersList' => 'GetOrdersList', 65 | 'calculateUnauthorizedProduct' => 'CalculateUnauthorizedProduct' 66 | ]; 67 | 68 | private static $sdkOptions = [ 69 | 'endpointId' => 'ENDPOINT', 70 | 'secretKey' => 'SECRET_KEY', 71 | 'timeout' => 'TIMEOUT', 72 | 'httpClient' => 'HTTP_CLIENT', 73 | 'domain' => 'DOMAIN', 74 | ]; 75 | 76 | public static function getOperationName($alias) 77 | { 78 | if (empty(static::$operations[$alias])) { 79 | throw new MindboxConfigException('Unknow Operation Name: ' . $alias); 80 | } 81 | 82 | return static::getPrefix() . '.' . static::$operations[$alias]; 83 | } 84 | 85 | public static function getSDKOptions() 86 | { 87 | foreach (static::$sdkOptions as $key => $option) { 88 | $sdkOptions[$key] = COption::GetOptionString('mindbox.marketing', $option); 89 | } 90 | 91 | // for standard mode 92 | $domain = COption::GetOptionString('mindbox.marketing', 'SYSTEM_NAME') . '-services.mindbox.'; 93 | 94 | $domainZone = COption::GetOptionString('mindbox.marketing', 'API_DOMAIN', 'ru'); 95 | 96 | $sdkOptions['domainZone'] = $domainZone; 97 | $sdkOptions['domain'] = $domain.$domainZone; 98 | 99 | return $sdkOptions; 100 | } 101 | 102 | public static function getConfig($queue = false) 103 | { 104 | $config = static::getSDKOptions(); 105 | if ($queue) { 106 | $config['timeout'] = COption::GetOptionString('mindbox.marketing', 'QUEUE_TIMEOUT', 30); 107 | } 108 | $path = COption::GetOptionString('mindbox.marketing', 'LOG_PATH'); 109 | 110 | try { 111 | $mindbox = new Mindbox($config, new MindboxFileLogger($path, 'debug')); 112 | $mindbox->getClientV2()->addHeaders(['Mindbox-Integration' => 'Bitrix', 'Mindbox-Integration-Version' => COption::GetOptionString('mindbox.marketing', 'MODULE_VERSION', '1.0')]); 113 | $mindbox->getClientV3()->addHeaders(['Mindbox-Integration' => 'Bitrix', 'Mindbox-Integration-Version' => COption::GetOptionString('mindbox.marketing', 'MODULE_VERSION', '1.0')]); 114 | 115 | return $mindbox; 116 | } catch (MindboxConfigException $e) { 117 | return false; 118 | } 119 | } 120 | 121 | 122 | public static function getPrefix() 123 | { 124 | return COption::GetOptionString('mindbox.marketing', 'WEBSITE_PREFIX', 'Website'); 125 | } 126 | 127 | public static function getExternalSystem() 128 | { 129 | return COption::GetOptionString('mindbox.marketing', 'EXTERNAL_SYSTEM', 'system1c'); 130 | } 131 | 132 | public static function getModuleOption($option) 133 | { 134 | return COption::GetOptionString('mindbox.marketing', $option); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /lib/QueueTable.php: -------------------------------------------------------------------------------- 1 | serialize($request)]); 21 | } 22 | return $result->getPrimary(); 23 | } 24 | 25 | public static function execute() 26 | { 27 | $mindbox = Options::getConfig(true); 28 | if (!$mindbox) { 29 | return; 30 | } 31 | 32 | foreach (self::getPendingTasks() as $task) { 33 | $request = unserialize($task['REQUEST_DATA']); 34 | if (!$request instanceof MindboxRequest) { 35 | continue; 36 | } 37 | 38 | try { 39 | $client = $mindbox->getClient($request->getApiVersion()); 40 | 41 | $client->setRequest($request)->sendRequest(); 42 | $status = 'Y'; 43 | } catch (Exceptions\MindboxClientErrorException $e) { 44 | $status = 'F'; 45 | } catch (Exceptions\MindboxUnavailableException $e) { 46 | $status = 'N'; 47 | } catch (Exceptions\MindboxClientException $e) { 48 | $status = 'N'; 49 | } 50 | 51 | self::update( 52 | $task['ID'], 53 | [ 54 | 'STATUS_EXEC' => $status, 55 | 'DATE_EXEC' => DateTime::createFromTimestamp(time()) 56 | ] 57 | ); 58 | } 59 | } 60 | 61 | private static function getPendingTasks() 62 | { 63 | $dbTasks = self::getList([ 64 | 'filter' => ['STATUS_EXEC' => 'N'] 65 | ]); 66 | 67 | $pending = []; 68 | 69 | while ($task = $dbTasks->fetch()) { 70 | $pending[] = $task; 71 | } 72 | 73 | return $pending; 74 | } 75 | 76 | public static function getTableName() 77 | { 78 | return 'mindbox_queue'; 79 | } 80 | 81 | public static function getMap() 82 | { 83 | return [ 84 | new Entity\IntegerField('ID', [ 85 | 'primary' => true, 86 | 'autocomplete' => true 87 | ]), 88 | new Entity\TextField('REQUEST_DATA'), 89 | new Entity\DatetimeField('DATE_INSERT', [ 90 | 'default_value' => DateTime::createFromTimestamp(time()) 91 | ]), 92 | new Entity\DatetimeField('DATE_EXEC'), 93 | new Entity\EnumField('STATUS_EXEC', [ 94 | 'values' => array('N', 'Y', 'F'), 95 | 'default_value' => 'N' 96 | 97 | ]) 98 | ]; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /lib/Transaction.php: -------------------------------------------------------------------------------- 1 | orderId = $orderId; 18 | $this->id = $this->set($orderId); 19 | } 20 | 21 | protected function set($orderId = false) 22 | { 23 | // check exist 24 | $transactionId = $this->createTransactionId(); 25 | 26 | if (!empty($orderId)) { 27 | $this->addTransaction($orderId, $transactionId); 28 | } 29 | 30 | return $transactionId; 31 | } 32 | 33 | public static function existOpenTransaction($orderId) 34 | { 35 | $result = false; 36 | 37 | $get = MindboxTransactionTable::getList([ 38 | 'select' => ['*'], 39 | 'filter' => [ 40 | '!close' => 1, 41 | 'order_id' => $orderId 42 | ], 43 | 'order' => [ 44 | 'id' => 'DESC' 45 | ], 46 | ]); 47 | 48 | if ($transaction = $get->fetch()) { 49 | $result = $transaction; 50 | } 51 | 52 | return $result; 53 | } 54 | 55 | public function addTransaction($orderId, $transactionId) 56 | { 57 | $result = MindboxTransactionTable::add([ 58 | 'order_id' => $orderId, 59 | 'transaction' => $transactionId, 60 | 'close' => 0 61 | ]); 62 | } 63 | 64 | protected function createTransactionId() 65 | { 66 | return getmypid() . microtime(true); 67 | } 68 | 69 | public function get() 70 | { 71 | return $this->id; 72 | } 73 | 74 | public static function closeTransaction($recordId) 75 | { 76 | MindboxTransactionTable::update( 77 | $recordId, 78 | ['close' => 1] 79 | ); 80 | } 81 | 82 | public function close() 83 | { 84 | if (!empty($this->orderId)) { 85 | if ($existTransaction = self::existOpenTransaction($this->orderId)) { 86 | self::closeTransaction($existTransaction['id']); 87 | } 88 | } 89 | 90 | $this->clear(); 91 | } 92 | 93 | public function clear() 94 | { 95 | self::$instance = null; 96 | } 97 | 98 | static function getInstance($orderId = false) 99 | { 100 | if (is_null(self::$instance)) { 101 | self::$instance = new self($orderId); 102 | } 103 | 104 | return self::$instance; 105 | } 106 | 107 | protected function __clone() 108 | { 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /logs/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine on 2 | RewriteRule ^(.*)$ index.php?path=$1 [NC,L,QSA] -------------------------------------------------------------------------------- /logs/index.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | checkLogAccess($_GET['path']); 9 | } 10 | ?> 11 | 12 | 2 | 3 | The Extended PSR2 coding standard. 4 | lib/ 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /updater.php: -------------------------------------------------------------------------------- 1 | CopyFiles("install/components", "components/"); 8 | } 9 | 10 | $updater->CopyFiles("lib", "modules/mindbox.marketing/lib"); 11 | $updater->CopyFiles("logs", "modules/mindbox.marketing/logs"); 12 | 13 | $moduleName = 'mindbox.marketing'; 14 | 15 | CAgent::RemoveModuleAgents($moduleName); 16 | $now = new DateTime(); 17 | CAgent::AddAgent( 18 | "\Mindbox\YmlFeedMindbox::start();", 19 | $moduleName, 20 | "N", 21 | 86400, 22 | $now, 23 | "Y", 24 | $now, 25 | 30 26 | ); 27 | 28 | CAgent::AddAgent( 29 | "\Mindbox\QueueTable::start();", 30 | $moduleName, 31 | "N", 32 | 60, 33 | $now, 34 | "Y", 35 | $now, 36 | 30 37 | ); 38 | 39 | $tomorrow = DateTime::createFromTimestamp(strtotime('tomorrow')); 40 | $tomorrow->setTime(3,0); 41 | 42 | CAgent::AddAgent( 43 | "\Mindbox\LogsRotation::agentRotationLogs();", 44 | $moduleName, 45 | "N", 46 | 86400, 47 | $tomorrow, 48 | "Y", 49 | $tomorrow, 50 | 30 51 | ); 52 | } 53 | --------------------------------------------------------------------------------