﻿<?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="PortalID" select="AjaxRequest/Params/PortalID"></xsl:variable>
		<xsl:variable name="NotificationList" select="AjaxRequest/Activities/Activity"></xsl:variable>
		<xsl:variable name ="TemplateURL" select="AjaxRequest/TemplateURL"/>
		<xsl:variable name="UserID" select="AjaxRequest/LoggedInUserID"></xsl:variable>
		<div class="container" style="max-height:550px;overflow-y:auto;">
			<div class="headingoutr">
				<h2>Your Notifications</h2>
			</div>
			<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="$PortalID"></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="$PortalID"></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>
				<div   onmouseover="document.getElementById('spanDelteNotification_{ActivityID}').style.visibility='visible';"
				 onmouseout="document.getElementById('spanDelteNotification_{ActivityID}').style.visibility='hidden';" class="col-md-12 hovr">
					<span class="col-md-1 col-sm-1 col-xs-1  onMouseOver" onclick="{$SlideBarClick}">
						<xsl:choose>
							<xsl:when test="ActorImage">
								<img src="{ActorImage}" class="notimg"></img>
							</xsl:when>
							<xsl:otherwise>
								<img src="{$TemplateURL}Web/Images/Ver_2_0/DefaultUserPic.jpg" class="notimg"></img>
							</xsl:otherwise>
						</xsl:choose>

					</span>
					<span class="col-md-11 col-sm-11 col-xs-11 font13   onMouseOver" onclick="{$SlideBarClick}">
						<b>
							<xsl:value-of select="FirstName"/>
						</b>
						<!--Notification part start here -->
						<xsl:call-template name="NotificationDetails">
							<xsl:with-param name="NotificationTypeID" select="NotificationTypeID"></xsl:with-param>
						</xsl:call-template>
						<!--Notification part end here -->
						<xsl:call-template name="TimeStamp">
							<xsl:with-param name="CreatedMinuteAgo" select="CreatedMinuteAgo"></xsl:with-param>
						</xsl:call-template>

						<xsl:choose>
							<xsl:when test="TypeID=9 or TypeID=14 or ParentTypeID=16">
								<span class="" style="color:#337ab7">
									<b>
										<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>
										<xsl:value-of select="ParentItem"/>
									</b>
								</span>
							</xsl:when>
							<xsl:otherwise>
								<b>
									<xsl:value-of select="Item"/>
								</b>
							</xsl:otherwise>
						</xsl:choose>

					</span>
					<span class="col-md-1 col-sm-1 col-xs-1 pull-right" style="  margin-top: -6px;">
						<img id="spanDelteNotification_{ActivityID}" style="visibility:hidden;width:15px;height:15px" title="Delete Activity"
							 class="onMouseOver"
							 onclick="DeleteGoalUserNotifications({$PortalID}, {ActivityID}, 'divGoalUserNotification', {$UserID})"
							 src="{$TemplateURL}Web/Images/Ver_2_0/BT_x.png"></img>
					</span>
				</div>

			</xsl:for-each>
		</div>
	</xsl:template>
	<xsl:template name="NotificationDetails">
		<xsl:param name="NotificationTypeID" select="'N/A'"></xsl:param>
		<xsl:if test="$NotificationTypeID=1">
			created goal
		</xsl:if>
		<xsl:if test="$NotificationTypeID=2">
			changed goal
		</xsl:if>
		<xsl:if test="$NotificationTypeID=3">
			completed goal
		</xsl:if>
		<xsl:if test="$NotificationTypeID=4">
			added action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=5">
			changed action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=6">
			completed action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=7">
			added note
		</xsl:if>
		<xsl:if test="$NotificationTypeID=8">
			changed note
		</xsl:if>
		<xsl:if test="$NotificationTypeID=9">
			deleted note
		</xsl:if>
		<xsl:if test="$NotificationTypeID=10">
			replied on a note
		</xsl:if>
		<xsl:if test="$NotificationTypeID=11">
			deleted action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=12">
			added on ShareIt
		</xsl:if>
		<xsl:if test="$NotificationTypeID=13">
			updated rights
		</xsl:if>
		<xsl:if test="$NotificationTypeID=16">
			assigned action
		</xsl:if>
		<xsl:if test="$NotificationTypeID=41">
			email for actions
		</xsl:if>
		<xsl:if test="$NotificationTypeID=47">
			added 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 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>
