﻿<?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 match="/">
		<xsl:variable name="ItemID" select="AjaxRequest/Params/ItemID"></xsl:variable>
		<xsl:variable name="UserID" select="AjaxRequest/Notifications/UserID"></xsl:variable>
		<xsl:variable name="NotificationList" select="AjaxRequest/Notifications/Notification"></xsl:variable>
		<xsl:variable name ="TemplateURL" select="AjaxRequest/TemplateURL"/>
		<xsl:variable name ="PageNumber" select="AjaxRequest/Params/PageNumber"/>
		<xsl:variable name ="TotalRec" select="$NotificationList/TotalRec"/>
		<xsl:variable name="CallType" select="AjaxRequest/Params/CallType"></xsl:variable>
		<xsl:variable name="DivID" select="AjaxRequest/Params/DivID"></xsl:variable>
		<input type="hidden" class="hfdRecentActivityTotalRecord" value="{$TotalRec}"></input>
		<xsl:for-each select="$NotificationList">
			<xsl:variable name="SlideBarClick">
				<xsl:choose>
					<xsl:when test="TypeID=9 or TypeID=14 or ParentTypeID=16">
						<xsl:text>	viewItemDetailVersion3('</xsl:text>
						<xsl:value-of select="ItemID"></xsl:value-of>
						<xsl:text>', '</xsl:text>
						<xsl:value-of select="$ItemID"></xsl:value-of>
						<xsl:text>', 'div_item_</xsl:text>
						<xsl:value-of select="ItemID"></xsl:value-of>
						<xsl:text>_detail_container', 'div_item_</xsl:text>
						<xsl:value-of select="ItemID"></xsl:value-of>
						<xsl:text>','2.0', 'view');</xsl:text>
					</xsl:when>
					<xsl:when test="ParentTypeID=9 or ParentTypeID=14 or TypeID=16">
						<xsl:text>	viewItemDetailVersion3('</xsl:text>
						<xsl:value-of select="ParentItemID"></xsl:value-of>
						<xsl:text>', '</xsl:text>
						<xsl:value-of select="$ItemID"></xsl:value-of>
						<xsl:text>', 'div_item_</xsl:text>
						<xsl:value-of select="ParentItemID"></xsl:value-of>
						<xsl:text>_detail_container', 'div_item_</xsl:text>
						<xsl:value-of select="ParentItemID"></xsl:value-of>
						<xsl:text>','2.0', 'view');</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text></xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<xsl:variable name="onMouseOver">
				<xsl:choose>
					<xsl:when test="$DivID =''">
						<xsl:text>$('#</xsl:text>
						<xsl:value-of  select="$DivID"></xsl:value-of>
						<xsl:text> #spanDelteNotification_</xsl:text>
						<xsl:value-of  select="NotificationID"></xsl:value-of>
						<xsl:text>').css('visibility','visible')</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>$('#spanDelteNotification_</xsl:text>
						<xsl:value-of  select="NotificationID"></xsl:value-of>
						<xsl:text>').css('visibility','visible')</xsl:text>
						</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<xsl:variable name="onMouseOut">
				<xsl:choose>
					<xsl:when test="$DivID !=''">
						<xsl:text>$('#</xsl:text>
						<xsl:value-of  select="$DivID"></xsl:value-of>
						<xsl:text> #spanDelteNotification_</xsl:text>
						<xsl:value-of  select="NotificationID"></xsl:value-of>
						<xsl:text>').css('visibility','hidden')</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>$('#spanDelteNotification_</xsl:text>
						<xsl:value-of  select="NotificationID"></xsl:value-of>
						<xsl:text>').css('visibility','hidden')</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<div RowID="{RowID}" class="RecentActivityClassForScroll divNotification_{NotificationID}"  onmouseover="{$onMouseOver}"
             onmouseout="{$onMouseOut}">
				<span class="col-md-2 col-sm-2 col-xs-2 width_span onMouseOver" onclick="{$SlideBarClick}">
					<xsl:choose>
						<xsl:when test="ActorImage">
							<img src="{ActorImage}"></img>
						</xsl:when>
						<xsl:otherwise>
							<img src="{$TemplateURL}Web/Images/Ver_2_0/DefaultUserPic.jpg"></img>
						</xsl:otherwise>
					</xsl:choose>

				</span>
				<span class="col-md-9 col-sm-8 col-xs-8 block-with-text col-sm-10 onMouseOver" onclick="{$SlideBarClick}">
					<span class="whitespace2">
						<b>
							<xsl:value-of select="FirstName"/>
						</b>
						<!--Notification part start here -->
						<span class="fonts13">
							<xsl:call-template name="NotificationDetails">
								<xsl:with-param name="NotificationTypeID" select="NotificationTypeID"></xsl:with-param>
							</xsl:call-template>
						</span>
						<!--Notification part end here -->
						<xsl:call-template name="TimeStamp">
							<xsl:with-param name="CreatedMinuteAgo" select="CreatedMinuteAgo"></xsl:with-param>
						</xsl:call-template>
					</span>
					<p>
						<xsl:choose>
							<xsl:when test="TypeID=9 or TypeID=14 or ParentTypeID=16">
								<span class="" style="color:#337ab7">
									<b  class="whitespace2">
										<xsl:value-of select="Item"/>
									</b>
								</span>
							</xsl:when>
							<xsl:when test="ParentTypeID=9 or ParentTypeID=14 or TypeID=16">
								<span class="" style="color:#337ab7">
									<b class="whitespace2">
										<xsl:value-of select="ParentItem"/>
									</b>
								</span>
							</xsl:when>
							<xsl:otherwise>
								<b class="whitespace2">
									<xsl:value-of select="Item"/>
								</b>
							</xsl:otherwise>
						</xsl:choose>
					</p>
				</span>
				<span class="col-md-1 col-sm-1 col-xs-1 pull-right" style="  margin-top: 10px;">
					<img id="spanDelteNotification_{NotificationID}" style="visibility:hidden;width:15px;height:15px" title="Delete Activity"
						 class="onMouseOver"
						 onclick="DeleteGoalUserNotifications({$ItemID}, {NotificationID}, 'divGoalUserNotification', {$UserID},'{$CallType}',event)"
						 src="{$TemplateURL}Web/Images/Ver_2_0/BT_x.png"></img>
				</span>
			</div>

		</xsl:for-each>

	</xsl:template>
	<xsl:template name="NotificationDetails">
		<xsl:param name="NotificationTypeID" select="'N/A'"></xsl:param>
		<xsl:if test="$NotificationTypeID=1">
			created a goal
		</xsl:if>
		<xsl:if test="$NotificationTypeID=2">
			changed a goal
		</xsl:if>
		<xsl:if test="$NotificationTypeID=3">
			completed a goal
		</xsl:if>
		<xsl:if test="$NotificationTypeID=4">
			added a action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=5">
			changed a action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=6">
			completed a action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=7">
			added a note
		</xsl:if>
		<xsl:if test="$NotificationTypeID=8">
			changed a note
		</xsl:if>
		<xsl:if test="$NotificationTypeID=9">
			deleted a note
		</xsl:if>
		<xsl:if test="$NotificationTypeID=10">
			replied on a note
		</xsl:if>
		<xsl:if test="$NotificationTypeID=11">
			deleted a action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=12">
			added on ShareIt
		</xsl:if>
		<xsl:if test="$NotificationTypeID=13">
			updated a rights
		</xsl:if>
		<xsl:if test="$NotificationTypeID=16">
			assigned a action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=41">
			email for actions
		</xsl:if>
		<xsl:if test="$NotificationTypeID=47">
			added a new notebook entry
		</xsl:if>
		<xsl:if test="$NotificationTypeID=48">
			join the challenge
		</xsl:if>
		<xsl:if test="$NotificationTypeID=50">
			submitted the survey
		</xsl:if>
		<xsl:if test="$NotificationTypeID=51">
			returned a survey after review
		</xsl:if>
		<xsl:if test="$NotificationTypeID=52">
			reviewed the survey
		</xsl:if>
	</xsl:template>
	<xsl:template name ="TimeStamp">
		<xsl:param name="CreatedMinuteAgo" select="'N/A'"></xsl:param>
		<i>
			<font color="#17375E">
				<xsl:if test ="$CreatedMinuteAgo &lt; 1">
					<xsl:value-of select="round($CreatedMinuteAgo * 60)"/> second(s) ago
				</xsl:if>
				<xsl:if test ="$CreatedMinuteAgo &gt;= 1 and $CreatedMinuteAgo &lt; 60">
					<xsl:value-of select="round($CreatedMinuteAgo)"/> minute(s) ago
				</xsl:if>
				<xsl:if test ="$CreatedMinuteAgo &gt;= 60 and $CreatedMinuteAgo &lt; 1440 ">
					<xsl:value-of select="round($CreatedMinuteAgo div 60)"/> hour(s) ago
				</xsl:if>
				<xsl:if test ="$CreatedMinuteAgo &gt; 1440 ">
					<xsl:value-of select="round($CreatedMinuteAgo div 1440)"/> day(s) ago
				</xsl:if>
			</font>
		</i>
	</xsl:template>
</xsl:stylesheet>
