<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:eat="http://msqr.us/xsd/ieat"
	xmlns:xweb="http://msqr.us/xsd/jaxb-web"
	xmlns:date="http://exslt.org/dates-and-times"
	exclude-result-prefixes="eat xweb date">

	<xsl:import href="global-variables.xsl"/>

	<xsl:template match="eat:user" mode="validate">
		<xsl:apply-templates select="." mode="display-internal"/>
	</xsl:template>

	<xsl:template match="eat:user" mode="display-internal">
		<table class="view">
			<tr>
				<th><xsl:value-of select="key('i18n','name.displayName')"/>:</th>
				<td><xsl:value-of select="eat:name"/></td>
			</tr>
			<tr>
				<th><xsl:value-of select="key('i18n','email.displayName')"/>:</th>
				<td><xsl:value-of select="eat:email"/></td>
			</tr>
			<tr>
				<th><xsl:value-of select="key('i18n','login.displayName')"/>:</th>
				<td><xsl:value-of select="@login"/></td>
			</tr>
			<tr>
				<th><xsl:value-of select="key('i18n','password.displayName')"/>:</th>
				<td>*****</td>
			</tr>
			<xsl:if test="@createdDate">
				<tr>
					<th><xsl:value-of select="key('i18n','createdDate.displayName')"/>:</th>
					<td><xsl:value-of select="date:format-date(string(@createdDate),'d MMM yyyy')"/></td>
				</tr>
			</xsl:if>
			<xsl:if test="@lastLoginDate">
				<tr>
					<th><xsl:value-of select="key('i18n','lastLoginDate.displayName')"/>:</th>
					<td><xsl:value-of select="date:format-date(string(@lastLoginDate),'d MMM yyyy H:mm z')"/></td>
				</tr>
			</xsl:if>
		</table>
	</xsl:template>
	
	<xsl:template match="eat:user" mode="edit">
		<tr>
			<th>
				<xsl:if test="$err[@field='user.name']">
					<xsl:attribute name="class">error</xsl:attribute>
				</xsl:if>
				<xsl:value-of select="key('i18n','name.displayName')"/>
			</th>
			<td colspan="3">
				<input type="text" name="user.name" value="{eat:name}"
					maxlength="64"/>
				<div class="caption">
					<xsl:value-of select="key('i18n','name.caption')"/>
				</div>
			</td>
		</tr>
		<tr>
			<th>
				<xsl:if test="$err[@field='user.email']">
					<xsl:attribute name="class">error</xsl:attribute>
				</xsl:if>
				<xsl:value-of select="key('i18n','email.displayName')"/>
			</th>
			<td colspan="3">
				<input type="text" name="user.email" value="{eat:email}"
					maxlength="128"/>
				<div class="caption">
					<xsl:value-of select="key('i18n','email.caption')"/>
				</div>
			</td>
		</tr>
		<tr>
			<th>
				<xsl:if test="$err[@field='user.login']">
					<xsl:attribute name="class">error</xsl:attribute>
				</xsl:if>
				<xsl:value-of select="key('i18n','login.displayName')"/>
			</th>
			<td colspan="3">
				<input type="text" name="user.login" value="{@login}"
					maxlength="32"/>
				<div class="caption">
					<xsl:value-of select="key('i18n','login.caption')"/>
				</div>
			</td>
		</tr>
		<tr>
			<th>
				<xsl:if test="$err[@field='user.password']">
					<xsl:attribute name="class">error</xsl:attribute>
				</xsl:if>
				<xsl:value-of select="key('i18n','password.displayName')"/>
			</th>
			<td colspan="3">
				<input type="password" name="user.password" value="{eat:password}"
					maxlength="64"/>
				<div class="caption">
					<xsl:value-of select="key('i18n','password.caption')"/>
					<xsl:if test="@userId &gt; 0">
						<xsl:text> </xsl:text>
						<xsl:value-of select="key('i18n','password.edit.caption')"/>
					</xsl:if>
				</div>
			</td>
		</tr>
	</xsl:template>

</xsl:stylesheet>