forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.2 KiB
90 lines
3.2 KiB
2 years ago
|
|
||
|
--
|
||
|
-- RELACAO DE STATUS POR MATRICULA
|
||
|
--
|
||
|
SELECT DISTINCT d.ctst_id, d.ctst_nome
|
||
|
FROM pbx_usuarios a
|
||
|
INNER JOIN pbx_grupo_usuario b ON a.id = b.user_id
|
||
|
INNER JOIN pbx_grupo_campanha_contato_status c ON b.gp_id = c.gp_id
|
||
|
INNER JOIN pbx_campanha_contato_status d ON c.ctst_id = d.ctst_id
|
||
|
WHERE matricula = '1084'
|
||
|
AND d.ctst_status = 1
|
||
|
ORDER BY ctst_nome;
|
||
|
|
||
|
--
|
||
|
-- NUMERO DE REGISTROS POR STATUS
|
||
|
--
|
||
|
select ctst_ID, ctst_nome, count(*)
|
||
|
from pbx_cliente a, pbx_campanha_contato_status b
|
||
|
where b.ctst_id = a.client_status::int
|
||
|
and a.clo_id = 1
|
||
|
group by ctst_ID, ctst_nome order by 2;
|
||
|
|
||
|
|
||
|
-- Cliente origem
|
||
|
-- select * from pbx_cliente_origem
|
||
|
-- select * from pbx_cliente_fornecedor
|
||
|
|
||
|
--
|
||
|
-- INFORMACOES DO FORNECEDOR E LISTAS
|
||
|
--
|
||
|
SELECT clo_id,clo_titulo,clo_descricao,a.cfr_id,cfr_razao_social,nome,apelido, (SELECT count(clo_id) FROM pbx_cliente WHERE clo_id = a.clo_id) AS registros, a.data_reg
|
||
|
FROM pbx_cliente_origem a
|
||
|
INNER JOIN pbx_cliente_fornecedor b ON a.cfr_id = b.cfr_id
|
||
|
INNER JOIN pbx_usuarios c ON c.matricula = a.user_reg::VARCHAR
|
||
|
WHERE clo_id = 1;
|
||
|
|
||
|
--
|
||
|
-- NUMERO TOTAL DE REGISTROS POR LISTA E NUMERO DE REGISTROS ATRIBUIDOS A UMA MATRICULA
|
||
|
--
|
||
|
SELECT COUNT(client_id) AS registros, SUM(CASE WHEN(client_user_contato <> '')THEN 1 ELSE 0 END) AS registros_matricula FROM pbx_cliente WHERE clo_id = 1 and client_status <> '999'
|
||
|
|
||
|
--
|
||
|
-- USUARIOS RELACIONADOS AO PRE-VENDA
|
||
|
--
|
||
|
SELECT DISTINCT id, nome, apelido, matricula FROM pbx_usuarios a
|
||
|
INNER JOIN pbx_grupo_usuario b ON a.id = b.user_id
|
||
|
INNER JOIN pbx_grupo_funcoes c ON c.gp_id = b.gp_id
|
||
|
WHERE b.gp_id IN(SELECT gp_id FROM (SELECT CASE WHEN(COUNT(gp_id) > 1) THEN gp_id END AS gp_id FROM pbx_grupo_funcoes WHERE fun_id = 209 OR fun_id = 2 GROUP BY gp_id ORDER BY 1) AS DATA)
|
||
|
|
||
|
--select * FROM pbx_funcoes WHERE fun_id = 209 OR fun_id = 2
|
||
|
|
||
|
|
||
|
/*
|
||
|
--
|
||
|
-- MANIPULA OS REGISTROS PARA APRESENTARMOS APENAS DE DETERMINADOS ESTADOS
|
||
|
--
|
||
|
select * from pbx_cliente where clo_id = 1 and client_status = '0' and client_user_contato = '' and client_uf NOT in('SP', 'PR', 'SC', 'RS');
|
||
|
update pbx_cliente set client_status = '999' where clo_id = 1 and client_status = '0' and client_user_contato = '' and client_uf NOT in('SP', 'PR', 'SC', 'RS');
|
||
|
SELECT * FROM pbx_cliente WHERE clo_id = 1 AND client_user_contato <> '' AND list_id IS NULL AND cmp_id IS NULL;
|
||
|
|
||
|
|
||
|
|
||
|
"Pre Venda";"alessandra.neri";"1055"
|
||
|
"Pre Venda";"aline.souza";"1067"
|
||
|
"Pre Venda";"joicy.alves";"1073"
|
||
|
"Pre Venda";"luciene.franca";"1054"
|
||
|
"Pre Venda Admin";"amarildo.pereira";"1028"
|
||
|
"Pre Venda Admin";"awade";"1040"
|
||
|
"Pre Venda Admin";"gabriely.korb";"1084"
|
||
|
"Pre Venda Admin";"paulo.ricardo";"1074"
|
||
|
|
||
|
|
||
|
select * from pbx_grupo_campanha_contato_status c, pbx_campanha_contato_status d where c.ctst_id = d.ctst_id order by 2,3 ;
|
||
|
select * from pbx_campanha_contato_status;
|
||
|
select * from pbx_grupo_usuario;
|
||
|
select * from pbx_funcoes_internas where arquivo ilike '%grupos%'
|
||
|
select * from pbx_funcoes_internas where id_prog = 352
|
||
|
|
||
|
341;"cadastros/prevenda/listacampanhacliente.php";338;0;0
|
||
|
344;"cadastros/prevenda/statusReciclaLista.php";338;0;0
|
||
|
|
||
|
-- matriculas pre-venda
|
||
|
select distinct c.gp_id, c.gp_nome, a.apelido, a.matricula
|
||
|
from pbx_usuarios a, pbx_grupo_usuario b, pbx_grupo c
|
||
|
where b.user_id = a.id
|
||
|
and c.gp_id = b.gp_id
|
||
|
and gp_nome ilike 'pre%'
|
||
|
order by 1,2;
|
||
|
*/
|