245 lines
9.2 KiB
Plaintext
245 lines
9.2 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="hideNonPositive">
|
||
<cfargument name="a"/>
|
||
<cfreturn (a GT 0)? a : ""/>
|
||
</cffunction>
|
||
|
||
<cffunction name="_nFmt">
|
||
<cfargument name="n"/>
|
||
<cfif n EQ 0 OR !isNumeric(n)>
|
||
<cfreturn "">
|
||
<cfelse>
|
||
<cfreturn replace(NumberFormat(n, ",.00"), ",", " ", "ALL")/>
|
||
</cfif>
|
||
</cffunction>
|
||
|
||
<m:prepare_ls entity="specification_item" accessObject="" 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.specification_item_class_type like ?) OR (p.division like ?) OR (p.performer_short like ?))" default=""/>
|
||
</m:filter_settings> --->
|
||
<!--- <cfset pageInfo.settings.filter=#filter#/> --->
|
||
|
||
|
||
<cfquery name="qRead" datasource="#request.DS#">
|
||
select
|
||
--install
|
||
siv.dt_from
|
||
,siv.dt_to
|
||
,a.probability_perc
|
||
,a.agreement_version
|
||
,a.is_actual
|
||
,(siv.price*siv.quantity) as install
|
||
|
||
,siv0.dt_from as dt_from_prev
|
||
,siv0.dt_to as dt_to_prev
|
||
,a0.probability_perc as probability_perc_prev
|
||
,a0.agreement_version as agreement_version_prev
|
||
,a0.is_actual as is_actual_prev
|
||
,(siv0.price*siv0.quantity) as install_prev
|
||
|
||
,0 as recurring
|
||
,0 as recurring_prev
|
||
|
||
,svc.svc
|
||
,siv.quantity
|
||
,siv.price
|
||
,s.specification
|
||
,s.contract_id
|
||
,d.contract
|
||
,d.dt_contract
|
||
,k.contragent
|
||
|
||
from specification_item_version siv /*on (dayscale.dt=siv.dt_from)*/
|
||
join specification_item si on (siv.specification_item_uid=si.specification_item_uid AND si.pricing_model_id in (1))
|
||
join specification s on (si.specification_id=s.specification_id)
|
||
join agreement a on (s.contract_id=a.contract_id AND siv.agreement_version=a.agreement_version AND 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=si.specification_item_uid
|
||
--AND ia.is_actual
|
||
))
|
||
join contract d on s.contract_id=d.contract_id
|
||
join contragent k on d.contragent_id=k.contragent_id
|
||
join svc on (si.svc_id=svc.svc_id)
|
||
|
||
left outer join agreement a0 on (s.contract_id=a0.contract_id AND siv.agreement_version=a0.agreement_version AND a0.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=si.specification_item_uid
|
||
AND ia.agreement_version < a.agreement_version
|
||
AND ia.is_actual
|
||
))
|
||
left outer join specification_item_version siv0 on (siv0.specification_item_uid=si.specification_item_uid
|
||
AND siv0.agreement_version=a0.agreement_version)
|
||
where 1=1 <m:filter_build filter=#pageInfo.settings.filter#/>
|
||
|
||
|
||
union all
|
||
|
||
--fix and payg
|
||
select
|
||
siv.dt_from
|
||
,siv.dt_to
|
||
,a.probability_perc
|
||
,a.agreement_version
|
||
,a.is_actual
|
||
,0
|
||
,siv0.dt_from
|
||
,siv0.dt_to
|
||
,a0.probability_perc
|
||
,a0.agreement_version
|
||
,a0.is_actual
|
||
,0
|
||
,siv.price*siv.quantity
|
||
,siv0.price*siv0.quantity
|
||
|
||
,svc.svc
|
||
,siv.quantity
|
||
,siv.price
|
||
|
||
,s.specification
|
||
,s.contract_id
|
||
,d.contract
|
||
,d.dt_contract
|
||
,k.contragent
|
||
from specification_item_version siv /*on (dayscale.dt >= siv.dt_from AND (siv.dt_to >= dayscale.dt OR siv.dt_to IS NULL))*/
|
||
join specification_item si on (siv.specification_item_uid=si.specification_item_uid AND si.pricing_model_id in (2,3))
|
||
join specification s on (si.specification_id=s.specification_id )
|
||
join agreement a on (s.contract_id=a.contract_id AND siv.agreement_version=a.agreement_version AND 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=si.specification_item_uid
|
||
--AND ia.is_actual
|
||
))
|
||
join contract d on s.contract_id=d.contract_id
|
||
join contragent k on d.contragent_id=k.contragent_id
|
||
join svc on (si.svc_id=svc.svc_id)
|
||
left outer join agreement a0 on (s.contract_id=a0.contract_id /*AND siv.agreement_version=a0.agreement_version*/ AND a0.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=si.specification_item_uid
|
||
AND ia.agreement_version < a.agreement_version
|
||
AND ia.is_actual
|
||
))
|
||
left outer join specification_item_version siv0 on (siv0.specification_item_uid=si.specification_item_uid
|
||
AND siv0.agreement_version=a0.agreement_version)
|
||
where 1=1 <m:filter_build filter=#pageInfo.settings.filter#/>
|
||
|
||
order by 1
|
||
|
||
</cfquery>
|
||
<!--- <cfdump var=#pageInfo.settings.filter#/> --->
|
||
|
||
|
||
|
||
|
||
<!--- <cfquery name="qCountTotal" datasource="#request.DS#">
|
||
select count(*) as cnt from specification_item 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>Актуальные версии, развернутые во времени</b></cfoutput>
|
||
</layout:attribute>
|
||
<!--- <layout:attribute name="controls">
|
||
skip filter link, filter is not implemented
|
||
<layout:language_switch/>
|
||
</layout:attribute> --->
|
||
</layout:page>
|
||
|
||
<cfif pageInfo.readPermitted() AND !pageInfo.status.errorState>
|
||
|
||
|
||
|
||
<div style="display:inline-block; width:30%; vertical-align:top;">
|
||
<cfoutput><b>#qRead.recordCount#</b> записей</cfoutput>
|
||
<a href="?output_xls" title="экспорт в Excel" style="margin:.5em; height:100%;" target="_blank"><img src="img/xls.gif" style="vertical-align:text-bottom;"/></a>
|
||
<a href="?output_json" title="экспорт в json" style="margin:.5em; height:100%;" target="_blank"><img src="img/json.svg" style="vertical-align:text-bottom;" width="13" height="13"/></a>
|
||
<br/>
|
||
Дни и месяцы с нулевой суммой не показаны
|
||
<table class="worktable wide">
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>Дата c</th>
|
||
<th>Дата по</th>
|
||
<th>Вер-ть</th>
|
||
<th>v</th>
|
||
<th>Инсталл</th>
|
||
<th>Ежемес</th>
|
||
|
||
<th>Дата c пред.</th>
|
||
<th>Дата по пред.</th>
|
||
<th>Вер-ть пред.</th>
|
||
<th>v</th>
|
||
<th>Инсталл пред.</th>
|
||
<th>Ежемес пред.</th>
|
||
|
||
<th>Услуга</th>
|
||
<th>Кол-во</th>
|
||
<th>Цена</th>
|
||
<th>Спецификация</th>
|
||
<th>Договор</th>
|
||
<th>Дата договора</th>
|
||
<th>Клиент</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<cfoutput query="qRead">
|
||
<tr>
|
||
<td class="c">#dateFormat(dt_from,"DD.MM.YYYY")#</td>
|
||
<td class="c">#dateFormat(dt_to,"DD.MM.YYYY")#</td>
|
||
<td class="r">#probability_perc#</td>
|
||
<!--- <td class="r">#agreement_version#</td> --->
|
||
<td class="r"><a href="agreement.cfm?contract_id=#contract_id#&agreement_version=#agreement_version#&#tr.fwx#">#agreement_version#</a></td>
|
||
<td class="r">#_nFmt(install)#</td>
|
||
<td class="r">#_nFmt(recurring)#</td>
|
||
|
||
<td class="c">#dateFormat(dt_from_prev,"DD.MM.YYYY")#</td>
|
||
<td class="c">#dateFormat(dt_to_prev,"DD.MM.YYYY")#</td>
|
||
<td class="r">#probability_perc_prev#</td>
|
||
<td class="r"><a href="agreement.cfm?contract_id=#contract_id#&agreement_version=#agreement_version_prev#&#tr.fwx#">#agreement_version_prev#</a></td>
|
||
<td class="r">#_nFmt(install_prev)#</td>
|
||
<td class="r">#_nFmt(recurring_prev)#</td>
|
||
|
||
<td class="r">#svc#</td>
|
||
<td class="r">#quantity#</td>
|
||
<td class="r">#_nFmt(price)#</td>
|
||
<td class="r">#specification#</td>
|
||
<td class="r">#contract#</td>
|
||
<td class="r">#dateFormat(dt_contract,'DD.MM.YYYY')#</td>
|
||
<td class="r">#contragent#</td>
|
||
</tr>
|
||
</cfoutput>
|
||
|
||
</table>
|
||
</div>
|
||
|
||
|
||
|
||
</cfif>
|
||
<layout:page section="footer"/>
|