В данной форме настраиваются правила поиска документа для [журнала состояния документов](https://ecm-user-manuals.readthedocs.io/ru/latest/User%20manuals/Анализ%20и%20отчетность/#журнал_состояния_документов).
* **Служебное наименование** - указывается служебное наименование по которому фильтруется реестр документов. Служебное наименование должно быть **уникальным** в системе.

* **Показывать в форме** - указывается служебное наименование формы, в которой необходимо отображать данную настройку, например, в личном кабинете HR. Если поле незаполнено то данная настройка отображается во всех формах.
В данном блоке можно добавить дополнительные колонки для отображения в журнале. Наименование колонок может быть произвольным. Информация в дополнительных колонках отображается в зависимости от указанных в [запросе](#вкладка_запрос) условий.
В запросе возможно настроить цветовое отображение полей документов в зависимости от условий. Для этого в запросе необходимо указать поле "Colors" и заполнить его одним из следующих значений: `1 - colors.gray 2 - colors.orange 3 - colors.yellow 4 - colors.green 5 - colors.blue 6 - colors.indigo 7 -colors.violet`. Например в запросе: **Все документы** данное значение указано в конце запроса: `(select top 1 wr."VCode" from "RP_Worker" wr join "RP_PersonContact" pc on wr."IdPerson"= pc."Pcode" and pc."IdTypeContact" = 6 and pc."Code" = t."StageUser" where wr."COrg" = 4 order by wr."DateBeg" ) as "AnyColumnO"
where coalesce(t."RouteStatusId",0) = 2 and t."IsMarked" is not true
and t."StageItemStatus"= 2
AND (
t."DocumentDate" IS NULL OR t."DocumentDate" BETWEEN _bdate AND _edate
) ) dd
where
coalesce(dd."expired", 0) <> 0 ;
```
**Зависшие документы у инициатора** - в реестре отображаются документы, которые были инициированы сотрудником, но не запущены далее по маршруту согласования.
where coalesce(t."RouteStatusId",0) in ( 2 ) and t."StageItemStatus"= 2 and t."IsMarked" is not true
and t."StageNumber" = 1 AND (
t."DocumentDate" IS NULL OR t."DocumentDate" BETWEEN _bdate AND _edate
) ;
```
**Поступят к hr в ближайшее время** - в реестре отображаются документы, которые в данный момент находятся на стадии согласования у руководителя сотрудника, и после этого поступят в HR службу.
(select top 1 convert(varchar,daa1."DateValue",104) from "DocumentCategoryAttributeType" bd
join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#bdate#' where t."DocumentCategory" = bd."PCode" ) as "AnyColumnF" ,
(select top 1 convert(varchar,daa1."DateValue",104) from "DocumentCategoryAttributeType" bd
join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#edate#' where t."DocumentCategory" = bd."PCode") as "AnyColumnG" ,
(select top 1 daa1."BigIntValue" from "DocumentCategoryAttributeType" bd
join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" ='#kolvo#' where t."DocumentCategory" = bd."PCode") as "AnyColumnH",
/* (select string_agg(dca."Name" || ':' || (case
when coalesce(dca."AttributeType",'') = 'string' and coalesce(atr."Value",'') <> '' then atr."Value"
when coalesce(dca."AttributeType",'') = 'string' and coalesce(atr."Value",'') = '' then ' '
when coalesce(dca."AttributeType",'') = 'bigint' and atr."BigIntValue" is not null then cast(atr."BigIntValue" as varchar(255))
when coalesce(dca."AttributeType",'') = 'bigint' and atr."BigIntValue" is null then ' '
when coalesce(dca."AttributeType",'') = 'string' and atr."BigIntValue" is not null then cast(atr."BigIntValue" as varchar(255))
when coalesce(dca."AttributeType",'') = 'string' and atr."BigIntValue" is null then ' '
when coalesce(dca."AttributeType",'') = 'Base.Unispr' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' '
when coalesce(dca."AttributeType",'') = 'Base.Unispr' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ')
when coalesce(dca."AttributeType",'') = 'Base.Post' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' '
when coalesce(dca."AttributeType",'') = 'Base.Post' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ')
when coalesce(dca."AttributeType",'') = 'Base.RP_Worker' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' '
when coalesce(dca."AttributeType",'') = 'Base.RP_Worker' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ')
when coalesce(dca."AttributeType",'') = 'Base.Contract' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' '
when coalesce(dca."AttributeType",'') = 'Base.Contract' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ')
when coalesce(dca."AttributeType",'') = 'Base.Contractor' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' '
when coalesce(dca."AttributeType",'') = 'Base.Contractor' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ')
when coalesce(dca."AttributeType",'') = 'Base.Department' and atr."BigIntValue" is null and coalesce(atr."Value",'') = '' then ' '
when coalesce(dca."AttributeType",'') = 'Base.Department' and atr."BigIntValue" is not null and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ')
when coalesce(dca."AttributeType",'') = 'money' and atr."MoneyValue" is not null then cast(atr."MoneyValue" as varchar(255))
when coalesce(dca."AttributeType",'') = 'money' and atr."MoneyValue" is null then ' '
when coalesce(dca."AttributeType",'') = 'Date' and atr."DateValue" is not null then to_char(atr."DateValue", 'DD.MM.YYYY')
when coalesce(dca."AttributeType",'') = 'Date' and atr."DateValue" is null then ' '
when coalesce(dca."AttributeType",'') = 'DateTime' and atr."DateTimeValue" is not null then to_char(atr."DateValue", 'DD.MM.YYYY')
when coalesce(dca."AttributeType",'') = 'DateTime' and atr."DateTimeValue" is null then ' '
when coalesce(dca."AttributeType",'') = 'double' and atr."DoubleValue" is not null then cast(atr."DoubleValue" as varchar(255))
when coalesce(dca."AttributeType",'') = 'double' and atr."DoubleValue" is null then ' '
when coalesce(dca."AttributeType",'') = 'ServiceWord' and coalesce(atr."Value",'') <> '' then coalesce(atr."Value",' ')
when coalesce(dca."AttributeType",'') = 'ServiceWord' and coalesce(atr."Value",'') = '' then ' '
when coalesce(dca."AttributeType",'') = 'bool' and coalesce("BigIntValue"::integer,0) = 0 then substring(coalesce("Value",'|'), position('|' in coalesce("Value",'|'))+1,char_length(coalesce("Value",'|')))
when coalesce(dca."AttributeType",'') = 'bool' and coalesce("BigIntValue"::integer,0) = 1 then substring(coalesce("Value",'|'),0, position('|' in coalesce("Value",'|')))
end), '; ') AS "x"
from "DocumentAdditionalAttribute" atr
join "DocumentCategoryAttributeType" dca on atr."CategoryAttributeType" = dca."VCode"
where t."DocCode" = atr."PCode" and dca."ColumnName" not in ('#bdate#', '#edate#', '#kolvo#'))
*/ null as "AnyColumnI",
null/*sii."Name"*/,
case when coalesce(t."RouteStatusId",0) = 2 and exists (select 1 from "RouteStage" rs
where rs."PCode" = t."RouteVCode" and rs."StageNumber" = 1 and rs."Status" = 2 ) then 'Не запущен'
when coalesce(t."RouteStatusId",0) = 2 and t."StageItemStatus"= 2 and t."StageNumber" > 1
and exists (select 1 from "RouteStage" rs
where rs."PCode" = t."RouteVCode"
and isnull(rs."IsMarked",0) = 1
and rs."StageName" in ( 'Исполнить')
and rs."Status"=1) then 'На согласовании / на согл у рук-ля'
when coalesce(t."RouteStatusId",0) = 3
and not exists (select 1 from "RouteStage" rs
join "StageItem" si on rs."VCode" = si."PCode"
where rs."PCode" = t."RouteVCode"
and si."DocumentStatus" in (19,23)) then 'Завершен'
when coalesce(t."RouteStatusId",0) = 3 and exists (select 1 from "RouteStage" rs
join "StageItem" si on rs."VCode" = si."PCode"
where rs."PCode" = t."RouteVCode"
and si."DocumentStatus" in (19,23)) then 'Отклонен'
end as "AnyColumnK",
/*( SELECT DISTINCT string_agg(u."Initials"|| '(' || ds."Name"|| ')' , '; ') AS "x"
FROM "RouteStage" as rs
join "StageItem" AS i on i."PCode" = rs."VCode"
join "VUserMeta" AS u ON u."VCode" = i."StageUser"
join "DocumentStatus" AS ds ON ds."VCode" = i."DocumentStatus"
WHERE rs."PCode" = t."RouteVCode"
AND i."StageItemStatus" = 3
and coalesce(i."DocumentStatus",0) <> 0
) */ '' as "AnyColumnL",
case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select top 1 w."NumTab" from "DocumentCategoryAttributeType" bd
join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
join "RP_Worker" w on w."VCode" = daa1."BigIntValue"
where t."DocumentCategory" = bd."PCode")
else (select r."NumTab" from "RP_Worker" as r where r."VCode" = t."IdWorker") end as "AnyColumnM",
case when t."DocType" in ('UniversalDocument','DocumentForSigning') then (select top 1 w."NameFull" from "DocumentCategoryAttributeType" bd
join "DocumentAdditionalAttribute" daa1 on t."DocCode" = daa1."PCode" and daa1."CategoryAttributeType" = bd."VCode" and bd."ColumnName" = '#Worker#'
join "RP_Worker" w on w."VCode" = daa1."BigIntValue"
where t."DocumentCategory" = bd."PCode" )
else (select r."NameFull" from "RP_Worker" as r where r."VCode" = t."IdWorker") end as "AnyColumnN",
(select top 1 wr."VCode" from "RP_Worker" wr join "RP_PersonContact" pc on wr."IdPerson"= pc."Pcode" and pc."IdTypeContact" = 6 and pc."Code" = t."StageUser" where wr."COrg" = 4 order by wr."DateBeg" ) as "EmailRecipient",
(select top 1 wr."VCode" from "RP_Worker" wr join "RP_PersonContact" pc on wr."IdPerson"= pc."Pcode" and pc."IdTypeContact" = 6 and pc."Code" = t."StageUser" where wr."COrg" = 4 order by wr."DateBeg" ) as "AnyColumnO"
, 2
from #tmp_preresult t
where t."DocType" not in ('ServiceDesk') and
(
t."DocumentDate" IS NULL OR t."DocumentDate" BETWEEN @_bdate AND @_edate