DuplicatePersonCriterion::prepareSortParams

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. DuplicatePersonCriterion
  4. prepareSortParams
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicatepersoncriterion.php
  • Класс: Bitrix\Crm\Integrity\DuplicatePersonCriterion
  • Вызов: DuplicatePersonCriterion::prepareSortParams
static function prepareSortParams($entityTypeID, array $entityIDs)
{
	if(empty($entityIDs))
	{
		return array();
	}

	$query = new Main\Entity\Query(DuplicatePersonMatchCodeTable::getEntity());
	$query->addSelect('ENTITY_ID');
	$query->addSelect('LAST_NAME');
	$query->addSelect('SECOND_NAME');
	$query->addSelect('NAME');

	$query->addFilter('=ENTITY_TYPE_ID', $entityTypeID);
	$query->addFilter('@ENTITY_ID', $entityIDs);

	$result = array();

	$dbResult = $query->exec();
	while($fields = $dbResult->fetch())
	{
		$entityID = intval($fields['ENTITY_ID']);

		$name = isset($fields['NAME']) ? $fields['NAME'] : '';
		$secondName = isset($fields['SECOND_NAME']) ? $fields['SECOND_NAME'] : '';
		$lastName = isset($fields['LAST_NAME']) ? $fields['LAST_NAME'] : '';

		if($name !== '' && $secondName !== '')
		{
			$slug = "{$lastName} {$name} {$secondName}";
		}
		elseif($name !== '')
		{
			$slug = "{$lastName} {$name}";
		}
		else
		{
			$slug = $lastName;
		}
		$result[$entityID] = array('FULL_NAME' => $slug);
	}
	return $result;
}

Добавить комментарий