1
0
Fork 0
mirror of synced 2025-04-11 05:00:55 +00:00
Добавление хранимых опций.
Обработка получаемой информации о кастомных полях
Работа с вёрсткой
This commit is contained in:
Ivan Chaplygin 2023-12-01 18:22:20 +03:00
parent 999c2c5517
commit f9b919ac57
5 changed files with 153 additions and 12 deletions

View file

@ -451,7 +451,15 @@ class RCrmActions
]
]);
return $propsList->fetchAll();
$propsList->fetchAll();
$resultList = [];
foreach ($propsList as $prop) {
$key = $prop['ID'] . '#' . $prop['CODE'];
$resultList[$key] = $prop['NAME'] . ' (' . $prop['PERSON_TYPE_ID'] . ')';
}
return $resultList;
}
public static function customUserFieldList()
@ -466,7 +474,9 @@ class RCrmActions
])->fetchAll();
foreach ($userFields as $key => $userField) {
$resultList = [];
foreach ($userFields as $userField) {
$label = UserFieldLangTable::getList([
'select' => ['EDIT_FORM_LABEL'],
'filter' => [
@ -475,10 +485,11 @@ class RCrmActions
]
])->fetch();
$userFields[$key]['FIELD_LABEL'] = $label['EDIT_FORM_LABEL'];
$key = $userField['ID'] . '#' . $userField['FIELD_NAME'];
$resultList[$key] = $label['EDIT_FORM_LABEL'];
}
return $userFields;
return $resultList;
}
public static function sendConfiguration($api, $active = true)

View file

@ -184,4 +184,7 @@ $MESS ['CUSTOM_FIELDS_ORDER_BITRIX'] = 'Свойства заказа';
$MESS ['CUSTOM_FIELDS_ORDER_CRM'] = 'Пользовательские поля заказа в црм';
$MESS ['CUSTOM_FIELDS_USER_BITRIX'] = 'Поля пользователя';
$MESS ['CUSTOM_FIELDS_USER_CRM'] = 'Пользовательские поля клиента в црм';
$MESS ['SELECT_FIELD_NAME'] = 'Поле';

View file

@ -117,6 +117,12 @@ class ConfigProvider
/** @var bool|null|string $loyaltyProgramStatus */
protected static $loyaltyProgramStatus;
/** @var array $mathedCustomProps */
protected static $mathedCustomProps;
/** @var array $mathedCustomFields */
protected static $mathedCustomFields;
/**
* @return bool|string|null
*/
@ -1187,4 +1193,51 @@ class ConfigProvider
{
static::setOption(Constants::CUSTOM_FIELDS_TOGGLE, $customFieldsStatus);
}
/**
* @return array
*/
public static function getMatchedOrderProps()
{
if (self::isEmptyNotZero(static::$mathedCustomProps)) {
static::$mathedCustomProps = static::getUnserializedOption(Constants::MATCHED_CUSTOM_PROPS);
}
return static::$mathedCustomProps;
}
/**
* @param array|null $customPropsList
*
* @return void
* @throws \Bitrix\Main\ArgumentOutOfRangeException
*/
public static function setMatchedOrderProps(?array $customPropsList)
{
static::setOption(Constants::MATCHED_CUSTOM_PROPS, serialize($customPropsList));
'selected';
}
/**
* @return array
*/
public static function getMatchedUserFields()
{
if (self::isEmptyNotZero(static::$mathedCustomFields)) {
static::$mathedCustomFields = static::getUnserializedOption(Constants::MATCHED_CUSTOM_USER_FIELDS);
}
return static::$mathedCustomFields;
}
/**
* @param array|null $customUserFields
*
* @return void
* @throws \Bitrix\Main\ArgumentOutOfRangeException
*/
public static function setMatchedUserFields(?array $customUserFields)
{
static::setOption(Constants::MATCHED_CUSTOM_USER_FIELDS, serialize($customUserFields));
}
}

View file

@ -106,4 +106,6 @@ class Constants
public const RECEIVE_TRACK_NUMBER_DELIVERY = 'receive_track_number_delivery';
public const CUSTOM_FIELDS_TOGGLE = 'custom_fields_toggle';
public const MATCHED_CUSTOM_PROPS = 'matched_order_props';
public const MATCHED_CUSTOM_USER_FIELDS = 'matched_custom_field';
}

View file

@ -120,8 +120,7 @@ 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);
@ -963,8 +962,13 @@ 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']);
$arResult['crmCustomOrderFields'] = $APPLICATION->ConvertCharsetArray(
$api->customFieldsList(['entity' => 'order'], 250)->customFields, 'utf-8', SITE_CHARSET
);
$arResult['crmCustomUserFields'] = $APPLICATION->ConvertCharsetArray(
$api->customFieldsList(['entity' => 'customer'], 250)->customFields, 'utf-8', SITE_CHARSET
);
var_dump($arResult['crmCustomOrderFields'], $arResult['crmCustomUserFields']);
} catch (\RetailCrm\Exception\CurlException $e) {
RCrmActions::eventLog(
'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::*List::CurlException',
@ -980,6 +984,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
echo CAdminMessage::ShowMessage(GetMessage('ERR_JSON'));
}
$arResult['bitrixOrdersCustomProp'] = RCrmActions::customOrderPropList();
$arResult['bitrixCustomUserFields'] = RCrmActions::customUserFieldList();
$arResult['matchedOrderProps'] = ConfigProvider::getMatchedOrderProps();
$arResult['matchedUserFields'] = ConfigProvider::getMatchedUserFields();
$arResult['paymentTypesList'] = RetailCrmService::getAvailableTypes(
$availableSites,
$api->paymentTypesList()->paymentTypes
@ -2126,15 +2135,78 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
</tr>
</thead>
<tbody>
<?php
$matchedNum = 1;
foreach ($arResult['matchedOrderProps'] as $bitrixProp => $crmField) {?>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell" colspan="2">
<select
style="width: 200px;" class="typeselect"
id="matchedOrderProps_<?php $matchedNum ?>"
name="matchedOrderFields"
>
<option value=""></option>
<?php foreach ($arResult['bitrixOrdersCustomProp'] as $code => $prop) {?>
<option
value="<?php $bitrixProp ?>"
<?php if ($bitrixProp === $code) echo 'selected'; ?>
>
<?php $prop ?>
</option>
<?php } ?>
</select>
</td>
<!--Доработать-->
<td class="adm-list-table-cell" colspan="2">
<select
style="width: 200px;" class="typeselect"
id="matchedOrderProps_<?php $matchedNum ?>"
name="matchedOrderFields"
>
<option value=""></option>
<?php if (isset($arResult['bitrixOrdersCustomProp'][$bitrixProp])) {?>
<option value="<?php $bitrixProp?>">
<?php $arResult['bitrixOrdersCustomProp'][$bitrixProp]?>
</option>
<?php }?>
</select>
</td>
<td class="adm-list-table-cell" colspan="1"><a>Удалить</a></td>
</tr>
<?php $matchedNum++; }?>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell" colspan="2">
<select style="width: 200px;" class="property-export">
<select
style="width: 200px;" class="typeselect"
name=""
>
<option value=""></option>
<optgroup label="<?=GetMessage('SELECT_FIELD_NAME')?>">
<?php
foreach ($arResult['bitrixOrdersCustomProp'] as $prop) { ?>
<option value="<?=$prop['ID'] . '#' . $prop['CODE']?>">
<?= $prop['NAME'] . ' (' . $prop['PERSON_TYPE_ID'] . ')'?>
</option>
<?php
}
?>
</optgroup>
</select>
</td>
<td class="adm-list-table-cell" colspan="2">
<select style="width: 200px;" class="property-export">
<select style="width: 200px;" class="typeselect">
<option value=""></option>
<optgroup label="<?=GetMessage('SELECT_FIELD_NAME')?>">
<?php
foreach ($arResult['crmCustomOrderFields'] as $prop) { ?>
<option value="<?=$prop['code']?>">
<?= $prop['name']?>
</option>
<?php
}
?>
</optgroup>
</select>
</td>
<td class="adm-list-table-cell" colspan="1"><a>Удалить</a></td>
@ -2166,12 +2238,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
<tbody>
<tr class="adm-list-table-row">
<td class="adm-list-table-cell" colspan="2">
<select style="width: 200px;" class="property-export">
<select style="width: 200px;" class="typeselect">
<option value=""></option>
</select>
</td>
<td class="adm-list-table-cell" colspan="2">
<select style="width: 200px;" class="property-export">
<select style="width: 200px;" class="typeselect">
<option value=""></option>
</select>
</td>