﻿<?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:import href="../../GenericTemplates/DisplayNotes.xslt"/>

	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/">
		<xsl:variable name="PortalItemID" select="AjaxRequest/Params/PortalItemID"></xsl:variable>
		<xsl:variable name="GoalItemID" select="AjaxRequest/Params/GoalItemID"></xsl:variable>
		<xsl:variable name="UserID" select="AjaxRequest/Params/UserID"></xsl:variable>
		<xsl:variable name="LoggedInUserID" select="AjaxRequest/LoggedInUserID"></xsl:variable>
		<xsl:variable name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:variable>
		<xsl:variable name="DivID" select="AjaxRequest/Params/DivID"></xsl:variable>
		<xsl:variable name="ShareITList" select="AjaxRequest/ShareITRecords/ShareIT"></xsl:variable>
		<xsl:variable name="PortalUserList" select="AjaxRequest/PortalUserDetail/Local/Permission"></xsl:variable>
		<xsl:variable name="PortalClientList" select="AjaxRequest/PortalClientDetail/Local/Permission"></xsl:variable>
		<xsl:variable name="Classification" select="AjaxRequest/Classification"></xsl:variable>
		<xsl:variable name="NoteAutoNotify">
			<xsl:choose>
				<xsl:when test="AjaxRequest/Settings/NoteAutoNotify[text()]">
					<xsl:value-of select="AjaxRequest/Settings/NoteAutoNotify"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:number value="0"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="PermissionID" select="AjaxRequest/Permissions/ItemPermission/PermissionID"></xsl:variable>
		<xsl:call-template name="NoteMemoAtGoalLvel">
			<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
			<xsl:with-param name="GoalItemID" select="$GoalItemID"></xsl:with-param>
			<xsl:with-param name="UserID" select="$UserID"></xsl:with-param>
			<xsl:with-param name="LoggedInUserID" select="$LoggedInUserID"></xsl:with-param>
			<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
			<xsl:with-param name="DivID" select="$DivID"></xsl:with-param>
			<xsl:with-param name="ShareITList" select="$ShareITList"></xsl:with-param>
			<xsl:with-param name="PortalUserList" select="$PortalUserList"></xsl:with-param>
			<xsl:with-param name="PortalClientList" select="$PortalClientList"></xsl:with-param>
			<xsl:with-param name="Classification" select="$Classification"></xsl:with-param>
			<xsl:with-param name="NoteAutoNotify" select="$NoteAutoNotify"></xsl:with-param>
			<xsl:with-param name="PermissionID" select="$PermissionID"></xsl:with-param>
		</xsl:call-template>
	</xsl:template>
	<xsl:template name="NoteMemoAtGoalLvel">
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="GoalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="UserID" select="'N/A'"></xsl:param>
		<xsl:param name="LoggedInUserID" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="DivID" select="'N/A'"></xsl:param>
		<xsl:param name="ShareITList" 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="Classification" select="'N/A'"></xsl:param>
		<xsl:param name="NoteAutoNotify" select="'N/A'"></xsl:param>
		<xsl:param name="PermissionID" select="'N/A'"></xsl:param>
		<xsl:variable name="Div">
			<xsl:choose>
				<xsl:when test="$DivID !=''">
					<xsl:value-of select="$DivID"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>div_Goal_</xsl:text>
					<xsl:value-of select="$GoalItemID"/>
					<xsl:text>_Operations</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="displayNotesclass">
			<xsl:choose>
				<xsl:when test="$NoteAutoNotify =1">
					display:none;>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<div class="marginTop5">
			<textarea id="txt_AddNoteOnMyProgress_{$GoalItemID}" rows ="4" cols ="93" style="padding:4px;width:100%"
					  defaultText="Add a note here"
				   onFocus='SetTextAreaValue("txt_AddNoteOnMyProgress_{$GoalItemID}", "Add a note here", "focus");document.getElementById("div_{$GoalItemID}_ShareWithTeam").style.display="block";  if((document.getElementById("div_{$GoalItemID}_UploadSuite_AddButton") != null) &amp;&amp; (document.getElementById("NoteFileUpload_{$GoalItemID}_Panel").style.display=="none"))
					  document.getElementById("div_{$GoalItemID}_UploadSuite_AddButton").style.display="block";'
				   onBlur='SetTextAreaValue("txt_AddNoteOnMyProgress_{$GoalItemID}", "Add a note here", "blur");' >
				<xsl:text>Add a note here</xsl:text>
			</textarea>
		</div>
		<xsl:variable name="onclick">
			<xsl:choose>
				<xsl:when test="$DivID !=''">

				</xsl:when>
				<xsl:otherwise>
					<xsl:text>setTimeout('LoadPortalUserNotes(\'Employee_Operations_Filters\',</xsl:text>
					<xsl:value-of select="$PortalItemID"></xsl:value-of>
					<xsl:text>,</xsl:text>
					<xsl:value-of select="$UserID"></xsl:value-of>
					<xsl:text>, 1, \'Header\');', 100);</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<div class='col-md-12 col-xs-12 padingL0' id='newAttachment'>
			<div style="text-align: left;float: left;" class="col-md-9 col-xs-9 padingL0">
				<xsl:call-template name="SurveyQuestionFileUpload">
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="SourceItemID" select="$GoalItemID"></xsl:with-param>
				</xsl:call-template>
			</div>
			<div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray adbtn col-md-3 col-xs-3 padingL0 postbtn"
							   
								   onclick="goal_AddQuickNote3_0('txt_AddNoteOnMyProgress_{$GoalItemID}',{$GoalItemID},'{$Div}','chk_{$GoalItemID}_ShareWithTeam');{$onclick}">
				<span class="glyphicon glyphicon-plus"></span>
				<span >POST </span>
			</div>
		</div>

		<div style='width: 100%;'>
			<div id='div_{$GoalItemID}_ShareWithTeam' style='width: 75%;float: left;text-align:left;margin-top:5px;'>
				<div style="width:75%;float:left">

					<xsl:choose>
						<xsl:when test="$NoteAutoNotify = 1">
							<input type="checkbox"   class="verticallyMiddle"  id="chk_{$GoalItemID}_ShareWithTeam" style="margin:0 !important;"  checked="checked"
							onclick="displayNotesNotifyDiv('chk_{$GoalItemID}_ShareWithTeam','div_{$GoalItemID}_NotifyMyClientPortal','div_{$GoalItemID}_NotifyAllCoachingProgram');"></input>
						</xsl:when>
						<xsl:otherwise>
							<input type="checkbox"   class="verticallyMiddle"  id="chk_{$GoalItemID}_ShareWithTeam" style="margin:0 !important;"
							onclick="displayNotesNotifyDiv('chk_{$GoalItemID}_ShareWithTeam','div_{$GoalItemID}_NotifyMyClientPortal','div_{$GoalItemID}_NotifyAllCoachingProgram');"></input>
						</xsl:otherwise>
					</xsl:choose>
					<span class="verticallyMiddle capitalFont">
						Notify Additional Members:
					</span>
				</div>
			</div>






			<div style="height: auto;float: left;margin-bottom: 5px;width:100%;">
				<xsl:if test="count($ShareITList) &gt; 0">
					<div style="width:100%;float:left;{$displayNotesclass};" id="div_{$GoalItemID}_NotifyAllCoachingProgram">
						<xsl:if test="count($ShareITList[Coach =1 ])&gt;0 and count($ShareITList[(ID != $LoggedInUserID)  or  (Coach !=1 and Participant=1)])&gt;0">
							<!-- Greg
							<span class="verticallyMiddle capitalFont" >
								<b class="heding">Notify All in My <xsl:value-of select="$Classification"></xsl:value-of> 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 != $LoggedInUserID">
											<span class="chk_box">
												<input name="nmUsers" type="checkbox" class="verticallyMiddle"
												   style="margin:0 !important;" userID="{ID}"></input>
												<span>
													<xsl:value-of select="Name"/>
												</span>
											</span>
										</xsl:if>

									</xsl:for-each>
								</div>
							</xsl:if>
						</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 != $LoggedInUserID">
										<span class="chk_box">
											<input name="nmUsers" type="checkbox" class="verticallyMiddle"
											   style="margin:0 !important;" userID="{ID}"></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 != $LoggedInUserID">
										<span class="chk_box">
											<input name="nmUsers" type="checkbox" class="verticallyMiddle"
											   style="margin:0 !important;" userID="{ID}"></input>
											<span>
												<xsl:value-of select="Name"/>
											</span>
										</span>
									</xsl:if>
								</xsl:for-each>
							</div>
						</xsl:if>
					</div>
				</xsl:if>
				<xsl:if test="$PermissionID &gt;1">
					<xsl:if test="(count($PortalUserList) &gt; 0 or count($PortalClientList) &gt; 0) and count($PortalUserList[PermissionTypeID = 4 and PermissionActiveYN = 1])&gt; 0 and count($PortalUserList[AuthorizedID != $LoggedInUserID])&gt;0">
						<div style="width:100%;float:left;{$displayNotesclass};" id="div_{$GoalItemID}_NotifyMyClientPortal">
							<span id="moreClient" class="glyphicon glyphicon-chevron-right" data-toggle="collapse" data-target="#collapseUser " style="width:100%;" onclick="CollapseDiv('moreClient')">
								<b class="heding">Send Copy To Others In This Portal:</b>
							</span>
							<div id="collapseUser" class="collapse">
								<xsl:if test="count($PortalUserList[PermissionTypeID = 4 and PermissionActiveYN = 1])&gt; 0 and count($PortalUserList[AuthorizedID != $LoggedInUserID])&gt;0">
									<div class="even-div">
										<xsl:for-each select="$PortalUserList[PermissionTypeID = 4 and PermissionActiveYN = 1]">
											<xsl:sort select="PermissionTypeID" order="descending" />
											<xsl:if test="AuthorizedID != $LoggedInUserID">
												<span class="chk_box">
													<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
													   style="margin:0 !important;" userID="{AuthorizedID}"></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 and PermissionActiveYN = 1]) &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 and PermissionActiveYN = 1]) &gt; 0">
									<div class="{$cls3}">
										<xsl:for-each select="$PortalUserList[PermissionTypeID =3 and PermissionActiveYN = 1]">
											<xsl:sort select="PermissionTypeID" order="descending" />
											<xsl:if test="AuthorizedID != $LoggedInUserID">
												<span class="chk_box">
													<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
													   style="margin:0 !important;" userID="{AuthorizedID}"></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 and PermissionActiveYN = 1]) &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 and PermissionActiveYN = 1]) &gt; 0">
									<div class="{$cls2}">
										<xsl:for-each select="$PortalUserList[PermissionTypeID =2 and PermissionActiveYN = 1]">
											<xsl:sort select="PermissionTypeID" order="descending" />
											<xsl:if test="AuthorizedID != $LoggedInUserID">
												<span class="chk_box">
													<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
													   style="margin:0 !important;" userID="{AuthorizedID}"></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 and PermissionActiveYN = 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 and PermissionActiveYN = 1]) &gt; 0">
									<div class="{$cls1}">
										<xsl:for-each select="$PortalUserList[PermissionTypeID =1 and PermissionActiveYN = 1]">
											<xsl:sort select="PermissionTypeID" order="descending" />
											<xsl:if test="AuthorizedID != $LoggedInUserID">
												<span class="chk_box">
													<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
													   style="margin:0 !important;" userID="{AuthorizedID}"></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 != $LoggedInUserID">
												<span class="chk_box">
													<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
													   style="margin:0 !important;" userID="{AuthorizedID}"></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 != $LoggedInUserID">
												<span class="chk_box">
													<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
													   style="margin:0 !important;" userID="{AuthorizedID}"></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 != $LoggedInUserID">
												<span class="chk_box">
													<input name="nmUsers" type="checkbox"  class="verticallyMiddle"
													   style="margin:0 !important;" userID="{AuthorizedID}"></input>
													<span>
														<xsl:value-of select="AuthorizedName"/>
													</span>
												</span>
											</xsl:if>
										</xsl:for-each>
									</div>
								</xsl:if>
							</div>
						</div>
					</xsl:if>
				</xsl:if>
			</div>



		</div>

	</xsl:template>
</xsl:stylesheet>
