Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
4| Name | Data Type | Length | Description |
|---|---|---|---|
| @accion | varchar | 100 | |
| @p_contraparte | int | 4 | |
| @p_cliente | int | 4 | |
| @p_email | varchar | 100 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
/*
exec Imperium_cliente_contraparte_led 'buscar_contratista_imperium', 457
---
ATENCION : ELIMINAR EN LAS OPCIONES DE ESTE STORED LA CLAUSULA AND clientes.cliente in (....) de todas las consultas luego de migrar el sistema
---
*/
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.Imperium_cliente_contraparte_led
-- Add the parameters for the stored procedure here
@accion varchar(100) = NULL,
@p_contraparte int = NULL,
@p_cliente int = NULL,
@p_email varchar(100) = NULL
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
if (@accion = 'buscar_contratista_imperium') begin
if (@p_contraparte > 0) begin
-- Dejamos opción cliente por si se desea hardcodear en la web de Fidelitas que sólo se habilite vista imperium a determinado cliente
if (@p_cliente is not null)
select p.identificador,identificadores.abreviatura,p.identificacion,p.nombre_persona,p.id_padron,c.contraparte,i.contratista, c.cliente,
iif(cliente_paises.nombre_local IS NOT NULL, cliente_paises.nombre_local, l.nombre_cliente) as nombre_cliente, users.user_id,
c.pais_servicio, country.country_name, identificadores.country_code,
ISNULL(c.codigo_idioma, 'spa') AS codigo_idioma,
i.user_id, users.first_name, users.last_name, users.email, users.username, users.password, c.email_contacto,c.nombre_contacto,users.password as clave,
c.clave_expira,null as nombre_filial, c.email_ejecutivo_cuenta
from LN_contrapartes c inner join LN_gestiones g on c.contraparte = g.contraparte
inner join led_contratistas i on (c.id_padron = i.id_padron and c.cliente = i.cliente)
inner join padrones p on i.id_padron = p.id_padron
inner join identificadores on p.identificador = identificadores.identificador
inner join country on identificadores.country_code = country.country_code
inner join clientes l on c.cliente = l.cliente
inner join users on i.user_id = users.user_id
left outer join cliente_paises on (c.cliente = cliente_paises.cliente
and c.pais_servicio = cliente_paises.country_code
and c.servicio_contratado = cliente_paises.servicio_contratado)
where g.desde <= GETDATE()
and g.hasta >= GETDATE()
/* and c.cliente IN (5546348, 3920694, 9936068, 7855254,2046807993,5967702)*/
and c.activo = 1
and i.estado_contratista = 'A'
and ISNULL(c.subcontratista, 0) = 0
and i.contratista = i.contratista_1
and c.contraparte = @p_contraparte
and c.cliente = @p_cliente
order by p.nombre_persona
else
select p.identificador,identificadores.abreviatura,p.identificacion,p.nombre_persona,p.id_padron,c.contraparte,i.contratista, c.cliente,
iif(cliente_paises.nombre_local IS NOT NULL, cliente_paises.nombre_local, l.nombre_cliente) as nombre_cliente, users.user_id,
c.pais_servicio, country.country_name, identificadores.country_code,
ISNULL(c.codigo_idioma, 'spa') AS codigo_idioma,
i.user_id, users.first_name, users.last_name, users.email, users.username, users.password, c.email_contacto,c.nombre_contacto,users.password as clave,
c.clave_expira,null as nombre_filial, c.email_ejecutivo_cuenta
from LN_contrapartes c inner join LN_gestiones g on c.contraparte = g.contraparte
inner join led_contratistas i on (c.id_padron = i.id_padron and c.cliente = i.cliente and i.contratista=c.id_imperium)
inner join padrones p on i.id_padron = p.id_padron
inner join identificadores on p.identificador = identificadores.identificador
inner join country on identificadores.country_code = country.country_code
inner join clientes l on c.cliente = l.cliente
left join users on i.user_id = users.user_id
left outer join cliente_paises on (c.cliente = cliente_paises.cliente
and c.pais_servicio = cliente_paises.country_code
and c.servicio_contratado = cliente_paises.servicio_contratado)
/* MIS */
where g.desde <= GETDATE()
and g.hasta >= GETDATE()
/*and c.cliente IN (5546348, 3920694, 9936068, 7855254,2046807993,7048064,5967702)*/
/*
and c.activo = 1
and i.estado_contratista = 'A'
*/
and (c.activo = 1 or i.estado_contratista = 'A')
and ISNULL(c.subcontratista, 0) = 0
and i.contratista = i.contratista_1
and c.contraparte = @p_contraparte
order by p.nombre_persona
end
-- Para buscar por e-mail
else if (LTRIM(RTRIM(@p_email)) != '') begin
declare @email varchar(100) = LTRIM(RTRIM(@p_email))
select p.identificador,identificadores.abreviatura,p.identificacion,p.nombre_persona,p.id_padron,c.contraparte,i.contratista, c.cliente,
iif(cliente_paises.nombre_local IS NOT NULL, cliente_paises.nombre_local, l.nombre_cliente) as nombre_cliente, users.user_id,
c.pais_servicio, country.country_name, identificadores.country_code,
ISNULL(c.codigo_idioma, 'spa') AS codigo_idioma,
i.user_id, users.first_name, users.last_name, users.email, users.username, users.password,c.nombre_contacto,users.password as clave,c.clave_expira, c.email_ejecutivo_cuenta
from LN_contrapartes c inner join LN_gestiones g on c.contraparte = g.contraparte
inner join led_contratistas i on (c.id_padron = i.id_padron and c.cliente = i.cliente)
inner join padrones p on i.id_padron = p.id_padron
inner join identificadores on p.identificador = identificadores.identificador
inner join country on identificadores.country_code = country.country_code
inner join clientes l on c.cliente = l.cliente
inner join users on i.user_id = users.user_id
left outer join cliente_paises on (c.cliente = cliente_paises.cliente
and c.pais_servicio = cliente_paises.country_code
and c.servicio_contratado = cliente_paises.servicio_contratado)
where g.desde <= GETDATE()
and g.hasta >= GETDATE()
/*and c.cliente IN (5546348, 3920694, 9936068, 7855254,2046807993,7048064)*/
and c.activo = 1
and i.estado_contratista = 'A'
and ISNULL(c.subcontratista, 0) = 0
and i.contratista = i.contratista_1
and users.email = @email
order by p.nombre_persona
end
end
END
GO
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
/*
exec Imperium_cliente_contraparte_led 'buscar_contratista_imperium', 457
---
ATENCION : ELIMINAR EN LAS OPCIONES DE ESTE STORED LA CLAUSULA AND clientes.cliente in (....) de todas las consultas luego de migrar el sistema
---
*/
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.Imperium_cliente_contraparte_led
-- Add the parameters for the stored procedure here
@accion varchar(100) = NULL,
@p_contraparte int = NULL,
@p_cliente int = NULL,
@p_email varchar(100) = NULL
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
if (@accion = 'buscar_contratista_imperium') begin
if (@p_contraparte > 0) begin
-- Dejamos opción cliente por si se desea hardcodear en la web de Fidelitas que sólo se habilite vista imperium a determinado cliente
if (@p_cliente is not null)
select p.identificador,identificadores.abreviatura,p.identificacion,p.nombre_persona,p.id_padron,c.contraparte,i.contratista, c.cliente,
iif(cliente_paises.nombre_local IS NOT NULL, cliente_paises.nombre_local, l.nombre_cliente) as nombre_cliente, users.user_id,
c.pais_servicio, country.country_name, identificadores.country_code,
ISNULL(c.codigo_idioma, 'spa') AS codigo_idioma,
i.user_id, users.first_name, users.last_name, users.email, users.username, users.password, c.email_contacto,c.nombre_contacto,users.password as clave,
c.clave_expira,null as nombre_filial, c.email_ejecutivo_cuenta
from LN_contrapartes c inner join LN_gestiones g on c.contraparte = g.contraparte
inner join led_contratistas i on (c.id_padron = i.id_padron and c.cliente = i.cliente)
inner join padrones p on i.id_padron = p.id_padron
inner join identificadores on p.identificador = identificadores.identificador
inner join country on identificadores.country_code = country.country_code
inner join clientes l on c.cliente = l.cliente
inner join users on i.user_id = users.user_id
left outer join cliente_paises on (c.cliente = cliente_paises.cliente
and c.pais_servicio = cliente_paises.country_code
and c.servicio_contratado = cliente_paises.servicio_contratado)
where g.desde <= GETDATE()
and g.hasta >= GETDATE()
/* and c.cliente IN (5546348, 3920694, 9936068, 7855254,2046807993,5967702)*/
and c.activo = 1
and i.estado_contratista = 'A'
and ISNULL(c.subcontratista, 0) = 0
and i.contratista = i.contratista_1
and c.contraparte = @p_contraparte
and c.cliente = @p_cliente
order by p.nombre_persona
else
select p.identificador,identificadores.abreviatura,p.identificacion,p.nombre_persona,p.id_padron,c.contraparte,i.contratista, c.cliente,
iif(cliente_paises.nombre_local IS NOT NULL, cliente_paises.nombre_local, l.nombre_cliente) as nombre_cliente, users.user_id,
c.pais_servicio, country.country_name, identificadores.country_code,
ISNULL(c.codigo_idioma, 'spa') AS codigo_idioma,
i.user_id, users.first_name, users.last_name, users.email, users.username, users.password, c.email_contacto,c.nombre_contacto,users.password as clave,
c.clave_expira,null as nombre_filial, c.email_ejecutivo_cuenta
from LN_contrapartes c inner join LN_gestiones g on c.contraparte = g.contraparte
inner join led_contratistas i on (c.id_padron = i.id_padron and c.cliente = i.cliente and i.contratista=c.id_imperium)
inner join padrones p on i.id_padron = p.id_padron
inner join identificadores on p.identificador = identificadores.identificador
inner join country on identificadores.country_code = country.country_code
inner join clientes l on c.cliente = l.cliente
left join users on i.user_id = users.user_id
left outer join cliente_paises on (c.cliente = cliente_paises.cliente
and c.pais_servicio = cliente_paises.country_code
and c.servicio_contratado = cliente_paises.servicio_contratado)
/* MIS */
where g.desde <= GETDATE()
and g.hasta >= GETDATE()
/*and c.cliente IN (5546348, 3920694, 9936068, 7855254,2046807993,7048064,5967702)*/
/*
and c.activo = 1
and i.estado_contratista = 'A'
*/
and (c.activo = 1 or i.estado_contratista = 'A')
and ISNULL(c.subcontratista, 0) = 0
and i.contratista = i.contratista_1
and c.contraparte = @p_contraparte
order by p.nombre_persona
end
-- Para buscar por e-mail
else if (LTRIM(RTRIM(@p_email)) != '') begin
declare @email varchar(100) = LTRIM(RTRIM(@p_email))
select p.identificador,identificadores.abreviatura,p.identificacion,p.nombre_persona,p.id_padron,c.contraparte,i.contratista, c.cliente,
iif(cliente_paises.nombre_local IS NOT NULL, cliente_paises.nombre_local, l.nombre_cliente) as nombre_cliente, users.user_id,
c.pais_servicio, country.country_name, identificadores.country_code,
ISNULL(c.codigo_idioma, 'spa') AS codigo_idioma,
i.user_id, users.first_name, users.last_name, users.email, users.username, users.password,c.nombre_contacto,users.password as clave,c.clave_expira, c.email_ejecutivo_cuenta
from LN_contrapartes c inner join LN_gestiones g on c.contraparte = g.contraparte
inner join led_contratistas i on (c.id_padron = i.id_padron and c.cliente = i.cliente)
inner join padrones p on i.id_padron = p.id_padron
inner join identificadores on p.identificador = identificadores.identificador
inner join country on identificadores.country_code = country.country_code
inner join clientes l on c.cliente = l.cliente
inner join users on i.user_id = users.user_id
left outer join cliente_paises on (c.cliente = cliente_paises.cliente
and c.pais_servicio = cliente_paises.country_code
and c.servicio_contratado = cliente_paises.servicio_contratado)
where g.desde <= GETDATE()
and g.hasta >= GETDATE()
/*and c.cliente IN (5546348, 3920694, 9936068, 7855254,2046807993,7048064)*/
and c.activo = 1
and i.estado_contratista = 'A'
and ISNULL(c.subcontratista, 0) = 0
and i.contratista = i.contratista_1
and users.email = @email
order by p.nombre_persona
end
end
END
GO
Depends On
9Used By
No items found