067 end customer

This commit is contained in:
2026-08-05 09:50:54 +03:00
parent 7ac2c85238
commit 5cc71b6587
7 changed files with 70 additions and 47 deletions
+1 -1
View File
@@ -87,7 +87,7 @@
<!--- global settings --->
<cfset request.RECORDS_PER_PAGE=500/>
<cfset request.APP_VERSION="0.00.065"/>
<cfset request.APP_VERSION="0.00.067"/>
<cfset request.STAND=getStand()/>
<cflock scope="application" type="readonly" timeout=3>
+9 -1
View File
@@ -223,6 +223,11 @@ where 1=1 <!--- <m:filter_build filter=#pageInfo.settings.filter#/> --->
order by <m:order_build sortArray=#pageInfo.settings.sort.sortArray# fieldCount=#fieldCount#/>
</cfquery>
<cfif structKeyExists(URL,"debug") OR structKeyExists(FORM,"debug")>
<cfdump var=#qRead#/>
<cfflush/>
</cfif>
<cfquery name="qTotal" dbtype="query">
select
sum(hosts_total) as hosts_total
@@ -260,7 +265,10 @@ select
from qRead
</cfquery>
<cfif structKeyExists(URL,"debug") OR structKeyExists(FORM,"debug")>
<cfdump var=#qTotal#/>
<cfflush/>
</cfif>
<cfif isDefined("output_xls")>
<layout:xml qRead=#qRead# titleMap=#titleMap# filename="#pageInfo.entity#.xml"/>
+15 -9
View File
@@ -170,10 +170,14 @@
,s.probability_pc
,d.__index
,d.__id as deal_uid
,siv.end_customer as end_customer_uid
,z.id_klienta as end_customer_wz
,z.__name as end_customer_name
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.companies z on (siv.end_customer=z.__id)
left outer join elma.additional_agreements a on (a.__id=ANY(siv.additional_agreement))
where d._companies=<cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid("guid",d.__id)#/>
AND siv.is_actual
@@ -192,24 +196,25 @@
<tr>
<th>__index</th>
<!--- <th>__name</th> --->
<th width="20%">user_description</th>
<th width="20%">user description</th>
<th width="25%">Компоненты</th>
<th>Кол-во</th>
<th>Скидка%</th>
<th width="5%">Сумма</th>
<th>Код</th>
<th>type</th>
<th>is_actual</th>
<th>is actual</th>
<th>hash</th>
<th>version</th>
<th>name_version</th>
<th>date_accept</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="5%">Вер.%</th>
<th width="7%">additional_agreement</th>
<th width="5%">date nop</th>
<th width="5%">date end</th>
<th>is easy</th>
<th width="2%">Вер.%</th>
<th width="10%">Дополнительное соглашение</th>
<th width="5%">Конечник</th>
</tr>
</thead>
@@ -259,6 +264,7 @@
<td class="c">#probability_pc#</td>
<!--- <td class="c">#additional_agreement_uid#</td> --->
<td class="c"><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td>
<td class="c"><a href="contragent.cfm?__id=#end_customer_uid#&#tr.fwx#" title="#replace(end_customer_name,'"','&quot;','ALL')#">#end_customer_wz#</a></td><!--- *** надо эскейпить кавычки в имени --->
</tr>
</cfoutput>
</table>
+8 -1
View File
@@ -52,10 +52,14 @@ WITH
,d.__status_status AS deal_status_id
,siv.user_description
,siv.params
,siv.end_customer as end_customer_uid
,z.id_klienta as end_customer_wz
,z.__name as end_customer_name
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)
LEFT JOIN elma.additional_agreements a ON (a.__id = ANY (siv.additional_agreement))
LEFT OUTER JOIN elma.additional_agreements a ON (a.__id = ANY (siv.additional_agreement))
LEFT OUTER JOIN elma.companies z on (siv.end_customer=z.__id)
WHERE siv.is_actual
AND siv."__deletedAt" IS NULL
AND d."__deletedAt" IS NULL
@@ -274,6 +278,7 @@ select
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
<d:field title="WZ Elma">r.wz as wz_sold</d:field>
<d:field title="Клиент">r.client as client_sold</d:field>
<d:field title="Конечник">r.end_customer_wz</d:field>
<d:field>r.company_uid</d:field>
<d:field title="WZ Cloud">a.wz as wz_alloc</d:field>
<d:field title="Manager">u.manager</d:field>
@@ -367,6 +372,7 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
<th width="5%"><layout:column_head name="wz_sold"/></th>
<th width="10%"><layout:column_head name="client_sold"/></th>
<th width="3%"><layout:column_head name="end_customer_wz"/></th>
<th width="5%"><layout:column_head name="wz_alloc"/></th>
<th width="5%"><layout:column_head name="manager"/></th>
<th width="3%"><layout:column_head name="status_ids"/></th>
@@ -408,6 +414,7 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
<a href="contragent_rpt.cfm?__id=#alloc_company_uid#&#tr.fwx#">#alloc_company#</a>
</cfif>
</td>
<td class="c"><a href="contragent.cfm?__id=#end_customer_uid#&#tr.fwx#" title="#replace(end_customer_name,'"','&quot;','ALL')#">#end_customer_wz#</td>
<td>#wz_alloc#</td>
<td><a href="mailto:#email#"<cfif qRead.status NEQ 2> title="не работает"</cfif>><span<cfif qRead.status NEQ 2> class="err"</cfif>>#manager#</span></a></td>
<td>#status_ids#</td>
+7 -1
View File
@@ -231,6 +231,9 @@
,siv.params::text
,a.__id::text as additional_agreement_uid
,a.__name as additional_agreement
,siv.end_customer as end_customer_uid
,z.id_klienta as end_customer_wz
,z.__name as end_customer_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
@@ -242,6 +245,7 @@
) as param_cnt
from elma.deals_services siv
left outer join elma.additional_agreements a on (a.__id=ANY(siv.additional_agreement))
left outer join elma.companies z on (siv.end_customer=z.__id)
where <cfqueryparam cfsqltype="cf_sql_other" value="#d.__id#" null=#!isValid("guid",d.__id)#/>=ANY(siv.deal)
and siv.is_actual
order by version::int
@@ -273,6 +277,7 @@
<th>is_easy</th>
<th>Компонентов</th>
<th width="12%">additional_agreement</th>
<th>Конечный клиент</th>
</tr>
</thead>
@@ -308,8 +313,9 @@
<td class="c"><cfif is_easy GT 0>Простая<cfelseif is_easy EQ 0>Композитная<cfelse>is_easy=#is_easy#</cfif></td>
<td class="c">#param_cnt#</td>
<!--- <td class="c">#additional_agreement_uid#</td> --->
<!--- <td class="c">#additional_agreement_uid#</td> --->
<td class="c"><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td>
<td class="c"><a href="contragent.cfm?__id=#end_customer_uid#&#tr.fwx#">#end_customer_wz# #end_customer_name#</a></td>
</tr>
</cfoutput>
</table>
+22 -33
View File
@@ -24,61 +24,49 @@
('Закрыта неуспешно',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))
end_customers_agg AS (
SELECT
unnest(siv.deal) AS deal_id,
STRING_AGG(DISTINCT z.id_klienta, ', ') AS end_customer_wzs
FROM elma.deals_services siv
LEFT JOIN elma.companies z ON siv.end_customer = z.__id
GROUP BY unnest(siv.deal)
)
select
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
<d:field title="ID" cfSqlType="CF_SQL_OTHER">d.__id</d:field>
<d:field title="ID" cfSqlType="CF_SQL_OTHER">d.__id::text as __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="company_uid">d._companies::text as _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="Контрагент">k.__id::text 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="Допник">a.__id::text 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.__id::text as contract_uid</d:field>
<d:field title="Дата дог.">g.date_of_aggrement as dt_contract</d:field>
<!--- <d:field>(select count(*)
from elma.deals_services siv
where d.__id = ANY(siv.deal)
) as line_cnt
</d:field> --->
<!--- <d:field title="Строк">(select count(*)
from elma.deals_services siv
where d.__id = ANY(siv.deal) AND siv.is_actual AND siv."__deletedAt" IS NULL
) as line_cnt_actual
</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 title="Конечники">ec.end_customer_wzs</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)
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)
LEFT OUTER JOIN end_customers_agg ec ON (d.__id = ec.deal_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>
<!--- <cfdump var=#qRead#/> --->
<cfcatch type="database">
@@ -182,6 +170,7 @@ 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="end_customer_wzs"/>
<!--- <c:column width="1%" field="line_cnt"><c:td class="c"/></c:column> --->
<!--- <c:column width="1%" field="line_cnt_actual"><c:td class="c"/></c:column> --->
<!--- <c:column width="5%" field="install" formatter=#nFmt#><c:td class="c"/></c:column>
+8 -1
View File
@@ -50,12 +50,16 @@
,siv.date_nop as dt_from, siv.date_end as dt_to, siv.discount as service_discount, siv.cnt as service_quantity
/*,p.__name as line_key*/, p.ed_izm, p.name as component, p.type, aa.__name as additional_agreement, aa.__id::text as additional_agreement_uid
--, aa.is_actual
,siv.end_customer as end_customer_uid
,z.id_klienta as end_customer_wz
,z.__name as end_customer_name
from elma.deals d
join elma.deals_services siv on (d.__id=ANY(siv.deal))
join elma.service_parametrs p on (p.__id = ANY(siv.params))
join elma.companies k on (d._companies=k.__id)
join elma.additional_agreements aa on (aa.__id = ANY(siv.additional_agreement))
join elma.aggrements a on (aa.contract_uid = a.__id)
left outer join elma.companies z on (siv.end_customer=z.__id)
where p.type IN (2,3) AND aa.is_actual
AND siv.date_nop < <cfqueryparam cfsqltype="cf_sql_timestamp" value=#dt_finish#/>
AND (siv.date_end > <cfqueryparam cfsqltype="cf_sql_timestamp" value=#dt_start#/> OR siv.date_end IS NULL)/*****/
@@ -349,6 +353,7 @@ order by wz, code
SELECT
<d:field_set titleMapOut="titleMap" lengthOut="fieldCount">
<d:field title="WZ">coalesce(coalesce(c.wz, m.wz), s.wz) as wz</d:field>
<d:field title="WZE">s.end_customer_wz as wze</d:field>
<d:field title="Артикул">coalesce(m.code, s.code) as code</d:field>
<d:field title="Артикул фикс">f.code as f_code</d:field>
<d:field title="Кол-во к оплате" cfSqlType="CF_SQL_NUMERIC">ceiling(m.chargeable_metric) as chargeable_metric</d:field>
@@ -475,6 +480,7 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
<td width="5%">Договор</td>
<td width="10%">Допник</td>
<td width="10%">Сделка</td>
<td width="3%">Конечник</td>
</thead>
@@ -519,13 +525,14 @@ S3 операции и трафик: <b>#dateFormat(qS3OpsTrfAge.dt_load,'YYYY-M
<td><a href="contract.cfm?__id=#contract_uid#&#tr.fwx#">#contract#</a></td>
<td><a href="additional_agreement.cfm?__id=#additional_agreement_uid#&#tr.fwx#">#additional_agreement#</a></td>
<td><a href="deal.cfm?__id=#deal_uid#&#tr.fwx#">#deal#</a></td>
<td>#WZE#</a></td>
</tr>
</cfoutput>
<tr>
<td bgcolor="##eee" style="border-bottom:2px solid gray;"></td>
<td bgcolor="##eee" colspan="4" class="r" style="border-bottom:2px solid gray;"><b>Итого</b> <a href="contragent.cfm?__id=#contragent_uid#&#tr.fwx#">#wz#</a> #contragent#:</td>
<td bgcolor="##eee" colspan="1" class="r b nw" style="border-bottom:2px solid gray;">#NumFmt(acc,2)#</td>
<td colspan="14" style="border-bottom:2px solid gray;"></td>
<td colspan="99" style="border-bottom:2px solid gray;"></td>
</tr >
</cfoutput>