﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="../Version1.1/Item.xslt"/>
    <xsl:template match="/">
        <xsl:variable name ="FrstDayOfMonth" select ="normalize-space(AjaxRequest/Params/Day)"></xsl:variable>
        <xsl:variable name ="TotalDaysInMonth" select ="normalize-space(AjaxRequest/Params/TotalDays)"></xsl:variable>
        <xsl:variable name ="SelectedDate" select ="normalize-space(AjaxRequest/Params/SelectedDate)"></xsl:variable>
        <xsl:variable name ="Month" select ="normalize-space(AjaxRequest/Params/Month)"></xsl:variable>
        <xsl:variable name ="Year" select ="normalize-space(AjaxRequest/Params/Year)"></xsl:variable>
        <xsl:variable name ="CurrentDay" select ="normalize-space(AjaxRequest/Params/CurrentDay)"></xsl:variable>
        <xsl:variable name ="TemplateURL" select ="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
        <xsl:variable name ="HostName" select ="normalize-space(AjaxRequest/HostName)"></xsl:variable>
        <xsl:variable name ="ItemID" select ="normalize-space(AjaxRequest/Params/ItemID)"></xsl:variable>
        <xsl:variable name ="DivID" select ="normalize-space(AjaxRequest/Params/DivID)"></xsl:variable>
        <xsl:variable name ="Date" select ="normalize-space(AjaxRequest/Params/Date)"></xsl:variable>
        <xsl:variable name ="DisplayDate" select ="normalize-space(AjaxRequest/DisplayDate)"></xsl:variable>
        <xsl:variable name ="Settings" select ="normalize-space(AjaxRequest/Params/Settings)"></xsl:variable>
        <xsl:variable name ="UserID" select ="normalize-space(AjaxRequest/Params/UserID)"></xsl:variable>
        <xsl:variable name ="Origin" select ="normalize-space(AjaxRequest/Params/Origin)"></xsl:variable>
        <xsl:variable name ="ItemTypeID" select ="normalize-space(AjaxRequest/PlannerActiveItems/ItemTypeID)"></xsl:variable>
        <xsl:variable name="LifeSpaceItemID" select="normalize-space(AjaxRequest/PlannerActiveItems/LifeSpaceItemID)"></xsl:variable>
        
        <div id="divPlanner" style="margin:5px;" plannerViewMode="2">
            <table width="100%" cellpadding="0" cellspacing="0" border="0">
                <tr class="trBackColor">
                    <td width="10%" style="text-align:center;">
                        <span id="dayPlannerPerDay" class="labelSize14" style="cursor: pointer;"
                                onClick="planner_ViewByDay('{$SelectedDate}','{$Month}','{$Year}',
                          '{$TotalDaysInMonth}','{$FrstDayOfMonth}','{$DivID}','PrevDay','{$ItemID}','{$UserID}','{$Origin}');">&lt;</span>
                    </td>
                    <td width="80%" style="text-align:center;">
                        <span class="labelSize14">
                            <xsl:value-of select ="$DisplayDate"/>
                        </span>
                    </td>
                    <td width="10%" style="text-align:center;">
                        <span class="labelSize14" style="cursor: pointer;"
                                onClick="planner_ViewByDay('{$SelectedDate}','{$Month}','{$Year}',
                          '{$TotalDaysInMonth}','{$FrstDayOfMonth}','{$DivID}','NextDay','{$ItemID}','{$UserID}','{$Origin}');">&gt;</span>
                    </td>
                </tr>
                <tr class="labelNormalSize11 tdBackColor">
                    <td colspan="3">
                        <div style="padding-left:10px;">
                            <xsl:for-each select ="AjaxRequest/PlannerActiveItems/Items[not(following::GoalID = GoalID)]">
                                <xsl:variable name="GoalID" select="GoalID"></xsl:variable>

                                <div class="seperatorLine">
                                    <a class="labelBoldItalic link" style="color:#003366;"
                                       href="http://{$HostName}/Goal.aspx?ID={GoalID}" target="_blank">
                                        <xsl:value-of select="GoalName"/>
                                    </a>
                                </div>

                                <div id="divActions_{GoalID}" style="display: block; margin-bottom: 20px;">
                                    <xsl:for-each select ="../Items[GoalID = $GoalID]">
                                        <div id="divPlanner_{ItemID}" dateBlock="{$Month+1}/{$SelectedDate}/{$Year}" plannerMode="1" plannerViewMode="2">
                                            <xsl:call-template name="Item">
                                                <xsl:with-param name="ItemDivPrefix">
                                                    <xsl:text>divPlanner</xsl:text>
                                                </xsl:with-param>
                                                <xsl:with-param name="ItemID" select="ItemID"></xsl:with-param>
                                                <xsl:with-param name="ItemName" select="Item"></xsl:with-param>
                                                <xsl:with-param name="TemplatePathURL" select="$TemplateURL"></xsl:with-param>
                                                <xsl:with-param name="ItemSubID" select="ItemSubID"></xsl:with-param>
                                                <xsl:with-param name="ItemSubTitle" select="ItemSubTitle"></xsl:with-param>
                                                <xsl:with-param name="StatusID" select="StatusID"></xsl:with-param>
                                                <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
                                                <xsl:with-param name="OrderBy">
                                                    <xsl:text>-1</xsl:text>
                                                </xsl:with-param>
                                                <xsl:with-param name="PermissionID" select="PermissionID"></xsl:with-param>
                                                <xsl:with-param name="TotalDays" select="TotalDays"></xsl:with-param>
                                                <xsl:with-param name="KeyParameter" select="KeyParameter"></xsl:with-param>
                                                <xsl:with-param name="ItemType" select="TypeID"></xsl:with-param>
                                                <xsl:with-param name="GoalID" select="GoalID"></xsl:with-param>
                                                <xsl:with-param name="DisplayStyle">
                                                    <xsl:text>display:block</xsl:text>
                                                </xsl:with-param>
                                                <xsl:with-param name="MineOrOther" select="normalize-space(MineOrOther)"></xsl:with-param>
                                                <xsl:with-param name="TemplateSourceID" select="TemplateSourceID"></xsl:with-param>
                                                <xsl:with-param name="FirstName" select="ResponsibleName"></xsl:with-param>
                                                <xsl:with-param name="Mode">
                                                    <xsl:text>DayPlanner</xsl:text>
                                                </xsl:with-param>
                                                <xsl:with-param name="OwnerPortalItemID" select="OwnerPortalItemID"></xsl:with-param>
                                            </xsl:call-template>
                                        </div>
                                    </xsl:for-each>
                                </div>
                            </xsl:for-each>
                        </div>
                    </td>
                </tr>
                <tr class="tdBackColor" >
                    <td colspan="3" style="padding-left:30px;padding-top:5px;padding-bottom:5px;text-align:center;">
                        <xsl:choose>
                            <xsl:when test="$ItemTypeID = 5">
                                <span class="link"
                                     onClick="planner_AddNewActionBox({$ItemID},{$LifeSpaceItemID},
                             'div_{$SelectedDate}_{$Month}_{$Year}_operations', 1, '{$Month+1}/{$SelectedDate}/{$Year}')">
                                    Add New Item
                                </span>
                            </xsl:when>
                            <!--<xsl:when test="$ItemTypeID = 3">
                                <span class="link"
                                    onClick="workoutTracker_DisplayWorkOutProgramsList('{$ItemID}',
                             'div_{$SelectedDate}_{$Month}_{$Year}_operations','{$UserID}','{$AccountID}','{$AccountName}','PlannerMode','{$Month+1}/{$SelectedDate}/{$Year}');">
                                    Add New Workout
                                </span>
                            </xsl:when>-->
                            <xsl:otherwise>
                                <!--<span class="link"
                              onClick="planner_GetGoalList('divPlannerAddNew','div_{$SelectedDate}_{$Month}_{$Year}', '{$ItemID}','{$Month+1}/{$SelectedDate}/{$Year}','Planner');">
                                    Add New Item
                                </span>-->

                                <span class="link" 
                                      onClick="planner_GetGoalList(event,'divPlannerAddNew','div_{$SelectedDate}_{$Month}_{$Year}', '{$ItemID}','{$Month+1}/{$SelectedDate}/{$Year}','Planner');">
                                    Add New Item
                                </span>
                                
                            </xsl:otherwise>
                        </xsl:choose>
                        <span class="link" style="margin-left:50px;"
                              onClick="planner_ViewByMonth('{$SelectedDate}','{$Month}','{$Year}',
                                    '{$DivID}','','{$ItemID}','{$Settings}','{$UserID}','{$Origin}');">View Month</span>
                        <span id="dayPlannerRefreshCall" class="labelSize14" style="cursor: pointer;display:none;"
                              onClick="planner_ViewByDay('{$SelectedDate}','{$Month}','{$Year}',
                          '{$TotalDaysInMonth}','{$FrstDayOfMonth}','{$DivID}','','{$ItemID}','{$UserID}','{$Origin}');"></span>
                    </td>
                </tr>
                <tr class="tdBackColor">
                    <td colspan="3">
                        <div id="div_{$SelectedDate}_{$Month}_{$Year}" style="margin:2px;"
                dateBlock="{$Month+1}/{$SelectedDate}/{$Year}" name="collapsed">

                            <itemExpansionStatus id="div_{$SelectedDate}_{$Month}_{$Year}_expansionStatus" status="collapsed"></itemExpansionStatus>

                            <div id="div_{$SelectedDate}_{$Month}_{$Year}_operations" style="padding-left:30px;position:absolute;display:none;border: 2px solid black;padding: 5px;
                                             background-color:#FFFFFF;visibility: visible; width:600px;"
                     IsPlannerOperations="1"></div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>

</xsl:stylesheet>
