314 lines
11 KiB
Plaintext
314 lines
11 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">
|
||
|
||
<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"
|
||
queryString="specification_id=#specification_id#&agreement_version=#agreement_version#"
|
||
/>
|
||
<!--- <cfdump var=#tr#/> --->
|
||
|
||
<!--- 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, a.is_actual
|
||
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>
|
||
|
||
<cfquery name="qVersion" datasource="#request.DS#">
|
||
select
|
||
a.agreement
|
||
,a.dt_agreement
|
||
,a.agreement_version
|
||
,a.is_actual
|
||
,(select count(*) from specification_item si
|
||
join specification_item_version iv on (si.specification_item_uid=iv.specification_item_uid)
|
||
where si.specification_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.specification_id#"/>
|
||
AND iv.agreement_version=a.agreement_version
|
||
) as changed_item_cnt
|
||
from agreement a
|
||
where a.contract_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.contract_id#"/>
|
||
order by a.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">
|
||
<cfoutput>
|
||
<button type="button" name="close" class="maincontrol" onClick="document.location.href='#tr.backUrl#'">
|
||
Закрыть
|
||
</button>
|
||
</cfoutput>
|
||
</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# [#d.specification_id#]
|
||
</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>
|
||
|
||
Изменено
|
||
#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 class="tr">
|
||
<div class="th">Версии</div>
|
||
<div class="td">
|
||
<cfoutput query=#qVersion#>
|
||
<cfif qVersion.agreement_version EQ qAgreement.agreement_version>
|
||
<b>#agreement_version#</b>
|
||
<cfelse>
|
||
<a href="specification_version.cfm?specification_id=#specification_id#&agreement_version=#agreement_version#&track=#tr.self#">#agreement_version#</a>
|
||
</cfif>
|
||
|
||
</cfoutput>
|
||
</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::text as specification_item_uid
|
||
,svc.svc_id
|
||
,svc.svc
|
||
,svc.code
|
||
,s.specification_id
|
||
,s.contract_id
|
||
,(select count(*) from specification_item_version siv where siv.specification_item_uid=i.specification_item_uid) as item_version_count
|
||
,ver.agreement_version
|
||
,ver.specification_item_uid
|
||
,ver.agreement
|
||
,ver.dt_agreement
|
||
,ver.is_actual
|
||
,ver.specification_item_version as specification_item
|
||
,ver.quantity
|
||
,ver.price
|
||
,ver.dt_from
|
||
,ver.dt_to
|
||
from specification_item i
|
||
join specification s on (i.specification_id=s.specification_id)
|
||
join (select
|
||
siv.agreement_version
|
||
,siv.specification_item_uid
|
||
,a.agreement
|
||
,a.contract_id
|
||
,a.dt_agreement
|
||
,a.is_actual
|
||
,siv.specification_item_version
|
||
,siv.quantity
|
||
,siv.price
|
||
,siv.dt_from
|
||
,siv.dt_to
|
||
,ii1.specification_id
|
||
from specification_item_version siv
|
||
join specification_item ii1 on (siv.specification_item_uid=ii1.specification_item_uid)
|
||
join specification is1 on (ii1.specification_id=is1.specification_id)
|
||
join agreement a on (siv.agreement_version=a.agreement_version AND is1.contract_id=a.contract_id)
|
||
where a.agreement_version = (select max(iiv.agreement_version)
|
||
from specification_item_version iiv
|
||
join specification_item ii on (iiv.specification_item_uid=ii.specification_item_uid)
|
||
join specification isp on (ii.specification_id=isp.specification_id)
|
||
join agreement ia on (isp.contract_id=ia.contract_id AND iiv.agreement_version=ia.agreement_version)
|
||
where iiv.specification_item_uid=siv.specification_item_uid
|
||
<!--- <cfif qAgreement.is_actual GT 0> --->
|
||
AND ia.is_actual
|
||
<!--- </cfif> --->
|
||
AND ia.agreement_version <= <cfqueryparam cfsqltype="cf_sql_integer" value="#agreement_version#"/>
|
||
)
|
||
) ver on (i.specification_item_uid=ver.specification_item_uid AND s.contract_id=ver.contract_id AND ver.specification_id=s.specification_id)
|
||
|
||
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>
|
||
|
||
<!--- <cfdump var=#qItem#/> --->
|
||
|
||
<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> </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=#qItem.agreement_version#&#tr.fwx#">#qItem.agreement_version#</a> <cfif is_actual><img src="img/ok.png"/></cfif></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>
|
||
<br/>
|
||
учитываются только действующие соглашения
|
||
|
||
</cfif>
|
||
|
||
|
||
<layout:page section="footer"/>
|