25 $factory = static::getFactory($entityType);
32 $fieldsCollection = $factory->getFieldsCollection();
33 foreach ($fieldsCollection as $field)
35 $type = static::getFieldType($field->getType());
38 || !$field->isDisplayed()
44 $fieldName = $field->getName();
46 $entityFields[$fieldName] = [
47 'Name' => $field->getTitle(),
49 'Filterable' => !$field->isUserField(),
50 'Editable' => \CCrmFieldInfoAttr::isFieldHasAttribute($field->getSettings(), \CCrmFieldInfoAttr::ReadOnly),
51 'Required' => $field->isRequired(),
56 return $entityFields + static::getAssignedByFields();
62 Field::TYPE_STRING => Field::TYPE_STRING,
63 Field::TYPE_BOOLEAN => Field::TYPE_BOOLEAN,
64 Field::TYPE_CRM_STATUS =>
'select',
65 Field::TYPE_DATE => Field::TYPE_DATETIME,
66 Field::TYPE_DATETIME => Field::TYPE_DATETIME,
67 Field::TYPE_TEXT => Field::TYPE_TEXT,
68 Field::TYPE_INTEGER =>
'int',
71 return $map[$type] ??
null;
77 array $usedFields = [
'*'],
78 string $sortBy =
'id',
79 string $sortOrder =
'asc'
82 $hasIncorrectFields =
false;
84 if (empty($usedFields))
88 $factory = static::getFactory($entityType);
94 $fields = array_values($usedFields);
96 $oldIncorrectFields = [
97 'ASSIGNED_BY_EMAIL' =>
'ASSIGNED_BY.EMAIL',
98 'ASSIGNED_BY_WORK_PHONE' =>
'ASSIGNED_BY.WORK_PHONE',
99 'ASSIGNED_BY_PERSONAL_MOBILE' =>
'ASSIGNED_BY.PERSONAL_MOBILE',
101 foreach ($fields as &$field)
103 if (array_key_exists($field, $oldIncorrectFields))
105 $field = $oldIncorrectFields[$field];
106 if (!$hasIncorrectFields)
108 $hasIncorrectFields =
true;
114 $items = $factory->getItems([
115 'select' => array_merge(
117 [
'UF_*',
'ASSIGNED_BY_ID']
123 foreach ($items as $item)
125 $data = $item->getCompatibleData();
127 if ($item->getAssignedById() > 0)
131 static::processUserFieldValues($factory->getUserFields(), $data);
132 $result[$data[
'ID']] = $data + static::getCommunicationFieldsValues($factory->getEntityTypeId(), $data[
'ID']);
133 if ($hasIncorrectFields)
135 foreach ($oldIncorrectFields as $incorrectField => $correctField)
137 if (isset($data[$correctField]) && !empty($data[$correctField]))
139 $result[$data[
'ID']] += [
140 $incorrectField => $data[$correctField]