58 $this->fieldsList = ($params[
'fieldsList'] ?? []);
59 $this->gridFilter = ($params[
'gridFilter'] ?? []);
60 $this->currentUserId = (int)($params[
'currentUserId'] ?? 0);
61 $this->contextUserId = (int)($params[
'contextUserId'] ?? 0);
62 $this->mode = (string)($params[
'mode'] ??
'');
63 $this->query = $query;
64 $this->hasAccessToTasksCounters = (boolean)($params[
'hasAccessToTasksCounters'] ??
false);
72 '=SITE.SITE_ID' => SITE_ID,
75 if ($this->query ===
null)
81 !empty($this->gridFilter[
'EXTRANET'])
82 && $this->gridFilter[
'EXTRANET'] ===
'Y'
86 $this->query->registerRuntimeField(
89 WorkgroupSiteTable::class,
90 Join::on(
'this.ID',
'ref.GROUP_ID')->where(
'ref.SITE_ID', static::getExtranetSiteId()),
91 [
'join_type' =>
'INNER']
97 !empty($this->gridFilter[
'FAVORITES'])
98 && $this->gridFilter[
'FAVORITES'] ===
'Y'
99 && $this->currentUserId > 0
102 $filter[
'=FAVORITES.USER_ID'] = $this->currentUserId;
105 if ($this->runtimeFieldsManager->has(
'SCRUM'))
109 $filter[
'=PROJECT'] =
'Y';
110 $filter[
'=SCRUM'] =
'Y';
114 $filter[
'=SCRUM'] =
'N';
118 $this->initFilterFieldsData();
127 if ($this->hasAccessToTasksCounters)
387 !in_array($gridFilterField, [
'COUNTERS',
'COMMON_COUNTERS' ],
true)
388 || empty($this->gridFilter[$gridFilterField])
389 || !Loader::includeModule(
'tasks')
395 $this->query->setDistinct(
true);
397 $this->query->registerRuntimeField(
401 Join::on(
'this.ID',
'ref.GROUP_ID')->where(
'ref.USER_ID', $this->contextUserId),
402 [
'join_type' =>
'INNER']
405 $this->runtimeFieldsManager->add(
'TASKS_COUNTER');
407 if ($gridFilterField ===
'COUNTERS')
411 'INCLUDE' => TasksCounter\CounterDictionary::MAP_EXPIRED,
415 'INCLUDE' => TasksCounter\CounterDictionary::MAP_COMMENTS,
418 'PROJECT_EXPIRED' => [
419 'INCLUDE' => array_merge(
420 [
TasksCounter\CounterDictionary::COUNTER_GROUP_EXPIRED ],
423 'EXCLUDE' => TasksCounter\CounterDictionary::MAP_EXPIRED,
425 'PROJECT_NEW_COMMENTS' => [
426 'INCLUDE' => array_merge(
427 [
TasksCounter\CounterDictionary::COUNTER_GROUP_COMMENTS ],
430 'EXCLUDE' => TasksCounter\CounterDictionary::MAP_COMMENTS,
433 $type = $typesMap[$this->gridFilter[$gridFilterField]];
435 elseif ($gridFilterField ===
'COMMON_COUNTERS')
438 'INCLUDE' => array_merge(
439 array_values(
TasksCounter\CounterDictionary::MAP_EXPIRED),
440 array_values(
TasksCounter\CounterDictionary::MAP_COMMENTS),
446 $filter[
'INCLUDED_COUNTER'] = $type[
'INCLUDE'];
448 if ($type[
'EXCLUDE'])
450 $this->query->registerRuntimeField(
451 'EXCLUDED_COUNTER_EXISTS',
453 'EXCLUDED_COUNTER_EXISTS',
460 AND USER_ID = " . $this->contextUserId .
"
461 AND TYPE IN ('" . implode(
"','", $type[
'EXCLUDE']) .
"')
464 [
'ID',
'TASKS_COUNTER.TASK_ID' ]
467 $this->runtimeFieldsManager->add(
'EXCLUDED_COUNTER_EXISTS');
517 $filterFieldName = ($params[
'FILTER_FIELD_NAME'] ??
'');
518 $value = ($params[
'VALUE'] ??
'');
521 $filterFieldName ===
''
529 isset($params[
'FIELD_NAME'])
530 && $params[
'FIELD_NAME'] !==
''
531 ? $params[
'FIELD_NAME']
534 $operation = ($params[
'OPERATION'] ??
'=');
536 if (in_array($fieldName, $this->fieldsList,
true))
538 $filter[$operation . $fieldName] = $value;
546 $filterFieldName = ($params[
'FILTER_FIELD_NAME'] ??
'');
547 $value = ($params[
'VALUE'] ??
'');
549 if ($filterFieldName ===
'')
555 && trim($value,
'%') ===
''
563 && empty(array_filter($value,
static function ($item) {
564 return trim($item,
'%') !==
'';
572 isset($params[
'FIELD_NAME'])
573 && $params[
'FIELD_NAME'] !==
''
574 ? $params[
'FIELD_NAME']
577 $operation = ($params[
'OPERATION'] ??
'%=');
579 if (in_array($fieldName, $this->fieldsList,
true))
581 $filter[$operation . $fieldName] = $value;
589 $filterFieldName = ($params[
'FILTER_FIELD_NAME'] ??
'');
590 $valueFrom = ($params[
'VALUE_FROM'] ??
'');
591 $valueTo = ($params[
'VALUE_TO'] ??
'');
594 $filterFieldName ===
''
605 isset($params[
'FIELD_NAME'])
606 && $params[
'FIELD_NAME'] !==
''
607 ? $params[
'FIELD_NAME']
611 if (in_array($fieldName, $this->fieldsList,
true))
613 if ($valueFrom !==
'')
615 $filter[
'>=' . $fieldName] = $valueFrom;
619 $filter[
'<=' . $fieldName] = $valueTo;