

/****** Object:  View [dbo].[vRegistriVendita]    Script Date: 04/05/2017 18:28:56 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vRegistriVendita]'))
DROP VIEW [dbo].[vRegistriVendita]
GO


/****** Object:  View [dbo].[vRegistriVendita]    Script Date: 04/05/2017 18:28:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[vRegistriVendita]
AS
SELECT     dbo.DocumentiRighe.IDCausaleMovimento, dbo.vEditori.RagioneSociale AS Editore, dbo.vDL.RagioneSociale AS DL, 
                      dbo.vClienti.RagioneSociale AS Cliente, dbo.Utenti.UserName, dbo.Utenti.IDUtente, dbo.DocumentiRighe.DataOraVendita, dbo.DocumentiRighe.Qta, 
                      dbo.Prodotti.Testata, dbo.DocumentiRighe.PrezzoCopertina, dbo.DocumentiRighe.PrezzoNetto, dbo.Uscite.PrezzoCessione, dbo.DocumentiRighe.IVA, 
                      dbo.Uscite.NumeroCopertina, dbo.IVA.Aliquota, dbo.Prodotti.IDProd, dbo.Uscite.IDDL, dbo.vEdicola.RagioneSociale, dbo.vEdicola.Indirizzo, 
                      dbo.vEdicola.Cap, dbo.vEdicola.Citta, dbo.vEdicola.Prov, dbo.vEdicola.Telefono, dbo.vEdicola.Codicefiscale, dbo.vEdicola.PartitaIVA, 
                      dbo.vDL.Cognome, dbo.Uscite.IDEditore, dbo.Prodotti.IDTipoProdotto, dbo.DocumentiRighe.Provenienza, dbo.DocumentiRighe.IDUscita, 
                      dbo.DocumentiRighe.IDDocumento, dbo.Documenti.Contabilizzato, dbo.Uscite.Giacenza, dbo.Uscite.DataUscita, dbo.DocumentiRighe.IDCliente
FROM         dbo.Utenti RIGHT OUTER JOIN
                      dbo.Documenti ON dbo.Utenti.IDUtente = dbo.Documenti.IDOperatore RIGHT OUTER JOIN
                      dbo.Prodotti RIGHT OUTER JOIN
                      dbo.vEditori RIGHT OUTER JOIN
                      dbo.DocumentiRighe LEFT OUTER JOIN
                      dbo.vClienti ON dbo.DocumentiRighe.IDCliente = dbo.vClienti.IDSoggetto LEFT OUTER JOIN
                      dbo.IVA ON dbo.DocumentiRighe.IVA = dbo.IVA.IDIva RIGHT OUTER JOIN
                      dbo.Uscite ON dbo.DocumentiRighe.IDUscita = dbo.Uscite.IDUscita LEFT OUTER JOIN
                      dbo.vDL ON dbo.Uscite.IDDL = dbo.vDL.IDSoggetto ON dbo.vEditori.IDSoggetto = dbo.Uscite.IDEditore ON dbo.Prodotti.IDProd = dbo.Uscite.IDProd ON 
                      dbo.Documenti.IDDocumento = dbo.DocumentiRighe.IDDocumento CROSS JOIN
                      dbo.vEdicola
WHERE     (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[73] 4[5] 2[5] 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 [75] 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 = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = -96
         Left = 0
      End
      Begin Tables = 
         Begin Table = "Utenti"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 121
               Right = 213
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Documenti"
            Begin Extent = 
               Top = 6
               Left = 251
               Bottom = 121
               Right = 438
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "Prodotti"
            Begin Extent = 
               Top = 126
               Left = 38
               Bottom = 241
               Right = 233
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vEditori"
            Begin Extent = 
               Top = 126
               Left = 271
               Bottom = 241
               Right = 449
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "DocumentiRighe"
            Begin Extent = 
               Top = 246
               Left = 38
               Bottom = 361
               Right = 255
            End
            DisplayFlags = 280
            TopColumn = 28
         End
         Begin Table = "vClienti"
            Begin Extent = 
               Top = 223
               Left = 558
               Bottom = 338
               Right = 741
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "IVA"
            Begin Extent = 
               Top = 366
               Left = 38
               Bottom = 481
               Right = 213
            End
            DisplayFlags' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'VIEW',@level1name=N'vRegistriVendita'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_DiagramPane2', @value=N' = 280
            TopColumn = 0
         End
         Begin Table = "Uscite"
            Begin Extent = 
               Top = 486
               Left = 38
               Bottom = 601
               Right = 276
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vDL"
            Begin Extent = 
               Top = 366
               Left = 251
               Bottom = 481
               Right = 429
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vEdicola"
            Begin Extent = 
               Top = 606
               Left = 38
               Bottom = 721
               Right = 216
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 9
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         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'vRegistriVendita'
GO

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


