338 lines
17 KiB
Plaintext
338 lines
17 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>
|
||
|
||
|
||
<!--- так... а у нас ключ составной, prepare_detail несколько сложнее --->
|
||
<cfparam name="specification_item_uid" type="guid"/>
|
||
<cfparam name="agreement_version" default=""/>
|
||
|
||
<m:prepare_detail
|
||
entity="specification_item_version"
|
||
key="undefined"
|
||
pageInfoOut="pageInfo"
|
||
thisUrl="#request.thisPage#?specification_item_uid=#specification_item_uid#&agreement_version=#agreement_version#"
|
||
defaultBackUrl="specification_item.cfm?specification_item_uid=#specification_item_uid#"
|
||
/>
|
||
<!--- ситуация
|
||
мы создаем новую строку спецификации и сразу ее версию - при этом у нас в контексте может быть известно текущее соглашение, и еще из него нужно взять dt_from по умолчанию
|
||
либо мы создаем новую версию строки, а текущая версия уже занята - тогда нужно создавать
|
||
НЕУДОБНО: когда мы меняем номер соглашения у версии строки, у нас не меняется версия, а создается новая --->
|
||
|
||
<cfquery name="qLastVersion">
|
||
select agreement_version, quantity, price, specification_item_version
|
||
from specification_item_version
|
||
where specification_item_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#specification_item_uid#" null=#!IsValid('guid',specification_item_uid)#/>
|
||
<cfif isValid('integer',agreement_version)>
|
||
AND agreement_version=<cfqueryparam cfsqltype="cf_sql_integer" value="#agreement_version#"/>
|
||
</cfif>
|
||
order by agreement_version desc limit 1
|
||
</cfquery>
|
||
<cfif qLastVersion.recordCount EQ 0>
|
||
<cfset queryAddRow(qLastVersion,[0,1,0,""])/>
|
||
</cfif>
|
||
|
||
<cfquery name="qAgreement">
|
||
select a.agreement, a.dt_agreement, a.contract_id
|
||
from specification_item si
|
||
join specification s on (si.specification_id=s.specification_id)
|
||
join agreement a on (s.contract_id=a.contract_id)
|
||
where si.specification_item_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#specification_item_uid#" null=#!IsValid('guid',specification_item_uid)#/>
|
||
<cfif isValid('integer',agreement_version)>
|
||
AND agreement_version=<cfqueryparam cfsqltype="cf_sql_integer" value="#agreement_version#"/>
|
||
</cfif>
|
||
order by a.agreement_version desc limit 1
|
||
</cfquery>
|
||
|
||
|
||
<d:bean readonly=#!pageInfo.writePermitted()# table="#pageInfo.entity#" datasource="#request.DS#" output="d" status="status">
|
||
<d:param field="specification_item_uid" type="guid" key/>
|
||
<d:param field="agreement_version" type="integer" key/> <!--- init=#qLastVersion.agreement_version# --->
|
||
|
||
<d:param field="specification_item_version" type="varchar" size="1023" init="#qLastVersion.specification_item_version#" preprocessor=#cleanInput#/><!--- неудачное название, это имя данной записи, перетирающее имя услуги из справочника --->
|
||
<d:param field="quantity" type="numeric" init=#qLastVersion.quantity#/>
|
||
<d:param field="price" type="numeric" init=#qLastVersion.price# preprocessor=#request.stripWhiteSpace#/>
|
||
<d:param field="dt_from" type="timestamp" format="yyyy-MM-dd" forNull="" init="#qAgreement.dt_agreement#"/> <!--- !!! Important yyyy-MM-dd NOT YYYY-MM-DD --->
|
||
<d:param field="dt_to" type="timestamp" format="yyyy-MM-dd" forNull="" init=""/> <!--- !!! Important yyyy-MM-dd NOT YYYY-MM-DD --->
|
||
|
||
<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=""
|
||
queryString="specification_item_uid=#d.specification_item_uid#&agreement_version=#d.agreement_version#"
|
||
defaultBackUrl="specification_item.cfm?specification_item_uid=#d.specification_item_uid#"
|
||
status=#pageInfo.status#
|
||
trackOut="tr"
|
||
idAttributesOut="id"
|
||
/>
|
||
|
||
<!--- контекст строки всегда известен при создании версии, полный ключ не нужен для него - соответственно, джойн с основной таблицей. При этом мы собираем неверсионную часть данных, а версионная образует параллельную ветку --->
|
||
<!--- можно обратить внимание на то, что это один джойн, который растет сверху вниз (возможно, ветвится), добавляются таблицы и поля. На самом деле джойны внешние только для удобства отладки - так ошибки виднее --->
|
||
<cfquery name="qSpecificationItem">
|
||
select i.svc_id, v.svc
|
||
,s.specification_id, s.specification, s.contract_id
|
||
,d.contract, d.dt_contract, d.contragent_id
|
||
,k.contragent
|
||
,i.pricing_model_id, p.pricing_model, p.pricing_model_short
|
||
|
||
from specification_item i
|
||
left join specification s on (i.specification_id=s.specification_id)
|
||
left join contract d on (s.contract_id=d.contract_id)
|
||
left join contragent k on (d.contragent_id=k.contragent_id)
|
||
left join svc v on (i.svc_id=v.svc_id)
|
||
left join pricing_model p on (i.pricing_model_id=p.pricing_model_id)
|
||
where i.specification_item_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.specification_item_uid#" null=#!IsValid('guid',d.specification_item_uid)#/>
|
||
</cfquery>
|
||
|
||
<cfquery name="qAgreement" datasource="#request.DS#">
|
||
select
|
||
iv.agreement_version, a.probability_perc, a.is_actual
|
||
from specification_item_version iv
|
||
join specification_item si on (iv.specification_item_uid=si.specification_item_uid)
|
||
join specification s on (si.specification_id=s.specification_id)
|
||
join agreement a on (iv.agreement_version=a.agreement_version and s.contract_id=a.contract_id)
|
||
where iv.specification_item_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.specification_item_uid#" null=#!isValid('guid', d.specification_item_uid)#/>
|
||
AND iv.agreement_version=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.agreement_version#" null=#!isValid('integer', d.agreement_version)#/>
|
||
</cfquery>
|
||
|
||
<cfquery name="qVersion" datasource="#request.DS#">
|
||
select
|
||
iv.agreement_version, a.probability_perc, a.is_actual
|
||
from specification_item_version iv
|
||
join specification_item si on (iv.specification_item_uid=si.specification_item_uid)
|
||
join specification s on (si.specification_id=s.specification_id)
|
||
join agreement a on (iv.agreement_version=a.agreement_version and s.contract_id=a.contract_id)
|
||
where iv.specification_item_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.specification_item_uid#" null=#!isValid('guid', d.specification_item_uid)#/>
|
||
order by 1
|
||
</cfquery>
|
||
|
||
|
||
<!--- decoration --->
|
||
<cfquery name="qDecoration">
|
||
select
|
||
a.login as creator, a.shortname as creator_shortname, m.login as updater, m.shortname as updater_shortname
|
||
from specification_item_version 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.specification_item_uid=<cfqueryparam cfsqltype="cf_sql_other" value=#d.specification_item_uid# null=#!isValid('guid',d.specification_item_uid)#/>
|
||
AND e.agreement_version=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.agreement_version#" null=#!isValid('integer',d.agreement_version)#/>
|
||
</cfquery>
|
||
|
||
</m:silent><!---
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
------------------------------------------------------------------------------------------------------------------------
|
||
---><layout:page section="header" pageInfo=#pageInfo#>
|
||
<layout:attribute name="title">
|
||
<cfoutput>
|
||
Версия строки спецификации
|
||
[#d.specification_item_uid#]:[#d.agreement_version#]
|
||
</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_item_uid" value="#d.specification_item_uid#"/>
|
||
<!--- <input type="hidden" name="agreement_version" value="#d.agreement_version#"/> --->
|
||
<input type="hidden" name="track" value="#tr.self#"/>
|
||
<input type="hidden" name="pass" value=""/><!--- pass marker to prevent save on submit --->
|
||
|
||
<div class="detail">
|
||
|
||
<layout:detail_line title="Спецификация">
|
||
<a href="specification.cfm?specification_id=#qSpecificationItem.specification_id#&#tr.fwx#">#qSpecificationItem.specification#[#qSpecificationItem.specification_id#]</a>
|
||
<a href="contract.cfm?contract_id=#qSpecificationItem.contract_id#&#tr.fwx#">#qSpecificationItem.contract# #dateFormat(qSpecificationItem.dt_contract,'DD.MM.YYYY')#</a>
|
||
<a href="contragent.cfm?contragent_id=#qSpecificationItem.contragent_id#&#tr.fwx#">#qSpecificationItem.contragent# </a>
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Строка">
|
||
<a href="specification_item.cfm?specification_item_uid=#d.specification_item_uid#&#tr.fwx#">#d.specification_item_uid#</a>
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Услуга">
|
||
<a href="svc.cfm?svc_id=#qSpecificationItem.svc_id#&#tr.fwx#">#qSpecificationItem.svc# [#qSpecificationItem.svc_id#]</a>
|
||
#qSpecificationItem.pricing_model_short# (#qSpecificationItem.pricing_model#)
|
||
</layout:detail_line>
|
||
|
||
<!--- <layout:detail_line title="Версия">#d.agreement_version# (версия-номер соглашения)</layout:detail_line> --->
|
||
<layout:detail_line title="Версия">
|
||
<cfquery name="qList" datasource="#request.DS#">
|
||
select a.agreement_version, a.agreement, a.dt_agreement, a.probability_perc
|
||
from agreement a
|
||
where a.contract_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#qSpecificationItem.contract_id#" null=#!isValid('integer',qSpecificationItem.contract_id)#/>
|
||
order by 1 desc
|
||
</cfquery>
|
||
<c:combo
|
||
query=#qList#
|
||
combo="agreement_version"
|
||
id="agreement_version"
|
||
key="agreement_version"
|
||
selected="#d.agreement_version#"
|
||
displayf="##agreement## [##agreement_version##] ##dateFormat(dt_agreement,'DD.MM.YYYY')## ##probability_perc##%"
|
||
class=""
|
||
/>
|
||
(версия-номер соглашения)
|
||
<!--- *** можно придумать коструктор ссылок с декоратором tr.fwx --->
|
||
<cfif d.agreement_version GE 0>
|
||
<a href="agreement.cfm?agreement_version=#d.agreement_version#&contract_id=#qSpecificationItem.contract_id#&#tr.fwx#">
|
||
#d.agreement_version# (#qAgreement.probability_perc#% <cfif qAgreement.is_actual GT 0><img src="img/ok.png"title="Действует"/></cfif>)
|
||
</a>
|
||
</cfif>
|
||
<a href="agreement.cfm?contract_id=#qSpecificationItem.contract_id#&#tr.fwx#">
|
||
<img src="img/add.gif"/>
|
||
</a>
|
||
ВАЖНО! Если нового соглашения нет, его нужно сначала создать (само не создается)
|
||
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Дата с">
|
||
<input type="date" name="dt_from" id="dt_from" value="#dateFormat(d.dt_from,"YYYY-MM-DD")#"/>
|
||
<button type="button" onclick="document.getElementById('dt_from').value='#DateFormat(Now(), 'YYYY-MM-DD')#';">Сегодня</button>
|
||
на макете мы пока собираем цепочки дат руками
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Дата по">
|
||
<input type="date" name="dt_to" id="dt_to" value="#dateFormat(d.dt_to,"YYYY-MM-DD")#"/>
|
||
<button type="button" onclick="document.getElementById('dt_to').value='#DateFormat(Now(), 'YYYY-MM-DD')#';">Сегодня</button>
|
||
<i>Если оставлено пустым, то версия действует до начала действия следующей. Заполнять, если хотим прекратить услугу постоянно или временно</i>
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Имя для печати">
|
||
<textarea name="specification_item_version" id="specification_item_version" rows="2" cols="90" style="width:99%;"/><cfif len(d.specification_item_version)>#d.specification_item_version#<cfelse>#qSpecificationItem.svc#</cfif></textarea>
|
||
<!--- <button type="button" onclick="document.getElementById('specification_item_version').value='';submit();">Сформировать</button> --->
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Количество">
|
||
<input type="text" name="quantity" value="#d.quantity#" size="7" class="r"/><!---*** Халява с точностью ---><!--- <cftry>#round(d.quantity,qService.precision)#<cfcatch type="ANY"></cfcatch></cftry> --->
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Цена">
|
||
<input type="text" name="price" id="price" value="#d.price#" size="7" class="r"/>
|
||
<cfif len(d.price)>
|
||
<cftry>
|
||
Стоимость: <b>#d.quantity*d.price#</b>
|
||
<cfcatch type="any"></cfcatch>
|
||
</cftry>
|
||
</cfif>
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Создано">
|
||
#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>
|
||
</layout:detail_line>
|
||
|
||
<layout:detail_line title="Версии">
|
||
<cfoutput query=#qVersion#>
|
||
<cfif qVersion.agreement_version EQ d.agreement_version>
|
||
<b>#agreement_version# (#qAgreement.probability_perc#% <cfif qAgreement.is_actual GT 0><img src="img/ok.png"title="Действует"/></cfif>)</b>
|
||
<cfelse>
|
||
<a href="specification_item_version.cfm?specification_item_uid=#d.specification_item_uid#&agreement_version=#agreement_version#&track=#tr.self#">#agreement_version# (#probability_perc#%
|
||
<cfif is_actual GT 0><img src="img/ok.png"title="Действует"/></cfif>)</a>
|
||
</cfif>
|
||
|
||
</cfoutput>
|
||
<i>номера соглашений, в которых данная строка изменялась</i>
|
||
</layout:detail_line>
|
||
|
||
</div>
|
||
|
||
</cfoutput>
|
||
|
||
<layout:page section="extension" closeForm="Yes"/>
|
||
|
||
<cfif len(d.specification_item_uid) AND d.agreement_version GT 0>
|
||
<!--- <cfoutput>
|
||
<p>
|
||
Компоненты (#qSpecificationItemParam.recordCount#)
|
||
<!---<cfif pageInfo.writePermitted()>
|
||
<cfoutput>
|
||
<cfset addUrl="specification_item_version_param.cfm?specification_item_version_param=-1&specification_item_version_id=#d.specification_item_version_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>
|
||
</tr>
|
||
</thead>
|
||
<cfoutput query="qSpecificationItemParam">
|
||
<tr>
|
||
<td>
|
||
<cfif specification_item_version_param_id GT 0>
|
||
<a href="specification_item_version_param.cfm?specification_item_version_param_id=#specification_item_version_param_id#&#tr.fwx#">
|
||
<img src="img/edit.gif"/>
|
||
</a>
|
||
</cfif>
|
||
<!--- <cfif NOT (specification_item_version_param_id GT 0)> --->
|
||
<a href="specification_item_version_param.cfm?service_param_id=#service_param_id#&specification_item_version_id=#d.specification_item_version_id#&#tr.fwx#">
|
||
<img src="img/add.gif"/>
|
||
</a>
|
||
</td>
|
||
<td>
|
||
<a href="service_param.cfm?service_param_id=#service_param_id#&#tr.fwx#">
|
||
#param_class# #param#
|
||
</a>
|
||
</td>
|
||
<td>#qService.abstract_service_code#.#qService.modifier_code#.#code#</td>
|
||
<td class="r"><!--- *** Халява --->
|
||
<cftry>#round(quantity,precision)#<cfcatch type="ANY"></cfcatch></cftry>
|
||
</td>
|
||
<td>#measure_short#</td>
|
||
<td class="r">#min_price#</td>
|
||
<td class="r">#price#</td>
|
||
<td class="c">
|
||
<cfif specification_item_version_param_id GT 0>
|
||
<c:link_del canWrite=#pageInfo.writePermitted()# entity="specification_item_version_param" id=#specification_item_version_param_id# fwx=#tr.fwx#/>
|
||
</cfif>
|
||
</td>
|
||
</tr>
|
||
</cfoutput>
|
||
</table> --->
|
||
|
||
</cfif>
|
||
Здесь могли бы быть компоненты (но мы их пока не запилили)
|
||
|
||
|
||
<layout:page section="footer"/>
|