3use Bitrix\Crm\Service\Container;
4use Bitrix\Crm\UserField\Types\ElementType;
32 throw new \Bitrix\Main\SystemException(
'Method "getEntityName" must be defined in child class.');
37 throw new \Bitrix\Main\SystemException(
'Method "getOwnerId" must be defined in child class.');
42 throw new \Bitrix\Main\SystemException(
'Method "getColumnList" must be defined in child class.');
52 throw new \Bitrix\Main\SystemException(
'Method "getDefaultColumns" must be defined in child class.');
57 throw new \Bitrix\Main\SystemException(
'Method "getPeriodFilter" must be defined in child class.');
62 if (!is_array(self::$arUFId) ||
count(self::$arUFId) <= 0 || is_array(self::$ufInfo))
65 self::$arUFId =
array();
66 self::$ufInfo =
array();
67 self::$ufEnumerations =
array();
72 static::prepareUFInfo();
79 if (!is_array(self::$ufEnumerations))
81 self::$ufEnumerations =
array();
87 static::prepareUFEnumerations($usedUFMap);
89 return self::$ufEnumerations;
94 static::prepareUFInfo();
101 if ($field instanceof \
Bitrix\Main\
Entity\ExpressionField && is_array(self::$ufInfo) &&
count(self::$ufInfo) > 0)
103 $ufKey = $field->getName();
104 $ufId = $field->getEntity()->getUFId();
105 if (is_string($ufId) && !empty($ufId) && array_key_exists($ufId, self::$ufInfo)
106 && is_array(self::$ufInfo[$ufId])
107 && array_key_exists($ufKey, self::$ufInfo[$ufId]))
109 $arUF[
'isUF'] =
true;
110 $arUF[
'ufInfo'] = self::$ufInfo[$ufId][$ufKey];
121 if (is_array($arUF) && isset($arUF[
'isUF']) && $arUF[
'isUF'] ===
true && isset($arUF[
'ufInfo'])
122 && is_array($arUF[
'ufInfo']) && isset($arUF[
'ufInfo'][
'USER_TYPE_ID']))
124 $result = $arUF[
'ufInfo'][
'USER_TYPE_ID'];
130 public static function getFieldDataType($field)
132 static::prepareUFInfo();
135 $dataType = $field->getDataType();
138 if ($dataType ===
'date')
139 $dataType =
'datetime';
142 if ($field instanceof
Entity\ExpressionField && is_array(self::$ufInfo) &&
count(self::$ufInfo) > 0)
144 $ufKey = $field->getName();
145 $ufId = $field->getEntity()->getUFId();
146 if (is_string($ufId) && !empty($ufId) && array_key_exists($ufId, self::$ufInfo)
147 && is_array(self::$ufInfo[$ufId])
148 && array_key_exists($ufKey, self::$ufInfo[$ufId]))
150 $ufInfo = self::$ufInfo[$ufId][$ufKey];
157 switch (
$ufInfo[
'USER_TYPE_ID'])
160 $dataType =
'integer';
166 $dataType =
'boolean';
169 $dataType =
'datetime';
172 $dataType =
'datetime';
178 $dataType =
'employee';
184 $dataType =
'disk_file';
190 $dataType =
'crm_status';
192 case 'iblock_element':
193 $dataType =
'iblock_element';
195 case 'iblock_section':
196 $dataType =
'iblock_section';
210 $ufId = isset(
$ufInfo[
'ENTITY_ID']) ? strval(
$ufInfo[
'ENTITY_ID']) :
'';
211 $ufName = isset(
$ufInfo[
'FIELD_NAME']) ? strval(
$ufInfo[
'FIELD_NAME']) :
'';
213 if (!empty($ufId) && !empty($ufName))
215 if (!is_array(self::$ufEnumerations) || !isset(self::$ufEnumerations[$ufId][$ufName]))
217 static::prepareUFEnumerations(
array($ufId =>
array($ufName =>
true)));
220 if (is_array(self::$ufEnumerations) && isset(self::$ufEnumerations[$ufId][$ufName][$valueKey][
'VALUE']))
221 $value = self::$ufEnumerations[$ufId][$ufName][$valueKey][
'VALUE'];
229 $valueKey = intval($valueKey);
234 if (is_array(self::$ufFiles) && is_array(self::$ufFiles[$valueKey]))
236 $arFile = self::$ufFiles[$valueKey];
238 $value =
htmlspecialcharsbx($arFile[
'ORIGINAL_NAME'].
' ('.$file->FormatSize($arFile[
'FILE_SIZE']).
')');
251 $valueKey = intval($valueKey);
256 if (is_array(self::$ufFiles) && is_array(self::$ufFiles[$valueKey]))
258 $arFile = self::$ufFiles[$valueKey];
272 $valueKey = intval($valueKey);
277 if (is_array(self::$ufDiskFiles) && is_array(self::$ufDiskFiles[$valueKey]))
279 $arDiskFile = self::$ufDiskFiles[$valueKey];
280 $src = isset($arDiskFile[
'DOWNLOAD_URL']) ? strval($arDiskFile[
'DOWNLOAD_URL']) :
'';
284 $value =
'<a target="_blank" href="'.htmlspecialcharsbx($src).
'" title="'.
290 $value =
htmlspecialcharsbx($arDiskFile[
'NAME'].
' ('.$file->FormatSize($arDiskFile[
'SIZE']).
')');
304 $valueKey = intval($valueKey);
309 if (is_array(self::$ufDiskFiles) && is_array(self::$ufDiskFiles[$valueKey]))
311 $arFile = self::$ufDiskFiles[$valueKey];
325 $valueKey = intval($valueKey);
330 if (is_array(self::$ufEmployees) && is_array(self::$ufEmployees[$valueKey]))
332 $employeeName = CUser::FormatName(self::getUserNameFormat(), self::$ufEmployees[$valueKey],
true);
333 if (!empty($employeeName))
335 $employeeLink = str_replace(
336 array(
'#ID#',
'#USER_ID#'),
337 urlencode($valueKey),
338 COption::GetOptionString(
'intranet',
'path_user',
'/company/personal/user/#USER_ID#/')
340 if (empty($employeeLink))
341 $value = $employeeName;
343 $value =
'<a href="'.$employeeLink.
'">'.$employeeName.
'</a>';
357 $valueKey = intval($valueKey);
362 if (is_array(self::$ufEmployees) && is_array(self::$ufEmployees[$valueKey]))
364 $employeeName = CUser::FormatName(self::getUserNameFormat(), self::$ufEmployees[$valueKey],
true);
365 if (!empty($employeeName))
366 $value = $employeeName;
383 $userPermissions = Container::getInstance()->getUserPermissions();
384 foreach (array_keys(ElementType::getPossibleEntityTypes()) as $entityTypeName)
386 $entityTypeNameLower = mb_strtolower($entityTypeName);
387 $entityTypeId = CCrmOwnerType::ResolveID($entityTypeName);
389 $entityTypeId !== CCrmOwnerType::Undefined
390 && $userPermissions->entityType()->canReadItems($entityTypeId)
393 $result[$entityTypeNameLower] =
394 CCrmOwnerTypeAbbr::ResolveByTypeName($entityTypeName)
405 $valueKey = trim(strval($valueKey));
410 $prefixByType = static::getUserFieldCrmTypePrefixMap();
412 $maxPrefixLength = 3;
413 $singleTypePrefix =
'';
414 if (is_array(
$ufInfo[
'SETTINGS']))
416 $supportedTypes =
array();
419 if ($supported ===
'Y')
420 $supportedTypes[
$type] =
true;
422 $supportedTypes = array_keys($supportedTypes);
423 if (
count($supportedTypes) === 1)
425 if (isset($prefixByType[mb_strtolower($supportedTypes[0])]))
426 $singleTypePrefix = $prefixByType[mb_strtolower($supportedTypes[0])];
428 unset($supportedTypes,
$type, $supported);
432 if (($pos = mb_strpos(mb_substr($valueKey, 0, $maxPrefixLength + 1),
'_')) !==
false && $pos > 0)
433 $prefix = mb_substr($valueKey, 0, $pos);
435 $valueKey = $singleTypePrefix .
'_' . $valueKey;
436 unset($prefix, $pos);
438 if (is_array(self::$ufCrmElements) && is_array(self::$ufCrmElements[$valueKey]))
440 $element = self::$ufCrmElements[$valueKey];
441 $item = explode(
'_', $valueKey);
442 if ($item[0] !==
'' && $item[1] !==
'')
444 $entityTitle = $element[
'title'];
445 $entityUrl = $element[
'url'];
446 if ($entityTitle !==
'')
448 if ($entityUrl !==
'')
451 '<a target="_blank" href="' . $entityUrl .
'">'
469 $valueKey = trim(strval($valueKey));
474 $prefixByType = static::getUserFieldCrmTypePrefixMap();
476 $maxPrefixLength = 3;
477 $singleTypePrefix =
'';
478 if (is_array(
$ufInfo[
'SETTINGS']))
480 $supportedTypes =
array();
483 if ($supported ===
'Y')
484 $supportedTypes[
$type] =
true;
486 $supportedTypes = array_keys($supportedTypes);
487 if (
count($supportedTypes) === 1)
489 if (isset($prefixByType[mb_strtolower($supportedTypes[0])]))
490 $singleTypePrefix = $prefixByType[mb_strtolower($supportedTypes[0])];
492 unset($supportedTypes,
$type, $supported);
496 if (($pos = mb_strpos(mb_substr($valueKey, 0, $maxPrefixLength + 1),
'_')) !==
false && $pos > 0)
497 $prefix = mb_substr($valueKey, 0, $pos);
499 $valueKey = $singleTypePrefix .
'_' . $valueKey;
500 unset($prefix, $pos);
502 if (is_array(self::$ufCrmElements) && is_array(self::$ufCrmElements[$valueKey]))
504 $element = self::$ufCrmElements[$valueKey];
505 $item = explode(
'_', $valueKey);
506 if ($item[0] <>
'' && $item[1] <>
'')
518 $entityType = isset(
$ufInfo[
'SETTINGS'][
'ENTITY_TYPE']) ? strval(
$ufInfo[
'SETTINGS'][
'ENTITY_TYPE']) :
'';
519 $valueKey = trim(strval($valueKey));
522 if (!empty($entityType) && $valueKey <>
'')
524 if (is_array(self::$ufCrmStatuses) && isset(self::$ufCrmStatuses[$entityType][$valueKey]))
533 $valueKey = intval($valueKey);
538 if (is_array(self::$ufIblockElements) && is_array(self::$ufIblockElements[$valueKey]))
540 $element = self::$ufIblockElements[$valueKey];
542 $elementName = $element[
'~NAME'];
543 if (!empty($element[
'~DETAIL_PAGE_URL']))
544 $elementLink = $element[
'~DETAIL_PAGE_URL'];
545 if ($elementName <>
'')
547 if ($elementLink <>
'')
549 $value =
'<a target="_blank" href="'.$elementLink.
'">'.
563 $valueKey = intval($valueKey);
568 if (is_array(self::$ufIblockElements) && is_array(self::$ufIblockElements[$valueKey]))
570 $element = self::$ufIblockElements[$valueKey];
571 $elementName = $element[
'~NAME'];
572 if ($elementName <>
'')
582 $valueKey = intval($valueKey);
587 if (is_array(self::$ufIblockSections) && is_array(self::$ufIblockSections[$valueKey]))
589 $section = self::$ufIblockSections[$valueKey];
591 $sectionName = $section[
'~NAME'];
592 if (!empty($section[
'~SECTION_PAGE_URL']))
593 $sectionLink = $section[
'~SECTION_PAGE_URL'];
594 if ($sectionName <>
'')
596 if ($sectionLink <>
'')
598 $value =
'<a target="_blank" href="'.$sectionLink.
'">'.
612 $valueKey = intval($valueKey);
617 if (is_array(self::$ufIblockSections) && is_array(self::$ufIblockSections[$valueKey]))
619 $section = self::$ufIblockSections[$valueKey];
620 $sectionName = $section[
'~NAME'];
621 if ($sectionName <>
'')
634 && isset(
$ufInfo[
'USER_TYPE'][
'VIEW_CALLBACK'])
635 && is_callable(
$ufInfo[
'USER_TYPE'][
'VIEW_CALLBACK']))
637 $value = [
'VALUE' => $value];
638 $value = call_user_func_array(
$ufInfo[
'USER_TYPE'][
"VIEW_CALLBACK"], [$value]);
649 && is_string(
$ufInfo[
'USER_TYPE'][
'CLASS_NAME']) &&
$ufInfo[
'USER_TYPE'][
'CLASS_NAME'] !==
''
650 && is_callable(
array(
$ufInfo[
'USER_TYPE'][
'CLASS_NAME'],
'getPublicText')))
652 $value = [
'VALUE' => $value];
654 call_user_func_array([
$ufInfo[
'USER_TYPE'][
'CLASS_NAME'],
'getPublicText'], [$value])
713 'disk_file' =>
array(
722 'crm_status' =>
array(
725 'iblock_element' =>
array(
728 'iblock_section' =>
array(
781 '\Bitrix\Main\User' =>
array(
784 '\Bitrix\Socialnetwork\Workgroup' =>
array(
795 'disk_file' =>
array(
807 'crm_status' =>
array(
811 'iblock_element' =>
array(
815 'iblock_section' =>
array(
837 if (is_array($withReferencesChoose))
839 $filtrableGroups = $withReferencesChoose;
844 $filtrableGroups = [];
845 $isRefChoose = $withReferencesChoose;
852 foreach($tree as $treeElem)
854 $isLastElem = (++
$i ==
count($tree));
856 $fieldDefinition = $treeElem[
'fieldName'];
857 $branch = $treeElem[
'branch'];
860 $customColumnTypes = static::getCustomColumnTypes();
861 if (array_key_exists($fieldDefinition, $customColumnTypes))
863 $fieldType = $customColumnTypes[$fieldDefinition];
867 $fieldType = $treeElem[
'field'] ? static::getFieldDataType($treeElem[
'field']) :
null;
871 if ($isRefChoose && ($fieldType ===
'file' || $fieldType ===
'disk_file'))
877 if ($isRefChoose && $fieldType ===
'money'
878 && $treeElem[
'isUF'] ===
true
879 && is_array($treeElem[
'ufInfo'])
880 && isset($treeElem[
'ufInfo'][
'MULTIPLE'])
881 && $treeElem[
'ufInfo'][
'MULTIPLE'] ===
'Y')
889 $htmlElem = static::buildSelectTreePopupElelemnt(
890 $treeElem[
'humanTitle'],
891 $treeElem[
'fullHumanTitle'],
894 (($treeElem[
'isUF'] ??
false) ===
true && is_array($treeElem[
'ufInfo']))
895 ? $treeElem[
'ufInfo']
899 if ($isLastElem && $level > 0)
901 $htmlElem = str_replace(
902 '<div class="reports-add-popup-item">',
903 '<div class="reports-add-popup-item reports-add-popup-item-last">',
915 $scalarTypes =
array(
'integer',
'float',
'string',
'text',
'boolean',
'file',
'disk_file',
'datetime',
916 'enum',
'employee',
'crm',
'crm_status',
'iblock_element',
'iblock_section',
'money');
918 && !in_array($fieldDefinition, $filtrableGroups,
true)
919 && (in_array($fieldType, $scalarTypes) || empty($fieldType))
926 $html .= sprintf(
'<div class="reports-add-popup-item reports-add-popup-it-node">
927 <span class="reports-add-popup-arrow"></span><span
928 class="reports-add-popup-it-text">%s</span>
929 </div>', $treeElem[
'humanTitle']);
931 $html .=
'<div class="reports-add-popup-it-children">';
936 $html .= static::buildSelectTreePopupElelemnt(
938 $treeElem[
'humanTitle'],
944 $html .= static::buildHTMLSelectTreePopup($branch, $withReferencesChoose, $level+1);
956 $grcFields = static::getGrcColumns();
960 $ufId = $ufName =
'';
964 $ufName =
$ufInfo[
'FIELD_NAME'];
970 $htmlCheckbox = sprintf(
971 '<input type="checkbox" name="%s" title="%s" fieldType="%s" isGrc="%s" isUF="%s"%s class="reports-add-popup-checkbox" />',
973 (
int) in_array($fieldDefinition, $grcFields), (
int)$isUF,
977 $htmlElem = sprintf(
'<div class="reports-add-popup-item">
978 <span class="reports-add-pop-left-bord"></span><span
979 class="reports-add-popup-checkbox-block">
981 </span><span class="reports-add-popup-it-text%s">%s</span>
998 if (is_array($fElem) && $fElem[
'type'] ==
'field')
1000 $field = $fieldList[$fElem[
'name']];
1002 if ($field instanceof
Entity\ReferenceField)
1003 static::fillFilterReferenceColumn($fElem, $field);
1011 if ($field->getRefEntityName() ==
'\Bitrix\Main\User')
1014 if ($filterElement[
'value'])
1016 $res = CUser::GetByID($filterElement[
'value']);
1021 $username = CUser::FormatName(static::getUserNameFormat(),
$user,
true,
false);
1022 $filterElement[
'value'] =
array(
'id' =>
$user[
'ID'],
'name' => $username);
1026 $filterElement[
'value'] =
array(
'id' => $filterElement[
'value'],
'name' =>
GetMessage(
'REPORT_USER_NOT_FOUND'));
1031 $filterElement[
'value'] =
array(
'id' =>
'');
1034 else if ($field->getRefEntityName() ==
'\Bitrix\Socialnetwork\Workgroup')
1037 if ($filterElement[
'value'])
1039 $group = CSocNetGroup::GetByID($filterElement[
'value']);
1043 $filterElement[
'value'] =
array(
array(
'id' => $group[
'ID'],
'title' => $group[
'NAME']));
1047 $filterElement[
'value'] =
array(
array(
'id' => $filterElement[
'value'],
'title' =>
GetMessage(
'REPORT_PROJECT_NOT_FOUND')));
1052 $filterElement[
'value'] =
array(
array(
'id' =>
''));
1059 foreach ($filters as &
$filter)
1063 if (is_array($fElem) && $fElem[
'type'] ==
'field')
1065 $field = $fieldList[$fElem[
'name']];
1067 $arUF = static::detectUserField($field);
1068 if ($arUF[
'isUF'] && is_array($arUF[
'ufInfo']) && isset($arUF[
'ufInfo'][
'USER_TYPE_ID']))
1069 static::fillFilterUFColumn($fElem, $field, $arUF[
'ufInfo']);
1077 if (
$ufInfo[
'USER_TYPE_ID'] ===
'employee')
1079 $value = intval($filterElement[
'value']);
1084 $arUser =
$res->fetch();
1088 $userName = CUser::FormatName(self::getUserNameFormat(), $arUser,
true);
1089 $filterElement[
'value'] =
array(
'id' => $arUser[
'ID'],
'name' =>
$userName);
1093 $filterElement[
'value'] =
array(
'id' => $filterElement[
'value'],
'name' =>
GetMessage(
'REPORT_USER_NOT_FOUND'));
1098 $filterElement[
'value'] =
array(
'id' =>
'');
1133 $fileColumns =
array();
1134 $diskFileColumns =
array();
1135 $employeeColumns =
array();
1136 $crmColumns =
array();
1137 $crmStatusColumns =
array();
1138 $iblockElementColumns =
array();
1139 $iblockSectionColumns =
array();
1140 if (is_array($columnInfo))
1142 foreach ($columnInfo as
$k => $cInfo)
1145 ($cInfo[
'isUF'] ??
false)
1146 && isset($cInfo[
'ufInfo'])
1147 && is_array($cInfo[
'ufInfo'])
1148 && isset($cInfo[
'ufInfo'][
'USER_TYPE_ID'])
1151 switch ($cInfo[
'ufInfo'][
'USER_TYPE_ID'])
1154 $fileColumns[
$k] =
true;
1157 $diskFileColumns[
$k] =
true;
1160 $employeeColumns[
$k] =
true;
1163 $crmColumns[
$k] =
true;
1166 $crmStatusColumns[
$k] =
true;
1168 case 'iblock_element':
1169 $iblockElementColumns[
$k] =
true;
1171 case 'iblock_section':
1172 $iblockSectionColumns[
$k] =
true;
1179 $arFileID =
array();
1180 $arDiskFileID =
array();
1181 $arEmployeeID =
array();
1183 $arCrmStatusID =
array();
1184 $arCrmStatusEntityType =
array();
1185 $arIblockElementID =
array();
1186 $arIblockSectionID =
array();
1187 if (
count($fileColumns) > 0 ||
count($diskFileColumns) > 0 ||
count($employeeColumns) > 0
1188 ||
count($crmColumns) > 0 ||
count($crmStatusColumns) > 0 ||
count($iblockElementColumns) > 0
1189 ||
count($iblockSectionColumns) > 0)
1191 foreach (
$rows as $row)
1193 foreach ($row as
$k => $v)
1196 if (isset($fileColumns[
$k]))
1199 foreach ($v as $subv)
1201 $value = intval($subv);
1203 $arFileID[] = $value;
1207 $value = intval($v);
1209 $arFileID[] = $value;
1214 if (isset($diskFileColumns[
$k]))
1217 foreach ($v as $subv)
1219 $value = intval($subv);
1221 $arDiskFileID[] = $value;
1225 $value = intval($v);
1227 $arDiskFileID[] = $value;
1232 if (isset($employeeColumns[
$k]))
1235 foreach ($v as $subv)
1237 $value = intval($subv);
1239 $arEmployeeID[] = $value;
1243 $value = intval($v);
1245 $arEmployeeID[] = $value;
1250 if (isset($crmColumns[
$k]))
1252 $prefixByType = static::getUserFieldCrmTypePrefixMap();
1254 $maxPrefixLength = 3;
1255 $singleTypePrefix =
'';
1256 if (is_array($columnInfo[
$k][
'ufInfo'][
'SETTINGS']))
1258 $supportedTypes =
array();
1259 foreach ($columnInfo[
$k][
'ufInfo'][
'SETTINGS'] as
$type => $supported)
1261 if ($supported ===
'Y')
1262 $supportedTypes[
$type] =
true;
1264 $supportedTypes = array_keys($supportedTypes);
1265 if (
count($supportedTypes) === 1)
1267 if (isset($prefixByType[mb_strtolower($supportedTypes[0])]))
1268 $singleTypePrefix = $prefixByType[mb_strtolower($supportedTypes[0])];
1270 unset($supportedTypes,
$type, $supported);
1275 foreach ($v as $subv)
1277 $subv = strval($subv);
1281 if (($pos = mb_strpos(mb_substr($subv, 0, $maxPrefixLength + 1),
'_')) !==
false && $pos > 0)
1282 $prefix = mb_substr($subv, 0, $pos);
1284 $subv = $singleTypePrefix .
'_' . $subv;
1285 unset($prefix, $pos);
1287 $value = explode(
'_', trim($subv));
1288 if ($value[0] <>
'' && $value[1] <>
'')
1290 if (!(isset($arCrmID[$value[0]]) && is_array($arCrmID[$value[0]])))
1291 $arCrmID[$value[0]] =
array();
1292 $arCrmID[$value[0]][] = $value[1];
1303 if (($pos = mb_strpos(mb_substr($v, 0, $maxPrefixLength + 1),
'_')) !==
false && $pos > 0)
1304 $prefix = mb_substr($v, 0, $pos);
1306 $v = $singleTypePrefix .
'_' . $v;
1307 unset($prefix, $pos);
1309 $value = explode(
'_', trim($v));
1310 if ($value[0] <>
'' && $value[1] <>
'')
1312 if (!(isset($arCrmID[$value[0]]) && is_array($arCrmID[$value[0]])))
1313 $arCrmID[$value[0]] =
array();
1314 $arCrmID[$value[0]][] = $value[1];
1319 unset($maxPrefixLength);
1323 if (isset($crmStatusColumns[
$k]))
1325 if (!isset($arCrmStatusEntityType[
$k]))
1327 if (isset($columnInfo[
$k][
'ufInfo'][
'SETTINGS'][
'ENTITY_TYPE']))
1329 $arCrmStatusEntityType[
$k] =
1330 strval($columnInfo[
$k][
'ufInfo'][
'SETTINGS'][
'ENTITY_TYPE']);
1333 if (!empty($arCrmStatusEntityType[
$k]))
1336 foreach ($v as $subv)
1340 if (!is_array($arCrmStatusID[$arCrmStatusEntityType[
$k]]))
1341 $arCrmStatusID[$arCrmStatusEntityType[
$k]] =
array();
1342 $arCrmStatusID[$arCrmStatusEntityType[
$k]][] = $subv;
1349 if (!is_array($arCrmStatusID[$arCrmStatusEntityType[
$k]]))
1350 $arCrmStatusID[$arCrmStatusEntityType[
$k]] =
array();
1351 $arCrmStatusID[$arCrmStatusEntityType[
$k]][] = $v;
1358 if (isset($iblockElementColumns[
$k]))
1361 foreach ($v as $subv)
1363 $value = intval($subv);
1365 $arIblockElementID[] = $value;
1369 $value = intval($v);
1371 $arIblockElementID[] = $value;
1376 if (isset($iblockSectionColumns[
$k]))
1379 foreach ($v as $subv)
1381 $value = intval($subv);
1383 $arIblockSectionID[] = $value;
1387 $value = intval($v);
1389 $arIblockSectionID[] = $value;
1397 if (
count($fileColumns) > 0)
1399 if (
count($arFileID) > 0)
1400 $arFileID = array_unique($arFileID);
1405 $nIDs =
count($arFileID);
1407 $file =
new CFile();
1408 foreach ($arFileID as $fileID)
1410 $arID[$cnt++] = $fileID;
1413 if ($cnt === $stepCnt ||
$i === $nIDs)
1415 $res = $file->GetList(
array(),
array(
'@ID' => implode(
',', $arID)));
1416 if (is_object(
$res))
1418 while ($arFile =
$res->Fetch())
1422 if(array_key_exists(
"~src", $arFile))
1425 $arFile[
"SRC"] = $arFile[
"~src"];
1427 $arFile[
"SRC"] = $file->GetFileSRC($arFile,
false,
false);
1431 $arFile[
"SRC"] = $file->GetFileSRC($arFile,
false);
1434 self::$ufFiles[intval($arFile[
'ID'])] = $arFile;
1446 if (
count($diskFileColumns) > 0)
1448 if (
count($arDiskFileID) > 0)
1449 $arDiskFileID = array_unique($arDiskFileID);
1454 $nIDs =
count($arDiskFileID);
1456 foreach ($arDiskFileID as $diskFileID)
1458 $arID[$cnt++] = $diskFileID;
1461 if ($cnt === $stepCnt ||
$i === $nIDs)
1463 $res = \Bitrix\Disk\AttachedObject::getList(
array(
1464 'filter' =>
array(
'ID' => $arID),
1466 'ID',
'NAME' =>
'OBJECT.NAME',
'SIZE' =>
'OBJECT.SIZE'
1469 $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
1470 if (is_object(
$res))
1472 while ($arDiskFile =
$res->Fetch())
1476 $arDiskFile[
'DOWNLOAD_URL'] = $urlManager->getUrlUfController(
1478 array(
'attachedId' => $arDiskFile[
'ID'])
1480 self::$ufDiskFiles[intval($arDiskFile[
'ID'])] = $arDiskFile;
1492 if (
count($employeeColumns) > 0)
1494 if (
count($arEmployeeID) > 0)
1495 $arEmployeeID = array_unique($arEmployeeID);
1500 $nIDs =
count($arEmployeeID);
1502 foreach ($arEmployeeID as $employeeID)
1504 $arID[$cnt++] = $employeeID;
1507 if ($cnt === $stepCnt ||
$i === $nIDs)
1511 'filter' =>
array(
'ID' => $arID),
1512 'select' =>
array(
'ID',
'LOGIN',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'TITLE')
1515 if (is_object(
$res))
1517 while ($arUser =
$res->fetch())
1518 self::$ufEmployees[intval($arUser[
'ID'])] = $arUser;
1530 foreach ($arCrmID as $typeIndex => $arSubID)
1532 if (
count($arSubID) > 0)
1533 $arCrmID[$typeIndex] = array_unique($arSubID);
1538 $nIDs =
count($arSubID);
1540 foreach ($arSubID as $crmID)
1542 $arID[$cnt++] = $crmID;
1545 if ($cnt === $stepCnt ||
$i === $nIDs)
1547 $entityTypeName = CCrmOwnerTypeAbbr::ResolveName($typeIndex);
1548 $settings = [mb_strtoupper($entityTypeName) =>
'Y'];
1549 $selectorParams = ElementType::getDestSelectorParametersForFilter(
$settings,
true);
1550 $selectorEntityTypeOptions = ElementType::getDestSelectorOptions($selectorParams);
1553 $provider = Entities::getProviderByEntityType(key($selectorEntityTypeOptions));
1562 self::$ufCrmElements[$typeIndex .
'_' . $item[
'entityId']] = [
1563 'id' => $item[
'entityId'],
1564 'type' => $entityTypeName,
1566 'url' => $item[
'url'] ??
'',
1580 if (
count($crmStatusColumns) > 0 && CModule::IncludeModule(
'crm'))
1582 foreach ($arCrmStatusID as $entityType => $arSubID)
1584 if (
count($arSubID) > 0)
1585 $arCrmID[$entityType] = array_unique($arSubID);
1588 $res = CCrmStatus::GetStatusList($entityType);
1591 foreach ($arSubID as $crmStatusID)
1593 if (isset(
$res[$crmStatusID]))
1594 if (!isset(self::$ufCrmStatuses[$entityType]))
1595 self::$ufCrmStatuses[$entityType] =
array();
1596 self::$ufCrmStatuses[$entityType][$crmStatusID] =
$res[$crmStatusID];
1603 if (
count($iblockElementColumns) > 0 && CModule::IncludeModule(
'iblock'))
1605 if (
count($arIblockElementID) > 0)
1606 $arIblockElementID = array_unique($arIblockElementID);
1611 $nIDs =
count($arIblockElementID);
1613 foreach ($arIblockElementID as $iblockElementID)
1615 $arID[$cnt++] = $iblockElementID;
1618 if ($cnt === $stepCnt ||
$i === $nIDs)
1620 $res = CIBlockElement::GetList(
array(
'SORT'=>
'ASC'),
array(
'=ID' => $arID));
1621 if (is_object(
$res))
1623 while ($arIblockElement =
$res->GetNext())
1624 self::$ufIblockElements[intval($arIblockElement[
'ID'])] = $arIblockElement;
1634 if (
count($iblockSectionColumns) > 0 && CModule::IncludeModule(
'iblock'))
1636 if (
count($arIblockSectionID) > 0)
1637 $arIblockSectionID = array_unique($arIblockSectionID);
1642 $nIDs =
count($arIblockSectionID);
1644 foreach ($arIblockSectionID as $iblockSectionID)
1646 $arID[$cnt++] = $iblockSectionID;
1649 if ($cnt === $stepCnt ||
$i === $nIDs)
1651 $res = CIBlockSection::GetList(
1652 array(
'left_margin' =>
'asc'),
1653 array(
'ID' => $arID),
1654 false,
array(
'ID',
'NAME',
'SECTION_PAGE_URL')
1656 if (is_object(
$res))
1658 while ($arIblockSection =
$res->GetNext())
1659 self::$ufIblockSections[intval($arIblockSection[
'ID'])] = $arIblockSection;
1671 if (!is_int($value) && !is_float($value))
1673 if (is_string($value) && $value !==
'')
1675 if (is_numeric($value))
1677 $value = (float)$value;
1695 foreach (
$rows as &$row)
1697 foreach ($row as
$k => &$v)
1699 if (!array_key_exists(
$k, $columnInfo))
1704 $cInfo = $columnInfo[
$k];
1708 foreach ($v as &$subv)
1711 self::formatResultValue(
$k, $subv, $row, $cInfo, $total);
1717 self::formatResultValue(
$k, $v, $row, $cInfo, $total);
1722 unset($row, $v, $subv);
1725 public static function formatResultValue(
$k, &$v, &$row, &$cInfo, $total, &$customChartValue =
null)
1728 $field = $cInfo[
'field'];
1730 $dataType = self::getFieldDataType($field);
1734 if (isset($cInfo[
'isUF']) && $cInfo[
'isUF'])
1740 if ($isUF && $dataType ==
'float' && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1741 && !mb_strlen($cInfo[
'prcnt']))
1749 $v = static::prepareValueToRound($v);
1752 elseif ($isUF && $dataType ===
'enum' && !empty($v)
1753 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1754 && !mb_strlen($cInfo[
'prcnt']))
1758 elseif ($isUF && $dataType ===
'file' && !empty($v)
1759 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1760 && !mb_strlen($cInfo[
'prcnt']))
1763 $v = static::getUserFieldFileValue($valueKey,
$ufInfo);
1765 $customChartValue[
'exist'] =
true;
1766 $customChartValue[
'type'] =
'string';
1767 $customChartValue[
'value'] = static::getUserFieldFileValueForChart($valueKey,
$ufInfo);
1769 elseif ($isUF && $dataType ===
'disk_file' && !empty($v)
1770 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1771 && !mb_strlen($cInfo[
'prcnt']))
1774 $v = static::getUserFieldDiskFileValue($valueKey,
$ufInfo);
1776 $customChartValue[
'exist'] =
true;
1777 $customChartValue[
'type'] =
'string';
1778 $customChartValue[
'value'] = static::getUserFieldDiskFileValueForChart($valueKey,
$ufInfo);
1780 elseif ($isUF && $dataType ===
'employee' && !empty($v)
1781 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1782 && !mb_strlen($cInfo[
'prcnt']))
1785 $v = static::getUserFieldEmployeeValue($valueKey,
$ufInfo);
1787 $customChartValue[
'exist'] =
true;
1788 $customChartValue[
'type'] =
'string';
1789 $customChartValue[
'value'] = static::getUserFieldEmployeeValueForChart($valueKey,
$ufInfo);
1791 elseif ($isUF && $dataType ===
'crm' && !empty($v)
1792 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1793 && !mb_strlen($cInfo[
'prcnt']))
1796 $v = static::getUserFieldCrmValue($valueKey,
$ufInfo);
1798 $customChartValue[
'exist'] =
true;
1799 $customChartValue[
'type'] =
'string';
1800 $customChartValue[
'value'] = static::getUserFieldCrmValueForChart($valueKey,
$ufInfo);
1802 elseif ($isUF && $dataType ===
'crm_status' && !empty($v)
1803 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1804 && !mb_strlen($cInfo[
'prcnt']))
1807 $v = static::getUserFieldCrmStatusValue($valueKey,
$ufInfo);
1809 elseif ($isUF && $dataType ===
'iblock_element' && !empty($v)
1810 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1811 && !mb_strlen($cInfo[
'prcnt']))
1814 $v = static::getUserFieldIblockElementValue($valueKey,
$ufInfo);
1816 $customChartValue[
'exist'] =
true;
1817 $customChartValue[
'type'] =
'string';
1818 $customChartValue[
'value'] = static::getUserFieldIblockElementValueForChart($valueKey,
$ufInfo);
1820 elseif ($isUF && $dataType ===
'iblock_section' && !empty($v)
1821 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1822 && !mb_strlen($cInfo[
'prcnt']))
1825 $v = static::getUserFieldIblockSectionValue($valueKey,
$ufInfo);
1827 $customChartValue[
'exist'] =
true;
1828 $customChartValue[
'type'] =
'string';
1829 $customChartValue[
'value'] = static::getUserFieldIblockSectionValueForChart($valueKey,
$ufInfo);
1831 elseif ($isUF && $dataType ===
'money' && !empty($v)
1832 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1833 && !mb_strlen($cInfo[
'prcnt']))
1836 $v = static::getUserFieldMoneyValue($valueKey,
$ufInfo);
1838 $customChartValue[
'exist'] =
true;
1839 $customChartValue[
'type'] =
'string';
1840 $customChartValue[
'value'] = static::getUserFieldMoneyValueForChart($valueKey,
$ufInfo);
1842 elseif ($dataType ==
'datetime' && !empty($v)
1843 && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] !==
'COUNT_DISTINCT')
1844 && !mb_strlen($cInfo[
'prcnt'])
1847 $v = ($v instanceof \Bitrix\Main\Type\DateTime || $v instanceof \Bitrix\Main\Type\Date) ?
ConvertTimeStamp($v->getTimestamp(),
'SHORT') :
'';
1849 elseif ($dataType ==
'float' && !empty($v) && !$isUF && !mb_strlen($cInfo[
'prcnt']))
1851 $v = static::prepareValueToRound($v);
1854 elseif (mb_substr(
$k, -11) ==
'_SHORT_NAME' && (empty($cInfo[
'aggr']) || $cInfo[
'aggr'] ==
'GROUP_CONCAT'))
1857 array(
'#NOBR#',
'#/NOBR#'),
1858 array(
'<NOBR>',
'</NOBR>'),
1861 elseif (mb_substr(
$k, -6) ==
'_PRCNT' && !mb_strlen($cInfo[
'prcnt']))
1863 $v = static::prepareValueToRound($v);
1864 $v = round($v, 2).
'%';
1866 elseif ($dataType ==
'boolean' && empty($cInfo[
'aggr']))
1868 if ($isUF && empty($v))
1875 $boolValues = ($isUF?
array(0, 1) : $field->GetValues());
1876 $fValues = array_flip($boolValues);
1877 $fValue = (bool)$fValues[$v];
1879 $mess =
'REPORT_BOOLEAN_VALUE_'.($fValue?
'TRUE' :
'FALSE');
1883 elseif($cInfo[
'prcnt'] <>
'')
1885 if($cInfo[
'prcnt'] ==
'self_column')
1887 if(array_key_exists(
'TOTAL_'.
$k, $total) && $total[
'TOTAL_'.
$k] > 0)
1889 $v = round($v / $total[
'TOTAL_'.
$k] * 100, 2);
1898 $v = static::prepareValueToRound($v);
1912 foreach ($total as
$k => $v)
1915 $original_k = mb_substr(
$k, 6);
1917 $cInfo = $columnInfo[$original_k];
1918 $field = $cInfo[
'field'];
1920 $dataType = self::getFieldDataType($field);
1924 if (isset($cInfo[
'isUF']) && $cInfo[
'isUF'])
1930 if ($field->getName() ==
'ID' && empty($cInfo[
'aggr']) && $cInfo[
'prcnt'] ==
'')
1934 elseif($cInfo[
'prcnt'] <>
'')
1936 if($cInfo[
'prcnt'] ==
'self_column')
1938 if(array_key_exists(
$k, $total) && $v > 0)
1940 $v = round($v / $total[
$k] * 100, 2);
1949 $v = static::prepareValueToRound($v);
1953 $total[
$k] = $v.
'%';
1955 elseif (mb_substr(
$k, -6) ==
'_PRCNT' && !mb_strlen($cInfo[
'prcnt']))
1957 $v = static::prepareValueToRound($v);
1958 $total[
$k] = round($v, 2).
'%';
1960 elseif ($isUF && $dataType ==
'float')
1968 $v = static::prepareValueToRound($v);
2003 if (self::$userNameFormat ===
null)
2006 self::$userNameFormat =
$site->GetNameFormat(
false);
2009 return self::$userNameFormat;
2015 $searchInputId = strval($searchInputId);
2016 $dataInputId = strval($dataInputId);
2031 $delay = intval($delay);
2037 echo
'<input type="text" id="',
htmlspecialcharsbx($searchInputId) ,
'" style="width:200px;">',
2042 'BX.ready(function(){',
2043 'BX.ReportUserSearchPopup.deletePopup("', $id,
'");',
2044 'BX.ReportUserSearchPopup.create("', $id,
'", { searchInput: BX("',
2045 CUtil::jSEscape($searchInputId),
'"), dataInput: BX("',
2046 CUtil::jSEscape($dataInputId),
'"), componentName: "',
2050 $GLOBALS[
'APPLICATION']->includeComponent(
2051 'bitrix:intranet.user.selector.new',
2056 'INPUT_NAME' => $searchInputId,
2057 'SHOW_EXTRANET_USERS' =>
'NONE',
2061 'ON_CHANGE' =>
'reports.onResponsiblesChange',
2064 array(
'HIDE_ICONS' =>
'Y')
if(!Loader::includeModule('messageservice')) $provider
static includeModule($moduleName)
static getList(array $parameters=array())
static renderUserSearch($id, $searchInputId, $dataInputId, $componentName, $siteId='', $nameFormat='', $delay=0)
static getUserFieldCrmValue($valueKey, $ufInfo)
static confirmFilterBackReferenceRewrite($fElem, $chain)
static getDefaultReports()
static getUserFieldCrmStatusValue($valueKey, $ufInfo)
const UF_DATETIME_SHORT_POSTFIX
static buildSelectTreePopupElelemnt($humanTitle, $fullHumanTitle, $fieldDefinition, $fieldType, $ufInfo=array())
static & getUFEnumerations($usedUFMap=null)
const UF_TEXT_TRIM_POSTFIX
static getUserFieldMoneyValue($valueKey, $ufInfo)
static getUserFieldCrmTypePrefixMap()
static getUserFieldMoneyValueForChart($valueKey, $ufInfo)
static beforeFilterBackReferenceRewrite(&$filter, $viewColumns)
static getCurrentVersion()
static getUserFieldDiskFileValueForChart($valueKey, $ufInfo)
static getCompareVariations()
static getCustomSelectFields($select, $fList)
static getUserFieldEnumerationValue($valueKey, $ufInfo)
static getUserFieldFileValueForChart($valueKey, $ufInfo)
static prepareUFEnumerations($usedUFMap=null)
static confirmSelectBackReferenceRewrite($elem, $chain)
static getUserNameFormat()
static getUserFieldEmployeeValueForChart($valueKey, $ufInfo)
static beforeViewDataQuery(&$select, &$filter, &$group, &$order, &$limit, &$options, &$runtime=null)
static fillFilterReferenceColumn(&$filterElement, Entity\ReferenceField $field)
static collectUFValues($rows, $columnInfo, $total)
static setRuntimeFields(\Bitrix\Main\Entity\Base $entity, $sqlTimeInterval)
static getFiltrableColumnGroups()
static buildHTMLSelectTreePopup($tree, $withReferencesChoose=false, $level=0)
static prepareValueToRound($value)
static getDefaultElemHref($elem, $fList)
static fillFilterReferenceColumns(&$filters, &$fieldList)
static getUserFieldIblockSectionValue($valueKey, $ufInfo)
static getCustomColumnTypes()
static getAlternatePhrasesOfColumns()
static getUserFieldFileValue($valueKey, $ufInfo)
const UF_MONEY_CURRENCY_POSTFIX
static getUserFieldDataType($arUF)
static formatResults(&$rows, &$columnInfo, $total)
static setUserNameFormat($userNameFormat)
static getUserFieldIblockSectionValueForChart($valueKey, $ufInfo)
static getUserFieldCrmValueForChart($valueKey, $ufInfo)
const UF_MONEY_NUMBER_POSTFIX
static getPeriodFilter($date_from, $date_to)
static getUserFieldDiskFileValue($valueKey, $ufInfo)
static formatResultsTotal(&$total, &$columnInfo, &$customChartTotal=null)
static detectUserField($field)
static rewriteResultRowValues(&$row, &$columnInfo)
static getUserFieldEmployeeValue($valueKey, $ufInfo)
static getDefaultColumns()
static getUserFieldIblockElementValue($valueKey, $ufInfo)
static getUserFieldIblockElementValueForChart($valueKey, $ufInfo)
static fillFilterUFColumns(&$filters, &$fieldList)
static getEntityFilterPrimaryFieldName($fElem)
static fillFilterUFColumn(&$filterElement, $field, $ufInfo)
static getCalcVariations()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
htmlspecialcharsback($str)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
ConvertTimeStamp($timestamp=false, $type="SHORT", $site=false, $bSearchInSitesOnly=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
$GLOBALS['_____370096793']