022 even more interlinks
This commit is contained in:
+230
-47
@@ -122,56 +122,239 @@
|
||||
|
||||
</cfoutput>
|
||||
сюда добавить сделок, договоров и т.д.
|
||||
<!---
|
||||
|
||||
<layout:page section="extension" closeForm="Yes"/>
|
||||
|
||||
<cfif d.contragent_id GT 0>
|
||||
<cfquery name="qContract">
|
||||
select
|
||||
d.contract_id
|
||||
,d.contract
|
||||
,d.dt_contract
|
||||
,(select count(*) from specification s where s.contract_id=d.contract_id) as spec_cnt
|
||||
from contract d
|
||||
where d.contragent_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#d.contragent_id#"/>
|
||||
order by 1
|
||||
</cfquery>
|
||||
<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>
|
||||
|
||||
<cfoutput>
|
||||
<h4>Договоры (#qContract.recordCount#)</h4>
|
||||
</cfoutput>
|
||||
|
||||
<table class="worktable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><c:link_add canWrite=#pageInfo.writePermitted()# entity="contract" id="#contragent_id#" extra="contragent_id=#d.contragent_id#" fwx=#tr.fwx#/></th>
|
||||
<th>Номер договора</th>
|
||||
<th>Дата договора</th>
|
||||
<th>Спецификаций</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<cfoutput query="qContract">
|
||||
<tr>
|
||||
<td>
|
||||
<c:link_view_edit canWrite=#pageInfo.writePermitted()# entity="contract" id=#contract_id# fwx=#tr.fwx#/>
|
||||
</td>
|
||||
<td>#contract#</td>
|
||||
<td class="c">
|
||||
#dateFormat(dt_contract,'YYYY-MM-DD')#
|
||||
</td>
|
||||
<td class="c">
|
||||
<cfif spec_cnt GT 0>#spec_cnt#</cfif>
|
||||
|
||||
</td>
|
||||
<td class="c">
|
||||
<c:link_del canWrite=#pageInfo.writePermitted()# entity="contract" id=#contract_id# fwx=#tr.fwx#/>
|
||||
</td>
|
||||
</tr>
|
||||
</cfoutput>
|
||||
</table>
|
||||
</cfif> --->
|
||||
<!--- ----------------------------------------------------------------- --->
|
||||
<!--- ----------------------------------------------------------------- --->
|
||||
<!--- ----------------------------------------------------------------- --->
|
||||
|
||||
<!--- <cfdump var=#this.datasources#/> --->
|
||||
<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"/>
|
||||
Reference in New Issue
Block a user