<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:n="http://www.minefi.gouv.fr/cp/helios/pes_v2/Rev0/aller"
    xmlns:added="http://projets.admisource.gouv.fr/xemelios/namespaces#added"
    xmlns:ano="http://projets.admisource.gouv.fr/xemelios/namespaces#anomally"
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
    xmlns:xad="http://uri.etsi.org/01903/v1.1.1#"
    xmlns:data="data.uri"
    xmlns:xem="fr.gouv.finances.cp.utils.xml.certs.Certificate509"
    version="2.0">
    <xsl:param name="browser-destination" />
    <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:template match="*"/>
    <xsl:template match="/n:PES_Aller">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
            <head>
                <style type="text/css">
                    body {
                    width: 29cm;
                    font-family: verdana, sans-serif;
                    font-size: 12px;
                    background-color: #FFFFFF;
                    }
                    div.divpage {
                    width: 29cm;
                    margin: 0 0 0 0;
                    }
                    table { border-collapse: collapse; }
                    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.head1 {
                    width: 16cm;
                    border-style: none;
                    }
                    td.head2 {
                    width: 5cm;
                    text-align: center;
                    border-style: none;
                    }
                    td.colonne1 {
                    width: 6cm;
                    border-style: none;
                    }
                    td.colonne2 {
                    width: 15cm;
                    text-align: center;
                    border-style: none;
                    }
                    td.colonne3 {
                    width: 3.5cm;
                    border-style: none;
                    }
                    td.colonne4 {
                    width: 3cm;
                    border-style: none;
                    }
                    table.enteteTablePrincipale {
                    font-size: 10px;
                    text-align: center;
                    width: 100%;
                    }
                    table.inner {
                    font-size: 10px;
                    text-align: left;
                    width: 100%;
                    }
                    td.principaleCol1 {
                    width: 6.5cm;
                    }
                    td.principaleCol2 {
                    width: 2cm;
                    }
                    td.principaleCol3 {
                    width: 6.5cm;
                    }
                    td.principaleCol4 {
                    width: 1.7cm;
                    }
                    td.principaleCol5 {
                    width: 1.7cm;
                    }
                    td.principaleCol6 {
                    width: 1.6cm;
                    }
                    td.principaleCol7 {
                    width: 2.5cm;
                    }
                    td.principaleCol8 {
                    width: 2.5cm;
                    }
                    td.principaleCol9 {
                    width: 2.5cm;
                    }
                    table.totaux {
                    width: 100%;
                    font-size: 10px;
                    border-style: none;
                    }
                    td.sansBordure {
                    border-style: none;
                    }
                    td.mandatCol1 {
                    width: 5.5cm;
                    border-style: none none solid solid;
                    }
                    td.mandatCol2 {
                    width: 1cm;
                    border-style: none none solid solid;
                    }
                    td.mandatCol3 {
                    width: 4cm;
                    border-style: none none solid solid;
                    }
                    td.mandatCol3a {
                    width: 2cm;
                    text-align: left;
                    border-style: none none solid solid;
                    }
                    td.mandatCol3b {
                    width: 2cm;
                    text-align: right;
                    border-style: none none solid none;
                    }
                    td.mandatCol4 {
                    width: 6cm;
                    border-style: none none solid solid;
                    }
                    td.mandatCol4a {
                    width: 4cm;
                    text-align: left;
                    border-style: none none solid solid;
                    }
                    td.mandatCol4b {
                    width: 2cm;
                    text-align: right;
                    border-left-style: none;
                    border-style: none none solid none;
                    }
                    td.mandatCol5 {
                    width: 1.5cm;
                    border-style: none none solid solid;
                    }
                    td.mandatCol6 {
                    width: 1.5cm;
                    border-style: none none solid solid;
                    }
                    td.mandatCol7 {
                    width: 1.5cm;
                    border-style: none none solid solid;
                    }
                    td.mandatCol8 {
                    width: 6.5cm;
                    border-style: none solid solid solid;
                    }
                    td.mandatCol8a {
                    width: 4cm;
                    text-align: left;
                    border-style: none none solid solid; 
                    }
                    td.mandatCol8b {
                    width: 2.5cm;
                    text-align: right;
                    border-style: none solid solid none; 
                    }
                    table.footer {
                    margin: 0;
                    border-style: none;
                    width: 100%;
                    font-size: 12px;
                    }
                    td.totalLibelle {
                    width: 6cm;
                    }
                    td.totalValeur {
                    width: 2cm;
                    text-align: right;
                    }
                    td.noborder {
                    border-style: none;
                    }
                    td.right {
                    text-align: right;
                    }
                    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; }
                    .pj { font-size: 10px; font-weight: normal; }
                    li.pj { list-style-type: none; margin-left: -20px; }
                </style>
                <title>Etat de PES Aller</title>
            </head>
            <body>
                <table class="entete" cellspacing="0">
                    <tr>
                        <td class="head1">
                            <xsl:value-of select="./n:EnTetePES/n:IdPost/@V"/>&#160;<xsl:value-of select="./n:EnTetePES/n:LibellePoste/@V"/>
                        </td>
                    </tr>
                </table>
                <p><a href="xemelios:/query?docId=PES_Aller&amp;etatId=analyse-flux">R&#233;sum&#233; du flux</a></p>
                <xsl:apply-templates/>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template match="//n:PES_DepenseAller">
        <h2>Domaine D&#233;pense</h2>
        <p>
            <li>
                <xsl:for-each select="n:Bordereau">
                    <xsl:call-template name="BordereauDepense">
                        <xsl:with-param name="bId" select="."/>
                    </xsl:call-template>
                </xsl:for-each>
            </li>
        </p>
    </xsl:template>
    <xsl:template name="BordereauDepense">
        <xsl:param name="bId"/>
        <ul>
            <xsl:variable name="bUri">xemelios:/query?docId=PES_Aller&amp;etatId=PES_DepenseAller&amp;elementId=BordereauDepense&amp;path=[@added:primary-key='<xsl:value-of select="$bId/@added:primary-key"/>']&amp;xsl:param=(elementId,Bordereau)</xsl:variable>
            <xsl:element name="a">
                <xsl:attribute name="href" select="$bUri"/>
                Bordereau <xsl:value-of select="$bId/n:BlocBordereau/n:IdBord/@V"/>
            </xsl:element>
        </ul>
    </xsl:template>
    
    <xsl:template match="//n:PES_RecetteAller">
        <h2>Domaine Recette</h2>
        <p>
            <li>
                <xsl:for-each select="n:Bordereau">
                    <xsl:call-template name="BordereauRecette">
                        <xsl:with-param name="bId" select="."/>
                    </xsl:call-template>
                </xsl:for-each>
            </li>
        </p>
    </xsl:template>
    <xsl:template name="BordereauRecette">
        <xsl:param name="bId"/>
        <ul>
            <xsl:variable name="bUri">xemelios:/query?docId=PES_Aller&amp;etatId=PES_RecetteAller&amp;elementId=BordereauRecette&amp;path=[@added:primary-key='<xsl:value-of select="$bId/@added:primary-key"/>']&amp;xsl:param=(elementId,Bordereau)</xsl:variable>
            <xsl:element name="a">
                <xsl:attribute name="href" select="$bUri"/>
                Bordereau <xsl:value-of select="$bId/n:BlocBordereau/n:IdBord/@V"/>
            </xsl:element>
        </ul>
    </xsl:template>
</xsl:stylesheet>
