/****** Object:  View [dbo].[view_seg_perfil]    Script Date: 10/12/2011 14:57:03 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[view_seg_perfil]'))
DROP VIEW [dbo].[view_seg_perfil]
GO
CREATE  VIEW [dbo].[view_seg_perfil] AS
SELECT 	[seg_perfil].[id] AS [id],
		[seg_perfil].[uid] AS [uid],
		[seg_perfil].[eid] AS [eid],
		[seg_perfil].[id_usuario_modifico] AS [id_usuario_modifico],
		[seg_perfil].[id_usuario_creo] AS [id_usuario_creo],
		[seg_perfil].[fechaModificacion] AS [fechaModificacion],
		[seg_perfil].[fechaCreacion] AS [fechaCreacion],
		[seg_perfil].[active] AS [active],
		[seg_perfil].[perfil] AS [perfil],
		[seg_perfil].[perfil_codigo] AS [perfil_codigo],
		[seg_perfil].[descripcion] AS [descripcion],
		[seg_perfil].[mostrarBotones] AS [mostrarBotones],
        [seg_perfil].[paraCliente] AS [paraCliente],
        [seg_perfil].[paraProveedor] AS [paraProveedor],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [seg_perfil]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[seg_perfil].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[seg_perfil].[id_usuario_creo]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [seg_perfil].eid = [empresaCodigo].[codigo] and empresaCodigo.active=1
WHERE [seg_perfil].active=1
