﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template name="NotifyListDetails">
		<xsl:param name="ShareITList" select="'N/A'"></xsl:param>
		<xsl:param name="taskID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalUserList" select="'N/A'"></xsl:param>
		<xsl:param name="PortalClientList" select="'N/A'"></xsl:param>
		<xsl:param name="LogInUser" select="'N/A'"></xsl:param>
		<xsl:param name="NoteAutoNotify" select="'N/A'"></xsl:param>
		<xsl:param name="PortalPermissionID" select="'N/A'"></xsl:param>
		
		<xsl:if test="count($ShareITList[ID != $LogInUser]) &gt; 0">
		
			<div class="divOtherPortalMemberList"  style="width:90%;float:left;display:none;" id="div_{$taskID}_NotifyAllCoachingProgram">
				<!--
				<span class="verticallyMiddle capitalFont" >
					<b class="heding">Notify All in My Coaching Program:</b>
				</span>
-->
				<xsl:if test="count($ShareITList[Coach =1])&gt;0">
					<div class="even-div">
						<xsl:for-each select="$ShareITList[Coach =1]">
							<xsl:sort order="descending" select="PermissionID"/>
							<xsl:if test="ID != $LogInUser">
								<span class="chk_box">
									<input name="nmUsers" type="checkbox" class="verticallyMiddle"
									   style="margin:0 !important;" userID="{ID}" pid="{PermissionID}"></input>
									<span>
										<xsl:value-of select="Name"/>
									</span>
								</span>
							</xsl:if>

						</xsl:for-each>
					</div>
				</xsl:if>
				<xsl:if test="count($ShareITList[Coach !=1 and Participant=1])&gt;0">
					<div class="odd-div">
						<xsl:for-each select="$ShareITList[Coach !=1 and Participant=1]">
							<xsl:sort order="descending" select="PermissionID"/>
							<xsl:if test="ID != $LogInUser">
								<span class="chk_box">
									<input name="nmUsers" type="checkbox" class="verticallyMiddle"
									   style="margin:0 !important;" userID="{ID}" pid="{PermissionID}"></input>
									<span>
										<xsl:value-of select="Name"/>
									</span>
								</span>
							</xsl:if>
						</xsl:for-each>
					</div>
				</xsl:if>
				<xsl:if test="count($ShareITList[Coach !=1 and Participant !=1 and Observer =1])&gt;0">
					<xsl:variable name="EvenOddCls">
						<xsl:choose>
							<xsl:when test="count($ShareITList[Coach !=1 and Participant=1])&gt;0">
								<xsl:text>even-div</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>odd-div</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<div class="{$EvenOddCls}">
						<xsl:for-each select="$ShareITList[Coach !=1 and Participant !=1 and Observer =1]">
							<xsl:sort order="descending" select="PermissionID"/>
							<xsl:if test="ID != $LogInUser">
								<span class="chk_box">
									<input name="nmUsers" type="checkbox" class="verticallyMiddle"
									   style="margin:0 !important;" userID="{ID}" pid="{PermissionID}"></input>
									<span>
										<xsl:value-of select="Name"/>
									</span>
								</span>
							</xsl:if>
						</xsl:for-each>
					</div>
				</xsl:if>
			</div>
		</xsl:if>
		<xsl:if test="$PortalPermissionID &gt;1">
			
			<xsl:if test="count($PortalUserList[AuthorizedID != $LogInUser]) &gt; 0 or count($PortalClientList[AuthorizedID != $LogInUser]) &gt; 0">
			<div style="width:90%;float:left;display:none;"  id="div_{$taskID}_NotifyMyClientPortal">
				<span id="more" class="glyphicon glyphicon-chevron-right" data-toggle="collapse" data-target="#collapse " style="width:100%;" onclick="CollapseDiv('more')">
					<b class="heding">
						Send Copy To Others In This Portal:
					</b>
				</span>
				<!--<span class="verticallyMiddle capitalFont" >
					<b class="heding">Send Copy To Others In This Portal:</b>
				</span>-->
				<div id="collapse" class="collapse">
					<xsl:if test="count($PortalUserList[PermissionTypeID = 4])">
						<div class="even-div">
							<xsl:for-each select="$PortalUserList[PermissionTypeID = 4]">
								<xsl:sort select="PermissionTypeID" order="descending" />
								<!--<xsl:if test="AuthorizedID != $LogInUser">-->
									<span class="chk_box">
										<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
										   style="margin:0 !important;" userID="{AuthorizedID}" pid="{PermissionID}"></input>
										<span>
											<xsl:value-of select="AuthorizedName"/>
										</span>
									</span>
								<!--</xsl:if>-->
							</xsl:for-each>

						</div>
					</xsl:if>
					<xsl:variable name="cls3">
						<xsl:choose>
							<xsl:when test="count($PortalUserList[PermissionTypeID =3]) &gt; 0">
								<xsl:text>odd-div</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>even-div</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<xsl:if test="count($PortalUserList[PermissionTypeID =3]) &gt; 0">
						<div class="{$cls3}">
							<xsl:for-each select="$PortalUserList[PermissionTypeID =3]">
								<xsl:sort select="PermissionTypeID" order="descending" />
								<!--<xsl:if test="AuthorizedID != $LogInUser">-->
									<span class="chk_box">
										<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
										   style="margin:0 !important;" userID="{AuthorizedID}" pid="{PermissionID}"></input>
										<span>
											<xsl:value-of select="AuthorizedName"/>
										</span>
									</span>
								<!--</xsl:if>-->
							</xsl:for-each>

						</div>
					</xsl:if>
					<xsl:variable name="cls2">
						<xsl:choose>
							<xsl:when test="count($PortalUserList[PermissionTypeID =2]) &gt; 0">
								<xsl:choose>
									<xsl:when test="$cls3 ='even-div'">
										<xsl:text>odd-div</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>even-div</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$cls3"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<xsl:if test="count($PortalUserList[PermissionTypeID =2]) &gt; 0">
						<div class="{$cls2}">
							<xsl:for-each select="$PortalUserList[PermissionTypeID =2]">
								<xsl:sort select="PermissionTypeID" order="descending" />
								<!--<xsl:if test="AuthorizedID != $LogInUser">-->
									<span class="chk_box">
										<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
										   style="margin:0 !important;" userID="{AuthorizedID}" pid="{PermissionID}"></input>
										<span>
											<xsl:value-of select="AuthorizedName"/>
										</span>
									</span>
								<!--</xsl:if>-->
							</xsl:for-each>
						</div>
					</xsl:if>
					<xsl:variable name="cls1">
						<xsl:choose>
							<xsl:when test="count($PortalUserList[PermissionTypeID =1]) &gt; 0">
								<xsl:choose>
									<xsl:when test="$cls2 ='even-div'">
										<xsl:text>odd-div</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>even-div</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$cls2"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<xsl:if test="count($PortalUserList[PermissionTypeID =1]) &gt; 0">
						<div class="{$cls1}">
							<xsl:for-each select="$PortalUserList[PermissionTypeID =1]">
								<xsl:sort select="PermissionTypeID" order="descending" />
								<!--<xsl:if test="AuthorizedID != $LogInUser">-->
									<span class="chk_box">
										<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
										   style="margin:0 !important;" userID="{AuthorizedID}" pid="{PermissionID}"></input>
										<span>
											<xsl:value-of select="AuthorizedName"/>
										</span>
									</span>
								<!--</xsl:if>-->
							</xsl:for-each>
						</div>
					</xsl:if>
					<xsl:variable name="cls0">
						<xsl:choose>
							<xsl:when test="count($PortalClientList[PermissionTypeID =0]) &gt; 0">
								<xsl:choose>
									<xsl:when test="$cls1 ='even-div'">
										<xsl:text>odd-div</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>even-div</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$cls1"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<xsl:if test="count($PortalClientList[PermissionTypeID =0]) &gt; 0">
						<div class="{$cls0}">
							<xsl:for-each select="$PortalClientList[PermissionTypeID =0]">
								<xsl:sort select="PermissionTypeID" order="descending" />
								<!--<xsl:if test="AuthorizedID != $LogInUser">-->
									<span class="chk_box">
										<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
										   style="margin:0 !important;" userID="{AuthorizedID}" pid="{PermissionID}"></input>
										<span>
											<xsl:value-of select="AuthorizedName"/>
										</span>
									</span>
								<!--</xsl:if>-->
							</xsl:for-each>
						</div>
					</xsl:if>
					<xsl:variable name="cls-1">
						<xsl:choose>
							<xsl:when test="count($PortalClientList[PermissionTypeID =-1]) &gt; 0">
								<xsl:choose>
									<xsl:when test="$cls0 ='even-div'">
										<xsl:text>odd-div</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>even-div</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$cls0"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<xsl:if test="count($PortalClientList[PermissionTypeID =-1]) &gt; 0">
						<div class="{$cls-1}">
							<xsl:for-each select="$PortalClientList[PermissionTypeID =-1]">
								<xsl:sort select="PermissionTypeID" order="descending" />
								<!--<xsl:if test="AuthorizedID != $LogInUser">-->
									<span class="chk_box">
										<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
										   style="margin:0 !important;" userID="{AuthorizedID}" pid="{PermissionID}"></input>
										<span>
											<xsl:value-of select="AuthorizedName"/>
										</span>
									</span>
								<!--</xsl:if>-->
							</xsl:for-each>
						</div>
					</xsl:if>
					<xsl:variable name="cls-2">
						<xsl:choose>
							<xsl:when test="count($PortalClientList[PermissionTypeID =-2]) &gt; 0">
								<xsl:choose>
									<xsl:when test="$cls-1 ='even-div'">
										<xsl:text>odd-div</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>even-div</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$cls-1"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<xsl:if test="count($PortalClientList[PermissionTypeID =-2]) &gt; 0">
						<div class="{$cls-2}">
							<xsl:for-each select="$PortalClientList[PermissionTypeID =-2]">
								<xsl:sort select="PermissionTypeID" order="descending" />
								<!--<xsl:if test="AuthorizedID != $LogInUser">-->
									<span class="chk_box">
										<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
										   style="margin:0 !important;" userID="{AuthorizedID}" pid="{PermissionID}"></input>
										<span>
											<xsl:value-of select="AuthorizedName"/>
										</span>
									</span>
								<!--</xsl:if>-->
							</xsl:for-each>
						</div>
					</xsl:if>
				</div>
			</div>
		</xsl:if>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
