22 !isset($params[
'groupIdList'], $params[
'counterData'])
23 || !is_array($params[
'groupIdList'])
24 || !is_array($params[
'counterData'])
30 $counterData = $params[
'counterData'];
32 $groupIdList = Util::filterNumericIdList($params[
'groupIdList']);
33 if (empty($groupIdList))
39 if (isset($params[
'scrumIdList']))
41 $scrumIdList = Util::filterNumericIdList($params[
'scrumIdList']);
44 $currentUserId = static::getCurrentUserId();
45 if ($currentUserId <= 0)
50 $mode = ($params[
'mode'] ?? WorkgroupList::MODE_COMMON);
51 $groupUrlTemplate = ($params[
'groupUrl'] ?? Helper\Path::get(
'group_path_template'));
53 if (in_array($mode, WorkgroupList::getTasksModeList(),
true))
55 $result = static::fillTasksCounters([
56 'counterData' => $counterData,
58 'groupUrl' => $groupUrlTemplate,
59 'groupIdList' => $groupIdList,
60 'scrumIdList' => $scrumIdList,
65 $result = static::fillCommonCounters([
66 'counterData' => $counterData,
67 'groupUrl' =>
Helper\Path::get(
'group_livefeed_path_template'),
68 'groupIdList' => $groupIdList,
69 'scrumIdList' => $scrumIdList,
70 'livefeedCounterSliderOptions' => $params[
'livefeedCounterSliderOptions'],
79 static $tasksCounterCache = [];
83 $mode = ($params[
'mode'] ?? WorkgroupList::MODE_COMMON);
85 $groupIdList = $params[
'groupIdList'] ?? [];
86 if (empty($groupIdList))
91 $scrumIdList = $params[
'scrumIdList'] ?? [];
93 $currentUserId = static::getCurrentUserId();
94 if ($currentUserId <= 0)
101 if (in_array($mode, WorkgroupList::getTasksModeList(),
true))
104 $mode === WorkgroupList::MODE_TASKS_SCRUM
105 ?
new ScrumCounter($currentUserId)
106 :
new ProjectCounter($currentUserId)
109 foreach ($groupIdList as $groupId)
111 $counterData = $projectCounter->getRowCounter($groupId);
113 $result[$groupId] = [
115 'VALUE' => $counterData[
'VALUE'],
116 'COLOR' => $counterData[
'COLOR'],
123 $counters = \CUserCounter::getValues($currentUserId);
124 if (!isset($tasksCounterCache[$currentUserId]))
126 $tasksCounterCache[$currentUserId] = TasksCounter::getInstance($currentUserId);
129 $tasksCounter = $tasksCounterCache[$currentUserId];
131 foreach ($groupIdList as $groupId)
133 $counterKey = \CUserCounter::LIVEFEED_CODE .
'SG' . $groupId;
135 $result[$groupId] = [
137 'VALUE' => (int)($counters[$counterKey] ?? 0),
141 if ($tasksModuleInstalled)
143 $result[$groupId][
'tasks_expired'] = [
145 in_array($groupId, $scrumIdList,
true)
147 : $tasksCounter->get(
TasksCounter\CounterDictionary::COUNTER_EXPIRED, $groupId)
151 $result[$groupId][
'tasks_new_comments'] = [
152 'VALUE' => $tasksCounter->get(
TasksCounter\CounterDictionary::COUNTER_NEW_COMMENTS, $groupId),
165 $groupIdList = $params[
'groupIdList'] ?? [];
166 if (empty($groupIdList))
171 $currentUserId = static::getCurrentUserId();
172 if ($currentUserId <= 0)
177 $counterData = $params[
'counterData'] ?? [];
179 $scrumIdList = $params[
'scrumIdList'] ?? [];
181 $groupUrlTemplate = ($params[
'groupUrl'] ?? Helper\Path::get(
'group_path_template'));
184 Helper\UI\Grid\CounterStyle::STYLE_GRAY => Grid\Counter\Color::GRAY,
185 Helper\UI\Grid\CounterStyle::STYLE_GREEN => Grid\Counter\Color::SUCCESS,
186 Helper\UI\Grid\CounterStyle::STYLE_RED => Grid\Counter\Color::DANGER,
189 $sliderOptionsData = [
190 'contentClassName' =>
'bitrix24-group-slider-content',
191 'loader' =>
'intranet:slider-tasklist',
192 'cacheable' =>
false,
193 'customLeftBoundary' => 0,
194 'newWindowLabel' =>
true,
195 'copyLinkLabel' =>
true,
198 foreach ($groupIdList as $groupId)
200 $groupCounterData = ($counterData[$groupId] ?? []);
202 $groupUrl = str_replace([
'#id#',
'#ID#',
'#GROUP_ID#',
'#group_id#' ], $groupId, $groupUrlTemplate);
204 if (in_array($groupId, $scrumIdList,
true))
206 $sliderOptionsData[
'loader'] =
'intranet:scrum';
211 $result[$groupId] = [
213 'type' => Grid\Counter\Type::LEFT_ALIGNED,
214 'color' => $colorMap[$groupCounterData[
'all'][
'COLOR']],
215 'value' => $groupCounterData[
'all'][
'VALUE'],
217 'click' =>
"BX.SidePanel.Instance.open.bind(BX.SidePanel.Instance, '{$groupUrl}', {$sliderOptions})",
219 'class' =>
'sonet-ui-grid-counter',
231 $groupIdList = $params[
'groupIdList'] ?? [];
232 if (empty($groupIdList))
237 $counterData = $params[
'counterData'] ?? [];
239 $scrumIdList = $params[
'scrumIdList'] ?? [];
241 $groupUrlTemplate = ($params[
'groupUrl'] ?? Helper\Path::get(
'group_livefeed_path_template'));
242 $sliderOptionsData = ($params[
'sliderOptions'] ?? static::getLivefeedCounterSliderOptions());
246 foreach ($groupIdList as $groupId)
248 $groupCounterData = ($counterData[$groupId] ?? []);
250 $livefeedCounterValue = (int)($groupCounterData[
'livefeed'][
'VALUE'] ?? 0);
251 $tasksCounterValue = (
252 $tasksModuleInstalled
253 ? (int)($groupCounterData[
'tasks_expired'][
'VALUE'] ?? 0)
254 + (int)($groupCounterData[
'tasks_new_comments'][
'VALUE'] ?? 0)
258 $groupUrl = str_replace([
'#id#',
'#ID#',
'#GROUP_ID#',
'#group_id#' ], $groupId, $groupUrlTemplate);
260 if (in_array($groupId, $scrumIdList,
true))
262 $sliderOptionsData[
'loader'] =
'intranet:scrum';
267 $result[$groupId] = [
268 static::getLivefeedCounterColumnId() => [
269 'type' => Grid\Counter\Type::RIGHT,
270 'color' => Grid\Counter\Color::DANGER,
271 'value' => $livefeedCounterValue + $tasksCounterValue,
273 'click' =>
"BX.SidePanel.Instance.open.bind(BX.SidePanel.Instance, '{$groupUrl}', {$sliderOptions})",
275 'class' =>
'sonet-ui-grid-counter',