CREATE FUNCTION dbo.ArrangementLineWithInPeriod  (@ReferenceNumber int, @ArrDate Varchar(8))

/*
  Changes:
    KJ 20070105: Disable halls on subreservations
    KJ 20070104: Enable halls on subreservations

*/

RETURNS bit
AS
BEGIN
  declare @MainResArrival varchar(8)
  declare @MainResDeparture varchar (8)
  declare @return bit

  select @MainResArrival = Arrivaldate, @MainResDeparture = Departuredate from Reservations WITH (nolock) where ReferenceNumber = @ReferenceNumber and GuestNumber = 0

  if @ArrDate <@MainResArrival or @ArrDate >@MainResDeparture
    set @Return = 0
  else
    set @Return = 1 

 return @return
end

