﻿<?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/Params/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:call-template name="ClientWorkoutsTemplate">
            <xsl:with-param name ="PortalID" select ="$PortalID"></xsl:with-param>
            <xsl:with-param name ="AccID" select ="$AccID"></xsl:with-param>
            <xsl:with-param name="TemplateURL" select="$TemplateURL"/>
            <xsl:with-param name ="ClientUserID" select ="$ClientUserID"></xsl:with-param>
            <xsl:with-param name="AccountID"  select="$AccountID"></xsl:with-param>
            <xsl:with-param name="AccountName"  select="$AccountName"></xsl:with-param>
            <xsl:with-param name="userID" select="$userID"></xsl:with-param>
            <xsl:with-param name="Origin" select="$Origin"></xsl:with-param>
            <xsl:with-param name="HostName" select="$HostName"></xsl:with-param>
        </xsl:call-template>

    </xsl:template>


    <xsl:template name="ClientWorkoutsTemplate">


        <xsl:param name ="PortalID" select ="'N/A'"></xsl:param>
        <xsl:param name ="AccID" select ="'N/A'"></xsl:param>
        <xsl:param name="TemplateURL" select ="'N/A'"></xsl:param>
        <xsl:param name ="ClientUserID" select ="'N/A'"></xsl:param>
        <xsl:param name="AccountID"  select ="'N/A'"></xsl:param>
        <xsl:param name="AccountName"  select ="'N/A'"></xsl:param>
        <xsl:param name="userID" select ="'N/A'"></xsl:param>
        <xsl:param name="Origin" select ="'N/A'"></xsl:param>
        <xsl:param name="HostName" select ="'N/A'"></xsl:param>

        <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">
            <div align="right">
                <div id="div_AddWorkoutBtn" class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray"
                     style="width:120px;line-height:30px;text-align:center;"
                     onmouseover="document.getElementById('img_AddWorkout').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
                     onmouseout="document.getElementById('img_AddWorkout').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
                     onClick="goal_HightlightSelectedLink('cell_Notes','defaultMenuGoal','selectedMenuGoalTabs','GoalMenuAction',0); 
                              workoutTracker_DisplayWorkOutProgramsList('{$PortalID}','ClientAccount_Operations_Filters','{$ClientUserID}',
                                                                        '{$AccountID}','{$AccountName}','ProgramClientProfile','');
                              document.getElementById('div_workoutHeader').style.display = 'none';">
                    <img id="img_AddWorkout" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" class="marginRight5"></img>
                    <span id="span_Cancel">ADD WORKOUT</span>
                </div>
            </div>
            <xsl:if test="$Origin!='Brand'">
                <div style="text-align:left;">
                    <table>
                        <tr id="tr_WorkoutFilterHeader">
                            <td class="labelFormFields verticallyMiddle">
                                <span class="packageTitle">Display:&#xa0;</span>
                            </td>

                            <td class="publicationSummary">
                                <input id="rdbClientWorkOut_WorkOutList" type="radio" checked="true" name="clientWorkOut" style="line-height:35px"
                                       onClick="client_GetCRMClientWorkouts('ClientAccount_Operations_Filters','{$PortalID}','{$AccID}','');">
                                    <span style="line-height:12px">Workout List</span>
                                </input>
                            </td>
                            <td class="publicationSummary">
                                <input id="rdbClientWorkOut_MonthView" type="radio"  name="clientWorkOut" style="line-height:35px"
                                       onClick="planner_LoadCalendar('','divClientWorkItemsContainer','4','{$PortalID}','{$AccountID}','{$AccountID}','ItemWorkout');
                                                        document.getElementById('div_AddWorkoutBtn').style.display='none';">
                                    <span style="line-height:12px">This Month</span>
                                </input>
                            </td>

                        </tr>
                    </table>
                </div>
            </xsl:if>

            <div id="divClientWorkItemsContainer" style="width: 95%; margin-top: 20px;text-align:center;padding-left:10px;">
                <table cellpadding ="3" cellspacing ="3" 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>
                                    <span class="packageTitle" style="font-size:13px;">Workout</span>
                                </td>
                                <td>
                                    <span class="packageTitle" style="font-size:13px;">Date</span>
                                </td>
                                <td>
                                    <span class="packageTitle" style="font-size:13px;">Added By</span>
                                </td>
                                <td class="textCenter">
                                    <span class="packageTitle" style="font-size:13px;">% Complete</span>
                                </td>
                                <td class="textCenter">
                                    <span class="packageTitle" style="font-size:13px;">Duration</span>
                                </td>
                            </tr>
                            <xsl:for-each select="AjaxRequest/ClientWorkoutDetail/ClientWorkouts">
                                <tr id="tr_WorkoutsList_{WorkoutID}">
                                    <td width="25%" style="padding-left:5px;" class="verticallyMiddle">
                                        <xsl:choose>
                                            <xsl:when test="ApprovedUserID">
                                                 <div class="publicationSummary onMouseOver"                                                    
                                                     onClick="workoutTracker_LoadCompleteWorkoutPopup('{WorkoutID}','{$AccountID}','{$PortalID}','default','ClientAccount_Operations_Filters','workout');">
                                                    <xsl:value-of select="WorkoutName"/>
                                                </div>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <div class="publicationSummary onMouseOver"
                                                    onClick="workout_GetWorkoutView('{WorkoutID}','{$AccountID}','{$PortalID}','ClientAccount_Operations_Filters');">
                                                    <xsl:value-of select="WorkoutName"/>
                                                </div>                                              
                                            </xsl:otherwise>
                                        </xsl:choose>                                                                              
                                    </td>
                                    <td width="15%" nowrap="nowrap" class="verticallyMiddle">
                                        <span id="{WorkoutID}_WorkOut_ItemSelectDate" class="publicationSummary" style="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;">
                                            <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="15%" class="verticallyMiddle">
                                        <span class="publicationSummary sentenceFont">
                                            <xsl:value-of select="DisplayName"/>
                                        </span>
                                    </td>
                                    <td width="15%" class="verticallyMiddle textCenter">
                                        <span class="publicationSummary">
                                            <span>
                                                <xsl:value-of select="CompletedExerciseCount"/>
                                            </span>
                                            <xsl:text>/</xsl:text>
                                            <span>
                                                <xsl:value-of select="TotalExerciseCount"/>
                                            </span>-
                                            <xsl:choose>
                                                <xsl:when test="CompleteExerPercent">
                                                    <xsl:value-of select="CompleteExerPercent"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:text>0</xsl:text>
                                                </xsl:otherwise>
                                            </xsl:choose>%
                                        </span>
                                    </td>
                                    <td width="15%" class=" textCenter">
                                        <span class="publicationSummary">
                                            <xsl:value-of select="Duration"/>
                                        </span>
                                    </td>
                                    <td class="verticallyMiddle">
                                        <select id="ddlWorkoutAdmin_{WorkoutID}" class="smallDropdown" style="width:80px;"
                                                onchange="Workout_SelectWorkoutListAdminOption('ddlWorkoutAdmin_{WorkoutID}','{$PortalID}','{WorkoutID}','tr_WorkoutsList_{WorkoutID}','{$AccountID}');">
                                            <option value="-99">-Select-</option>
                                            <option value="1">Copy</option>
                                            <option value="2">Delete</option>

                                            <option value="3">Print</option>
                                        </select>
                                    </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>
            <xsl:if test="count(AjaxRequest/ClientWorkoutDetail/ClientWorkouts) &gt; 10">
                <div align="right" class="marginTop15">
                    <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:120px;line-height:30px;text-align:center;"
                                                onmouseover="document.getElementById('img_Add2Workout').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
                                                onmouseout="document.getElementById('img_Add2Workout').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
                                                onClick="workoutTracker_DisplayWorkOutProgramsList('{$PortalID}','div_ProgramWorkout','{$ClientUserID}',
                                              '{$AccountID}','{$AccountName}','ProgramClientProfile','');">
                        <img id="img_Add2Workout" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" class="marginRight5"></img>
                        <span id="span_Cancel">ADD WORKOUT</span>
                    </div>
                </div>
            </xsl:if>

            <div id="div_ProgramWorkout"></div>
        </div>
    </xsl:template>
</xsl:stylesheet>
