﻿<?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="../TemplateDetailTemplate.xslt"/>
	<xsl:import href="../TemplateDetailItems.xslt"/>
	<xsl:import href="../TemplateDetailTopics.xslt"/>
	<xsl:import href="../TemplateDetailNumbers.xslt"/>
	<xsl:import href="AddTemplateSummary.xslt"/>
	<xsl:import href="AddMetricToTemplate.xslt"/>


	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:variable>
		<xsl:variable name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:variable>
		<xsl:variable name="BrandID" select="AjaxRequest/BrandID"></xsl:variable>
		<xsl:variable name="CommunityAdmin" select="AjaxRequest/CommunityAdmin"></xsl:variable>
		<xsl:variable name="TemplateItemID" select="AjaxRequest/Params/ItemID"></xsl:variable>
		<xsl:variable name="ImageURL" select="AjaxRequest/TemplateDetailForClients/TemplateImage/Item"></xsl:variable>
		<xsl:variable name="TemplateRoles" select="AjaxRequest/Roles/."></xsl:variable>
		<xsl:variable name="PermissionList" select="AjaxRequest/Permissions/."></xsl:variable>
		<xsl:variable name="ShareITList" select="AjaxRequest/ShareITRecords/."></xsl:variable>
		<xsl:variable name="CommunityItemID" select="AjaxRequest/TemplateDetailItems/Template/CommunityItemID"></xsl:variable>
		<xsl:variable name="SuccessKey" select="AjaxRequest/TemplateDetail/Template[TypeKey = 'SuccessKey']/Item"></xsl:variable>
		<xsl:variable name="PortalItemID" select="AjaxRequest/PortalItemID"></xsl:variable>
		<xsl:variable name="TemplateNumbers" select="AjaxRequest/TemplateNumbers/."></xsl:variable>
		<xsl:variable name="GoalNumberDirectionXML" select="AjaxRequest/GoalNumberDirectionXML/."></xsl:variable>
		<xsl:variable name="NumberGoalPermissionXML" select="AjaxRequest/NumberGoalPermission/."></xsl:variable>
		<xsl:variable name="PortalMetrics" select="AjaxRequest/PortalMetrics/."></xsl:variable>
		<xsl:variable name="GoalNumberFormatXML" select="AjaxRequest/GoalNumberFormatXML/."></xsl:variable>
		<xsl:variable name="TemplateType" select="AjaxRequest/Params/TemplateType"></xsl:variable>
		<xsl:variable name="LoggedInUserID" select="AjaxRequest/LoggedInUserID"></xsl:variable>
		<xsl:variable name="CategoryControl" select="AjaxRequest/CategoryControl/."></xsl:variable>
		<xsl:variable name="TemplateStatusXML" select="AjaxRequest/Template/."></xsl:variable>
		<xsl:variable name="BrandAdmin" select="AjaxRequest/UserRoles/Role[RoleName = 'Brand Admin']"></xsl:variable>
		<xsl:variable name="IsSecureConnection" select="AjaxRequest/IsSecureConnection"/>
		<xsl:variable name="MetricInputTypes" select="AjaxRequest/MetricInputTypes"/>
		<xsl:variable name="MetricPeriodTypes" select="AjaxRequest/PeriodTypes"/>
		<xsl:variable name="ClassificationList" select="AjaxRequest/Settings/DefaultSettings/Classification"/>

		<xsl:call-template name="Portal_MyServicesTemplateDetail">
			<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
			<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
			<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
			<xsl:with-param name="CommunityAdmin" select="$CommunityAdmin"></xsl:with-param>
			<xsl:with-param name="TemplateItemID" select="$TemplateItemID"></xsl:with-param>
			<xsl:with-param name="ImageURL" select="$ImageURL"></xsl:with-param>
			<xsl:with-param name="TemplateRoles" select="$TemplateRoles"></xsl:with-param>
			<xsl:with-param name="PermissionList" select="$PermissionList"></xsl:with-param>
			<xsl:with-param name="ShareITList" select="$ShareITList"></xsl:with-param>
			<xsl:with-param name="CommunityItemID" select="$CommunityItemID"></xsl:with-param>
			<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
			<xsl:with-param name="SuccessKey" select="$SuccessKey"></xsl:with-param>
			<xsl:with-param name="TemplateNumbers" select="$TemplateNumbers"></xsl:with-param>
			<xsl:with-param name="GoalNumberDirectionXML" select="$GoalNumberDirectionXML"></xsl:with-param>
			<xsl:with-param name="NumberGoalPermissionXML" select="$NumberGoalPermissionXML"></xsl:with-param>
			<xsl:with-param name="PortalMetrics" select="$PortalMetrics"></xsl:with-param>
			<xsl:with-param name="GoalNumberFormatXML" select="$GoalNumberFormatXML"></xsl:with-param>
			<xsl:with-param name="TemplateType" select="$TemplateType"></xsl:with-param>
			<xsl:with-param name="LoggedInUserID" select="$LoggedInUserID"></xsl:with-param>
			<xsl:with-param name="CategoryControl" select="$CategoryControl"></xsl:with-param>
			<xsl:with-param name="TemplateStatusXML" select="$TemplateStatusXML"></xsl:with-param>
			<xsl:with-param name="BrandAdmin" select="$BrandAdmin"></xsl:with-param>
			<xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
			<xsl:with-param name="MetricInputTypes" select="$MetricInputTypes"></xsl:with-param>
			<xsl:with-param name="MetricPeriodTypes" select="$MetricPeriodTypes"></xsl:with-param>
			<xsl:with-param name="ClassificationList" select="$ClassificationList"></xsl:with-param>

		</xsl:call-template>
	</xsl:template>


	<xsl:template name="Portal_MyServicesTemplateDetail">
		<xsl:param name="HostName" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<xsl:param name="BrandID" select="'N/A'"></xsl:param>
		<xsl:param name="CommunityAdmin" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateItemID" select="'N/A'"></xsl:param>
		<xsl:param name="ImageURL" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateRoles" select="'N/A'"></xsl:param>
		<xsl:param name="PermissionList" select="'N/A'"></xsl:param>
		<xsl:param name="ShareITList" select="'N/A'"></xsl:param>
		<xsl:param name="CommunityItemID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="SuccessKey" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateNumbers" select="'N/A'"></xsl:param>
		<xsl:param name="GoalNumberDirectionXML" select="'N/A'"></xsl:param>
		<xsl:param name="NumberGoalPermissionXML" select="'N/A'"></xsl:param>
		<xsl:param name="PortalMetrics" select="'N/A'"></xsl:param>
		<xsl:param name="GoalNumberFormatXML" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateType" select="'N/A'"></xsl:param>
		<xsl:param name="LoggedInUserID" select="'N/A'"></xsl:param>
		<xsl:param name="CategoryControl" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateStatusXML" select="'N/A'"></xsl:param>
		<xsl:param name="BrandAdmin" select="'N/A'"></xsl:param>
		<xsl:param name="IsSecureConnection" select="'N/A'"></xsl:param>
		<xsl:param name="MetricInputTypes" select="'N/A'"></xsl:param>
		<xsl:param name="MetricPeriodTypes" select="'N/A'"></xsl:param>
		<xsl:param name="ClassificationList" select="'N/A'"></xsl:param>



		<div align="right" class="padding5">
			<img src="{$TemplateURL}Web/Images/Ver_2_0/BT_x.png" class="onMouseOver"
                 onClick="Portal_GetTemplatesDisplay('divClientPortalOperations_Container','{$BrandID}');"></img>

		</div>
		<div>
			<div class="marginLeft5 marginRight10 onMouseOver" style="float:left;padding:2px;margin-top:2px;">
				<img id="img_expand_TemplateDetail" src="{$TemplateURL}Web/Images/Ver_2_0/arrow_right.png" height="15" width="15" title="Click to Expand"
                     onclick="ExpandCollapseTemplateDetails('div_TemplateDetail', 'expand', 'TemplateDetail');"></img>

				<img id="img_collapse_TemplateDetail" src="{$TemplateURL}Web/Images/Ver_2_0/arrow_down.png" height="15" width="15" style="display:none;" title="Click to Collapse"
                     onclick="ExpandCollapseTemplateDetails('div_TemplateDetail', 'collapse', 'TemplateDetail');"></img>
			</div>
			<div class="link seperatorLine" style="margin-bottom:10px;font-size:16px;background-color:rgb(217, 217, 217);">
				Advanced Template Settings
			</div>
			<div id="div_TemplateDetail" boxed="0" style="display:none;">
				<xsl:call-template name="TemplateDetailTemplate">
					<xsl:with-param name="TemplateItemID" select="$TemplateItemID"></xsl:with-param>
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
					<xsl:with-param name="PermissionList" select="$PermissionList"></xsl:with-param>
					<xsl:with-param name="ShareITList" select="$ShareITList"></xsl:with-param>
					<xsl:with-param name="TemplateType" select="$TemplateType"></xsl:with-param>
					<xsl:with-param name="LoggedInUserID" select="$LoggedInUserID"></xsl:with-param>
					<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
					<xsl:with-param name="CategoryControl" select="$CategoryControl"></xsl:with-param>
					<xsl:with-param name="TemplateStatusXML" select="$TemplateStatusXML"></xsl:with-param>
					<xsl:with-param name="CommunityAdmin" select="$CommunityAdmin"></xsl:with-param>
					<xsl:with-param name="BrandAdmin" select="$BrandAdmin"></xsl:with-param>
					<xsl:with-param name="IsSecureConnection" select="$IsSecureConnection"></xsl:with-param>
					<xsl:with-param name="ClassificationList" select="$ClassificationList"></xsl:with-param>
				</xsl:call-template>
			</div>
		</div>
		<xsl:if test="$SuccessKey = 'Number' or $SuccessKey='BusinessPlanning'">
			<div>
				<div class="marginLeft5 marginRight10 onMouseOver" style="float:left;padding:2px;margin-top:2px;">
					<img id="img_expand_TemplateDetailNumbersAndMetrics" src="{$TemplateURL}Web/Images/Ver_2_0/arrow_right.png" height="15" style="display:none;" width="15" title="Click to Expand"
                         onclick="ExpandCollapseTemplateDetails('div_TemplateDetailNumbersAndMetrics_container', 'expand', 'TemplateDetailNumbersAndMetrics');"></img>

					<img id="img_collapse_TemplateDetailNumbersAndMetrics" src="{$TemplateURL}Web/Images/Ver_2_0/arrow_down.png" height="15" width="15" title="Click to Collapse"
                         onclick="ExpandCollapseTemplateDetails('div_TemplateDetailNumbersAndMetrics_container', 'collapse', 'TemplateDetailNumbersAndMetrics');"></img>
				</div>
				<div class="link seperatorLine" style="font-size:16px;margin-top:10px;background-color:rgb(217, 217, 217)">Numbers and Metrics</div>
				<div id="div_TemplateDetailNumbersAndMetrics_container">
					<div id="div_TemplateDetailNumbersAndMetrics" boxed="0">
						<xsl:call-template name="TemplateDetailNumbers">
							<xsl:with-param name="TemplateItemID" select="$TemplateItemID"></xsl:with-param>
							<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
							<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
							<xsl:with-param name="TemplateNumbers" select="$TemplateNumbers"></xsl:with-param>
							<xsl:with-param name="GoalNumberDirectionXML" select="$GoalNumberDirectionXML"></xsl:with-param>
							<xsl:with-param name="NumberGoalPermissionXML" select="$NumberGoalPermissionXML"></xsl:with-param>
							<xsl:with-param name="GoalNumberFormatXML" select="$GoalNumberFormatXML"></xsl:with-param>
							<xsl:with-param name="PortalMetrics" select="$PortalMetrics"></xsl:with-param>
							<xsl:with-param name="MetricInputType" select="$MetricInputTypes"></xsl:with-param>
							<xsl:with-param name="MetricPeriodTypes" select="$MetricPeriodTypes"></xsl:with-param>
							<xsl:with-param name="SuccessKey" select="$SuccessKey"></xsl:with-param>  
						</xsl:call-template>
					
					</div>
					<div style="margin-top:10px;">
						
						<xsl:call-template name="AddMetricToTemplate">
							<xsl:with-param name="TemplateItemID" select="$TemplateItemID"></xsl:with-param>
							<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
							<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
							<xsl:with-param name="PortalMetrics" select="$PortalMetrics"></xsl:with-param>
							<xsl:with-param name="MetricInputType" select="$MetricInputTypes"></xsl:with-param>
							<xsl:with-param name="MetricPeriodTypes" select="$MetricPeriodTypes"></xsl:with-param>
							<xsl:with-param name="SelectedPeriodType" select="$TemplateNumbers/Template[TypeKey = 'UpdateMetrics']/Item"></xsl:with-param>
						</xsl:call-template>
					</div>
				</div>
			</div>
		</xsl:if>
		<div>
			<div class="marginLeft5 marginRight10 onMouseOver" style="float:left;padding:2px;margin-top:2px;">
				<img id="img_expand_TemplateDetailTopics" src="{$TemplateURL}Web/Images/Ver_2_0/arrow_right.png" height="15" style="display:none;" width="15" title="Click to Expand"
                     onclick="ExpandCollapseTemplateDetails('div_TemplateDetailTopics', 'expand', 'TemplateDetailTopics');"></img>

				<img id="img_collapse_TemplateDetailTopics" src="{$TemplateURL}Web/Images/Ver_2_0/arrow_down.png" height="15" width="15" title="Click to Collapse"
                     onclick="ExpandCollapseTemplateDetails('div_TemplateDetailTopics', 'collapse', 'TemplateDetailTopics');"></img>
			</div>
			<div style="background-color:rgb(217, 217, 217);">
				<div class="link seperatorLine" style="font-size:16px;margin-top:10px;">
					Topics
				</div>
			</div>
			<div style="font-size:14px;margin-top:10px;" class="publicationSummary marginBottom15">Items within goals are grouped by topics or milestones. Please create one or more topics and then add items under each topic below</div>

			<div id="div_TemplateDetailTopics" boxed="0">
				<xsl:call-template name="TemplateDetailTopics">
					<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
					<xsl:with-param name ="TemplateURL" select="$TemplateURL"></xsl:with-param>
				</xsl:call-template>
				<div style="margin-top:10px;">
					<xsl:call-template name="AddTemplateSummary">
						<xsl:with-param name="TemplateItemID" select="$TemplateItemID"></xsl:with-param>
						<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
						<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
					</xsl:call-template>
				</div>
			</div>
		</div>
		<div>
			<div class="marginLeft5 marginRight10 onMouseOver" style="float:left;padding:2px;margin-top:2px;">
				<img id="img_expand_TemplateDetailItems" src="{$TemplateURL}Web/Images/Ver_2_0/arrow_right.png" height="15" style="display:none;" width="15" title="Click to Expand"
                     onclick="ExpandCollapseTemplateDetails('div_TemplateDetailItems', 'expand', 'TemplateDetailItems');"></img>

				<img id="img_collapse_TemplateDetailItems" src="{$TemplateURL}Web/Images/Ver_2_0/arrow_down.png" height="15" width="15" title="Click to Collapse"
                     onclick="ExpandCollapseTemplateDetails('div_TemplateDetailItems', 'collapse', 'TemplateDetailItems');"></img>
			</div>
			<div class="link seperatorLine" style="margin-top:10px;font-size:16px;background-color:rgb(217, 217, 217)">Items</div>
			<div id="div_TemplateDetailItems" boxed="0">
				<xsl:call-template name="TemplateDetailItems">
					<xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
					<xsl:with-param name ="TemplateURL" select="$TemplateURL"></xsl:with-param>
					<xsl:with-param name="BrandID" select="$BrandID"></xsl:with-param>
					<xsl:with-param name="TemplateRoles" select="$TemplateRoles"></xsl:with-param>
					<xsl:with-param name="CommunityItemID" select="$CommunityItemID"></xsl:with-param>
					<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
				</xsl:call-template>
			</div>
		</div>
	</xsl:template>
</xsl:stylesheet>
