<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="VIEW-CONTENT">
	<xsl:choose>
		<xsl:when test="PAGED-LIST">
			<xsl:call-template name="SITE-USERS-PAGED-LIST"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:call-template name="NO-LOGIN-MODULE-MESSAGE"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>		
	
<xsl:template name="NO-LOGIN-MODULE-MESSAGE">
	<p style="padding-left: 10px;"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/NO-LOGIN-MODULE-ADDED"/></p>
</xsl:template>	
	
<xsl:template name="SITE-USERS-PAGED-LIST">	
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
	<td>&#160;</td>
</tr>
<tr>
	<td class="sb-toolbarpadding">
		<xsl:apply-templates select="/SITEBUILDER-PAGE/STATUS" mode="admin"/>
		<xsl:apply-templates/>
	</td>
</tr>
</table>
<script language="javascript">
function unlockUsers() {
	if (countSelectedCheckBoxes() > 0) {
		document.forms.listForm.action.value = '/Admin/Site/User/Activate';
		document.forms.listForm.siteId.value = '<xsl:value-of select="@SITE-ID"/>';
		document.forms.listForm.submit();
	}
	else {
		alert('<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/SELECT-FOR-DELETE"/>');
	}
}
function lockUsers() {
	if (countSelectedCheckBoxes() > 0) {
		document.forms.listForm.action.value = '/Admin/Site/User/Deactivate';
		document.forms.listForm.siteId.value = '<xsl:value-of select="@SITE-ID"/>';
		document.forms.listForm.submit();
	}
	else {
		alert('<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/SELECT-FOR-DELETE"/>');
	}
}
function deleteUsers() {
	if (countSelectedCheckBoxes() > 0) {
		if (confirm('<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/SURE-TO-DELETE"/>')) {
			document.forms.listForm.action.value = '/Admin/Site/User/Delete';
			document.forms.listForm.siteId.value = '<xsl:value-of select="@SITE-ID"/>';
			document.forms.listForm.submit();
		}
	}
	else {
		alert('<xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/SELECT-FOR-DELETE"/>');
	}
}
</script>

</xsl:template>

<xsl:template match="PAGED-LIST/LIST/HEADER">
<input type="hidden" id="siteId" name="siteId" />
<!--
<xsl:variable name="headerStructure" select="document('d:/1.xml')"/>
<xsl:for-each select="$headerStructure/root/item">
	<xsl:call-template name="LIST-HEADER-ITEM">
		<xsl:with-param name="field"><xsl:value-of select="field"/></xsl:with-param>
		<xsl:with-param name="title"><xsl:value-of select="title"/></xsl:with-param>
		<xsl:with-param name="width"><xsl:value-of select="width"/></xsl:with-param>
		<xsl:with-param name="align"><xsl:value-of select="align"/></xsl:with-param>
		<xsl:with-param name="currentSortField"><xsl:value-of select="../../LIST/@ORDER-BY"/></xsl:with-param>
		<xsl:with-param name="currentSortType"><xsl:value-of select="../../LIST/@ORDER-TYPE"/></xsl:with-param>
	</xsl:call-template>
</xsl:for-each>
-->

<tr class="sb-gridview-header" align="left" style="height:24px;white-space:nowrap;">
	<th style="width:1%;text-align:center;">
		<input type="checkbox" name="globalCheck" onclick="setCheckboxStatus(this.checked);"/>
	</th>
	
	<xsl:call-template name="LIST-HEADER-ITEM">
		<xsl:with-param name="field">status</xsl:with-param>
		<xsl:with-param name="title"><xsl:value-of select="STATUS"/></xsl:with-param>
		<xsl:with-param name="width">1%</xsl:with-param>
		<xsl:with-param name="currentSortField"><xsl:value-of select="../../LIST/@ORDER-BY"/></xsl:with-param>
		<xsl:with-param name="currentSortType"><xsl:value-of select="../../LIST/@ORDER-TYPE"/></xsl:with-param>
		<xsl:with-param name="align">center</xsl:with-param>
	</xsl:call-template>

	<xsl:call-template name="LIST-HEADER-ITEM">
		<xsl:with-param name="field">name</xsl:with-param>
		<xsl:with-param name="title"><xsl:value-of select="USER-NAME"/></xsl:with-param>
		<xsl:with-param name="currentSortField"><xsl:value-of select="../../LIST/@ORDER-BY"/></xsl:with-param>
		<xsl:with-param name="currentSortType"><xsl:value-of select="../../LIST/@ORDER-TYPE"/></xsl:with-param>
	</xsl:call-template>

	<xsl:call-template name="LIST-HEADER-ITEM">
		<xsl:with-param name="field">email</xsl:with-param>
		<xsl:with-param name="title"><xsl:value-of select="EMAIL"/></xsl:with-param>
		<xsl:with-param name="currentSortField"><xsl:value-of select="../../LIST/@ORDER-BY"/></xsl:with-param>
		<xsl:with-param name="currentSortType"><xsl:value-of select="../../LIST/@ORDER-TYPE"/></xsl:with-param>
	</xsl:call-template>

	<xsl:call-template name="LIST-HEADER-ITEM">
		<xsl:with-param name="field">fullName</xsl:with-param>
		<xsl:with-param name="title"><xsl:value-of select="FULL-NAME"/></xsl:with-param>
		<xsl:with-param name="currentSortField"><xsl:value-of select="../../LIST/@ORDER-BY"/></xsl:with-param>
		<xsl:with-param name="currentSortType"><xsl:value-of select="../../LIST/@ORDER-TYPE"/></xsl:with-param>
		<xsl:with-param name="align">left</xsl:with-param>
	</xsl:call-template>

	<xsl:call-template name="LIST-HEADER-ITEM">
		<xsl:with-param name="field">creationDate</xsl:with-param>
		<xsl:with-param name="title"><xsl:value-of select="CREATION-DATE"/></xsl:with-param>
		<xsl:with-param name="currentSortField"><xsl:value-of select="../../LIST/@ORDER-BY"/></xsl:with-param>
		<xsl:with-param name="currentSortType"><xsl:value-of select="../../LIST/@ORDER-TYPE"/></xsl:with-param>
		<xsl:with-param name="align">right</xsl:with-param>
	</xsl:call-template>
</tr>
</xsl:template>


<xsl:template match="PAGED-LIST/LIST/ITEM">
<xsl:variable name="class">
	<xsl:call-template name="LIST-ROW-CLASS">
        	<xsl:with-param name="position"><xsl:value-of select="position()"/></xsl:with-param>
	</xsl:call-template>
</xsl:variable>
<tr class="{$class}" style="height:24px;">
	<td style="width:1%;text-align:center;">
		<input type="checkbox" name="objectIds[]">
			<xsl:attribute name="value"><xsl:value-of select="ID"/></xsl:attribute>
		</input>
	</td>

	<xsl:call-template name="LIST-ROW-ITEM">
		<xsl:with-param name="icon">
			<xsl:choose>
				<xsl:when test="STATUS = '1'">run.png</xsl:when>
				<xsl:otherwise>shutdown.png</xsl:otherwise>
			</xsl:choose>
		</xsl:with-param>
	</xsl:call-template>

	<xsl:call-template name="LIST-ROW-ITEM">
		<xsl:with-param name="title"><xsl:value-of select="NAME"/></xsl:with-param>
		<xsl:with-param name="action"><xsl:value-of select="$baseUrl"/>/Admin/Site/User/Edit?siteId=<xsl:value-of select="../../../@SITE-ID"/>&amp;userId=<xsl:value-of select="ID"/></xsl:with-param>
	</xsl:call-template>

	<xsl:call-template name="LIST-ROW-ITEM">
		<xsl:with-param name="title"><xsl:value-of select="EMAIL"/></xsl:with-param>
	</xsl:call-template>

	<xsl:call-template name="LIST-ROW-ITEM">
		<xsl:with-param name="title"><xsl:value-of select="FIRST-NAME"/>&#160;<xsl:value-of select="LAST-NAME"/></xsl:with-param>
	</xsl:call-template>

	<xsl:call-template name="LIST-ROW-ITEM">
		<xsl:with-param name="title"><xsl:value-of select="CREATION-DATE"/></xsl:with-param>
		<xsl:with-param name="align">right</xsl:with-param>
	</xsl:call-template>
</tr>
</xsl:template>

</xsl:stylesheet>