﻿<?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:output method="xml" indent="yes"/>

    <xsl:template match="/">
        <xsl:variable name="PortalItemID" select="AjaxRequest/Params/PortalItemID"></xsl:variable>
        <xsl:variable name="Origin" select="AjaxRequest/Params/Origin"></xsl:variable>
        <xsl:variable name="ProtocolID" select="AjaxRequest/Params/ProtocolID"></xsl:variable>
        <xsl:variable name="ClientAccountID" select="AjaxRequest/Params/ClientAccountID"></xsl:variable>
        <xsl:variable name="TemplateURL" select="AjaxRequest/TemplateURL"></xsl:variable>
        <xsl:variable name="Title" select="AjaxRequest/CRMWorkoutScheduleXML/CRMWorkoutSchedule/Title"></xsl:variable>
        <xsl:variable name="ProtocolName" select="AjaxRequest/CRMWorkoutScheduleXML/ProtocolName"></xsl:variable>
        <xsl:variable name="PatientEmail">
            <xsl:choose>
                <xsl:when test="AjaxRequest/CRMWorkoutScheduleXML/CRMWorkoutSchedule/PatientEmail != ''">
                    <xsl:value-of select="AjaxRequest/CRMWorkoutScheduleXML/CRMWorkoutSchedule/PatientEmail"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="AjaxRequest/CRMWorkoutScheduleXML/Email"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="ActiveYN" select="AjaxRequest/CRMWorkoutScheduleXML/CRMWorkoutSchedule/ActiveYN"></xsl:variable>
        <xsl:variable name="ScheduledDaysXML" select="AjaxRequest/CRMWorkoutScheduleXML/Days/."></xsl:variable>

        <table class="tableMaster" cellpadding="5" cellspacing="5">
            <tr>
                <td>
                    <span class="packageTitle">Title</span>
                </td>
                <td>
                    <xsl:choose>
                        <xsl:when test="$Title != ''">
                            <input id="txt_{$PortalItemID}_{$ProtocolID}_Title" type="text" class="text" value="{$Title}"/>
                        </xsl:when>
                        <xsl:otherwise>
                             <input id="txt_{$PortalItemID}_{$ProtocolID}_Title" type="text" class="text" value="{$ProtocolName}"/>
                        </xsl:otherwise>
                    </xsl:choose>
                   
                </td>
            </tr>
            <tr style="display:none;">
                <td>
                    <span class="packageTitle">Protocol</span>
                </td>
                <td>
                    <input id="txt_{$PortalItemID}_{$ProtocolID}_Protocol" type="text" class="text" value="{$ProtocolName}"/>
                </td>
            </tr>
            <tr>
                <td>
                    <span class="packageTitle">Patient Email</span>
                </td>
                <td>
                    <input id="txt_{$PortalItemID}_{$ProtocolID}_PatientEM" type="text" class="text" value="{$PatientEmail}"/>
                </td>
            </tr>
            <tr>
                <td>
                    <span class="packageTitle">Reminder Days</span>
                    
                </td>
                <td>
                    <xsl:choose>
                        <xsl:when test="$ScheduledDaysXML/Monday = 'True'">
                            <input id="chkMonday" type="checkbox" checked="checked"/>
                            <span class="label">Monday</span>
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="chkMonday" type="checkbox"/>
                            <span class="label">Monday</span>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:choose>
                        <xsl:when test="$ScheduledDaysXML/Tuesday = 'True'">
                            <input id="chkTuesday" type="checkbox" checked="checked"/>
                            <span class="label">Tuesday</span>
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="chkTuesday" type="checkbox"/>
                            <span class="label">Tuesday</span>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:choose>
                        <xsl:when test="$ScheduledDaysXML/Wednesday = 'True'">
                            <input id="chkWednesday" type="checkbox" checked="checked"/>
                            <span class="label">Wednesday</span>
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="chkWednesday" type="checkbox"/>
                            <span class="label">Wednesday</span>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:choose>
                        <xsl:when test="$ScheduledDaysXML/Thursday = 'True'">
                            <input id="chkThursday" type="checkbox" checked="checked"/>
                            <span class="label">Thursday</span>
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="chkThursday" type="checkbox"/>
                            <span class="label">Thursday</span>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:choose>
                        <xsl:when test="$ScheduledDaysXML/Friday = 'True'">
                            <input id="chkFriday" type="checkbox" checked="checked"/>
                            <span class="label">Friday</span>
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="chkFriday" type="checkbox"/>
                            <span class="label">Friday</span>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:choose>
                        <xsl:when test="$ScheduledDaysXML/Saturday = 'True'">
                            <input id="chkSaturday" type="checkbox" checked="checked"/>
                            <span class="label">Saturday</span>
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="chkSaturday" type="checkbox"/>
                            <span class="label">Saturday</span>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:choose>
                        <xsl:when test="$ScheduledDaysXML/Sunday = 'True'">
                            <input id="chkSunday" type="checkbox" checked="checked"/>
                            <span class="label">Sunday</span>
                        </xsl:when>
                        <xsl:otherwise>
                            <input id="chkSunday" type="checkbox"/>
                            <span class="label">Sunday</span>
                        </xsl:otherwise>
                    </xsl:choose>                                        
                </td>
            </tr>
            <tr>
                <td>
                    <span class="packageTitle">Active</span>
                </td>
                <td>
                    <select id="opt_ActiveYN" class="smallDropdown">
                        <xsl:choose>
                            <xsl:when test="$ActiveYN = 1">
                                <option value="1" selected="selected">Yes</option>
                                <option value="0">No</option>
                            </xsl:when>
                            <xsl:when test="$ActiveYN = 0">
                                <option value="1">Yes</option>
                                <option value="0" selected="selected">No</option>
                            </xsl:when>
                            <xsl:otherwise>
                                <option value="1" selected="selected">Yes</option>
                                <option value="0">No</option>
                            </xsl:otherwise>
                        </xsl:choose>
                    </select>                  
                </td>
            </tr>
            <tr>
                <td>

                </td>
                <td>                    
                    <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray marginBottom10 marginTop10"
                         style="width:80px;line-height:30px;text-align:center;float:left;"
                         onmouseover="document.getElementById('img_AddHomeWorkout_{$ProtocolID}').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
                         onmouseout="document.getElementById('img_AddHomeWorkout_{$ProtocolID}').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
                         onClick="SaveHomeWorkout('txt_{$PortalItemID}_{$ProtocolID}_Protocol','txt_{$PortalItemID}_{$ProtocolID}_Title','{$ProtocolID}',
                                                  '{$ClientAccountID}','txt_{$PortalItemID}_{$ProtocolID}_PatientEM','opt_ActiveYN','{$PortalItemID}',
                                                  'chkMonday','chkTuesday','chkWednesday','chkThursday','chkFriday','chkSaturday','chkSunday','{$Origin}');">
                        <img id="img_AddHomeWorkout_{$ProtocolID}" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle"  class="marginRight5"></img>
                        <span id="span_Save">SAVE</span>
                    </div>
                </td>
            </tr>
        </table>
    </xsl:template>
</xsl:stylesheet>
