• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/crm.php
  • Класс: BitrixImOpenLinesCrm
  • Вызов: Crm::search
public function search(): bool
{
	$fields = $this->getFields();
	$filter = false;

	$facility = $this->getEntityManageFacility();
	$selector = $facility->getSelector();

	if (!$this->isIgnoreSearchCode())
	{
		if (($code = $this->getCode()) && ($codeImol = $this->getCodeImol()))
		{
			$selector->appendCommunicationCriterion(CrmCommon::getCommunicationType($code), $codeImol);
			$filter = true;
		}
	}

	if (!$this->isIgnoreSearchUserId())
	{
		if ($userId = $this->getUserId())
		{
			$selector->appendCommunicationCriterion(Type::SLUSER_NAME, (string)$userId);
			$filter = true;
		}
	}

	if (!$this->isIgnoreSearchPerson())
	{
		if ($fields->getPersonName() != LiveChat::getDefaultGuestName())
		{
			$personName = $fields->getPersonName();
		}
		else
		{
			$personName = '';
		}
		if ($fields->getPersonLastName() != LiveChat::getDefaultGuestName())
		{
			$personLastName = $fields->getPersonLastName();
		}
		else
		{
			$personLastName = '';
		}
		if ($fields->getPersonSecondName() != LiveChat::getDefaultGuestName())
		{
			$personSecondName = $fields->getPersonSecondName();
		}
		else
		{
			$personSecondName = '';
		}

		if (!empty($personName) || !empty($personLastName) || !empty($personSecondName))
		{
			$selector->appendPersonCriterion($personLastName, $personName, $personSecondName);

			$filter = true;
		}

		if (!empty($fields->getPersonEmail()))
		{
			$selector->appendEmailCriterion($fields->getPersonEmail());

			$filter = true;
		}

		if (!empty($fields->getPersonPhone()))
		{
			$selector->appendPhoneCriterion($fields->getPersonPhone());

			$filter = true;
		}
	}

	if (!$this->isIgnoreSearchEmails())
	{
		if (!empty($fields->getEmails()))
		{
			foreach ($fields->getEmails() as $email)
			{
				$selector->appendEmailCriterion($email);

				$filter = true;
			}
		}
	}

	if (!$this->isIgnoreSearchPhones())
	{
		if (!empty($fields->getPhones()))
		{
			foreach ($fields->getPhones() as $phone)
			{
				$selector->appendPhoneCriterion($phone);

				$filter = true;
			}
		}
	}

	if ($filter !== false)
	{
		$selector->search();
	}

	return true;
}