...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/widget/data/activity/activitydynamic.php
- Класс: Bitrix\Crm\Widget\Data\Activity\ActivityDynamic
- Вызов: ActivityDynamic::parseTemplate
static function parseTemplate(array $groupItems, array $items, array $results) { if (!(is_array($groupItems) && !empty($groupItems) && is_array($items) && !empty($items))) { Loc::getMessage("CRM_ACTIVITY_DYNAMIC_CHANNELS_ARE_NOT_FOUND"); } $mess = self::includeModuleFile(); $maxCounter = array( \CCrmActivityDirection::Incoming => 0, \CCrmActivityDirection::Outgoing => 0 ); foreach ($results as $res) { $value = (int)$res["COUNT"]; if (array_key_exists($res["CHANNEL_ID"], $items)) { $item = &$items[$res["CHANNEL_ID"]]; $direction = ((int)$res["DIRECTION"] == \CCrmActivityDirection::Outgoing ? \CCrmActivityDirection::Outgoing : \CCrmActivityDirection::Incoming); $item["COUNTERS"][$direction] += $value; $groupID = $item["GROUP_ID"]; if ($groupID !== '' && isset($groupItems[$groupID])) { $groupItems[$groupID]["COUNTERS"][$direction] += $item["COUNTERS"][$direction]; $groupItems[$groupID]["MAX_COUNTER"][$direction] = max($groupItems[$groupID]["MAX_COUNTER"][$direction], $item["COUNTERS"][$direction]); $maxCounter[$direction] = max($maxCounter[$direction], $groupItems[$groupID]["COUNTERS"][$direction]); $parentId = $groupItems[$groupID]["PARENT_ID"]; if ($parentId && isset($groupItems[$parentId])) { $groupItems[$parentId]["COUNTERS"][$direction] += $item["COUNTERS"][$direction]; $groupItems[$parentId]["MAX_COUNTER"][$direction] = max($groupItems[$parentId]["MAX_COUNTER"][$direction], $item["COUNTERS"][$direction]); $maxCounter[$direction] = max($maxCounter[$direction], $groupItems[$parentId]["COUNTERS"][$direction]); } } } } unset($item); $activities = array("active" => "", "inactive" => ""); $inactiveItems = array(); $inactiveItemCaptions = array(); $activeCount = 0; $telephonyIsChecked = false; foreach($activities as $status => &$html) { if ($item = reset($items)) { $groupStack = array(); $innerHTML = array(); $currentGroupID = ''; do { $groupID = $item['GROUP_ID']; $group = isset($groupItems[$groupID]) ? $groupItems[$groupID] : null; if ($status === "active" && ($groupID === '' || is_null($group) || isset($group['IS_IN_USE']) && !$group['IS_IN_USE'] || isset($item['IS_IN_USE']) && !$item['IS_IN_USE'])) { if (isset($item['IS_CONFIGURABLE']) && $item['IS_CONFIGURABLE']) { $inactiveItems[] = $item; if ($groupID !== \Bitrix\Crm\Integration\Channel\VoxImplantTracker::GROUP_ID) { $inactiveItemCaptions[] = $item["CAPTION"]; } else if ($telephonyIsChecked === false) { $telephonyIsChecked = true; $inactiveItemCaptions[] = $group["CAPTION"]; } } continue; } $activeCount++; if ($groupID !== $currentGroupID) { $innerHTML["#" . $groupID . "#"] = ""; $parent = ($group === null ? null : $group["PARENT_ID"]); $parentGroup = isset($groupItems[$parent]) ? $groupItems[$parent] : null; if (is_null($group) || ($status === "active" && ($parentGroup === null || $parentGroup["ID"] != ChannelType::IMOPENLINE_NAME) && $group['ACTIVE_ITEMS_COUNT'] <= 1)) { if (!is_null($group)) $group["hidden"] = "Y"; $html .= "#" . $groupID . "#"; } else { $groups = array(); reset($groupStack); while ($parentGroup !== null) { if ($parentGroup && ( $status !== "active" || $parentGroup["ID"] != ChannelType::IMOPENLINE_NAME || $parentGroup["ITEMS_COUNT"] > $group["ITEMS_COUNT"]) ) { $groups[] = array( "id" => $parentGroup['ID'], "url" => $parentGroup['IS_CONFIGURABLE'] ? $parentGroup['URL'] : '', "caption" => $parentGroup['CAPTION'], "counters" => $parentGroup["COUNTERS"]); $groupStack[] = $parent; $parent = $parentGroup["PARENT_ID"]; } else { $parent = null; } $parentGroup = isset($groupItems[$parent]) ? $groupItems[$parent] : null; } $groups = array_reverse($groups); $groups[] = array( "id" => $group['ID'], "caption" => $group['CAPTION'], "url" => $group['IS_CONFIGURABLE'] ? $group['URL'] : '', "counters" => $group["COUNTERS"]); $g = reset($groups); $lastGroupID = null; do { $id = "#{$g["id"]}#"; $caption = htmlspecialcharsbx($g["caption"]); $caption = ($g["url"] !== '' ? '' . $caption . '' : '' . $caption . ''); if (mb_strpos($html, $id) === false) { if ($status !== "active") { $g["counters"][\CCrmActivityDirection::Incoming] = 0; $g["counters"][\CCrmActivityDirection::Outgoing] = 0; } $g["percentage"][\CCrmActivityDirection::Incoming] = 0; if ($maxCounter[\CCrmActivityDirection::Incoming] > 0) $g["percentage"][\CCrmActivityDirection::Incoming] = intval($g["counters"][\CCrmActivityDirection::Incoming] * 100 / $maxCounter[\CCrmActivityDirection::Incoming]); $g["percentage"][\CCrmActivityDirection::Incoming] = max($g["percentage"][\CCrmActivityDirection::Incoming], 1); $g["percentage"][\CCrmActivityDirection::Outgoing] = 0; if ($maxCounter[\CCrmActivityDirection::Outgoing] > 0) $g["percentage"][\CCrmActivityDirection::Outgoing] = intval($g["counters"][\CCrmActivityDirection::Outgoing] * 100/ $maxCounter[\CCrmActivityDirection::Outgoing]); $g["percentage"][\CCrmActivityDirection::Outgoing] = max($g["percentage"][\CCrmActivityDirection::Outgoing], 1); $htmlG = <<