354 lines
12 KiB
Plaintext
354 lines
12 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="contract" accessObject="" key="__id" pageInfoOut="pageInfo"/>
|
|
|
|
<d:bean readonly=true table="elma.aggrements" 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="company_uid" type="uuid"/>
|
|
<d:param field="date_of_aggrement" type="timestamp"/>
|
|
<d:param field="date_end_aggrement" 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#">
|
|
select
|
|
__name as contragent, id_klienta as wz
|
|
from elma.companies k
|
|
where k.__id=<cfqueryparam cfsqltype="cf_sql_other" value=#d.company_uid# null=#!isValid('guid',d.company_uid)#/>
|
|
</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#</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="contragent.cfm?__id=#d.company_uid#&#tr.fwx#">
|
|
#qDecoration.contragent# #qDecoration.wz# [#d.company_uid#]
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Дата договора</div>
|
|
<div class="td">#dateFmt(d.date_of_aggrement)#</div>
|
|
</div>
|
|
|
|
<div class="tr">
|
|
<div class="th">Дата окончания договора</div>
|
|
<div class="td">#dateFmt(d.date_end_aggrement)#</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</cfoutput>
|
|
|
|
<layout:page section="extension" closeForm="Yes"/>
|
|
|
|
<cfif len(d.__id)>
|
|
<cfquery name="qAdditionalAgreement">
|
|
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)
|
|
)
|
|
select
|
|
a.__id::text
|
|
,a.__name
|
|
,a.__index
|
|
,a.contract_uid::text
|
|
,a.is_actual
|
|
,a.last_aa
|
|
,a.index
|
|
,a.deal_uid::text
|
|
,a.base_by[1]::text as base_by_uid
|
|
,b.__name as base_by_name
|
|
,b.__index as base_by_index
|
|
,d.__name as deal
|
|
,d.__status_status as status_id
|
|
,s.status
|
|
,s.probability_pc
|
|
from elma.additional_agreements a
|
|
left outer join elma.deals d on (a.deal_uid=d.__id)
|
|
left outer join s on (d.__status_status=s.status_id)
|
|
left outer join elma.additional_agreements b on (a.base_by[1]=b.__id)
|
|
where a.contract_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid('guid',d.__id)#/>
|
|
order by 1
|
|
</cfquery>
|
|
|
|
<cfoutput>
|
|
<h4>Дополнительные соглашения (#qAdditionalAgreement.recordCount#)</h4>
|
|
</cfoutput>
|
|
<!--- <cfdump var=#qAdditionalAgreements#/> --->
|
|
<!--- <layout:render_query query=#qAdditionalAgreement#/> --->
|
|
<table class="worktable">
|
|
<thead>
|
|
<tr>
|
|
<th>__index</th>
|
|
<th>__id</th>
|
|
<th>__name</th>
|
|
<th>версия</th>
|
|
<!--- <th>contract_uid</th> --->
|
|
<th>is_actual</th>
|
|
<th>last_aa</th>
|
|
<th>deal_uid</th>
|
|
<th>deal</th>
|
|
<th>status_id</th>
|
|
<th>status</th>
|
|
<th>вер-ть</th>
|
|
<th>base_by_index</th>
|
|
<th>base_by_uid</th>
|
|
<th>base_by_name</th>
|
|
</tr>
|
|
</thead>
|
|
<cfoutput query="qAdditionalAgreement">
|
|
<tr>
|
|
|
|
<td><a href="additional_agreement.cfm?__id=#__id#&#tr.fwx#">#__index#</a></td>
|
|
<td><a href="additional_agreement.cfm?__id=#__id#&#tr.fwx#">#__id#</a></td>
|
|
<td>#__name#</td>
|
|
<td class="c">#index#</td>
|
|
<!--- <td>#contract_uid#</td> --->
|
|
<td class="c">#is_actual#</td>
|
|
<td class="c">#last_aa#</td>
|
|
<td><a href="deal.cfm?__id=#deal_uid#&#tr.fwx#">#deal_uid#</a></td>
|
|
<td>#deal#</td>
|
|
<td class="c">#status_id#</td>
|
|
<td>#status#</td>
|
|
<td class="r">#probability_pc#</td>
|
|
<td class="r"><a href="additional_agreement.cfm?__id=#base_by_uid#&#tr.fwx#">#base_by_index#</a></td>
|
|
<td><a href="additional_agreement.cfm?__id=#base_by_uid#&#tr.fwx#">#base_by_uid#</a></td>
|
|
<td><a href="additional_agreement.cfm?__id=#base_by_uid#&#tr.fwx#">#base_by_name#</a></td>
|
|
|
|
</tr>
|
|
</cfoutput>
|
|
</table>
|
|
|
|
<br/>
|
|
Мы не показываем тут сделки, поскольку связь со сделкой у договора не прямая и не обязательная. Сделки относятся к контрагенту, а не к договору. Сделка может быть связана с договором через дополнительное соглашение (включая нулевое соглашение, по умолчанию)
|
|
<!--- <cfquery name="qDeal">
|
|
select
|
|
d.__id
|
|
,d.__name
|
|
,d._companies
|
|
,d._plannedDueDate
|
|
,d.kommentarii_k_sdelke
|
|
,d.__status_notify
|
|
,d.__debug
|
|
,d.is_corrective_transaction
|
|
,d.dt_load
|
|
from elma.deals d limit 10
|
|
</cfquery> --->
|
|
|
|
<!--- ----------------------------------------------------- --->
|
|
<!--- ----------------------------------------------------- --->
|
|
<!--- ----------------------------------------------------- --->
|
|
|
|
<cfquery name="qService">
|
|
with
|
|
status(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)
|
|
)
|
|
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
|
|
,p.price
|
|
,p.cnt as p_cnt
|
|
,p.ed_izm
|
|
,p.code
|
|
,p.discount as p_discount
|
|
,p.__id as p_uid
|
|
,p.name
|
|
/*,(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)
|
|
AND p."__deletedAt" IS NULL
|
|
) as line_cost
|
|
,(select count(*)
|
|
from elma.service_parametrs p
|
|
where p.__id = ANY (siv.params)
|
|
AND p."__deletedAt" IS NULL
|
|
) as param_cnt*/
|
|
,s.probability_pc
|
|
,d.__index
|
|
,d.__id as deal_uid
|
|
from elma.deals_services siv
|
|
join elma.deals d on d.__id=ANY(siv.deal)
|
|
join status s on (d.__status_status=s.status_id)
|
|
join elma.service_parametrs p ON (p.__id = ANY (siv.params) AND p."__deletedAt" IS NULL)
|
|
left outer join elma.additional_agreements a on (a.__id=ANY(siv.additional_agreement))
|
|
where a.contract_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid('guid',d.__id)#/>
|
|
and siv.is_actual
|
|
and a.is_actual
|
|
order by siv.version::int
|
|
</cfquery>
|
|
|
|
<cfoutput>
|
|
<h4>Услуги (версии строк спецификации, только актуальные) (#qService.recordCount#) </h4>
|
|
</cfoutput>
|
|
|
|
<!--- <layout:render_query query=#qService#/> --->
|
|
<table class="worktable">
|
|
<thead>
|
|
<tr>
|
|
<th>__index</th>
|
|
<th>Код</th>
|
|
<th width="20%">user_description</th>
|
|
<th width="25%">Компоненты</th>
|
|
<th>Кол-во</th>
|
|
<th>Скидка</th>
|
|
<th width="5%">Сумма</th>
|
|
|
|
<th>type</th>
|
|
<th>is_actual</th>
|
|
<th>hash</th>
|
|
<th>version</th>
|
|
<th>name_version</th>
|
|
<th>date_accept</th>
|
|
<th>__index</th>
|
|
<th width="5%">date_nop</th>
|
|
<th width="5%">date_end</th>
|
|
<th>is_easy</th>
|
|
|
|
<th width="7%">additional_agreement</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<cfoutput query="qService" group="__index">
|
|
<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">
|
|
#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="l">#user_description#</td>
|
|
<td>
|
|
<table>
|
|
<cfset cost=0/>
|
|
<cfoutput group="p_uid">
|
|
<cfif p_cnt NEQ 0>
|
|
<tr>
|
|
<td class="nw">#code#</td>
|
|
<td>#name#</td>
|
|
<td>#p_cnt#</td>
|
|
<td>#ed_izm#</td>
|
|
<td class="r nw">#nFmt(price,3)#</td>
|
|
<td class="r">#p_discount#%</td>
|
|
</tr>
|
|
<cfset cost+=price*p_cnt*(100-(isNumeric(p_discount)?p_discount:0))/100 />
|
|
</cfif>
|
|
</cfoutput>
|
|
</table>
|
|
</td>
|
|
<td class="c">#cnt#</td>
|
|
<td class="c">#discount#%</td>
|
|
<td class="r">#nFmt(cost*cnt*(100-(isNumeric(discount)?discount:0))/100)#</td>
|
|
|
|
<td class="c">#type#</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">#__index#</td>
|
|
<td class="c">#dateFormat(date_nop,'YYYY-MM-DD')#</td>
|
|
<td class="c">#dateFormat(date_end,'YYYY-MM-DD')#</td>
|
|
<td class="c">#is_easy#</td>
|
|
|
|
<!--- <td class="c">#additional_agreement_uid#</td> --->
|
|
<td><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td>
|
|
</tr>
|
|
</cfoutput>
|
|
</table>
|
|
|
|
</cfif><!--- len(d.__id) --->
|
|
|
|
|
|
<layout:page section="footer"/> |