317 lines
10 KiB
Plaintext
317 lines
10 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="deal" accessObject="" key="__id" pageInfoOut="pageInfo"/>
|
|
|
|
<d:bean readonly=true table="elma.deals" datasource="#request.DS#" output="d" status="status">
|
|
<d:param field="__id" type="uuid" key/>
|
|
<d:param field="__name" type="varchar" size="255" preprocessor=#cleanInput# forNull=""/>
|
|
<d:param field="_companies" type="uuid" forNull=""/>
|
|
<!--- <d:param field="_plannedDueDate" type="timestamp" forNull=""/> ---><!--- *** не используем, потому что имя в смешанном регистре --->
|
|
<d:param field="__index" type="integer" forNull="" default="0" init="0"/>
|
|
<d:param field="__status_status" type="integer" forNull="" default="0" init="0"/>
|
|
<d:param field="is_corrective_transaction" type="bit" forNull=""/>
|
|
<d:param field="dt_load" type="timestamp"/>
|
|
</d:bean>
|
|
|
|
|
|
<m:dispatch_detail
|
|
usePRG="No"<!---*** --->
|
|
pageInfo=#pageInfo#
|
|
id="#d.__id#"
|
|
status=#pageInfo.status#
|
|
trackOut="tr"
|
|
idAttributesOut="id"
|
|
/>
|
|
|
|
<!--- decoration --->
|
|
<cfquery name="qDecoration" datasource="#request.DS#">
|
|
with
|
|
s(status, status_id, probability_pc) as (VALUES
|
|
('Закрыта неуспешно',7,0),('Закрыта успешно',6,100),('Договор подписан',5,100),('Договор на подписании',15,90),('Договор на согласовании',12,70),
|
|
('Тестирование',8,50),('Отправлено ТКП',10,20),('Внутреннее согласование',37,10),('Проработка решения',4,10),('Сбор потребностей',1,0)
|
|
),
|
|
component as (select siv.deal as deal_uids, siv.type, (siv.cnt*(100-COALESCE(siv.discount,0))/100*p.price*p.cnt*(100-COALESCE(p.discount,0))) as param_cost
|
|
from elma.deals_services siv
|
|
join elma.service_parametrs p on (p.__id = ANY(siv.params))
|
|
)
|
|
|
|
select
|
|
k.__name as contragent
|
|
,k.id_klienta as wz
|
|
,k.__index as contragent_index
|
|
,d."_plannedDueDate" as _plannedDueDate
|
|
,d."__createdAt"
|
|
,d."__index" as deal_index
|
|
,s.status
|
|
,s.probability_pc
|
|
,c.__name as owner
|
|
,(select sum(param_cost)
|
|
from component
|
|
where d.__id = ANY(component.deal_uids) AND component.type IN (1)
|
|
) as install
|
|
,(select sum(param_cost)
|
|
from component
|
|
where d.__id = ANY(component.deal_uids) AND component.type IN (2)
|
|
) as periodical
|
|
,(select sum(param_cost)
|
|
from component
|
|
where d.__id = ANY(component.deal_uids) AND component.type IN (3)
|
|
) as metered
|
|
from elma.deals d
|
|
left outer join elma.companies k on (d._companies=k.__id)
|
|
left outer join elma.comp_users_ext c on (d._owner=c.__id)
|
|
left outer join s on (d.__status_status=s.status_id)
|
|
where d.__id=<cfqueryparam cfsqltype="cf_sql_other" value=#d.__id# null=#!isValid("guid",d.__id)#/>
|
|
</cfquery>
|
|
|
|
|
|
</m:silent><!---
|
|
------------------------------------------------------------------------------------------------------------------------
|
|
------------------------------------------------------------------------------------------------------------------------
|
|
------------------------------------------------------------------------------------------------------------------------
|
|
------------------------------------------------------------------------------------------------------------------------
|
|
------------------------------------------------------------------------------------------------------------------------
|
|
---><layout:page section="header" pageInfo=#pageInfo#>
|
|
<layout:attribute name="title">
|
|
<cfoutput>
|
|
Сделка
|
|
<cfif len(d.__id)>
|
|
<b>#d.__name#</b>
|
|
[#d.__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="__id" value="#d.__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">__id</div>
|
|
<div class="td">
|
|
#d.__id#
|
|
index:#qDecoration.deal_index#
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Название</div>
|
|
<div class="td">#d.__name#</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Контрагент</div>
|
|
<div class="td"><!--- <a href="contract.cfm?__id=#d.contract_uid#&#tr.fwx#"><b>#qDecoration.contract#</b> #dateFormat(qDecoration.date_of_aggrement,'DD.MM.YYYY')#
|
|
[#d.contract_uid#]</a> --->
|
|
<a href="contragent.cfm?__id=#d._companies#&#tr.fwx#"> #qDecoration.contragent# #qDecoration.wz#
|
|
index:#qDecoration.contragent_index#</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">_plannedDueDate</div>
|
|
<div class="td">#dateFormat(qDecoration._plannedDueDate,'YYYY-MM-DD')#
|
|
Паразитное поле, не использовать в расчетах
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Статус</div>
|
|
<div class="td">
|
|
#d.__status_status#: #qDecoration.status# (#qDecoration.probability_pc#%)
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Доп.соглашение</div>
|
|
<div class="td">
|
|
<cfquery name="qAgreement">
|
|
select
|
|
a.__id
|
|
,a.__name
|
|
,g.__id as contract_uid
|
|
,g.__name as contract
|
|
,g.date_of_aggrement
|
|
from elma.additional_agreements a
|
|
join elma.aggrements g on (a.contract_uid=g.__id)
|
|
where a.deal_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid("guid",d.__id)#/>
|
|
</cfquery>
|
|
<cfloop query=#qAgreement#>
|
|
<a href="additional_agreement.cfm?__id=#__id#&#tr.fwx#" title="доп.соглашение">#__name#</a>
|
|
<a href="contract.cfm?__id=#contract_uid#&#tr.fwx#" title="договор">#contract# #dateFmt(date_of_aggrement)#</a>
|
|
</cfloop>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">is_corrective_transaction</div>
|
|
<div class="td">#d.is_corrective_transaction#</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">dt_load</div>
|
|
<div class="td">#dateTimeFormat(d.dt_load,"yyyy-MM-dd HH:nn:ss.SSSZ")#</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">__createdAt</div>
|
|
<div class="td">#dateFormat(qDecoration.__createdAt,"YYYY-MM-DD")#</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Ответственный</div>
|
|
<div class="td">#qDecoration.owner#</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Инсталл</div>
|
|
<div class="td">#numFmt(qDecoration.install,2)#</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Ежемес</div>
|
|
<div class="td">#numFmt(qDecoration.periodical,2)#</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Тарифицируемые</div>
|
|
<div class="td">#numFmt(qDecoration.metered,2)#</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</cfoutput>
|
|
|
|
<layout:page section="extension" closeForm="Yes"/>
|
|
|
|
<cfif len(d.__id)>
|
|
<cfquery name="qService">
|
|
select
|
|
siv.__id
|
|
,siv.__name
|
|
,siv.user_description
|
|
,siv.discount
|
|
,siv.cnt
|
|
,siv.modifier_code
|
|
,siv.abstractive_service_code
|
|
,siv.is_actual
|
|
,siv.type
|
|
,siv.hash
|
|
,siv.version
|
|
,siv.name_version
|
|
,siv.date_accept
|
|
,siv.__index
|
|
,siv.date_nop
|
|
,siv.date_end
|
|
,siv.is_easy
|
|
,siv.params::text
|
|
,a.__id::text as additional_agreement_uid
|
|
,a.__name as additional_agreement
|
|
,(select
|
|
sum(siv.cnt*(100-COALESCE(siv.discount,0))/100*p.price*p.cnt*(100-COALESCE(p.discount,0))/100)
|
|
from elma.service_parametrs p
|
|
where p.__id = ANY (siv.params)
|
|
) as line_cost
|
|
,(select count(*)
|
|
from elma.service_parametrs p
|
|
where p.__id = ANY (siv.params)
|
|
) as param_cnt
|
|
from elma.deals_services siv
|
|
left outer join elma.additional_agreements a on (a.__id=ANY(siv.additional_agreement))
|
|
where <cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid("guid",d.__id)#/>=ANY(siv.deal)
|
|
and siv.is_actual
|
|
order by version::int
|
|
</cfquery>
|
|
|
|
<cfoutput>
|
|
<h4>Услуги (версии строк спецификации, только актуальные) (#qService.recordCount#)</h4>
|
|
</cfoutput>
|
|
|
|
<!--- <layout:render_query query=#qService#/> --->
|
|
<table class="worktable">
|
|
<thead>
|
|
<tr>
|
|
<th>__index</th>
|
|
<!--- <th>__name</th> --->
|
|
<th width="12%">user_description</th>
|
|
<th>Кол-во</th>
|
|
<th>Скидка%</th>
|
|
<th width="5%">Сумма</th>
|
|
<th>Код</th>
|
|
<th>type</th>
|
|
<th>is_actual</th>
|
|
<th>hash</th>
|
|
<th>version</th>
|
|
<th>name_version</th>
|
|
<th>date_accept</th>
|
|
<th width="5%">date_nop</th>
|
|
<th width="5%">date_end</th>
|
|
<th>is_easy</th>
|
|
<th>Компонентов</th>
|
|
<th width="12%">additional_agreement</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<cfoutput query="qService">
|
|
<tr>
|
|
<td class="c"><a href="deal_service.cfm?__id=#__id#&#tr.fwx#" title="__id">#__index#</a></td>
|
|
<!--- <td class="c">#__name#</td> --->
|
|
<td class="l">#user_description#</td>
|
|
<td class="c">#cnt#</td>
|
|
<td class="c">#discount#</td>
|
|
<td class="r">#nFmt(line_cost)#</td>
|
|
<td class="l">
|
|
#abstractive_service_code#.#modifier_code#<!--- <cfswitch expression=#type#>
|
|
<cfcase value=1>-i</cfcase>
|
|
<cfcase value=2>-f</cfcase>
|
|
<cfcase value=3>-m</cfcase>
|
|
</cfswitch> --->
|
|
</td>
|
|
<td class="c">#type# (<cfswitch expression=#type#>
|
|
<cfcase value=1>i</cfcase>
|
|
<cfcase value=2>f</cfcase>
|
|
<cfcase value=3>m</cfcase>
|
|
</cfswitch>)</td>
|
|
<td class="c">#is_actual#</td>
|
|
<td class="c">#hash#</td>
|
|
<td class="c">#version#</td>
|
|
<td class="c">#name_version#</td>
|
|
<td class="c">#date_accept#</td>
|
|
<td class="c">#dateFormat(date_nop,'YYYY-MM-DD')#</td>
|
|
<td class="c">#dateFormat(date_end,'YYYY-MM-DD')#</td>
|
|
<td class="c"><cfif is_easy GT 0>Простая<cfelseif is_easy EQ 0>Композитная<cfelse>is_easy=#is_easy#</cfif></td>
|
|
<td class="c">#param_cnt#</td>
|
|
|
|
<!--- <td class="c">#additional_agreement_uid#</td> --->
|
|
<td class="c"><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td>
|
|
</tr>
|
|
</cfoutput>
|
|
</table>
|
|
</cfif>
|
|
|
|
|
|
<layout:page section="footer"/> |