1
0
Fork 0
mirror of synced 2025-04-11 05:00:55 +00:00
Удален неиспользуемых код
Изменена фильтрация свойств заказов
Добавлены проверки при получении параметров по истории.
This commit is contained in:
Ivan Chaplygin 2023-12-19 10:10:58 +03:00
parent cb3ce4d171
commit 58146c541d
3 changed files with 28 additions and 57 deletions

View file

@ -449,6 +449,26 @@ class RCrmActions
'DATE' => 'DATE'
];
//Базовые свойства заказа и используемые свойства в функционале модуля
$bannedCodeList = [
'FIO',
'EMAIL',
'PHONE',
'ZIP',
'CITY',
'LOCATION',
'ADDRESS',
'COMPANY',
'COMPANY_ADR',
'INN',
'KPP',
'CONTACT_PERSON',
'FAX',
'LP_BONUS_INFO',
'LP_DISCOUNT_INFO',
''
];
$listPersons = PersonType::getList([
'select' => ['ID', 'NAME'],
'filter' => ['ENTITY_REGISTRY_TYPE' => 'ORDER']
@ -463,10 +483,7 @@ class RCrmActions
$propsList = OrderPropsTable::getList([
'select' => ['ID', 'CODE', 'NAME', 'PERSON_TYPE_ID', 'TYPE'],
'filter' => [
['!=CODE' => "LP_BONUS_INFO"],
['!=CODE' => "LP_DISCOUNT_INFO"],
['!=CODE' => ''],
['>ID' => 19],
['!=CODE' => $bannedCodeList],
['?TYPE' => 'STRING | NUMBER | Y/N | DATE'],
['MULTIPLE' => 'N'],
['ACTIVE' => 'Y']

View file

@ -64,8 +64,8 @@ class RetailCrmHistory
$historyStart = RetailcrmConfigProvider::getCustomersHistorySinceId();
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
$matchedCustomFields = RetailcrmConfigProvider::getMatchedUserFields() ?? [];
$matchedCustomFields = array_flip($matchedCustomFields);
$matchedCustomFields = RetailcrmConfigProvider::getMatchedUserFields();
$matchedCustomFields = is_array($matchedCustomFields) ? array_flip($matchedCustomFields) : [];
self::$CUSTOM_FIELDS_IS_ACTIVE = RetailcrmConfigProvider::getCustomFieldsStatus();
$customUserFieldTypes = [];
@ -277,10 +277,10 @@ class RetailCrmHistory
$shipmentDeducted = RetailcrmConfigProvider::getShipmentDeducted();
$matchedCustomUserFields = RetailcrmConfigProvider::getMatchedUserFields() ?? [];
$matchedCustomUserFields = array_flip($matchedCustomUserFields);
$matchedCustomUserFields = is_array($matchedCustomUserFields) ? array_flip($matchedCustomUserFields) : [];
$matchedCustomOrderFields = RetailcrmConfigProvider::getMatchedOrderProps() ?? [];
$matchedCustomOrderFields = array_flip($matchedCustomOrderFields);
$matchedCustomOrderFields = is_array($matchedCustomOrderFields) ? array_flip($matchedCustomOrderFields) : [];
self::$CUSTOM_FIELDS_IS_ACTIVE = RetailcrmConfigProvider::getCustomFieldsStatus();
@ -1253,8 +1253,8 @@ class RetailCrmHistory
if (self::$CUSTOM_FIELDS_IS_ACTIVE === 'Y' && !empty($matchedCustomOrderFields)) {
foreach ($order['customFields'] as $code => $value) {
if (isset($matchedCustomOrderFields[$code])) {
$masIdentifier = explode('#', $matchedCustomOrderFields[$code], 2);
$property = $propertyCollection->getItemByOrderPropertyId($masIdentifier[0]);
$arrayIdentifier = explode('#', $matchedCustomOrderFields[$code], 2);
$property = $propertyCollection->getItemByOrderPropertyId($arrayIdentifier[0]);
$value = RCrmActions::convertCrmValueToCmsField($value, $property->getType());
$queryResult = $property->setField('VALUE', $value);
@ -1262,7 +1262,7 @@ class RetailCrmHistory
RCrmActions::eventLog(
'RetailCrmHistory::orderHistory',
'CustomOrderPropSave',
'Error when saving a property: ' . $masIdentifier[1]
'Error when saving a property: ' . $arrayIdentifier[1]
);
}
}

View file

@ -1434,52 +1434,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
document.getElementById(type + "_matched").appendChild(matchedElement);
}
function createMatchedOrder()
{
let elements = document.getElementsByClassName("adm-list-table-row matched-Order");
let nextId = 1;
if (elements.length >= 1) {
let lastElement = elements[elements.length - 1];
nextId = parseInt(lastElement.id.replace("matchedOrderFields_", "")) + 1;
}
let matchedBlank = document.getElementById("OrderMatchedFieldsBlank");
let matchedElement = matchedBlank.cloneNode(true);
matchedElement.classList.add("adm-list-table-row");
matchedElement.classList.add("matched-Order");
matchedElement.setAttribute("id", "matchedOrderFields_" + nextId);
matchedElement.querySelector("select[name='bitrixOrderFields']").setAttribute("name", "bitrixOrderFields_" + nextId);
matchedElement.querySelector("select[name='crmOrderFields']").setAttribute("name", "crmOrderFields_" + nextId);
matchedElement.removeAttribute("hidden");
document.getElementById("Order_matched").appendChild(matchedElement);
}
function createMatchedUser()
{
let elements = document.getElementsByClassName("adm-list-table-row matched-User");
let nextId = 1;
if (elements.length >= 1) {
let lastElement = elements[elements.length-1];
nextId = parseInt(lastElement.id.replace("matchedUserFields_", "")) + 1;
}
let matchedBlank = document.getElementById("UserMatchedFieldsBlank");
let matchedElement = matchedBlank.cloneNode(true);
matchedElement.classList.add("adm-list-table-row");
matchedElement.classList.add("matched-User");
matchedElement.setAttribute("id", "matchedUserFields_" + nextId);
matchedElement.querySelector("select[name='bitrixUserFields']").setAttribute("name", "bitrixUserFields_" + nextId);
matchedElement.querySelector("select[name='crmUserFields']").setAttribute("name", "crmUserFields_" + nextId);
matchedElement.removeAttribute("hidden");
document.getElementById("User_matched").appendChild(matchedElement);
}
function deleteMatched(element)
{
element.parentNode.parentNode.remove();