spec/specification_version.cfm
2025-06-09 16:03:38 +03:00

270 lines
11 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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">
<cffunction name="plain2HtmClean">
<cfargument name="s" type="string"/>
<cfreturn request.plain2htm(request.cleanHtm(s))/>
</cffunction>
<cffunction name="cleanInput">
<cfargument name="s" type="string"/>
<cfreturn htmlEditFormat(s)/>
</cffunction>
<!--- Синтетическая версия спецификации (отчет). Не подразумевает сохранения --->
<cfparam name="specification_id" type="integer"/>
<cfparam name="agreement_version" type="integer"/>
<m:prepare_detail entity="specification" accessObject="undefined" key="specification_id" pageInfoOut="pageInfo"/>
<d:bean readonly=true table="specification" datasource="#request.DS#" output="d" status="status">
<d:param field="specification_id" type="integer" key autoincrement/>
<d:param field="contract_id" type="integer" forNull=""/>
<d:param field="specification" type="varchar" size="255" preprocessor=#cleanInput#/>
<d:param field="descr" type="varchar" preprocessor=#plain2HtmClean#/>
<d:param field="creator_id" type="integer" value="#request.usr_id#" skipUpdate/>
<d:param field="updater_id" type="integer" value="#request.usr_id#" />
<d:param field="dt_created" type="timestamp" value="#Now()#" skipUpdate/>
<d:param field="dt_updated" type="timestamp" value="#Now()#"/>
</d:bean>
<m:dispatch_detail
usePRG="No"<!---*** --->
pageInfo=#pageInfo#
id="#d.specification_id#"
status=#pageInfo.status#
trackOut="tr"
idAttributesOut="id"
/>
<!--- decoration --->
<cfquery name="qDecoration" datasource="#request.DS#">
select
a.login as creator, a.shortname as creator_shortname, m.login as updater, m.shortname as updater_shortname
from #pageInfo.entity# e
left outer join usr a on (e.creator_id=a.usr_id)
left outer join usr m on (e.updater_id=m.usr_id)
where e.#pageInfo.key#=<cfqueryparam attributeCollection=#id#/>
</cfquery>
<cfquery name="qContract" datasource="#request.DS#">
select d.contract_id, d.contract, d.dt_contract, c.contragent_id, c.contragent
from contract d
left outer join contragent c on (d.contragent_id=c.contragent_id)
where d.contract_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.contract_id#"/>
</cfquery>
<cfquery name="qAgreement" datasource="#request.DS#">
select a.agreement, a.agreement_version, a.dt_agreement
from agreement a
where a.contract_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.contract_id#"/>
AND a.agreement_version=<cfqueryparam cfsqltype="cf_sql_integer" value="#agreement_version#" null=#!isValid('integer', agreement_version)#>
</cfquery>
</m:silent><!---
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
---><layout:page section="header" pageInfo=#pageInfo#>
<layout:attribute name="title">
<cfoutput>
Версия [#agreement_version#]
спецификации
<cfif d.specification_id GT 0>
<b>#d.specification#</b>
[#d.specification_id#]
</cfif>
</cfoutput>
</layout:attribute>
<layout:attribute name="controls">
<button type="button" name="close" class="maincontrol" onClick="document.location.href='#tr.backUrl#'">
Закрыть
</button>
</layout:attribute>
</layout:page>
<cfif status.errorState GT 0>
<cfoutput><div class="err">#status.errorMessage#</div></cfoutput>
</cfif>
<cfoutput>
<input type="hidden" name="specification_id" value="#d.specification_id#"/>
<input type="hidden" name="track" value="#tr.self#"/>
<input type="hidden" name="pass" value=""/><!--- pass marker to prevent save on submit --->
<div class="detail">
<div class="tr">
<div class="th">Спецификация (номер)</div>
<div class="td">
#d.specification#
</div>
</div>
<div class="tr">
<div class="th">Договор</div>
<div class="td">
#qContract.contragent# #qContract.contract# #dateFormat(qContract.dt_contract,'DD.MM.YYYY')#
<cfif d.contract_id GT 0>
<c:link_view_edit canWrite=#pageInfo.writePermitted()# entity="contract" id=#d.contract_id# fwx=#tr.fwx#/>
</cfif>
</div>
</div>
<div class="tr">
<div class="th">Соглашение</div>
<div class="td">
<a href="argeement.cfm?contract_id=#d.contract_id#&agreement_version=#agreement_version#&#tr.fwx#">
#qAgreement.agreement# [#qAgreement.agreement_version#] #dateFormat(qAgreement.dt_agreement,'DD.MM.YYYY')#
</a>
</div>
</div>
<div class="tr">
<div class="th">Описание</div>
<div class="td">
#d.descr#
</div>
</div>
<div class="tr">
<div class="th">Создано</div>
<div class="td">
#dateFormat(d.dt_created,'DD.MM.YYYY')# #timeFormat(d.dt_created,'HH:MM')#
#qDecoration.creator# <cfif len(qDecoration.creator_shortname)>(#qDecoration.creator_shortname#)</cfif>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Изменено
#dateFormat(d.dt_updated,'DD.MM.YYYY')# #timeFormat(d.dt_updated,'HH:MM')#
#qDecoration.updater# <cfif len(qDecoration.updater_shortname)>(#qDecoration.updater_shortname#)</cfif>
</div>
</div>
</div>
</cfoutput>
<layout:page section="extension" closeForm="Yes"/>
<cfif d.specification_id GT 0>
<cfquery name="qItem" datasource="#request.DS#">
select
i.specification_item_uid
,svc.svc_id
,svc.svc
,svc.code
,s.specification_id
,s.contract_id
<!--- ,i.price*i.quantity as cost --->
<!--- ,(select count(*) from svc_param sp where sp.svc_id=i.svc_id) as svc_param_count --->
,(select siv.agreement_version from specification_item_version siv
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
order by siv.agreement_version desc limit 1) as agreement_version
,(select a.agreement from specification_item_version siv
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
order by siv.agreement_version desc limit 1) as agreement
,(select a.dt_agreement from specification_item_version siv
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
order by siv.agreement_version desc limit 1) as dt_agreement
,(select siv.specification_item_version from specification_item_version siv
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
order by siv.agreement_version desc limit 1) as specification_item
,(select siv.quantity from specification_item_version siv
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
order by siv.agreement_version desc limit 1) as quantity
,(select siv.price from specification_item_version siv
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
order by siv.agreement_version desc limit 1) as price
,(select siv.dt_from from specification_item_version siv
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
order by siv.agreement_version desc limit 1) as dt_from
,(select siv.dt_to from specification_item_version siv
join agreement a on (siv.agreement_version=a.agreement_version AND a.contract_id=s.contract_id)
where siv.specification_item_uid=i.specification_item_uid AND a.is_actual
order by siv.agreement_version desc limit 1) as dt_to
,(select count(*) from specification_item_version siv where siv.specification_item_uid=i.specification_item_uid) as item_version_count
from specification_item i
join specification s on (i.specification_id=s.specification_id)
--left outer join ()
left outer join svc on (i.svc_id=svc.svc_id)
where i.specification_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.specification_id#"/>
order by 2
</cfquery>
<cfoutput>
<p>
Строки спецификации (#qItem.recordCount#)
<cfif pageInfo.writePermitted()>
<cfoutput>
<cfset addUrl="specification_item.cfm?specification_item_uid=&specification_id=#d.specification_id#&#tr.fwx#"/>
<button type="button" class="maincontrol" onclick="document.location.href='#addUrl#'">
<a href="#addUrl#">Создать</a>
</button>
</cfoutput>
</cfif>
</p>
</cfoutput>
<table class="worktable">
<thead>
<tr>
<th></th>
<th>Ключ строки</th>
<th>Услуга</th>
<th>Код услуги</th>
<th>Версий</th>
<th>&nbsp;</th>
<th>Тек. соглашение</th>
<th>Тек. версия</th>
<th>Дата с</th>
<th>Дата по</th>
<th>Количество</th>
<th>Цена</th>
<th>Имя для печати</th>
<!--- <th>Компонентов</th> --->
<th></th>
</tr>
</thead>
<cfoutput query="qItem">
<tr>
<td>
<c:link_view_edit canWrite=#pageInfo.writePermitted()# entity="specification_item" key="specification_item_uid" id=#specification_item_uid# fwx=#tr.fwx#/>
</td>
<td>#specification_item_uid#</td>
<td>#svc#</td>
<td>#code#</td>
<td class="c">#item_version_count#</td>
<td class="c"></td>
<td><a href="agreement.cfm?contract_id=#contract_id#&agreement_version=#agreement_version#&#tr.fwx#">#agreement# #dateFormat(dt_agreement,'DD.MM.YYYY')#</td>
<td class="c"><a href="specification_item_version.cfm?specification_item_uid=#specification_item_uid#&agreement_version=#agreement_version#&#tr.fwx#">#agreement_version#</a></td>
<td class="c">#dateFormat(dt_from,'DD.MM.YYYY')#</td>
<td class="c">#dateFormat(dt_to,'DD.MM.YYYY')#</td>
<td class="r">#quantity#</td>
<td class="r">#price#</td>
<td>#specification_item#</td>
<td class="c">
<c:link_del canWrite=#pageInfo.writePermitted()# entity="specification_item" key="specification_item_uid" id=#specification_item_uid# fwx=#tr.fwx#/>
</td>
</tr>
</cfoutput>
</table>
</cfif>
<layout:page section="footer"/>