
/****** Object:  View [dbo].[view_cat_catalogo_bodega]    Script Date: 10/04/2013 09:33:06 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[view_cat_catalogo_bodega]'))
DROP VIEW [dbo].[view_cat_catalogo_bodega]
GO


/****** Object:  View [dbo].[view_cat_catalogo_bodega]    Script Date: 10/04/2013 09:33:07 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER OFF
GO

CREATE  VIEW [dbo].[view_cat_catalogo_bodega] AS
SELECT 	[cat_catalogo_bodega].[id] AS [id],
		[cat_catalogo_bodega].[uid] AS [uid],
		[cat_catalogo_bodega].[eid] AS [eid],
		[cat_catalogo_bodega].[id_usuario_modifico] AS [id_usuario_modifico],
		[cat_catalogo_bodega].[id_usuario_creo] AS [id_usuario_creo],
		[cat_catalogo_bodega].[fechaModificacion] AS [fechaModificacion],
		[cat_catalogo_bodega].[fechaCreacion] AS [fechaCreacion],
		[cat_catalogo_bodega].[active] AS [active],
		[cat_catalogo_bodega].[catalogo_bodega] AS [catalogo_bodega],
		[cat_catalogo_bodega].[disponible] AS [disponible],
		[cat_catalogo_bodega].[existencia] AS [existencia],
		[cat_catalogo_bodega].[reservado] AS [reservado],
		[cat_catalogo_bodega].[existenciaMinima] AS [existenciaMinima],
		[cat_catalogo_bodega].[enOrdenes] AS [enOrdenes],
		[cat_catalogo_bodega].[localizacion] AS [localizacion],
		[cat_catalogo_bodega].[costo] AS [costo],
		[cat_catalogo_bodega].[existenciaMaxima] AS [existenciaMaxima],
		[cat_catalogo_bodega].[id_catalogo] AS [id_catalogo],
[cat_catalogo].[catalogo] as [cat_catalogo_catalogo],
[cat_catalogo].[catalogo_codigo] as [cat_catalogo_catalogo_codigo],
[cat_catalogo].[codigoInventario] as [cat_catalogo_codigoInventario],
[cat_catalogo].[precioVenta] as [cat_catalogo_precioVenta],
[cat_catalogo].[tiempoConsecucion] as [cat_catalogo_tiempoConsecucion],
[cat_catalogo].[esNacional] as [cat_catalogo_esNacional],
[cat_catalogo].[id_familia] as [cat_catalogo_id_familia],
[cat_catalogo].[id_subTipoCatalogo] as [cat_catalogo_id_subTipoCatalogo],
[cat_catalogo].[id_unidad] as [cat_catalogo_id_unidad],
[cat_catalogo].[id_impuesto] as [cat_catalogo_id_impuesto],
[cat_catalogo].[descripcion] as [cat_catalogo_descripcion],
[cat_catalogo].[bloquearCostear] as [cat_catalogo_bloquearCostear],
		[cat_catalogo_bodega].[id_bodega] AS [id_bodega],
[gen_bodega].[bodega] as [gen_bodega_bodega],
[gen_bodega].[bodega_codigo] as [gen_bodega_bodega_codigo],
[gen_bodega].[salidasEnRojo] as [gen_bodega_salidasEnRojo],
[gen_bodega].[usaLocalizacion] as [gen_bodega_usaLocalizacion],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [cat_catalogo_bodega]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[cat_catalogo_bodega].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[cat_catalogo_bodega].[id_usuario_creo]
	INNER JOIN [cat_catalogo] ON [cat_catalogo].id=[cat_catalogo_bodega].[id_catalogo]
	INNER JOIN [gen_bodega] ON [gen_bodega].id=[cat_catalogo_bodega].[id_bodega]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [cat_catalogo_bodega].eid = [empresaCodigo].[codigo] and empresaCodigo.active=1

GO


