



CREATE PROCEDURE DBO.KitchenUnprinted @BeginDate char(8), @EndDate char(8) AS
SET NOCOUNT ON
SELECT     dbo.TRANSACTIONS.FolioNumber As FolioNr, dbo.TRANSACTIONS.TransactionNumber AS TransNr, dbo.TRANSACTIONS.DateStamp, 
                      dbo.TRANSACTIONS.TextOverwrite, dbo.TRANSACTIONS.Pieces as Pcs, dbo.Printers.Name AS PrinterName, dbo.PERSONEL.UserIDCode, dbo.TransactionKitchenStatementXTab.Note
                      
FROM         dbo.TRANSACTIONS WITH (NOLOCK) INNER JOIN
                      dbo.Ware WITH (NOLOCK) ON dbo.TRANSACTIONS.WareNumber = dbo.Ware.WareNumber INNER JOIN
                      dbo.FOLIOS WITH (NOLOCK) ON dbo.TRANSACTIONS.FolioNumber = dbo.FOLIOS.FolioNumber INNER JOIN
                      dbo.Printers WITH (NOLOCK) ON dbo.Ware.PrinterNumber = dbo.Printers.PrinterNumber INNER JOIN
                      dbo.PERSONEL WITH (NOLOCK) ON dbo.TRANSACTIONS.UserIDNumber = dbo.PERSONEL.UserIDNumber LEFT OUTER JOIN
                      dbo.TransactionKitchenStatementXTab WITH (NOLOCK) ON 
                      dbo.TRANSACTIONS.TransactionNumber = dbo.TransactionKitchenStatementXTab.TransactionNumber
WHERE    (dbo.TransactionKitchenStatementXTab.KitchenStatementNumber IS NULL) AND (dbo.TRANSACTIONS.InvoiceBillNumber IS NULL) AND (dbo.TRANSACTIONS.ShowOnBillFlag = 1) AND 
                 ((Transactions.MovedDeleted IS NULL) OR (Transactions.MovedDeleted=0)) AND
                 (CONVERT(varchar, dbo.TRANSACTIONS.DateStamp, 112) >= @BeginDate) AND (CONVERT(varchar, dbo.TRANSACTIONS.DateStamp, 112) <= @EndDate)
ORDER BY dbo.TRANSACTIONS.DateStamp

