360 lines
13 KiB
Plaintext
360 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="contragent" accessObject="" key="contragent_id" pageInfoOut="pageInfo"/>
|
||
|
||
<d:bean readonly=true table="elma.companies" 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="_inn" type="varchar" size="255" preprocessor=#cleanInput# forNull=""/>
|
||
<d:param field="_kpp" type="varchar" size="255" preprocessor=#cleanInput# forNull=""/>
|
||
<d:param field="id_klienta" type="varchar" size="255" preprocessor=#cleanInput# forNull=""/>
|
||
<!--- *** билдер показывает... <d:param field="wz_id" type="varchar" size="255" preprocessor=#cleanInput# forNull=""/> --->
|
||
<!--- <d:param field="code_inn" type="varchar" size="255" preprocessor=#cleanInput# forNull=""/>
|
||
<d:param field="code_kpp" type="varchar" size="255" preprocessor=#cleanInput# forNull=""/> --->
|
||
</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
|
||
a.login as creator, a.shortname as creator_shortname, m.login as updater, m.shortname as updater_shortname
|
||
from contragent g
|
||
left outer join usr a on (g.creator_id=a.usr_id)
|
||
left outer join usr m on (g.updater_id=m.usr_id)
|
||
where g.contragent_id=<cfqueryparam attributeCollection=#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#</div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">__name</div>
|
||
<div class="td">#d.__name#</div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">_inn</div>
|
||
<div class="td">#d._inn#</div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">_kpp</div>
|
||
<div class="td">#d._kpp#</div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">id_klienta</div>
|
||
<div class="td">#d.id_klienta#</div>
|
||
</div>
|
||
|
||
<!--- <div class="tr">
|
||
<div class="th">wz_id</div>
|
||
<div class="td">#d.wz_id#"/></div>
|
||
</div> --->
|
||
|
||
<!--- <div class="tr">
|
||
<div class="th">code_inn</div>
|
||
<div class="td">#d.code_inn#"/></div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">code_kpp</div>
|
||
<div class="td">#d.code_kpp#"/></div>
|
||
</div> --->
|
||
|
||
</div>
|
||
|
||
</cfoutput>
|
||
сюда добавить сделок, договоров и т.д.
|
||
|
||
<layout:page section="extension" closeForm="Yes"/>
|
||
|
||
<cfif len(d.__id)>
|
||
|
||
<cfquery name="qContract">
|
||
select
|
||
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
|
||
<d:field title="ID" cfSqlType="CF_SQL_OTHER">d.__id</d:field>
|
||
<d:field title="Внут.номер">d.agreement_id</d:field>
|
||
<d:field title="Договор">d.__name</d:field>
|
||
<d:field title="company_uid">d.company_uid</d:field>
|
||
<d:field title="Дата договора">d.date_of_aggrement</d:field>
|
||
<d:field title="Дата окончания">d.date_end_aggrement</d:field>
|
||
<d:field title="Тип договора">d.type_of_agreement</d:field>
|
||
<d:field title="__index">d.__index</d:field>
|
||
</d:field_set>
|
||
from elma.aggrements d
|
||
where d.company_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid('guid',d.__id)#/>
|
||
</cfquery>
|
||
|
||
<cfoutput>
|
||
<h4>Договоры (#qContract.recordCount#)</h4>
|
||
</cfoutput>
|
||
|
||
<table class="worktable">
|
||
<thead>
|
||
<tr>
|
||
<th>__id</th>
|
||
<th>Номер</th>
|
||
<th>Внут. номер</th>
|
||
<th>Дата</th>
|
||
<th>Дата оконч.</th>
|
||
<th>Тип договора</th>
|
||
</tr>
|
||
</thead>
|
||
<cfoutput query="qContract">
|
||
<tr>
|
||
<td><a href="contract.cfm?__id=#__id#&#tr.fwx#">#__id#</a></td>
|
||
<td>#__name#</td>
|
||
<td>#agreement_id#</td>
|
||
<td>#dateFormat(date_of_aggrement,"YYYY-MM-DD")#</td>
|
||
<td>#dateFormat(date_end_aggrement,"YYYY-MM-DD")#</td>
|
||
<td class="c">#type_of_agreement#</td>
|
||
</tr>
|
||
</cfoutput>
|
||
</table>
|
||
|
||
|
||
<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)
|
||
),
|
||
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
|
||
a.__id::text
|
||
,a.__name as additional_agreement
|
||
,a.contract_uid::text
|
||
,a.is_actual
|
||
,a.last_aa
|
||
,a.deal_uid::text
|
||
,c.__name as contract
|
||
,c.agreement_id
|
||
,c.date_of_aggrement
|
||
,d.__id as deal_uid
|
||
,d.__name as deal
|
||
,d.__status_status
|
||
,s.status
|
||
,s.probability_pc
|
||
,u.__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.additional_agreements a
|
||
join elma.aggrements c on (a.contract_uid=c.__id)
|
||
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.comp_users_ext u on (d._owner=c.__id)
|
||
where c.company_uid=<cfqueryparam cfsqltype="cf_sql_other" value=#d.__id# null=#!isValid("guid",d.__id)#/>
|
||
</cfquery>
|
||
|
||
|
||
<cfoutput>
|
||
<h4>Доп. соглашения (#qAdditionalAgreement.recordCount#)</h4>
|
||
</cfoutput>
|
||
|
||
<table class="worktable">
|
||
<thead>
|
||
<tr>
|
||
<th>__id</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="qAdditionalAgreement">
|
||
<tr>
|
||
<td><a href="additional_agreement.cfm?__id=#__id#&#tr.fwx#">#__id#</a></td>
|
||
<td>#additional_agreement#</td>
|
||
<td><a href="contract.cfm?__id=#contract_uid#&#tr.fwx#">#agreement_id#</a></td>
|
||
<td>#dateFormat(date_of_aggrement,"YYYY-MM-DD")#</td>
|
||
<td><a href="deal.cfm?__id=#deal_uid#&#tr.fwx#">#deal#</a></td>
|
||
<td>#status#</td>
|
||
<td>#probability_pc#</td>
|
||
<td>#owner#</td>
|
||
<td class="r">#nFmt(install)#</td>
|
||
<td class="r">#nFmt(periodical)#</td>
|
||
<td class="r">#nFmt(metered)#</td>
|
||
</tr>
|
||
</cfoutput>
|
||
</table>
|
||
|
||
<!--- ----------------------------------------------------------------- --->
|
||
<!--- ----------------------------------------------------------------- --->
|
||
<!--- ----------------------------------------------------------------- --->
|
||
|
||
<cfquery name="qDeal">
|
||
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)
|
||
),
|
||
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
|
||
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
|
||
<d:field title="ID" cfSqlType="CF_SQL_OTHER">d.__id</d:field>
|
||
<d:field title="index" cfSqlType="CF_SQL_INTEGER">d.__index</d:field>
|
||
<d:field title="Название">d.__name</d:field>
|
||
<d:field title="company_uid">d._companies</d:field>
|
||
<d:field title="Создана">d."__createdAt" as __createdAt</d:field><!--- *** косяк d:field, если взять в кавычки имя поля, оно не попадает в массив полей --->
|
||
<d:field title="Контрагент">k.__name as contragent</d:field>
|
||
<d:field title="Контрагент">k.__id as contragent_uid</d:field>
|
||
<d:field title="WZ">k.id_klienta as wz</d:field>
|
||
<d:field title="status_id">d.__status_status</d:field>
|
||
<d:field title="Статус">s.status</d:field>
|
||
<d:field title="Вероятность%">s.probability_pc</d:field>
|
||
<d:field title="Ответственный">c.__name as owner</d:field>
|
||
<d:field title="Допник">a.__name as additional_agreement</d:field>
|
||
<d:field title="Допник">a.__id as additional_agreement_uid</d:field>
|
||
<d:field title="Договор">g.__name as contract</d:field>
|
||
<d:field title="Договор">g.__id as contract_uid</d:field>
|
||
<d:field title="Договор">g.date_of_aggrement</d:field>
|
||
<d:field title="Договор">g.agreement_id</d:field>
|
||
<d:field title="Дата дог.">g.date_of_aggrement as dt_contract</d:field>
|
||
<d:field>(select sum(param_cost)
|
||
from component
|
||
where d.__id = ANY(component.deal_uids) AND component.type IN (1)
|
||
) as install
|
||
</d:field>
|
||
<d:field>(select sum(param_cost)
|
||
from component
|
||
where d.__id = ANY(component.deal_uids) AND component.type IN (2)
|
||
) as periodical
|
||
</d:field>
|
||
<d:field>(select sum(param_cost)
|
||
from component
|
||
where d.__id = ANY(component.deal_uids) AND component.type IN (3)
|
||
) as metered
|
||
</d:field>
|
||
</d:field_set>
|
||
from elma.deals d
|
||
left outer join elma.companies k on (d._companies=k.__id)
|
||
left outer join status s on (d.__status_status=s.status_id)
|
||
left outer join elma.comp_users_ext c on (d._owner=c.__id)
|
||
left outer join elma.additional_agreements a on (d.__id=a.deal_uid)
|
||
left outer join elma.aggrements g on (a.contract_uid = g.__id)
|
||
where d._companies=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid('guid',d.__id)#/>
|
||
</cfquery>
|
||
|
||
<cfoutput>
|
||
<h4>Сделки (#qDeal.recordCount#)</h4>
|
||
</cfoutput>
|
||
|
||
<table class="worktable">
|
||
<thead>
|
||
<tr>
|
||
<th>__id</th>
|
||
<th>__index</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="qDeal">
|
||
<tr>
|
||
<td><a href="deal.cfm?__id=#__id#&#tr.fwx#">#__id#</a></td>
|
||
<td>#__index#</td>
|
||
<td><a href="deal.cfm?__id=#__id#&#tr.fwx#">#__name#</a></td>
|
||
<td>#status#</td>
|
||
<td>#probability_pc#</td>
|
||
<td>#owner#</td>
|
||
<td>#additional_agreement#</td>
|
||
<td>#contract#</td>
|
||
<td><a href="contract.cfm?__id=#contract_uid#&#tr.fwx#">#agreement_id#</a></td>
|
||
<td>#dateFormat(date_of_aggrement,"YYYY-MM-DD")#</td>
|
||
<td class="r">#nFmt(install)#</td>
|
||
<td class="r">#nFmt(periodical)#</td>
|
||
<td class="r">#nFmt(metered)#</td>
|
||
</tr>
|
||
</cfoutput>
|
||
</table>
|
||
|
||
</cfif>
|
||
<layout:page section="footer"/> |