<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fo="http://www.w3.org/1999/XSL/Format">
	
	<xsl:import href="styleEsterno.xsl"/>
	<xsl:template match="/">
		
		<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
			
			<fo:layout-master-set>
				
				<fo:simple-page-master master-name="A4" xsl:use-attribute-sets="paginaXslDef">

					<fo:region-before xsl:use-attribute-sets="beforeXslDef" />          

					<fo:region-body xsl:use-attribute-sets="bodyXslDef" />
					
					<fo:region-after xsl:use-attribute-sets="afterXslDef" />

				</fo:simple-page-master>


				
			</fo:layout-master-set>


			<fo:page-sequence master-reference="A4"  >


				
					<!-- header -->
				<fo:static-content flow-name="xsl-region-before" xsl:use-attribute-sets="flowBeforeXslDef">

          
					
					
					<fo:block space-after="10pt">
					<fo:table table-layout="fixed" >					
						<fo:table-column column-width="50mm"/>
						<fo:table-column column-width="90mm"/>
						<fo:table-column column-width="40mm"/>
						
						<fo:table-body>
							<fo:table-row>
								<fo:table-cell text-align="left" >
									<fo:block><fo:external-graphic src="{//LOGO}" xsl:use-attribute-sets="logoXslDef" scaling-method="auto"/></fo:block>
								</fo:table-cell>
								<fo:table-cell xsl:use-attribute-sets="titoloXslDef" >
									<fo:block>
										<fo:block><xsl:value-of select="//TITLE"/><fo:leader leader-length="2mm" leader-pattern="space" />-<fo:leader leader-length="2mm" leader-pattern="space" /><xsl:value-of select="//DATA_ODIERNA"/></fo:block>
									</fo:block>
								</fo:table-cell>
								<fo:table-cell xsl:use-attribute-sets="numeroPaginaXslDef"  >
									<fo:block >
										<xsl:value-of select="//NUMEROPAGINA"/> <fo:page-number/>/<fo:page-number-citation ref-id="terminator"/>
									</fo:block>
								</fo:table-cell>

							</fo:table-row>	
							
						</fo:table-body>
					</fo:table>
					</fo:block>
					
									
				</fo:static-content>


				

        <fo:flow flow-name="xsl-region-body" font-family="Times" font-size="10pt">
					
					<fo:block>
						<fo:table table-layout="fixed" xsl:use-attribute-sets="tableBodyDef">

								<fo:table-column column-width="18mm"/>
								<fo:table-column column-width="15mm"/>
								<fo:table-column column-width="16mm"/>
								<fo:table-column column-width="15mm"/>
								<fo:table-column column-width="20mm"/>
								<fo:table-column column-width="29mm"/>
								<fo:table-column column-width="17mm"/>
								<fo:table-column column-width="27mm"/>
								<fo:table-column column-width="27mm"/>
				
								<fo:table-header> 
									
														
				
									
				
									<fo:table-row xsl:use-attribute-sets="tabellaSommarioRow">
										<fo:table-cell number-columns-spanned="2"  xsl:use-attribute-sets="celleTitoliSxUp">
											<fo:block><xsl:value-of select="//ESERCENTEDESC" /></fo:block>
										</fo:table-cell>
										<fo:table-cell number-columns-spanned="7" xsl:use-attribute-sets="celleTitoliDxUp">
											<fo:block><xsl:value-of select="//HEADER_ESERCENTESIA"/></fo:block>
										</fo:table-cell>
									</fo:table-row>	
									
									<fo:table-row xsl:use-attribute-sets="tabellaSommarioRow">
										<fo:table-cell number-columns-spanned="2" xsl:use-attribute-sets="celleTitoliSx">
											<fo:block><xsl:value-of select="//TERMINALEDESC" /></fo:block>
										</fo:table-cell>
										<fo:table-cell number-columns-spanned="7" xsl:use-attribute-sets="celleTitoliDx">
											<fo:block><xsl:value-of select="//HEADER_TERMINALE"/></fo:block>
										</fo:table-cell>
									</fo:table-row>	
									
									<fo:table-row xsl:use-attribute-sets="tabellaSommarioRow">
										<fo:table-cell number-columns-spanned="2" xsl:use-attribute-sets="celleTitoliSxDn">
											<fo:block><xsl:value-of select="//CASSADESC" /></fo:block>
										</fo:table-cell>
										<fo:table-cell number-columns-spanned="7" xsl:use-attribute-sets="celleTitoliDxDn">
											<fo:block><xsl:value-of select="//HEADER_NUMEROCASSA"/></fo:block>
										</fo:table-cell>
									</fo:table-row>	
									
								
									
									
									
									
									<fo:table-row>
										<fo:table-cell number-columns-spanned="9" xsl:use-attribute-sets="fraBodyESommarioSotto">
											<fo:block text-align="right" >
											</fo:block>
										</fo:table-cell>
									</fo:table-row>		
									
									<fo:table-row xsl:use-attribute-sets="tabellaSommarioRow">
										<fo:table-cell  xsl:use-attribute-sets="celleTitoliSxUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//DATADESC"/></fo:block>
										</fo:table-cell>
										<fo:table-cell  xsl:use-attribute-sets="celleTitoliCnUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//ORADESC" /></fo:block>
										</fo:table-cell>
										<fo:table-cell  xsl:use-attribute-sets="celleTitoliCnUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//ISSUERDESC"/></fo:block>
										</fo:table-cell>
										<fo:table-cell  xsl:use-attribute-sets="celleTitoliCnUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//IMPORTODESC"/></fo:block>
										</fo:table-cell>
										<fo:table-cell  xsl:use-attribute-sets="celleTitoliCnUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//TIPOOPERAZIONEDESC"/></fo:block>
										</fo:table-cell>
										<fo:table-cell   xsl:use-attribute-sets="celleTitoliCnUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//PANCARTADES"/></fo:block>
										</fo:table-cell>									
										
										
										<fo:table-cell   xsl:use-attribute-sets="celleTitoliCnUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//CONTATOREPOSDESC"/></fo:block>
										</fo:table-cell>
										<fo:table-cell  xsl:use-attribute-sets="celleTitoliCnUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//CODAUTORIZZAZIONEDESC"/></fo:block>
										</fo:table-cell>
										<fo:table-cell   xsl:use-attribute-sets="celleTitoliCnUpDn">
											<fo:block text-align="center" ><xsl:value-of select="//ESITODESC"/></fo:block>
										</fo:table-cell>
										
										
									</fo:table-row>	
							
							</fo:table-header>
							
												
							<fo:table-body xsl:use-attribute-sets="bordoSopraBody">
				
							</fo:table-body>
				
						</fo:table>
						
						
  				</fo:block>		
						
					<fo:block>
						<xsl:apply-templates select="//RAPPORTO" /> 
          </fo:block>

		<fo:block id="terminator">
						
  				</fo:block>			
								
					
        </fo:flow>
        


      </fo:page-sequence>



    </fo:root>
  </xsl:template>


	<xsl:template match="//RAPPORTO">

		<fo:table table-layout="fixed" xsl:use-attribute-sets="tableBodyDef">
				
				<xsl:if test="position() = 1"><xsl:attribute name="break-before">auto</xsl:attribute></xsl:if> 
			
				<fo:table-column column-width="18mm"/>
				<fo:table-column column-width="15mm"/>
				<fo:table-column column-width="16mm"/>
				<fo:table-column column-width="15mm"/>
				<fo:table-column column-width="20mm"/>
				<fo:table-column column-width="29mm"/>
				<fo:table-column column-width="17mm"/>
				<fo:table-column column-width="27mm"/>
				<fo:table-column column-width="27mm"/>

				<fo:table-header> 
					
										

					

					<fo:table-row height="5mm" xsl:use-attribute-sets="tabellaSommarioSotto" >
						<fo:table-cell xsl:use-attribute-sets="celleTitoliSx">
							<fo:block text-align="center" >
							 <xsl:apply-templates select="DISPOSIZIONE/DATAORA" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell xsl:use-attribute-sets="celleTitoliSxDx" >
							<fo:block text-align="center" >
							 <xsl:apply-templates select="DISPOSIZIONE/ORA" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell xsl:use-attribute-sets="celleTitoliCn">
							<fo:block text-align="center" >
								<xsl:apply-templates select="DISPOSIZIONE/ISSUERCARTA" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell xsl:use-attribute-sets="celleTitoliDx">
							<fo:block text-align="right" >
								<xsl:apply-templates select="DISPOSIZIONE/SEGNO" /><xsl:apply-templates select="DISPOSIZIONE/IMPORTO" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell xsl:use-attribute-sets="celleTitoliDx">
							<fo:block text-align="center" >
								<xsl:apply-templates select="DISPOSIZIONE/TIPOOPERAZIONE" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell xsl:use-attribute-sets="celleTitoliDx">
							<fo:block text-align="right" >
								<xsl:apply-templates select="DISPOSIZIONE/PANCARTA" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell xsl:use-attribute-sets="celleTitoliCn">
							<fo:block text-align="center" >
								<xsl:apply-templates select="DISPOSIZIONE/CONTATOREPOS" />
							</fo:block>
						</fo:table-cell>
						
						<fo:table-cell xsl:use-attribute-sets="celleTitoliDx">
							<fo:block text-align="center" >
								<xsl:apply-templates select="DISPOSIZIONE/CODAUTORIZZAZIONE" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell xsl:use-attribute-sets="celleTitoliDx">
							<fo:block text-align="center" >
								<xsl:apply-templates select="DISPOSIZIONE/ESITO" />
							</fo:block>
						</fo:table-cell>
						
						
					</fo:table-row>		

				
			
			</fo:table-header>
			
								
			<fo:table-body xsl:use-attribute-sets="bordoSopraBody">
				<xsl:apply-templates select="DISPOSIZIONE/MOVIMENTO" />			
			</fo:table-body>
			
			
			
			
			
			
			
			
			
				
		</fo:table>

			
	</xsl:template>



	
	<xsl:template match="DISPOSIZIONE/MOVIMENTO" >

		<fo:table-row keep-together="always">
			<xsl:choose>
				<xsl:when test="position() mod 2 = 1">
					<fo:table-cell text-align="left" padding="2pt" xsl:use-attribute-sets="rigaPariSx">
						<fo:block text-align="right"><xsl:value-of select="DATA_CONTABILE"/></fo:block>
					</fo:table-cell>
					<fo:table-cell text-align="left" padding="2pt" xsl:use-attribute-sets="rigaPariCn">
						<fo:block text-align="right"><xsl:value-of select="DATA_VALUTA"/></fo:block>
					</fo:table-cell>
					<fo:table-cell text-align="left" padding="2pt" xsl:use-attribute-sets="rigaPariCn" number-columns-spanned="3">
						<fo:block text-align="left" hyphenate="true" language="it" ><xsl:value-of select="DESCRIZIONE"/></fo:block>
					</fo:table-cell>
					<fo:table-cell text-align="right" padding="2pt" xsl:use-attribute-sets="rigaPariCn">
						<fo:block text-align="right"><xsl:value-of select="DARE"/></fo:block>
					</fo:table-cell>
					<fo:table-cell text-align="right" padding="2pt" xsl:use-attribute-sets="rigaPariDx">
						<fo:block text-align="right"><xsl:value-of select="AVERE"/></fo:block>
					</fo:table-cell>
				</xsl:when> 
				<xsl:otherwise>
					<fo:table-cell text-align="left" padding="2pt" xsl:use-attribute-sets="rigaDispSx">
						<fo:block text-align="right"><xsl:value-of select="DATA_CONTABILE"/></fo:block>
					</fo:table-cell>
					<fo:table-cell text-align="left" padding="2pt" xsl:use-attribute-sets="rigaDispCn">
						<fo:block text-align="right"><xsl:value-of select="DATA_VALUTA"/></fo:block>
					</fo:table-cell>
					<fo:table-cell text-align="left" padding="2pt" xsl:use-attribute-sets="rigaDispCn" number-columns-spanned="3">
						<fo:block text-align="left" hyphenate="true" language="it" ><xsl:value-of select="DESCRIZIONE"/></fo:block>
					</fo:table-cell>
					<fo:table-cell text-align="right" padding="2pt" xsl:use-attribute-sets="rigaDispCn">
						<fo:block text-align="right"><xsl:value-of select="DARE"/></fo:block>
					</fo:table-cell>
					<fo:table-cell text-align="right" padding="2pt" xsl:use-attribute-sets="rigaDispDx">
						<fo:block text-align="right"><xsl:value-of select="AVERE"/></fo:block>
					</fo:table-cell>
				</xsl:otherwise>
			</xsl:choose>	 
				
			
				
			
		
		</fo:table-row>
		
	
	</xsl:template>
	
	



</xsl:stylesheet>
