/****** Object:  StoredProcedure [dbo].[OnlineGetTableBookingSeating]    Script Date: 08/22/2011 13:15:50 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER OFF
GO

CREATE PROCEDURE [dbo].[OnlineGetTableBookingSeating] 
 @APax INT = 0, @ADepartmentNumber char(1) = ''
AS
/*
SG/2021-10-11: OUTER JOIN instead of inner join
SG/2021-09-16: New optional parameter @ADepartmentNumber
LJE/20110921: Read MaxPax as TableSize.
LJE/20110803: Created.
*/

select tbs.TotalPax 
 ,tbs.Priority
 ,tbs.TableCount
-- ,crt.Type TableSize
 ,crt.MaxPax TableSize
 ,tbs.PaxAtTable
 ,crt.Type 
 ,crt.ConferenceRoomTypeNumber ResourceId
 --,crt.Text TableDescription
 ,tbs.Description SeatingDescription
from TableBookingSeating tbs (NOLOCK), 
     CONFERENCEROOMTYPES crt (NOLOCK)
LEFT OUTER JOIN TableTypeDepXtab ttx (NOLOCK) ON crt.ConferenceRoomTypeNumber = ttx.TableTypeNumber
where tbs.ConferenceRoomTypeNumber = crt.ConferenceRoomTypeNumber
  and tbs.TotalPax = @APax
  and tbs.Enabled = 1
  and (ttx.DepartmentNumber = @ADepartmentNumber or @ADepartmentNumber = '')
  order by tbs.Priority,crt.Type
