spec/abstract_service_rpt.cfm
2025-06-02 16:16:51 +03:00

270 lines
12 KiB
Plaintext

<cfsilent>
<cfimport prefix="m" taglib="lib"/>
<cfimport prefix="c" taglib="lib/controls"/>
<cfimport prefix="d" taglib="lib/data"/>
<cfimport prefix="layout" taglib="layout"/>
</cfsilent><m:silent silent="No">
<m:prepare_ls entity="abstract_service" accessObject="abstract_service_rpt" pageInfoOut="pageInfo" trackOut="tr"/>
<m:filter_settings target="#pageInfo.entity#_ls">
<m:filterparam filter=#filter# param="quickfilter" ftype="string" prefix="%" suffix="%" expression="((p.project like ?) OR (p.customer like ?) OR (p.customer_alias like ?) OR (p.abstract_service_type like ?) OR (p.division like ?) OR (p.performer_short like ?))" default=""/>
</m:filter_settings>
<cfset pageInfo.settings.filter=#filter#/>
<cftry>
<cfquery name="qRead" datasource="#request.DS#">
select
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
<d:field title="ID" cfSqlType="CF_SQL_INTEGER">a.abstract_service_id</d:field>
<d:field title=#i18("Код группы","Group Code")#>g.area_code</d:field>
<d:field title="Группа каталога">g.area</d:field>
<d:field title="Catalog Group">g.area_en</d:field>
<d:field title="Статус">u.status</d:field>
<d:field title="Status">u.status_en</d:field>
<d:field title=#i18("Код услуги","Service Code")#>a.code</d:field>
<d:field title=#i18("Номенклатура (RUS)","Service (RUS)")#>a.abstract_service</d:field>
<d:field title=#i18("Номенклатура (ENG)","Service (ENG)")#>a.abstract_service_en</d:field>
<d:field title="Ед.изм.">m.measure_short</d:field>
<d:field title="Measure">m.measure_short_en</d:field>
<d:field title="Провайдер" cfSqlType="CF_SQL_INTEGER">(select count(*) from abstract_service_provider sp where sp.abstract_service_id=a.abstract_service_id) as provider_count</d:field>
<d:field title="Провайдеры">
CAST(
(
select coalesce(p.provider,'') as provider /*null does not produce an attribute*/
from abstract_service_provider sp
join provider p on (sp.provider_id=p.provider_id)
where sp.abstract_service_id=a.abstract_service_id
FOR XML AUTO, TYPE, ROOT('providers')
)
AS VARCHAR(MAX))
as providers
</d:field>
<d:field title="Providers">
CAST(
(
select coalesce(p.provider_en, '') as provider /*NB!*/
from abstract_service_provider sp
join provider p on (sp.provider_id=p.provider_id)
where sp.abstract_service_id=a.abstract_service_id
FOR XML AUTO, TYPE, ROOT('providers')
)
AS VARCHAR(MAX))
as providers_en
</d:field>
<d:field title="Периодичность">p.payment_periodicity</d:field>
<d:field title="Periodicity">p.payment_periodicity_en</d:field>
<d:field title=#i18("Код","Code")#>b.budget_code</d:field>
<d:field title="Бюджетная статья">b.budget</d:field>
<d:field title="Budget Item">b.budget_en</d:field>
<d:field title="Тип">st.service_type</d:field>
<d:field title="Type">st.service_type_en</d:field>
<d:field title=#i18("Класс характеристики","Characteristic class")#>mc.modifier_class</d:field>
<d:field title=#i18("Вариантов","Variants")# cfSqlType="CF_SQL_INTEGER">(select count(*) from service s where s.abstract_service_id=a.abstract_service_id) as service_count</d:field>
<d:field title=#i18("Документы","Documents")# cfSqlType="CF_SQL_INTEGER">(select count(*) from abstract_service_doc d where d.abstract_service_id=a.abstract_service_id) as doc_count</d:field>
<d:field title=#i18("Документы","Documents")# >
CAST(
(
select abstract_service_doc_id, abstract_service_doc, fname, contenttype, dt_created
from abstract_service_doc d
where d.abstract_service_id=a.abstract_service_id
FOR XML AUTO, TYPE, ROOT('docs')
)
AS VARCHAR(MAX))
as docs
</d:field>
</d:field_set>
from abstract_service a
join service_type st on (a.service_type_id=st.service_type_id)
join status u on (a.status_id=u.status_id)
left outer join modifier_class mc on (a.modifier_class_id=mc.modifier_class_id)
left outer join area g on (a.area_id=g.area_id)
left outer join budget b on (a.budget_id=b.budget_id)
left outer join measure m on (a.measure_id=m.measure_id)
left outer join payment_periodicity p on (b.payment_periodicity_id=p.payment_periodicity_id)
where 1=1 <m:filter_build filter=#pageInfo.settings.filter#/>
order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=#fieldCount#/>
</cfquery>
<cfcatch type="database">
<m:ls_catch catch=#cfcatch# status=#pageInfo.status#/>
</cfcatch>
</cftry>
<cfquery name="qCountTotal" datasource="#request.DS#">
select count(*) as cnt from abstract_service where 1=1
</cfquery>
</m:silent><!---
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
---><cfif isDefined("output_xls")>
<layout:xml qRead=#qRead# titleMap=#titleMap# filename="#pageInfo.entity#.xml"/>
<cfabort/>
</cfif><cfif isDefined("output_json")>
<layout:json qRead=#qRead# titleMap=#titleMap# filename="#pageInfo.entity#.json"/>
<cfabort/>
</cfif><!---
---><layout:page section="header" pageInfo=#pageInfo#>
<layout:attribute name="title">
<cfoutput><b>#i18("Каталог","Catalog")#</b> </cfoutput>
</layout:attribute>
</layout:page>
<cfif pageInfo.readPermitted() AND !pageInfo.status.errorState>
<layout:grid_summary
recordCount=#qRead.recordCount#
totalCount=#qCountTotal.cnt#
footerOut="gridFooter"
excelLink="Yes"
jsonLink="Yes"
/>
<cffunction name="formatProviders" output="true">
<cfargument name="providers"/>
<cfif len(ARGUMENTS.providers)>
<cftry>
<cfset providerCollection=xmlParse(ARGUMENTS.providers)/>
<cfloop array=#providerCollection.providers.XmlChildren# index="d">
<p style="margin:.5em 0;">
#d.XmlAttributes.provider#
</p>
</cfloop>
<cfcatch type="ANY">#cfcatch.message# #cfcatch.detail#</cfcatch>
</cftry>
</cfif>
</cffunction>
<cfset request.formatProviders=formatProviders/>
<!---NB CALLER.tr.fwx! --->
<cffunction name="formatDocs" output="true">
<cfargument name="docs"/>
<cfif len(docs)>
<cftry>
<cfset docsCollection=xmlParse(docs)/><!---<cfdump var=#docsCollection#/>--->
<cfloop array=#docsCollection.docs.XmlChildren# index="d"> <!---<cfdump var=#d.XmlAttributes#/>--->
<p style="line-height:1.8em;">
<a href="doc_get.cfm?entity=abstract_service&doc_id=#d.XmlAttributes.abstract_service_doc_id#" title="открыть (#d.XmlAttributes.contenttype#)" target="_blank">
<m:contenttype_icon contenttype=#d.XmlAttributes.contenttype#/>
</a>
<a href="doc.cfm?entity=abstract_service&doc_id=#d.XmlAttributes.abstract_service_doc_id#&#CALLER.tr.fwx#" title="редактировать атрибуты"><cfif len(d.XmlAttributes.abstract_service_doc)>#d.XmlAttributes.abstract_service_doc#<cfelse>#d.XmlAttributes.abstract_fname#</cfif> (#dateFormat(d.XmlAttributes.dt_created,'DD.MM.YYYY')#)</a>
</p>
</cfloop>
<cfcatch type="ANY">#cfcatch.message# #cfcatch.detail#</cfcatch>
</cftry>
</cfif>
</cffunction>
<cfset request.formatDocs=formatDocs/>
<!---*** очень осторожно: используется Dynamic Evaluation! --->
<c:table query=#qRead# recordsPerPage=#pageInfo.recordsPerPage# nStart=#pageInfo.nStart# titleMap=#titleMap# sortArray=#pageInfo.settings.sort.sortArray# class="worktable wide">
<c:column width="1%" field="area_code"/>
<c:column width="5%" field="area" lang="ru"/><c:column width="5%" field="area_en" lang="en"/>
<c:column width="3%" field="status" lang="ru"/><c:column width="3%" field="status_en" lang="en"/>
<c:column width="3%" field="service_type" lang="ru"/><c:column width="3%" field="service_type_en" lang="en"/>
<c:column width="15%" field="abstract_service"><c:td><a href="abstract_service.cfm?abstract_service_id=#abstract_service_id#&#CALLER.tr.fwx#">#abstract_service#</a></c:td></c:column>
<c:column width="15%" field="abstract_service_en"><c:td><a href="abstract_service.cfm?abstract_service_id=#abstract_service_id#&#CALLER.tr.fwx#">#abstract_service_en#</a></c:td></c:column>
<c:column width="5%" field="code"><c:td><a href="abstract_service.cfm?abstract_service_id=#abstract_service_id#&#CALLER.tr.fwx#">#code#</a></c:td></c:column>
<c:column width="2%" field="measure_short" lang="ru"/><c:column width="2%" field="measure_short_en" lang="en"/>
<c:column width="15%" field="provider_count" lang="ru">
<c:th>Провайдеры</c:th>
<c:td>#request.formatProviders(providers)#<!---<pre>#replace(replace(providers,'<','&lt;', 'ALL'),'>','&gt;', 'ALL')#</pre>---></c:td>
</c:column>
<c:column width="15%" field="provider_count" lang="en">
<c:th>Providers</c:th>
<c:td>#request.formatProviders(providers_en)#<!---<pre>#replace(replace(providers_en,'<','&lt;', 'ALL'),'>','&gt;', 'ALL')#</pre>---></c:td>
</c:column>
<c:column width="20%" field="doc_count">
<c:td>#request.formatDocs(docs)#</c:td>
</c:column>
</c:table>
<!--- <table class="worktable">
<thead>
<layout:grid_head titleMap=#titleMap# sortArray=#pageInfo.settings.sort.sortArray#>
<th width="1%"></th>
<th width="3%"><layout:column_head name="area_code"/></th>
<th width="10%"><layout:column_head name="area"/></th>
<th width="3%"><layout:column_head name="status"/></th>
<th width="5%"><layout:column_head name="service_type"/></th>
<th width="10%"><layout:column_head name="abstract_service"/></th>
<th width="2%"><layout:column_head name="code"/></th>
<th width="2%"><layout:column_head name="measure_short"/></th>
<th width="5%"><layout:column_head name="provider_count"/></th>
<th width="15%"><layout:column_head name="doc_count"/></th>
</layout:grid_head>
</thead>
<cfoutput query="qRead" maxrows=#pageInfo.recordsPerPage# startrow=#pageInfo.nStart#>
<tr>
<td class="c">
<c:link_view_edit canWrite=#pageInfo.writePermitted()# entity=#pageInfo.entity# id=#qRead[pageInfo.entity&'_id'][currentRow]# fwx=#tr.fwx#/>
</td>
<td>#area_code#</td>
<td>#area#</td>
<td>#status#</td>
<td class="c">#service_type#</td>
<td>#abstract_service#</td>
<td>#code#</td>
<td class="c">#measure_short#</td>
<td>
<cfif len(providers)>
<cftry>
<cfset providerCollection=xmlParse(providers)/>
<cfloop array=#providerCollection.providers.XmlChildren# index="d">
<p style="margin:.5em 0;">
#d.XmlAttributes.provider#
</p>
</cfloop>
<cfcatch type="ANY">#cfcatch.message# #cfcatch.detail#</cfcatch>
</cftry>
</cfif>
</td>
<td>
<cfif len(docs)>
<cftry>
<cfset docsCollection=xmlParse(docs)/>
<cfloop array=#docsCollection.docs.XmlChildren# index="d">
<p style="line-height:1.8em;">
<a href="doc_get.cfm?entity=abstract_service&doc_id=#d.XmlAttributes.abstract_service_doc_id#" title="открыть (#d.XmlAttributes.contenttype#)" target="_blank">
<m:contenttype_icon contenttype=#d.XmlAttributes.contenttype#/>
</a>
<a href="doc.cfm?entity=abstract_service&doc_id=#d.XmlAttributes.abstract_service_doc_id#&#tr.fwx#" title="редактировать атрибуты"><cfif len(d.XmlAttributes.abstract_service_doc)>#d.XmlAttributes.abstract_service_doc#<cfelse>#d.XmlAttributes.abstract_fname#</cfif> (#dateFormat(d.XmlAttributes.dt_created,'DD.MM.YYYY')#)</a>
</p>
</cfloop>
<cfcatch type="ANY">#cfcatch.message# #cfcatch.detail#</cfcatch>
</cftry>
</cfif>
</td>
</tr>
</cfoutput>
</table>--->
<cfoutput>#gridFooter#</cfoutput>
</cfif>
<layout:page section="footer"/>