add part of template logic
This commit is contained in:
parent
9fe54d2e52
commit
a1abded059
13 changed files with 491 additions and 30 deletions
|
@ -1,4 +1,4 @@
|
|||
<?
|
||||
<?php
|
||||
$MESS["AUTH_REGISTER"] = "Регистрация";
|
||||
$MESS["REGISTER_CAPTCHA_TITLE"] = "Защита от автоматической регистрации";
|
||||
$MESS["REGISTER_CAPTCHA_PROMT"] = "Введите слово на картинке";
|
||||
|
@ -60,4 +60,7 @@ $MESS["AUTH_SECURE_NOTE"] = "Перед отправкой формы парол
|
|||
$MESS["AUTH_NONSECURE_NOTE"] = "Пароль будет отправлен в открытом виде. Включите JavaScript в браузере, чтобы зашифровать пароль перед отправкой.";
|
||||
$MESS["main_register_sms"] = "Код подтверждения из СМС:";
|
||||
$MESS["main_register_sms_send"] = "Отправить";
|
||||
?>
|
||||
$MESS["UF_REG_IN_PL_INTARO"] = "Зарегистрироваться в программе лояльности:";
|
||||
$MESS["UF_AGREE_PL_INTARO"] = "программы лояльности:";
|
||||
$MESS["I_AM_AGREE"] = "Я согласен с условиями";
|
||||
$MESS["UF_PD_PROC_PL_INTARO"] = "обработки персональных данных:";
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Bitrix\Main\ArgumentException;
|
||||
use Bitrix\Main\Loader;
|
||||
use Bitrix\Main\ObjectPropertyException;
|
||||
use Bitrix\Main\SystemException;
|
||||
use Intaro\RetailCrm\Repository\AgreementRepository;
|
||||
Loader::includeModule('intaro.retailcrm');
|
||||
|
||||
try {
|
||||
$agreementPersonalData = AgreementRepository::getFirstByWhere(
|
||||
['AGREEMENT_TEXT'],
|
||||
[
|
||||
['CODE', '=', 'AGREEMENT_PERSONAL_DATA_CODE'],
|
||||
]
|
||||
);
|
||||
$agreementLoyaltyProgram = AgreementRepository::getFirstByWhere(
|
||||
['AGREEMENT_TEXT'],
|
||||
[
|
||||
['CODE', '=', 'AGREEMENT_LOYALTY_PROGRAM_CODE'],
|
||||
]
|
||||
);
|
||||
$arResult['AGREEMENT_PERSONAL_DATA'] = $agreementPersonalData['AGREEMENT_TEXT'];
|
||||
$arResult['AGREEMENT_LOYALTY_PROGRAM'] = $agreementLoyaltyProgram['AGREEMENT_TEXT'];
|
||||
} catch (ObjectPropertyException | ArgumentException | SystemException $e) {
|
||||
AddMessage2Log($e->getMessage());
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
function addTelNumber(userId) {
|
||||
$('#confirmationCode').show();
|
||||
console.log(userId);
|
||||
}
|
|
@ -23,17 +23,93 @@ if($arResult["SHOW_SMS_FIELD"] == true)
|
|||
CJSCore::Init('phone_auth');
|
||||
}
|
||||
?>
|
||||
<?php CUtil::InitJSCore( array('ajax' , 'jquery' , 'popup' )); ?>
|
||||
<div id="uf_agree_pl_intaro_popup" style="display:none;">
|
||||
<?= $arResult['AGREEMENT_LOYALTY_PROGRAM']?>
|
||||
</div>
|
||||
<div id="uf_pd_proc_pl_intaro_popup" style="display:none;">
|
||||
<?= $arResult['AGREEMENT_PERSONAL_DATA']?>
|
||||
</div>
|
||||
<script>
|
||||
BX.ready(function(){
|
||||
const lpAgreementPopup = new BX.PopupWindow('lp_agreement_popup', window.body, {
|
||||
autoHide: true,
|
||||
offsetTop: 1,
|
||||
offsetLeft: 0,
|
||||
lightShadow: true,
|
||||
closeIcon: true,
|
||||
closeByEsc: true,
|
||||
overlay: {
|
||||
backgroundColor: 'grey', opacity: '30'
|
||||
}
|
||||
});
|
||||
lpAgreementPopup.setContent(BX('uf_agree_pl_intaro_popup'));
|
||||
BX.bindDelegate(
|
||||
document.body, 'click', {className: 'lp_agreement_link' },
|
||||
BX.proxy(function(e){
|
||||
if(!e)
|
||||
e = window.event;
|
||||
lpAgreementPopup.show();
|
||||
return BX.PreventDefault(e);
|
||||
}, lpAgreementPopup)
|
||||
);
|
||||
|
||||
const personalDataAgreementPopup = new BX.PopupWindow('personal_data_agreement_popup', window.body, {
|
||||
autoHide: true,
|
||||
offsetTop: 1,
|
||||
offsetLeft: 0,
|
||||
lightShadow: true,
|
||||
closeIcon: true,
|
||||
closeByEsc: true,
|
||||
overlay: {
|
||||
backgroundColor: 'grey', opacity: '30'
|
||||
}
|
||||
});
|
||||
personalDataAgreementPopup.setContent(BX('uf_pd_proc_pl_intaro_popup'));
|
||||
BX.bindDelegate(
|
||||
document.body, 'click', {className: 'personal_data_agreement_link'},
|
||||
BX.proxy(function(e){
|
||||
if(!e)
|
||||
e = window.event;
|
||||
personalDataAgreementPopup.show();
|
||||
return BX.PreventDefault(e);
|
||||
}, personalDataAgreementPopup)
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<div class="bx-auth-reg">
|
||||
|
||||
<?if($USER->IsAuthorized()):?>
|
||||
|
||||
<p><?echo GetMessage("MAIN_REGISTER_AUTH")?></p>
|
||||
<?php
|
||||
$this->addExternalJs(SITE_TEMPLATE_PATH . '/script.js');
|
||||
|
||||
$rsUser = CUser::GetByID($USER->GetID());
|
||||
$arUser = $rsUser->Fetch();
|
||||
|
||||
if (
|
||||
isset($arUser['UF_REG_IN_PL_INTARO'], $arUser['UF_AGREE_PL_INTARO'], $arUser['UF_PD_PROC_PL_INTARO'])
|
||||
&& (int)$arUser['UF_REG_IN_PL_INTARO'] === 1
|
||||
&& (int)$arUser['UF_AGREE_PL_INTARO'] === 1
|
||||
&& (int)$arUser['UF_PD_PROC_PL_INTARO'] === 1
|
||||
) { ?>
|
||||
<b>Для завершения регистрации в программе лояльности введите номер телефона</b><br>
|
||||
<b>Мы отправим на него код подтверждения</b><br>
|
||||
<input type="tel" id="regNumber" placeholder="+7 (900) 000-00-00">
|
||||
<input type="button" onclick="addTelNumber(<?=$USER->GetID()?>)" value="Отправить код подтверждения"/>
|
||||
<br>
|
||||
<div id="confirmationCode" style="display: none;">
|
||||
<input type="text" placeholder="Код подтверждения">
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?else:?>
|
||||
<?
|
||||
if (count($arResult["ERRORS"]) > 0):
|
||||
foreach ($arResult["ERRORS"] as $key => $error)
|
||||
if (intval($key) == 0 && $key !== 0)
|
||||
if (intval($key) == 0 && $key !== 0)
|
||||
$arResult["ERRORS"][$key] = str_replace("#FIELD_NAME#", """.GetMessage("REGISTER_FIELD_".$key).""", $error);
|
||||
|
||||
ShowError(implode("<br />", $arResult["ERRORS"]));
|
||||
|
@ -225,6 +301,37 @@ document.getElementById('bx_auth_secure').style.display = 'inline-block';
|
|||
array("bVarsFromForm" => $arResult["bVarsFromForm"], "arUserField" => $arUserField, "form_name" => "regform"), null, array("HIDE_ICONS"=>"Y"));?></td></tr>
|
||||
<?endforeach;?>
|
||||
<?endif;?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="fields boolean" id="main_UF_REG_IN_PL_INTARO">
|
||||
<div class="fields boolean"><input type="hidden" value="0" name="UF_REG_IN_PL_INTARO">
|
||||
<label><input type="checkbox" value="1" name="UF_REG_IN_PL_INTARO"> да</label></div>
|
||||
</div>
|
||||
</td>
|
||||
<td><?= GetMessage("UF_REG_IN_PL_INTARO")?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="fields boolean" id="main_UF_AGREE_PL_INTARO">
|
||||
<div class="fields boolean"><input type="hidden" value="0" name="UF_AGREE_PL_INTARO">
|
||||
<label><input type="checkbox" value="1" name="UF_AGREE_PL_INTARO"> да</label></div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<?= GetMessage("I_AM_AGREE")?> <a class="lp_agreement_link" href="javascript:void(0)" ><?= GetMessage("UF_AGREE_PL_INTARO")?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="fields boolean" id="main_UF_PD_PROC_PL_INTARO">
|
||||
<div class="fields boolean"><input type="hidden" value="0" name="UF_PD_PROC_PL_INTARO">
|
||||
<label><input type="checkbox" value="1" name="UF_PD_PROC_PL_INTARO"> да</label></div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<?= GetMessage("I_AM_AGREE")?> <a class="personal_data_agreement_link" href="javascript:void(0)" ><?= GetMessage("UF_PD_PROC_PL_INTARO")?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?// ******************** /User properties ***************************************************?>
|
||||
<?
|
||||
/* CAPTCHA */
|
||||
|
|
|
@ -10,21 +10,24 @@ global $MESS;
|
|||
use Bitrix\Highloadblock\HighloadBlockTable;
|
||||
use Bitrix\Main\Application;
|
||||
use Bitrix\Main\ArgumentException;
|
||||
use Bitrix\Main\ArgumentOutOfRangeException;
|
||||
use Bitrix\Main\Context;
|
||||
use Bitrix\Main\EventManager;
|
||||
use Bitrix\Main\Loader;
|
||||
use Bitrix\Main\ObjectPropertyException;
|
||||
use Bitrix\Main\SystemException;
|
||||
use Bitrix\Main\UserConsent\Internals\AgreementTable;
|
||||
use Bitrix\Sale\Internals\OrderPropsGroupTable;
|
||||
use Bitrix\Sale\Internals\PaySystemActionTable;
|
||||
use Bitrix\Sale\Delivery\Services\Manager;
|
||||
use Bitrix\sale\EventActions;
|
||||
use Bitrix\Sale\Internals\OrderTable;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Agreement;
|
||||
use Intaro\RetailCrm\Repository\AgreementRepository;
|
||||
use \RetailCrm\ApiClient;
|
||||
use RetailCrm\Exception\CurlException;
|
||||
use Intaro\RetailCrm\Component\Loyalty\EventsHandlers;
|
||||
use Intaro\RetailCrm\Repository\OrderPropsRepository;
|
||||
use Intaro\RetailCrm\Repository\PersonTypeRepository;
|
||||
use Intaro\RetailCrm\Repository\ToModuleRepository;
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
@ -55,9 +58,12 @@ class intaro_retailcrm extends CModule
|
|||
['EVENT_NAME' => 'OnSaleComponentOrderOneStepProcess', 'FROM_MODULE' => 'sale'],
|
||||
['EVENT_NAME' => 'OnSaleComponentOrderResultPrepared', 'FROM_MODULE' => 'sale'],
|
||||
];
|
||||
|
||||
public const V5 = 'v5';
|
||||
public const INTARO_BONUS = 'INTARO_BONUS';
|
||||
|
||||
public const V5 = 'v5';
|
||||
public const INTARO_BONUS = 'INTARO_BONUS';
|
||||
public const AGREEMENT_LOYALTY_PROGRAM_CODE = 'AGREEMENT_LOYALTY_PROGRAM_CODE';
|
||||
public const AGREEMENT_PERSONAL_DATA_CODE = 'AGREEMENT_PERSONAL_DATA_CODE';
|
||||
|
||||
public $MODULE_ID = 'intaro.retailcrm';
|
||||
public $OLD_MODULE_ID = 'intaro.intarocrm';
|
||||
public $MODULE_VERSION;
|
||||
|
@ -234,11 +240,16 @@ class intaro_retailcrm extends CModule
|
|||
include($this->INSTALL_PATH . '/../lib/repository/persontyperepository.php');
|
||||
include($this->INSTALL_PATH . '/../lib/repository/tomodulerepository.php');
|
||||
include($this->INSTALL_PATH . '/../lib/model/bitrix/orm/tomodule.php');
|
||||
|
||||
include($this->INSTALL_PATH . '/../lib/model/bitrix/agreement.php');
|
||||
include($this->INSTALL_PATH . '/../lib/component/configprovider.php');
|
||||
include($this->INSTALL_PATH . '/../lib/component/constants.php');
|
||||
include($this->INSTALL_PATH . '/../lib/repository/agreementrepository.php');
|
||||
|
||||
$this->CopyFiles();
|
||||
$this->addBonusPaySystem();
|
||||
$this->addLPUserFields();
|
||||
$this->addLPEvents();
|
||||
$this->addAgreement();
|
||||
|
||||
if ($step == 11) {
|
||||
$arResult['arSites'] = RCrmActions::SitesList();
|
||||
|
@ -1664,4 +1675,46 @@ class intaro_retailcrm extends CModule
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавление соглашений для формы регистрации
|
||||
*/
|
||||
private function addAgreement(): void
|
||||
{
|
||||
$isAgreementLoyaltyProgram = AgreementRepository::getFirstByWhere(
|
||||
['ID'],
|
||||
[
|
||||
['CODE', '=', self::AGREEMENT_LOYALTY_PROGRAM_CODE]
|
||||
]
|
||||
);
|
||||
|
||||
if (!isset($isAgreementLoyaltyProgram['ID'])) {
|
||||
$agreementLoyaltyProgram = new Agreement();
|
||||
$agreementLoyaltyProgram->setCode(self::AGREEMENT_LOYALTY_PROGRAM_CODE);
|
||||
$agreementLoyaltyProgram->setDateInsert(new \Bitrix\Main\Type\DateTime());
|
||||
$agreementLoyaltyProgram->setActive('Y');
|
||||
$agreementLoyaltyProgram->setName(GetMessage('AGREEMENT_LOYALTY_PROGRAM_TITLE'));
|
||||
$agreementLoyaltyProgram->setType('C');
|
||||
$agreementLoyaltyProgram->setAgreementText(GetMessage('AGREEMENT_LOYALTY_PROGRAM_TEXT'));
|
||||
$agreementLoyaltyProgram->save();
|
||||
}
|
||||
|
||||
$isAgreementPersonalProgram = AgreementRepository::getFirstByWhere(
|
||||
['ID'],
|
||||
[
|
||||
['CODE', '=', self::AGREEMENT_PERSONAL_DATA_CODE]
|
||||
]
|
||||
);
|
||||
|
||||
if (!isset($isAgreementPersonalProgram['ID'])) {
|
||||
$agreementPersonalData = new Agreement();
|
||||
$agreementPersonalData->setCode(self::AGREEMENT_PERSONAL_DATA_CODE);
|
||||
$agreementPersonalData->setDateInsert(new \Bitrix\Main\Type\DateTime());
|
||||
$agreementPersonalData->setActive('Y');
|
||||
$agreementPersonalData->setName(GetMessage('AGREEMENT_PERSONAL_DATA_TITLE'));
|
||||
$agreementPersonalData->setType('C');
|
||||
$agreementPersonalData->setAgreementText(GetMessage('AGREEMENT_PERSONAL_DATA_TEXT'));
|
||||
$agreementPersonalData->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ $MESS ['RETAILCRM_CURL_ERR'] = 'Для работы модуля интегра
|
|||
$MESS ['ERR_ARTICLE_IBLOCK'] = 'Не установлены артикулы';
|
||||
$MESS ['DATE_TIMEZONE_ERR'] = 'Не указана временная зона в настройках php.';
|
||||
$MESS ['SALE_VERSION_ERR'] = 'Версия модуля \'Интернет-магазин\' должна быть выше 16.';
|
||||
$MESS ['AGREEMENT_LOYALTY_PROGRAM_TEXT'] = 'Вставить текст Правил программы лояльности';
|
||||
$MESS ['AGREEMENT_PERSONAL_DATA_TEXT'] = 'Вставить текст соглашения на обработку персональных данных';
|
||||
|
||||
$MESS ['AGREEMENT_LOYALTY_PROGRAM_TITLE'] = 'Условия программы лояльности retailCRM';
|
||||
$MESS ['AGREEMENT_PERSONAL_DATA_TITLE'] = 'Согласие на обработку персональных данных retailCRM';
|
||||
/*
|
||||
$MESS ['ORDER_PROPS'] = 'Настройки соответствия полей заказа retailCRM свойствам заказа 1С-Битрикс';
|
||||
$MESS ['FIO'] = 'Ф.И.О.';
|
||||
|
|
|
@ -110,11 +110,15 @@ $MESS['PHONE_REQUIRED'] = "В настройках главного модуля
|
|||
$MESS ['LOYALTY_PROGRAM_TITLE'] = 'Программа лояльности';
|
||||
$MESS ['LOYALTY_PROGRAM_TOGGLE_MSG'] = 'Активность программы лояльности';
|
||||
$MESS ['LP_CUSTOM_TEMP_CREATE_MSG'] = 'Создать шаблон intaro.retailCRM для компонента оформления заказа sale.order.ajax c функциями Программы лояльности. <br> <b>Внимение:</b> если шаблон уже существует, то он будет перезаписан';
|
||||
$MESS ['LP_DEF_TEMP_CREATE_MSG'] = 'Заменить шаблон .default компонента sale.order.ajax шаблоном с функциями Программы лояльности. <br> Если в папке .local уже есть шаблон .default для sale.order.ajax, то он будет скопирован в папку .default_backup';
|
||||
$MESS ['LP_CUSTOM_REG_TEMP_CREATE_MSG'] = 'Создать шаблон intaro.retailCRM для компонента регистрации main.register c функциями Программы лояльности. <br> <b>Внимение:</b> если шаблон уже существует, то он будет перезаписан';
|
||||
$MESS ['LP_DEF_TEMP_CREATE_MSG'] = 'Заменить шаблон .default компонента sale.order.ajax шаблоном с функциями Программы лояльности. <br> Если в папке шаблонов компонента уже будет .default, то он будет скопирован в папку .default_backup';
|
||||
$MESS ['LP_CREATE_TEMPLATE'] = 'Создать шаблон';
|
||||
$MESS ['LP_REPLACE_TEMPLATE'] = 'Заменить шаблон';
|
||||
$MESS ['LP_SALE_ORDER_AJAX_HEAD'] = ' Управление компонентом Оформление заказа (sale.order.ajax)';
|
||||
$MESS ['LP_TEMP_CHOICE_MSG'] = 'Выберите, в каких шаблонах сайта будет доступен шаблон компонента Оформление заказа с функциями Программы лояльности:';
|
||||
$MESS ['LP_TEMP_CHOICE_MSG'] = 'Выберите, в каких шаблонах сайта будет доступен шаблон компонента с функциями Программы лояльности:';
|
||||
$MESS ['CREATING_AN_ADDITIONAL_TEMPLATE'] = 'Создание дополнительного шаблона';
|
||||
$MESS ['REPLACING_THE_STANDARD_TEMPLATE'] = 'Замена стандартного шаблона .default';
|
||||
|
||||
$MESS ['LP_MAIN_REGISTER_HEAD'] = 'Управление компонентом регистрации (main.register)';
|
||||
$MESS ['LP_DEF_TEMP_REG_CREATE_MSG'] = 'Заменить шаблон .default компонента main.register шаблоном с функциями Программы лояльности. <br> Если в папке шаблонов компонента уже будет .default, то он будет скопирован в папку .default_backup';
|
||||
|
||||
|
|
|
@ -615,6 +615,42 @@ class ConfigProvider
|
|||
static::setOption(Constants::LOYALTY_PROGRAM_TOGGLE, $loyaltyProgramStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getAgreementLoyaltyProgram(): ?string
|
||||
{
|
||||
return static::getOption(Constants::AGREEMENT_LOYALTY_PROGRAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getAgreementPersonalData(): ?string
|
||||
{
|
||||
return static::getOption(Constants::AGREEMENT_PERSONAL_DATA);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $agreementLoyaltyProgramId
|
||||
* @return void
|
||||
* @throws \Bitrix\Main\ArgumentOutOfRangeException
|
||||
*/
|
||||
public static function setAgreementLoyaltyProgram($agreementLoyaltyProgramId): void
|
||||
{
|
||||
static::setOption(Constants::AGREEMENT_LOYALTY_PROGRAM, $agreementLoyaltyProgramId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $agreementPersonalData
|
||||
* @return void
|
||||
* @throws \Bitrix\Main\ArgumentOutOfRangeException
|
||||
*/
|
||||
public static function setAgreementPersonalData($agreementPersonalData): void
|
||||
{
|
||||
static::setOption(Constants::AGREEMENT_PERSONAL_DATA, $agreementPersonalData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps Bitrix \COption::GetOptionString(...)
|
||||
*
|
||||
|
@ -689,4 +725,4 @@ class ConfigProvider
|
|||
{
|
||||
return empty($value) && $value !== 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,5 +71,7 @@ class Constants
|
|||
public const CORPORATE_CONTRAGENT_TYPE = 'legal-entity';
|
||||
public const LOYALTY_PROGRAM_TOGGLE = 'loyalty_program_toggle';
|
||||
public const CLIENT_ID = 'client_id';
|
||||
public const AGREEMENT_LOYALTY_PROGRAM = 'agreement_loyalty_program';
|
||||
public const AGREEMENT_PERSONAL_DATA = 'agreement_personal_data';
|
||||
public const BONUS_PAYMENT_CODE = 'INTARO_BONUS';
|
||||
}
|
||||
|
|
|
@ -41,10 +41,11 @@ class AdminPanel extends Controller
|
|||
|
||||
/**
|
||||
* @param array $templates
|
||||
* @param string $donor
|
||||
* @param string $replaceDefaultTemplate
|
||||
* @return array
|
||||
*/
|
||||
public function createSaleTemplateAction(array $templates, $replaceDefaultTemplate = 'N'): array
|
||||
public function createTemplateAction(array $templates, string $donor ,$replaceDefaultTemplate = 'N'): array
|
||||
{
|
||||
$templateName = $replaceDefaultTemplate === 'Y' ? '.default' : Constants::MODULE_ID;
|
||||
|
||||
|
@ -52,18 +53,22 @@ class AdminPanel extends Controller
|
|||
$pathFrom = $_SERVER['DOCUMENT_ROOT']
|
||||
. '/bitrix/modules/'
|
||||
. Constants::MODULE_ID
|
||||
. '/install/export/local/components/intaro/sale.order.ajax/templates/.default';
|
||||
. '/install/export/local/components/intaro/' . $donor . '/templates/.default';
|
||||
$pathTo = $_SERVER['DOCUMENT_ROOT']
|
||||
. $template['location']
|
||||
. $template['name']
|
||||
. '/components/bitrix/sale.order.ajax/'
|
||||
. '/components/bitrix/'
|
||||
. $donor
|
||||
. '/'
|
||||
. $templateName;
|
||||
|
||||
if ($replaceDefaultTemplate === 'Y' && file_exists($pathTo)) {
|
||||
$backPath = $_SERVER['DOCUMENT_ROOT']
|
||||
. $template['location']
|
||||
. $template['name']
|
||||
. '/components/bitrix/sale.order.ajax/'
|
||||
. '/components/bitrix/'
|
||||
. $donor
|
||||
. '/'
|
||||
. $templateName.'_backup';
|
||||
|
||||
CopyDirFiles(
|
||||
|
|
60
intaro.retailcrm/lib/model/bitrix/agreement.php
Normal file
60
intaro.retailcrm/lib/model/bitrix/agreement.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Bitrix
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Model\Bitrix;
|
||||
|
||||
use Bitrix\Main\ORM\Objectify\EntityObject;
|
||||
use Bitrix\Main\Type\DateTime;
|
||||
use Bitrix\Main\UserConsent\Internals\AgreementTable;
|
||||
use Bitrix\Sale\FuserTable;
|
||||
use Bitrix\Sale\Internals\OrderPropsTable;
|
||||
use Intaro\RetailCrm\Model\Bitrix\ORM\ToModuleTable;
|
||||
|
||||
/**
|
||||
* Class Agreement
|
||||
*
|
||||
* @package Intaro\RetailCrm\Model\Bitrix
|
||||
*
|
||||
* @method int getId()
|
||||
* @method void setId(int $id)
|
||||
* @method string getCode()
|
||||
* @method void setCode(string $code)
|
||||
* @method DateTime getDateInsert()
|
||||
* @method void setDateInsert(DateTime $dateInsert)
|
||||
* @method bool getActive()
|
||||
* @method void setActive(bool $active)
|
||||
* @method string getName()
|
||||
* @method void setName(string $name)
|
||||
* @method string getType()
|
||||
* @method void setType(string $type)
|
||||
* @method string getLanguageId()
|
||||
* @method void setLanguageId(string $languageId)
|
||||
* @method string getDataProvider()
|
||||
* @method void setDataProvider(string $dataProvider)
|
||||
* @method string getAgreementText()
|
||||
* @method void setAgreementText(string $agreementText)
|
||||
* @method string getLabelText()
|
||||
* @method void setLabelText(string $labelText)
|
||||
* @method string getSecurityCode()
|
||||
* @method void setSecurityCode(string $securityCode)
|
||||
*/
|
||||
class Agreement extends AbstractModelProxy
|
||||
{
|
||||
/**
|
||||
* @return \Bitrix\Main\ORM\Objectify\EntityObject|null
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
protected static function newObject(): ?EntityObject
|
||||
{
|
||||
return AgreementTable::createObject();
|
||||
}
|
||||
}
|
67
intaro.retailcrm/lib/repository/agreementrepository.php
Normal file
67
intaro.retailcrm/lib/repository/agreementrepository.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Repository
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Repository;
|
||||
|
||||
use Bitrix\Main\UserConsent\Internals\AgreementTable;
|
||||
use Bitrix\Sale\OrderUserProperties;
|
||||
use Intaro\RetailCrm\Component\Json\Deserializer;
|
||||
use Intaro\RetailCrm\Component\Json\Serializer;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Agreement;
|
||||
use Intaro\RetailCrm\Model\Bitrix\BuyerProfile;
|
||||
use Intaro\RetailCrm\Model\Bitrix\ORM\ToModuleTable;
|
||||
use Intaro\RetailCrm\Model\Bitrix\ToModule;
|
||||
|
||||
/**
|
||||
* Class AgreementRepository
|
||||
*
|
||||
* @package Intaro\RetailCrm\Repository
|
||||
*/
|
||||
class AgreementRepository extends AbstractRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns array with buyer profile if one was found. Returns empty array otherwise.
|
||||
*
|
||||
* @param array $select
|
||||
* @param array $where
|
||||
* @return \Intaro\RetailCrm\Model\Bitrix\Agreement|null|boolean
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
public static function getFirstByWhere(array $select, array $where)
|
||||
{
|
||||
return AgreementTable::query()
|
||||
->setSelect($select)
|
||||
->where($where)
|
||||
->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $buyerProfileData
|
||||
*
|
||||
* @return \Intaro\RetailCrm\Model\Bitrix\Agreement
|
||||
*/
|
||||
private static function deserialize(array $buyerProfileData): Agreement
|
||||
{
|
||||
return Deserializer::deserializeArray($buyerProfileData, Agreement::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $result
|
||||
* @return string
|
||||
*/
|
||||
private static function serialize($result)
|
||||
{
|
||||
return Serializer::serialize($result, Agreement::class);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ use Bitrix\Main\Application;
|
|||
use Bitrix\Sale\Delivery\Services\Manager;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
use Intaro\RetailCrm\Repository\AgreementRepository;
|
||||
use Intaro\RetailCrm\Repository\TemplateRepository;
|
||||
use RetailCrm\Exception\CurlException;
|
||||
|
||||
|
@ -769,9 +770,8 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
CJSCore::Init(array("jquery"));
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
function createSaleTemplates() {
|
||||
BX.ajax.runAction('intaro:retailcrm.api.adminpanel.createSaleTemplate',
|
||||
function createTemplates(donor) {
|
||||
BX.ajax.runAction('intaro:retailcrm.api.adminpanel.createTemplate',
|
||||
{
|
||||
data: {
|
||||
sessid: BX.bitrix_sessid(),
|
||||
|
@ -780,17 +780,28 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
'location': '/local/templates/',
|
||||
'name': '.default'
|
||||
}
|
||||
]
|
||||
],
|
||||
donor: donor
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function replaceDefaultSaleTemplates() {
|
||||
function replaceDefaultTemplates(donor) {
|
||||
let templates = [];
|
||||
let i = 0;
|
||||
|
||||
$('#lp-templates input:checkbox:checked').each(
|
||||
|
||||
let node;
|
||||
|
||||
if (donor === 'sale.order.ajax') {
|
||||
node = $('#lp-sale-templates input:checkbox:checked');
|
||||
}
|
||||
|
||||
if (donor === 'main.register') {
|
||||
node = $('#lp-reg-templates input:checkbox:checked');
|
||||
}
|
||||
|
||||
node.each(
|
||||
function(index, checkbox){
|
||||
templates[i] = {
|
||||
'name': $(checkbox).val(),
|
||||
|
@ -800,12 +811,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
}
|
||||
);
|
||||
|
||||
BX.ajax.runAction('intaro:retailcrm.api.adminpanel.createSaleTemplate',
|
||||
BX.ajax.runAction('intaro:retailcrm.api.adminpanel.createTemplate',
|
||||
{
|
||||
data: {
|
||||
sessid: BX.bitrix_sessid(),
|
||||
templates: templates,
|
||||
defreplace: 'Y'
|
||||
sessid: BX.bitrix_sessid(),
|
||||
templates: templates,
|
||||
donor: donor,
|
||||
replaceDefaultTemplate: 'Y'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -1363,7 +1375,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
</div>
|
||||
<?php echo GetMessage('LP_CUSTOM_TEMP_CREATE_MSG'); ?>
|
||||
<div style="text-align: center;">
|
||||
<input type="button" onclick="createSaleTemplates()" class="adm-btn-save" value="<?php echo GetMessage('LP_CREATE_TEMPLATE'); ?>"/>
|
||||
<input type="button" onclick="createTemplates('sale.order.ajax')" class="adm-btn-save" value="<?php echo GetMessage('LP_CREATE_TEMPLATE'); ?>"/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -1381,10 +1393,10 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
</tr>
|
||||
<tr>
|
||||
<td width="50%" align="center">
|
||||
<input type="button" onclick="replaceDefaultSaleTemplates()" class="adm-btn-save" value="<?php echo GetMessage('LP_REPLACE_TEMPLATE'); ?>" />
|
||||
<input type="button" onclick="replaceDefaultTemplates('sale.order.ajax')" class="adm-btn-save" value="<?php echo GetMessage('LP_REPLACE_TEMPLATE'); ?>" />
|
||||
</td>
|
||||
<td width="50%" >
|
||||
<div id="lp-templates">
|
||||
<div id="lp-sale-templates">
|
||||
<?php
|
||||
$templates = TemplateRepository::getAllIds();
|
||||
foreach ($templates as $template) {
|
||||
|
@ -1396,6 +1408,80 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
|
||||
</tr>
|
||||
</table>
|
||||
<table width="100%">
|
||||
<tr class="heading">
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<?php echo GetMessage('LP_MAIN_REGISTER_HEAD'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div style="text-align: center;">
|
||||
<h4>
|
||||
<?=GetMessage('CREATING_AN_ADDITIONAL_TEMPLATE')?>
|
||||
</h4>
|
||||
</div>
|
||||
<?php echo GetMessage('LP_CUSTOM_REG_TEMP_CREATE_MSG'); ?>
|
||||
<div style="text-align: center;">
|
||||
<input type="button" onclick="createTemplates('main.register')" class="adm-btn-save" value="<?php echo GetMessage('LP_CREATE_TEMPLATE'); ?>"/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div style="text-align: center;">
|
||||
<h4>
|
||||
<?= GetMessage('REPLACING_THE_STANDARD_TEMPLATE') ?>
|
||||
</h4>
|
||||
</div>
|
||||
<?php echo GetMessage('LP_DEF_TEMP_REG_CREATE_MSG'); ?>
|
||||
<hr>
|
||||
<?php echo GetMessage('LP_TEMP_CHOICE_MSG'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50%" align="center">
|
||||
<input type="button" onclick="replaceDefaultTemplates('main.register')" class="adm-btn-save" value="<?php echo GetMessage('LP_REPLACE_TEMPLATE'); ?>" />
|
||||
</td>
|
||||
<td width="50%" >
|
||||
<div id="lp-reg-templates">
|
||||
<?php
|
||||
$templates = TemplateRepository::getAllIds();
|
||||
foreach ($templates as $template) {
|
||||
?>
|
||||
<p><input type="checkbox" name="<?= $template['name']?>" value="<?= $template['name']?>" templateFolder="<?= $template['folder']?>"> <?= $template['name']?> (<?= $template['folder']?>)</p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="text-align: center;" colspan="2">
|
||||
|
||||
<?php
|
||||
$isAgreementPersonalProgram = AgreementRepository::getFirstByWhere(
|
||||
['ID'],
|
||||
[
|
||||
['CODE', '=', 'AGREEMENT_PERSONAL_DATA_CODE']
|
||||
]
|
||||
);
|
||||
$isAgreementLoyaltyProgram = AgreementRepository::getFirstByWhere(
|
||||
['ID'],
|
||||
[
|
||||
['CODE', '=', 'AGREEMENT_LOYALTY_PROGRAM_CODE']
|
||||
]
|
||||
);
|
||||
?>
|
||||
<h4>Редактирование соглашений</h4>
|
||||
<?php if (isset($isAgreementLoyaltyProgram['ID']) && isset($isAgreementLoyaltyProgram['ID'])) { ?>
|
||||
<a href="<?= SITE_SERVER_NAME . '/bitrix/admin/agreement_edit.php?ID=' . $isAgreementLoyaltyProgram['ID']?>">Редактирование "Соглашения на обработку персональных данных"</a>
|
||||
<br>
|
||||
<a href="<?= SITE_SERVER_NAME . '/bitrix/admin/agreement_edit.php?ID=' . $isAgreementLoyaltyProgram['ID']?>">Ссылка на Согласие с условиями программы лояльности</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Reference in a new issue