diff --git a/CHANGELOG.md b/CHANGELOG.md index 323f2d44..1c5cfe0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-08-22 v.6.4.0 +- Добавлена функция подписки на рекламно-информационные рассылки + ## 2023-07-25 v.6.3.20 - Исправлена ошибка некорректного вывода информации о программе лояльности в личном кабинете клиента diff --git a/intaro.retailcrm/classes/general/CustomerBuilder.php b/intaro.retailcrm/classes/general/CustomerBuilder.php index 5f4ce2e4..3f4b5d38 100644 --- a/intaro.retailcrm/classes/general/CustomerBuilder.php +++ b/intaro.retailcrm/classes/general/CustomerBuilder.php @@ -200,6 +200,15 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa if (isset($this->dataCrm['address'])) { $this->buildAddress(); } + + // клиент считается подписанным при значении равном null + if (array_key_exists('emailMarketingUnsubscribedAt', $this->dataCrm)) { + if (empty($this->dataCrm['emailMarketingUnsubscribedAt'])) { + $this->customer->setSubscribe('Y'); + } else { + $this->customer->setSubscribe('N'); + } + } } public function buildPassword() diff --git a/intaro.retailcrm/classes/general/Model/Customer.php b/intaro.retailcrm/classes/general/Model/Customer.php index 76ac73b9..9cfec5be 100644 --- a/intaro.retailcrm/classes/general/Model/Customer.php +++ b/intaro.retailcrm/classes/general/Model/Customer.php @@ -47,6 +47,9 @@ class Customer extends BaseModel /**@var string $PERSONAL_GENDER */ protected $PERSONAL_GENDER; + /**@var string $UF_SUBSCRIBE_USER_EMAIL */ + protected $UF_SUBSCRIBE_USER_EMAIL; + /** * @param string $EMAIL * @return $this @@ -200,4 +203,15 @@ class Customer extends BaseModel return $this; } + + /** + * @param string $UF_SUBSCRIBE_USER_EMAIL + * @return $this + */ + public function setSubscribe($UF_SUBSCRIBE_USER_EMAIL) + { + $this->UF_SUBSCRIBE_USER_EMAIL = $UF_SUBSCRIBE_USER_EMAIL; + + return $this; + } } diff --git a/intaro.retailcrm/classes/general/RCrmActions.php b/intaro.retailcrm/classes/general/RCrmActions.php index 11c7050f..8b45346a 100644 --- a/intaro.retailcrm/classes/general/RCrmActions.php +++ b/intaro.retailcrm/classes/general/RCrmActions.php @@ -237,12 +237,12 @@ class RCrmActions RetailCrmHistory::orderHistory(); self::uploadOrdersAgent(); } catch (\Throwable $exception) { - RCrmActions::eventLog( - 'RCrmActions', - 'orderAgent', + Logger::getInstance()->write( + 'Fail orderAgent:' . PHP_EOL . $exception->getMessage() . PHP_EOL . 'File: ' . $exception->getFile() . PHP_EOL . - 'Line: ' . $exception->getLine() . PHP_EOL + 'Line: ' . $exception->getLine() . PHP_EOL, + 'orderAgent' ); } diff --git a/intaro.retailcrm/classes/general/config/objects.xml b/intaro.retailcrm/classes/general/config/objects.xml index 82210e9a..4b4ac958 100644 --- a/intaro.retailcrm/classes/general/config/objects.xml +++ b/intaro.retailcrm/classes/general/config/objects.xml @@ -15,6 +15,7 @@ cumulativeDiscount personalDiscount discountCardNumber + emailMarketingUnsubscribedAt index countryIso diff --git a/intaro.retailcrm/classes/general/config/retailcrm.json b/intaro.retailcrm/classes/general/config/retailcrm.json index a0708826..af57234e 100644 --- a/intaro.retailcrm/classes/general/config/retailcrm.json +++ b/intaro.retailcrm/classes/general/config/retailcrm.json @@ -81,12 +81,7 @@ "default": false }, "subscribed": { - "type": "bool", - "default": false - }, - "subscribed": { - "type": "bool", - "default": false + "type": "string" }, "commentary": { "type": "string" diff --git a/intaro.retailcrm/classes/general/events/RetailCrmEvent.php b/intaro.retailcrm/classes/general/events/RetailCrmEvent.php index a3d10bb7..87b24255 100644 --- a/intaro.retailcrm/classes/general/events/RetailCrmEvent.php +++ b/intaro.retailcrm/classes/general/events/RetailCrmEvent.php @@ -1,6 +1,10 @@ 0) { + $user = UserRepository::getById($arFields['USER_ID']); + + if (isset($_POST['REGISTER']['PERSONAL_PHONE'])) { + $phone = htmlspecialchars($_POST['REGISTER']['PERSONAL_PHONE']); + + if ($user !== null) { + $user->setPersonalPhone($phone); + $user->save(); + } + + $arFields['PERSONAL_PHONE'] = $phone; + } + + /* @var CustomerService $customerService */ + $customerService = ServiceLocator::get(CustomerService::class); + $customer = $customerService->createModel($arFields['USER_ID']); + + $customerService->createOrUpdateCustomer($customer); + + RetailCrmService::writeLogsSubscribe($arFields); + + //Если пользователь выразил желание зарегистрироваться в ПЛ и согласился со всеми правилами + if ((int) $arFields['UF_REG_IN_PL_INTARO'] === 1 + && (int) $arFields['UF_AGREE_PL_INTARO'] === 1 + && (int) $arFields['UF_PD_PROC_PL_INTARO'] === 1 + ) { + $phone = $arFields['PERSONAL_PHONE'] ?? ''; + $card = $arFields['UF_CARD_NUM_INTARO'] ?? ''; + $customerId = (string) $arFields['USER_ID']; + + /** @var LoyaltyAccountService $service */ + $service = ServiceLocator::get(LoyaltyAccountService::class); + $createResponse = $service->createLoyaltyAccount($phone, $card, $customerId); + + $service->activateLpUserInBitrix($createResponse, $arFields['USER_ID']); + } + } + } + + /** + * @param $arFields + * + * @return void + * @throws InvalidArgumentException + */ + public static function OnAfterUserAdd($arFields) + { + RetailCrmService::writeLogsSubscribe($arFields); + } + /** * @return bool */ diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index f779679a..3fe712e9 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -155,9 +155,8 @@ class RetailCrmHistory if ($registerNewUser === true) { $customerBuilder->buildPassword(); - $registeredUserID = $newUser->Add( - $customerBuilder->getCustomer()->getObjectToArray() - ); + + $registeredUserID = $newUser->Add(self::getDataUser($customerBuilder)); if ($registeredUserID === false) { RCrmActions::eventLog( @@ -198,7 +197,9 @@ class RetailCrmHistory ); } - $u = $newUser->Update($customer['externalId'], $customerBuilder->getCustomer()->getObjectToArray()); + $customerArray = $customerBuilder->getCustomer()->getObjectToArray(); + $u = $newUser->Update($customer['externalId'], self::convertBooleanFields($customerArray)); + if (!$u) { RCrmActions::eventLog( 'RetailCrmHistory::customerHistory', @@ -457,9 +458,13 @@ class RetailCrmHistory $corporateCustomerBuilder->setCorporateContact($userData); $newUser = new CUser(); - $registeredUserID = $newUser->Add( - $corporateCustomerBuilder->getCustomer()->getObjectToArray() - ); + $customerArray = $corporateCustomerBuilder->getCustomer()->getObjectToArray(); + + if (!array_key_exists('UF_SUBSCRIBE_USER_EMAIL', $customerArray)) { + $customerArray['UF_SUBSCRIBE_USER_EMAIL'] = 'Y'; + } + + $registeredUserID = $newUser->Add(self::convertBooleanFields($customerArray)); if ($registeredUserID === false) { RCrmActions::eventLog( @@ -921,9 +926,8 @@ class RetailCrmHistory } if ($registerNewUser === true) { - $registeredUserID = $newUser->Add( - $customerBuilder->getCustomer()->getObjectToArray() - ); + $registeredUserID = $newUser->Add(self::getDataUser($customerBuilder)); + if ($registeredUserID === false) { RCrmActions::eventLog( 'RetailCrmHistory::orderHistory', @@ -2088,4 +2092,34 @@ class RetailCrmHistory ); } } + + /** + * @param array $array + * @return array + */ + public static function convertBooleanFields($array) + { + foreach ($array as $key => $value) { + if ($value === 'N') { + $array[$key] = false; + } + } + + return $array; + } + + /** + * @param $customerBuilder + * @return array + */ + private static function getDataUser($customerBuilder) + { + $customerArray = $customerBuilder->getCustomer()->getObjectToArray(); + + if (!array_key_exists('UF_SUBSCRIBE_USER_EMAIL', $customerArray)) { + $customerArray['UF_SUBSCRIBE_USER_EMAIL'] = 'Y'; + } + + return self::convertBooleanFields($customerArray); + } } diff --git a/intaro.retailcrm/classes/general/services/RetailCrmService.php b/intaro.retailcrm/classes/general/services/RetailCrmService.php index d889cffa..58081426 100644 --- a/intaro.retailcrm/classes/general/services/RetailCrmService.php +++ b/intaro.retailcrm/classes/general/services/RetailCrmService.php @@ -154,4 +154,28 @@ class RetailCrmService return $result; } + + /** + * @param array $arFields + * @return void + */ + public static function writeLogsSubscribe(array $arFields): void + { + if (array_key_exists('UF_SUBSCRIBE_USER_EMAIL', $arFields)) { + $actionSub = GetMessage('SUBSCRIBED_USER'); + $fileSub = 'subscribe'; + + if (empty($arFields['UF_SUBSCRIBE_USER_EMAIL'])) { + $actionSub = GetMessage('UNSUBSCRIBED_USER'); + $fileSub = 'unSubscribe'; + } + + $id = $arFields['ID'] ?? $arFields['USER_ID']; + + Logger::getInstance()->write( + $actionSub . ' (' . $id . ')', + $fileSub + ); + } + } } diff --git a/intaro.retailcrm/classes/general/user/RetailCrmUser.php b/intaro.retailcrm/classes/general/user/RetailCrmUser.php index 61019bdf..2572e228 100644 --- a/intaro.retailcrm/classes/general/user/RetailCrmUser.php +++ b/intaro.retailcrm/classes/general/user/RetailCrmUser.php @@ -27,7 +27,6 @@ class RetailCrmUser $customer = self::getSimpleCustomer($arFields); $customer['createdAt'] = new \DateTime($arFields['DATE_REGISTER']); - $customer['subscribed'] = false; $customer['contragent'] = ['contragentType' => $contragentType]; if ($send && isset($_COOKIE['_rc']) && $_COOKIE['_rc'] != '') { @@ -49,6 +48,10 @@ class RetailCrmUser $normalizer = new RestNormalizer(); $customer = $normalizer->normalize($customer, 'customers'); + if (empty($arFields['UF_SUBSCRIBE_USER_EMAIL'])) { + $customer['subscribed'] = false; + } + Logger::getInstance()->write($customer, 'customerSend'); if ( @@ -90,6 +93,7 @@ class RetailCrmUser if ($found) { $normalizer = new RestNormalizer(); $customer = $normalizer->normalize($customer, 'customers'); + $customer = self::getBooleanFields($customer, $arFields); if (function_exists('retailCrmBeforeCustomerSend')) { $newResCustomer = retailCrmBeforeCustomerSend($customer); @@ -133,4 +137,17 @@ class RetailCrmUser return $customer; } + + private static function getBooleanFields($customer, $arFields) + { + if (isset($arFields['UF_SUBSCRIBE_USER_EMAIL'])) { + if ($arFields['UF_SUBSCRIBE_USER_EMAIL'] === "1") { + $customer['subscribed'] = true; + } else { + $customer['subscribed'] = false; + } + } + + return $customer; + } } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 38d0a104..58155e93 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлена ошибка некорректного вывода информации о программе лояльности в личном кабинете клиента \ No newline at end of file +- Добавлена функция подписки на рекламно-информационные рассылки diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/lang/ru/template.php b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/lang/ru/template.php index 69faad47..fb2bdee2 100644 --- a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/lang/ru/template.php +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/lang/ru/template.php @@ -81,3 +81,4 @@ $MESS["SEC"] = "сек."; $MESS["RESEND_SMS"] = "Отправить смс повторно"; $MESS["RESEND_POSSIBLE"] = "Повторная отправка смс возможна через"; $MESS["LOYALTY_CONNECTION_ERROR"] = "Возникли проблемы с подключением к удаленному серверу. Попробуйте перезагрузить страницу."; +$MESS["SUBSCRIBE_EMAIL"] = "Согласен на рекламно-информационные рассылки"; diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/template.php b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/template.php index 4ae8931c..7f0a9e74 100644 --- a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/template.php +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default/template.php @@ -540,6 +540,19 @@ if ($arResult["LOYALTY_CONNECTION_ERROR"] === true) { :* + + + + +
+
+ +
+
+ + array( + "NAME" => GetMessage("USER_PROPERTY_NAME"), + "TYPE" => "STRING", + "DEFAULT" => "", + ), +); +?> \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/images/sec-unlocked.png b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/images/sec-unlocked.png new file mode 100644 index 00000000..b3ea2911 Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/images/sec-unlocked.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/images/sec.png b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/images/sec.png new file mode 100644 index 00000000..b9249a08 Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/images/sec.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/en/.parameters.php b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/en/.parameters.php new file mode 100644 index 00000000..c09d49d4 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/en/.parameters.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/en/template.php b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/en/template.php new file mode 100644 index 00000000..106d0274 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/en/template.php @@ -0,0 +1,64 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/ru/.parameters.php b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/ru/.parameters.php new file mode 100644 index 00000000..2c713dfe --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/ru/.parameters.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/ru/template.php b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/ru/template.php new file mode 100644 index 00000000..29d3a541 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/lang/ru/template.php @@ -0,0 +1,64 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/style.css b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/style.css new file mode 100644 index 00000000..d2fd8983 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/style.css @@ -0,0 +1,5 @@ +div.bx-auth-reg input.bx-auth-input {vertical-align:middle;} +div.bx-auth-reg span.bx-auth-secure {background-color:#FFFAE3; border:1px solid #DEDBC8; padding:2px; display:inline-block; vertical-align:middle;} +div.bx-auth-reg div.bx-auth-secure-icon {background-image:url(images/sec.png); background-repeat:no-repeat; background-position:center; width:19px; height:18px;} +div.bx-auth-reg div.bx-auth-secure-unlock {background-image:url(images/sec-unlocked.png);} + diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/style.min.css b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/style.min.css new file mode 100644 index 00000000..a3a5be34 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/style.min.css @@ -0,0 +1 @@ +div.bx-auth-reg input.bx-auth-input{vertical-align:middle}div.bx-auth-reg span.bx-auth-secure{background-color:#fffae3;border:1px solid #dedbc8;padding:2px;display:inline-block;vertical-align:middle}div.bx-auth-reg div.bx-auth-secure-icon{background-image:url(images/sec.png);background-repeat:no-repeat;background-position:center;width:19px;height:18px}div.bx-auth-reg div.bx-auth-secure-unlock{background-image:url(images/sec-unlocked.png)} \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/template.php b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/template.php new file mode 100644 index 00000000..667c1936 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/main.register/templates/.default_subscribe/template.php @@ -0,0 +1,279 @@ + +
+ +IsAuthorized()):?> + +

+ + + $error) + if (intval($key) == 0 && $key !== 0) + $arResult["ERRORS"][$key] = str_replace("#FIELD_NAME#", """.GetMessage("REGISTER_FIELD_".$key).""", $error); + + ShowError(implode("
", $arResult["ERRORS"])); + +elseif($arResult["USE_EMAIL_CONFIRMATION"] === "Y"): +?> +

+ + + + +
+ ''): +?> + " /> + +" /> + + + + + + + + + + + + + +
*" autocomplete="off" />
" />
+
+ + + + + +
+ + + +
+ ''): +?> + " /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $arUserField):?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
* + +
+ +
:*" autocomplete="off" class="bx-auth-input" /> + + " style="display:none"> +
+
+ + + +" autocomplete="off" />
" />IncludeComponent( + 'bitrix:main.calendar', + '', + array( + 'SHOW_INPUT' => 'N', + 'FORM_NAME' => 'regform', + 'INPUT_NAME' => 'REGISTER[PERSONAL_BIRTHDAY]', + 'SHOW_TIME' => 'N' + ), + null, + array("HIDE_ICONS"=>"Y") + ); + ?>
'' ? $arParams["USER_PROPERTY_NAME"] : GetMessage("USER_TYPE_EDIT_TAB")?>
:* + IncludeComponent( + "bitrix:system.field.edit", + $arUserField["USER_TYPE"]["USER_TYPE_ID"], + array("bVarsFromForm" => $arResult["bVarsFromForm"], "arUserField" => $arUserField, "form_name" => "regform"), null, array("HIDE_ICONS"=>"Y"));?>
+ " /> + " width="180" height="40" alt="CAPTCHA" /> +
:*
+ +
" />
+
+ +

+ + + +

*

+ + +
\ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/account.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/account.php new file mode 100644 index 00000000..4458f217 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/account.php @@ -0,0 +1,90 @@ +IsAuthorized()) +{ + LocalRedirect($arResult['PATH_TO_AUTH_PAGE']); +} + +if ($arParams['SET_TITLE'] === 'Y') +{ + $APPLICATION->SetTitle(Loc::getMessage("SPS_TITLE_ACCOUNT")); +} + +if ($arParams["MAIN_CHAIN_NAME"] !== '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_ACCOUNT")); + +if ($arParams['SHOW_ACCOUNT_COMPONENT'] !== 'N') +{ + $APPLICATION->IncludeComponent( + "bitrix:sale.personal.account", + "bootstrap_v4", + [ + "SET_TITLE" => "N", + "AUTH_FORM_IN_TEMPLATE" => 'Y', + ], + $component + ); +} +if ($arParams['SHOW_ACCOUNT_PAY_COMPONENT'] !== 'N' && $USER->IsAuthorized()) +{ + ?> +
+
+ +
+
+ +
+
+ IncludeComponent( + "bitrix:sale.account.pay", + "bootstrap_v4", + Array( + "COMPONENT_TEMPLATE" => "bootstrap_v4", + "REFRESHED_COMPONENT_MODE" => "Y", + "ELIMINATED_PAY_SYSTEMS" => $arParams['ACCOUNT_PAYMENT_ELIMINATED_PAY_SYSTEMS'], + "PATH_TO_BASKET" => $arParams['PATH_TO_BASKET'], + "PATH_TO_PAYMENT" => $arParams['PATH_TO_PAYMENT'], + "PERSON_TYPE" => $arParams['ACCOUNT_PAYMENT_PERSON_TYPE'], + "REDIRECT_TO_CURRENT_PAGE" => "N", + "SELL_AMOUNT" => $arParams['ACCOUNT_PAYMENT_SELL_TOTAL'], + "SELL_CURRENCY" => $arParams['ACCOUNT_PAYMENT_SELL_CURRENCY'], + "SELL_SHOW_FIXED_VALUES" => $arParams['ACCOUNT_PAYMENT_SELL_SHOW_FIXED_VALUES'], + "SELL_SHOW_RESULT_SUM" => $arParams['ACCOUNT_PAYMENT_SELL_SHOW_RESULT_SUM'], + "SELL_TOTAL" => $arParams['ACCOUNT_PAYMENT_SELL_TOTAL'], + "SELL_USER_INPUT" => $arParams['ACCOUNT_PAYMENT_SELL_USER_INPUT'], + "SELL_VALUES_FROM_VAR" => "N", + "SELL_VAR_PRICE_VALUE" => "", + "SET_TITLE" => "N", + "CONTEXT_SITE_ID" => $arParams["CONTEXT_SITE_ID"], + "AUTH_FORM_IN_TEMPLATE" => 'Y', + ), + $component + ); + } + ?> +
+
diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/images/sec-unlocked.png b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/images/sec-unlocked.png new file mode 100644 index 00000000..b3ea2911 Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/images/sec-unlocked.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/images/sec.png b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/images/sec.png new file mode 100644 index 00000000..b9249a08 Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/images/sec.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/lang/en/template.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/lang/en/template.php new file mode 100644 index 00000000..6dd53d52 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/bitrix/main.profile/.default/lang/en/template.php @@ -0,0 +1,18 @@ + + +
+ +
+ + + " /> + " /> +
+
+ 0) + { + if ($arResult["arUser"]["TIMESTAMP_X"] <> '') + { + ?> +
+ + +
+ '') + { + ?> +
+ + +
+ +
+ +
+
+ +
+
+
+ + " /> +
+
+
+ +
+ +
+ " /> +
+
+ +
+ +
+ " /> +
+
+
+ +
+ " /> +
+
+
+ +
+ " /> +
+
+ +
+ +
+ +
+
+
+ +
+ + +
+
+ +
+
+
+
+ + /> + +
+
+
+
+
+ 0) ? Loc::getMessage("MAIN_SAVE") : Loc::getMessage("MAIN_ADD"))?>"> + "> +
+
+ +
+ +
+ IncludeComponent( + "bitrix:socserv.auth.split", + ".default", + [ + "SHOW_PROFILES" => "Y", + "ALLOW_DELETE" => "Y", + ], + false + ); + } + ?> +
+ +
+ +
\ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_black.png b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_black.png new file mode 100644 index 00000000..1fa0f31f Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_black.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_blue.png b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_blue.png new file mode 100644 index 00000000..d097cce9 Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_blue.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_green.png b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_green.png new file mode 100644 index 00000000..8f95932e Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_green.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_red.png b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_red.png new file mode 100644 index 00000000..c5059129 Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_red.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_yellow.png b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_yellow.png new file mode 100644 index 00000000..b48cc87c Binary files /dev/null and b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/images/wt_yellow.png differ diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/index.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/index.php new file mode 100644 index 00000000..3fe73783 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/index.php @@ -0,0 +1,133 @@ + '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} + +$this->addExternalCss("/bitrix/css/main/font-awesome.css"); +$theme = Bitrix\Main\Config\Option::get("main", "wizard_eshop_bootstrap_theme_id", "blue", SITE_ID); + +$availablePages = array(); + +if ($arParams['SHOW_ORDER_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_ORDERS'], + "name" => Loc::getMessage("SPS_ORDER_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_ACCOUNT_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_ACCOUNT'], + "name" => Loc::getMessage("SPS_ACCOUNT_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_PRIVATE_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_PRIVATE'], + "name" => Loc::getMessage("SPS_PERSONAL_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_ORDER_PAGE'] === 'Y') +{ + + $delimeter = ($arParams['SEF_MODE'] === 'Y') ? "?" : "&"; + $availablePages[] = array( + "path" => $arResult['PATH_TO_ORDERS'].$delimeter."filter_history=Y", + "name" => Loc::getMessage("SPS_ORDER_PAGE_HISTORY"), + "icon" => '' + ); +} + +if ($arParams['SHOW_PROFILE_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_PROFILE'], + "name" => Loc::getMessage("SPS_PROFILE_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_BASKET_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arParams['PATH_TO_BASKET'], + "name" => Loc::getMessage("SPS_BASKET_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_SUBSCRIBE_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_SUBSCRIBE'], + "name" => Loc::getMessage("SPS_SUBSCRIBE_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_CONTACT_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arParams['PATH_TO_CONTACT'], + "name" => Loc::getMessage("SPS_CONTACT_PAGE_NAME"), + "icon" => '' + ); +} + +$customPagesList = CUtil::JsObjectToPhp($arParams['~CUSTOM_PAGES']); +if ($customPagesList) +{ + foreach ($customPagesList as $page) + { + $availablePages[] = array( + "path" => $page[0], + "name" => $page[1], + "icon" => (mb_strlen($page[2])) ? '' : "" + ); + } +} + +if (empty($availablePages)) +{ + ShowError(Loc::getMessage("SPS_ERROR_NOT_CHOSEN_ELEMENT")); +} +else +{ + ?> +
+ +
+ +
+ +
+ diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/account.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/account.php new file mode 100644 index 00000000..34dfa144 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/account.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/index.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/index.php new file mode 100644 index 00000000..1b784447 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/index.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_cancel.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_cancel.php new file mode 100644 index 00000000..5292744c --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_cancel.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_detail.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_detail.php new file mode 100644 index 00000000..4463ec0a --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_detail.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_list.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_list.php new file mode 100644 index 00000000..b59ec203 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/order_list.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/orders.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/orders.php new file mode 100644 index 00000000..b59ec203 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/orders.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/private.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/private.php new file mode 100644 index 00000000..75e29d51 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/private.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile.php new file mode 100644 index 00000000..3fe62b56 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile_detail.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile_detail.php new file mode 100644 index 00000000..3fe62b56 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile_detail.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile_list.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile_list.php new file mode 100644 index 00000000..3fe62b56 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/profile_list.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/subscribe.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/subscribe.php new file mode 100644 index 00000000..a2bda0c1 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/subscribe.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/template.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/template.php new file mode 100644 index 00000000..1b784447 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/en/template.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/ru/account.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/ru/account.php new file mode 100644 index 00000000..21d4ba23 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/lang/ru/account.php @@ -0,0 +1,5 @@ +IsAuthorized()) +{ + LocalRedirect($arResult['PATH_TO_AUTH_PAGE']); +} + +if ($arParams["MAIN_CHAIN_NAME"] <> '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_ORDERS"), $arResult['PATH_TO_ORDERS']); +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_ORDER_DETAIL", array("#ID#" => $arResult["VARIABLES"]["ID"]))); +$APPLICATION->IncludeComponent( + "bitrix:sale.personal.order.cancel", + "bootstrap_v4", + array( + "PATH_TO_LIST" => $arResult["PATH_TO_ORDERS"], + "PATH_TO_DETAIL" => $arResult["PATH_TO_ORDER_DETAIL"], + "AUTH_FORM_IN_TEMPLATE" => 'Y', + "SET_TITLE" =>$arParams["SET_TITLE"], + "ID" => $arResult["VARIABLES"]["ID"], + "CONTEXT_SITE_ID" => $arParams["CONTEXT_SITE_ID"], + ), + $component +); +?> diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/order_detail.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/order_detail.php new file mode 100644 index 00000000..07e689ac --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/order_detail.php @@ -0,0 +1,56 @@ +IsAuthorized()) +{ + LocalRedirect($arResult['PATH_TO_AUTH_PAGE']); +} + +if ($arParams["MAIN_CHAIN_NAME"] <> '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_ORDERS"), $arResult['PATH_TO_ORDERS']); +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_ORDER_DETAIL", array("#ID#" => urldecode($arResult["VARIABLES"]["ID"])))); +$arDetParams = array( + "PATH_TO_LIST" => $arResult["PATH_TO_ORDERS"], + "PATH_TO_CANCEL" => $arResult["PATH_TO_ORDER_CANCEL"], + "PATH_TO_COPY" => $arResult["PATH_TO_ORDER_COPY"], + "PATH_TO_PAYMENT" => $arParams["PATH_TO_PAYMENT"], + "SET_TITLE" =>$arParams["SET_TITLE"], + "ID" => $arResult["VARIABLES"]["ID"], + "ACTIVE_DATE_FORMAT" => $arParams["ACTIVE_DATE_FORMAT"], + "ALLOW_INNER" => $arParams["ALLOW_INNER"], + "ONLY_INNER_FULL" => $arParams["ONLY_INNER_FULL"], + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => $arParams["CACHE_TIME"], + "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], + "RESTRICT_CHANGE_PAYSYSTEM" => $arParams["ORDER_RESTRICT_CHANGE_PAYSYSTEM"], + "REFRESH_PRICES" => $arParams["ORDER_REFRESH_PRICES"], + "DISALLOW_CANCEL" => $arParams["ORDER_DISALLOW_CANCEL"], + "HIDE_USER_INFO" => $arParams["ORDER_HIDE_USER_INFO"], + "AUTH_FORM_IN_TEMPLATE" => 'Y', + "CONTEXT_SITE_ID" => $arParams["CONTEXT_SITE_ID"], + "CUSTOM_SELECT_PROPS" => $arParams["CUSTOM_SELECT_PROPS"] + ); +foreach($arParams as $key => $val) +{ + if(mb_strpos($key, "PROP_") !== false) + $arDetParams[$key] = $val; +} + +$APPLICATION->IncludeComponent( + "bitrix:sale.personal.order.detail", + "bootstrap_v4", + $arDetParams, + $component +); +?> diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/orders.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/orders.php new file mode 100644 index 00000000..ba38cce6 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/orders.php @@ -0,0 +1,62 @@ +IsAuthorized()) +{ + LocalRedirect($arResult['PATH_TO_AUTH_PAGE']); +} + +if ($arParams["MAIN_CHAIN_NAME"] !== '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} + +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_ORDERS"), $arResult['PATH_TO_ORDERS']); +$APPLICATION->IncludeComponent( + "bitrix:sale.personal.order.list", + "bootstrap_v4", + array( + "PATH_TO_DETAIL" => $arResult["PATH_TO_ORDER_DETAIL"], + "PATH_TO_CANCEL" => $arResult["PATH_TO_ORDER_CANCEL"], + "PATH_TO_CATALOG" => $arParams["PATH_TO_CATALOG"], + "PATH_TO_COPY" => $arResult["PATH_TO_ORDER_COPY"], + "PATH_TO_BASKET" => $arParams["PATH_TO_BASKET"], + "PATH_TO_PAYMENT" => $arParams["PATH_TO_PAYMENT"], + "SAVE_IN_SESSION" => $arParams["SAVE_IN_SESSION"], + "ORDERS_PER_PAGE" => $arParams["ORDERS_PER_PAGE"], + "SET_TITLE" =>$arParams["SET_TITLE"], + "ID" => $arResult["VARIABLES"]["ID"], + "NAV_TEMPLATE" => $arParams["NAV_TEMPLATE"], + "ACTIVE_DATE_FORMAT" => $arParams["ACTIVE_DATE_FORMAT"], + "HISTORIC_STATUSES" => $arParams["ORDER_HISTORIC_STATUSES"], + "ALLOW_INNER" => $arParams["ALLOW_INNER"], + "ONLY_INNER_FULL" => $arParams["ONLY_INNER_FULL"], + "CACHE_TYPE" => $arParams["CACHE_TYPE"], + "CACHE_TIME" => $arParams["CACHE_TIME"], + "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], + "DEFAULT_SORT" => $arParams["ORDER_DEFAULT_SORT"], + "DISALLOW_CANCEL" => $arParams["ORDER_DISALLOW_CANCEL"], + "RESTRICT_CHANGE_PAYSYSTEM" => $arParams["ORDER_RESTRICT_CHANGE_PAYSYSTEM"], + "REFRESH_PRICES" => $arParams["ORDER_REFRESH_PRICES"], + "CONTEXT_SITE_ID" => $arParams["CONTEXT_SITE_ID"], + "AUTH_FORM_IN_TEMPLATE" => 'Y', + ), + $component +); diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/private.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/private.php new file mode 100644 index 00000000..5baad315 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/private.php @@ -0,0 +1,119 @@ +AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_PRIVATE")); +if ($arParams['SET_TITLE'] == 'Y') +{ + $APPLICATION->SetTitle(Loc::getMessage("SPS_TITLE_PRIVATE")); +} + +if (!$USER->IsAuthorized() || $arResult['SHOW_LOGIN_FORM'] === 'Y') +{ + if ($arParams['USE_PRIVATE_PAGE_TO_AUTH'] !== 'Y') + { + ob_start(); + $APPLICATION->AuthForm('', false, false, 'N', false); + $authForm = ob_get_clean(); + } + else + { + if ($arResult['SHOW_FORGOT_PASSWORD_FORM'] === 'Y') + { + ob_start(); + $APPLICATION->IncludeComponent( + 'bitrix:main.auth.forgotpasswd', + '.default', + array( + 'AUTH_AUTH_URL' => $arResult['PATH_TO_PRIVATE'], +// 'AUTH_REGISTER_URL' => 'register.php', + ), + false + ); + $authForm = ob_get_clean(); + } + elseif($arResult['SHOW_CHANGE_PASSWORD_FORM'] === 'Y') + { + ob_start(); + $APPLICATION->IncludeComponent( + 'bitrix:main.auth.changepasswd', + '.default', + array( + 'AUTH_AUTH_URL' => $arResult['PATH_TO_PRIVATE'], +// 'AUTH_REGISTER_URL' => 'register.php', + ), + false + ); + $authForm = ob_get_clean(); + } + else + { + ob_start(); + $APPLICATION->IncludeComponent( + 'bitrix:main.auth.form', + '.default', + array( + 'AUTH_FORGOT_PASSWORD_URL' => $arResult['PATH_TO_PASSWORD_RESTORE'], +// 'AUTH_REGISTER_URL' => 'register.php', + 'AUTH_SUCCESS_URL' => $arResult['AUTH_SUCCESS_URL'], + 'DISABLE_SOCSERV_AUTH' => $arParams['DISABLE_SOCSERV_AUTH'], + ), + false + ); + $authForm = ob_get_clean(); + } + } + + ?> +
+ +
+
+
+ +
+ +
+
+ IncludeComponent( + "bitrix:main.profile", + "", + Array( + "SET_TITLE" =>$arParams["SET_TITLE"], + "AJAX_MODE" => $arParams['AJAX_MODE_PRIVATE'], + "SEND_INFO" => $arParams["SEND_INFO_PRIVATE"], + "CHECK_RIGHTS" => $arParams['CHECK_RIGHTS_PRIVATE'], + "EDITABLE_EXTERNAL_AUTH_ID" => $arParams['EDITABLE_EXTERNAL_AUTH_ID'], + "DISABLE_SOCSERV_AUTH" => $arParams['DISABLE_SOCSERV_AUTH'] + ), + $component + ); +} diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/profile.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/profile.php new file mode 100644 index 00000000..383537fa --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/profile.php @@ -0,0 +1,42 @@ +IsAuthorized()) +{ + LocalRedirect($arResult['PATH_TO_AUTH_PAGE']); +} + +if ($arParams["MAIN_CHAIN_NAME"] !== '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_PROFILE")); +$APPLICATION->IncludeComponent( + "bitrix:sale.personal.profile.list", + "bootstrap_v4", + [ + "PATH_TO_DETAIL" => $arResult['PATH_TO_PROFILE_DETAIL'], + "PATH_TO_DELETE" => $arResult['PATH_TO_PROFILE_DELETE'], + "PER_PAGE" => $arParams["PROFILES_PER_PAGE"], + "SET_TITLE" =>$arParams["SET_TITLE"], + "AUTH_FORM_IN_TEMPLATE" => 'Y', + ], + $component +); diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/profile_detail.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/profile_detail.php new file mode 100644 index 00000000..2abc0e7c --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/profile_detail.php @@ -0,0 +1,35 @@ +IsAuthorized()) +{ + LocalRedirect($arResult['PATH_TO_AUTH_PAGE']); +} + +if ($arParams["MAIN_CHAIN_NAME"] <> '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_PROFILE")); +$APPLICATION->IncludeComponent( + "bitrix:sale.personal.profile.detail", + "bootstrap_v4", + array( + "PATH_TO_LIST" => $arResult["PATH_TO_PROFILE"], + "PATH_TO_DETAIL" => $arResult["PATH_TO_PROFILE_DETAIL"], + "SET_TITLE" =>$arParams["SET_TITLE"], + "USE_AJAX_LOCATIONS" => $arParams['USE_AJAX_LOCATIONS_PROFILE'], + "COMPATIBLE_LOCATION_MODE" => $arParams['COMPATIBLE_LOCATION_MODE_PROFILE'], + "ID" => $arResult["VARIABLES"]["ID"], + "AUTH_FORM_IN_TEMPLATE" => 'Y', + ), + $component +); +?> diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/style.css b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/style.css new file mode 100644 index 00000000..3286c06b --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/style.css @@ -0,0 +1,49 @@ +.sale-personal-section-index-block { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + margin: 15px 0; + padding: 0; + height: 87%; + border-radius: 3px; + background-size: cover; + color: #fff; + text-align: center; + text-transform: uppercase; + opacity: .8; + transition: all 0.3s; + justify-content: space-around; + background-color: var(--theme-color-primary, #51cbce); +} + +@media (max-width: 992px) { + .sale-personal-section-index-block { + margin: 8px 0; + height: auto; + } +} + +.sale-personal-section-index-block:hover { opacity: 1; } + +.sale-personal-section-index-block-link, +.sale-personal-section-index-block-link:hover, +.sale-personal-section-index-block-link:active, +.sale-personal-section-index-block-link:focus, +.sale-personal-section-index-block-link:visited { + display: block; + padding: 25px 5px; + width: 100%; + color: #fff; + text-decoration: none; +} + +.sale-personal-section-index-block-link { color: #fff; } + +.sale-personal-section-index-block-ico { font-size: 64px; } + +.sale-personal-section-index-block-name { + color: #fff; + font-size: 15px; + margin: 0; + padding: 0; +} \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/style.min.css b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/style.min.css new file mode 100644 index 00000000..4f72b311 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/style.min.css @@ -0,0 +1 @@ +.sale-personal-section-index-block{display:-webkit-box;display:-ms-flexbox;display:flex;margin:15px 0;padding:0;height:87%;border-radius:3px;background-size:cover;color:#fff;text-align:center;text-transform:uppercase;opacity:.8;transition:all .3s;justify-content:space-around;background-color:var(--theme-color-primary,#51cbce)}@media(max-width:992px){.sale-personal-section-index-block{margin:8px 0;height:auto}}.sale-personal-section-index-block:hover{opacity:1}.sale-personal-section-index-block-link,.sale-personal-section-index-block-link:hover,.sale-personal-section-index-block-link:active,.sale-personal-section-index-block-link:focus,.sale-personal-section-index-block-link:visited{display:block;padding:25px 5px;width:100%;color:#fff;text-decoration:none}.sale-personal-section-index-block-link{color:#fff}.sale-personal-section-index-block-ico{font-size:64px}.sale-personal-section-index-block-name{color:#fff;font-size:15px;margin:0;padding:0} \ No newline at end of file diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/subscribe.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/subscribe.php new file mode 100644 index 00000000..b5051bec --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/subscribe.php @@ -0,0 +1,31 @@ +IsAuthorized()) +{ + LocalRedirect($arResult['PATH_TO_AUTH_PAGE']); +} + +if ($arParams["MAIN_CHAIN_NAME"] <> '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} +$APPLICATION->AddChainItem(Loc::getMessage("SPS_CHAIN_SUBSCRIBE_NEW")); +$APPLICATION->IncludeComponent( + 'bitrix:catalog.product.subscribe.list', + "bootstrap_v4", + array( + 'SET_TITLE' => $arParams['SET_TITLE'], + 'DETAIL_URL' => $arParams['SUBSCRIBE_DETAIL_URL'] + ), + $component +); + diff --git a/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/template.php b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/template.php new file mode 100644 index 00000000..827667b9 --- /dev/null +++ b/intaro.retailcrm/install/export/local/components/intaro/sale.personal.section/templates/.default/template.php @@ -0,0 +1,132 @@ + '') +{ + $APPLICATION->AddChainItem(htmlspecialcharsbx($arParams["MAIN_CHAIN_NAME"]), $arResult['SEF_FOLDER']); +} + +$this->addExternalCss("/bitrix/css/main/font-awesome.css"); +$theme = Bitrix\Main\Config\Option::get("main", "wizard_eshop_bootstrap_theme_id", "blue", SITE_ID); + +$availablePages = array(); + +if ($arParams['SHOW_ORDER_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_ORDERS'], + "name" => Loc::getMessage("SPS_ORDER_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_ACCOUNT_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_ACCOUNT'], + "name" => Loc::getMessage("SPS_ACCOUNT_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_PRIVATE_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_PRIVATE'], + "name" => Loc::getMessage("SPS_PERSONAL_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_ORDER_PAGE'] === 'Y') +{ + + $delimeter = ($arParams['SEF_MODE'] === 'Y') ? "?" : "&"; + $availablePages[] = array( + "path" => $arResult['PATH_TO_ORDERS'].$delimeter."filter_history=Y", + "name" => Loc::getMessage("SPS_ORDER_PAGE_HISTORY"), + "icon" => '' + ); +} + +if ($arParams['SHOW_PROFILE_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_PROFILE'], + "name" => Loc::getMessage("SPS_PROFILE_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_BASKET_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arParams['PATH_TO_BASKET'], + "name" => Loc::getMessage("SPS_BASKET_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_SUBSCRIBE_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arResult['PATH_TO_SUBSCRIBE'], + "name" => Loc::getMessage("SPS_SUBSCRIBE_PAGE_NAME"), + "icon" => '' + ); +} + +if ($arParams['SHOW_CONTACT_PAGE'] === 'Y') +{ + $availablePages[] = array( + "path" => $arParams['PATH_TO_CONTACT'], + "name" => Loc::getMessage("SPS_CONTACT_PAGE_NAME"), + "icon" => '' + ); +} + +$customPagesList = CUtil::JsObjectToPhp($arParams['~CUSTOM_PAGES']); +if ($customPagesList) +{ + foreach ($customPagesList as $page) + { + $availablePages[] = array( + "path" => $page[0], + "name" => $page[1], + "icon" => (mb_strlen($page[2])) ? '' : "" + ); + } +} + +if (empty($availablePages)) +{ + ShowError(Loc::getMessage("SPS_ERROR_NOT_CHOSEN_ELEMENT")); +} +else +{ + ?> +
+ +
+ +
+ +
+ diff --git a/intaro.retailcrm/install/export/sub-register/index.php b/intaro.retailcrm/install/export/sub-register/index.php new file mode 100644 index 00000000..82312725 --- /dev/null +++ b/intaro.retailcrm/install/export/sub-register/index.php @@ -0,0 +1,21 @@ +SetTitle('Регистрация'); +?> + +IncludeComponent( + 'bitrix:main.register', + 'default_subscribe', + [ + 'AUTH' => 'Y', + 'REQUIRED_FIELDS' => [], + 'SET_TITLE' => 'Y', + 'SHOW_FIELDS' => ['NAME'], + 'SUCCESS_PAGE' => '', + 'USER_PROPERTY' => [], + 'USER_PROPERTY_NAME' => '', + 'USE_BACKURL' => 'Y', + ] +); ?> + + diff --git a/intaro.retailcrm/install/index.php b/intaro.retailcrm/install/index.php index c43f1d34..5f962a4c 100644 --- a/intaro.retailcrm/install/index.php +++ b/intaro.retailcrm/install/index.php @@ -14,7 +14,7 @@ use Bitrix\Sale\Delivery\Services\Manager; use Bitrix\Sale\EventActions; use Bitrix\Sale\Internals\OrderTable; use Intaro\RetailCrm\Component\ConfigProvider; -use Intaro\RetailCrm\Component\Installer\LoyaltyInstallerTrait; +use Intaro\RetailCrm\Component\Installer\InstallerTrait; use Intaro\RetailCrm\Service\OrderLoyaltyDataService; use Intaro\RetailCrm\Vendor\Symfony\Component\Process\PhpExecutableFinder; use RetailCrm\ApiClient; @@ -29,11 +29,11 @@ if (class_exists('intaro_retailcrm')) { return false; } -include(__DIR__ . '/../lib/component/installer/loyaltyinstallertrait.php'); +include (__DIR__ . '/../lib/component/installer/installertrait.php'); class intaro_retailcrm extends CModule { - use LoyaltyInstallerTrait; + use InstallerTrait; public const V5 = 'v5'; public $MODULE_ID = 'intaro.retailcrm'; @@ -247,9 +247,9 @@ class intaro_retailcrm extends CModule include($this->INSTALL_PATH . '/../lib/component/apiclient/clientadapter.php'); $this->CopyFiles(); - $this->addLPUserFields(); - $this->addLPEvents(); + $this->addEvents(); $this->addAgreement(); + $this->addUserFields(); OrderLoyaltyDataService::createLoyaltyHlBlock(); @@ -1069,6 +1069,9 @@ class intaro_retailcrm extends CModule RegisterModuleDependences('sale', 'OnSaleOrderDeleted', $this->MODULE_ID, 'RetailCrmEvent', 'orderDelete'); RegisterModuleDependences('sale', 'OnSalePaymentEntitySaved', $this->MODULE_ID, 'RetailCrmEvent', 'paymentSave'); RegisterModuleDependences('sale', 'OnSalePaymentEntityDeleted', $this->MODULE_ID, 'RetailCrmEvent', 'paymentDelete'); + RegisterModuleDependences('main', 'OnAfterUserRegister', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserRegister'); + RegisterModuleDependences('main', 'OnAfterUserAdd', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserAdd'); + COption::SetOptionString($this->MODULE_ID, $this->CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types']))); COption::SetOptionString($this->MODULE_ID, $this->CRM_INVENTORIES_UPLOAD, 'N'); @@ -1266,6 +1269,8 @@ class intaro_retailcrm extends CModule UnRegisterModuleDependences('main', 'OnBeforeProlog', $this->MODULE_ID, 'RetailCrmUa', 'add'); UnRegisterModuleDependences('sale', 'OnSalePaymentEntitySaved', $this->MODULE_ID, 'RetailCrmEvent', 'paymentSave'); UnRegisterModuleDependences('sale', 'OnSalePaymentEntityDeleted', $this->MODULE_ID, 'RetailCrmEvent', 'paymentDelete'); + UnRegisterModuleDependences('main', 'OnAfterUserRegister', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserRegister'); + UnRegisterModuleDependences('main', 'OnAfterUserAdd', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserAdd'); if ( CModule::IncludeModule('catalog') diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index b3fb9049..38bb6f73 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.3.20', - 'VERSION_DATE' => '2023-07-25 13:00:00' + 'VERSION' => '6.4.0', + 'VERSION_DATE' => '2023-08-22 13:00:00' ]; diff --git a/intaro.retailcrm/lang/en/classes/general/services/RetailCrmService.php b/intaro.retailcrm/lang/en/classes/general/services/RetailCrmService.php new file mode 100644 index 00000000..607f8cda --- /dev/null +++ b/intaro.retailcrm/lang/en/classes/general/services/RetailCrmService.php @@ -0,0 +1,4 @@ +setBooleanParameters($serialized); $response = $this->client->customersCreate($serialized['customer'] ?? [], $request->site); return Deserializer::deserializeArray($response->getResponseBody(), CustomerChangeResponse::class); @@ -182,4 +183,18 @@ trait CustomersTrait return Deserializer::deserializeArray($response->getResponseBody(), HistoryResponse::class); } + + /** + * @param array $serializedRequest + * @return array + */ + private function setBooleanParameters($serializedRequest) + { + if (empty($serializedRequest['customer']['subscribed'])) + { + $serializedRequest['customer']['subscribed'] = false; + } + + return $serializedRequest; + } } diff --git a/intaro.retailcrm/lib/component/builder/api/customerbuilder.php b/intaro.retailcrm/lib/component/builder/api/customerbuilder.php index 0a1c9bbe..2f022fb0 100644 --- a/intaro.retailcrm/lib/component/builder/api/customerbuilder.php +++ b/intaro.retailcrm/lib/component/builder/api/customerbuilder.php @@ -162,7 +162,7 @@ class CustomerBuilder implements BuilderInterface $this->customer->externalId = $this->user->getId(); $this->customer->email = $this->user->getEmail(); $this->customer->createdAt = $this->user->getDateRegister(); - $this->customer->subscribed = false; + $this->customer->subscribed = !empty($this->user->getSubscribe()); } /** diff --git a/intaro.retailcrm/lib/component/constants.php b/intaro.retailcrm/lib/component/constants.php index 1f57c107..433ee2a2 100644 --- a/intaro.retailcrm/lib/component/constants.php +++ b/intaro.retailcrm/lib/component/constants.php @@ -101,7 +101,6 @@ class Constants public const LP_EVENTS = [ ['EVENT_NAME' => 'OnSaleOrderSaved', 'FROM_MODULE' => 'sale'], ['EVENT_NAME' => 'OnSaleComponentOrderResultPrepared', 'FROM_MODULE' => 'sale'], - ['EVENT_NAME' => 'OnAfterUserRegister', 'FROM_MODULE' => 'main'], ]; public const SITES_AVAILABLE = 'sites_available'; } diff --git a/intaro.retailcrm/lib/component/handlers/eventshandlers.php b/intaro.retailcrm/lib/component/handlers/eventshandlers.php index e12e05f1..053895c8 100644 --- a/intaro.retailcrm/lib/component/handlers/eventshandlers.php +++ b/intaro.retailcrm/lib/component/handlers/eventshandlers.php @@ -214,51 +214,4 @@ class EventsHandlers Logger::getInstance()->write(GetMessage('CAN_NOT_SAVE_ORDER') . $exception->getMessage(), 'uploadApiErrors'); } } - - /** - * Регистрирует пользователя в CRM системе после регистрации на сайте - * - * @param array $arFields - * @return mixed - * @throws \ReflectionException - */ - public static function OnAfterUserRegisterHandler(array $arFields): void - { - if (isset($arFields['USER_ID']) && $arFields['USER_ID'] > 0) { - $user = UserRepository::getById($arFields['USER_ID']); - - if (isset($_POST['REGISTER']['PERSONAL_PHONE'])) { - $phone = htmlspecialchars($_POST['REGISTER']['PERSONAL_PHONE']); - - if ($user !== null) { - $user->setPersonalPhone($phone); - $user->save(); - } - - $arFields['PERSONAL_PHONE'] = $phone; - } - - /* @var CustomerService $customerService */ - $customerService = ServiceLocator::get(CustomerService::class); - $customer = $customerService->createModel($arFields['USER_ID']); - - $customerService->createOrUpdateCustomer($customer); - - //Если пользователь выразил желание зарегистрироваться в ПЛ и согласился со всеми правилами - if ((int) $arFields['UF_REG_IN_PL_INTARO'] === 1 - && (int) $arFields['UF_AGREE_PL_INTARO'] === 1 - && (int) $arFields['UF_PD_PROC_PL_INTARO'] === 1 - ) { - $phone = $arFields['PERSONAL_PHONE'] ?? ''; - $card = $arFields['UF_CARD_NUM_INTARO'] ?? ''; - $customerId = (string) $arFields['USER_ID']; - - /** @var LoyaltyAccountService $service */ - $service = ServiceLocator::get(LoyaltyAccountService::class); - $createResponse = $service->createLoyaltyAccount($phone, $card, $customerId); - - $service->activateLpUserInBitrix($createResponse, $arFields['USER_ID']); - } - } - } } diff --git a/intaro.retailcrm/lib/component/installer/loyaltyinstallertrait.php b/intaro.retailcrm/lib/component/installer/installertrait.php similarity index 75% rename from intaro.retailcrm/lib/component/installer/loyaltyinstallertrait.php rename to intaro.retailcrm/lib/component/installer/installertrait.php index 10f27f35..c8d25f15 100644 --- a/intaro.retailcrm/lib/component/installer/loyaltyinstallertrait.php +++ b/intaro.retailcrm/lib/component/installer/installertrait.php @@ -1,16 +1,5 @@ - * @license MIT - * @link http://retailcrm.ru - * @see http://retailcrm.ru/docs - */ - namespace Intaro\RetailCrm\Component\Installer; use Bitrix\Main\ArgumentException; @@ -28,12 +17,12 @@ use RCrmActions; IncludeModuleLangFile(__FILE__); -trait LoyaltyInstallerTrait +trait InstallerTrait { /** - * create loyalty program events handlers + * Создание событий для программы лояльности */ - public function addLPEvents(): void + public function addEvents(): void { $eventManager = EventManager::getInstance(); @@ -69,7 +58,7 @@ trait LoyaltyInstallerTrait } /** - * CamelCase в имени является требованием Bitrix. Изменить на lowerCamelCase нельзя + * Перемещение модульных шаблонов в CMS */ public function CopyFiles(): void { @@ -83,37 +72,45 @@ trait LoyaltyInstallerTrait false ); - $lpTemplateNames = [ - 'sale.order.ajax', - 'sale.basket.basket', - 'main.register', + $templateNames = [ + 'default_loyalty' => [ + 0 => [ + 'name' => 'sale.order.ajax', + 'templateDirectory' => '.default' + ], + 1 => [ + 'name' => 'sale.basket.basket', + 'templateDirectory' => '.default' + ], + 2 => [ + 'name' => 'main.register', + 'templateDirectory' => '.default' + ], + ], + + 'default_subscribe' => [ + 0 => [ + 'name' => 'sale.personal.section', + 'templateDirectory' => '.default' + ], + 1 => [ + 'name' => 'main.register', + 'templateDirectory' => '.default_subscribe' + ] + ] ]; - foreach ($lpTemplateNames as $lpTemplateName){ - $lpTemplatePath = $_SERVER['DOCUMENT_ROOT'] - . '/local/templates/.default/components/bitrix/' . $lpTemplateName . '/default_loyalty'; - - if (!file_exists($lpTemplatePath)) { - $pathFrom = $_SERVER['DOCUMENT_ROOT'] - . '/bitrix/modules/intaro.retailcrm/install/export/local/components/intaro/' - . $lpTemplateName - . '/templates/.default'; - - CopyDirFiles( - $pathFrom, - $lpTemplatePath, - true, - true, - false - ); + foreach ($templateNames as $directory => $templates) { + foreach ($templates as $template) { + $this->copy($directory, $template); } } } /** - * Add USER fields for LP + * Добавление полей пользователя для ПЛ и подписки */ - public function addLPUserFields(): void + public function addUserFields(): void { $this->addCustomUserFields( [ @@ -154,6 +151,10 @@ trait LoyaltyInstallerTrait 'name' => 'UF_EXT_REG_PL_INTARO', 'title' => GetMessage('UF_EXT_REG_PL_INTARO_TITLE'), ], + [ + 'name' => 'UF_SUBSCRIBE_USER_EMAIL', + 'title' => GetMessage('UF_SUBSCRIBE_USER_EMAIL_TITLE') + ] ] ); } @@ -248,4 +249,27 @@ trait LoyaltyInstallerTrait ); } } -} + + private function copy($directory, $template): void + { + $templatePath = $_SERVER['DOCUMENT_ROOT'] + . '/local/templates/.default/components/bitrix/' . $template['name'] . '/'. $directory + ; + + if (!file_exists($templatePath)) { + $pathFrom = $_SERVER['DOCUMENT_ROOT'] + . '/bitrix/modules/intaro.retailcrm/install/export/local/components/intaro/' + . $template['name'] + . '/templates/' . $template['templateDirectory'] + ; + + CopyDirFiles( + $pathFrom, + $templatePath, + true, + true, + false + ); + } + } +} \ No newline at end of file diff --git a/intaro.retailcrm/lib/model/bitrix/user.php b/intaro.retailcrm/lib/model/bitrix/user.php index 757057c3..1fb2ae11 100644 --- a/intaro.retailcrm/lib/model/bitrix/user.php +++ b/intaro.retailcrm/lib/model/bitrix/user.php @@ -524,6 +524,14 @@ class User extends AbstractSerializableModel */ private $loyalty; + /** + * @var bool + * + * @Mapping\Type("boolean") + * @Mapping\SerializedName("UF_SUBSCRIBE_USER_EMAIL") + */ + private $subscribe; + /** * @return int */ @@ -1730,4 +1738,24 @@ class User extends AbstractSerializableModel { $this->loyalty = $loyalty; } + + /** + * @return bool + */ + public function getSubscribe() + { + return $this->subscribe; + } + + + /** + * @param bool $subscribe + * @return $this + */ + public function setSubscribe($subscribe) + { + $this->subscribe = $subscribe; + + return $this; + } } diff --git a/intaro.retailcrm/updater.php b/intaro.retailcrm/updater.php index c2783c69..60a990fb 100644 --- a/intaro.retailcrm/updater.php +++ b/intaro.retailcrm/updater.php @@ -1074,6 +1074,102 @@ class LoyaltyProgramUpdater } } +class UpdateSubscribe +{ + public function CopyFiles(): self + { + $pathFrom = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/install'; + + CopyDirFiles( + $pathFrom . '/export', + $_SERVER['DOCUMENT_ROOT'], + true, + true, + false + ); + + $templateNames = [ + 'default_subscribe' => [ + 0 => [ + 'name' => 'sale.personal.section', + 'templateDirectory' => '.default' + ], + 1 => [ + 'name' => 'main.register', + 'templateDirectory' => '.default_subscribe' + ] + ] + ]; + + foreach ($templateNames as $directory => $templates) { + foreach ($templates as $template) { + $templatePath = $_SERVER['DOCUMENT_ROOT'] + . '/local/templates/.default/components/bitrix/' . $template['name'] . '/' . $directory + ; + + if (!file_exists($templatePath)) { + $pathFrom = $_SERVER['DOCUMENT_ROOT'] + . '/bitrix/modules/intaro.retailcrm/install/export/local/components/intaro/' + . $template['name'] + . '/templates/' . $template['templateDirectory'] + ; + + CopyDirFiles( + $pathFrom, + $templatePath, + true, + true, + false + ); + } + } + } + + return $this; + } + + public function addEvent(): self + { + $eventManager = EventManager::getInstance(); + + $eventManager->unRegisterEventHandler( + 'main', + 'OnAfterUserRegister', + 'intaro.retailcrm', + 'Intaro\RetailCrm\Component\Handlers\EventsHandlers', + 'OnAfterUserRegisterHandler' + ); + + RegisterModuleDependences('main', 'OnAfterUserRegister', 'intaro.retailcrm', 'RetailCrmEvent', 'OnAfterUserRegister'); + RegisterModuleDependences('main', 'OnAfterUserAdd', 'intaro.retailcrm', 'RetailCrmEvent', 'OnAfterUserAdd'); + + return $this; + } + + public function addCustomUserField(): self + { + $arProps = [ + 'ENTITY_ID' => 'USER', + 'FIELD_NAME' => 'UF_SUBSCRIBE_USER_EMAIL', + 'USER_TYPE_ID' => 'boolean', + 'MULTIPLE' => 'N', + 'MANDATORY' => 'N', + 'EDIT_FORM_LABEL' => ['ru' => 'Подписка на события'], + + ]; + + $props = array_merge($arProps, []); + $obUserField = new CUserTypeEntity(); + $dbRes = CUserTypeEntity::GetList([], ['FIELD_NAME' => 'UF_SUBSCRIBE_USER_EMAIL'])->fetch(); + + if (!$dbRes['ID']) { + $obUserField->Add($props); + } + + return $this; + } +} + /** * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ObjectPropertyException @@ -1093,6 +1189,11 @@ function update() UnRegisterModuleDependences("main", "OnBeforeProlog", 'intaro.retailcrm', "RetailCrmPricePrchase", "add"); UnRegisterModuleDependences("main", "OnBeforeProlog", 'intaro.retailcrm', "RetailCrmDc", "add"); UnRegisterModuleDependences("main", "OnBeforeProlog", 'intaro.retailcrm', "RetailCrmCc", "add"); + + (new UpdateSubscribe()) + ->CopyFiles() + ->addEvent() + ->addCustomUserField(); } try {