



/****** Object:  View [dbo].[vDettaglioCopieRese]    Script Date: 02/10/2018 09:36:13 ******/
DROP VIEW [dbo].[vDettaglioCopieRese]
GO



/****** Object:  View [dbo].[vDettaglioCopieRese]    Script Date: 28/09/2021 18:07:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[vDettaglioCopieRese]
AS
SELECT        TOP (100) PERCENT dbo.Prodotti.Testata, dbo.Uscite.NumeroCopertina, dbo.Uscite.PrezzoCopertinaEuroDistributore AS Prezzo, dbo.Uscite.Giacenza, ISNULL(dbo.Uscite.CopieRese, 0) AS CopieRese, 
                         dbo.DocumentiRighe.IDDocumentoRiga, dbo.Documenti.IDDocumento, dbo.DocumentiRighe.PrezzoNetto, dbo.Uscite.IDUscita, dbo.Causali.Descrizione AS DescrizioneCausale, dbo.DocumentiRighe.IDCausaleMovimento, 
                         dbo.Documenti.Data, dbo.Documenti.Numero, dbo.Documenti.Descrizione, dbo.Uscite.IDProd, dbo.Uscite.PrezzoBuonoScontoEuro, dbo.DocumentiRighe.Qta, dbo.DocumentiRighe.Spunta, dbo.DocumentiRighe.QtaRec, 
                         dbo.Uscite.BarcodeAddon, dbo.Documenti.FlagRegistrataResa, dbo.DocumentiRighe.TipoRecord, dbo.DocumentiRighe.NumeroRiga, dbo.Uscite.CopieFornite, dbo.Uscite.IDEditore, dbo.Uscite.Sottotitolo, 
                         dbo.DocumentiRighe.Descrizione AS DescrizioneRiga, dbo.Uscite.Foto, dbo.Uscite.FlagContoDepositoFatt, dbo.Uscite.DataPresuntaFattCD, dbo.DocumentiRighe.PrezzoCopertina, dbo.Uscite.NoteNumeroEdicola, 
                         dbo.DocumentiRighe.Buono, dbo.Uscite.Giacenza - dbo.DocumentiRighe.Qta AS QtaDaScaricare
FROM            dbo.Prodotti INNER JOIN
                         dbo.Uscite INNER JOIN
                         dbo.Causali INNER JOIN
                         dbo.Documenti INNER JOIN
                         dbo.DocumentiRighe ON dbo.Documenti.IDDocumento = dbo.DocumentiRighe.IDDocumento ON dbo.Causali.IDCausale = dbo.DocumentiRighe.IDCausaleMovimento ON dbo.Uscite.IDUscita = dbo.DocumentiRighe.IDUscita ON 
                         dbo.Prodotti.IDProd = dbo.Uscite.IDProd LEFT OUTER JOIN
                         dbo.Soggetti ON dbo.Uscite.IDEditore = dbo.Soggetti.IDSoggetto
WHERE        (dbo.DocumentiRighe.IDCausaleMovimento > 8) AND (dbo.DocumentiRighe.IDCausaleMovimento < 21)

GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane1', @value=N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1[50] 2[25] 3) )"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4[30] 2[40] 3) )"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1[56] 3) )"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1[22] 4) )"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 9
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = -192
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Prodotti"
            Begin Extent = 
               Top = 169
               Left = 273
               Bottom = 299
               Right = 490
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Uscite"
            Begin Extent = 
               Top = 0
               Left = 547
               Bottom = 685
               Right = 808
            End
            DisplayFlags = 280
            TopColumn = 45
         End
         Begin Table = "Causali"
            Begin Extent = 
               Top = 270
               Left = 38
               Bottom = 400
               Right = 229
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Documenti"
            Begin Extent = 
               Top = 10
               Left = 28
               Bottom = 140
               Right = 238
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "DocumentiRighe"
            Begin Extent = 
               Top = 5
               Left = 260
               Bottom = 135
               Right = 500
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Soggetti"
            Begin Extent = 
               Top = 325
               Left = 279
               Bottom = 455
               Right = 481
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
      PaneHidden = 
   End
   Begin DataPane = 
      PaneHidden = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin Colu' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'vDettaglioCopieRese'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane2', @value=N'mnWidths = 11
         Column = 4455
         Alias = 3480
         Table = 4680
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'vDettaglioCopieRese'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPaneCount', @value=2 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'vDettaglioCopieRese'
GO
