private function getFilterRaw(): array
{
$filter = [];
$fields = $this->getAvailableFields();
$isScrumProject = $this->isScrumProject();
if (in_array('CREATED_BY', $fields))
{
$filter['CREATED_BY'] = [
'id' => 'CREATED_BY',
'name' => Loc::getMessage('TASKS_HELPER_FLT_CREATED_BY'),
'type' => 'dest_selector',
'params' => [
'apiVersion' => '3',
'context' => 'TASKS_FILTER_CREATED_BY',
'multiple' => 'Y',
'contextCode' => 'U',
'enableAll' => 'N',
'enableSonetgroups' => 'N',
'allowEmailInvitation' => 'N',
'allowSearchEmailUsers' => 'Y',
'departmentSelectDisable' => 'Y',
'isNumeric' => 'Y',
'prefix' => 'U',
],
];
}
if (in_array('RESPONSIBLE_ID', $fields))
{
$filter['RESPONSIBLE_ID'] = [
'id' => 'RESPONSIBLE_ID',
'name' => Loc::getMessage('TASKS_HELPER_FLT_RESPONSIBLE_ID'),
'type' => 'dest_selector',
'params' => [
'apiVersion' => '3',
'context' => 'TASKS_FILTER_RESPONSIBLE_ID',
'multiple' => 'Y',
'contextCode' => 'U',
'enableAll' => 'N',
'enableSonetgroups' => 'N',
'allowEmailInvitation' => 'N',
'allowSearchEmailUsers' => 'Y',
'departmentSelectDisable' => 'Y',
'isNumeric' => 'Y',
'prefix' => 'U',
],
'default' => $isScrumProject,
];
}
if (in_array('STATUS', $fields))
{
$statusItems = [
Status::PENDING => Loc::getMessage('TASKS_STATUS_2'),
Status::IN_PROGRESS => Loc::getMessage('TASKS_STATUS_3'),
Status::SUPPOSEDLY_COMPLETED => Loc::getMessage('TASKS_STATUS_4'),
Status::COMPLETED => Loc::getMessage('TASKS_STATUS_5'),
Status::DEFERRED => Loc::getMessage('TASKS_STATUS_6'),
EntityForm::STATE_COMPLETED_IN_ACTIVE_SPRINT => Loc::getMessage('TASKS_STATUS_8'),
];
$filter['STATUS'] = [
'id' => 'STATUS',
'name' => Loc::getMessage('TASKS_FILTER_STATUS'),
'type' => 'list',
'params' => ['multiple' => 'Y'],
'items' => $statusItems,
'default' => $isScrumProject,
];
}
if (in_array('DEADLINE', $fields))
{
$filter['DEADLINE'] = [
'id' => 'DEADLINE',
'name' => Loc::getMessage('TASKS_FILTER_DEADLINE'),
'type' => 'date',
];
}
if (in_array('GROUP_ID', $fields))
{
$filter['GROUP_ID'] = [
'id' => 'GROUP_ID',
'name' => Loc::getMessage('TASKS_HELPER_FLT_GROUP'),
'type' => 'dest_selector',
'params' => [
'context' => 'TASKS_FILTER_GROUP_ID',
'multiple' => 'Y',
'contextCode' => 'SG',
'enableUsers' => 'N',
'enableSonetgroups' => 'Y',
'enableDepartments' => 'N',
'departmentSelectDisable' => 'Y',
'allowAddSocNetGroup' => 'N',
'isNumeric' => 'Y',
'prefix' => 'SG',
],
];
}
if (in_array('PROBLEM', $fields))
{
$filter['PROBLEM'] = [
'id' => 'PROBLEM',
'name' => Loc::getMessage('TASKS_FILTER_PROBLEM'),
'type' => 'list',
'items' => ($isScrumProject ? $this->getAllowedTaskScrumCategories() : $this->getAllowedTaskCategories()),
];
}
if (in_array('PARAMS', $fields))
{
$filter['PARAMS'] = [
'id' => 'PARAMS',
'name' => Loc::getMessage('TASKS_FILTER_PARAMS'),
'type' => 'list',
'params' => ['multiple' => 'Y'],
'items' => [
'MARKED' => Loc::getMessage('TASKS_FILTER_PARAMS_MARKED'),
'IN_REPORT' => Loc::getMessage('TASKS_FILTER_PARAMS_IN_REPORT'),
'OVERDUED' => Loc::getMessage('TASKS_FILTER_PARAMS_OVERDUED'),
'FAVORITE' => Loc::getMessage('TASKS_FILTER_PARAMS_FAVORITE'),
'ANY_TASK' => Loc::getMessage('TASKS_FILTER_PARAMS_ANY_TASK'),
],
];
}
if (in_array('ID', $fields))
{
$filter['ID'] = [
'id' => 'ID',
'name' => Loc::getMessage('TASKS_FILTER_ID'),
'type' => 'number',
];
}
if (in_array('TITLE', $fields))
{
$filter['TITLE'] = [
'id' => 'TITLE',
'name' => Loc::getMessage('TASKS_FILTER_TITLE'),
'type' => 'string',
];
}
if (in_array('PRIORITY', $fields))
{
$filter['PRIORITY'] = [
'id' => 'PRIORITY',
'name' => Loc::getMessage('TASKS_PRIORITY'),
'type' => 'list',
'items' => [
1 => Loc::getMessage('TASKS_PRIORITY_1'),
2 => Loc::getMessage('TASKS_PRIORITY_2'),
],
];
}
if (in_array('MARK', $fields))
{
$filter['MARK'] = [
'id' => 'MARK',
'name' => Loc::getMessage('TASKS_FILTER_MARK_MSGVER_1'),
'type' => 'list',
'items' => [
'P' => Loc::getMessage('TASKS_MARK_P'),
'N' => Loc::getMessage('TASKS_MARK_N'),
],
];
}
if (in_array('ALLOW_TIME_TRACKING', $fields))
{
$filter['ALLOW_TIME_TRACKING'] = [
'id' => 'ALLOW_TIME_TRACKING',
'name' => Loc::getMessage('TASKS_FILTER_ALLOW_TIME_TRACKING'),
'type' => 'list',
'items' => [
'Y' => Loc::getMessage('TASKS_ALLOW_TIME_TRACKING_Y'),
'N' => Loc::getMessage('TASKS_ALLOW_TIME_TRACKING_N'),
],
];
}
if (in_array('CREATED_DATE', $fields))
{
$filter['CREATED_DATE'] = [
'id' => 'CREATED_DATE',
'name' => Loc::getMessage('TASKS_FILTER_CREATED_DATE'),
'type' => 'date',
];
}
if (in_array('CLOSED_DATE', $fields))
{
$filter['CLOSED_DATE'] = [
'id' => 'CLOSED_DATE',
'name' => Loc::getMessage('TASKS_FILTER_CLOSED_DATE'),
'type' => 'date',
];
}
if (in_array('DATE_START', $fields))
{
$filter['DATE_START'] = [
'id' => 'DATE_START',
'name' => Loc::getMessage('TASKS_FILTER_DATE_START'),
'type' => 'date',
];
}
if (in_array('START_DATE_PLAN', $fields))
{
$filter['START_DATE_PLAN'] = [
'id' => 'START_DATE_PLAN',
'name' => Loc::getMessage('TASKS_FILTER_START_DATE_PLAN'),
'type' => 'date',
];
}
if (in_array('END_DATE_PLAN', $fields))
{
$filter['END_DATE_PLAN'] = [
'id' => 'END_DATE_PLAN',
'name' => Loc::getMessage('TASKS_FILTER_END_DATE_PLAN'),
'type' => 'date',
];
}
if (in_array('ACTIVE', $fields))
{
$filter['ACTIVE'] = [
'id' => 'ACTIVE',
'name' => Loc::getMessage('TASKS_FILTER_ACTIVE'),
'type' => 'date',
];
}
if (in_array('ACCOMPLICE', $fields))
{
$filter['ACCOMPLICE'] = [
'id' => 'ACCOMPLICE',
'name' => Loc::getMessage('TASKS_HELPER_FLT_ACCOMPLICES'),
'type' => 'dest_selector',
'params' => [
'apiVersion' => '3',
'context' => 'TASKS_FILTER_ACCOMPLICE',
'multiple' => 'Y',
'contextCode' => 'U',
'enableAll' => 'N',
'enableSonetgroups' => 'N',
'allowEmailInvitation' => 'N',
'allowSearchEmailUsers' => 'Y',
'departmentSelectDisable' => 'Y',
'isNumeric' => 'Y',
'prefix' => 'U',
],
];
}
if (in_array('AUDITOR', $fields))
{
$filter['AUDITOR'] = [
'id' => 'AUDITOR',
'name' => Loc::getMessage('TASKS_HELPER_FLT_AUDITOR'),
'type' => 'dest_selector',
'params' => [
'apiVersion' => '3',
'context' => 'TASKS_FILTER_AUDITOR',
'multiple' => 'Y',
'contextCode' => 'U',
'enableAll' => 'N',
'enableSonetgroups' => 'N',
'allowEmailInvitation' => 'N',
'allowSearchEmailUsers' => 'Y',
'departmentSelectDisable' => 'Y',
'isNumeric' => 'Y',
'prefix' => 'U',
],
];
}
if (in_array('TAG', $fields))
{
$filter['TAG'] = [
'id' => 'TAG',
'name' => Loc::getMessage('TASKS_FILTER_TAG'),
'type' => 'entity_selector',
'default' => $isScrumProject,
'params' => [
'multiple' => 'Y',
'dialogOptions' => [
'context' => ($isScrumProject ? "TASKS_SCRUM_TAG_{$this->getGroupId()}" : 'TASKS_TAG'),
'entities' => [
[
'id' => 'task-tag',
'options' => $isScrumProject
? [
'groupId' => $this->getGroupId(),
'filter' => true,
]
: ['filter' => true]
,
],
],
'dropdownMode' => true,
'compactView' => true,
],
],
];
}
if ($isScrumProject)
{
$filter['STORY_POINTS'] = [
'id' => 'STORY_POINTS',
'name' => Loc::getMessage('TASKS_FILTER_STORY_POINTS'),
'type' => 'list',
'items' => [
'Y' => Loc::getMessage('TASKS_FILTER_STORY_POINTS_Y'),
'N' => Loc::getMessage('TASKS_FILTER_STORY_POINTS_N'),
],
'default' => true,
];
$filter['EPIC'] = [
'id' => 'EPIC',
'name' => Loc::getMessage('TASKS_FILTER_EPIC'),
'type' => 'list',
'items' => $this->getEpics(),
'default' => true,
];
}
if (in_array('ROLEID', $fields))
{
$items = [];
foreach (CounterRole::getRoles() as $roleCode => $roleName)
{
$items[$roleCode] = $roleName['TITLE'];
}
$filter['ROLEID'] = [
'id' => 'ROLEID',
'name' => Loc::getMessage('TASKS_FILTER_ROLEID'),
'type' => 'list',
'default' => !$isScrumProject,
'items' => $items,
];
}
if (in_array('COMMENT', $fields))
{
$filter['COMMENT_SEARCH_INDEX'] = [
'id' => 'COMMENT_SEARCH_INDEX',
'name' => Loc::getMessage('TASKS_FILTER_COMMENT'),
'type' => 'fulltext',
];
}
if (in_array('CREATED_DATE', $fields))
{
$filter['ACTIVITY_DATE'] = [
'id' => 'ACTIVITY_DATE',
'name' => Loc::getMessage('TASKS_FILTER_ACTIVITY_DATE'),
'type' => 'date',
];
}
if (!empty($uf = $this->getUF()))
{
foreach ($uf as $item)
{
$type = $item['USER_TYPE_ID'];
if ($type === 'crm')
{
continue;
}
$availableTypes = ['datetime', 'string', 'double', 'boolean'];
if (!in_array($type, $availableTypes, true))
{
$type = 'string';
}
if ($type === 'datetime')
{
$type = 'date';
}
else if ($type === 'double')
{
$type = 'number';
}
if ($type === 'boolean')
{
$filter[$item['FIELD_NAME']] = [
'id' => $item['FIELD_NAME'],
'name' => $item['EDIT_FORM_LABEL'],
'type' => 'list',
'items' => [
1 => GetMessage('TASKS_FILTER_NO'),
2 => GetMessage('TASKS_FILTER_YES'),
],
'uf' => true,
];
}
else
{
$filter[$item['FIELD_NAME']] = [
'id' => $item['FIELD_NAME'],
'name' => $item['EDIT_FORM_LABEL'],
'type' => $type,
'uf' => true,
];
}
}
}
return $filter;
}