<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="html" version="4.0" encoding="iso-8859-1" indent="yes"/>
<xsl:decimal-format name="std" decimal-separator="." grouping-separator=","/>

<!-- Include the Style Sheet -->
<xsl:include href="style.xsl"/>
<xsl:include href="menu.xsl"/>
<xsl:include href="bottom_menu.xsl"/>
<xsl:include href="toplogo.xsl"/>


<xsl:template match="/">
	<html xmlns:fo="http://www.w3.org/1999/XSL/Format"><head>
  <!-- StyleSheet -->
  <xsl:call-template name="style"/>

  <title>IBS OPENAccess Tenancy Statement</title>
  <meta http-equiv="content-language" content="en-gb"/>
  <meta name="Generator" content="MoreMotion Web Designer"/>
  <meta name="Category" content="WEB Development"/>
    
</head>
		<body>
			<table height="100%" cellSpacing="2" cellPadding="2" width="100%" border="0">
				<tbody style="background-color: #d7e7ef">
					<xsl:call-template name="toplogo"/>
					<tr>
						<td vAlign="top">
							<table cellSpacing="0" cellPadding="0" name="Header">
								<tbody>
									<tr>
										<td class="header" align="center">OPENAccess</td>
									</tr>
									<tr>
										<td vAlign="top">
											<xsl:call-template name="Menu"/>
										</td>
									</tr>
								</tbody>
							</table>
						</td><!-- Main Body -->
						<td vAlign="top">
							<table cellSpacing="5" cellPadding="5" width="100%">
								<tbody>
									<tr>
										<td class="header" colSpan="2" vAlign="middle" align="center">Your Statement Details</td>
									</tr>
									<tr>
										<td class="header2" width="20%">Name</td>
										<td class="data2">
											<b>
												<xsl:value-of select="Root/PersonName/PersonTitle"/>
												<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
												<xsl:value-of select="Root/PersonName/Initials"/>
												<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
												<xsl:value-of select="Root/PersonName/Surname"/>
											</b>
										</td>
									</tr>
									<tr>
										<td class="data">Tenancy Ref</td>
										<td class="data2">
											<strong>
												<xsl:value-of select="Root/TenancyStatement/Tenancy/@tenancy_ref"/>
											</strong>
										</td>
									</tr>
								</tbody>
							</table>
							<table cellSpacing="5" cellPadding="5" width="100%">
								<tbody>
									<tr>
										<td>
											<table cellSpacing="0" cellPadding="5">
												<tbody>
													<tr>
														<td class="data2">Date</td>
														<td class="data2">Posting Yr/Wk</td>
														<td class="data2">Transaction</td>
														<td class="data2">Comment</td>
														<td class="data2">Credit</td>
														<td class="data2">Debit</td>
														<td class="data2">Balance</td>
													</tr>
													<xsl:for-each select="Root/TenancyStatement/Tenancy/Tenancy_Trans/Trans">
														<xsl:sort select="@posting_year_week" order="ascending" data-type="number"/><xsl:variable name="running_bal" select="sum(@amount)"/><xsl:variable name="total_bal" select="$running_bal + sum(@amount)"/>
														<xsl:choose>
															<xsl:when test="position() mod 2 = 0">
															<tr>
																<td class="dataamt"><xsl:value-of select="@posting_year_week"/></td>
																<td class="dataamt"><xsl:value-of select="@trans_date"/></td>																
																<td class="dataamt"><xsl:value-of select="@account_desc"/></td>
										  	  					<td class="dataamt"><xsl:value-of select="@comment"/></td>
																<td class="dataamt"><xsl:if test="@credit=0"><xsl:text/></xsl:if><xsl:if test="@credit!=0"><xsl:value-of select="@credit"/><xsl:text>CR</xsl:text></xsl:if></td>
																<td class="dataamt"><xsl:if test="@debit=0"><xsl:text/></xsl:if><xsl:if test="@debit!=0"><xsl:value-of select="@debit"/><xsl:text>DR</xsl:text></xsl:if></td>
																<td class="dataamt"><xsl:value-of select="sum(//@amount)"/></td>
										        			</tr>
															</xsl:when>
															<xsl:when test="position() mod 2 = 1">
																<tr>
																	<td class="dataamt1">
																		<xsl:value-of select="@posting_year_week"/>
																	</td>
																	<td class="dataamt1">
																		<xsl:value-of select="@trans_date"/>
																	</td>
																	<td class="dataamt1">
																		<xsl:value-of select="@account_desc"/>
																	</td>
																	<td class="dataamt1">
																		<xsl:value-of select="@comment"/>
																	</td>
																	<td class="dataamt1">
																		<xsl:if test="@credit=0">
																			<xsl:text/>
																		</xsl:if>
																		<xsl:if test="@credit!=0"><xsl:value-of select="@credit"/><xsl:text>CR</xsl:text></xsl:if>
																	</td>
																	<td class="dataamt1">
																		<xsl:if test="@debit=0"><xsl:text/></xsl:if>
																		<xsl:if test="@debit!=0">
																			<xsl:value-of select="@debit"/>
																			<xsl:text>DR</xsl:text>
																		</xsl:if>
																	</td>
																	<td class="dataamt1">
																		<xsl:value-of select="sum(@amount)"/>
																	</td>
																</tr>
															</xsl:when>
														</xsl:choose>
													</xsl:for-each>
													<tr>
														<td>
															<table width="100%">
																<tbody>
																	<tr>
																		<td class="data">Total:</td>
																		<td class="data1" colSpan="2" vAlign="right">
																			<xsl:value-of select="format-number(sum(/Root/TenancyStatement/Tenancy/Tenancy_Trans/Trans/@amount),'########0.00;-########0.00')"/>
																		</td>
																	</tr>
																</tbody>
															</table>
														</td>
													</tr>
												</tbody>
											</table>
										</td>
									</tr>
								</tbody>
							</table>
						</td>
						<td/><!-- Left Pane -->
					</tr><!-- Bottom Row -->
					<tr>
						<xsl:call-template name="bottom_menu"/>
					</tr>
				</tbody>
			</table>
		</body>
	</html>
</xsl:template>




</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2005. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="..\..\sample_xml\Trans.xml" htmlbaseurl="http://localhost/" outputurl="" processortype="internal" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition></MapperMetaTag>
</metaInformation>
-->