﻿<?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="AccountName" select="ScheduledWorkouts/AccountName"></xsl:variable>
        <xsl:variable name="PortalName" select="ScheduledWorkouts/PortalName"></xsl:variable>
        <xsl:variable name="ScheduleID" select="ScheduledWorkouts/ScheduleID"></xsl:variable>
        <xsl:variable name="CRMWorkoutScheduleXML" select="ScheduledWorkouts/CRMWorkoutScheduleXML/."></xsl:variable>
        <xsl:variable name="Ticket" select="ScheduledWorkouts/Ticket"></xsl:variable>
        <xsl:variable name="IsExistingUser" select="ScheduledWorkouts/IsExistingUser"></xsl:variable>
        <xsl:variable name="PortalItemID" select="ScheduledWorkouts/PortalItemID"></xsl:variable>
        <xsl:variable name="PatientID" select="ScheduledWorkouts/PatientID"></xsl:variable>
        <xsl:variable name="TargetURL" select="ScheduledWorkouts/CRMWorkoutScheduleXML/CRMWorkoutSchedule/TargetURL"></xsl:variable>
        <xsl:variable name="LogoURL" select="ScheduledWorkouts/CRMWorkoutScheduleXML/CRMWorkoutSchedule/SettingsXML/brandSettings[SettingKey = 'NotificationLogoURLPath']/SettingValue"></xsl:variable>

        <HTML>
            <Body>
                <table width="100%" cellspacing="0" cellpadding="0" style="width: 100.0%; background: #f2f2f2;">
                    <tbody>
                        <tr>
                            <td valign="top" style="padding: 0in 0in 0in 0in; min-height: 10px">
                                <div align="center">
                                    <table width="600" cellspacing="0" cellpadding="0" border="0" style="width: 6.25in;background: #EDEDED">
                                        <tbody>
                                            <tr style="min-height: 7.5pt">
                                                <td width="25" valign="top" style="width: 18.75pt; padding: 0in 0in 0in 0in; min-height: 7.5pt">
                                                    <p style="line-height: 0%;margin:0;">
                                                        <img width="10" height="10" border="0" src="https://www.coachsimple.net/DesktopModules/LifespaceTemplates/Web/Images/Ver_2_0/LtTopInspire.png" />
                                                    </p>
                                                </td>
                                                <td style="padding: 0in 0in 0in 0in; min-height: 7.5pt">
                                                </td>
                                                <td width="25" valign="top" style="width: 18.75pt; padding: 0in 0in 0in 0in; min-height: 7.5pt;min-height: 10px">
                                                    <p align="right" style="text-align: right; line-height: 0%;margin:0;">
                                                        <img width="10" height="10" border="0" src="https://www.coachsimple.net/DesktopModules/LifespaceTemplates/Web/Images/Ver_2_0/RtTopInspire.png" />
                                                    </p>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 0in 0in 0in 0in">
                                                </td>
                                                <td style="padding: 0in 0in 0in 0in">
                                                    <table width="100%" cellspacing="0" cellpadding="0" border="0" style="width: 100.0%">
                                                        <tbody>
                                                            <tr>
                                                                <td style="padding: 0in 0in 0in 0in">
                                                                    <p style="margin:0;">
                                                                        <img height="32" border="0" alt="LifeSpace" src="{$LogoURL}" />
                                                                    </p>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </td>
                                                <td style="padding: 0in 0in 0in 0in">
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <p align="center" style="text-align: center;margin:0;">

                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top" style="padding: 0in 0in 0in 0in">
                                <div align="center">
                                    <table width="600" cellspacing="0" cellpadding="0" border="0" style="width: 6.25in">
                                        <tbody>
                                            <tr>
                                                <td style="padding: 0in 0in 0in 0in">
                                                    <table width="100%" cellspacing="0" cellpadding="0"  style="width: 100.0%;
															background: white; border-top: none; border-left: solid #e4e4e4 1.0pt; border-bottom: none;
															border-right: solid #e4e4e4 1.0pt">
                                                        <tbody>
                                                            <tr>
                                                                <td style="padding: 0.4in 0in 0in 0.3in">
                                                                    <span style="text-decoration:none;font-size: 15.5pt; font-family: Arial,sans-serif; color: #222222; font-weight: normal;">
                                                                        Hi <xsl:value-of select="$AccountName"/>,
                                                                    </span>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding: 0.3in 0in 0in 0.3in">
                                                                    <span style="color: #3088cd; text-decoration: none;font-size: 10.0pt;color: #6D6E71;">
                                                                        A workout in <xsl:value-of select="$PortalName"></xsl:value-of> has been assigned to you for
                                                                        <xsl:for-each select="$CRMWorkoutScheduleXML/Days/child::node()[(.) = 'True']">
                                                                            <xsl:variable name="AllDays" select="."></xsl:variable>
                                                                            <xsl:variable name="Days" select="name(.)"></xsl:variable>

                                                                            <xsl:if test="position() != 1">
                                                                                <span style="margin-right:5px;">
                                                                                    <xsl:text>,</xsl:text>
                                                                                </span>
                                                                            </xsl:if>

                                                                            <xsl:if test="$Days = 'Sunday'">
                                                                                <span>Sunday</span>
                                                                            </xsl:if>
                                                                            <xsl:if test="$Days = 'Monday'">
                                                                                <span>Monday</span>
                                                                            </xsl:if>
                                                                            <xsl:if test="$Days = 'Tuesday'">
                                                                                <span>Tuesday</span>
                                                                            </xsl:if>
                                                                            <xsl:if test="$Days = 'Wednesday'">
                                                                                <span>Wednesday</span>
                                                                            </xsl:if>
                                                                            <xsl:if test="$Days = 'Thursday'">
                                                                                <span>Thursday</span>
                                                                            </xsl:if>
                                                                            <xsl:if test="$Days = 'Friday'">
                                                                                <span>Friday</span>
                                                                            </xsl:if>
                                                                            <xsl:if test="$Days = 'Saturday'">
                                                                                <span>Saturday</span>
                                                                            </xsl:if>
                                                                        </xsl:for-each>
                                                                    </span>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding: 0.3in 0in 0in 0.3in">
                                                                    <xsl:choose>
                                                                        <xsl:when test="$IsExistingUser = 'True'">
                                                                            <span style="color: #3088cd; text-decoration: none;font-size: 10.0pt;color: #6D6E71;">
                                                                                <a href="{$TargetURL}/HomeWorkout.aspx?id={$PortalItemID}&amp;ScheduleID={$ScheduleID}&amp;PatientID={$PatientID}&amp;PTPanel=Patient">Click here </a>to view and log your workout
                                                                            </span>                                                                            
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                            <span style="color: #3088cd; text-decoration: none;font-size: 10.0pt;color: #6D6E71;">
                                                                                <a href="{$TargetURL}/HomeWorkout.aspx?ticket={$Ticket}&amp;PTPanel=Patient">Click here </a>to view and log your workout
                                                                            </span>
                                                                        </xsl:otherwise>
                                                                    </xsl:choose>

                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding: 0.4in 0in 0in 0.3in">
                                                                    <span style="color: #3088cd; text-decoration: none;font-size: 10.0pt;color: #6D6E71;">
                                                                        Sincerely,
                                                                    </span>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="padding: 0.2in 0in 0in 0.3in">
                                                                    <span style="color: #3088cd; text-decoration: none;font-size: 10.0pt;color: #6D6E71;">
                                                                        <xsl:value-of select="$PortalName"/>
                                                                    </span>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <table width="100%" cellspacing="0" cellpadding="0" border="0" style="width: 100.0%;background: white">
                                                        <tbody>
                                                            <tr style="min-height: 7.5pt">
                                                                <td width="10" valign="top" style="width: 7.5pt; background: #f2f2f2; padding: 0in 0in 0in 0in;min-height: 7.5pt; min-height: 10px">
                                                                    <p style="line-height: 0%;margin:0;">
                                                                        <span style="font-size: 1.0pt">
                                                                            <img width="10" height="10" border="0" src="https://www.coachsimple.net/desktopModules/LifespaceTemplates/Web/Images/Ver_2_0/clb_01.png" />

                                                                        </span>
                                                                    </p>
                                                                </td>
                                                                <td valign="bottom" style="padding: 0in 0in 0in 0in; min-height: 7.5pt; min-height: 10px">
                                                                    <table width="100%" cellspacing="0" cellpadding="0" border="0" style="width: 100.0%">
                                                                        <tbody>
                                                                            <tr style="min-height: .75pt">
                                                                                <td style="background: #e4e4e4; padding: 0in 0in 0in 0in; min-height: .75pt; min-height: 1px">
                                                                                    <p style="line-height: 0%;margin:0;">
                                                                                        <span style="font-size: 1.0pt">

                                                                                        </span>
                                                                                    </p>
                                                                                </td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table>
                                                                </td>
                                                                <td width="10" valign="top" style="width: 7.5pt; background: #f2f2f2; padding: 0in 0in 0in 0in;min-height: 7.5pt; min-height: 10px">
                                                                    <p align="right" style="text-align: right; line-height: 0%;margin:0;">
                                                                        <span style="font-size: 1.0pt">
                                                                            <img width="10" height="10" border="0" src="https://www.coachsimple.net/desktopModules/LifespaceTemplates/Web/Images/Ver_2_0/crb_01.png" />
                                                                        </span>
                                                                    </p>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </td>

                                            </tr>
                                            <tr style="min-height: 15.0pt">
                                                <td colspan="2" style="padding: 0in 0in 0in 0in; min-height: 15.0pt; min-height: 20px">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" style="padding: 0in 0in 0in 0in; min-height: 10px">
                                                    <table width="100%" cellspacing="0" cellpadding="0" border="0" style="width: 100.0%;background: white">
                                                        <tbody>
                                                            <tr style="min-height: 7.5pt">
                                                                <td valign="top" style="padding: 0in 0in 0in 0in; min-height: 7.5pt; min-height: 1px">
                                                                    <table width="100%" cellspacing="0" cellpadding="0" border="0" style="width: 100.0%">
                                                                        <tbody>
                                                                            <tr style="min-height: .75pt">
                                                                                <td style="background: #e4e4e4; padding: 0in 0in 0in 0in; min-height: .75pt; border-bottom:solid #e4e4e4 1.0pt;">
                                                                                    <p style="line-height: 0%;margin:0;">
                                                                                        <span style="font-size: 1.0pt">

                                                                                        </span>
                                                                                    </p>
                                                                                </td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </Body>
        </HTML>
    </xsl:template>
</xsl:stylesheet>
