328 lines
13 KiB
Plaintext
328 lines
13 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>
|
||
|
||
<m:prepare_detail entity="specification" key="specification_id" pageInfoOut="pageInfo"/>
|
||
|
||
<d:bean readonly=#!pageInfo.writePermitted()# table="#pageInfo.entity#" 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>
|
||
|
||
</m:silent><!---
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
---><layout:page section="header" pageInfo=#pageInfo#>
|
||
<layout:attribute name="title">
|
||
<cfoutput>
|
||
Спецификация
|
||
<cfif d.specification_id GT 0>
|
||
<b>#d.specification#</b>
|
||
[#d.specification_id#]
|
||
</cfif>
|
||
</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">
|
||
<input type="text" name="specification" value="#d.specification#" size="70"/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">Договор</div>
|
||
<div class="td">
|
||
<cfquery name="qList" datasource="#request.DS#">
|
||
select c.contract_id, c.contract, c.dt_contract
|
||
from contract c
|
||
order by 1
|
||
</cfquery>
|
||
<c:combo
|
||
query=#qList#
|
||
combo="contract_id"
|
||
id="contract_id"
|
||
key="contract_id"
|
||
selected="#d.contract_id#"
|
||
displayf="##contract## ##dateFormat(dt_contract,'DD.MM.YYYY')##"
|
||
empty=""
|
||
class=""
|
||
<!---onchange="submit();"--->
|
||
/>
|
||
<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">
|
||
<textarea name="descr" rows="3" cols="100">#request.htm2plain(d.descr)#</textarea>
|
||
</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>
|
||
|
||
</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> </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>
|
||
|
||
Как сущности версии спецификации нет.
|
||
Можно синтезировать версию спецификации на произвольную дату, а можно по версии определенного соглашения (это должно быть возмозно, потому что соглашение меняет каждую строку не более 1 раза
|
||
)
|
||
Спецификация по версии соглашения не учитывает is_actual этого соглашения, но учитывает предыдущие
|
||
*** Собственно, нам нужно для илюстрации версионности как раз синтезировать спецификацию на дату и спецификацию по версии согдашения
|
||
|
||
|
||
|
||
|
||
|
||
<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#"/>
|
||
/*AND exists (
|
||
select * from specification_item si
|
||
join specification_item_version iv on (si.specification_item_uid=iv.specification_item_uid)
|
||
where si.specification_id=s.specification_id
|
||
AND iv.agreement_version=a.agreement_version
|
||
)*/
|
||
order by 2
|
||
</cfquery>
|
||
|
||
<cfoutput>
|
||
<p>
|
||
Версии (#qVersion.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>
|
||
</tr>
|
||
</thead>
|
||
<cfoutput query="qVersion">
|
||
<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>#agreement#</td>
|
||
<td class="c">#dateFormat(dt_agreement,'DD.MM.YYYY')#</td>
|
||
<td class="c"><a href="specification_version.cfm?specification_id=#specification_id#&agreement_version=#agreement_version#&#tr.fwx#">#agreement_version#</a></td>
|
||
<td class="c">#changed_item_cnt#</td>
|
||
</tr>
|
||
</cfoutput>
|
||
</table>
|
||
</cfif>
|
||
|
||
|
||
<layout:page section="footer"/>
|