﻿<?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="GoalItemID" select="AjaxRequest/Topics/GoalItemID"></xsl:variable>
		<xsl:variable name="Classification" select="AjaxRequest/Topics/Classification"></xsl:variable>
		<xsl:variable name="UserID" select="AjaxRequest/Topics/UserID"></xsl:variable>
		<xsl:variable name="TopicList" select="AjaxRequest/Topics/Topic"></xsl:variable>
		<xsl:variable name="LoggedInUserID" select="AjaxRequest/LoggedInUserID"/>
		<xsl:variable name="IsCoach" select="AjaxRequest/IsCoach"/>
		<xsl:variable name="SelectedUserID" select="AjaxRequest/Params/SelectedUserID"></xsl:variable>
		<xsl:variable name="ResponsibleList" select="AjaxRequest/GoalResponsible/Responsible"></xsl:variable>
		<xsl:variable name="SuccessKey" select="AjaxRequest/Params/SuccessKey"></xsl:variable>
		<xsl:variable name="TotalNotes" select="AjaxRequest/Topics/TotalNotes"></xsl:variable>
		<xsl:variable name="OnClickTask">
			<xsl:text>	LoadCoreGoalTask_3_0('</xsl:text>
			<xsl:value-of select="$GoalItemID"></xsl:value-of>
			<xsl:text>', 'div_Goal_</xsl:text>
			<xsl:value-of select="$GoalItemID"></xsl:value-of>
			<xsl:text>_Operations', 'Topic', 'asc', 1);</xsl:text>
		</xsl:variable>
		<div class="col-md-12 white-bg-new" >
			<div class="box inner light-gray">
				<div class="row-fluid padded0">
					<div class="section-title ">
						<p style="100%">
							<span style="width:60%">
								<xsl:variable name="OverViewHeading">
									<xsl:choose>
										<xsl:when test="$SuccessKey='Worksheets'">
											<xsl:text>Training</xsl:text>
										</xsl:when>
										<xsl:otherwise>
											<xsl:text>Tasks</xsl:text>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:variable>
								<xsl:choose>
									<xsl:when test="$LoggedInUserID=$SelectedUserID">
										<xsl:text>	My </xsl:text>
										<xsl:value-of select="$OverViewHeading"/>
										<xsl:text>  Overview</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select="$OverViewHeading"/>
										<xsl:text> Overview</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</span>
							<xsl:if test="$IsCoach = 1">
								<span class="pull-right TopLeftTitle">
									<span class="onMouseOver pull-right "  id="spanSelectedDashboardUser" onclick="$('#spanSelectedDashboardUser').css('display','none');$('#ddlSelectedDashboardUser').css('display','inline');">
										<xsl:choose>
											<xsl:when test="$LoggedInUserID=$SelectedUserID or not($SelectedUserID)">
												<xsl:text>Me</xsl:text>
											</xsl:when>
											<xsl:when test="$SelectedUserID=0">
												All
											</xsl:when>
											<xsl:otherwise>
												<xsl:value-of select="$ResponsibleList[ID=$SelectedUserID]/Name"/>
											</xsl:otherwise>
										</xsl:choose>
									</span>

									<select class="form-control-dashboard pull-right" style="display:none" id="ddlSelectedDashboardUser" OnChange="LoadGoalActionDashboard_3_0({$GoalItemID}, 'div_Goal_{$GoalItemID}_Operations', {$SelectedUserID});">
										<option value="0">All</option>
										<xsl:for-each select="$ResponsibleList">
											<xsl:choose>
												<xsl:when test="$SelectedUserID=ID">
													<option value="{ID}" selected="">
														<xsl:choose>
															<xsl:when test="$LoggedInUserID=ID">
																<xsl:text>Me</xsl:text>
															</xsl:when>
															<xsl:otherwise>
																<xsl:value-of select="Name"/>
															</xsl:otherwise>
														</xsl:choose>
													</option>
												</xsl:when>
												<xsl:otherwise>
													<option value="{ID}">
														<xsl:choose>
															<xsl:when test="$LoggedInUserID=ID">
																<xsl:text>Me</xsl:text>
															</xsl:when>
															<xsl:otherwise>
																<xsl:value-of select="Name"/>
															</xsl:otherwise>
														</xsl:choose>
													</option>
												</xsl:otherwise>
											</xsl:choose>
										</xsl:for-each>
									</select>
								</span>
							</xsl:if>
						</p>
					</div>
					<xsl:choose>
						<xsl:when test="$SuccessKey='Worksheets'">
							<xsl:variable name="ModulebgcolorClass">
								<xsl:choose>
									<xsl:when test="$TopicList/Modules/Status='PastDue'">
										<xsl:text>medium-yellow</xsl:text>
									</xsl:when>
									<xsl:when test="$TopicList/Modules/Status='None'">
										<xsl:text>medium-blue</xsl:text>
									</xsl:when>
									<xsl:when test="$TopicList/Modules/Status='Done'">
										<xsl:text>medium-green</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>medium-blue</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>
							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="{$OnClickTask}">
								<div class="stat-box {$ModulebgcolorClass}">

									<span class="count">
										<i class="glyphicon glyphicon-list-alt"></i>
										<span class="dec_font">
											<xsl:value-of select="sum($TopicList/Modules/WS)"/> of <xsl:value-of select="sum($TopicList/Modules/TotalWS)"/>
										</span>
									</span>
									<span class="stat-text">
										Worksheets Completed
									</span>
								</div>
							</div>
							<xsl:variable name="WaitingbgcolorClass">
								<xsl:choose>
									<xsl:when test="$TopicList/Waiting/Status='PastDue'">
										medium-yellow
									</xsl:when>
									<!--<xsl:when test="$TopicList/Waiting/Status='Done'">
										medium-green
									</xsl:when>-->
									<xsl:otherwise>
										medium-blue
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>
							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="{$OnClickTask}">
								<div class="stat-box {$WaitingbgcolorClass}">
									<span class="count">
										<i class="glyphicon glyphicon-list-alt"></i>

										<span class="dec_font">
											<xsl:value-of select="sum($TopicList/Waiting/WS)"/> <!-- of <xsl:value-of select="sum($TopicList/Waiting/TotalWS)"/> -->
										</span>
									</span>
									<span class="stat-text">Waiting for Review</span>
								</div>
							</div>

							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="{$OnClickTask}">
								<div class="stat-box medium-blue">

									<span class="count">
										<i class="glyphicon glyphicon-check"></i>

										<span class="dec_font">
											<xsl:value-of select="sum($TopicList/Actions/Action)"/>
											<xsl:if test="sum($TopicList/Actions/TotalActions) &gt; 0">
												of <xsl:value-of select="sum($TopicList/Actions/TotalActions)"/>
											</xsl:if>
										</span>
									</span>
									<span class="stat-text">Tasks<xsl:if test="sum($TopicList/Actions/TotalActions) &gt; 0"> Completed</xsl:if>
								</span>
								</div>
							</div>

							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="removeWorksheetCss();SetTitleOfGoal_3_0('span_{$GoalItemID}_GoalTitle','Notes',0);goal_LoadNotebook('div_Goal_{$GoalItemID}_Operations',{$GoalItemID});document.getElementById('slidepanel').style.display='none';">
								<div class="stat-box text-blue">

									<span class="count">
										<i class="glyphicon glyphicon-comment"></i>
										<span class="dec_font">
											<xsl:value-of select="$TotalNotes"/>
										</span>
									</span>
									<span class="stat-text">Notes</span>
								</div>
							</div>

							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="">
								<div class="stat-box dark-blue">
									<span class="count">
										<i class="glyphicon glyphicon-folder-open"></i>
										<span class="dec_font">
											<xsl:value-of select="sum($TopicList/TotalResources)"/>
										</span>
									</span>
									<span class="stat-text">Resources</span>
								</div>
							</div>
						</xsl:when>
						<xsl:otherwise>
							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="{$OnClickTask}">
								<div class="stat-box medium-blue">

									<span class="count">
										<i class="glyphicon glyphicon-list-alt"></i>
										<span class="dec_font">
											<xsl:call-template name="DoubleWord">
												<xsl:with-param name="words" select="sum($TopicList/Total)"></xsl:with-param>
											</xsl:call-template>
										</span>
									</span>
									<span class="stat-text">
										<xsl:choose>
											<xsl:when test="$SuccessKey='Worksheets'">
												<xsl:text>Modules</xsl:text>
											</xsl:when>
											<xsl:otherwise>
												<xsl:text>Tasks</xsl:text>
											</xsl:otherwise>
										</xsl:choose>
									</span>
								</div>
							</div>

							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="{$OnClickTask}">
								<xsl:variable name="CompletedBgColor">
									<xsl:choose>
										<xsl:when test="sum($TopicList/Completed) &gt;0">
											border-blue
										</xsl:when>
										<xsl:otherwise>
											medium-blue
										</xsl:otherwise>
									</xsl:choose>
								</xsl:variable>
								<div class="stat-box {$CompletedBgColor}">
									<span class="count">
										<i class="glyphicon glyphicon-list-alt"></i>
										<i class="glyphicon glyphicon-ok-sign second_icon"></i>
										<span class="dec_font">
											<xsl:call-template name="DoubleWord">
												<xsl:with-param name="words" select="sum($TopicList/Completed)"></xsl:with-param>
											</xsl:call-template>
										</span>
									</span>
									<span class="stat-text">Completed</span>
								</div>
							</div>
							<xsl:variable name="PastDueBgColor">
								<xsl:choose>
									<xsl:when test="sum($TopicList/PastDue) &gt;0">
										medium-yellow
									</xsl:when>
									<xsl:otherwise>
										medium-blue
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>
							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="{$OnClickTask}">
								<div class="stat-box {$PastDueBgColor}">

									<span class="count">
										<i class="glyphicon glyphicon-calendar"></i>
										<i class="glyphicon glyphicon-exclamation-sign second_icon"></i>
										<span class="dec_font">
											<xsl:call-template name="DoubleWord">
												<xsl:with-param name="words" select="sum($TopicList/PastDue)"></xsl:with-param>
											</xsl:call-template>
										</span>
									</span>
									<span class="stat-text">Past Due</span>
								</div>
							</div>
							<xsl:variable name="ThisWeekPastDueBgColor">
								<xsl:choose>
									<xsl:when test="sum($TopicList/ThisWeek) &gt;0">
										medium-green
									</xsl:when>
									<xsl:otherwise>
										medium-blue
									</xsl:otherwise>
								</xsl:choose>
							</xsl:variable>

							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="{$OnClickTask}">

								<div class="stat-box {$ThisWeekPastDueBgColor}">

									<span class="count">
										<i class="glyphicon glyphicon-calendar"></i>
										<span class="dec_font">
											<xsl:call-template name="DoubleWord">
												<xsl:with-param name="words" select="sum($TopicList/ThisWeek)"></xsl:with-param>
											</xsl:call-template>
										</span>
									</span>
									<span class="stat-text">This Week</span>
								</div>
							</div>

							<div class="col-md-2 col-xs-12 center onMouseOver" onclick="{$OnClickTask}">
								<div class="stat-box dark-blue">
									<span class="count">
										<i class="glyphicon glyphicon-time"></i>
										<span class="dec_font">
											<xsl:call-template name="DoubleWord">
												<xsl:with-param name="words" select="sum($TopicList/Future)"></xsl:with-param>
											</xsl:call-template>
										</span>
									</span>
									<span class="stat-text">Future</span>
								</div>
							</div>
						</xsl:otherwise>
					</xsl:choose>

				</div>
			</div>

		</div>

		<xsl:if test="$SuccessKey != 'Worksheets'">
			<div class="col-md-12 pading0 Borderd alter-color">
				<div class="tab_grid Taskwid padded10" id="divIsLandTopic" style="background:#fff">
					<!-- section-heading-->
					<div class="section-title">
						<p> Current Progress </p>
					</div>
					<!-- same code-->
					<xsl:for-each select="$TopicList">
						<div class="full_column ExpandRow " >
							<div class="left_column PadingLft" style="width:100%;padding:2px;cursor:pointer !important" onclick="LoadCoreGoalTask_3_0('{$GoalItemID}', 'div_Goal_{$GoalItemID}_Operations', '', '', 1,'{ItemID}')">
								<div class="MiDiv ExpandRow " style="cursor:pointer !important;line-height:40px!important;width:78%">
									<xsl:value-of select="Item"/>
								</div>
								<div class="right_column RightDiv Progres">
									<xsl:variable name="BarColor">
										<xsl:choose>
											<xsl:when test="round(CompletionPercentage)=100">
												<xsl:text>progress-bar-success</xsl:text>
											</xsl:when>
											<xsl:otherwise>
												progress-bar-info
											</xsl:otherwise>
										</xsl:choose>
									</xsl:variable>
									<div class="progress Mrgin">
										<div class="progress-bar {$BarColor}" role="progressbar"  style="width:{CompletionPercentage}%">
											<span class="">
												<xsl:value-of select="round(CompletionPercentage)"></xsl:value-of>%
											</span>
										</div>
									</div>
								</div>
							</div>
						</div>
					</xsl:for-each>

				</div>

			</div>
		</xsl:if>


	</xsl:template>
	<xsl:template name="DoubleWord">
		<xsl:param name="words" select="'N/A'"></xsl:param>
		<!--<xsl:value-of select="$words"/>-->
		<xsl:choose>
			<xsl:when test="$words &lt;10">
				0<xsl:value-of select="$words"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$words"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
