diff --git a/Application.cfc b/Application.cfc index d719cc1..61b45d3 100644 --- a/Application.cfc +++ b/Application.cfc @@ -99,7 +99,7 @@ - + diff --git a/contract.cfm b/contract.cfm index c5cc03f..3096d24 100644 --- a/contract.cfm +++ b/contract.cfm @@ -85,7 +85,11 @@
Контрагент
-
#qDecoration.contragent# #qDecoration.wz# [#d.company_uid#]
+
@@ -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= + where a.contract_uid= order by 1 diff --git a/contragent.cfm b/contragent.cfm index 9c9bf31..d26a210 100644 --- a/contragent.cfm +++ b/contragent.cfm @@ -122,56 +122,239 @@ сюда добавить сделок, договоров и т.д. - + + + - + + 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.__id + d.__index + d.__name + d._companies + d."__createdAt" as __createdAt + k.__name as contragent + k.__id as contragent_uid + k.id_klienta as wz + d.__status_status + s.status + s.probability_pc + c.__name as owner + a.__name as additional_agreement + a.__id as additional_agreement_uid + g.__name as contract + g.__id as contract_uid + g.date_of_aggrement + g.agreement_id + g.date_of_aggrement as dt_contract + (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 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= + + +

Сделки (#qDeal.recordCount#)

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
__id__indexСделкаСтатус сделкиВер-ть %ОтветственныйДопникДоговорВнут. н-р дог.Дата договораИнсталлЕжемесТариф.
#__id##__index##__name##status##probability_pc##owner##additional_agreement##contract##agreement_id##dateFormat(date_of_aggrement,"YYYY-MM-DD")##nFmt(install)##nFmt(periodical)##nFmt(metered)#
+ + \ No newline at end of file diff --git a/deal.cfm b/deal.cfm index beb0f9e..98c5b87 100644 --- a/deal.cfm +++ b/deal.cfm @@ -126,8 +126,8 @@
Контрагент
- #qDecoration.contragent# #qDecoration.wz# - index:#qDecoration.contragent_index# + #qDecoration.contragent# #qDecoration.wz# + index:#qDecoration.contragent_index#
diff --git a/deal_ls.cfm b/deal_ls.cfm index 8ff6c90..9261953 100644 --- a/deal_ls.cfm +++ b/deal_ls.cfm @@ -18,11 +18,15 @@ - + 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 @@ -36,13 +40,28 @@ k.id_klienta as wz d.__status_status s.status - s.probability_pc + s.probability_pc c.__name as owner a.__name as additional_agreement a.__id as additional_agreement_uid g.__name as contract g.__id as contract_uid g.date_of_aggrement as dt_contract + 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 order by + limit #pageInfo.recordsPerPage# + offset #pageInfo.nStart# @@ -148,6 +169,9 @@ select count(*) as cnt from elma.deals d where 1=1 + diff --git a/deal_service.cfm b/deal_service.cfm index 01b49cf..11d8b03 100644 --- a/deal_service.cfm +++ b/deal_service.cfm @@ -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)