﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <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="OwnerID" select="normalize-space(AjaxRequest/ClientsList/Client/OwnerId)"></xsl:variable>
        <!--<xsl:variable name="ModuleKey" select="normalize-space(AjaxRequest/ClientsList/PortalModules/PortalModule/ModuleKey)"></xsl:variable>-->
        

        <table cellpadding ="0" cellspacing ="2" style="margin-left:10px;margin-right:10px;width:100%;">
            <tr>
                <td width="30%"></td>
                <td width="25%"></td>
                <td width="25%"></td>
                <td width="25%"></td>
            </tr>
            <tr style="margin-bottom:25px;">
                <td>
                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Account Name</span>
                </td>
                <td>
                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Account Type</span>
                </td>
                <td>
                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Account Number</span>
                </td>
                <td>
                    <span class="labelHeader" style="color: rgb(55, 96, 146);">Action</span>
                </td>
            </tr>
            <xsl:for-each select ="AjaxRequest/ClientsList/Client">
                <xsl:variable name="PersonUserID" select="PersonUserID"></xsl:variable>
                <xsl:variable name="AccountID" select="AccountID"></xsl:variable>
                <tr>
                    <td>
                        <xsl:choose>
                            <xsl:when test="$PersonUserID and count(../PortalModules/PortalModule[ModuleKey = 'WorkOutTracker' and DisplayModule != 0]) &gt; 0">
                                <span class="link"
                                      onClick="client_GetClientDetail('divClientPortalRight_1','{$ItemID}','{$PersonUserID}','{AccountName}','{AccountID}'); 
                                                    client_GetClientWorkouts('divClientPortalOperations_Container','{$ItemID}','{$PersonUserID}','{AccountID}','Portal');">
                                   <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="link"
                                     onClick="client_GetClientDetail('divClientPortalRight_1','{$ItemID}','{$PersonUserID}','{AccountName}','{AccountID}'); 
                                                    Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'-1','{$PersonUserID}','-99','1');">
                                    <xsl:value-of select ="AccountName"/>
                                </span>
                            </xsl:when>
                            <xsl:otherwise>
                                <span class="link" onClick="client_GetClientDetail('divClientPortalRight_1','{$ItemID}','{ClientUserID}','{Account}','{AccountID}'); 
                                                  Portal_getProjectLists('divClientPortalOperations_Container',{$ItemID},'-1','{ClientUserID}','{AccountID}','1');">
                                    <xsl:value-of select ="AccountName"/>
                                </span>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                    <td>
                        <span class="label">
                            <xsl:value-of select ="AccountType"/>
                        </span>
                    </td>
                    <td>
                        <span class="label">
                            <xsl:value-of select ="AccountNumber"/>
                        </span>
                    </td>
                    <td>                       
                        <input type="button"
                               class="smallButton" value="Edit"
                               onClick="return clientPortal_DisplayAddNewClient('{$ItemID}','divClientPortalOperations_Container','Update','{AccountID}','');">                            
                        </input>
                    </td>
                </tr>
            </xsl:for-each>
            <xsl:choose>
                <xsl:when test="count(AjaxRequest/ClientsList/Client)=0">
                    <tr>
                        <td colspan="4" style="text-align:center;">
                            <div style="padding:15px;">
                                <span class="label">There are no accounts</span>                                
                            </div>
                            <input type="button" class="button" value="Add New Account" 
                                   onClick="return clientPortal_DisplayAddNewClient('{$ItemID}','divClientPortalOperations_Container','Save','0','');"></input>
                        </td>
                    </tr>
                </xsl:when>
                <xsl:otherwise>
                    <tr>
                        <td colspan="4" >
                            <input type="button" class="button" value="Add New Account" style="margin-top:10px;"
                                   onClick="return clientPortal_DisplayAddNewClient('{$ItemID}','divClientPortalOperations_Container','Save','0','');"></input>
                        </td>
                    </tr>
                </xsl:otherwise>
            </xsl:choose>    
        </table>
    </xsl:template>
</xsl:stylesheet>
