USE [P21]
GO

/****** Object:  StoredProcedure [dbo].[nutech_inv_mast_bins]    Script Date: 10/11/2024 12:52:18 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- ===================================================
-- Author:		Fred Rappuhn, NuTech Services, LLC
-- Create date: 08/23/2007
-- Description:	Return primary and all secondary bins
-- ===================================================
CREATE PROCEDURE [dbo].[nutech_inv_mast_bins] 
	@location_id as integer, 
	@inv_mast_uid as integer
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    select inv_loc.primary_bin, 
      Stuff((
	    select ', ' + '[' + inv_bin.bin + ']'
	    from inv_bin, inv_loc, bin
        where inv_loc.location_id = inv_bin.location_id
        and inv_loc.inv_mast_uid = inv_bin.inv_mast_uid
        and inv_bin.inv_mast_uid = @inv_mast_uid
        and inv_bin.location_id = @location_id
		and bin.location_id = inv_bin.location_id
		and bin.bin_id = inv_bin.bin
		and bin.bin_type_uid <> 25
		and (inv_bin.bin not like 'MSBS%' AND
		     inv_bin.bin not like 'RECV%' AND
		     inv_bin.bin not like 'SHIP%' AND
			 inv_bin.bin not like 'WEBUI%' )
	    order by inv_bin.bin
	    FOR XML PATH('')
      ),1,2,'') as bins
    from inv_loc 
    where inv_loc.inv_mast_uid = @inv_mast_uid
      and inv_loc.location_id = @location_id

END
GO


