- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicateindexbuilder.php
- Класс: Bitrix\Crm\Integrity\DuplicateIndexBuilder
- Вызов: DuplicateIndexBuilder::prepareTableData
protected function prepareTableData($matchHash, Duplicate $item, array &$sortParams, $enablePrimaryKey = true)
{
$data = array(
'ROOT_ENTITY_ID' => 0,
'ROOT_ENTITY_NAME' => '',
'ROOT_ENTITY_TITLE' => '',
'ROOT_ENTITY_PHONE' => '',
'ROOT_ENTITY_EMAIL' => ''
);
foreach (DuplicateRequisiteCriterion::getSupportedDedupeTypes() as $typeID)
{
$fieldName = DuplicateIndexType::resolveName($typeID);
$data["ROOT_ENTITY_{$fieldName}"] = '';
}
foreach (DuplicateBankDetailCriterion::getSupportedDedupeTypes() as $typeID)
{
$fieldName = DuplicateIndexType::resolveName($typeID);
$data["ROOT_ENTITY_{$fieldName}"] = '';
}
$data['QUANTITY'] = 0;
$entityTypeID = $this->getEntityTypeID();
if($enablePrimaryKey)
{
$data['USER_ID'] = $this->getUserID();
$data['ENTITY_TYPE_ID'] = $entityTypeID;
$data['TYPE_ID'] = $this->typeID;
$data['MATCH_HASH'] = $matchHash;
$data['SCOPE'] = $this->getScope();
$criterion = $item->getCriterion();
$data['MATCHES'] = serialize($criterion->getMatches());
}
$entityID = $item->getRootEntityID();
if($entityID > 0)
{
$data['ROOT_ENTITY_ID'] = $entityID;
$pers = isset($sortParams['PERS']) ? $sortParams['PERS'] : null;
if(is_array($pers) && isset($pers[$entityID]) && isset($pers[$entityID]['FULL_NAME']))
{
$data['ROOT_ENTITY_NAME'] = $pers[$entityID]['FULL_NAME'];
}
$org = isset($sortParams['ORG']) ? $sortParams['ORG'] : null;
if(is_array($org) && isset($org[$entityID]) && isset($org[$entityID]['TITLE']))
{
$data['ROOT_ENTITY_TITLE'] = $org[$entityID]['TITLE'];
}
$comm = isset($sortParams['COMM']) ? $sortParams['COMM'] : null;
if(is_array($comm) && isset($comm[$entityID]))
{
if(isset($comm[$entityID]['PHONE']))
{
$data['ROOT_ENTITY_PHONE'] = $comm[$entityID]['PHONE'];
}
if(isset($comm[$entityID]['EMAIL']))
{
$data['ROOT_ENTITY_EMAIL'] = $comm[$entityID]['EMAIL'];
}
}
$rq = isset($sortParams['RQ']) ? $sortParams['RQ'] : null;
if(is_array($rq) && isset($rq[$entityID]))
{
foreach (DuplicateRequisiteCriterion::getSupportedDedupeTypes() as $typeID)
{
$fieldName = DuplicateIndexType::resolveName($typeID);
if (is_array($rq[$entityID][$fieldName]))
{
foreach ($rq[$entityID][$fieldName] as $scope => $value)
{
if ($scope === $this->getScope())
$data["ROOT_ENTITY_{$fieldName}"] = $value;
}
}
}
}
$bd = isset($sortParams['BD']) ? $sortParams['BD'] : null;
if(is_array($bd) && isset($bd[$entityID]))
{
foreach (DuplicateBankDetailCriterion::getSupportedDedupeTypes() as $typeID)
{
$fieldName = DuplicateIndexType::resolveName($typeID);
if (isset($bd[$entityID][$fieldName]))
{
foreach ($bd[$entityID][$fieldName] as $scope => $value)
{
if ($scope === $this->getScope())
$data["ROOT_ENTITY_{$fieldName}"] = $value;
}
}
}
}
}
return $data;
}