﻿<?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:import href="WorkoutProgramList.xslt"/>
    <xsl:output method="xml" indent="no" omit-xml-declaration ="yes"/>



    <xsl:template match="/">
        <xsl:variable name ="PortalID" select ="AjaxRequest/Params/PortalItemID"></xsl:variable>
        <xsl:variable name ="AccID" select ="AjaxRequest/Params/ClientUserID"></xsl:variable>
        <xsl:variable name="TemplateURL" select="AjaxRequest/TemplateURL"/>
        <xsl:variable name ="ClientUserID" select ="normalize-space(AjaxRequest/Params/ClientUserID)"></xsl:variable>
        <xsl:variable name="AccountID"  select="AjaxRequest/ClientWorkoutDetail/ClientWorkouts/AccountID"></xsl:variable>
        <xsl:variable name="AccountName"  select="AjaxRequest/ClientWorkoutDetail/ClientWorkouts/AccountName"></xsl:variable>
        <xsl:variable name="userID" select="AjaxRequest/Params/UserID"></xsl:variable>
        <xsl:variable name="Origin" select="AjaxRequest/Params/Origin"></xsl:variable>
        <xsl:variable name="HostName" select="AjaxRequest/HostName"></xsl:variable>
        <xsl:variable name="divWorkout">
            <xsl:choose>
                <xsl:when test="$Origin='Brand'">
                    <xsl:text>divBrandWorkOutTrackerPlanner</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>divClientPortalOperations_Container</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <div id="div_{$AccID}_ItemWorkout">
            <xsl:if test="$Origin!='Brand'">
                <div style="width:100%; text-align:right;margin-top:-40px;margin-bottom:20px;margin-left:20px;" id="divFullScreenModeIcon">
                    <img border="0" onclick="workout_ExpandToFullScreen('{$AccID}','ItemWorkOut');" class="link"
                         title="Full Screen" src="{$TemplateURL}/Web/Images/full_screen.png" width="20" height="20"></img>
                </div>
                <input type="hidden" id="txtWorkoutDisplayMode" value="Min"></input>
            </xsl:if>

            <div id="div_btnWorkout" style="margin-bottom:20px;margin-left:10px;text-align:left;">
                <!--<input type="button" class="button" value="Add Workout" 
                       onclick="workoutTracker_AddWorkoutFromWorkoutList('{$PortalID}','divClientPortalOperations_Container','{$ClientUserID}','{$AccountID}');"></input>-->
                <input type="button" class="button" value="Add Workout"
                       onClick="workoutTracker_DisplayWorkOutProgramsList('{$PortalID}','{$divWorkout}','{$ClientUserID}',
                                              '{$AccountID}','{$AccountName}','NotPlanner','');"></input>
            </div>

            <!--<div id="div_WorkoutList_Operations" style="display:none;">
               
            </div>-->
            <xsl:if test="$Origin!='Brand'">
                <div style="text-align:left;">
                    <table>
                        <tr>
                            <td class="labelFormFields">
                                <span class="labelSize11">Display:&#xa0;</span>
                            </td>
                            <xsl:choose>
                                <xsl:when test ="$ClientUserID = '-99'">
                                    <td class="labelFormFields">
                                        <input id="rdbClientWorkOut_WorkOutList" type="radio" checked="true" name="clientWorkOut"
                                               onClick="client_GetClientWorkouts('{$divWorkout}','{$PortalID}','-99','-99','Portal');">Workout List</input>
                                    </td>
                                    <td class="labelFormFields">
                                        <input id="rdbClientWorkOut_MonthView" type="radio" name="clientWorkOut"
                                               onClick="planner_LoadCalendar('','divClientWorkItemsContainer','4','{$PortalID}','-99','-99','ItemWorkout');">This Month</input>
                                    </td>
                                </xsl:when>
                                <xsl:otherwise>
                                    <td class="labelFormFields">
                                        <input id="rdbClientWorkOut_WorkOutList" type="radio" checked="true" name="clientWorkOut"
                                               onClick="client_GetClientWorkouts('{$divWorkout}','{$PortalID}','{$AccID}','{$AccountID}','Portal');">Workout List</input>
                                    </td>
                                    <td class="labelFormFields">
                                        <input id="rdbClientWorkOut_MonthView" type="radio" name="clientWorkOut"
                                               onClick="planner_LoadCalendar('','divClientWorkItemsContainer','4','{$PortalID}','{$AccID}','{$AccountID}','ItemWorkout');">This Month</input>
                                    </td>
                                </xsl:otherwise>
                            </xsl:choose>

                        </tr>
                    </table>
                </div>
            </xsl:if>

            <div id="divClientWorkItemsContainer" style="width: 95%; margin-top: 20px;text-align:center;padding-left:10px;">
                <table cellpadding ="0" cellspacing ="0" width="100%">
                    <xsl:choose>
                        <xsl:when test="count(AjaxRequest/ClientWorkoutDetail/ClientWorkouts)>0">
                            <xsl:variable name="display">
                                <xsl:choose>
                                    <xsl:when test="$ClientUserID &lt;0">
                                        <xsl:text>display:block;</xsl:text>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:text>display:none;</xsl:text>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:variable>
                            <tr style="margin-bottom:25px;">
                                <td style="{$display}">
                                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Client</span>
                                </td>
                                <td>
                                    <span class="labelHeader" style="color: rgb(55, 96, 146);padding-left:5px;">Workout</span>
                                </td>
                                <td>
                                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Date</span>
                                </td>
                                <td>
                                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Status</span>
                                </td>
                                <td>
                                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Time</span>
                                </td>
                                <td>
                                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Miles</span>
                                </td>
                                <td>
                                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Cals</span>
                                </td>
                            </tr>
                            <xsl:for-each select="AjaxRequest/ClientWorkoutDetail/ClientWorkouts">
                                <tr>
                                    <td width="23%" style="{$display}">
                                        <span class="link"
                                              onClick="client_GetClientDetail('divClientPortalRight_1','{PortalItemID}','{ResponsibleID}','{AccountName}','{AccountID}'); 
                                                client_GetClientWorkouts('{$divWorkout}','{PortalItemID}','{ResponsibleID}','{AccountID}','Portal');">
                                            <xsl:value-of select="DisplayName"/>
                                        </span>
                                    </td>
                                    <td width="28%" style="padding-left:5px;">
                                        <div class="link"
                                              onClick="client_GetClientDetail('divClientPortalRight_1','{PortalItemID}','{ResponsibleID}','{AccountName}','{AccountID}');                                                    
                                  workoutTracker_GetWorkoutDetail('{ItemID}','{$divWorkout}','{PortalItemID}','1','NotPlanner',-99);">
                                            <xsl:value-of select="WorkoutName"/>
                                        </div>
                                        <!--<div style="margin-top:2px;">
                                            <a href="http://{$HostName}/workout.aspx?id={ItemID}" target="_blank" class="link" style="color:green;">[ Workout Sheet ]</a>
                                        </div>-->
                                    </td>
                                    <td width="17%" nowrap="nowrap">
                                        <span id="{WorkoutID}_WorkOut_ItemSelectDate" class="label" style="color: black;margin-right:5px;"
                                              name="&lt;OperationalData&gt;&lt;WorkOutID&gt;{WorkoutID}&lt;/WorkOutID&gt;&lt;WorkOutItemID&gt;{ItemID}&lt;/WorkOutItemID&gt;&lt;Mode&gt;WorkOutDetail&lt;/Mode&gt;&lt;Origin&gt;{$Origin}&lt;/Origin&gt;&lt;StatusID&gt;{StatusID}&lt;/StatusID&gt;&lt;ItemDivPrefix&gt;{WorkoutID}_WorkOut_ItemSelectDate&lt;/ItemDivPrefix&gt;&lt;/OperationalData&gt;"
                                              onmouseover="this.style.textDecoration='underline'; this.style.cursor='pointer';"
                                              onmouseout="this.style.textDecoration='none';"
                                              onclick='dp("{WorkoutID}_WorkOut_ItemSelectDate", 
                                      "{WorkoutID}_WorkOut_ItemSelectDate")'>
                                            <xsl:value-of  select="DueDate"/>
                                        </span>
                                        <input id="{WorkoutID}_WorkOut_ItemSelectDate_txt"
                                                   type="text" class="dateTextBox" value="{DueDate}" style="display: none;">
                                        </input>
                                    </td>
                                    <td width="17%">
                                        <span class="label">
                                            <xsl:value-of select="Status"/>
                                        </span>
                                    </td>
                                    <td width="12%">
                                        <span class="label">
                                            <xsl:choose>
                                                <xsl:when test="TotalTimeMins='0.00'">
                                                    <span class="labelComment" style="font-size:10pt;">0.00</span>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:value-of select="TotalTimeMins"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </span>
                                    </td>
                                    <td width="12%">
                                        <span class="label">
                                            <xsl:choose>
                                                <xsl:when test="TotalDistanceMiles='0.00'">
                                                    <span class="labelComment" style="font-size:10pt;">0.00</span>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:value-of select="TotalDistanceMiles"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </span>
                                    </td>
                                    <td width="13%">
                                        <span class="label">
                                            <xsl:choose>
                                                <xsl:when test="TotalCaloriesCals='0.00'">
                                                    <span class="labelComment" style="font-size:10pt;">0.00</span>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:value-of select="TotalCaloriesCals"/>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </span>
                                    </td>
                                  <td>
                                    <input type="button" style="margin-bottom:2px;" class="smallButton" value="Copy"
                                           onclick="copyCompleteWorkout('{PortalItemID}','{ItemID}', 'divClientPortalOperations_Container','{AccountID}');"></input>
                        
                                  </td>
                                </tr>
                              <tr>
                                <td colspan="6" style="margin-top:10px;" id="td_StartWorkoutProgram_{PortalItemID}_{ItemID}_Operations" targetDiv="div_{PortalItemID}_{ItemID}_Operations">
                                  <itemExpansionStatus id="td_StartWorkoutProgram_{PortalItemID}_{ItemID}_Operations_expansionStatus" status="collapsed"></itemExpansionStatus>
                                  <div id="div_{PortalItemID}_{ItemID}_Operations"
                                       style="display:none;padding:10px;border:1px solid #385D8A;width:95%" name="collapsed">
                                  </div>
                                </td>
                              </tr>
                            </xsl:for-each>
                        </xsl:when>
                        <xsl:otherwise>
                            <tr>
                                <td colspan="6" style="text-align:center;">
                                    <div style="padding:15px;">
                                        <span class="label">There are no workouts.</span>
                                    </div>
                                </td>
                            </tr>
                        </xsl:otherwise>
                    </xsl:choose>
                </table>
            </div>

            <div id="div_btnWorkout" style="margin-top:20px;margin-left:10px;margin-bottom:20px;text-align:left;">
                <!--<input type="button" class="button" value="Add Workout" 
                       onclick="workoutTracker_AddWorkoutFromWorkoutList('{$PortalID}','divClientPortalOperations_Container','{$ClientUserID}','{$AccountID}');"></input>-->
                <input type="button" class="button" value="Add Workout"
                      onClick="workoutTracker_DisplayWorkOutProgramsList('{$PortalID}','{$divWorkout}','{$ClientUserID}',
                                              '{$AccountID}','{$AccountName}','NotPlanner','');"></input>
            </div>
          
        </div>
    </xsl:template>
</xsl:stylesheet>
