<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0" >
<xsl:template match="/">
	<fo:root>
		<!--la mise en page -->
		<fo:layout-master-set>
			<fo:simple-page-master master-name="A4"
			 page-width="210mm" page-height="297mm"
			 margin-top="0.5cm"   margin-bottom="0.5cm"
			 margin-left="0.5cm"  margin-right="1cm">
			  <fo:region-body   margin="3cm"/>
			  <fo:region-before extent="3cm"/>
			  <fo:region-after  extent="2cm"/>
			  <fo:region-start  extent="1cm"/>
			  <fo:region-end    extent="2cm"/>
			</fo:simple-page-master>
		</fo:layout-master-set>	
		<!--le Document -->
		<fo:page-sequence master-reference="A4">		
			<!-- Pieds de page -->
			<fo:static-content flow-name="xsl-region-after">				
				<xsl:for-each select="document/bassoc">
					<fo:external-graphic>
						<xsl:attribute name="src"><xsl:value-of select="imagebas/@sourcebas"/></xsl:attribute>
					</fo:external-graphic>
				</xsl:for-each>		
			</fo:static-content>		
			<!--Corps du document -->
			<fo:flow flow-name="xsl-region-body">	
				<!-- Cadres entête -->			
				<fo:table table-layout="fixed" font-family="Verdana" font-size="8pt" border="0px solid #000">
					<fo:table-column  column-width="10cm"/>
					<fo:table-column  column-width="9cm"/>					
					<fo:table-body>
					<xsl:for-each select="document/references">
						<fo:table-row>
							<fo:table-cell padding="4px" text-align="center" border="0.5px solid #000" >
								<fo:block  font-family="Arial" font-size="10pt" font-weight="bold" text-align="left" color="#084800" >
									C o n v e n t i o n n é
								</fo:block>
								<fo:block  font-family="Arial" font-size="10pt" text-align="left"  padding-before="0.5cm">
									<xsl:value-of select="refps"/> 
								</fo:block>
								<fo:block  font-family="Arial" font-size="10pt" text-align="left">
									Facture N° :<xsl:value-of select="numcons"/>
								</fo:block>
								<fo:block  font-family="Arial" font-size="10pt" text-align="left">
									<xsl:value-of select="specps"/>
								</fo:block>
							</fo:table-cell>	
							<fo:table-cell padding="4px" text-align="center" border="0.5px solid #000">
								<fo:block  font-family="Arial" font-weight="bold" font-size="10pt" text-align="left" color="#084800">
									O r g a n i s m e
								</fo:block>					
								<fo:block  font-family="Arial" font-size="10pt" text-align="left" padding-before="0.5cm" >
									<xsl:value-of select="refclient"/>
								</fo:block>					
								<fo:block  font-family="Arial" font-size="10pt" text-align="left">
									<xsl:value-of select="adresseclient"/>
								</fo:block>
							</fo:table-cell>																								
						</fo:table-row>
					</xsl:for-each>		
					</fo:table-body>
				</fo:table>	
				<!--les entêtes (titres) -->
				<xsl:for-each select="document/titres">
					<fo:block  font-family="Verdana" color="#001e7a" font-size="10pt" text-align="center" padding-before="0.5cm" font-weight="bold"><xsl:value-of select="titre"/><xsl:text> </xsl:text>
					</fo:block>
				</xsl:for-each>										
				<!--tableau -->				
				<fo:table table-layout="fixed" font-family="Arial" font-size="10px" border="0px solid #000">
					<fo:table-column  column-width="1cm"/>
					<fo:table-column  column-width="3cm"/>
					<fo:table-column  column-width="3cm"/>
					<fo:table-column  column-width="2cm"/>
					<fo:table-column  column-width="7cm"/>
					<fo:table-column  column-width="3cm"/>					
					<fo:table-body>
					<xsl:for-each select="document/ligne">
						<fo:table-row font-family="Verdana" font-size="8pt">
							<fo:table-cell padding="4px" border="0.5px solid #000">
								<fo:block><xsl:value-of select="numlig"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>
							<fo:table-cell padding="4px" border="0.5px solid #000" text-align="right">
								<fo:block><xsl:value-of select="numbs"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>
							<fo:table-cell padding="4px" border="0.5px solid #000" text-align="right">
								<fo:block><xsl:value-of select="datecons"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>
							<fo:table-cell padding="4px" border="0.5px solid #000" text-align="right">
								<fo:block><xsl:value-of select="identif"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>	
							<fo:table-cell padding="4px" border="0.5px solid #000" text-align="left">
								<fo:block><xsl:value-of select="nomadh"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>	
							<fo:table-cell padding="4px" border="0.5px solid #000" text-align="right">
								<fo:block><xsl:value-of select="montant"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>																								
						</fo:table-row>
					</xsl:for-each>		
					</fo:table-body>
				</fo:table>	
				<!--Bas du Tableau -->			
				<fo:table table-layout="fixed" font-family="Verdana" font-size="8pt" border="0px solid #000">
					<fo:table-column  column-width="12.5cm"/>
					<fo:table-column  column-width="6.5cm"/>					
					<fo:table-body>
					<xsl:for-each select="document/totaux">
						<fo:table-row >
							<fo:table-cell padding="4px" text-align="center" font-weight="bold" border="0.5px solid #000" color="#084800">
								<fo:block><xsl:value-of select="totlettre"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>
							<fo:table-cell padding="4px" border="0.5px solid #000" text-align="right" color="#001e7a">
								<fo:block><xsl:value-of select="totnet"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>																								
						</fo:table-row>
					</xsl:for-each>		
					</fo:table-body>
				</fo:table>	
				<!-- Cadres -->
				<fo:block  font-family="Arial" font-size="10pt" text-align="right" padding-after="0.5cm" ></fo:block>			
				<fo:table table-layout="fixed" font-family="Verdana" font-size="8pt" border="0.5px solid #000">
					<fo:table-column  column-width="6.6cm"/>
					<fo:table-column  column-width="6.8cm"/>
					<fo:table-column  column-width="5.6cm"/>					
					<fo:table-body>
					<xsl:for-each select="document/cadres">
						<fo:table-row>
							<fo:table-cell padding="4px" text-align="center" border="0.5px solid #000" >
								<fo:block><xsl:value-of select="zone1"/><xsl:text> </xsl:text></fo:block>
								<fo:block  font-family="Verdana" font-size="8pt" text-align="right" padding-after="0.5cm" ></fo:block>
								<fo:block  font-family="Verdana" font-size="8pt" text-align="right" padding-after="0.5cm" ></fo:block>
							</fo:table-cell>
							<fo:table-cell padding="4px" text-align="center" border="0.5px solid #000">
								<fo:block padding-after="0.5cm"><xsl:value-of select="zone2"/><xsl:text> </xsl:text></fo:block>
								<fo:block padding-after="0.3cm" text-align="left" >Date de réception:.....................................</fo:block>
								<fo:block  text-align="left" >N° d'enregistrement:..................................</fo:block>
							</fo:table-cell>	
							<fo:table-cell padding="4px" text-align="center" border="0.5px solid #000">
								<fo:block><xsl:value-of select="zone3"/><xsl:text> </xsl:text></fo:block>
							</fo:table-cell>																								
						</fo:table-row>
					</xsl:for-each>		
					</fo:table-body>
				</fo:table>								
			</fo:flow>								
		</fo:page-sequence>			
	</fo:root>	
</xsl:template>
</xsl:stylesheet>
