- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicatebankdetailcriterion.php
- Класс: Bitrix\Crm\Integrity\DuplicateBankDetailCriterion
- Вызов: DuplicateBankDetailCriterion::prepareSearchQuery
public function prepareSearchQuery($entityTypeID = \CCrmOwnerType::Undefined,
array $select = null, array $order = null, $limit = 0)
{
if($this->fieldName === '')
{
throw new Main\InvalidOperationException('The field "fieldName" is not assigned.');
}
if($this->value === '')
{
throw new Main\InvalidOperationException('The field "value" is not assigned.');
}
if(!is_int($entityTypeID))
{
throw new Main\ArgumentTypeException('entityTypeID', 'integer');
}
$query = new Main\Entity\Query(DuplicateBankDetailMatchCodeTable::getEntity());
if(!is_array($select))
{
$select = array();
}
if(empty($select))
{
$select = array('ENTITY_TYPE_ID', 'ENTITY_ID');
}
$query->setSelect($select);
if(is_array($order) && !empty($order))
{
$query->setOrder($order);
}
$filter = array();
if ($this->countryId > 0)
$filter['=BD_COUNTRY_ID'] = $this->countryId;
$filter['=BD_FIELD_NAME'] = $this->fieldName;
$value = self::prepareCode($this->countryId, $this->fieldName, $this->value);
if($this->useStrictComparison)
{
$filter['=VALUE'] = $value;
}
else
{
$filter['%VALUE'] = new Main\DB\SqlExpression('?s', $value.'%');
}
if(\CCrmOwnerType::IsDefined($entityTypeID))
{
$filter['ENTITY_TYPE_ID'] = $entityTypeID;
}
$query->setFilter($filter);
if($limit > 0)
{
$query->setLimit($limit);
}
return $query;
}