Index: /trunk/RaportySQL/SzacowanieSprzedazy.rdl
===================================================================
--- /trunk/RaportySQL/SzacowanieSprzedazy.rdl (revision 164)
+++ /trunk/RaportySQL/SzacowanieSprzedazy.rdl (revision 169)
@@ -151,6 +151,6 @@
     <DataSet Name="ListaAgencji">
       <Fields>
-        <Field Name="Id_agencji">
-          <DataField>Id_agencji</DataField>
+        <Field Name="ID">
+          <DataField>ID</DataField>
           <rd:TypeName>System.Int32</rd:TypeName>
         </Field>
@@ -162,8 +162,24 @@
       <Query>
         <DataSourceName>BAZA_REKLAM</DataSourceName>
-        <CommandText>SELECT        Id_agencji, Symbol
+        <CommandText>--SELECT        Id_agencji, Symbol
+--FROM            AGENCJE where aktywna=1 and (@prawa_agencje is null or @prawa_agencje= Id_agencji)
+--UNION 
+--SELECT NULL, 'Wszystkie'
+
+
+DECLARE @Agencies TABLE
+(
+ID int,
+Symbol nvarchar(50)
+)
+
+INSERT INTO @Agencies(ID, Symbol)
+SELECT        Id_agencji, Symbol
 FROM            AGENCJE where aktywna=1 and (@prawa_agencje is null or @prawa_agencje= Id_agencji)
-UNION 
-SELECT NULL, 'Wszystkie'</CommandText>
+
+IF (@prawa_agencje IS NULL)
+INSERT INTO @Agencies (ID, Symbol) VALUES (NULL, 'Wszystkie')
+
+SELECT * FROM @Agencies</CommandText>
         <QueryParameters>
           <QueryParameter Name="@prawa_agencje">
@@ -212,8 +228,5 @@
 INSERT INTO @Agents(ID, Symbol, Agencja) VALUES (NULL, 'Wszyscy', NULL)
 
-SELECT * FROM @Agents ORDER BY Symbol
---UNION
---select NULL,'Wszyscy','costam'
---ORDER BY A.Symbol</CommandText>
+SELECT * FROM @Agents ORDER BY Symbol</CommandText>
         <QueryParameters>
           <QueryParameter Name="@agencja">
@@ -291,4 +304,6 @@
 INNER JOIN Klienci K on K.CustomerID = Z.idKlienta 
 WHERE E.zafakturowana=0
+AND R.[ZATWIERDZONO DO DRUKU]=1
+AND E.status&lt;&gt;2
 AND MONTH(N.Data_W) in (@ms) 
 AND ((R.[symbol akwizytora] in (@agent))  OR (R.[symbol akwizytora] COLLATE SQL_Latin1_General_CP1250_CI_AS in (select symbol COLLATE SQL_Latin1_General_CP1250_CI_AS from @Agents)))
Index: /trunk/BazaReklam/ReportsForm.cs
===================================================================
--- /trunk/BazaReklam/ReportsForm.cs (revision 163)
+++ /trunk/BazaReklam/ReportsForm.cs (revision 169)
@@ -194,13 +194,8 @@
                 node.Name = "/" + reportsCatalog + "/OcenaAgenta";
                 node.Text = "Ocena agentów";
-                stareRaportyTreeView.Nodes["Wp³ywy"].Nodes.Add(node);                               
+                stareRaportyTreeView.Nodes["Wp³ywy"].Nodes.Add(node);
             }
 
             if (User.getUser().St_kierownik) {
-
-                node = new TreeNode();
-                node.Name = "/" + reportsCatalog + "/SzacowanieSprzedazy";
-                node.Text = "Szacowanie sprzeda¿y";
-                stareRaportyTreeView.Nodes["Sprzeda¿"].Nodes.Add(node);
 
                 node = new TreeNode();
@@ -521,5 +516,5 @@
             }
 
-            if (User.getUser().St_kierownik)
+            if (User.getUser().St_handlowiec | User.getUser().St_subhandlowiec | User.getUser().St_kierownik)
             {
                 node = new TreeNode();
@@ -527,8 +522,5 @@
                 node.Text = "Szacowanie sprzeda¿y";
                 raportyTreeView.Nodes["Sprzeda¿"].Nodes.Add(node);
-            }
-
-            if (User.getUser().St_handlowiec | User.getUser().St_subhandlowiec | User.getUser().St_kierownik)
-            {
+                
                 node = new TreeNode();
                 node.Name = "/" + reportsCatalog + "/WynikAgenta";
@@ -749,4 +741,5 @@
                        reportViewer1.ServerReport.ReportPath == "/" + reportsCatalog + "/ZestawienieKontaktow" |
                        reportViewer1.ServerReport.ReportPath == "/" + reportsCatalog + "/RozliczenieWplywowWgDatyWplaty2" |
+                       reportViewer1.ServerReport.ReportPath == "/" + reportsCatalog + "/SzacowanieSprzedazy" |
                        reportViewer1.ServerReport.ReportPath == "/" + reportsCatalog + "/RozliczenieProwizjiZaReklame")
                     {
