022 even more interlinks

This commit is contained in:
msyu
2025-08-30 17:59:29 +03:00
parent 9fc45f76a1
commit 0189aae6cb
6 changed files with 267 additions and 56 deletions
+1 -1
View File
@@ -99,7 +99,7 @@
<cfset request.RECORDS_PER_PAGE=500/>
<cfset request.APP_VERSION="0.00.021"/>
<cfset request.APP_VERSION="0.00.022"/>
<cfset request.STAND=getStand()/>
<cflock scope="application" type="readonly" timeout=3>
+6 -2
View File
@@ -85,7 +85,11 @@
<div class="tr">
<div class="th">Контрагент</div>
<div class="td">#qDecoration.contragent# #qDecoration.wz# [#d.company_uid#] </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">
@@ -127,7 +131,7 @@
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)
where a.contract_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#"/>
where a.contract_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid('guid',d.__id)#/>
order by 1
</cfquery>
+213 -30
View File
@@ -122,19 +122,25 @@
</cfoutput>
сюда добавить сделок, договоров и т.д.
<!---
<layout:page section="extension" closeForm="Yes"/>
<cfif d.contragent_id GT 0>
<cfif len(d.__id)>
<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
<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>
@@ -144,34 +150,211 @@
<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>
<th>__id</th>
<th>Номер</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>
<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>
</cfif> --->
<!--- <cfdump var=#this.datasources#/> --->
<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"/>
+2 -2
View File
@@ -126,8 +126,8 @@
<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> --->
#qDecoration.contragent# #qDecoration.wz#
index:#qDecoration.contragent_index#
<a href="contragent.cfm?__id=#d._companies#&#tr.fwx#"> #qDecoration.contragent# #qDecoration.wz#
index:#qDecoration.contragent_index#</a>
</div>
</div>
+26 -2
View File
@@ -18,11 +18,15 @@
<!--- <cfset pageInfo.settings.filter=#filter#/> --->
<cftry>
<cfquery name="qRead" datasource="#request.DS#">
<cfquery name="qRead">
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">
@@ -36,13 +40,28 @@
<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="Вер-ть %">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 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)
@@ -52,6 +71,8 @@
left outer join elma.aggrements g on (a.contract_uid = g.__id)
where 1=1 <m:filter_build filter=#pageInfo.settings.filter#/>
order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=#fieldCount#/>
limit #pageInfo.recordsPerPage#
offset #pageInfo.nStart#
</cfquery>
@@ -148,6 +169,9 @@ select count(*) as cnt from elma.deals d where 1=1
<c:column width="5%" field="f_additional_agreement"><c:td class="l"/></c:column>
<c:column width="5%" field="f_contract"><c:td class="l"/></c:column>
<c:column width="5%" field="dt_contract" formatter=#function(dt){return dateformat(dt,"YYYY-MM-DD");}#><c:td class="c"/></c:column>
<!--- <c:column width="5%" field="install" formatter=#nFmt#><c:td class="c"/></c:column>
<c:column width="5%" field="periodical" formatter=#nFmt#><c:td class="c"/></c:column>
<c:column width="5%" field="metered" formatter=#nFmt#><c:td class="c"/></c:column> --->
</c:table>
+2 -2
View File
@@ -231,8 +231,8 @@
,d.__index
,d.__status_status
,c.id_klienta as wz
, s.status
, s.probability_pc
,s.status
,s.probability_pc
from elma.deals_services siv
join elma.deals d on (d.__id = ANY(siv.deal))
left outer join elma.companies c on (d._companies=c.__id)