

/****** Object:  StoredProcedure [dbo].[ApiDevicesProc]    Script Date: 07.09.2021 13:54:43 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



--exec [dbo].[ApiDevicesProc] 0, 'pl';

CREATE PROCEDURE [dbo].[ApiDevicesProc]

	@VendorId AS INT
	, @Lang AS varchar(2)
AS 
BEGIN
	 select [Id]
      ,[ItemId]
      ,[CustId]
      ,[CustName]
      ,[CustLocationId]
      ,[CustLocationName]
      ,[Name]
      ,[Code]
      ,[SerialNumber], SerialNumber2
      ,[Description]
      ,[GroupName1]
      ,[GroupId1]
      ,dbo.ApiTranslateWord([GroupName2],@Lang) [GroupName2]
      ,[GroupId2]
      ,dbo.ApiTranslateWord([GroupName3],@Lang) [GroupName3]
      ,[GroupId3]
      ,[ManufactureYear]
      ,[StateId]
      ,dbo.ApiTranslateText([StateName],@Lang,'-') [StateName]
      ,[Adress]
      ,[geolat]
      ,[geolong]
      ,[inUseFrom]
      ,[Counters],CountersDate
      ,[Price]
      ,[Price2]
      ,[InspectionFrequency]
      ,[VendorId]
	  ,InventoryValue
	  ,WarrantyType,WarrantyDate,WarrantyCounter,Attachments
	 
	 from dbo.ApiDevicesView where  VendorId=0 OR VendorId = @VendorId
	
END



GO


