<collection name="WorkplaceRequests_(vw_cmj_all)" idField="id" replace="runtime">
<prototype>
<![CDATA[
SELECT
id,
created_date,
updated_date,
Module,
self_1,
self_2,
self_3,
typeRequest,
statusWPRequest,
stage,
regNumber,
rNumber,
numberWOTags,
wpInitiator,
term,
finishtime,
wpEmployee,
wpEmpDepartment,
wpEmpHierDepatment,
wpEmpGoingToWork,
wpMovingDate,
wpInitBranch,
wpOffice,
wpTypeOffice,
wpInitOrganization,
wpInitiatorDepartment,
wpLocality,
wpCountry,
wpArea,
wpFloor,
wpRoomNumber,
wpCode
FROM (
select
rkkbase.id,
rkkbase.created_date,
rkkbase.updated_date,
rkkbase.module AS Module,
'<id>' AS self_1,
':' AS self_2,
'</>' AS self_3,
rkkbase."type" AS typeRequest,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'status') as statusWPRequest,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'stage') as stage,
'<regNumberPrefix>' || coalesce(rkk.prjnumprist, '') || '</>' || '<regNumberCounter#Number>' || coalesce(cast(rkk.prjnumcounter as varchar), '') || '</>' || '<regNumberSuffix>' || coalesce(rkk.prjnumfin , '') || '</>' as regNumber,
rkk.prjnumcounter as rNumber,
coalesce(rkk.prjnumprist, '') || coalesce(cast(rkk.prjnumcounter as VARCHAR), '') || coalesce(rkk.prjnumfin, '') as numberWOTags,
(select
coalesce('<id>' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'%(.*)')
|| ':' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'(.*)%') || '</><shortName>'
|| substr(tfs."value", 1, strpos(tfs."value", '%') - 1) || '</>', '<id></><shortName></>') as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpInitiator') as wpInitiator,
(select tfs."value" as v
from tn_field
join tn_field_datetime tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'plannedfinishtime') as term,
(select tfs."value" as v
from tn_field
join tn_field_datetime tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'finishtime') as finishtime,
(select tfs."value" as v
from tn_field
join tn_field_beard tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'assignee') as assignee,
(select
coalesce('<id>' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'%(.*)')
|| ':' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'(.*)%') || '</><shortName>'
|| substr(tfs."value", 1, strpos(tfs."value", '%') - 1) || '</>', '<id></><shortName></>') as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpEmployee') as wpEmployee,
(select date(tfs."value") as v
from tn_field
join tn_field_dateonly tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpEmpGoingToWork') as wpEmpGoingToWork,
(select date(tfs."value") as v
from tn_field
join tn_field_dateonly tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpMovingDate') as wpMovingDate,
(select
coalesce('<id>' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'%(.*)')
|| ':' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'(.*)%') || '</><shortName>'
|| substr(tfs."value", 1, strpos(tfs."value", '%') - 1) || '</>', '<id></><shortName></>') as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpEmpDepartment') as wpEmpDepartment,
(select
tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpEmpHierDepatment') as wpEmpHierDepatment,
(select
coalesce('<id>' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'%(.*)')
|| ':' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'(.*)%') || '</><shortName>'
|| substr(tfs."value", 1, strpos(tfs."value", '%') - 1) || '</>', '<id></><shortName></>') as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpInitBranch') as wpInitBranch,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpOffice') as wpOffice,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpTypeOffice') as wpTypeOffice,
(select
coalesce('<id>' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'%(.*)')
|| ':' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'(.*)%') || '</><shortName>'
|| substr(tfs."value", 1, strpos(tfs."value", '%') - 1) || '</>', '<id></><shortName></>') as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpInitOrganization') as wpInitOrganization,
(select
coalesce('<id>' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'%(.*)')
|| ':' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'(.*)%') || '</><shortName>'
|| substr(tfs."value", 1, strpos(tfs."value", '%') - 1) || '</>', '<id></><shortName></>') as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpInitDepartment') as wpInitiatorDepartment,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpLocality') as wpLocality,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpCountry') as wpCountry,
(select
coalesce('<id>' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'%(.*)')
|| ':' || substring(substring(substring(substring(tfs."value", '%(.*)'), '%(.*)'), '%(.*)'),'(.*)%') || '</><shortName>'
|| substr(tfs."value", 1, strpos(tfs."value", '%') - 1) || '</>', '<id></><shortName></>') as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpArea') as wpArea,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpFloor') as wpFloor,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpRoomNumber') as wpRoomNumber,
(select tfs."value" as v
from tn_field
join tn_field_string tfs on tn_field.access_object_id = tfs.id
where tn_field."owner" = rkkbase.id
and tn_field.owner_type = rkkbase.id_type
and tn_field.cmjfield = 'wpRMCode') as wpCode
FROM F_DP_Intrkk internalrkk
JOIN f_dp_rkk rkk ON rkk.id = internalrkk.id
JOIN f_dp_rkkbase rkkbase ON rkkbase.id = rkk.id
JOIN F_DP_Intrkk_Executor executor ON executor.owner = internalrkk.id
JOIN so_beard beard ON beard.id = executor.executor
WHERE rkkbase.isdeleted <> 1
AND rkk.regnumcnt IS NULL
) s
WHERE stage NOT IN ('Перемещена в архив')
AND 1 = 1
::where-clause
]]>
</prototype>
<counting-prototype>
<![CDATA[
SELECT
COUNT(1)
FROM (
SELECT
rkkbase.id
FROM F_DP_Intrkk internalrkk
JOIN f_dp_rkk rkk ON rkk.id = internalrkk.id
JOIN f_dp_rkkbase rkkbase ON rkkbase.id = rkk.id
JOIN F_DP_Intrkk_Executor executor ON executor.owner = internalrkk.id
JOIN so_beard beard ON beard.id = executor.executor
WHERE rkkbase.isdeleted <> 1 AND rkk.regnumcnt IS NULL
) s
WHERE stage NOT IN ('Перемещена в архив')
AND 1 = 1
::where-clause
]]>
</counting-prototype>
<filter name="MODULE">
<criteria placeholder="where-clause">
<![CDATA[
Module = {0}
]]>
</criteria>
</filter>
<filter name="self">
<criteria placeholder="where-clause"><![CDATA[ Module = {0} and id = {1} ]]></criteria>
</filter>
<filter name="created_date">
<criteria placeholder="where-clause">
<![CDATA[
cast(created_date as date) = cast({0} as date)
]]>
</criteria>
</filter>
<filter name="rNumber">
<criteria placeholder="where-clause"><![CDATA[ rNumber = {0} ]]></criteria>
</filter>
<filter name="rNumber_partial">
<criteria placeholder="where-clause"><![CDATA[ rNumber iLIKE ('%'||{0}||'%') ]]></criteria>
</filter>
<filter name="rNumber_L">
<criteria placeholder="where-clause"><![CDATA[ rNumber < {0} ]]></criteria>
</filter>
<filter name="rNumber_GE">
<criteria placeholder="where-clause"><![CDATA[ rNumber >= {0} ]]></criteria>
</filter>
<filter name="rNumber_Partial">
<criteria placeholder="where-clause"><![CDATA[ rNumber LIKE {0} ]]></criteria>
</filter>
<filter name="regNumber">
<criteria placeholder="where-clause"><![CDATA[ regNumber = {0} ]]></criteria>
</filter>
<filter name="regNumber_partial">
<criteria placeholder="where-clause"><![CDATA[ numberWOTags iLIKE ('%'||{0}||'%') ]]></criteria>
</filter>
<filter name="typeRequest">
<criteria placeholder="where-clause">
<![CDATA[
typeRequest = {0}
]]>
</criteria>
</filter>
<filter name="typeRequest_partial">
<criteria placeholder="where-clause">
<![CDATA[
typeRequest ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpInitiator">
<criteria placeholder="where-clause">
<![CDATA[
wpInitiator = {0}
]]>
</criteria>
</filter>
<filter name="wpInitiator_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpInitiator ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="stage">
<criteria placeholder="where-clause">
<![CDATA[
stage = {0}
]]>
</criteria>
</filter>
<filter name="stage_partial">
<criteria placeholder="where-clause">
<![CDATA[
stage ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="statusWPRequest">
<criteria placeholder="where-clause">
<![CDATA[
wpStatus = {0}
]]>
</criteria>
</filter>
<filter name="statusWPRequest_partial">
<criteria placeholder="where-clause">
<![CDATA[
statusWPRequest ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="term_partial">
<criteria placeholder="where-clause">
<![CDATA[
cast(term as date) = cast({0} as date)
]]>
</criteria>
</filter>
<filter name="finishtime_partial">
<criteria placeholder="where-clause">
<![CDATA[
cast(finishtime as date) = cast({0} as date)
]]>
</criteria>
</filter>
<filter name="wpEmpGoingToWork_partial">
<criteria placeholder="where-clause">
<![CDATA[
cast(wpEmpGoingToWork as date) = cast({0} as date)
]]>
</criteria>
</filter>
<filter name="wpMovingDate">
<criteria placeholder="where-clause">
<![CDATA[
(wpMovingDate >= ({0})::timestamp and
wpMovingDate < (({0})::timestamp + interval '1 day'))
]]>
</criteria>
</filter>
<filter name="assignee">
<criteria placeholder="where-clause">
<![CDATA[
assignee = {0}
]]>
</criteria>
</filter>
<filter name="assignee_partial">
<criteria placeholder="where-clause">
<![CDATA[
assignee ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpEmployee">
<criteria placeholder="where-clause">
<![CDATA[
wpEmployee = {0}
]]>
</criteria>
</filter>
<filter name="wpEmployee_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpEmployee ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpEmpDepartment">
<criteria placeholder="where-clause">
<![CDATA[
wpEmpDepartment = {0}
]]>
</criteria>
</filter>
<filter name="wpEmpDepartment_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpEmpDepartment ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpInitBranch">
<criteria placeholder="where-clause">
<![CDATA[
wpInitBranch = {0}
]]>
</criteria>
</filter>
<filter name="wpInitBranch_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpInitBranch ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpInitiatorDepartment">
<criteria placeholder="where-clause">
<![CDATA[
wpInitiatorDepartment = {0}
]]>
</criteria>
</filter>
<filter name="wpInitiatorDepartment_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpInitiatorDepartment ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpLocality">
<criteria placeholder="where-clause">
<![CDATA[
wpLocality = {0}
]]>
</criteria>
</filter>
<filter name="wpLocality_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpLocality ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpCountry">
<criteria placeholder="where-clause">
<![CDATA[
wpCountry = {0}
]]>
</criteria>
</filter>
<filter name="wpCountry_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpCountry ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpArea">
<criteria placeholder="where-clause">
<![CDATA[
wpArea = {0}
]]>
</criteria>
</filter>
<filter name="wpArea_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpArea ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="wpFloor">
<criteria placeholder="where-clause">
<![CDATA[
wpFloor = {0}
]]>
</criteria>
</filter>
<filter name="wpRoomNumber">
<criteria placeholder="where-clause">
<![CDATA[
wpRoomNumber = {0}
]]>
</criteria>
</filter>
<filter name="wpCode">
<criteria placeholder="where-clause">
<![CDATA[
wpCode = {0}
]]>
</criteria>
</filter>
<filter name="wpEmpHierDepatment">
<criteria placeholder="where-clause">
<![CDATA[
wpEmpHierDepatment = {0}
]]>
</criteria>
</filter>
<filter name="wpEmpHierDepatment_partial">
<criteria placeholder="where-clause">
<![CDATA[
wpEmpHierDepatment ilike '%'||{0}||'%'
]]>
</criteria>
</filter>
<filter name="BeforeDate">
<criteria placeholder="where-clause">
<![CDATA[
updated_date < {0}
]]>
</criteria>
</filter>
</collection> |