Bladeren bron

Merge branch 'master' of bn.git:plabudda/se

Piotr Labudda 8 jaren geleden
bovenliggende
commit
874b820264

+ 272 - 9
SE/schema/default_db_xml_cache.public/default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_tree_to_dita.xsl

@@ -15,7 +15,7 @@
     
     <xsl:variable name="KRS_own">
         <KRS_own>
-            <KRS>0000033455</KRS>
+           <!-- <KRS>0000033455</KRS>
             <KRS>0000049425</KRS>
             <KRS>0000207049</KRS>
             <KRS>0000372150</KRS>
@@ -32,9 +32,9 @@
             <KRS>0000539158</KRS>
             <KRS>0000539818</KRS>
             <KRS>0000540064</KRS>
-            <KRS>0000033455</KRS><!-- ENERGA-OPER -ATOR SPÓŁKA AKCYJNA -->
+            <KRS>0000033455</KRS><!-\- ENERGA-OPER -ATOR SPÓŁKA AKCYJNA -\->
             <KRS>0000007426</KRS>
-            <KRS>0000025667</KRS>
+            <KRS>0000025667</KRS>-->
         </KRS_own>
     </xsl:variable>
     
@@ -304,6 +304,24 @@
                 </topichead>
                 
                 
+                <!-- ##### <topichead navtitle="Powiązania do obiektów KRS ogólnie dla wyzwolenia analizy ogólnej">
+                    
+                    <xsl:for-each-group select="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row[object[position() =  last()]/BI_audit_KRS ]" group-by="object[position() =  last()]/BI_audit_KRS/concat(ID,krs)">
+                        <xsl:variable name="group_name" select="object[position() = last() ]/* [ position() = 1]/system_cache__appinfo:truncate_special_and_do_uppercase(concat(ID,krs,nazwa,position()))"/>
+                        
+                        <xsl:variable name="current_group" select="current-group()"/>
+                        <xsl:variable name="krs" select=" object[ position() = last()]/ BI_audit_KRS/krs"/>
+                        <!-\-<topichead navtitle="{object[position() = last()]/*/concat(Pelna_nazwa_kontrahenta,' ',Miejscowosc,' ',NIP)} powiązań ({ count( current-group())}) ">-\->
+                                <xsl:apply-templates mode="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_do_krs" select="current-group()[ position() = 1]">
+                                    <xsl:with-param name="group_name" select="$group_name"/>
+                                    <xsl:with-param name="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA" select="$BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA"/>
+                                    <xsl:with-param name="resulset" select="$resulset"/>
+                                    <xsl:with-param name="krs" select="$krs"/>
+                                </xsl:apply-templates>
+                        <!-\-</topichead>-\->
+                    </xsl:for-each-group>
+                </topichead>-->
+                
                 
                 <topichead navtitle="Powiązania wykryte po wyrywkowym uzupełnieniu danych (w przypadku dowiązania raportu porównawczego) ">
                     
@@ -587,7 +605,7 @@
                         <xsl:value-of select="A_ulica"/><xsl:text> </xsl:text><xsl:value-of select="A_nrDomu"/>
                     </title>
                     <body>
-                        
+                        <draft-comment author="a.binder">#608</draft-comment>
                         <simpletable frame="all" relcolwidth="1* 3* 3*" id="simpletable_rows__child_krs_{$group_name}_{$refpos}">
                             <strow>
                                 <stentry>Lp</stentry>
@@ -623,6 +641,18 @@
                                                         <xsl:value-of select="../../object[ position() = last()]/* [ position() = 1 ] /concat(Pelna_nazwa_kontrahenta,' ',Seller_Person,' ',Nr_KW)"/>
                                                     </xref>
                                                 </xsl:when>
+                                                <xsl:when test="../../object[ position() = last()]/BI_audit_KRS">
+                                                    <xsl:variable name="krs" select="../../object[ position() = last()]/*[ position() = 1]/krs"/>
+                                                    <xref href="../KRSY_{$krs}/{$krs}_1.dita">
+                                                        KRS:  <xsl:value-of select="../../object[ position() = last()]/*[ position() = 1]/concat(nazwa,' ',S_miejscowosc, ' ',nip)"/>
+                                                    </xref>
+                                                </xsl:when>
+                                                <xsl:when test="../../object[ position() = last()]/BI_audit_KRS_company">
+                                                        KRS:  <xsl:value-of select="../../object[ position() = last()]/*[ position() = 1]/concat(nazwa,' ',S_miejscowosc, ' ',nip)"/>
+                                                </xsl:when>
+                                                <xsl:when test="../../object[ position() = last()]/BI_audit_KRS_person">
+                                                    KRS(osoba):  <xsl:value-of select="../../object[ position() = last()]/*[ position() = 1]/concat(nazwisko,' ',imiona, ' ',pesel)"/>
+                                                </xsl:when>
                                                 <xsl:otherwise>
                                                     <xsl:value-of select="../../object[ position() = last()]/* [ position() = 1 ] /concat(Pelna_nazwa_kontrahenta,' ',Seller_Person,' ',Nr_KW)"/>
                                                 </xsl:otherwise>
@@ -644,6 +674,210 @@
         
     </xsl:template>
     
+    
+    <!--<xsl:template mode="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_do_krs" match="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row">
+        <xsl:param name="group_name" required="yes"/>
+        <xsl:param name="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA" required="yes"/>
+        <xsl:param name="resulset" required="yes"/>
+        <xsl:param name="krs" required="yes"/>
+        <xsl:variable name="current" select="."/>
+        
+        
+        <topicref href="{$group_name}_DO_krs/{position()}.dita">
+            <xsl:result-document href="{$temp}/{$uuid}/{$group_name}_DO/{position()}.dita">
+                <topic id="topic_simpletable_cheat_row_{$group_name}_DO_{position()}_{ generate-id()}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                    xsi:noNamespaceSchemaLocation="urn:oasis:names:tc:dita:xsd:topic.xsd">
+                    <title>Powiązanie do KRS
+                        <xsl:value-of select="object[ position() = last()]/*/regon"/><xsl:text> </xsl:text>
+                        <xsl:value-of select="object[ position() = last()]/*/S_miejscowosc"/><xsl:text> </xsl:text>
+                        <xsl:value-of select="object[ position() = last()]/*/nip"/><xsl:text> </xsl:text>
+                        ilość: <xsl:value-of select=" count(current-group())"/>
+                    </title>
+                    
+                    <body>
+                        <p>
+                            
+                            Występuje w powiązaniach: 
+                            <simpletable frame="all" relcolwidth="1* 2* 2* 4*" id="simpletable_rows__child_cheat_2_krs_{$group_name}_{ position()}_{generate-id()}">
+                                <strow>
+                                    <stentry>Lp</stentry>
+                                    <stentry>Osoba powiązana</stentry>
+                                    <stentry>Rejestr</stentry>
+                                    <stentry>Dane z rejestru</stentry>
+                                </strow>
+                                
+                                
+                                <xsl:for-each-group select="current-group()/object[ position() = 1]" group-by="BI_audit_ENERGA_PRACOWNICY/ID">
+                                    <xsl:variable name="current_pesel" select="BI_audit_ENERGA_PRACOWNICY/pesel"/>
+                                    <!-\- chce sprawdzic czy pesel inny niz current() wystepuje w BI_audit_KRS_person jak tak to olac  -\->
+                                    <xsl:variable name="test_if_prev_worker">
+                                        <xsl:for-each select="../object/BI_audit_KRS_person[not(pesel = $current_pesel)]">
+                                            <xsl:variable name="current_pesel_2" select="pesel/text()"/>
+                                            <!-\-testuje:<xsl:value-of select="$current_pesel_2"/>,-\->
+                                            <xsl:for-each select="$BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA//BI_audit_ENERGA_PRACOWNICY[pesel/text()=$current_pesel_2][1]">
+                                                <prev pesel="{pesel}">
+                                                    <xsl:value-of select="nazwisko"/>
+                                                </prev>
+                                            </xsl:for-each>
+                                        </xsl:for-each>
+                                    </xsl:variable>
+                                    <!-\-<xsl:choose>
+                                        <xsl:when test=" count(../object/BI_audit_ENERGA_PRACOWNICY) &gt; 1">-\->
+                                    <!-\-<strow>
+                                            <stentry>dodatk jest</stentry>
+                                            <stentry><xsl:value-of select=" count(../object/BI_audit_ENERGA_PRACOWNICY)"/></stentry>
+                                            <stentry>following-sibling::node test_if_prev_worker <xsl:for-each-group select="$test_if_prev_worker/prev" group-by="@pesel"><xsl:value-of select="@pesel"/><xsl:value-of select="."/></xsl:for-each-group></stentry>
+                                            <stentry>$current_pesel = <xsl:value-of select="$current_pesel"/><!-\\-following-siblin::node <xsl:value-of select="preceding-sibling::node()/BI_audit_ENERGA_PRACOWNICY"/>-\\-></stentry>
+                                        </strow>-\->
+                                    <!-\- 
+                                    </xsl:when>
+                                    <xsl:otherwise>
+                                        <strow>
+                                            <stentry>dodatk nie jest</stentry>
+                                            <stentry><xsl:value-of select=" count(../object/BI_audit_ENERGA_PRACOWNICY)"/></stentry>
+                                            <stentry>following-sibling::node test_if_prev_worker <xsl:copy-of select="$test_if_prev_worker"/><!-\\-<xsl:copy-of select="$current/../following-sibling::node()/name()"></xsl:copy-of>-\\-></stentry>
+                                            <stentry><!-\\-<xsl:copy-of select="following-sibling::node()/name()"></xsl:copy-of>-\\-></stentry>
+                                        </strow>
+                                    </xsl:otherwise>
+                                </xsl:choose>-\->
+                                    <xsl:choose>
+                                        <xsl:when test="$test_if_prev_worker/prev"/>
+                                        <xsl:otherwise>
+                                            <strow>
+                                                <stentry><xsl:value-of select="position()"/></stentry>
+                                                <stentry>
+                                                    <xsl:variable name="group_name_refpos" select="$current/object[ position() = 1]/BI_audit_ENERGA_PRACOWNICY/system_cache__appinfo:truncate_special_and_do_uppercase(concat(imiona,'_',nazwisko,'_',nip))"/>
+                                                    <!-\-<xsl:variable name="group_name_refpos" select="../../object[position() = last() ]/* [ position() = 1]/system_cache__appinfo:truncate_special_and_do_uppercase(concat(ID,Pelna_nazwa_kontrahenta,'_kontr'))"/>-\->
+                                                    <xsl:variable name="refpos" select="concat($current/object[ position() = last()]/* [ position() = 1]/concat(name(),ID),'_', 1)"/>
+                                                    <xref href="../{$group_name_refpos}/{$refpos}.dita">
+                                                        <xsl:value-of select="*/concat(imiona,' ', nazwisko, ' ', nip,' (żr:',source,')')"/>
+                                                    </xref>
+                                                </stentry>
+                                                <stentry>
+                                                    <xsl:variable name="name">
+                                                        <name><xsl:value-of select="*/name()"/></name>
+                                                    </xsl:variable>
+                                                    <xsl:apply-templates mode="enter_to_ph_text" select="$name/name">
+                                                        <xsl:with-param name="element" select="'entry'"/>
+                                                    </xsl:apply-templates>
+                                                </stentry>
+                                                <stentry>
+                                                    <xsl:for-each select="*/*">
+                                                        <xsl:if test="text()">
+                                                            <xsl:variable name="name">
+                                                                <name><xsl:value-of select="name()"/></name>
+                                                            </xsl:variable>
+                                                            <b><xsl:apply-templates mode="enter_to_ph_text" select="$name/name">
+                                                                <xsl:with-param name="element" select="'entry'"/>
+                                                            </xsl:apply-templates></b>
+                                                            <xsl:text> </xsl:text>
+                                                            <xsl:apply-templates mode="enter_to_ph_text" select=".">
+                                                                <xsl:with-param name="element" select="'entry'"/>
+                                                            </xsl:apply-templates>
+                                                            <xsl:text> </xsl:text>
+                                                        </xsl:if>
+                                                    </xsl:for-each>
+                                                </stentry>
+                                            </strow>
+                                        </xsl:otherwise>
+                                    </xsl:choose>
+                                    
+                                </xsl:for-each-group>
+                            </simpletable>
+                            
+                        </p>
+                        <p>
+                            Podpisane umowy:<!-\-(<xsl:value-of select="../BI_audit_ENERGA_RUM_KONTRAHENCI[ID/text()='2816']/BI_audit_ENERGA_RUM_UMOWY/Tytul_dokumentu"/>)-\->
+                            <!-\- (<xsl:value-of select="current()/object[ position() = last() ]/BI_audit_ENERGA_RUM_KONTRAHENCI/ID "/>)-\->
+                            <simpletable frame="all" relcolwidth="1* 1* 1* 1* 1* 1*" id="simpletable_rows__child_cheat_4{$group_name}_{generate-id()}_{ position()}">
+                                <strow>
+                                    <stentry>Data utw. spr./ Tytul dokumentu</stentry>
+                                    <stentry>Wprowadzajacy wniosek</stentry>
+                                    <stentry>Kontrahent</stentry>
+                                    <stentry>Akceptujacy merytorycznie</stentry>
+                                    <stentry>Osoba merytoryczna</stentry>
+                                    <stentry>Przedmiot umowy</stentry>
+                                </strow>
+                                <strow>
+                                    <stentry>Spółka główna</stentry>
+                                    <stentry>Typ umowy</stentry>
+                                    <stentry>Wartosc zlecenia zamowienia netto w PLN</stentry>
+                                    <stentry>Wartosc zlecenia zamowienia netto w walucie</stentry>
+                                    <stentry>Wartosc przedmiotu umowy netto w PLN</stentry>
+                                    <stentry>Wartosc kosztowa przedmiotu umowy netto w walucie </stentry>
+                                </strow>
+                                <!-\-  current()/object[ position() = last() ]/I -\->
+                                <xsl:for-each select="$resulset/BI_audit_ENERGA_RUM_KONTRAHENCI[ID/text()= current()/object[ position() = last() ]/BI_audit_ENERGA_RUM_KONTRAHENCI/ID/text()]/BI_audit_ENERGA_RUM_UMOWY">
+                                    <xsl:sort select="Wartosc_przedmiotu_umowy_netto_w_PLN" order="descending"/>
+                                    <xsl:choose>
+                                        <xsl:when test=" position() &lt; 100">
+                                            <strow>
+                                                <stentry><xsl:value-of select="Data_utworzenia_sprawy"/> / 
+                                                    <xsl:apply-templates mode="enter_to_ph_text" select="Tytul_dokumentu">
+                                                        <xsl:with-param name="element" select="'entry'"/>
+                                                    </xsl:apply-templates>
+                                                    <!-\-<xsl:value-of select="field[@name='Tytul_dokumentu']"/>-\-></stentry>
+                                                <stentry>
+                                                    <xsl:value-of select="Wprowadzajacy_wniosek___nazwisko_i_imie"/>
+                                                </stentry>
+                                                <stentry>
+                                                    <xsl:apply-templates mode="enter_to_ph_text" select="Pelna_nazwa_kontrahenta">
+                                                        <xsl:with-param name="element" select="'entry'"/>
+                                                    </xsl:apply-templates>
+                                                </stentry>
+                                                <stentry>
+                                                    <xsl:value-of select="Akceptujacy_merytorycznie___nazwisko_i_imie"/>
+                                                </stentry>
+                                                <stentry>
+                                                    <xsl:value-of select="Osoba_merytoryczna___nazwisko_i_imie"/>
+                                                </stentry>
+                                                <stentry>
+                                                    <xsl:apply-templates mode="enter_to_ph_text" select="Przedmiot_umowy">
+                                                        <xsl:with-param name="element" select="'entry'"/>
+                                                    </xsl:apply-templates>
+                                                    <!-\-<xsl:value-of select="field[@name='Przedmiot_umowy']"/>-\-></stentry>
+                                            </strow>
+                                            <strow>
+                                                <stentry>
+                                                    <xsl:value-of select="Spolka_glowna"/>
+                                                </stentry>
+                                                <stentry><xsl:value-of select="Typ_umowy__aktualny_"/></stentry>
+                                                <stentry><xsl:value-of select="Wartosc_zlecenia_zamowienia_netto_w_PLN"/></stentry>
+                                                <stentry><xsl:value-of select="Wartosc_zlecenia_zamowienia_netto_w_walucie"/></stentry>
+                                                <stentry><xsl:value-of select="Wartosc_przedmiotu_umowy_netto_w_PLN__aktualna_"/></stentry>
+                                                <stentry><xsl:value-of select="Wartosc_kosztowa_przedmiotu_umowy_netto_w_walucie"/></stentry>
+                                            </strow>
+                                            <strow>
+                                                <stentry>-</stentry>
+                                                <stentry>-</stentry>
+                                                <stentry>-</stentry>
+                                                <stentry>-</stentry>
+                                                <stentry>-</stentry>
+                                                <stentry>-</stentry>
+                                            </strow>
+                                        </xsl:when>
+                                        <xsl:when test="position() = 100">
+                                            <strow>
+                                                <stentry>Zestawienie zawiera więcej rekordów</stentry>
+                                                <stentry>Pominięto z uwagi na wielkość raportu</stentry>
+                                                <stentry/>
+                                                <stentry/>
+                                                <stentry/>
+                                                <stentry/>
+                                            </strow>
+                                        </xsl:when>
+                                        <xsl:otherwise/>
+                                    </xsl:choose>
+                                </xsl:for-each>
+                            </simpletable>
+                        </p>
+                    </body>
+                </topic>
+            </xsl:result-document>
+        </topicref>
+    </xsl:template>-->
+    
+    
     <xsl:template mode="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_do" match="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row">
         <xsl:param name="group_name" required="yes"/>
         <xsl:param name="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA" required="yes"/>
@@ -887,7 +1121,7 @@
         <xsl:param name="BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA" required="yes"/>
         <xsl:variable name="position" select="position()"/>
         
-        <xsl:for-each-group select=" current-group()" group-by="object[position() =  last()]/*[ position() = 1]/concat(name(),ID,imiona,nazwisko,pesel,nip)">
+        <xsl:for-each-group select=" current-group()" group-by="object[position() =  last()]/*[ position() = 1]/concat(name(),ID,imiona,nazwisko,pesel,nip,regon,krs)">
             <xsl:sort select="count(object)" order="ascending"/>
             <!--<xsl:for-each select="current-group()">-->
                 
@@ -931,12 +1165,13 @@
                                             <xsl:value-of select="object[ position() = 1]/*/nazwisko"/><xsl:text> </xsl:text>
                                             <xsl:value-of select="object[ position() = 1]/*/nip"/><xsl:text> </xsl:text>
                                             źródło:<xsl:value-of select="object[ position() = 1]/*/source"/>
-                                            - do : <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(Pelna_nazwa_kontrahenta,' - ',Miejscowosc, ' ',NIP,' ',Nr_dzialki,' ',Nr_KW,' ',Seller_person)"/><xsl:text> </xsl:text>
+                                            - do : <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(Pelna_nazwa_kontrahenta,nazwa,nazwisko,' - ',Miejscowosc, ' ',NIP,imiona,' ',regon,' ',Nr_dzialki,' ',Nr_KW,' ',Seller_person,pesel)"/><xsl:text> </xsl:text>
                                             <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/Seller_person"/><xsl:text> </xsl:text> poprzez: <xsl:value-of select="object[ position() = last()]/relation_from"/>
                                             (gł.szuk.: <xsl:value-of select="count(object)"/>) ;
                                         </title>
                                         
                                         <body>
+                                            <draft-comment author="a.binder">#1171</draft-comment>
                                             <p>
                                                 Ścieżka śledzenia do 
                                                 <xsl:choose>
@@ -946,11 +1181,21 @@
                                                         
                                                     </xsl:when>
                                                     <xsl:when test="object[ position() = last()]/BI_audit_ENERGA_RUM_KONTRAHENCI">
-                                                        
                                                         <xref href="../{$group_name_refpos.kon}/{$refpos.kon}.dita">
                                                             kontrahenta:  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(Pelna_nazwa_kontrahenta,' ',Miejscowosc, ' ',NIP,' ',Nr_dzialki,' ',Nr_KW,' ',Seller_Person)"/>
                                                         </xref>
-                                                        
+                                                    </xsl:when>
+                                                    <xsl:when test="object[ position() = last()]/BI_audit_KRS">
+                                                        <xsl:variable name="group_name" select="object[ position() = last()]/concat('KRSY_',krs)"/>
+                                                        <xref href="../{$group_name}/{$refpos.kon}.dita">
+                                                            KRS:  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(nazwa,' ',S_miejscowosc, ' ',nip)"/>
+                                                        </xref>
+                                                    </xsl:when>
+                                                    <xsl:when test="object[ position() = last()]/BI_audit_KRS_company">
+                                                        KRS (firma):  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(nazwa,' ',S_miejscowosc, ' ',nip)"/>
+                                                    </xsl:when>
+                                                    <xsl:when test="object[ position() = last()]/BI_audit_KRS_person">
+                                                        KRS (osoba):  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(nazwisko,' ',imiona, ' ',pesel)"/>
                                                     </xsl:when>
                                                     <xsl:otherwise>
                                                         
@@ -1125,12 +1370,13 @@
                                                 <xsl:value-of select="object[ position() = 1]/*/nazwisko"/><xsl:text> </xsl:text>
                                                 <xsl:value-of select="object[ position() = 1]/*/nip"/><xsl:text> </xsl:text>
                                                 źródło:<xsl:value-of select="object[ position() = 1]/*/source"/><xsl:text> </xsl:text>
-                                                - do : <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(Pelna_nazwa_kontrahenta,' ',Miejscowosc, ' ',NIP,' ',Nr_dzialki,' ',Nr_KW,' ',Seller_person)"/><xsl:text> </xsl:text>
+                                                - do : <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(Pelna_nazwa_kontrahenta,nazwa,nazwisko,' - ',Miejscowosc,imiona,' ',NIP,' ',regon,' ',Nr_dzialki,' ',Nr_KW,' ',Seller_person,pesel)"/><xsl:text> </xsl:text>
                                                 <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/Seller_person"/><xsl:text> </xsl:text> poprzez: <xsl:value-of select="object[ position() = last()]/relation_from"/>
                                                 (gł.szuk.: <xsl:value-of select="count(object)"/>) ;
                                             </title>
                                             
                                             <body>
+                                                <draft-comment author="a.binder">#1376</draft-comment>
                                                 <p>
                                                     Ścieżka śledzenia do 
                                                     <xsl:choose>
@@ -1139,6 +1385,23 @@
                                                             działki:  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(Pelna_nazwa_kontrahenta,' ',Miejscowosc, ' ',NIP,' ',Nr_dzialki,' ',Nr_KW,' ',Seller_Person)"/>
                                                             
                                                         </xsl:when>
+                                                        
+                                                        <xsl:when test="object[ position() = last()]/BI_audit_KRS">
+                                                            <xsl:variable name="group_name" select="object[ position() = last()]/concat('KRSY_',krs)"/>
+                                                            <xref href="../{$group_name}/{$refpos.kon}.dita">
+                                                                KRS:  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(nazwa,' ',S_miejscowosc, ' ',nip)"/>
+                                                            </xref>
+                                                            
+                                                        </xsl:when>
+                                                        
+                                                        <xsl:when test="object[ position() = last()]/BI_audit_KRS_company">
+                                                                KRS (firma):  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(nazwa,' ',S_miejscowosc, ' ',nip)"/>
+                                                        </xsl:when>
+                                                        
+                                                        <xsl:when test="object[ position() = last()]/BI_audit_KRS_person">
+                                                            KRS (osoba):  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(nazwisko,' ',imiona, ' ',pesel)"/>
+                                                        </xsl:when>
+                                                        
                                                         <xsl:otherwise>
                                                             <xref href="../{$group_name_refpos.kon}/{$refpos.kon}.dita">
                                                                 kontrahenta:  <xsl:value-of select="object[ position() = last()]/*[ position() = 1]/concat(Pelna_nazwa_kontrahenta,' ',Miejscowosc, ' ',NIP,' ',Nr_dzialki,' ',Nr_KW,' ',Seller_Person)"/>

+ 29 - 7
SE/se-lib/Route/UrlAction/BiAuditGenerate.php

@@ -186,6 +186,7 @@ function toggle(source) {
 			if (!($lAppoitmentInfo = V::get('info', false, $_POST))) throw new Exception("Błąd formularza!");
 			if (!($BiAnalizaMinDepth = V::get('minDepth', false, $_POST))) throw new Exception("Błąd formularza!");
 			if (!($BiAnalizaMaxDepth = V::get('maxDepth', false, $_POST))) throw new Exception("Błąd formularza!");
+			if (!($BiAnalizaOnlyTargets = V::get('onlyTargets', false, $_POST))) throw new Exception("Błąd formularza!");
 			$query = "select * from BI_audit_ENERGA_PRACOWNICY where ID='{$prID[0]}'";
 			$result = DB::getPDO()->fetchFirst($query);
 			if (!$result) throw new Exception("Błąd formularza!");
@@ -200,6 +201,7 @@ function toggle(source) {
 				'BI_analiza_reloadCache' => $sqlUpdate['BI_analiza_reloadCache'],
 				'BI_analiza_minDepth' => $BiAnalizaMinDepth,
 				'BI_analiza_maxDepth' => $BiAnalizaMaxDepth,
+				'BI_analiza_onlyTargets' => $BiAnalizaOnlyTargets,
 			];
 			$powiazanieID = DB::getDB()->ADD_NEW_OBJ('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', (object)$sqlInsert);
 			if ($powiazanieID) SE_Layout::alert('success','Dodano rekord do wygenerowania powiązań');
@@ -320,6 +322,7 @@ function toggle(source) {
             <td>Adnotacje</td>
             <td>Minimalna głębokość analizy</td>
             <td>Maksymalna głębokość analizy</td>
+            <td>Powiązania tylko do celów</td>
             <td>Status raportu</td>
             <td>Status raportu - informacje</td>
             <td>Indywidualny raport</td>
@@ -337,7 +340,7 @@ join `{$refPowiazaniaToPracownicy}` on `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZAN
 where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
 		$result = DB::getPDO()->fetchAll($query);
 
-		if (!$result) echo '<tr><td align="center" colspan="8">Brak znalezionych powiązań</td></tr>';
+		if (!$result) echo '<tr><td align="center" colspan="9">Brak znalezionych powiązań</td></tr>';
 		else {
 	                foreach ($result as $row) {
 				$query = "select count(*) from `{$refPowiazaniaToPracownicy}` where `PRIMARY_KEY` = '{$row['ID']}'";
@@ -348,6 +351,7 @@ where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
             <td><?=$row['L_APPOITMENT_INFO']?></td>
             <td><?=$row['BI_analiza_minDepth']?></td>
             <td><?=$row['BI_analiza_maxDepth']?></td>
+            <td><?=($row['BI_analiza_onlyTargets'] == 'N' ? "Nie" : "Tak")?></td>
             <td><?=$row['FILE_STATUS']?></td>
             <td><?=$row['FILE_STATUS_info']?></td>
             <td><?=($count > 1 ? 'Nie' : 'Tak')?></td>
@@ -379,6 +383,15 @@ where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
         <input type="number" class="form-control" name="maxDepth" id="maxDepth" data-bind="value:replyNumber" min="1" max="9" value="6" required/>
       </div>
     </div>
+    <div class="form-group">
+      <label class="col-sm-4 control-label">Czy zwracać tylko wyniki ze znalezionymi obiektami docelowymi (z tabeli kontrahentów)?</label>
+      <div class="col-sm-1">
+        <select name="onlyTargets" class="form-control">
+          <option value="Y" selected>Tak</option>
+          <option value="N">Nie</option>
+        </select>
+      </div>
+    </div>
     <div class="form-group">
       <label class="col-sm-4 control-label">Adnotacje</label>
       <div class="col-sm-4">
@@ -415,7 +428,6 @@ where `REMOTE_PRIMARY_KEY` = '{$this->SOURCE['ID']}'";
     <input type="hidden" name="prID[]" value="<?=$pracownik['ID']?>">
   </form>
 </div>
-DUPA
 <script language="JavaScript">
 <!--
 function validate() {
@@ -551,7 +563,10 @@ function validate() {
 				case "addKrsToKontrahenci":
 					$krsId = V::get('krsId', 0, $_POST, int);
 					if (!$krsId) throw new Exception("Błąd formularza");
-					$query = "insert into BI_audit_ENERGA_RUM_KONTRAHENCI (uwagi, Pelna_nazwa_kontrahenta, REGON, NIP, KRS) select 'import z KRS', nazwa, regon, nip, krs from BI_audit_KRS where ID = ".$krsId." ";
+					$query = "select count(*) from BI_audit_ENERGA_RUM_KONTRAHENCI kh join BI_audit_KRS krs on (kh.NIP = krs.nip or kh.REGON = krs.regon or kh.KRS = krs.krs) where krs.ID = '{$krsId}'";
+					$kontrahentExists = DB::getPDO()->fetchValue($query);
+					if ($kontrahentExists) throw new Exception("Podmiot znajduje się już w tabeli kontrahentów");
+					$query = "insert into BI_audit_ENERGA_RUM_KONTRAHENCI (Tytul_dokumentu, Pelna_nazwa_kontrahenta, REGON, NIP, KRS) select 'ZaImportowano z KRS', nazwa, regon, nip, krs from BI_audit_KRS where ID = ".$krsId." ";
 					DB::getPDO()->query($query);
 					SE_Layout::alert('success', "Pomyślnie zaimportowano kontrahenta");
 					break;
@@ -643,7 +658,7 @@ function validate() {
 		if (count($result) > 1) {
 ?>
               <td align="center">
-               <input type="radio" name="krsId" id="krsId" value="<?=$row['ID']?>"/>
+               <input type="radio" name="krsId" value="<?=$row['ID']?>"/>
              </td>
 <?php
 		}
@@ -780,7 +795,9 @@ function validatePerson(source) {
   return checked;
 }
 function validateCompany(source) {
-  checked = document.getElementById('krsId').checked;
+  radios = document.getElementsByName('krsId');
+  checked = false;
+  for(var i=0, n=radios.length;i<n;i++)  if(radios[i].checked) checked = true;
   if (!checked) alert('Nie wybrano żadnej firmy!');
   return checked;
 }
@@ -1590,6 +1607,7 @@ class BiAuditPowiazania {
 
 	private $minDepth;
 	private $maxDepth;
+	private $onlyTargets;
 	private $ID;
 	private $endNodes;
 	private $path = [];
@@ -1600,11 +1618,14 @@ class BiAuditPowiazania {
 
 	public function __construct($ID = 0) {
 		if (!$ID) throw new Exception("Wrong ID parameter");
-		$query = "select BI_analiza_minDepth, BI_analiza_maxDepth from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where ID = '{$ID}' and FILE_STATUS = 'IN_PROGRESS' and BI_analiza_reloadCache not in ('Full', 'Part')";
+		$query = "select BI_analiza_minDepth, BI_analiza_maxDepth, BI_analiza_onlyTargets from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where ID = '{$ID}' and FILE_STATUS = 'IN_PROGRESS' and BI_analiza_reloadCache not in ('Full', 'Part')";
 		$result = DB::getPDO()->fetchAll($query);
 		if (!$result) throw new Exception("Błąd danych");
 		$this->minDepth = (int) $result[0]['BI_analiza_minDepth'];
 		$this->maxDepth = (int) $result[0]['BI_analiza_maxDepth'];
+		$this->onlyTargets = ($result[0]['BI_analiza_onlyTargets'] != 'N');
+		if (!$this->minDepth) $this->minDepth = 1;
+		if (!$this->maxDepth) throw new Exception("Błąd danych - nieokreślono maksymalnej głębokości analizy");
 		if ($this->minDepth > $this->maxDepth) throw new Exception("Wartość minimalnej głębokości analizy jest większa od wartości maksymalnej głębokości analizy");
 		$this->ID = $ID;
 
@@ -1633,12 +1654,13 @@ class BiAuditPowiazania {
 		if (!$relation) $relation = 0;
 
 		if ($end) {
-			if (in_array($ID, $this->endNodes) && count($this->path) >= $this->minDepth) $this->results[] = $this->path;
+			if (in_array($ID, $this->endNodes) && count($this->path) > $this->minDepth) $this->results[] = $this->path;
 			array_pop($this->path);
 			return true;
 		}
 
 		if (count($this->path) > $this->maxDepth) {
+			if (!$this->onlyTargets) $this->results[] = $this->path;
 			array_pop($this->path);
 			return false;
 		}