<?xml version="1.0" encoding="ISO-8859-1" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/extrato">
	<table width="100%"><tr>
		<td valign="middle" align="center" width="100"><img width="90" height="79" src="logo.jpg"/> </td>
		<td valign="middle">
			<b>Associação Médica do Hospital Samaritano</b>
			<br/>Extrato de Cobrança para Conferência

			<br/>Médico: <i><xsl:value-of select="@pnome" /></i> (crm <xsl:value-of select="@pcrm" />)
			<br/>Procedimentos de <xsl:value-of select="@periodo_de" /> até <xsl:value-of select="@periodo_ate" />
		</td>
		<td valign="middle"><a href="javascript:window.print();void(0);"><img src="print.gif"/></a></td>
	</tr></table>

	<xsl:apply-templates select="convenio">
		<xsl:sort select="@razao_social"/>
	</xsl:apply-templates>
</xsl:template>


<xsl:template match="convenio">
	<h2>
		Convênio: <xsl:value-of select="@razao_social" /> (CNPJ <xsl:value-of select="@cnpj" />)
	</h2>

	<table border="0" cellpadding="0" cellspacing="0" width="94%" align="center">
		<tr bordercolor="#000000">
			<td width="8%" class="xyzTit2">Lancto</td>
			<td width="27%" class="xyzTit">Paciente</td>
			<td width="20%" class="xyzTit">Dt Proc</td>
			<td class="xyzTit">IR</td>
			<td class="xyzTit">INSS</td>
			<td width="8%" class="xyzTit">Vlr Liquido</td>
			<td class="xyzTit">Dt cobr</td>
			<td width="8%" class="xyzTit">Vlr recebido</td>
			<td class="xyzTit">Dt receb</td>
		</tr>

		<xsl:apply-templates select="lancamento">
			<xsl:sort select="@cod"/>
		</xsl:apply-templates>

		<tr bordercolor="#000000">
			<td >Totais:</td>
			<td colspan="4"></td>
			<td class="xTot"><xsl:value-of select="format-number(sum(lancamento/@VlrLiquido),'#.00')" /></td>
			<td ></td>
			<td class="xTot"><xsl:value-of select="format-number(sum(lancamento/@VlrReceb),'#.00')" /></td>
			<td ></td>
		</tr>
	</table>
</xsl:template>



<xsl:template match="lancamento">
	<tr>
		<td width="8%" class="xyz2"><xsl:value-of select="@cod"/></td>
		<td width="27%" class="xyz"><xsl:value-of select="@pac_nome"/></td>
		<td width="10%" class="xyz"><xsl:value-of select="@proc_dt"/></td>
		<td class="xyz"><xsl:value-of select="@IR"/></td>
		<td class="xyz"><xsl:value-of select="@INSS"/></td>
		<td width="8%" class="xyz"><xsl:value-of select="format-number(@VlrLiquido,'#.00')"/></td>
		<td class="xyz"><xsl:value-of select="@DtCobr"/></td>
		<td width="8%" class="xyz"><xsl:value-of select="format-number(@VlrReceb,'#.00')"/></td>
		<td class="xyz"><xsl:value-of select="@DtReceb"/></td>
	</tr>
</xsl:template>





</xsl:stylesheet>

