﻿<?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="TemplatePathURL" select="GoalDetail/TemplateURL"/>

        <xsl:variable name="itemID" select="normalize-space(GoalDetail/Goal/ItemID)"/>

        <xsl:variable name="statusID" select="normalize-space(GoalDetail/Goal/StatusID)"/>
        <xsl:variable name="SuccessKey" select="normalize-space(GoalDetail/Goal/SuccessKey)"/>

        <xsl:variable name="Metrics" select="normalize-space(GoalDetail/Goal/Metrics)"/>
        <xsl:variable name="TrackData" select="normalize-space(GoalDetail/Goal/TrackData)"/>
        <xsl:variable name="StartAmt" select="normalize-space(GoalDetail/Goal/StartAmt)"/>
        <xsl:variable name="TargetWhat" select="normalize-space(GoalDetail/Goal/TargetWhat)"/>
        <xsl:variable name="TargetAmt" select="normalize-space(GoalDetail/Goal/TargetAmt)"/>
        <xsl:variable name="TargetFormat" select="normalize-space(GoalDetail/Goal/TargetFormat)"/>
        <xsl:variable name="TargetDisplay" select="normalize-space(GoalDetail/Goal/TargetDisplay)"/>
        <xsl:variable name="DisplayDivKey">
            <xsl:choose>
                <xsl:when test ="$SuccessKey = 'Number'">
                    <xsl:text>display:block</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>display:none</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="CommunityAdmin" select="GoalDetail/UserRoles/Role/RoleName"></xsl:variable>
        <xsl:variable name ="DisplayAmount">
            <xsl:choose>
                <xsl:when test ="$TargetAmt != ''">
                    <xsl:text>label</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>autoSuggest</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name ="DisplayofWhat">
            <xsl:choose>
                <xsl:when test ="$TargetWhat != ''">
                    <xsl:text>label</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>autoSuggest</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <!--<xsl:variable name="lblGoalNameID">
        <xsl:value-of select="normalize-space(GoalDetail/Params/LabelGoalNameID)"/>
      </xsl:variable>
      <xsl:variable name="divNewGoalTree">
        <xsl:value-of select="normalize-space(GoalDetail/Params/divNewGoalTree)"/>
      </xsl:variable>-->
        <div style="margin:20px;">
            <table class="tableMaster">
                <tr>
                    <td style="width: 20%;">
                        <span class="labelFormFields">Goal</span>
                    </td>
                    <td>
                        <input id="txt_Item_{normalize-space($itemID)}_Update_Title" type="text"
                               value ="{normalize-space(GoalDetail/Goal/Item)}" class="text" tabindex="1" maxlength="50"/>
                    </td>
                    <td>
                        <span id ="span_item_{normalize-space($itemID)}_Update_ErrorMessage" class="labelError" style="display:none;">*</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields">Description</span>
                    </td>
                    <td>
                        <textarea id="txt_Item_{normalize-space($itemID)}_Update_Description" rows="2" class="textArea" tabindex="2">
                            <xsl:value-of select ="normalize-space(GoalDetail/Goal/ProjectDesc)"/>
                        </textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields">Measure Success</span>
                    </td>
                    <td>
                        <select id ="opt_Item_{normalize-space($itemID)}_Success" name="lifespace" class="smallDropdownSuccess"
                                 onchange='setSuccessKeyDisplay("opt_Item_{$itemID}_Success", "div_{$itemID}_DisplayNumbers");'>
                            <xsl:choose>
                                <xsl:when test ="$SuccessKey = 'Number'">
                                    <option value="Action">Completing Actions</option>
                                    <option value="Number" selected="selected">By Numbers and Metrics</option>
                                </xsl:when>
                                <xsl:otherwise>
                                    <option value="Action" selected="selected">Completing Actions</option>
                                    <option value="Number">By Numbers and Metrics</option>
                                </xsl:otherwise>
                            </xsl:choose>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <div id="div_{$itemID}_DisplayNumbers" style="{$DisplayDivKey};margin-left:-3px;">
                            <table class="tableMaster">
                                <tr>
                                    <td style="width: 20%;">
                                        <span class="labelFormFields">Target</span>
                                    </td>
                                    <td>
                                        <span>
                                            <select id ="opt_Item_{$itemID}_DisplayNumbers" name="lifespace" class="smallDropdown">
                                                <xsl:choose>
                                                    <xsl:when test ="$TargetDisplay = 'PeriodAbove'">
                                                        <option value="TotalAbove" >Total Above</option>
                                                        <option value="PeriodAbove" selected="selected">
                                                            <xsl:value-of select ="$TrackData"/>&#xa0;Above
                                                        </option>
                                                        <option value="PeriodBelow">
                                                            <xsl:value-of select ="$TrackData"/>&#xa0;Below
                                                        </option>
                                                    </xsl:when>
                                                    <xsl:when test ="$TargetDisplay = 'PeriodBelow'">
                                                        <option value="TotalAbove" >Total Above</option>
                                                        <option value="PeriodAbove">
                                                            <xsl:value-of select ="$TrackData"/>&#xa0;Above
                                                        </option>
                                                        <option value="PeriodBelow" selected="selected">
                                                            <xsl:value-of select ="$TrackData"/>&#xa0;Below
                                                        </option>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <option value="TotalAbove" selected="selected">Total Above</option>
                                                        <option value="PeriodAbove">
                                                            <xsl:value-of select ="$TrackData"/>&#xa0;Above
                                                        </option>
                                                        <option value="PeriodBelow">
                                                            <xsl:value-of select ="$TrackData"/>&#xa0;Below
                                                        </option>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </select>
                                        </span>&#xa0;<span>
                                            <select id ="opt_Item_{$itemID}_NumberFormat" style="width:50px"
                                                    name="lifespace" class="smallDropdown"
                                                    onChange='setSuccessFormat("opt_Item_{$itemID}_NumberFormat","txt_Item_{$itemID}_StartFormat");'>
                                                <xsl:choose>
                                                    <xsl:when test ="$TargetFormat = '#'">
                                                        <option value="$">$</option>
                                                        <option value="#" selected="selected">#</option>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <option value="$" selected="selected">$</option>
                                                        <option value="#">#</option>
                                                    </xsl:otherwise>
                                                </xsl:choose>

                                            </select>
                                        </span>&#xa0;
                                        <span>
                                            <input id="txt_Item_{$itemID}_TargetAmount" type="text"
                                                   value ="{$TargetAmt}" class="{$DisplayAmount}" style="width:75px;"
                                                   onFocus='return SuccessKey_ClearAutoSuggestTextbox("txt_Item_{$itemID}_TargetAmount");'/>
                                        </span>&#xa0;
                                        <span>
                                            <input id="txt_Item_{$itemID}_TargetWhat" type="text"
                                                   value ="{$TargetWhat}" class="{$DisplayofWhat}" style="width:75px;"
                                                   onFocus='return SuccessKey_ClearAutoSuggestTextbox("txt_Item_{$itemID}_TargetWhat");'
                                                   onBlur='SetTargetText("txt_Item_{$itemID}_TargetWhat", "txt_Item_{$itemID}_StartWhat");'/>
                                        </span>&#xa0;
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 20%;">
                                        <span class="labelFormFields">Starting With</span>
                                    </td>
                                    <td>
                                        <span class="text" id="txt_Item_{$itemID}_StartFormat">
                                            <xsl:choose>
                                                <xsl:when test ="$TargetFormat = ''">$</xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:value-of select ="$TargetFormat"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </span>&#xa0;
                                        <span>
                                            <input id="txt_Item_{$itemID}_StartAmount" type="text"
                                                   value ="{$StartAmt}" class="text" style="width:75px;"/>
                                        </span>&#xa0;
                                        <span class="text" id="txt_Item_{$itemID}_StartWhat">
                                            <xsl:value-of select ="$TargetWhat"/>
                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 20%;">
                                        <span class="labelFormFields">Track Amount</span>
                                    </td>
                                    <td>
                                        <select id ="opt_Item_{$itemID}_TrackAmount"
                                                onChange="goal_ChangeTargetAmountOption('opt_Item_{$itemID}_TrackAmount','opt_Item_{$itemID}_DisplayNumbers');"
                                                name="lifespace" class="smallDropdown">
                                            <xsl:choose>
                                                <xsl:when test ="$TrackData = 'Weekly'">
                                                    <option value="Daily" >Daily</option>
                                                    <option value="Weekly" selected="selected">Weekly</option>
                                                    <option value="Monthly">Monthly</option>
                                                    <option value="Quaterly">Quaterly</option>
                                                    <option value="Annually">Annually</option>
                                                </xsl:when>
                                                <xsl:when test ="$TrackData = 'Daily'">
                                                    <option value="Daily" selected="selected">Daily</option>
                                                    <option value="Weekly">Weekly</option>
                                                    <option value="Monthly" >Monthly</option>
                                                    <option value="Quaterly">Quaterly</option>
                                                    <option value="Annually">Annually</option>
                                                </xsl:when>
                                                <xsl:when test ="$TrackData = 'Quaterly'">
                                                    <option value="Daily" >Daily</option>
                                                    <option value="Weekly">Weekly</option>
                                                    <option value="Monthly">Monthly</option>
                                                    <option value="Quaterly" selected="selected">Quaterly</option>
                                                    <option value="Annually">Annually</option>
                                                </xsl:when>
                                                <xsl:when test ="$TrackData = 'Annually'">
                                                    <option value="Daily" >Daily</option>
                                                    <option value="Weekly">Weekly</option>
                                                    <option value="Monthly">Monthly</option>
                                                    <option value="Quaterly">Quaterly</option>
                                                    <option value="Annually" selected="selected">Annually</option>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <option value="Daily" >Daily</option>
                                                    <option value="Weekly">Weekly</option>
                                                    <option value="Monthly" selected="selected">Monthly</option>
                                                    <option value="Quaterly">Quaterly</option>
                                                    <option value="Annually">Annually</option>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 20%;">
                                        <span class="labelFormFields">Update Metrics</span>
                                    </td>
                                    <td>
                                        <select id ="opt_Item_{$itemID}_UpdateMetrics" name="lifespace" class="smallDropdown">
                                            <xsl:choose>
                                                <xsl:when test ="$Metrics = 'Daily'">
                                                    <option value="Daily" selected="selected">Daily</option>
                                                    <option value="Weekly" >Weekly</option>
                                                    <option value="Monthly">Monthly</option>
                                                    <option value="Quaterly">Quaterly</option>
                                                    <option value="Annually">Annually</option>
                                                </xsl:when>
                                                <xsl:when test ="$Metrics = 'Monthly'">
                                                    <option value="Daily" >Daily</option>
                                                    <option value="Weekly">Weekly</option>
                                                    <option value="Monthly" selected="selected">Monthly</option>
                                                    <option value="Quaterly">Quaterly</option>
                                                    <option value="Annually">Annually</option>
                                                </xsl:when>
                                                <xsl:when test ="$Metrics = 'Quaterly'">
                                                    <option value="Daily" >Daily</option>
                                                    <option value="Weekly">Weekly</option>
                                                    <option value="Monthly">Monthly</option>
                                                    <option value="Quaterly" selected="selected">Quaterly</option>
                                                    <option value="Annually">Annually</option>
                                                </xsl:when>
                                                <xsl:when test ="$Metrics = 'Annually'">
                                                    <option value="Daily" >Daily</option>
                                                    <option value="Weekly">Weekly</option>
                                                    <option value="Monthly">Monthly</option>
                                                    <option value="Quaterly">Quaterly</option>
                                                    <option value="Annually" selected="selected">Annually</option>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <option value="Daily" >Daily</option>
                                                    <option value="Weekly" selected="selected">Weekly</option>
                                                    <option value="Monthly">Monthly</option>
                                                    <option value="Quaterly">Quaterly</option>
                                                    <option value="Annually">Annually</option>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </select>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields">Image URL</span>
                    </td>
                    <td>
                        <input id="txt_Item_{normalize-space($itemID)}_Update_ImageURL" type="text"
                              value ="{normalize-space(GoalDetail/Goal/ImageURL)}" class="text" tabindex="3"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields">Start Date</span>
                    </td>
                    <td>
                        <input id="txt_Item_{normalize-space($itemID)}_Update_StartDate" type="text" onblur="checkdate(this)"
                               class="date" value ="{normalize-space(GoalDetail/Goal/StartDate)}" tabindex="4"/>
                        <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif"></img>
                        <img id="img_Item_{normalize-space($itemID)}_Update_StartDate"
                             src="{normalize-space($TemplatePathURL)}Web/Images/CalendarIcon.gif"
                             onclick='dp("txt_Item_{normalize-space($itemID)}_Update_StartDate", "img_Item_{normalize-space($itemID)}_Update_StartDate");'></img>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields">End Date</span>
                    </td>
                    <td>
                        <input id="txt_Item_{normalize-space($itemID)}_Update_EndDate" type="text" onblur="checkdate(this)"
                               runat="server" class="date" value ="{normalize-space(GoalDetail/Goal/EndDate)}" tabindex="5"/>
                        <img src="{normalize-space($TemplatePathURL)}Web/Images/big_spacer.gif"></img>
                        <img id="img_Item_{normalize-space($itemID)}_Update_EndDate"
                             src="{normalize-space($TemplatePathURL)}Web/Images/CalendarIcon.gif"
                             onclick='dp("txt_Item_{normalize-space($itemID)}_Update_EndDate", "img_Item_{normalize-space($itemID)}_Update_EndDate");'></img>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields">Status</span>
                    </td>
                    <td>
                        <select id ="opt_Item_{normalize-space($itemID)}_Update_Status" name="status" class="smallDropdown" tabindex="6">
                            <xsl:for-each select="GoalDetail/Status/ItamStatus">
                                <xsl:if test ="$statusID=ID">
                                    <option value="{ID/.}" selected="selected">
                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                    </option>
                                </xsl:if>
                                <xsl:if test ="$statusID!=ID">
                                    <option value="{ID/.}">
                                        <xsl:value-of select="normalize-space(Name/.)"/>
                                    </option>
                                </xsl:if>
                            </xsl:for-each>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                </tr>
                <tr>
                    <td>
                        <!--<input type="button" class="button" 
                     onclick='return UpdateGoal(
                                         "txt_Item_{normalize-space($itemID)}_Update_Title",
                                         "txt_Item_{normalize-space($itemID)}_Update_Description",
                                         "txt_Item_{normalize-space($itemID)}_Update_StartDate",
                                         "txt_Item_{normalize-space($itemID)}_Update_EndDate",
                                         "opt_Item_{normalize-space($itemID)}_Update_Status",
                                         "divGoalOutlineViewTree",
                                         "divGoalInfo",
                                         "{normalize-space($itemID)}",
                                         "{normalize-space($lblGoalNameID)}",
                                         "span_item_{normalize-space($itemID)}_Update_ErrorMessage","{$divNewGoalTree}",
                                         "divGoalDetailButton", "divWhatsNewButton", "divGoalMonitorButton", "divMyItemsButton", "divSummaryButton");' 
                     value="Update" tabindex="6"></input>-->
                        <input type="button" class="button"
                                 onclick='return Dashboard_UpdateGoal(
                                            "opt_Item_{$itemID}_UpdateMetrics",
                                            "opt_Item_{$itemID}_TrackAmount",
                                            "txt_Item_{$itemID}_StartAmount",
                                            "txt_Item_{$itemID}_TargetWhat",
                                            "txt_Item_{$itemID}_TargetAmount",
                                            "opt_Item_{$itemID}_NumberFormat",
                                            "opt_Item_{$itemID}_DisplayNumbers",
                                             "opt_Item_{normalize-space($itemID)}_Success",
                                             "txt_Item_{normalize-space($itemID)}_Update_Title",
                                             "txt_Item_{normalize-space($itemID)}_Update_Description",
                                             "txt_Item_{normalize-space($itemID)}_Update_StartDate",
                                             "txt_Item_{normalize-space($itemID)}_Update_EndDate",
                                             "opt_Item_{normalize-space($itemID)}_Update_Status",
                                             "{normalize-space($itemID)}",
                                             "div_SelectedGoalItem_Name",
                                             "span_item_{normalize-space($itemID)}_Update_ErrorMessage",
                                             "txt_Item_{normalize-space($itemID)}_Update_ImageURL","UpdateGoal"
                                            );'
                                 value="Save" tabindex="7"></input>
                    </td>
                    <td>
                        <!--<input type="button" class="button"
                     onclick='return CancelGoalUpdate("divGoalOutlineViewTree", "divGoalInfo", "{$divNewGoalTree}", "{$itemID}",
                                        "divGoalDetailButton", "divWhatsNewButton", "divGoalMonitorButton", "divMyItemsButton", "divSummaryButton");'  
                     value="Cancel" tabindex="7"></input>-->
                        <input type="button" class="button" onclick='return CloseItemBox("divGoal_Operations","-99");' value="Cancel" tabindex="8"></input>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>
</xsl:stylesheet>
