<?xml version="1.0"?>
<xsl:stylesheet  version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:java="http://www.jclark.com/xt/java/java.net.URLEncoder">
<xsl:output method = "html"/> 
<xsl:template match = "CROSS_DAILY_TRANSGROUP/LIST_G_EXCHANGE_ID2/G_EXCHANGE_ID2/LIST_G_EXCHANGE_DESC/G_EXCHANGE_DESC/LIST_G_ACCOUNT_NO" > 
	<xsl:variable name="rows">0</xsl:variable>
	<xsl:variable name="count">0</xsl:variable>
	<xsl:variable name="total-rows">
	    <xsl:value-of select="count(//TRANS_NO)"/>		    
	</xsl:variable>
	<xsl:variable name="no-of-lines">
	    <xsl:value-of select="80"/>		    
	</xsl:variable>	
	<xsl:variable name="total-pages">
	    <xsl:value-of select="$total-rows div $no-of-lines"/>		    
	</xsl:variable>		
	<xsl:text disable-output-escaping="yes">
		<![CDATA[
			<script type="text/javascript">
				//Function to set count
				var sendcount;
				function sendcount(fincount){
					sendcount=fincount;
					return sendcount;
				}
				//Function to get Package name
				function returncount(getcount){
					return sendcount;
				}
			</script>
		]]>
	</xsl:text>		
	<html>
		<head>
			<title>Daily Transaction Report</title>
			<META http-equiv="Content-Language" content="en-us"/>		
		</head>
		<body>	
		    	<xsl:for-each select="G_ACCOUNT_NO">		    	    		    	 
		 	   <xsl:choose>
				<xsl:when test="position()=1">				    
				  	<xsl:call-template name="DTR-HEADER"/><br/>
				 </xsl:when>			
				<xsl:otherwise>			
					<xsl:call-template name="DTR-HEADER"/><br/>		  	     
				</xsl:otherwise>
			   </xsl:choose>	 		
			   <table width="100%" border="0" cellpadding="0" cellspacing="0">
			     <tr>
				   <td width="10%" height="19" valign="top"><p align="center"><font face="Arial" size="1"><xsl:value-of select="ACCOUNT_NO"/></font></p></td>
				   <td width="10%" height="19" valign="top"><p align="center"><font face="Arial" size="1"><xsl:value-of select="ACCOUNT_NAME_E"/></font></p></td>
			  	   <td width="50%" height="18" valign="top">
			  	        <table border="0" width="100%" cellspacing="0" cellpadding="0">
			  	        	 <xsl:call-template name="LIST_G_NOTES1_TEMPLATE">
			  	        	 	<xsl:with-param name="rows"><xsl:value-of select="$rows" /></xsl:with-param>
			  	        	 	<xsl:with-param name="count"><xsl:value-of select="$rows + $count" /></xsl:with-param>
						</xsl:call-template>
					 </table>
		  	         </td>		    	    
   			         <td width="10%" height="19" valign="top"><p align="center"><font face="Arial" size="1"><xsl:value-of select="CUR_ENG_NAME"/></font></p></td>    	
		 		  <td width="10%" height="19" valign="top"><p align="center"><font face="Arial" size="1"><xsl:value-of select="LIST_G_ACCOUNT_NO1/G_ACCOUNT_NO1/FC_OP_NEW_BAL"/> </font></p></td>
      		               <td width="10%" height="19" valign="top"><p align="center"><font face="Arial" size="1"><xsl:value-of select="LIST_G_ACCOUNT_NO1/G_ACCOUNT_NO1/LC_OP_NEW_BAL"/></font></p></td>
     		           </tr>		  	 		
		         </table>
			 <br/>						 				 				 				 
			</xsl:for-each>	      		
	  	</body>
	    </html>
  </xsl:template> 

  <xsl:template name="LIST_G_NOTES1_TEMPLATE">  
	<xsl:param name="rows"/>
	<xsl:param name="count"/>
	<xsl:for-each select="LIST_G_NOTES1/G_NOTES1">
	    	<xsl:call-template name="G_NOTES1_TEMPLATE">
	    	     <xsl:with-param name="rows"> <xsl:value-of select="$rows" /> </xsl:with-param>
	    	     <xsl:with-param name="count"> <xsl:value-of select="$count" /> </xsl:with-param>
	    	</xsl:call-template>
	</xsl:for-each>
  </xsl:template>
  
  <xsl:template name="G_NOTES1_TEMPLATE">
	  <xsl:param name="rows"/>
	    <xsl:param name="count"/>
         <xsl:variable name="NOTES1_DESC">
	         <xsl:choose>
			<xsl:when test="not(boolean(NOTES1 = null ))"><xsl:value-of select="NOTES1"/></xsl:when>
			<xsl:otherwise>&#160;</xsl:otherwise>
		</xsl:choose>
         </xsl:variable>              
	 <xsl:for-each select="LIST_G_PREPARE_DATE/G_PREPARE_DATE">				
     	  	<tr>
     	  	   <xsl:choose>
			<xsl:when test="position() = 1">
				<td width="20%">
		        	  <p><font face="Arial" size="1">
				          <xsl:value-of select="$NOTES1_DESC"/>         	        
		         	       </font></p>
	         	       	<xsl:call-template name="G_PREPARE_DATE_TEMPLATE">
						  <xsl:with-param name="rows"><xsl:value-of select="position() + $rows" /></xsl:with-param> 
						  <xsl:with-param name="count"><xsl:value-of select="$count + $rows"/></xsl:with-param> 		         
					</xsl:call-template>
	          	      </td>	
			</xsl:when>
			<xsl:otherwise>
				<td width="20%">
		        	  <p><font face="Arial" size="1"></font></p>
	          	      </td>
				<xsl:call-template name="G_PREPARE_DATE_TEMPLATE">
					  <xsl:with-param name="rows"><xsl:value-of select=" position() + $rows"/></xsl:with-param>
					  <xsl:with-param name="count"><xsl:value-of select=" $rows + $rows"/></xsl:with-param>
				</xsl:call-template>
			</xsl:otherwise>
		  </xsl:choose>  	     
 	   </tr>	 		
	</xsl:for-each>	
  </xsl:template> 

<xsl:template name="G_PREPARE_DATE_TEMPLATE">
        <xsl:param name="rows"/>
        <xsl:param name="count"/>
	 <td width="5%"><p align="center"><font face="Arial" size="1"><xsl:value-of select="PREPARE_DATE"/></font></p></td>
	 <td width="10%"><p align="center"><font face="Arial" size="1"><xsl:value-of select="TRANS_NO"/>--<xsl:value-of select="$rows"/>--<xsl:value-of select="$count"/></font></p></td>
	 <td width="5%"><p align="center"><font face="Arial" size="1"><xsl:value-of select="CF_LINE_NO"/></font></p></td>
	 <td width="10%"><p align="center"><font face="Arial" size="1"><xsl:value-of select="REF_NO"/></font></p></td>	
	 
</xsl:template>

<xsl:template name="DTR-HEADER">		
	<xsl:variable name="as-of-date">
	    <xsl:value-of select="//CROSS_DAILY_TRANSGROUP/AS_OF_DATE"/>
	</xsl:variable>  
	<table cellpadding="0" cellspacing="0" width="100%" border="1">
		<tr>
			<td vAlign="middle" width="20%" height="25" colspan="2"><font face="Arial" size="1">Al Muzaini Exchange Co. - Head office</font></td>
			<td vAlign="middle" width="50%" height="25" colspan="5"><p align="center"><font face="Arial" size="1">Daily Transactions Report</font></p></td>
			<td vAlign="middle" width="20%" height="25" colspan="2"><font face="Arial" size="1">Printed Date : <xsl:value-of select="$as-of-date"/></font></td>
			<td vAlign="middle" width="10%" height="25"> <p align="center"><font face="Arial" size="1">Page No: </font></p></td></tr>		
		<tr>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">Account No</font></p></td>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">Account Name</font></p></td>
			<td width="20%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Tx Description</font></p></td>
			<td width="5%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Tx Date</font></p></td>
			<td width="10%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Doc No</font></p></td>
			<td width="5%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Ln</font></p></td>
			<td width="10%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Draft No.</font></p></td>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">Currency Name</font></p></td>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">FC Opening Bal</font></p></td>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">LC Opening Bal</font></p></td></tr>
	</table>
</xsl:template>

<xsl:template name="DTR-SUB-HEADER">		  
	<table cellpadding="0" cellspacing="0" width="100%" border="1">				
		<tr>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">Account No</font></p></td>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">Account Name</font></p></td>
			<td width="20%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Tx Description</font></p></td>
			<td width="5%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Tx Date</font></p></td>
			<td width="10%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Doc No</font></p></td>
			<td width="5%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Ln</font></p></td>
			<td width="10%" height="10" bgcolor="#F8F8F8"><p align="center"><font face="Arial" size="1">Draft No.</font></p></td>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">Currency Name</font></p></td>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">FC Opening Bal</font></p></td>
			<td width="10%" height="10" bgcolor="#EEEEEE"><p align="center"><font face="Arial" size="1">LC Opening Bal</font></p></td></tr>		
	</table>
</xsl:template>

</xsl:stylesheet> 