﻿<?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/FirstLastWord.xslt"/>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="MasterPortalItemID" select="AjaxRequest/Params/MasterPortalItemID"></xsl:variable>
		<!--<xsl:variable name="PortalItemID" select="AjaxRequest/Params/PortalItemID"></xsl:variable>-->
		<xsl:variable name="ManagerID" select="AjaxRequest/Params/ManagerID"></xsl:variable>
		<xsl:variable name="Classification" select="AjaxRequest/Params/Classification"></xsl:variable>
		<xsl:variable name="DivID" select="AjaxRequest/Params/DivID"></xsl:variable>
		<xsl:variable name="ReportList" select="AjaxRequest/Report"></xsl:variable>
		<xsl:variable name="ReportHeadingList" select="AjaxRequest/Report/Columns/Col"></xsl:variable>
		<xsl:variable name="OrderBy" select="AjaxRequest/Params/OrderBy"></xsl:variable>
		<xsl:variable name="Order" select="AjaxRequest/Params/Order"></xsl:variable>
		<xsl:variable name="PageNumber" select="AjaxRequest/Params/PageNumber"></xsl:variable>
		<xsl:variable name="PageSize" select="AjaxRequest/PageSize"></xsl:variable>
		<xsl:variable name="TotalPages" select="AjaxRequest/Report/Record/TotalPages"></xsl:variable>
		<!--<xsl:variable name="PortalID" select="AjaxRequest/Params/PortalItemID"></xsl:variable>-->
		<xsl:variable name="PortalItemID">
			<xsl:choose>
				<xsl:when test="AjaxRequest/Params/PortalItemID =''">
					<xsl:number value="-99"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="AjaxRequest/Params/PortalItemID"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="PortalID">
			<xsl:choose>
				<xsl:when test="AjaxRequest/Params/PortalItemID =''">
					<xsl:value-of select="AjaxRequest/Params/MasterPortalItemID"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="AjaxRequest/Params/PortalItemID"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="AllUser">
			<xsl:choose>
				<xsl:when test="AjaxRequest/Params/AllUser != ''">
					<xsl:value-of select="AjaxRequest/Params/AllUser"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>null</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="UserName" select="AjaxRequest/Params/UserName"></xsl:variable>
		<xsl:variable name="TotalRec" select="$ReportList/Record/TotalRec"></xsl:variable>


		<table class="table table-striped table-responsive table-fixed VerMid tdtrcenter" id="tblManagerProgram">
			<tr>
				<xsl:for-each select="$ReportHeadingList[Visibility=1]">
					<xsl:variable name="SortOrderTeamMember">
						<xsl:choose>
							<xsl:when test="$OrderBy=ColName and  $Order ='asc'">
								<xsl:text>desc</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>asc</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<xsl:choose>
						<xsl:when test="ColName = 'Image'">
							<th>
								<xsl:value-of select="ColDisplayName"/>
							</th>
						</xsl:when>
						<xsl:when test="ColName='StatusFirst'">
							<th  class="onMouseOver"
								onclick="loadManagerProgramsReport('{$DivID}',{$ManagerID},{$MasterPortalItemID},{$PortalItemID},'{$Classification}',{$AllUser},'{$UserName}', '{ColName}', '{$SortOrderTeamMember}',1);">
								<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" style="font-size:20px;color: #bbbbbb;"></span>
							</th>
						</xsl:when>
						<xsl:when test="ColName='Name'">
							<th style="text-align:left!important;"  class="onMouseOver"
								onclick="loadManagerProgramsReport('{$DivID}',{$ManagerID},{$MasterPortalItemID},{$PortalItemID},'{$Classification}',{$AllUser},'{$UserName}', '{ColName}', '{$SortOrderTeamMember}',1);">
								<xsl:value-of select="ColDisplayName"/>
							</th>
						</xsl:when>
						<xsl:otherwise>
							<th class="onMouseOver"
								onclick="loadManagerProgramsReport('{$DivID}',{$ManagerID},{$MasterPortalItemID},{$PortalItemID},'{$Classification}',{$AllUser},'{$UserName}', '{ColName}', '{$SortOrderTeamMember}',1);">
								<xsl:value-of select="ColDisplayName"/>
							</th>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:for-each>
			</tr>

			<xsl:if test="count($ReportList/Record) &gt;0">
				<xsl:for-each select="$ReportList/Record">
					<xsl:variable name="colorStyle">
						<xsl:choose>
							<xsl:when test="StatusFirst=1">
								<xsl:text> #e01515;</xsl:text>
							</xsl:when>
							<xsl:when test="StatusFirst=2">
								<xsl:text> #ddb230;</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text> #3fb044;</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<tr class="onMouseOver ExpandRow trOpenAccordian trClosedAccordian_{$PageNumber}_{position()}" id="trOpenAccordian_{$PageNumber}_{position()}" postion="{$PageNumber}_{position()}">
						<td>
							<xsl:choose>
								<xsl:when test="StatusFirst=1">
									<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" style="font-size:20px;color:{$colorStyle}"></span>
								</xsl:when>
								<xsl:when test="StatusFirst=2">
									<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" style="font-size:20px;color:{$colorStyle}"></span>
								</xsl:when>
								<xsl:otherwise>
									<span class="glyphicon glyphicon glyphicon-ok" aria-hidden="true" style="font-size:20px;color:{$colorStyle}"></span>
								</xsl:otherwise>
							</xsl:choose>
						</td>
						<td class="onMouseOver" onclick="loadManagerProgramMemberDetailsCall('divAccordian_{$PageNumber}_{position()}',{$PortalID},{UserID}
										, 1, 'ManagerProgram', null, null, null, null, null, null, null
										, 'true', 'false', 'false', 'false', 'true', 'true', {UserID}, null, null, '{$Classification}',
							'trClosedAccordian', 'trClosedAccordian_{$PageNumber}_{position()}','AccordianItems','true');">
							<xsl:choose>
								<xsl:when test="FbPicURL !=''">
									<img src="{FbPicURL}" style="width:50px;height:50px;margin:5px 0!important;"></img>
								</xsl:when>
								<xsl:otherwise>
									<xsl:call-template name="GetFirstLastWord">
										<xsl:with-param name="value" select="Name"></xsl:with-param>
									</xsl:call-template>
								</xsl:otherwise>
							</xsl:choose>
						</td>
						<td class="onMouseOver" style="text-align:left!important;" onclick="loadManagerProgramMemberDetailsCall('divAccordian_{$PageNumber}_{position()}',{$PortalID},{UserID}
										, 1, 'ManagerProgram', null, null, null, null, null, null, null
										, 'true', 'false', 'false', 'false', 'true', 'true', {UserID}, null, null, '{$Classification}',
							'trClosedAccordian', 'trClosedAccordian_{$PageNumber}_{position()}','AccordianItems','true');">
							<span >
								<xsl:choose>
									<xsl:when test="contains(Name,'@')">
										<xsl:value-of select="substring-before(Name,'@')"></xsl:value-of>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select="Name"></xsl:value-of>
									</xsl:otherwise>
								</xsl:choose>
							</span>
						</td>
						<td  onclick="accordionOpenAndClose('trClosedAccordian', 'trClosedAccordian_{$PageNumber}_{position()}','AccordianProgram');
							 loadActivityDashboardGoalSummaryForManagerProgram({$MasterPortalItemID}, {$PortalID}, -99,'divAccordian_{$PageNumber}_{position()}',{UserID}, 'divAccordian_{$PageNumber}_{position()}'
							 , '{$Classification}')">
							<span class="btn AccordianProgram">
								<xsl:value-of select="Programs"></xsl:value-of>
							</span>
						</td>
						<td onclick="accordionOpenAndClose('trClosedAccordian', 'trClosedAccordian_{$PageNumber}_{position()}','AccordianItems');
							loadBasePortalUserTasks_Base_3_0('divAccordian_{$PageNumber}_{position()}',{$PortalID},{UserID}
										, 1, 'ManagerProgram', null, null, null, null, null, null, null
										, 'true', 'false', 'false', 'false', 'true', 'true', {UserID}, null, null, '{$Classification}');">
							<span  class="btn AccordianItems">
								<xsl:value-of select="Items"></xsl:value-of>
							</span>
						</td>
						<td onclick="accordionOpenAndClose('trClosedAccordian', 'trClosedAccordian_{$PageNumber}_{position()}','AccordianCompleted');
							loadBasePortalUserTasks_Base_3_0('divAccordian_{$PageNumber}_{position()}',{$PortalID},{UserID}
										, 1, 'ManagerProgram', null, null, null, null, null, null, null
										, 'true', 'false', 'false', 'false', 'true', 'true', {UserID}, null, 'Completed', '{$Classification}');">
							<span  class="btn AccordianCompleted">
								<xsl:value-of select="Completed"></xsl:value-of>
							</span>
						</td>
						<td onclick="accordionOpenAndClose('trClosedAccordian', 'trClosedAccordian_{$PageNumber}_{position()}','AccordianRed');
							loadBasePortalUserTasks_Base_3_0('divAccordian_{$PageNumber}_{position()}',{$PortalID},{UserID}
										, 1, 'ManagerProgram', null, null, null, null, null, null, null
										, 'true', 'false', 'false', 'false', 'true', 'true', {UserID}, null, 'PastDue', '{$Classification}');">
							<span  class="btn AccordianRed">
								<xsl:value-of select="PastDue"></xsl:value-of>
							</span>
						</td>
						<td onclick="accordionOpenAndClose('trClosedAccordian', 'trClosedAccordian_{$PageNumber}_{position()}','AccordianYellow');
							loadBasePortalUserTasks_Base_3_0('divAccordian_{$PageNumber}_{position()}',{$PortalID},{UserID}
										, 1, 'ManagerProgram', null, null, null, null, null, null, null
										, 'true', 'false', 'false', 'false', 'true', 'true', {UserID}, null, 'Review', '{$Classification}');">
							<span  class="btn AccordianYellow">
								<xsl:value-of select="Review"></xsl:value-of>
							</span>
						</td>
						<td onclick="accordionOpenAndClose('trClosedAccordian', 'trClosedAccordian_{$PageNumber}_{position()}','AccordianWaiting');
							loadBasePortalUserTasks_Base_3_0('divAccordian_{$PageNumber}_{position()}',{$PortalID},{UserID}
										, 1, 'ManagerProgram', null, null, null, null, null, null, null
										, 'true', 'false', 'false', 'false', 'true', 'true', {UserID}, null, 'Remaining', '{$Classification}');">
							<span  class="btn AccordianWaiting">
								<xsl:value-of select="Remaining"></xsl:value-of>
							</span>
						</td>
						<td>
							<span>
								<xsl:choose>
									<xsl:when test="LastAccess !=''">
										<xsl:value-of select="LastAccess"></xsl:value-of> days ago
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>Not Available</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</span>
						</td>
						<td>
							<div class="progress Mrgin">
								<div class="progress-bar 	progress-bar-info" role="progressbar" style="width:{round(Status)}%;background-color:{$colorStyle}!important">
									<span class="">
										<xsl:value-of select="round(Status)"></xsl:value-of>%
									</span>
								</div>
							</div>
						</td>
					</tr>
					<tr style="display:none" class="trClosedAccordian" id="trClosedAccordian_{$PageNumber}_{position()}" openStatus="0">
						<td colspan="11">
							<div style="width: 100%;/*border: 1px solid #ccc;*/"  id="divAccordian_{$PageNumber}_{position()}"></div>
						</td>
					</tr>
				</xsl:for-each>
			</xsl:if>
			<xsl:if test="$TotalPages &gt; 1">
				<tr>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td colspan="3">

						<ul class="pager" style="font-size:14px;font-weight:bold;">
							<li class="previous">
								<xsl:if test="$PageNumber &gt;1">
									<a href="javascript:void(0);" id="btnPrevManagerPrgram"
								  onclick="loadManagerProgramsReportPaging('{$DivID}', {$ManagerID},{$MasterPortalItemID},{$PortalItemID},'{$Classification}'
				   ,{$AllUser}, '{$UserName}','{$OrderBy}', '{$Order}',{$PageNumber - 1});">Previous</a>
								</xsl:if>

							</li>

							<span style="width:auto;display:inline;height:29px;line-height:29px;">
								<span>
									Page	<xsl:value-of select="$PageNumber"/>
								</span>
								<span> of </span>
								<span>
									<xsl:value-of select="$TotalPages"/>
								</span>
							</span>

							<li class="next">
								<xsl:if test="$PageNumber &lt;$TotalPages">
									<a href="javascript:void(0);" id="btnPrevManagerPrgram"
								  onclick="loadManagerProgramsReportPaging('{$DivID}', {$ManagerID},{$MasterPortalItemID},{$PortalItemID},'{$Classification}'
				   ,{$AllUser}, '{$UserName}','{$OrderBy}', '{$Order}',{$PageNumber + 1});">Next</a>
								</xsl:if>
							</li>
						</ul>

					</td>
				</tr>
			</xsl:if>
		</table>
	
	</xsl:template>
</xsl:stylesheet>
