﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:variable name ="recordCount" select ="PlanItGoals/PlanIt/RecordCount"></xsl:variable>
        <xsl:variable name ="TemplatePathURL" select ="normalize-space(PlanItGoals/PlanIt/TemplateURL)"></xsl:variable>
        <xsl:variable name ="viewLifespaceID" select ="PlanItGoals/PlanIt/ViewLifeSpaceID"></xsl:variable>
        <xsl:variable name ="HostName" select ="PlanItGoals/PlanIt/HostName"></xsl:variable>
        <div id="divPlanIt_Container">
            <div id="divPlanITContent">
                <table width="95%" border="0" cellspacing="5" cellpadding="5">
                    <tr>
                        <xsl:if test ="normalize-space($recordCount) != 0">
                            <xsl:if test ="normalize-space($recordCount) &lt;= 10">
                                <td width="45%">
                                    <xsl:for-each select ="PlanItGoals/PlanIt/Item">
                                        <xsl:if test="position()&lt;=3">
                                            <div style="margin-left:30px;">
                                                <table>
                                                    <tr>
                                                        <td align="center">
                                                            <a href="http://{normalize-space($HostName)}/Goal.aspx?ID={normalize-space(GoalID)}">
                                                                <xsl:choose>
                                                                    <xsl:when test="ItemID > 6">
                                                                        <img id="divLifeSpaceListItem_{normalize-space(LifeSpaceID)}_img"
                                                                                style="display:inline; margin-left: 0px; vertical-align: middle; display: none;"
                                                                                src="{$TemplatePathURL}Web/Images/LifeSpace LLC.jpg"
                                                                                onload='setWidthAndHeightImage(this,"45");' />&#xa0;
                                                                    </xsl:when>
                                                                    <xsl:otherwise>
                                                                        <img id="divLifeSpaceListItem_{normalize-space(LifeSpaceID)}_img"
                                                                                style="display:inline; margin-left: 0px; vertical-align: middle; display: none;"
                                                                                src="{$TemplatePathURL}Web/Images/{normalize-space(LifeSpace)}.jpg"
                                                                                onload='setWidthAndHeightImage(this,"45");' />&#xa0;
                                                                    </xsl:otherwise>
                                                                </xsl:choose>
                                                            </a>
                                                        </td>
                                                        <td valign="top">
                                                            <div class="link">
                                                                <b>
                                                                    <a href="http://{normalize-space($HostName)}/Goal.aspx?ID={normalize-space(GoalID)}">
                                                                        <xsl:value-of select ="GoalName"/>
                                                                    </a>
                                                                </b>
                                                            </div>
                                                            <div class="label">
                                                                (<xsl:value-of select ="TotalNotifications"/>&#xa0;Notifications,
                                                                <xsl:value-of select ="TotalCount"/>&#xa0;Actions)
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                                <td width="5%"></td>
                                <td width="50%" valign="top">
                                    <xsl:for-each select ="PlanItGoals/PlanIt/Item">
                                        <xsl:if test="position()&gt;3">
                                            <div style="margin:10px;">
                                                <span class="link">
                                                    <b>
                                                        <a href="http://{normalize-space($HostName)}/Goal.aspx?ID={normalize-space(GoalID)}">
                                                            <xsl:value-of select ="GoalName"/>
                                                        </a>
                                                    </b>
                                                </span>
                                            </div>
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                            </xsl:if>
                            <xsl:if test ="normalize-space($recordCount) &gt; 10">
                                <td>
                                    <xsl:for-each select="PlanItGoals/LifeSpace/Item">
                                        <xsl:variable name ="LifeSpaceID" select="ID"/>
                                        <xsl:variable name ="LifeSpaceName" select="Name"/>
                                        <xsl:if test="count(../../PlanIt/Item[LifeSpaceID = $LifeSpaceID]) &gt; 0">
                                            <div id="div_Item_{normalize-space($LifeSpaceID)}_Group_PlanIt" style="margin-left:10px;">
                                                <div id="div_Item_{normalize-space($LifeSpaceID)}_Group_Header_PlanIt"
                                                     class="onmouseover seperatorLine label link"
                                                     onclick="return expandCollapseByGroup('div_Item_{normalize-space($LifeSpaceID)}_Group_Content_PlanIt');">
                                                    <span>
                                                        <xsl:value-of select="$LifeSpaceName"/>
                                                    </span>
                                                </div>
                                                <div id="div_Item_{normalize-space($LifeSpaceID)}_Group_Content_PlanIt" style="display:block;margin-left:15px;">
                                                    <xsl:for-each select="../../Status/ItamStatus">
                                                        <xsl:sort select="SortOrder" />
                                                        <xsl:variable name ="ItemStatusID" select="ID"/>
                                                        <xsl:variable name ="ItemStatusName" select="Name"/>
                                                        <xsl:if test="count(../../PlanIt/Item[StatusID = $ItemStatusID and LifeSpaceID = $LifeSpaceID]) &gt; 0">
                                                            <div id="div_Item_{normalize-space($LifeSpaceID)}_Status_{normalize-space($ItemStatusID)}_Goals_PlanIt">
                                                                <div id="div_Item_{normalize-space($LifeSpaceID)}_Status_{normalize-space($ItemStatusID)}_Goals_Header_PlanIt"
                                                                     class="onmouseover seperatorLine label link"
                                                                     onclick="return expandCollapseByGroup('div_Item_{normalize-space($LifeSpaceID)}_Status_{normalize-space($ItemStatusID)}_Goals_Content_PlanIt');">
                                                                    <span>
                                                                        <xsl:value-of select="$ItemStatusName"/>
                                                                    </span>
                                                                </div>
                                                                <div id="div_Item_{normalize-space($LifeSpaceID)}_Status_{normalize-space($ItemStatusID)}_Goals_Content_PlanIt"
                                                                     style="display:block;">
                                                                    <xsl:for-each select ="../../PlanIt/Item[StatusID = $ItemStatusID and LifeSpaceID = $LifeSpaceID]">
                                                                        <div style="margin:10px; margin-left:30px;">
                                                                            <span class="link">
                                                                                <b>
                                                                                    <a href="http://{normalize-space($HostName)}/Goal.aspx?ID={normalize-space(GoalID)}">
                                                                                        <xsl:value-of select ="GoalName"/>
                                                                                    </a>
                                                                                </b>
                                                                            </span>
                                                                            <span class="label">
                                                                                (<xsl:value-of select ="TotalNotifications"/>&#xa0;Notifications,
                                                                                <xsl:value-of select ="TotalCount"/>&#xa0;Actions)
                                                                            </span>
                                                                        </div>
                                                                    </xsl:for-each>
                                                                </div>
                                                            </div>
                                                        </xsl:if>
                                                    </xsl:for-each>
                                                </div>
                                            </div>
                                        </xsl:if>
                                    </xsl:for-each>
                                </td>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test ="normalize-space($recordCount) = 0">
                            <td>
                                <div style="margin:20px; align: center;">
                                    <span class="label" style="margin-left:38px">
                                        <i>
                                            <p style="text-align: center;">
                                                You currently have no goals.
                                                To create your first goal, click here
                                            </p>
                                        </i>
                                    </span>
                                </div>
                            </td>
                        </xsl:if>
                    </tr>
                </table>
            </div>
        </div>
    </xsl:template>
</xsl:stylesheet>
