CREATE PROCEDURE dbo.OnlineGetArrangementLines @AReferenceNumber INT, @AHallNumberID INT = 0 AS
--Created _AV 2007 1210
SELECT DISTINCT Packet.Text, ArrangementLines.ArrangementLineNumber,  WareText, Pieces, HallNumber,
CONVERT(DATETIME, ArrangementLines.Date,112) + CONVERT(DATETIME,ArrangementLines.Time,108) AS StartDateTime,
Price, TotalPrice FROM ArrangementLines WITH (NOLOCK)
INNER JOIN ArrangementReservationsXTab WITH (NOLOCK) ON ArrangementLines.ArrangementLineNumber = ArrangementReservationsXTab.ArrangementLineNumber
LEFT OUTER JOIN ArrangementRoomXTab WITH (NOLOCK) ON ArrangementRoomXTab.ArrangementLineNumber = ArrangementLines.ArrangementLineNumber
LEFT OUTER JOIN PacketItem_New WITH (NOLOCK) ON ArrangementRoomXTab.PacketItemNumber = PacketItem_New.PacketItemNumber
LEFT OUTER JOIN Packet WITH (NOLOCK) ON Packet.PacketNumber = PacketItem_New.PacketNumber

WHERE ArrangementReservationsXTab.ReferenceNumber = @AReferenceNumber AND (@AHallNumberID = 0 OR ArrangementLines.HallNumber = @AHallNumberId)
GO
