<?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"
    version="2.0">
    <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: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"/>
    <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ées pour les é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ÉNÉ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="FAC_CadreFournisseur">
        <xsl:param name="fournisseur"/>
        <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">SIRET : </td>
                <td class="fournisseurcolonne2">XXX XXX XXX XXXXX</td>
            </tr>
        </table>
    </xsl:template>
    
    <xsl:template name="FAC_CadreFacture">
        <xsl:param name="facture"/>
        <table class="facture" cellpadding="0" cellspacing="0">
            <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° : <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ésignation</td>
                <td class="facturecolonne4" style="border-bottom: solid 1px #000000;" align="center">Qté.</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é n° <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° <b><xsl:value-of select="$facture/n:NumeroFacture/@V"/></b>                    
                    &nbsp;Cde n° <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">
                <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:value-of select="format-number(./n:MtUnitaire/@V,'# ##0,00','decformat')"/></td>
                    <td class="facturecolonne6" align="right"><xsl:value-of select="format-number(./n:TauxTVA/@V,'# ##0,00','decformat')"/></td>
                    <td class="facturecolonne7" align="right"><xsl:value-of select="format-number(./n:MtHT/@V,'# ##0,00','decformat')"/></td>
                    <td class="facturecolonne8" align="right"><xsl:value-of select="format-number(./n:MtTVA/@V,'# ##0,00','decformat')"/></td>
                    <td class="facturecolonne9" align="right"><xsl:value-of select="format-number(./n:MtTTC/@V,'# ##0,00','decformat')"/></td>
                </tr>                
            </xsl:for-each>
            <!-- REFERENCES DIVERS -->
            <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>
            <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>            
        </table>
        <!-- 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:if test="$lignes_5_5!='' or $lignes_19_6!=''">
            <div class="total">
                <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:value-of select="format-number(sum($lignes_5_5/n:MtTVA/@V),'# ##0,00','decformat')"/>
                                </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:value-of select="format-number(sum($lignes_19_6/n:MtTVA/@V),'# ##0,00','decformat')"/>
                                </td>
                            </tr>
                        </xsl:if>
                    </tbody>
                </table>
            </div>
        </xsl:if>
        
        <div class="total">
            <table style="text-align: left;"  class="tableau3">
                <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:value-of select="format-number(./n:TotalAPayer/n:MtTotalHT/@V,'# ##0,00','decformat')"/></td>
                    </tr>
                    <tr>
                        <td class="cell_tableau1">Montant TVA</td>
                        <td class="cell_numeric_g"><xsl:value-of select="format-number(./n:TotalAPayer/n:MtTotalTVA/@V,'# ##0,00','decformat')"/></td>
                    </tr>
                    <tr>
                        <td class="cell_tableau1">Montant TTC</td>
                        <td class="cell_numeric_g"><xsl:value-of select="format-number(./n:TotalAPayer/n:MtTotalTTC/@V,'# ##0,00','decformat')"/></td>
                    </tr>
                </tbody>
            </table>
        </div>
        
    </xsl:template>

    <!-- début du document -->
    <xsl:template match="/n:DOC_PES_Facture">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
            <head>
                <style type="text/css">
                    @page {
                        size: 29.7cm 21cm;
                        margins: 0.5 0.5 0.5 0.5;
                    }
                    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;
                    }
                    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.fournisseur {
                        margin: 0;
                        border-style: solid;;
                        border-width: 1px;
                        border-color: black;
                        width: 8.5cm;
                        font-size: 12px;
                        align: left;
                    }
                    td.fournisseurcolonne1 {
                        width: 3cm;
                        border-style: none;
                        text-align: right;
                    }
                    td.fournisseurcolonne2 {
                        width: 5.5cm;
                        border-style: none;
                        text-align: left;
                    }
                    
                    table.facture {
                        margin: 0;
                        border-style: solid;
                        border-width: 1px;
                        border-color: #000000;
                        width: 100%;
                        font-size: 12px;
                        align: left;
                    }
                    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 {
                        width: 9.75cm;
                        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;
                    left: 23cm;
                    width: 6cm;
                    }
                    
                    .tableau3 { border-style: none;
                    border-width: 0px;
                    font-size: 12px;
                    font-family: Verdana;
                    font-style: normal;
                    }
                    .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">
                    
                <!-- pour une facture -->
                <xsl:for-each select="./n:PESFacture/n:FactureIndiv[n:NumeroFacture/@V = $numeroFacture]">
                    <!-- 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>

                </div>
            </body>        
            
            </html>
    </xsl:template>

</xsl:stylesheet>
