CREATE PROCEDURE dbo.OnlineHalls @ATableSetupNumberID INT, @APax INT, @ACountryNumber  INT = 0, @AHotelNumber INT = -1

AS

--Oprettet 2007 1002 AV. Proc'en returnerer et dataset med lokaler der opfylder input parameter kriterier

  SELECT  DISTINCT ConferenceRooms.ConferenceRoomNumber, ConferenceRooms.Number, 
  CASE WHEN ISNULL(Translation.Name,'') = '' THEN ConferenceRooms.Name ELSE Translation.Name END AS Name, 
  ConferenceRooms.ConferenceRoomTypeNumber, ConferenceRoomTypes.Type
  FROM ConferenceRooms WITH (NOLOCK)
  INNER JOIN OnlineBookTypeHallXTab WITH (NOLOCK) ON OnlineBookTypeHallXTab.HallNumber = ConferenceRooms.ConferenceRoomNumber INNER JOIN OnlineBookType WITH (NOLOCK) ON OnlineBookTypeHallXTab.OnlineBookTypeNumber = OnlineBookType.OnlineBookTypeNumber
  INNER JOIN ConferenceRoomTypes WITH (NOLOCK) ON ConferenceRooms.ConferenceRoomTypeNumber = ConferenceRoomTypes.ConferenceRoomTypeNumber
  LEFT OUTER JOIN Translation ON Translation.ObjectNumber = ConferenceRooms.ConferenceRoomNumber AND Translation.Type = 4 AND CountryNumber = @ACountryNumber
  WHERE ISNULL(ISTable,0) = 0 
  AND AllowFilterPicassoOnline = 1
  AND (@AHotelNumber = -1 OR (@AHotelNumber > -1 AND ConferenceRooms.HotelNumber = @AHotelNumber))
  AND  DBO.OnlineHallTableSetupOK(ConferenceRooms.ConferenceRoomNumber, @ATableSetupNumberID, @APax) = 1
  AND OnlineBookType.Number = 1

