Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
11| Name | Data Type | Length | Description |
|---|---|---|---|
| @accion | varchar | 50 | |
| @p_web_id | smallint | 2 | |
| @p_app_id | tinyint | 1 | |
| @p_cliente | int | 4 | |
| @p_sender | varchar | 50 | |
| @p_servicio | int | 4 | |
| @p_contraparte | int | 4 | |
| @p_app_key | varchar | 50 | |
| @p_tipo_mail | varchar | 100 | |
| @p_tipo_mail_subject | varchar | 100 | |
| @p_idioma | char | 3 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
/*
[multi_web_] 'mail_contraparte',null,null,null,null,null,141738, 'ALTA'
multi_web_ 'mail_contraparte',null,null,null,null,null,67260, 'ALTA'
multi_web_ 'recuperar_clave',null,null,null,null,null,null,null,'inquiro',null
multi_web_ 'mail_contraparte',null,null,null,null,null,182873,'EMAIL-IMPE','ALTA-USUARIO','ALTA-USUARIO-SUBJECT"
*/
CREATE OR ALTER PROCEDURE dbo.multi_web_
-- Add the parameters for the stored procedure here
@accion varchar(50) = null,
@p_web_id smallint = null,
@p_app_id tinyint = null,
@p_cliente int = null,
@p_sender varchar(50) = null,
@p_servicio int = null,
@p_contraparte int = null,
@p_app_key varchar(50) = 'EMAIL-LED',
@p_tipo_mail varchar(100) = null,
@p_tipo_mail_subject varchar(100) = null,
@p_idioma char(3) = null
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @idioma varchar(3)
-- Insert statements for procedure here
if (@accion = 'editar')
begin
select * from multi_web where web_id = @p_web_id
return
end
if (@accion = 'disponibles') begin
if (@p_app_id is not null)
select * from multi_web where app_id = @p_app_id and cliente IS NULL and isnull(is_default,0) = 0 order by web_name
else
select * from multi_web where cliente IS NULL and isnull(is_default,0) = 0 order by web_name
end else
if (@accion = 'asignar') begin
if (@p_web_id is not null and @p_cliente is not null) begin
declare @app_id tinyint
/* al asignar una personalización a un cliente, tengo que sacarlo de todas las otras de la misma app_id */
select @app_id = app_id from multi_web where web_id = @p_web_id
update multi_web set cliente = NULL, sender = NULL where app_id = @app_id and cliente = @p_cliente
update multi_web set cliente = @p_cliente , sender = @p_sender where web_id = @p_web_id
end
end else
if (@accion = 'desasignar') begin
update multi_web set cliente = NULL , sender = NULL where cliente = @p_cliente
end else
if (@accion = 'asignados') begin
select * from multi_web where cliente = @p_cliente order by web_name
end else
if (@accion = 'asignables') begin
select multi_web.*, clientes.nombre_cliente from multi_web left outer join clientes on multi_web.cliente = clientes.cliente where isnull(is_default,0) = 0 order by web_name
end
if (@accion = 'cliente') begin
if (@p_app_id is not null)
begin
if (@p_servicio is null)
select top 1 multi_web.*, clientes.nombre_cliente
from multi_web
inner join clientes on clientes.cliente = @p_cliente
where multi_web.app_id = @p_app_id
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
else
select top 1 multi_web.*, clientes.nombre_cliente
from multi_web
inner join clientes on clientes.cliente = @p_cliente
where multi_web.app_id = @p_app_id
and multi_web.servicio_contratado = @p_servicio
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
end
else
begin
if (@p_servicio is null)
select top 1 multi_web.*, clientes.nombre_cliente
from multi_web
inner join clientes on clientes.cliente = @p_cliente
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
else
select top 1 multi_web.*, clientes.nombre_cliente
from multi_web
inner join clientes on clientes.cliente = @p_cliente
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.servicio_contratado = @p_servicio
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
end
end
if (@accion = 'mail_cliente') begin
select top 1 multi_web.*, clientes.nombre_cliente,
clientes.nombre_cliente,
body.spa as body_spa,
body.por as body_por,
body.eng as body_eng,
subj.spa as subj_spa,
subj.por as subj_por,
subj.eng as subj_eng
from multi_web
inner join clientes on clientes.cliente = @p_cliente
left join traducciones body on body.app_id = multi_web.app_id and body.app_key like 'Email%body%'
left join traducciones subj on subj.app_id = multi_web.app_id and subj.app_key like 'Email%subj%'
where multi_web.app_id = isnull(@p_app_id,6) -- Para los mails es 6
and multi_web.servicio_contratado = @p_servicio
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
end
/* En la tabla fide_apps el campo cliente_contraparte = 1 para cliente, 2 para contraparte
En iv_migrados está la lista de clientes que ya se han migrado al nuevo sistema
La tabla fide_apss la usamos para poder saber que app_id buscar en la tabla multi_web, de acuerdo al servicio_contratado,
si es parte del cliente o de la contraparte, y si tiene que usar sistema nuevo para clientes migrados o viejo para no migrados
Vemos si en multi_web hay personalizacion para el cliente, si no hay, tomamos el default para ese app_id
*/
if (@accion = 'mail_contraparte' or @accion = 'mail_cliente_contraparte')
begin
declare @migrado bit
declare @modalidad_login char(1)
declare @cliente_contraparte int
if (@accion = 'mail_contraparte') set @cliente_contraparte = 2
else set @cliente_contraparte = 1
if (@p_contraparte is not null)
begin
select @p_cliente = cliente, @p_servicio = servicio_contratado, @idioma = isnull(codigo_idioma,'spa')
from ln_contrapartes where contraparte = @p_contraparte
select @modalidad_login = modalidad_login
from LN_Contrapartes
inner join LN_contraparte_familias on LN_contraparte_familias.contraparte = ln_contrapartes.contraparte
inner join LN_familias on (LN_contraparte_familias.familia = LN_familias.familia
and LN_contrapartes.cliente = LN_familias.cliente)
where LN_contrapartes.contraparte = @p_contraparte
and LN_contraparte_familias.activo = 1
and LN_familias.visible = 1
end
declare @blade varchar(50) = null
declare @blade_cliente varchar(50) = null
declare @subject varchar(50) = null
declare @subject_cliente varchar(50) = null
declare @mensaje varchar(max) = null
declare @asunto varchar(max) = null
set @migrado = 0
if (@p_servicio in (10,73))
begin
if exists (select * from iv_migrados where cliente = @p_cliente and servicio_contratado = @p_servicio)
set @migrado = 1
end
set @p_app_id = (select app_id from fide_apps
where servicio_contratado = @p_servicio
and cliente_contraparte = @cliente_contraparte
and isnull(migrado,0) = @migrado)
if (isnull(@p_tipo_mail,'') != 'ALTA')
begin
set @blade = upper(@p_tipo_mail)
set @blade_cliente = upper(@p_tipo_mail) + '_' + convert(varchar, @p_cliente)
set @subject = upper(@p_tipo_mail_subject)
set @subject_cliente =upper(@p_tipo_mail_subject) + '_' + convert(varchar, @p_cliente)
end
if (@p_tipo_mail = 'ALTA')
begin
if (@modalidad_login = 'T')
begin
if (@p_servicio = 10)
begin
set @blade = 'ALTA-TAXID-INQUIROVITAE'
set @blade_cliente ='ALTA-TAXID-INQUIROVITAE_' + convert(varchar, @p_cliente)
end
else
begin
set @blade = 'ALTA-TAXID'
set @blade_cliente ='ALTA-TAXID_' + convert(varchar, @p_cliente)
end
end
else
begin
if (@p_servicio = 10)
begin
set @blade = 'ALTA-LINK-INQUIROVITAE'
set @blade_cliente ='ALTA-LINK-INQUIROVITAE_' + convert(varchar, @p_cliente)
end
else
begin
set @blade = 'ALTA-LINK'
set @blade_cliente ='ALTA-LINK_' + convert(varchar, @p_cliente)
end
end
if (@modalidad_login = 'T')
begin
if (@p_servicio = 10)
begin
set @subject = 'ALTA-TAXID-SUBJECT-INQUIROVITAE'
set @subject_cliente ='ALTA-TAXID-SUBJECT-INQUIROVITAE_' + convert(varchar, @p_cliente)
end
else
begin
set @subject = 'ALTA-TAXID-SUBJECT'
set @subject_cliente = 'ALTA-TAXID-SUBJECT_' + convert(varchar, @p_cliente)
end
end
else
begin
if (@p_servicio = 10)
begin
set @subject = 'ALTA-LINK-SUBJECT-INQUIROVITAE'
set @subject_cliente ='ALTA-LINK-SUBJECT-INQUIROVITAE_' + convert(varchar, @p_cliente)
end
else
begin
set @subject = 'ALTA-LINK-SUBJECT'
set @subject_cliente = 'ALTA-LINK-SUBJECT_' + convert(varchar, @p_cliente)
end
end
end
-- Cuerpo y Asunto del mail:
-- Busca para ese cliente, ese blade y esa app_id
-- Si no encuentra, busca para ese cliente, ese blade
-- Si no encuentra, busca para cliente NULL, ese blade, esa app_id
-- Si no encuentra, busca para cliente NULL, ese blase
--select @p_app_key , @p_cliente, @blade, @blade_cliente
set @mensaje = (select case @idioma
when 'eng' then mensaje.eng
when 'por' then mensaje.por
else mensaje.spa
end as mensaje
from traducciones mensaje where mensaje.blade in (@blade, @blade_cliente) and app_key = @p_app_key
and app_id = @p_app_id
and cliente = @p_cliente)
if (@mensaje is null)
set @mensaje = (select case @idioma
when 'eng' then mensaje.eng
when 'por' then mensaje.por
else mensaje.spa
end as mensaje
from traducciones mensaje where mensaje.blade in (@blade, @blade_cliente) and app_key = @p_app_key
and cliente = @p_cliente)
if (@mensaje is null)
set @mensaje = (select case @idioma
when 'eng' then mensaje.eng
when 'por' then mensaje.por
else mensaje.spa
end as mensaje
from traducciones mensaje where mensaje.blade in (@blade, @blade_cliente) and app_key = @p_app_key
and app_id = @p_app_id
and cliente is null)
if (@mensaje is null)
set @mensaje = (select case @idioma
when 'eng' then mensaje.eng
when 'por' then mensaje.por
else mensaje.spa
end as mensaje
from traducciones mensaje where mensaje.blade in (@blade, @blade_cliente) and app_key = @p_app_key
and cliente is null)
set @asunto = (select case @idioma
when 'eng' then asunto.eng
when 'por' then asunto.por
else asunto.spa
end as asunto
from traducciones asunto where asunto.blade in (@subject,@subject_cliente) and app_key = @p_app_key
and app_id = @p_app_id
and cliente = @p_cliente)
if (@asunto is null)
set @asunto = (select case @idioma
when 'eng' then asunto.eng
when 'por' then asunto.por
else asunto.spa
end as asunto
from traducciones asunto where asunto.blade in (@subject,@subject_cliente) and app_key = @p_app_key
and cliente = @p_cliente)
if (@asunto is null)
set @asunto = (select case @idioma
when 'eng' then asunto.eng
when 'por' then asunto.por
else asunto.spa
end as asunto
from traducciones asunto where asunto.blade in (@subject,@subject_cliente) and app_key = @p_app_key
and app_id = @p_app_id
and cliente is null)
if (@asunto is null)
set @asunto = (select case @idioma
when 'eng' then asunto.eng
when 'por' then asunto.por
else asunto.spa
end as asunto
from traducciones asunto where asunto.blade in (@subject,@subject_cliente) and app_key = @p_app_key
and cliente is null)
if( @asunto = 'Fidelitas S.A. - Control de Contratistas')
set @asunto = 'IMPERIUM - Control de documentación'
if exists (select multi_web.*
from multi_web
where multi_web.app_id = @p_app_id
and multi_web.cliente = @p_cliente
and multi_web.active = 1)
begin
select top 1 multi_web.*, clientes.cliente, clientes.nombre_cliente,
@mensaje as mensaje,
@asunto as asunto,
@blade as blade
from multi_web
inner join clientes on clientes.cliente = @p_cliente
where multi_web.app_id = @p_app_id
and multi_web.cliente = @p_cliente
and multi_web.active = 1
end
else
begin
if (@p_contraparte = 31319)
select top 1 multi_web.*, clientes.cliente as cliente1, clientes.nombre_cliente,
@mensaje as mensaje,
@asunto as asunto,
@blade as blade
from multi_web, clientes
where multi_web.app_id = @p_app_id
and multi_web.active = 1
and clientes.cliente = @p_cliente
else
select top 1 multi_web.*, clientes.cliente, clientes.nombre_cliente,
@mensaje as mensaje,
@asunto as asunto,
@blade as blade
from multi_web, clientes
where multi_web.app_id = @p_app_id
and multi_web.cliente is null and is_default = 1
and multi_web.active = 1
and clientes.cliente = @p_cliente
end
end
if (@accion = 'recuperar_clave') begin
set @p_app_id = (select top 1 app_id from fide_apps where CHARINDEX(upper(app_url), upper(@p_tipo_mail)) != 0 )
set @idioma = isnull(@p_idioma,'spa')
select top 1 multi_web.*,
case @idioma
when 'eng' then body.eng
when 'por' then body.por
else body.spa
end as mensaje,
case @idioma
when 'eng' then subj.eng
when 'por' then subj.por
else subj.spa
end as asunto
from multi_web
left join traducciones body on body.app_id = multi_web.app_id and body.blade = 'RECUPERAR-CONTRASEÑA'
left join traducciones subj on subj.app_id = multi_web.app_id and subj.blade = 'RECUPERAR-CONTRASEÑA-SUBJECT'
where multi_web.app_id = isnull(@p_app_id,113) -- 113 - Logo Fidelitas
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
end
END
/*
select * from iv_migrados
select * from fide_apps
update fide_apps set migrado = 0 where app_id > 101 and app_id not in (104,106,108,110)
alter table iv_migrados add servicio_contratado int null
update iv_migrados set servicio_contratado = 10
select * from multi_web where app_id =107
*/
GO
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
/*
[multi_web_] 'mail_contraparte',null,null,null,null,null,141738, 'ALTA'
multi_web_ 'mail_contraparte',null,null,null,null,null,67260, 'ALTA'
multi_web_ 'recuperar_clave',null,null,null,null,null,null,null,'inquiro',null
multi_web_ 'mail_contraparte',null,null,null,null,null,182873,'EMAIL-IMPE','ALTA-USUARIO','ALTA-USUARIO-SUBJECT"
*/
CREATE OR ALTER PROCEDURE dbo.multi_web_
-- Add the parameters for the stored procedure here
@accion varchar(50) = null,
@p_web_id smallint = null,
@p_app_id tinyint = null,
@p_cliente int = null,
@p_sender varchar(50) = null,
@p_servicio int = null,
@p_contraparte int = null,
@p_app_key varchar(50) = 'EMAIL-LED',
@p_tipo_mail varchar(100) = null,
@p_tipo_mail_subject varchar(100) = null,
@p_idioma char(3) = null
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @idioma varchar(3)
-- Insert statements for procedure here
if (@accion = 'editar')
begin
select * from multi_web where web_id = @p_web_id
return
end
if (@accion = 'disponibles') begin
if (@p_app_id is not null)
select * from multi_web where app_id = @p_app_id and cliente IS NULL and isnull(is_default,0) = 0 order by web_name
else
select * from multi_web where cliente IS NULL and isnull(is_default,0) = 0 order by web_name
end else
if (@accion = 'asignar') begin
if (@p_web_id is not null and @p_cliente is not null) begin
declare @app_id tinyint
/* al asignar una personalización a un cliente, tengo que sacarlo de todas las otras de la misma app_id */
select @app_id = app_id from multi_web where web_id = @p_web_id
update multi_web set cliente = NULL, sender = NULL where app_id = @app_id and cliente = @p_cliente
update multi_web set cliente = @p_cliente , sender = @p_sender where web_id = @p_web_id
end
end else
if (@accion = 'desasignar') begin
update multi_web set cliente = NULL , sender = NULL where cliente = @p_cliente
end else
if (@accion = 'asignados') begin
select * from multi_web where cliente = @p_cliente order by web_name
end else
if (@accion = 'asignables') begin
select multi_web.*, clientes.nombre_cliente from multi_web left outer join clientes on multi_web.cliente = clientes.cliente where isnull(is_default,0) = 0 order by web_name
end
if (@accion = 'cliente') begin
if (@p_app_id is not null)
begin
if (@p_servicio is null)
select top 1 multi_web.*, clientes.nombre_cliente
from multi_web
inner join clientes on clientes.cliente = @p_cliente
where multi_web.app_id = @p_app_id
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
else
select top 1 multi_web.*, clientes.nombre_cliente
from multi_web
inner join clientes on clientes.cliente = @p_cliente
where multi_web.app_id = @p_app_id
and multi_web.servicio_contratado = @p_servicio
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
end
else
begin
if (@p_servicio is null)
select top 1 multi_web.*, clientes.nombre_cliente
from multi_web
inner join clientes on clientes.cliente = @p_cliente
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
else
select top 1 multi_web.*, clientes.nombre_cliente
from multi_web
inner join clientes on clientes.cliente = @p_cliente
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.servicio_contratado = @p_servicio
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
end
end
if (@accion = 'mail_cliente') begin
select top 1 multi_web.*, clientes.nombre_cliente,
clientes.nombre_cliente,
body.spa as body_spa,
body.por as body_por,
body.eng as body_eng,
subj.spa as subj_spa,
subj.por as subj_por,
subj.eng as subj_eng
from multi_web
inner join clientes on clientes.cliente = @p_cliente
left join traducciones body on body.app_id = multi_web.app_id and body.app_key like 'Email%body%'
left join traducciones subj on subj.app_id = multi_web.app_id and subj.app_key like 'Email%subj%'
where multi_web.app_id = isnull(@p_app_id,6) -- Para los mails es 6
and multi_web.servicio_contratado = @p_servicio
and (multi_web.cliente = @p_cliente or multi_web.cliente is null)
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
end
/* En la tabla fide_apps el campo cliente_contraparte = 1 para cliente, 2 para contraparte
En iv_migrados está la lista de clientes que ya se han migrado al nuevo sistema
La tabla fide_apss la usamos para poder saber que app_id buscar en la tabla multi_web, de acuerdo al servicio_contratado,
si es parte del cliente o de la contraparte, y si tiene que usar sistema nuevo para clientes migrados o viejo para no migrados
Vemos si en multi_web hay personalizacion para el cliente, si no hay, tomamos el default para ese app_id
*/
if (@accion = 'mail_contraparte' or @accion = 'mail_cliente_contraparte')
begin
declare @migrado bit
declare @modalidad_login char(1)
declare @cliente_contraparte int
if (@accion = 'mail_contraparte') set @cliente_contraparte = 2
else set @cliente_contraparte = 1
if (@p_contraparte is not null)
begin
select @p_cliente = cliente, @p_servicio = servicio_contratado, @idioma = isnull(codigo_idioma,'spa')
from ln_contrapartes where contraparte = @p_contraparte
select @modalidad_login = modalidad_login
from LN_Contrapartes
inner join LN_contraparte_familias on LN_contraparte_familias.contraparte = ln_contrapartes.contraparte
inner join LN_familias on (LN_contraparte_familias.familia = LN_familias.familia
and LN_contrapartes.cliente = LN_familias.cliente)
where LN_contrapartes.contraparte = @p_contraparte
and LN_contraparte_familias.activo = 1
and LN_familias.visible = 1
end
declare @blade varchar(50) = null
declare @blade_cliente varchar(50) = null
declare @subject varchar(50) = null
declare @subject_cliente varchar(50) = null
declare @mensaje varchar(max) = null
declare @asunto varchar(max) = null
set @migrado = 0
if (@p_servicio in (10,73))
begin
if exists (select * from iv_migrados where cliente = @p_cliente and servicio_contratado = @p_servicio)
set @migrado = 1
end
set @p_app_id = (select app_id from fide_apps
where servicio_contratado = @p_servicio
and cliente_contraparte = @cliente_contraparte
and isnull(migrado,0) = @migrado)
if (isnull(@p_tipo_mail,'') != 'ALTA')
begin
set @blade = upper(@p_tipo_mail)
set @blade_cliente = upper(@p_tipo_mail) + '_' + convert(varchar, @p_cliente)
set @subject = upper(@p_tipo_mail_subject)
set @subject_cliente =upper(@p_tipo_mail_subject) + '_' + convert(varchar, @p_cliente)
end
if (@p_tipo_mail = 'ALTA')
begin
if (@modalidad_login = 'T')
begin
if (@p_servicio = 10)
begin
set @blade = 'ALTA-TAXID-INQUIROVITAE'
set @blade_cliente ='ALTA-TAXID-INQUIROVITAE_' + convert(varchar, @p_cliente)
end
else
begin
set @blade = 'ALTA-TAXID'
set @blade_cliente ='ALTA-TAXID_' + convert(varchar, @p_cliente)
end
end
else
begin
if (@p_servicio = 10)
begin
set @blade = 'ALTA-LINK-INQUIROVITAE'
set @blade_cliente ='ALTA-LINK-INQUIROVITAE_' + convert(varchar, @p_cliente)
end
else
begin
set @blade = 'ALTA-LINK'
set @blade_cliente ='ALTA-LINK_' + convert(varchar, @p_cliente)
end
end
if (@modalidad_login = 'T')
begin
if (@p_servicio = 10)
begin
set @subject = 'ALTA-TAXID-SUBJECT-INQUIROVITAE'
set @subject_cliente ='ALTA-TAXID-SUBJECT-INQUIROVITAE_' + convert(varchar, @p_cliente)
end
else
begin
set @subject = 'ALTA-TAXID-SUBJECT'
set @subject_cliente = 'ALTA-TAXID-SUBJECT_' + convert(varchar, @p_cliente)
end
end
else
begin
if (@p_servicio = 10)
begin
set @subject = 'ALTA-LINK-SUBJECT-INQUIROVITAE'
set @subject_cliente ='ALTA-LINK-SUBJECT-INQUIROVITAE_' + convert(varchar, @p_cliente)
end
else
begin
set @subject = 'ALTA-LINK-SUBJECT'
set @subject_cliente = 'ALTA-LINK-SUBJECT_' + convert(varchar, @p_cliente)
end
end
end
-- Cuerpo y Asunto del mail:
-- Busca para ese cliente, ese blade y esa app_id
-- Si no encuentra, busca para ese cliente, ese blade
-- Si no encuentra, busca para cliente NULL, ese blade, esa app_id
-- Si no encuentra, busca para cliente NULL, ese blase
--select @p_app_key , @p_cliente, @blade, @blade_cliente
set @mensaje = (select case @idioma
when 'eng' then mensaje.eng
when 'por' then mensaje.por
else mensaje.spa
end as mensaje
from traducciones mensaje where mensaje.blade in (@blade, @blade_cliente) and app_key = @p_app_key
and app_id = @p_app_id
and cliente = @p_cliente)
if (@mensaje is null)
set @mensaje = (select case @idioma
when 'eng' then mensaje.eng
when 'por' then mensaje.por
else mensaje.spa
end as mensaje
from traducciones mensaje where mensaje.blade in (@blade, @blade_cliente) and app_key = @p_app_key
and cliente = @p_cliente)
if (@mensaje is null)
set @mensaje = (select case @idioma
when 'eng' then mensaje.eng
when 'por' then mensaje.por
else mensaje.spa
end as mensaje
from traducciones mensaje where mensaje.blade in (@blade, @blade_cliente) and app_key = @p_app_key
and app_id = @p_app_id
and cliente is null)
if (@mensaje is null)
set @mensaje = (select case @idioma
when 'eng' then mensaje.eng
when 'por' then mensaje.por
else mensaje.spa
end as mensaje
from traducciones mensaje where mensaje.blade in (@blade, @blade_cliente) and app_key = @p_app_key
and cliente is null)
set @asunto = (select case @idioma
when 'eng' then asunto.eng
when 'por' then asunto.por
else asunto.spa
end as asunto
from traducciones asunto where asunto.blade in (@subject,@subject_cliente) and app_key = @p_app_key
and app_id = @p_app_id
and cliente = @p_cliente)
if (@asunto is null)
set @asunto = (select case @idioma
when 'eng' then asunto.eng
when 'por' then asunto.por
else asunto.spa
end as asunto
from traducciones asunto where asunto.blade in (@subject,@subject_cliente) and app_key = @p_app_key
and cliente = @p_cliente)
if (@asunto is null)
set @asunto = (select case @idioma
when 'eng' then asunto.eng
when 'por' then asunto.por
else asunto.spa
end as asunto
from traducciones asunto where asunto.blade in (@subject,@subject_cliente) and app_key = @p_app_key
and app_id = @p_app_id
and cliente is null)
if (@asunto is null)
set @asunto = (select case @idioma
when 'eng' then asunto.eng
when 'por' then asunto.por
else asunto.spa
end as asunto
from traducciones asunto where asunto.blade in (@subject,@subject_cliente) and app_key = @p_app_key
and cliente is null)
if( @asunto = 'Fidelitas S.A. - Control de Contratistas')
set @asunto = 'IMPERIUM - Control de documentación'
if exists (select multi_web.*
from multi_web
where multi_web.app_id = @p_app_id
and multi_web.cliente = @p_cliente
and multi_web.active = 1)
begin
select top 1 multi_web.*, clientes.cliente, clientes.nombre_cliente,
@mensaje as mensaje,
@asunto as asunto,
@blade as blade
from multi_web
inner join clientes on clientes.cliente = @p_cliente
where multi_web.app_id = @p_app_id
and multi_web.cliente = @p_cliente
and multi_web.active = 1
end
else
begin
if (@p_contraparte = 31319)
select top 1 multi_web.*, clientes.cliente as cliente1, clientes.nombre_cliente,
@mensaje as mensaje,
@asunto as asunto,
@blade as blade
from multi_web, clientes
where multi_web.app_id = @p_app_id
and multi_web.active = 1
and clientes.cliente = @p_cliente
else
select top 1 multi_web.*, clientes.cliente, clientes.nombre_cliente,
@mensaje as mensaje,
@asunto as asunto,
@blade as blade
from multi_web, clientes
where multi_web.app_id = @p_app_id
and multi_web.cliente is null and is_default = 1
and multi_web.active = 1
and clientes.cliente = @p_cliente
end
end
if (@accion = 'recuperar_clave') begin
set @p_app_id = (select top 1 app_id from fide_apps where CHARINDEX(upper(app_url), upper(@p_tipo_mail)) != 0 )
set @idioma = isnull(@p_idioma,'spa')
select top 1 multi_web.*,
case @idioma
when 'eng' then body.eng
when 'por' then body.por
else body.spa
end as mensaje,
case @idioma
when 'eng' then subj.eng
when 'por' then subj.por
else subj.spa
end as asunto
from multi_web
left join traducciones body on body.app_id = multi_web.app_id and body.blade = 'RECUPERAR-CONTRASEÑA'
left join traducciones subj on subj.app_id = multi_web.app_id and subj.blade = 'RECUPERAR-CONTRASEÑA-SUBJECT'
where multi_web.app_id = isnull(@p_app_id,113) -- 113 - Logo Fidelitas
and multi_web.active = 1
order by isnull(multi_web.cliente,0) desc
end
END
/*
select * from iv_migrados
select * from fide_apps
update fide_apps set migrado = 0 where app_id > 101 and app_id not in (104,106,108,110)
alter table iv_migrados add servicio_contratado int null
update iv_migrados set servicio_contratado = 10
select * from multi_web where app_id =107
*/
GO
Depends On
8Used By
No items found