ref #92774
Передача кастомных полей в црм Изменение формата кода пользовательских полей пользователя
This commit is contained in:
parent
d4030d08ac
commit
58500a722b
4 changed files with 22 additions and 5 deletions
|
@ -485,8 +485,7 @@ class RCrmActions
|
|||
]
|
||||
])->fetch();
|
||||
|
||||
$key = $userField['ID'] . '#' . $userField['FIELD_NAME'];
|
||||
$resultList[$key] = $label['EDIT_FORM_LABEL'];
|
||||
$resultList[$userField['FIELD_NAME']] = $label['EDIT_FORM_LABEL'];
|
||||
}
|
||||
|
||||
return $resultList;
|
||||
|
|
|
@ -175,6 +175,7 @@ class RetailCrmEvent
|
|||
'optionsContragentType' => $optionsContragentType,
|
||||
'optionsSitesList' => $optionsSitesList,
|
||||
'optionsCustomFields' => $optionsCustomFields,
|
||||
'customOrderProps' => RetailcrmConfigProvider::getMatchedOrderProps(),
|
||||
]);
|
||||
|
||||
//many sites?
|
||||
|
|
|
@ -131,10 +131,10 @@ class RetailCrmOrder
|
|||
&& $search = array_search($prop['CODE'], $arParams['optionsLegalDetails'][$arOrder['PERSON_TYPE_ID']])
|
||||
) {
|
||||
$order['contragent'][$search] = $prop['VALUE'][0];//legal order data
|
||||
} elseif (!empty($arParams['optionsCustomFields'])
|
||||
&& $search = array_search($prop['CODE'], $arParams['optionsCustomFields'][$arOrder['PERSON_TYPE_ID']])
|
||||
} elseif (!empty($arParams['customOrderProps'])
|
||||
&& isset($arParams['customOrderProps'][$prop['ID'] . '#' . $prop['CODE']])
|
||||
) {
|
||||
$order['customFields'][$search] = $prop['VALUE'][0];//custom properties
|
||||
$order['customFields'][$arParams['customOrderProps'][$prop['ID'] . '#' . $prop['CODE']]] = $prop['VALUE'][0];
|
||||
} elseif (is_array($arParams['optionsOrderProps'][$arOrder['PERSON_TYPE_ID']])
|
||||
&& $search = array_search($prop['CODE'], $arParams['optionsOrderProps'][$arOrder['PERSON_TYPE_ID']])) {//other
|
||||
if (in_array($search, ['fio', 'phone', 'email'])) {//fio, phone, email
|
||||
|
@ -557,6 +557,7 @@ class RetailCrmOrder
|
|||
'optionsContragentType' => $optionsContragentType,
|
||||
'optionsSitesList' => RetailcrmConfigProvider::getSitesList(),
|
||||
'optionsCustomFields' => $optionsCustomFields,
|
||||
'customOrderProps' => RetailcrmConfigProvider::getMatchedOrderProps(),
|
||||
];
|
||||
|
||||
$recOrders = [];
|
||||
|
|
|
@ -26,6 +26,7 @@ class RetailCrmUser
|
|||
}
|
||||
|
||||
$customer = self::getSimpleCustomer($arFields);
|
||||
$customer['customFields'] = self::getCustomFields($arFields);
|
||||
$customer['createdAt'] = new \DateTime($arFields['DATE_REGISTER']);
|
||||
$customer['contragent'] = ['contragentType' => $contragentType];
|
||||
|
||||
|
@ -73,6 +74,7 @@ class RetailCrmUser
|
|||
}
|
||||
|
||||
$customer = self::getSimpleCustomer($arFields);
|
||||
$customer['customFields'] = self::getCustomFields($arFields);
|
||||
$found = false;
|
||||
|
||||
if (count($optionsSitesList) > 0) {
|
||||
|
@ -151,4 +153,18 @@ class RetailCrmUser
|
|||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
private static function getCustomFields(array $arFields)
|
||||
{
|
||||
$customUserFields = RetailcrmConfigProvider::getMatchedUserFields();
|
||||
$result = [];
|
||||
|
||||
foreach ($customUserFields as $code => $codeCrm) {
|
||||
if (!empty($arFields[$code])) {
|
||||
$result[$codeCrm] = $arFields[$code];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue