<?xml version="1.0" encoding="UTF-8" ?>
<!--<? /*ceci est juste un faux tag PHP (<?) pour permettre la colorisation du code*/ -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<html>
<head>
	<style>
		html {font-family:verdana, helvetica, sans-serif;	font-size:11px;}
		th {text-align:left;}
		div.unit {position:relative; float:left;border:solid black 1px;margin:5px;}
		div.header {border-bottom:solid black 1px;padding:2px;}
		div.body {position:relative;padding:2px; padding-right:40px;}
		div.att {font-weight:bold; position:absolute; right:3px; top:3px; border:solid black 1px; width:30px;height:30px; text-align:center; vertical-align:baseline;}
		div.def {font-weight:bold; position:absolute; right:3px; bottom:3px; border:solid black 1px; width:30px;height:30px; text-align:center; vertical-align:center;}
		table.detail {border:solid black 1px;}
		tr.values {font-weight:bold;}
		tr.equip {background-color:lightgrey;}
		tr.head {font-weight:bold; background-color:lightgrey;}
		tr.head th {border-bottom:solid black 1px;}
		td.values {text-align:center; border-left:solid black 1px;}
	</style>
</head>
<body>
<xsl:variable name="equiplist" select="/page/uniteequip/eqp"/>
<xsl:variable name="typelist" select="/page/unitetype/type"/>


<xsl:for-each select="/page/unites/unite">
	<xsl:variable name="unit" select="."/>
	<xsl:variable name="eqpunit" select="$unit//equipement/@id"/>
	
	<div class="unit">
		<div class="header">
			Type : <xsl:value-of select="$typelist[@id=$unit/@type]"/><br />
			Unité : <xsl:value-of select="@nom"/><br />
			Quantité : <xsl:value-of select="@total"/><br />
		</div>
		<div class="body">
			<table class="detail" cellspacing="0" cellpadding="2">
				<tr class="head">
					<th>Détail</th>
					<th>Att</th>
					<th>Déf</th>
				</tr>
				<tr class="values">
					<td>Valeur de Base</td>
					<td class="values"><xsl:value-of select="$typelist[@id=$unit/@type]/@att"/></td>
					<td class="values"><xsl:value-of select="$typelist[@id=$unit/@type]/@def"/></td>
				</tr>
				<xsl:for-each select="./equipement">
				<tr class="equip">
					<xsl:variable name="equipid" select="@id"/>
					<td>- <xsl:value-of select="$equiplist[@id=$equipid]/."/></td>
					<td class="values"><xsl:value-of select="$equiplist[@id=$equipid]/@att"/></td>
					<td class="values"><xsl:value-of select="$equiplist[@id=$equipid]/@def"/></td>
				</tr>
				</xsl:for-each>
				<tr class="values">
					<td>Total</td>
					<td class="values"><xsl:value-of select="sum($equiplist[@id=$eqpunit]/@att) + $typelist[@id=$unit/@type]/@att"/></td>
					<td class="values"><xsl:value-of select="sum($equiplist[@id=$eqpunit]/@def) + $typelist[@id=$unit/@type]/@def"/></td>
				</tr>
			</table>
			<div class="att">
				ATT<br />
				<xsl:value-of select="(sum($equiplist[@id=$eqpunit]/@att) + $typelist[@id=$unit/@type]/@att) * @total"/>
			</div>
			<div class="def">
				DEF<br />
				<xsl:value-of select="(sum($equiplist[@id=$eqpunit]/@def) + $typelist[@id=$unit/@type]/@def) * @total"/>
			</div>
		</div>
	</div>
</xsl:for-each>

</body>
</html>

</xsl:template>
</xsl:stylesheet>