ref #92774
Получение необходимых полей из Bitrix Получение необходимых полей из CRM Добавление новой настройки
This commit is contained in:
parent
e918317f6a
commit
999c2c5517
5 changed files with 191 additions and 3 deletions
|
@ -10,6 +10,8 @@ use Intaro\RetailCrm\Service\Utils;
|
|||
use RetailCrm\Exception\CurlException;
|
||||
use RetailCrm\Exception\InvalidJsonException;
|
||||
use Intaro\RetailCrm\Service\ManagerService;
|
||||
use Bitrix\Main\UserFieldTable;
|
||||
use Bitrix\Main\UserFieldLangTable;
|
||||
use Bitrix\Sale\Internals\SiteCurrencyTable;
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
@ -438,6 +440,47 @@ class RCrmActions
|
|||
return $result;
|
||||
}
|
||||
|
||||
public static function customOrderPropList()
|
||||
{
|
||||
$propsList = OrderPropsTable::getList([
|
||||
'select' => ['ID', 'CODE', 'NAME', 'PERSON_TYPE_ID'],
|
||||
'filter' => [
|
||||
['!=CODE' => "LP_BONUS_INFO"],
|
||||
['!=CODE' => "LP_DISCOUNT_INFO"],
|
||||
['>ID' => 19]
|
||||
]
|
||||
]);
|
||||
|
||||
return $propsList->fetchAll();
|
||||
}
|
||||
|
||||
public static function customUserFieldList()
|
||||
{
|
||||
$userFields = UserFieldTable::getList([
|
||||
'select' => ['ID', 'FIELD_NAME'],
|
||||
'filter' => [
|
||||
['ENTITY_ID' => 'USER'],
|
||||
['?FIELD_NAME' => '~%INTARO%'],
|
||||
['!=FIELD_NAME' => 'UF_SUBSCRIBE_USER_EMAIL']
|
||||
]
|
||||
])->fetchAll();
|
||||
|
||||
|
||||
foreach ($userFields as $key => $userField) {
|
||||
$label = UserFieldLangTable::getList([
|
||||
'select' => ['EDIT_FORM_LABEL'],
|
||||
'filter' => [
|
||||
["USER_FIELD_ID" => $userField['ID']],
|
||||
['LANGUAGE_ID' => LANGUAGE_ID]
|
||||
]
|
||||
])->fetch();
|
||||
|
||||
$userFields[$key]['FIELD_LABEL'] = $label['EDIT_FORM_LABEL'];
|
||||
}
|
||||
|
||||
return $userFields;
|
||||
}
|
||||
|
||||
public static function sendConfiguration($api, $active = true)
|
||||
{
|
||||
$scheme = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
|
||||
|
|
|
@ -176,3 +176,12 @@ $MESS ['WRONG_CREDENTIALS'] = 'Введите адрес и ключ автор
|
|||
$MESS ['Wrong "apiKey" value.'] = 'Недействительный ключ авторизации';
|
||||
|
||||
$MESS ['ORDER_TRACK_NUMBER'] = 'Получать трек-номер';
|
||||
|
||||
$MESS ['CUSTOM_FIELDS_TITLE'] = 'Пользовательские поля';
|
||||
$MESS ['CUSTOM_FIELDS_CAPTION'] = 'Сопоставление пользовательских полей';
|
||||
$MESS ['CUSTOM_FIELDS_TOGGLE_MSG'] = 'Активность обмена пользовательскими полями';
|
||||
$MESS ['CUSTOM_FIELDS_ORDER_BITRIX'] = 'Свойства заказа';
|
||||
$MESS ['CUSTOM_FIELDS_ORDER_CRM'] = 'Пользовательские поля заказа в црм';
|
||||
$MESS ['CUSTOM_FIELDS_USER_BITRIX'] = 'Поля пользователя';
|
||||
$MESS ['CUSTOM_FIELDS_USER_CRM'] = 'Пользовательские поля клиента в црм';
|
||||
|
||||
|
|
|
@ -1169,4 +1169,22 @@ class ConfigProvider
|
|||
{
|
||||
static::setOption(Constants::RECEIVE_TRACK_NUMBER_DELIVERY, $trackNumberStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getCustomFieldsStatus()
|
||||
{
|
||||
return static::getOption(Constants::CUSTOM_FIELDS_TOGGLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool|string|null $customFieldsStatus
|
||||
* @return void
|
||||
* @throws \Bitrix\Main\ArgumentOutOfRangeException
|
||||
*/
|
||||
public static function setCustomFieldsStatus($customFieldsStatus)
|
||||
{
|
||||
static::setOption(Constants::CUSTOM_FIELDS_TOGGLE, $customFieldsStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,4 +105,5 @@ class Constants
|
|||
public const SITES_AVAILABLE = 'sites_available';
|
||||
|
||||
public const RECEIVE_TRACK_NUMBER_DELIVERY = 'receive_track_number_delivery';
|
||||
public const CUSTOM_FIELDS_TOGGLE = 'custom_fields_toggle';
|
||||
}
|
||||
|
|
|
@ -120,6 +120,8 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/intaro.retailcrm/cl
|
|||
|
||||
$arResult['arSites'] = RCrmActions::getSitesList();
|
||||
$arResult['arCurrencySites'] = RCrmActions::getCurrencySites();
|
||||
$arResult['bitrixOrdersCustomProp'] = RCrmActions::customOrderPropList();
|
||||
$arResult['bitrixCustomUserFields'] = RCrmActions::customUserFieldList();
|
||||
//ajax update deliveryServices
|
||||
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') && isset($_POST['ajax']) && ($_POST['ajax'] === 1)) {
|
||||
$api_host = COption::GetOptionString($mid, $CRM_API_HOST_OPTION, 0);
|
||||
|
@ -961,6 +963,8 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
$arResult['sitesList'] = $APPLICATION->ConvertCharsetArray($api->sitesList()->sites, 'utf-8', SITE_CHARSET);
|
||||
$arResult['inventoriesList'] = $APPLICATION->ConvertCharsetArray($api->storesList()->stores, 'utf-8', SITE_CHARSET);
|
||||
$arResult['priceTypeList'] = $APPLICATION->ConvertCharsetArray($api->pricesTypes()->priceTypes, 'utf-8', SITE_CHARSET);
|
||||
$arResult['crmCustomOrderFields'] = $api->customFieldsList(['entity' => 'order']);
|
||||
$arResult['crmCustomUserFields'] = $api->customFieldsList(['entity' => 'customer']);
|
||||
} catch (\RetailCrm\Exception\CurlException $e) {
|
||||
RCrmActions::eventLog(
|
||||
'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::*List::CurlException',
|
||||
|
@ -1166,13 +1170,19 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
"TITLE" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_CAPTION'),
|
||||
],
|
||||
[
|
||||
"DIV" => "edit5",
|
||||
"DIV" => "edit5",
|
||||
"TAB" => GetMessage('CUSTOM_FIELDS_TITLE'),
|
||||
"ICON" => '',
|
||||
"TITLE" => GetMessage('CUSTOM_FIELDS_CAPTION'),
|
||||
],
|
||||
[
|
||||
"DIV" => "edit6",
|
||||
"TAB" => GetMessage('UPLOAD_ORDERS_OPTIONS'),
|
||||
"ICON" => '',
|
||||
"TITLE" => GetMessage('ORDER_UPLOAD'),
|
||||
],
|
||||
[
|
||||
"DIV" => "edit6",
|
||||
"DIV" => "edit7",
|
||||
"TAB" => GetMessage('OTHER_OPTIONS'),
|
||||
"ICON" => '',
|
||||
"TITLE" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_CAPTION'),
|
||||
|
@ -1323,6 +1333,10 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
$('#loyalty_main_settings').toggle(500);
|
||||
}
|
||||
|
||||
function switchCustomFieldsStatus() {
|
||||
$('#custom_fields_settings').toggle(500);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('input.addr').change(function() {
|
||||
splitName = $(this).attr('name').split('-');
|
||||
|
@ -1877,7 +1891,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php $tabControl->BeginNextTab(); ?>
|
||||
<?php
|
||||
//loyalty program options
|
||||
|
@ -2072,6 +2085,110 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<?php $tabControl->BeginNextTab(); ?>
|
||||
<?php
|
||||
$customFieldsToggle = ConfigProvider::getCustomFieldsStatus();
|
||||
?>
|
||||
<tr class="heading">
|
||||
<p>При работе с данной настройкой, убедитесь, что у вас не используются кастомизированные файлы по работе с заказами и пользователями.</p>
|
||||
<p>Если же они имеются, убедитеть, что функционал по работе с пользовательскими полями встроен в модуль</p>
|
||||
<td colspan="2" class="option-other-heading">
|
||||
<b>
|
||||
<label>
|
||||
<input class="addr" type="checkbox" id="custom_fields_toggle" name="custom_fields_toggle" onclick="switchCustomFieldsStatus();" <?php if ($customFieldsToggle === 'Y') {
|
||||
echo "checked";
|
||||
} ?>>
|
||||
<?php echo GetMessage('CUSTOM_FIELDS_TOGGLE_MSG'); ?>
|
||||
</label>
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div id="custom_fields_settings" <?php if ($customFieldsToggle !== 'Y') {
|
||||
echo "hidden";
|
||||
} ?>>
|
||||
<br>
|
||||
<table width="100%" class="adm-list-table">
|
||||
<thead>
|
||||
<tr class="adm-list-table-header">
|
||||
<td class="adm-list-table-cell" colspan="2">
|
||||
<div class="adm-list-table-cell-inner">
|
||||
<?=GetMessage('CUSTOM_FIELDS_ORDER_BITRIX')?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="adm-list-table-cell" colspan="2">
|
||||
<div class="adm-list-table-cell-inner">
|
||||
<?=GetMessage('CUSTOM_FIELDS_ORDER_CRM');?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="adm-list-table-cell" colspan="1"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="adm-list-table-row">
|
||||
<td class="adm-list-table-cell" colspan="2">
|
||||
<select style="width: 200px;" class="property-export">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="adm-list-table-cell" colspan="2">
|
||||
<select style="width: 200px;" class="property-export">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="adm-list-table-cell" colspan="1"><a>Удалить</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<button class="adm-btn-save">Добавить поле</button>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<table width="100%" class="adm-list-table">
|
||||
<thead>
|
||||
<tr class="adm-list-table-header">
|
||||
<td class="adm-list-table-cell" colspan="2">
|
||||
<div class="adm-list-table-cell-inner">
|
||||
<?=GetMessage('CUSTOM_FIELDS_USER_BITRIX')?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="adm-list-table-cell" colspan="2">
|
||||
<div class="adm-list-table-cell-inner">
|
||||
<?=GetMessage('CUSTOM_FIELDS_USER_CRM');?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="adm-list-table-cell" colspan="1"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="adm-list-table-row">
|
||||
<td class="adm-list-table-cell" colspan="2">
|
||||
<select style="width: 200px;" class="property-export">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="adm-list-table-cell" colspan="2">
|
||||
<select style="width: 200px;" class="property-export">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="adm-list-table-cell" colspan="1"><a>Удалить</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<button class="adm-btn-save">Добавить поле</button>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php // Manual orders upload. ?>
|
||||
<?php $tabControl->BeginNextTab(); ?>
|
||||
<style type="text/css">
|
||||
|
|
Loading…
Add table
Reference in a new issue