<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "&#160;">
]><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:n="http://www.minefi.gouv.fr/cp/helios/pes_v2/facture"
    xmlns:added="http://projets.admisource.gouv.fr/xemelios/namespaces#added"
    xmlns:ano="http://projets.admisource.gouv.fr/xemelios/namespaces#anomally"
    xmlns:data="data.uri"
    xmlns="http://www.w3.org/1999/xhtml"
    version="2.0">
    <xsl:param name="collectivite"/>
    <xsl:param name="budget"/>
    <xsl:param name="elementId"/> <!-- 'PESFacture' pour afficher le releve, vide sinon -->
    <xsl:param name="numeroFacture"/>  <!-- dans le cas de l'affichage d'une FactureIndiv FactureIndiv/NumeroFacture/@V -->
    <xsl:param name="browser-destination" />
    <xsl:param name="anoId"/>    <!-- id de l'anomalie a mettre en surbrillance -->
    <xsl:param name="idLigne" select="AA"/>
    <xsl:variable name="debug" select="false()"/>
    <xsl:output
        encoding="ISO-8859-1"
        method="xhtml"
        exclude-result-prefixes="n added ano data"
        doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
        include-content-type="no"
        indent="yes"
        standalone="yes"
        version="1.0"/>
    <xsl:decimal-format name="decformat" 
        decimal-separator="," 
        grouping-separator=" " 
        digit="#" 
        pattern-separator=";" 
        NaN="NaN" 
        minus-sign="-"/>
    <xsl:variable name="tags-ano">
        <xsl:for-each select="//ano:Anomalie[@ano:anoId = $anoId]/ano:node">
            <xsl:element name="node">
                <xsl:attribute name="id" select="./@ano:id"/>
            </xsl:element>
        </xsl:for-each>
    </xsl:variable>
    <!-- Donn&#233;es pour les &#233;quivalences des codes -->
    <xsl:variable name="data">
    <data:data>
        <data:codePaysINSEE>
            <data:p V="99125">ALBANIE</data:p>
            <data:p V="99109">ALLEMAGNE</data:p>
            <data:p V="99130">ANDORRE</data:p>
            <data:p V="99110">AUTRICHE</data:p>
            <data:p V="99131">BELGIQUE</data:p>
            <data:p V="99148">BIELORUSSIE</data:p>
            <data:p V="99118">BOSNIE-HERZEGOVINE</data:p>
            <data:p V="99103">BOUVET (ILE)</data:p>
            <data:p V="99111">BULGARIE</data:p>
            <data:p V="99119">CROATIE</data:p>
            <data:p V="99101">DANEMARK</data:p>
            <data:p V="99134">ESPAGNE</data:p>
            <data:p V="99106">ESTONIE</data:p>
            <data:p V="99156">EX-REPUBLIQUE YOUGOSLAVE DE MACEDOINE</data:p>
            <data:p V="99101">FEROE (ILES)</data:p>
            <data:p V="99105">FINLANDE</data:p>
            <data:p V="99133">GIBRALTAR</data:p>
            <data:p V="99126">GRECE</data:p>
            <data:p V="99112">HONGRIE</data:p>
            <data:p V="99136">IRLANDE, ou EIRE</data:p>
            <data:p V="99102">ISLANDE</data:p>
            <data:p V="99127">ITALIE</data:p>
            <data:p V="99107">LETTONIE</data:p>
            <data:p V="99113">LIECHTENSTEIN</data:p>
            <data:p V="99108">LITUANIE</data:p>
            <data:p V="99137">LUXEMBOURG</data:p>
            <data:p V="99144">MALTE</data:p>
            <data:p V="99151">MOLDAVIE</data:p>
            <data:p V="99138">MONACO</data:p>
            <data:p V="99120">MONTENEGRO</data:p>
            <data:p V="99103">NORVEGE</data:p>
            <data:p V="99135">PAYS-BAS</data:p>
            <data:p V="99122">POLOGNE</data:p>
            <data:p V="99139">PORTUGAL</data:p>
            <data:p V="99141">REPUBLIQUE DEMOCRATIQUE ALLEMANDE</data:p>
            <data:p V="99142">REPUBLIQUE FEDERALE D'ALLEMAGNE</data:p>
            <data:p V="99114">ROUMANIE</data:p>
            <data:p V="99132">ROYAUME-UNI</data:p>
            <data:p V="99123">RUSSIE</data:p>
            <data:p V="99128">SAINT-MARIN</data:p>
            <data:p V="99121">SERBIE-ET-MONT&#233;N&#233;GRO</data:p>
            <data:p V="99117">SLOVAQUIE</data:p>
            <data:p V="99145">SLOVENIE</data:p>
            <data:p V="99104">SUEDE</data:p>
            <data:p V="99140">SUISSE</data:p>
            <data:p V="99103">SVALBARD et ILE JAN MAYEN</data:p>
            <data:p V="99115">TCHECOSLOVAQUIE</data:p>
            <data:p V="99116">TCHEQUE (REPUBLIQUE)</data:p>
            <data:p V="99124">TURQUIE D'EUROPE</data:p>
            <data:p V="99155">UKRAINE</data:p>
            <data:p V="99129">VATICAN, ou SAINT-SIEGE</data:p>
            <data:p V="99212">AFGHANISTAN</data:p>
            <data:p V="99201">ARABIE SAOUDITE</data:p>
            <data:p V="99252">ARMENIE</data:p>
            <data:p V="99253">AZERBAIDJAN</data:p>
            <data:p V="99249">BAHREIN</data:p>
            <data:p V="99246">BANGLADESH</data:p>
            <data:p V="99214">BHOUTAN</data:p>
            <data:p V="99224">BIRMANIE</data:p>
            <data:p V="99225">BRUNEI</data:p>
            <data:p V="99234">CAMBODGE</data:p>
            <data:p V="99216">CHINE</data:p>
            <data:p V="99254">CHYPRE</data:p>
            <data:p V="99237">COREE</data:p>
            <data:p V="99239">COREE (REPUBLIQUE DE)</data:p>
            <data:p V="99238">COREE (REPUBLIQUE POPULAIRE DEMOCRATIQUE DE)</data:p>
            <data:p V="99247">EMIRATS ARABES UNIS</data:p>
            <data:p V="99228">ETATS MALAIS NON FEDERES</data:p>
            <data:p V="99255">GEORGIE</data:p>
            <data:p V="99223">GOA</data:p>
            <data:p V="99230">HONG-KONG</data:p>
            <data:p V="99223">INDE</data:p>
            <data:p V="99231">INDONESIE</data:p>
            <data:p V="99204">IRAN</data:p>
            <data:p V="99203">IRAQ</data:p>
            <data:p V="99207">ISRAEL</data:p>
            <data:p V="99217">JAPON</data:p>
            <data:p V="99222">JORDANIE</data:p>
            <data:p V="99211">KAMTCHATKA</data:p>
            <data:p V="99256">KAZAKHSTAN</data:p>
            <data:p V="99257">KIRGHIZISTAN</data:p>
            <data:p V="99240">KOWEIT</data:p>
            <data:p V="99241">LAOS</data:p>
            <data:p V="99205">LIBAN</data:p>
            <data:p V="99232">MACAO</data:p>
            <data:p V="99227">MALAISIE</data:p>
            <data:p V="99229">MALDIVES</data:p>
            <data:p V="99218">MANDCHOURIE</data:p>
            <data:p V="99242">MONGOLIE</data:p>
            <data:p V="99215">NEPAL</data:p>
            <data:p V="99250">OMAN</data:p>
            <data:p V="99258">OUZBEKISTAN</data:p>
            <data:p V="99213">PAKISTAN</data:p>
            <data:p V="99261">PALESTINE</data:p>
            <data:p V="99220">PHILIPPINES</data:p>
            <data:p V="99221">POSSESSIONS BRITANNIQUES AU PROCHE-ORIENT</data:p>
            <data:p V="99248">QATAR</data:p>
            <data:p V="99209">SIBERIE</data:p>
            <data:p V="99226">SINGAPOUR</data:p>
            <data:p V="99235">SRI LANKA</data:p>
            <data:p V="99206">SYRIE</data:p>
            <data:p V="99259">TADJIKISTAN</data:p>
            <data:p V="99236">TAIWAN</data:p>
            <data:p V="99219">THAILANDE</data:p>
            <data:p V="99262">TIMOR ORIENTAL</data:p>
            <data:p V="99210">TURKESTAN RUSSE</data:p>
            <data:p V="99260">TURKMENISTAN</data:p>
            <data:p V="99208">TURQUIE</data:p>
            <data:p V="99243">VIET NAM</data:p>
            <data:p V="99244">VIET NAM DU NORD</data:p>
            <data:p V="99245">VIET NAM DU SUD</data:p>
            <data:p V="99251">YEMEN</data:p>
            <data:p V="99233">YEMEN DEMOCRATIQUE</data:p>
            <data:p V="99202">YEMEN (REPUBLIQUE ARABE DU)</data:p>
            <data:p V="99319">ACORES, MADERE</data:p>
            <data:p V="99303">AFRIQUE DU SUD</data:p>
            <data:p V="99352">ALGERIE</data:p>
            <data:p V="99395">ANGOLA</data:p>
            <data:p V="99327">BENIN</data:p>
            <data:p V="99347">BOTSWANA</data:p>
            <data:p V="99331">BURKINA</data:p>
            <data:p V="99321">BURUNDI</data:p>
            <data:p V="99322">CAMEROUN</data:p>
            <data:p V="99305">CAMEROUN ET TOGO</data:p>
            <data:p V="99313">CANARIES (ILES)</data:p>
            <data:p V="99396">CAP-VERT</data:p>
            <data:p V="99323">CENTRAFRICAINE (REPUBLIQUE)</data:p>
            <data:p V="99397">COMORES</data:p>
            <data:p V="99324">CONGO</data:p>
            <data:p V="99312">CONGO (REPUBLIQUE DEMOCRATIQUE)</data:p>
            <data:p V="99326">COTE D'IVOIRE</data:p>
            <data:p V="99399">DJIBOUTI</data:p>
            <data:p V="99301">EGYPTE</data:p>
            <data:p V="99317">ERYTHREE</data:p>
            <data:p V="99315">ETHIOPIE</data:p>
            <data:p V="99328">GABON</data:p>
            <data:p V="99304">GAMBIE</data:p>
            <data:p V="99329">GHANA</data:p>
            <data:p V="99330">GUINEE</data:p>
            <data:p V="99314">GUINEE EQUATORIALE</data:p>
            <data:p V="99392">GUINEE-BISSAU</data:p>
            <data:p V="99320">ILES PORTUGAISES DE L'OCEAN INDIEN</data:p>
            <data:p V="99332">KENYA</data:p>
            <data:p V="99348">LESOTHO</data:p>
            <data:p V="99302">LIBERIA</data:p>
            <data:p V="99316">LIBYE</data:p>
            <data:p V="99333">MADAGASCAR</data:p>
            <data:p V="99334">MALAWI</data:p>
            <data:p V="99335">MALI</data:p>
            <data:p V="99350">MAROC</data:p>
            <data:p V="99390">MAURICE</data:p>
            <data:p V="99336">MAURITANIE</data:p>
            <data:p V="99393">MOZAMBIQUE</data:p>
            <data:p V="99311">NAMIBIE</data:p>
            <data:p V="99337">NIGER</data:p>
            <data:p V="99338">NIGERIA</data:p>
            <data:p V="99308">OCEAN INDIEN (TERRITOIRE BRITANNIQUE DE L')</data:p>
            <data:p V="99339">OUGANDA</data:p>
            <data:p V="99313">PRESIDES</data:p>
            <data:p V="99313">PROVINCES ESPAGNOLES D'AFRIQUE</data:p>
            <data:p V="99340">RWANDA</data:p>
            <data:p V="99389">SAHARA OCCIDENTAL</data:p>
            <data:p V="99306">SAINTE-HELENE</data:p>
            <data:p V="99394">SAO TOME-ET-PRINCIPE</data:p>
            <data:p V="99341">SENEGAL</data:p>
            <data:p V="99398">SEYCHELLES</data:p>
            <data:p V="99342">SIERRA LEONE</data:p>
            <data:p V="99318">SOMALIE</data:p>
            <data:p V="99343">SOUDAN</data:p>
            <data:p V="99307">SOUDAN ANGLO-EGYPTIEN, KENYA, OUGANDA</data:p>
            <data:p V="99391">SWAZILAND</data:p>
            <data:p V="99325">TANGER</data:p>
            <data:p V="99309">TANZANIE</data:p>
            <data:p V="99344">TCHAD</data:p>
            <data:p V="99345">TOGO</data:p>
            <data:p V="99351">TUNISIE</data:p>
            <data:p V="99346">ZAMBIE</data:p>
            <data:p V="99308">ZANZIBAR</data:p>
            <data:p V="99310">ZIMBABWE</data:p>
            <data:p V="99404">ALASKA</data:p>
            <data:p V="99425">ANGUILLA</data:p>
            <data:p V="99441">ANTIGUA-ET-BARBUDA</data:p>
            <data:p V="99431">ANTILLES NEERLANDAISES</data:p>
            <data:p V="99415">ARGENTINE</data:p>
            <data:p V="99431">ARUBA</data:p>
            <data:p V="99436">BAHAMAS</data:p>
            <data:p V="99434">BARBADE</data:p>
            <data:p V="99429">BELIZE</data:p>
            <data:p V="99425">BERMUDES</data:p>
            <data:p V="99418">BOLIVIE</data:p>
            <data:p V="99416">BRESIL</data:p>
            <data:p V="99425">CAIMAN (ILES)</data:p>
            <data:p V="99401">CANADA</data:p>
            <data:p V="99417">CHILI</data:p>
            <data:p V="99419">COLOMBIE</data:p>
            <data:p V="99406">COSTA RICA</data:p>
            <data:p V="99407">CUBA</data:p>
            <data:p V="99408">DOMINICAINE (REPUBLIQUE)</data:p>
            <data:p V="99438">DOMINIQUE</data:p>
            <data:p V="99414">EL SALVADOR</data:p>
            <data:p V="99420">EQUATEUR</data:p>
            <data:p V="99404">ETATS-UNIS</data:p>
            <data:p V="99427">GEORGIE DU SUD ET LES ILES SANDWICH DU SUD</data:p>
            <data:p V="99435">GRENADE</data:p>
            <data:p V="99430">GROENLAND</data:p>
            <data:p V="99409">GUATEMALA</data:p>
            <data:p V="99428">GUYANA</data:p>
            <data:p V="99410">HAITI</data:p>
            <data:p V="99411">HONDURAS</data:p>
            <data:p V="99426">JAMAIQUE</data:p>
            <data:p V="99403">LABRADOR</data:p>
            <data:p V="99427">MALOUINES, OU FALKLAND (ILES)</data:p>
            <data:p V="99405">MEXIQUE</data:p>
            <data:p V="99425">MONTSERRAT</data:p>
            <data:p V="99412">NICARAGUA</data:p>
            <data:p V="99413">PANAMA</data:p>
            <data:p V="99421">PARAGUAY</data:p>
            <data:p V="99422">PEROU</data:p>
            <data:p V="99432">PORTO RICO</data:p>
            <data:p V="99442">SAINT-CHRISTOPHE-ET-NIEVES</data:p>
            <data:p V="99439">SAINTE-LUCIE</data:p>
            <data:p V="99440">SAINT-VINCENT-ET-LES GRENADINES</data:p>
            <data:p V="99437">SURINAME</data:p>
            <data:p V="99432">TERR. DES ETATS-UNIS D'AMERIQUE EN AMERIQUE</data:p>
            <data:p V="99427">TERR. DU ROYAUME-UNI DANS L'ATLANTIQUE SUD</data:p>
            <data:p V="99402">TERRE-NEUVE</data:p>
            <data:p V="99431">TERRITOIRE DES PAYS-BAS</data:p>
            <data:p V="99425">TERRITOIRES DU ROYAUME-UNI AUX ANTILLES</data:p>
            <data:p V="99433">TRINITE-ET-TOBAGO</data:p>
            <data:p V="99425">TURKS ET CAIQUES (ILES)</data:p>
            <data:p V="99423">URUGUAY</data:p>
            <data:p V="99424">VENEZUELA</data:p>
            <data:p V="99425">VIERGES BRITANNIQUES (ILES)</data:p>
            <data:p V="99432">VIERGES DES ETATS-UNIS (ILES)</data:p>
            <data:p V="99501">AUSTRALIE</data:p>
            <data:p V="99501">CHRISTMAS (ILE)</data:p>
            <data:p V="99501">COCOS ou KEELING (ILES)</data:p>
            <data:p V="99502">COOK (ILES)</data:p>
            <data:p V="99508">FIDJI</data:p>
            <data:p V="99505">GUAM</data:p>
            <data:p V="99504">HAWAII (ILES)</data:p>
            <data:p V="99501">HEARD ET MACDONALD (ILES)</data:p>
            <data:p V="99513">KIRIBATI</data:p>
            <data:p V="99505">MARIANNES DU NORD (ILES)</data:p>
            <data:p V="99515">MARSHALL (ILES)</data:p>
            <data:p V="99516">MICRONESIE (ETATS FEDERES DE)</data:p>
            <data:p V="99507">NAURU</data:p>
            <data:p V="99502">NIUE</data:p>
            <data:p V="99501">NORFOLK (ILE)</data:p>
            <data:p V="99502">NOUVELLE-ZELANDE</data:p>
            <data:p V="99517">PALAOS (ILES)</data:p>
            <data:p V="99510">PAPOUASIE-NOUVELLE-GUINEE</data:p>
            <data:p V="99503">PITCAIRN (ILE)</data:p>
            <data:p V="99512">SALOMON (ILES)</data:p>
            <data:p V="99505">SAMOA AMERICAINES</data:p>
            <data:p V="99506">SAMOA OCCIDENTALES</data:p>
            <data:p V="99505">TERR. DES ETATS-UNIS D'AMERIQUE EN OCEANIE</data:p>
            <data:p V="99502">TOKELAU</data:p>
            <data:p V="99509">TONGA</data:p>
            <data:p V="99511">TUVALU</data:p>
            <data:p V="99514">VANUATU</data:p>
        </data:codePaysINSEE>
    </data:data>
    </xsl:variable>
    
    <!-- Correspondance entre le code de pays INSEE et son nom -->
    <xsl:template name="codePaysINSEE" xmlns:data="data.uri">
        <xsl:param name="codePays"/>
        <xsl:value-of select="$data/data:data/data:codePaysINSEE/data:p[@V=$codePays]/text()"/>
    </xsl:template>
    
    <xsl:template name="slash-date">
        <xsl:param name="datebrute"/>
        <!-- date xmlns:data="data.uri" xsl:exclude-result-prefixes="data" -->
            <xsl:value-of select="substring($datebrute, 9, 2)"/>
            <xsl:text>/</xsl:text>
            <xsl:value-of select="substring($datebrute, 6, 2)"/>
            <xsl:text>/</xsl:text>
            <xsl:value-of select="substring($datebrute, 1, 4)"/>
        <!-- /date -->
    </xsl:template>
    <xsl:template name="number">
        <xsl:param name="num"/>
        <xsl:choose>
            <xsl:when test="string-length(string($num)) = 0"/>
            <xsl:when test="number($num) = 0">0,00</xsl:when>
            <xsl:when test="string(number($num)) = 'NaN'"/>
            <xsl:otherwise>
                <xsl:value-of select="format-number($num,'# ###,00;-# ###,00','decformat')"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
    <xsl:template name="REL_CadreFournisseur">
        <xsl:param name="fournisseur"/>
        <!--xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
            <xsl:attribute name="class">fournisseur</xsl:attribute-->
        <table class="cadrefournisseur">
            <tr>
                <td class="cadrefournisseurcolonne1">
                    <table class="fournisseur">
                        <tr>
                            <td class="fournisseurcolonne1">Fournisseur : </td>
                            <td class="fournisseurcolonne2"><xsl:value-of select="$fournisseur/n:InfoTiers/n:Nom/@V"/></td>
                        </tr>
                        <tr>
                            <td class="fournisseurcolonne1">Adresse : </td>
                            <td class="fournisseurcolonne2">
                                <xsl:if test="string-length($fournisseur/n:Adresse/n:Adr1/@V) &gt; 0">
                                    <xsl:value-of select="$fournisseur/n:Adresse/n:Adr1/@V"/>
                                </xsl:if>
                                <xsl:if test="string-length($fournisseur/n:Adresse/n:Adr2/@V) &gt; 0">
                                    <xsl:value-of select="$fournisseur/n:Adresse/n:Adr2/@V"/>
                                </xsl:if>
                                <xsl:if test="string-length($fournisseur/n:Adresse/n:Adr3/@V) &gt; 0">
                                    <xsl:value-of select="$fournisseur/n:Adresse/n:Adr3/@V"/>
                                </xsl:if>
                                <br/>
                                <xsl:value-of select="$fournisseur/n:Adresse/n:CP/@V"/>&nbsp;
                                <xsl:value-of select="$fournisseur/n:Adresse/n:Ville/@V"/>                    
                                <xsl:call-template name="codePaysINSEE">
                                    <xsl:with-param name="codePays" select="$fournisseur/n:Adresse/n:CodPays/@V"/>
                                </xsl:call-template>
                            </td>
                        </tr>
                        <tr>
                            <td class="fournisseurcolonne1">Identifiant : </td>
                            <td class="fournisseurcolonne2">
                                <xsl:value-of select="$fournisseur/n:InfoTiers/n:IdTiers/@V"></xsl:value-of>
                                <xsl:if test="$fournisseur/n:InfoTiers/n:NatIdTiers/@V = 01">(SIRET)</xsl:if>
                                <xsl:if test="$fournisseur/n:InfoTiers/n:NatIdTiers/@V = 02">(SIREN)</xsl:if>
                                <xsl:if test="$fournisseur/n:InfoTiers/n:NatIdTiers/@V = 03">(FINESS)</xsl:if>
                                <xsl:if test="$fournisseur/n:InfoTiers/n:NatIdTiers/@V = 04">(NIR)</xsl:if>
                            </td>
                        </tr>
                    </table>
                </td>
                <td class="cadrefournisseurcolonne2">
                    <table class="totalreleve">
                        <tr>
                            <td class="totalrelevecolonne1">Total HT :</td>
                            <td class="totalrelevecolonne2"><xsl:value-of select="../../@added:montantHT"/></td>
                        </tr>
                        <tr>
                            <td class="totalrelevecolonne1">Total TVA :</td>
                            <td class="totalrelevecolonne2"><xsl:value-of select="../../@added:montantTVA"/></td>
                        </tr>
                        <tr>
                            <td class="totalrelevecolonne1">Total TTC :</td>
                            <td class="totalrelevecolonne2"><xsl:value-of select="../../@added:montantTTC"/></td>
                        </tr>
                    </table>
                </td>
            </tr>
        <!--/xsl:element-->
        </table>
    </xsl:template>
    
    <xsl:template name="REL_CadreFacture">
        <xsl:param name="facture"/>
        <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
            <xsl:attribute name="class">facture</xsl:attribute>
            <tr>
                <td class="facturecolonneTitre1" colspan="3" align="left"><b>Titulaire : <xsl:value-of select="$facture/n:Tiers[n:TypeTiersFacture/@V=11]/n:InfoTiers/n:Civilite/@V"/>&nbsp;<xsl:value-of select="$facture/n:Tiers[n:TypeTiersFacture/@V=11]/n:InfoTiers/n:Prenom/@V"/>&nbsp;<xsl:value-of select="$facture/n:Tiers[n:TypeTiersFacture/@V=11]/n:InfoTiers/n:Nom/@V"/></b></td>
                <td class="facturecolonneTitre2" colspan="6" align="right"><b>Carte N&#176; : <xsl:value-of select="$facture/n:Tiers[n:TypeTiersFacture/@V=11]/n:InfoTiers/n:IdTiers/@V"/></b></td>
            </tr>
            <tr>
                <td class="facturecolonne1" style="border-bottom: solid 1px #000000;" align="center">Date</td>
                <td class="facturecolonne2" style="border-bottom: solid 1px #000000;" align="center">&nbsp;</td>
                <td class="facturecolonne3" style="border-bottom: solid 1px #000000;" align="center">D&#233;signation</td>
                <td class="facturecolonne4" style="border-bottom: solid 1px #000000;" align="center">Qt&#233;.</td>
                <td class="facturecolonne5" style="border-bottom: solid 1px #000000;" align="center">Prix<br/>unitaire HT</td>
                <td class="facturecolonne6" style="border-bottom: solid 1px #000000;" align="center">Taux<br/>TVA</td>
                <td class="facturecolonne7" style="border-bottom: solid 1px #000000;" align="center">Montant<br/>TVA</td>
                <td class="facturecolonne8" style="border-bottom: solid 1px #000000;" align="center">TVA</td>
                <td class="facturecolonne9" style="border-bottom: solid 1px #000000;" align="center">Montant<br/>TTC</td>
            </tr>
            <tr>
                <td class="facturecolonne1"><xsl:value-of select="$facture/n:DateEmission/@V"/></td>
                <td class="facturecolonne2" colspan="2">March&#233; n&#176; <b><xsl:value-of select="$facture/n:NumeroMarche/@V"/></b></td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr>
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">Facture n&#176;
                    <xsl:choose>
                        <xsl:when test="($browser-destination = 'internal') and ($elementId = 'PESFacture')">
                            <!-- <xsl:value-of select="../n:Date/@V"/><xsl:value-of select="../n:Emetteur/n:InfoTiers/n:IdTiers/@V"/><xsl:value-of select="../@added:generated-id"/> -->
                            <xsl:element name="a">
                                <xsl:attribute name="href">xemelios:/query?docId=PES_ReleveCarteAchat&amp;etatId=PES_CarteAchat&amp;elementId=PESFacture&amp;collectivite=<xsl:value-of select="$collectivite"></xsl:value-of>&amp;budget=<xsl:value-of select="$budget"/>&amp;path=[@added:primarykey='<xsl:value-of select="../@added:primarykey"/>']&amp;xsl:param=(numeroFacture,<xsl:value-of select="$facture/n:NumeroFacture/@V"/>)</xsl:attribute>
                                <b><xsl:value-of select="$facture/n:NumeroFacture/@V"/></b>
                            </xsl:element>
                        </xsl:when>
                        <xsl:otherwise>
                            <b><xsl:value-of select="$facture/n:NumeroFacture/@V"/></b>
                        </xsl:otherwise>
                    </xsl:choose>
                    <!--xsl:if test="'"></xsl:if>
                    <xsl:if test="$browser-destination = 'external'"></xsl:if-->
                    
                    &nbsp;Cde n&#176; <b><xsl:value-of select="$facture/n:Reference[n:TypePiece/@V='COMMANDE']/n:NumeroPiece/@V"/></b>
                </td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr>
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">&nbsp;</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <!-- LIGNES DE FACTURE DE CETTE FACTURE -->
            <!--xsl:for-each select="$facture/n:LigneFacture">
                <xsl:element name="tr">
                    <td class="facturecolonne1">&nbsp;</td>
                    <td class="facturecolonne2"><xsl:value-of select="./n:CodeProduit/@V"/></td>
                    <td class="facturecolonne3"><xsl:value-of select="./n:Libelle/@V"/></td>
                    <td class="facturecolonne4" align="right"><xsl:value-of select="./n:Quantite/@V"/></td>
                    <td class="facturecolonne5" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:MtUnitaire/@V"/></xsl:call-template></td>
                    <td class="facturecolonne6" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:TauxTVA/@V"/></xsl:call-template></td>
                    <td class="facturecolonne7" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:MtHT/@V"/></xsl:call-template></td>
                    <td class="facturecolonne8" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:MtTVA/@V"/></xsl:call-template></td>
                    <td class="facturecolonne9" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:MtTTC/@V"/></xsl:call-template></td>
                </xsl:element>                
            </xsl:for-each-->
            <!-- TOTAL DE LA FACTURE -->
            <tr>
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2">&nbsp;</td>
                <td class="facturecolonne3" align="right"><b>TOTAL</b></td>
                <td class="facturecolonne4" align="right">&nbsp;</td>
                <td class="facturecolonne5" align="right">&nbsp;</td>
                <td class="facturecolonne6" align="right">&nbsp;</td>
                <td class="facturecolonne7" align="right"><b><xsl:call-template name="number"><xsl:with-param name="num" select="$facture/n:TotalAPayer/n:MtTotalHT/@V"/></xsl:call-template></b></td>
                <td class="facturecolonne8" align="right"><b><xsl:call-template name="number"><xsl:with-param name="num" select="$facture/n:TotalAPayer/n:MtTotalTVA/@V"/></xsl:call-template></b></td>
                <td class="facturecolonne9" align="right"><b><xsl:call-template name="number"><xsl:with-param name="num" select="$facture/n:TotalAPayer/n:MtTotalTTC/@V"/></xsl:call-template></b></td>
            </tr> 
            <!-- REFERENCES DIVERS -->
            <tr>
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">REFERENCE DE PAIEMENT BANQUE</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr>
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">IDENTIFIANT LONG : XXX XXX</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr>
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">IDENTIFIANT COURT : XXX</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>            
        </xsl:element>
    </xsl:template>
    
    <xsl:template name="FAC_CadreFournisseur">
        <xsl:param name="fournisseur"/>
        <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
            <xsl:attribute name="class">fournisseur</xsl:attribute>
            <tr>
                <td class="fournisseurcolonne1">Fournisseur : </td>
                <td class="fournisseurcolonne2"><xsl:value-of select="$fournisseur/n:InfoTiers/n:Nom/@V"/></td>
            </tr>
            <tr>
                <td class="fournisseurcolonne1">Adresse : </td>
                <td class="fournisseurcolonne2">
                    <xsl:if test="string-length($fournisseur/n:Adresse/n:Adr1/@V) &gt; 0">
                        <xsl:value-of select="$fournisseur/n:Adresse/n:Adr1/@V"/>
                    </xsl:if>
                    <xsl:if test="string-length($fournisseur/n:Adresse/n:Adr2/@V) &gt; 0">
                        <xsl:value-of select="$fournisseur/n:Adresse/n:Adr2/@V"/>
                    </xsl:if>
                    <xsl:if test="string-length($fournisseur/n:Adresse/n:Adr3/@V) &gt; 0">
                        <xsl:value-of select="$fournisseur/n:Adresse/n:Adr3/@V"/>
                    </xsl:if>
                    <br/>
                    <xsl:value-of select="$fournisseur/n:Adresse/n:CP/@V"/>&nbsp;
                    <xsl:value-of select="$fournisseur/n:Adresse/n:Ville/@V"/>                    
                    <xsl:call-template name="codePaysINSEE">
                        <xsl:with-param name="codePays" select="$fournisseur/n:Adresse/n:CodPays/@V"/>
                    </xsl:call-template>
                </td>
            </tr>
            <tr>
                <td class="fournisseurcolonne1">Identifiant : </td>
                <td class="fournisseurcolonne2">
                    <xsl:value-of select="$fournisseur/n:InfoTiers/n:IdTiers/@V"></xsl:value-of>
                    <xsl:if test="$fournisseur/n:InfoTiers/n:NatIdTiers/@V = 01">(SIRET)</xsl:if>
                    <xsl:if test="$fournisseur/n:InfoTiers/n:NatIdTiers/@V = 02">(SIREN)</xsl:if>
                    <xsl:if test="$fournisseur/n:InfoTiers/n:NatIdTiers/@V = 03">(FINESS)</xsl:if>
                    <xsl:if test="$fournisseur/n:InfoTiers/n:NatIdTiers/@V = 04">(NIR)</xsl:if>
                </td>
            </tr>
        </xsl:element>
    </xsl:template>
    
    <xsl:template name="FAC_CadreFacture">
        <xsl:param name="facture"/>
        <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
            <xsl:attribute name="class">facture</xsl:attribute>
            <tr class="facture">
                <td class="facturecolonneTitre1" colspan="3" align="left"><b>Titulaire : <xsl:value-of select="$facture/n:Tiers[n:TypeTiersFacture/@V=11]/n:InfoTiers/n:Civilite/@V"/>&nbsp;<xsl:value-of select="$facture/n:Tiers[n:TypeTiersFacture/@V=11]/n:InfoTiers/n:Prenom/@V"/>&nbsp;<xsl:value-of select="$facture/n:Tiers[n:TypeTiersFacture/@V=11]/n:InfoTiers/n:Nom/@V"/></b></td>
                <td class="facturecolonneTitre2" colspan="6" align="right"><b>Carte N&#176; : <xsl:value-of select="$facture/n:Tiers[n:TypeTiersFacture/@V=11]/n:InfoTiers/n:IdTiers/@V"/></b></td>
            </tr>
            <tr class="facture">
                <td class="facturecolonne1" style="border-bottom: solid 1px #000000;" align="center">Date</td>
                <td class="facturecolonne2" style="border-bottom: solid 1px #000000;" align="center">&nbsp;</td>
                <td class="facturecolonne3" style="border-bottom: solid 1px #000000;" align="center">D&#233;signation</td>
                <td class="facturecolonne4" style="border-bottom: solid 1px #000000;" align="center">Qt&#233;.</td>
                <td class="facturecolonne5" style="border-bottom: solid 1px #000000;" align="center">Prix<br/>unitaire HT</td>
                <td class="facturecolonne6" style="border-bottom: solid 1px #000000;" align="center">Taux<br/>TVA</td>
                <td class="facturecolonne7" style="border-bottom: solid 1px #000000;" align="center">Total<br/>HT</td>
                <td class="facturecolonne8" style="border-bottom: solid 1px #000000;" align="center">TVA</td>
                <td class="facturecolonne9" style="border-bottom: solid 1px #000000;" align="center">Montant<br/>TTC</td>
            </tr>
            <tr class="facture">
                <td class="facturecolonne1"><xsl:value-of select="$facture/n:DateEmission/@V"/></td>
                <td class="facturecolonne2" colspan="2">March&#233; n&#176; <b><xsl:value-of select="$facture/n:NumeroMarche/@V"/></b></td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr class="facture">
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">Facture n&#176;
                    <xsl:choose>
                        <xsl:when test="($browser-destination = 'internal') and ($elementId = 'PESFacture')">
                            <xsl:element name="a"><xsl:attribute name="href">xemelios:/query?docId=PES_ReleveCarteAchat&amp;etatId=PES_CarteAchat&amp;elementId=PESFacture&amp;collectivite=<xsl:value-of select="$collectivite"></xsl:value-of>&amp;budget=<xsl:value-of select="$budget"/>&amp;path=[@added:primarykey='<xsl:value-of select="../@added:primarykey"/>']&amp;xsl:param=(numeroFacture,<xsl:value-of select="$facture/n:NumeroFacture/@V"/>)</xsl:attribute><b><xsl:value-of select="$facture/n:NumeroFacture/@V"/></b></xsl:element>
                        </xsl:when>
                        <xsl:otherwise>
                            <b><xsl:value-of select="$facture/n:NumeroFacture/@V"/></b>
                        </xsl:otherwise>
                    </xsl:choose>
                    <!--xsl:if test="$browser-destination = 'internal'"><xsl:element name="a"><xsl:attribute name="href">xemelios:/query?docId=PES_ReleveCarteAchat&amp;etatId=PES_CarteAchat&amp;elementId=PESFacture&amp;collectivite=<xsl:value-of select="../@added:collectivite"></xsl:value-of>&amp;budget=00&amp;path=[@added:primarykey='<xsl:value-of select="../n:Date/@V"/><xsl:value-of select="../n:Emetteur/n:InfoTiers/n:IdTiers/@V"/><xsl:value-of select="../n:Tiers[n:TypeTiersFacture/@V=10]/n:InfoTiers/n:IdTiers/@V"/>']&amp;xsl:param=(numeroFacture,<xsl:value-of select="$facture/n:NumeroFacture/@V"/>)</xsl:attribute><b><xsl:value-of select="$facture/n:NumeroFacture/@V"/></b></xsl:element></xsl:if>
                    <xsl:if test="$browser-destination = 'external'"><b><xsl:value-of select="$facture/n:NumeroFacture/@V"/></b></xsl:if-->
                    
                    &nbsp;Cde n&#176; <b><xsl:value-of select="$facture/n:Reference[n:TypePiece/@V='COMMANDE']/n:NumeroPiece/@V"/></b>
                </td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr class="facture">
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">&nbsp;</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <!-- LIGNES DE FACTURE DE CETTE FACTURE -->
            <xsl:for-each select="$facture/n:LigneFacture">
                <xsl:element name="tr">
                    <xsl:attribute name="class" select="facture"/>
                    <xsl:if test="@added:generated-id = $idLigne">
                        <xsl:attribute name="style">background-color: #FFFF66;</xsl:attribute>
                    </xsl:if>
                    <td class="facturecolonne1">&nbsp;</td>
                    <td class="facturecolonne2"><xsl:value-of select="./n:CodeProduit/@V"/></td>
                    <td class="facturecolonne3"><xsl:value-of select="./n:Libelle/@V"/></td>
                    <td class="facturecolonne4" align="right"><xsl:value-of select="./n:Quantite/@V"/></td>
                    <td class="facturecolonne5" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:MtUnitaire/@V"/></xsl:call-template></td>
                    <td class="facturecolonne6" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:TauxTVA/@V"/></xsl:call-template></td>
                    <td class="facturecolonne7" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:MtHT/@V"/></xsl:call-template></td>
                    <td class="facturecolonne8" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:MtTVA/@V"/></xsl:call-template></td>
                    <td class="facturecolonne9" align="right"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:MtTTC/@V"/></xsl:call-template></td>
                </xsl:element>
            </xsl:for-each>
            <!-- REFERENCES DIVERS -->
            <tr class="facture">
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">&nbsp;</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr class="facture">
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">REFERENCE DE PAIEMENT BANQUE</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr class="facture">
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">IDENTIFIANT LONG : XXX XXX</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>
            <tr class="facture">
                <td class="facturecolonne1">&nbsp;</td>
                <td class="facturecolonne2" colspan="2">IDENTIFIANT COURT : XXX</td>
                <td class="facturecolonne4">&nbsp;</td>
                <td class="facturecolonne5">&nbsp;</td>
                <td class="facturecolonne6">&nbsp;</td>
                <td class="facturecolonne7">&nbsp;</td>
                <td class="facturecolonne8">&nbsp;</td>
                <td class="facturecolonne9">&nbsp;</td>
            </tr>            
        </xsl:element>
        <!-- TOTAUX -->
        <xsl:variable name="lignes_5_5" select="./n:LigneFacture[n:TauxTVA/@V='5.5']"/>
        <xsl:variable name="lignes_19_6" select="./n:LigneFacture[n:TauxTVA/@V='19.6']"/>
        <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
            <xsl:attribute name="style">width: 100%; border-width: 0px; border-none: solid; margin: 0; padding: 0; border-collapse: collapse;</xsl:attribute>
            <tr style="border-style: none; padding: none; margin: 0;"><td style="width: 100%; border-style:none; padding:0; margin: 0">&nbsp;</td>
            <td style="width: 100%; border-style:none; padding-top: 20; margin-top: 10; margin-right: 0;">
                <br />
            <xsl:if test="$lignes_5_5!='' or $lignes_19_6!=''">
                <xsl:element name="div" namespace="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="class">total</xsl:attribute>
                    <table style="text-align: left;"  class="tableau3">
                        <tbody>
                            <tr>
                                <td class="cell_titre_col" colspan="2">Totaux T.V.A par Taux</td>
                            </tr>
                            <xsl:if test="$lignes_5_5!=''">
                                <tr>
                                    <td class="cell_tableau1">5.5&nbsp;%</td>
                                    <td class="cell_numeric_g">
                                        <xsl:apply-templates select="$lignes_5_5"/>
                                        <xsl:call-template name="number"><xsl:with-param name="num" select="sum($lignes_5_5/n:MtTVA/@V)"/></xsl:call-template>
                                    </td>
                                </tr>
                            </xsl:if>
                            <xsl:if test="$lignes_19_6!=''">
                                <tr>
                                    <td class="cell_tableau1">19.6&nbsp;%</td>
                                    <td class="cell_numeric_g">
                                        <xsl:apply-templates select="$lignes_19_6"/>
                                        <xsl:call-template name="number"><xsl:with-param name="num" select="sum($lignes_19_6/n:MtTVA/@V)"/></xsl:call-template>
                                    </td>
                                </tr>
                            </xsl:if>
                        </tbody>
                    </table>
                </xsl:element>
            </xsl:if>

            <xsl:element name="div">
                <xsl:attribute name="class">total</xsl:attribute>
                <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="class">tableau3</xsl:attribute>
                    <tbody>
                        <tr>
                            <td class="cell_titre_col" colspan="2">Total</td>
                        </tr>
                        <tr>
                            <td class="cell_tableau1">Montant HT</td>
                            <td class="cell_numeric_g"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:TotalAPayer/n:MtTotalHT/@V"/></xsl:call-template></td>
                        </tr>
                        <tr>
                            <td class="cell_tableau1">Montant TVA</td>
                            <td class="cell_numeric_g"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:TotalAPayer/n:MtTotalTVA/@V"/></xsl:call-template></td>
                        </tr>
                        <tr>
                            <td class="cell_tableau1">Montant TTC</td>
                            <td class="cell_numeric_g"><xsl:call-template name="number"><xsl:with-param name="num" select="./n:TotalAPayer/n:MtTotalTTC/@V"/></xsl:call-template></td>
                        </tr>
                    </tbody>
                </xsl:element>
            </xsl:element>
            </td></tr>
        </xsl:element>
        
    </xsl:template>

    <!-- d&#233;but du document -->
    <xsl:template match="/n:PES_ReleveCarteAchat">
        <xsl:element name="html" exclude-result-prefixes="#all" namespace="http://www.w3.org/1999/xhtml">
        <!--html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" exclude-result-prefixes="n added ano data"-->
            <!--xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</xsl:text-->
            <head>
                <title><xsl:if test="$elementId='PESFacture'">Relev&#233; de </xsl:if>Carte achat</title>
                <style type="text/css" media="all">
                    @page {
                        size: landscape;
                        margin: 0.5cm 0.5cm 0.5cm 0.5cm;
                    }
                    body {
//                        width: 29cm;
                        font-family: verdana, sans-serif;
                        font-size: 10px;
                        background-color: #FFFFFF;
                    }
                    div.divpage {
//                        width: 29cm;
                        margin: 0 0 0 0;
                    }
                    table.entete {
                        margin: 0;
                        border-style: none;
                        border-width: 0px;
                        border-color: black;
                        width: 100%;
                        font-size: 14px;
                        padding: 0;
//                        border-collapse: collapse;
                    }
                    anomalie { background-color: #FFFF66; }
                    tr { margin: 0; }
                    td {
                        margin: 0;
                        border-style: inset;
                        border-width: 1px;
                        border-color: black;
                        vertical-align: top;
                        line-height: 13px;
                    }
                    td.entetecolonne1 {
                        width: 1.5cm;
                        border-style: none;
                    }
                    td.entetecolonne2 {
                        width: 1.5cm;
                        border-style: none;
                    }
                    td.entetecolonne3 {
                        width: 4cm;
                        border-style: none;
                    }
                    td.entetecolonne4 {
                        width: 1cm;
                        border-style: none;
                    }
                    td.entetecolonne5 {
                        width: 3.5cm;
                        border-style: none;
                    }
                    td.entetecolonne6 {
                        width: 7.5cm;
                        border-style: none;
                    }
                    
                    table.cadrefournisseur {
                        margin: 0;
                        border: none;
                        width: 100%;
                        font-size: 12px;
                        align: left;                    
                    }
                    
                    td.cadrefournisseurcolonne1 {
                        border: none;
                        width: 8.5cm;
                        align: left;
                    }
                    td.cadrefournisseurcolonne2 {
                        border: none;
                        width: 20.5cm;
                        align: right; 
                    }
                    
                    table.fournisseur {
                        margin: 0;
                        border-style: solid;
                        border-width: 1px;
                        border-color: black;
                        width: 8.5cm;
                        font-size: 12px;
                        text-align: left;
                        padding: 0;
//                        border-collapse: collapse;
                        page-break-inside: avoid;
                    }
                    td.fournisseurcolonne1 {
                        width: 3cm;
                        border-style: none;
                        text-align: right;
                    }
                    td.fournisseurcolonne2 {
                        width: 5.5cm;
                        border-style: none;
                        text-align: left;
                    }
                    
                    table.totalreleve {
                        margin: 0;
                        width: 100%;
                        border: none;
                        font-size: 12px;
                        align: right;
                    }
                    
                    td.totalrelevecolonne1 {
                        border: none;
                        width: 85%;
                        align: right;
                        text-align: right;
                    }
                    
                    td.totalrelevecolonne2 {
                        border: none;
                        width: 15%;
                        align: right;
                        text-align: right;
                    }

                    table.facture {
                        margin: 0;
                        border-style: solid;
                        border-width: 1px;
                        border-color: #000000;
                        width: 100%;
                        font-size: 12px;
                        text-align: left;
                        padding: 0;
                        page-break-inside: avoid;
//                        border-collapse: separate;
                    }
                    tr.facture { border-collapse: collapse; }
                    td.facturecolonneTitre1 {
                        width: 1cm;
                        border-top: none;
                        border-left: none;
                        border-bottom: solid 1px #000000;
                        border-right: none;
                    }
                    td.facturecolonneTitre2 {
                        width: 1cm;
                        border-top: none;
                        border-left: solid 1px #000000;
                        border-bottom: solid 1px #000000;
                        border-right: none;
                    }
                    td.facturecolonne1 {
                        width: 1cm;
                        border-top: none;
                        border-left: none;
                        border-bottom: none;
                        border-right: none;
                    }
                    td.facturecolonne2 {
                        width: 1.5cm;
                        border-top: none;
                        border-left: solid 1px #000000;
                        border-bottom: none;
                        border-right: none;
                        }
                    td.facturecolonne3 {
                        border-top: none;
                        border-left: none;
                        border-bottom: none;
                        border-right: none;
                        }
                    td.facturecolonne4 {
                        width: 1cm;
                        border-top: none;
                        border-left: solid 1px #000000;
                        border-bottom: none;
                        border-right: none;
                        }
                    td.facturecolonne5 {
                        width: 1.25cm;
                        border-top: none;
                        border-left: solid 1px #000000;
                        border-bottom: none;
                        border-right: none;
                        }
                    td.facturecolonne6 {
                        width: 1.25cm;
                        border-top: none;
                        border-left: solid 1px #000000;
                        border-bottom: none;
                        border-right: none;
                        }
                    td.facturecolonne7 {
                        width: 1.25cm;
                        border-top: none;
                        border-left: solid 1px #000000;
                        border-bottom: none;
                        border-right: none;
                        }
                    td.facturecolonne8 {
                        width: 1.25cm;
                        border-top: none;
                        border-left: solid 1px #000000;
                        border-bottom: none;
                        border-right: solid 1px #000000;
                        }
                    td.facturecolonne9 {
                        width: 1.25cm;
                        border-style: none;
                    }
                    
                    .bordHaut   { border-top: solid 1px #000000; }
                    .bordGauche { border-left: solid 1px #000000; }
                    .bordBas    { border-bottom: solid 1px #000000; }
                    .bordDroit  { border-right: solid 1px #000000; }

                    noupper { border-top-style: none; }
                    :link { color: #00c; background: transparent }
                    :visited { color: #609; background: transparent }
                    a:active { color: #c00; background: transparent }
                    a:link img, a:visited img { border-style: none }
                    .gras { font-weight: bold; }
                    .gauche { text-align: left; }
                    .droite { text-align: right; }
                    .nomBanque {border: solid 1px #000000; text-align: center; font-size: 12px; font-weight: bold;}
                    
                    .total {
                        position: relative;
                        width: 6cm;
                    }
                    
                    .tableau3 {
                        border-style: none;
                        border-width: 0px;
                        font-size: 12px;
                        font-family: Verdana;
                        font-style: normal;
                        text-align: left;
                        border-collapse: collapse;
                    }
                    
                    .cell_titre_col {
                        border-top-style: solid;
                        border-bottom-style: solid;
                        border-top-width: 1px;
                        border-bottom-width: 1px;
                        font-weight: bold;
                        text-align: center;
                        background-color: rgb(202, 202, 202);
                    
                    }
                        .cell_numeric_g {border-top-style: solid;
                        border-bottom-style: solid;
                        border-top-width: 1px;
                        border-bottom-width: 1px;
                        text-align: right;
                        font-weight: bold;
                        width: 3.5cm;
                    }
                    
                    .cell_tableau1 { 
                        border-top-style: solid;
                        border-bottom-style: solid;
                        border-top-width: 1px;
                        border-bottom-width: 1px;
                        width: 2.5cm;
                    }
                    
                </style>
            </head>
            <body>
                <div class="divpage">
                    <xsl:if test="$debug">
                        <p>elementId=<xsl:value-of select="$elementId"/><br/>anoId=<xsl:value-of select="$anoId"/><br/>browserDestination=<xsl:value-of select="$browser-destination"/></p>
                    </xsl:if>
                    
                <xsl:choose>
                <xsl:when test="$elementId='PESFacture'">
                <!-- pour un relev&#233; -->
                    
                    <!-- ENTETE -->
                    <table class="entete" cellspacing="0">
                        <tr>
                            <td class="entetecolonne1">&nbsp;</td>
                            <td class="entetecolonne2">&nbsp;</td>
                            <td class="entetecolonne3">&nbsp;</td>
                            <td class="entetecolonne4">&nbsp;</td>
                            <td class="entetecolonne5">&nbsp;</td>
                            <td class="entetecolonne6">&nbsp;</td>
                        </tr>
                        <tr>
                            <td class="entetecolonne1" colspan="3"><div class="nomBanque"><xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Emetteur/n:InfoTiers/n:Nom/@V"/></div></td>
                            <td class="entetecolonne4">&nbsp;</td>
                            <td class="entetecolonne5 droite" colspan="2">
                                <xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:InfoTiers/n:Civilite/@V"/>
                                <xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:InfoTiers/n:Prenom/@V"/>
                                <xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:InfoTiers/n:Nom/@V"/>
                                <br/>
                                <xsl:if test="string-length(./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:Adresse/n:Adr1/@V) &gt; 0">
                                    <xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:Adresse/n:Adr1/@V"/>
                                </xsl:if>
                                <xsl:if test="string-length(./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:Adresse/n:Adr2/@V) &gt; 0">
                                    <xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:Adresse/n:Adr2/@V"/>
                                </xsl:if>
                                <xsl:if test="string-length(./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:Adresse/n:Adr3/@V) &gt; 0">
                                    <xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:Adresse/n:Adr3/@V"/>
                                </xsl:if>
                                <br/>
                                <xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:Adresse/n:CP/@V"/>&nbsp;
                                <xsl:value-of select="./n:PES_CarteAchat/n:PESFacture/n:Tiers[n:TypeTiersFacture/@V=10]/n:Adresse/n:Ville/@V"/>
                            </td>
                        </tr>
                        <tr>
                            <td class="entetecolonne1" colspan="6">NUMERO DE RELEVE : <xsl:value-of select="//n:NumeroReleve/@V"/> - <xsl:call-template name="slash-date"><xsl:with-param name="datebrute" select="./n:PES_CarteAchat/n:PESFacture/n:Date/@V"/></xsl:call-template></td>
                        </tr>
                    </table>
                    <br/>
                    <!-- FOURNISSEURS -->
                    <xsl:for-each-group select="./n:PES_CarteAchat/n:PESFacture/n:FactureIndiv/n:Tiers[n:TypeTiersFacture/@V=24]" group-by="./n:InfoTiers/n:Nom/@V">
                        <xsl:call-template name="REL_CadreFournisseur">
                            <xsl:with-param name="fournisseur" select="."/>
                        </xsl:call-template>
                        <br/>
                        <!-- FACTURES DU FOURNISSEUR -->
                        <xsl:variable name="nomFournisseur" select="./n:InfoTiers/n:Nom/@V"></xsl:variable>
                        <xsl:for-each select="/n:PES_ReleveCarteAchat/n:PES_CarteAchat/n:PESFacture/n:FactureIndiv[n:Tiers/n:TypeTiersFacture/@V=24][n:Tiers/n:InfoTiers/n:Nom/@V=$nomFournisseur]">
                            <xsl:call-template name="REL_CadreFacture">
                                <xsl:with-param name="facture" select="."/>
                            </xsl:call-template>
                            <br/>
                        </xsl:for-each>
                    </xsl:for-each-group>
                </xsl:when>

                <xsl:otherwise>
                    <!-- pour une facture -->
                    <xsl:for-each select="./n:PES_CarteAchat/n:PESFacture/n:FactureIndiv[n:NumeroFacture/@V = $numeroFacture]">
                        <!-- ENTETE RELEVE -->
                        <table class="entete" cellspacing="0">
                            <tr>
                                <td class="entetecolonne1" colspan="6">NUMERO DE RELEVE : 
                                    <xsl:if test="$browser-destination = 'internal'"><xsl:element name="a"><xsl:attribute name="href">xemelios:/query?docId=PES_ReleveCarteAchat&amp;etatId=PES_CarteAchat&amp;elementId=PESFacture&amp;collectivite=<xsl:value-of select="$collectivite"/>&amp;budget=<xsl:value-of select="$budget"/>&amp;path=[@added:primarykey='<xsl:value-of select="../@added:primarykey"/>']&amp;xsl:param=(elementId,PESFacture)</xsl:attribute><b><xsl:value-of select="//n:NumeroReleve/@V"/></b></xsl:element></xsl:if>
                                    <xsl:if test="$browser-destination = 'external'"><b><xsl:value-of select="//n:NumeroReleve/@V"/></b></xsl:if>
                                    - <xsl:call-template name="slash-date"><xsl:with-param name="datebrute" select="../n:Date/@V"/></xsl:call-template></td>
                            </tr>
                        </table>
                        <br/>
                        <!-- FOURNISSEUR -->
                        <xsl:call-template name="FAC_CadreFournisseur">
                            <xsl:with-param name="fournisseur" select="./n:Tiers[n:TypeTiersFacture/@V=24]"/>
                        </xsl:call-template>
                        <br/>
                        <!-- FACTURE -->
                        <xsl:call-template name="FAC_CadreFacture">
                            <xsl:with-param name="facture" select="."/>
                        </xsl:call-template>
                    </xsl:for-each>
                </xsl:otherwise>
            
                </xsl:choose>
                </div>
            </body>        
            
            <!-- /html -->
        </xsl:element>
    </xsl:template>

</xsl:stylesheet>
