﻿<?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="ItemID" select="normalize-space(AjaxRequest/Params/ItemID)" />
        <xsl:variable name="HostName" select="normalize-space(AjaxRequest/HostName)"></xsl:variable>
        <xsl:variable name="TemplateURL" select="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
        <xsl:variable name="TotalPages" select="AjaxRequest/ClientsList/TotalPages"></xsl:variable>


        <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <div id="div_PatientList" class="marginTop20">
                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <xsl:call-template name="AddNewAccount">
                                        <xsl:with-param name="ClientXML" select="AjaxRequest/ClientsList/Client"></xsl:with-param>
                                        <xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
                                        <xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
                                    </xsl:call-template>
                                    <table cellpadding ="3" cellspacing ="3" style="margin-left:10px;margin-right:10px;width:100%;">
                                        <xsl:if test="count(AjaxRequest/ClientsList/Client) &gt; 0">
                                            <tr>
                                                <td width="10%"></td>
                                                <td width="20%"></td>
                                                <td width="25%"></td>
                                                <td width="25%"></td>
                                                <td width="25%"></td>
                                            </tr>
                                            <tr>
                                                <td></td>
                                                <td>
                                                    <span class="packageTitle" style="font-size:14px;">Patient Name</span>
                                                </td>
                                                <td>
                                                    <span class="packageTitle" style="font-size:14px;">Patient Type</span>
                                                </td>
                                                <td>
                                                    <span class="packageTitle" style="font-size:14px;">Account Number</span>
                                                </td>
                                                <td>
                                                    <span class="packageTitle" style="font-size:14px;">Admin</span>
                                                </td>
                                            </tr>
                                        </xsl:if>
                                        <xsl:for-each select="AjaxRequest/ClientsList/Client">
                                            <xsl:variable name="PersonUserID" select="PersonUserID"></xsl:variable>
                                            <xsl:variable name="AccountID" select="AccountID"></xsl:variable>
                                            <tr id="tr_Client_{AccountID}">
                                                <td class="verticallyMiddle">
                                                    <xsl:choose>
                                                        <xsl:when test="AccountImageURL != ''">
                                                            <img src="{AccountImageURL}" onload="setWidthAndHeightImage(this,'60');" style="display:none;cursor:pointer;"
                                                                 onClick="client_GetClientDetail('divClientPortalOperations_Container','{$ItemID}','{$PersonUserID}','{AccountName}','{AccountID}','yes');"></img>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <img src="{$TemplateURL}Web/Images/DefaultImage.JPG" onload="setWidthAndHeightImage(this,'60');" style="display:none;cursor:pointer;"
                                                                 onClick="client_GetClientDetail('divClientPortalOperations_Container','{$ItemID}','{$PersonUserID}','{AccountName}','{AccountID}','yes');"></img>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </td>
                                                <td class="verticallyMiddle">
                                                    <xsl:choose>
                                                        <xsl:when test="$PersonUserID and count(../PortalModules/PortalModule[ModuleKey = 'WorkOutTracker' and DisplayModule != 0]) &gt; 0">
                                                            <span class="packageTitle onMouseOver sentenceFont"
                                                                  onClick="client_GetClientDetail('divClientPortalOperations_Container','{$ItemID}','{$PersonUserID}','{AccountName}','{AccountID}','yes');">
                                                                <xsl:value-of select="AccountName"/>
                                                            </span>
                                                        </xsl:when>
                                                        <xsl:when test="$PersonUserID and  count(../PortalModules/PortalModule[ModuleKey = 'Oppurtunities' and DisplayModule != 0]) &gt; 0">
                                                            <span class="packageTitle onMouseOver sentenceFont"
                                                                 onClick="client_GetClientDetail('divClientPortalOperations_Container','{$ItemID}','{$PersonUserID}','{AccountName}','{AccountID}','yes');">
                                                                <xsl:value-of select="AccountName"/>
                                                            </span>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <span class="packageTitle onMouseOver sentenceFont"
                                                                  onClick="client_GetClientDetail('divClientPortalOperations_Container','{$ItemID}','{ClientUserID}','{Account}','{AccountID}','yes');">
                                                                <xsl:value-of select="AccountName"/>
                                                            </span>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </td>
                                                <td class="verticallyMiddle">
                                                    <span class="publicationSummary">
                                                        <xsl:value-of select="AccountType"/>
                                                    </span>
                                                </td>
                                                <td class="verticallyMiddle">
                                                    <span class="publicationSummary">
                                                        <xsl:value-of select="AccountNumber"/>
                                                    </span>
                                                </td>
                                                <td class="verticallyMiddle">
                                                    <select id="optAdminClient_{AccountID}" class="smallDropdown"
                                                            onchange="selectAdminOptionForPatientList('optAdminClient_{AccountID}','{$ItemID}','divClientPortalOperations_Container','Update','{AccountID}','tr_Client_{AccountID}');">
                                                        <option value="-99">-Select-</option>
                                                        <option value="1">Edit</option>
                                                        <option value="2">Delete</option>
                                                    </select>
                                                </td>
                                            </tr>
                                        </xsl:for-each>
                                    </table>
                                </td>
                            </tr>
                        </table>

                        <xsl:if test="$TotalPages &gt; 1">
                            <div class="verticallyMiddle textCenter marginTop15">
                                <span class="labelGoalTitle" style='font-size:22px;'>Page :</span>
                                <xsl:for-each select="(//*)[position() &lt;= $TotalPages]">
                                    <xsl:variable name="position" select="position()"></xsl:variable>
                                    <span class='onMouseOver marginLeft5 marginRight5 packageTitle' style='font-size:18px;'
                                          onclick="LoadPatientListXML('div_PatientList',{$ItemID},'10', '{$position}');">
                                        <xsl:value-of select="position()"/>
                                    </span>
                                </xsl:for-each>
                            </div>
                        </xsl:if>
                    </div>
                </td>
            </tr>
        </table>
    </xsl:template>


    <xsl:template name="AddNewAccount">
        <xsl:param name="ClientXML" select="'N/A'"></xsl:param>
        <xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>


        <table class="tableMaster" cellpadding ="0" cellspacing ="2" width="100%">
            <xsl:choose>
                <xsl:when test="count(AjaxRequest/ClientsList/Client)=0">
                    <tr>
                        <td colspan="4" style="text-align:center;">
                            <div style="padding:15px;">
                                <span class="packageTitle">There are no patients</span>
                            </div>
                            <div align="center">
                                <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:160px;line-height:30px;text-align:center;"
                                 onmouseover="document.getElementById('img_Add2Client').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
                                 onmouseout="document.getElementById('img_Add2Client').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
                                 onClick="return clientPortal_DisplayAddNewPatient('{$ItemID}','divClientPortalOperations_Container','Save','0','PatientAdmin');">
                                    <img id="img_Add2Client" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
                                    <span id="span_Cancel">ADD A PATIENT</span>
                                </div>
                            </div>
                        </td>
                    </tr>
                </xsl:when>
                <xsl:otherwise>
                    <tr>
                        <td colspan="4">
                            <div align="right">
                                <div class="verticallyMiddle onMouseOver divBrowseGradient spanBrowseGradientTextGray" style="width:160px;line-height:30px;text-align:center;"
                                 onmouseover="document.getElementById('img_Add2Client').src='{$TemplateURL}Web/Images/Ver_2_0/icon_add_over.png';"
                                 onmouseout="document.getElementById('img_Add2Client').src='{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png';"
                                 onClick="return clientPortal_DisplayAddNewPatient('{$ItemID}','divClientPortalOperations_Container','Save','0','PatientAdmin');">
                                    <img id="img_Add2Client" src="{$TemplateURL}Web/Images/Ver_2_0/icon_Add.png" align="absmiddle" style="padding-left:8px;" class="marginRight5"></img>
                                    <span id="span_Cancel">ADD A PATIENT</span>
                                </div>
                            </div>
                        </td>
                    </tr>
                </xsl:otherwise>
            </xsl:choose>
        </table>
    </xsl:template>
</xsl:stylesheet>
