﻿<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:include href="GenericTemplates/Item.xslt" />
    <xsl:include href="TaskFilter.xslt" />

    <xsl:template match="/">
        <xsl:variable name="TemplatePathURL" select ="Goal/TemplateURL"></xsl:variable>
        <div id="divGoalDetail" style="width:100%">

            <div id="div_GoalOutlineTree_Filter" style="margin-bottom:15px">
                <xsl:call-template name="TaskFilter"></xsl:call-template>
            </div>

            <div id="div_GoalOutlineTree" style="width:100%">
                <!--<xsl:variable name="TemplatePathURL" select ="Goal/TemplateURL"></xsl:variable>-->
                <input type="hidden" id="hiddenDivGoalTreeID" value="div_item_{normalize-space(Goal/@ID)}"></input>
                <div id="div_item_{normalize-space(Goal/@ID)}" class="body" style="margin-left: -15px">
                    <xsl:for-each select="Goal/Action">
                        
                        <xsl:variable name="ItemDivPrefix">
                            <xsl:text>div_item_</xsl:text>
                            <xsl:value-of select ="normalize-space(@ID)"></xsl:value-of>
                        </xsl:variable>
                        
                        <div id="{normalize-space($ItemDivPrefix)}" style="margin-left:15px; margin-right: 5px; margin-bottom: 10px;">
                            <xsl:call-template name="Item">
                                <xsl:with-param name="TemplatePathURL" select="$TemplatePathURL"></xsl:with-param>
                                <xsl:with-param name="ItemID" select="normalize-space(@ID)"></xsl:with-param>
                                <xsl:with-param name="GoalID" select="normalize-space(../@ID)"></xsl:with-param>
                                <xsl:with-param name="Status" select="normalize-space(Status)"></xsl:with-param>
                                <xsl:with-param name="Level" select="normalize-space(Level)"></xsl:with-param>
                                <xsl:with-param name="ParentParentID" select="normalize-space(ParentParentID)"></xsl:with-param>
                                <xsl:with-param name="ParentID" select="normalize-space(ParentID)"></xsl:with-param>
                                <xsl:with-param name="UpperSiblingID" select="normalize-space(UpperSiblingID)"></xsl:with-param>
                                <xsl:with-param name="LowerSiblingID" select="normalize-space(LowerSiblingID)"></xsl:with-param>
                                <xsl:with-param name="Mode" select="'GoalDetail'"></xsl:with-param>

                                <xsl:with-param name="PermissionID" select="normalize-space(PermissionID)"></xsl:with-param>
                                <xsl:with-param name="LeftDays" select="normalize-space(LeftDays)"></xsl:with-param>
                                <xsl:with-param name="DueDate" select="normalize-space(DueDate)"></xsl:with-param>
                                <xsl:with-param name="Responsible" select="normalize-space(Responsible)"></xsl:with-param>

                                <xsl:with-param name="TotalCount" select="normalize-space(TotalCount)"></xsl:with-param>
                                <xsl:with-param name="TotalChildCount" select="normalize-space(TotalChildCount)"></xsl:with-param>
                                <xsl:with-param name="Completed" select="normalize-space(Completed)"></xsl:with-param>
                                <xsl:with-param name="PastDueCount" select="normalize-space(PastDueCount)"></xsl:with-param>
                                <xsl:with-param name="Name" select="normalize-space(Name)"></xsl:with-param>
                                <xsl:with-param name="TypeID" select="normalize-space(TypeID)"></xsl:with-param>

                                <xsl:with-param name="ItemDivPrefix" select ="normalize-space($ItemDivPrefix)"></xsl:with-param>

                                <xsl:with-param name="RefItemTypeID" select="normalize-space(RefItemTypeID)"/>
                                <xsl:with-param name="RefItemID" select="normalize-space(RefItemID)"/>
                            </xsl:call-template>
                        </div>
                    </xsl:for-each>
                </div>
            </div>

            <xsl:if test="count(Goal/AddNewItem) &gt; 0">
                <div id="divParentAddNewItem" style="margin-bottom:10px;">
                    <div id="divAddNewItem">
                        <div id="divTxtAddAction" style="display: block;">
                            <input id="txtAddAction" class="textAreaGoal" value="Add new item here..."
                                   onclick="return toggleTaskDisplay('divGoalTask','divTxtAddAction');"/>
                        </div>
                        <div id="divGoalTask" style="display: none">
                            <xsl:value-of select="Goal/AddNewItem/Html" disable-output-escaping ="yes"/>
                        </div>
                    </div>
                </div>
            </xsl:if>
        </div>
    </xsl:template>

</xsl:stylesheet>