﻿<?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:key name="DistictManager" match="AjaxRequest/ManagerRelationShip/User" use="./ManagerUserID"></xsl:key>

    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/">
        <xsl:variable name="ItemID" select="AjaxRequest/Params/ItemID"></xsl:variable>
		<xsl:variable name="DivID" select="AjaxRequest/Params/DivID"></xsl:variable>
        <xsl:variable name="RelationshipCount" select="count(AjaxRequest/ManagerRelationShip/User)"/>
        <xsl:variable name="TemplatePathURL" select="AjaxRequest/TemplateURL"/>

        <xsl:choose>
            <xsl:when test="$RelationshipCount = 0">
                <center>
                    <div style="padding:10px;">
                        <span class="packageTitle">There are no relationships.</span>
                    </div>

                    <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray marginTop15" style="width:170px;line-height:30px;"
                         onmouseover="document.getElementById('img_Add1').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_add_over.png';"
                         onmouseout="document.getElementById('img_Add1').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png';"
                         onClick="return portal_LoadManagerRelationshipsAddForm('{$DivID}','{$ItemID}');">
                        <img id="img_Add1" src="{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
                        <span id="span_Cancel">ADD A RELATIONSHIP</span>
                    </div>

                </center>
            </xsl:when>
            <xsl:otherwise>
                <xsl:for-each select="AjaxRequest/ManagerRelationShip/User[generate-id() = generate-id(key('DistictManager', ./ManagerUserID))]">

                    <xsl:variable name="ManagerUserID" select="ManagerUserID"></xsl:variable>
                    <div class="marginLeft10 seperatorLine">
                        <span class="publicationSummary onMouseOver sentenceFont"
                              onclick="LoadEmployeeDetail('{ManagerUserID}','{$DivID}','{PortalItemID}');">
                            <xsl:value-of select="ManagerUserName"/>
                        </span>
                    </div>
                    <xsl:for-each select="../User[ManagerUserID = $ManagerUserID]">
                        <table class="tableMaster" cellpadding="2" cellspacing="2">
                            <tr>
                                <td width="10%" class="verticallyMiddle">
                                    <img style="margin-left:10px" class="onMouseOver" src="{$TemplatePathURL}/Web/Images/Ver_2_0/BT_x.png" height="10" width="10"
                                                onClick="deleteManagerEmployeeRelationship('{ManagerUserID}','{EmployeeUserID}','{PortalItemID}','{Level}');"></img>
                                </td>
                                <td width="40%" class="verticallyMiddle">
                                    <span class="publicationSummary onMouseOver sentenceFont"
                                          onclick="LoadEmployeeDetail('{EmployeeUserID}','{$DivID}','{PortalItemID}');">
                                        <xsl:value-of select="EmployeeUserName"/>
                                    </span>
                                </td>
                                <td width="50%" class="verticallyMiddle">
                                    <span id="span_Status_{CRMManagerEmployeeID}" class="publicationSummary">
                                        <xsl:value-of select="RelationshipStatus"/>
                                    </span>
                                </td>
                            </tr>
                        </table>
                    </xsl:for-each>

                </xsl:for-each>

                <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray marginTop15" style="width:100px;line-height:25px;"
                    onmouseover="document.getElementById('img_Add1').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_add_over.png';"
                    onmouseout="document.getElementById('img_Add1').src='{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png';"
                    onClick="return portal_LoadManagerRelationshipsAddForm('{$DivID}','{$ItemID}');">
                    <img id="img_Add1" src="{$TemplatePathURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
                    <span id="span_Cancel">ADD NEW</span>
                </div>
            </xsl:otherwise>
        </xsl:choose>



    </xsl:template>
</xsl:stylesheet>
