<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:variable name="payeeHeading">
        <xsl:choose>
            <xsl:when test="(/Root/Access/rps/publisher/search or /Root/Access/rps/ca_publisher/search) and (/Root/Access/rps/artist_payee/search or /Root/Access/rps/label_payee/search)">Publisher/Payee</xsl:when>
            <xsl:when test="/Root/Access/rps/publisher/search or /Root/Access/rps/ca_publisher/search">Publisher</xsl:when>
            <xsl:otherwise>Payee</xsl:otherwise>
        </xsl:choose>        
    </xsl:variable>

    <xsl:template name="payeeMainLayout">
        <div id="payeeMain">        
            <div class="section">
                <table class="landingPage">
                    <tr>
                        <xsl:call-template name="addSection" />
                        <xsl:call-template name="viewSection" />
                    </tr>
                </table>
            </div>
            <xsl:call-template name="searchSection" />
            <xsl:call-template name="recentList" />
        </div>
    </xsl:template>

    <xsl:template name="addSection">
        <td class="landingAdd">
            <h2>Add <xsl:value-of select="$payeeHeading" /></h2>
            <table>
                <tr>
                    <td>
                        <xsl:if test="Access/rps/publisher/edit and Access/rps/ca_publisher/edit">
                            <a href="javascript:getAreaFromDropDown('edit','editPublisherArea')" title="Add New Publisher"><img src="/production/images/icons/office/Add-(16x16).gif" /></a> <a href="javascript:getAreaFromDropDown('edit','editPublisherArea')">Add New Publisher </a>
                            <select name="editPublisherArea" id="editPublisherArea">
                                <option value="ca_publisher">Canadian</option>
                                <option value="publisher">
                                    <xsl:if test="EditPublisherArea = 'publisher'">
                                        <xsl:attribute name="selected">selected</xsl:attribute>
                                    </xsl:if>
                                    United States
                                </option>
                            </select>
                            <br /><br />                        
                        </xsl:if>
                        <xsl:if test="Access/rps/publisher/edit and not(Access/rps/ca_publisher/edit)">
                            <a href="/rps/publisher?c=edit" title="Add New Publisher (United States)"><img src="/production/images/icons/office/Add-(16x16).gif" /></a> <a href="/rps/publisher?c=edit">Add New Publisher (United States)</a>
                            <br /><br />
                        </xsl:if>
                        <xsl:if test="Access/rps/ca_publisher/edit and not(Access/rps/publisher/edit)">
                            <a href="/rps/ca_publisher?c=edit" title="Add New Publisher (Canadian)"><img src="/production/images/icons/office/Add-(16x16).gif" /></a> <a href="/rps/ca_publisher?c=edit">Add New Publisher (Canadian)</a>
                            <br /><br />
                        </xsl:if>
                        <xsl:if test="Access/rps/artist_payee/edit">
                            <a href="/rps/artist_payee?c=edit" title="Add New Artist/Producer Payee"><img src="/production/images/icons/office/Add-(16x16).gif" /></a> <a href="/rps/artist_payee?c=edit">Add New Artist/Producer Payee</a>
                            <br /><br />
                        </xsl:if>
                        <xsl:if test="Access/rps/label_payee/edit">
                            <a href="/rps/label_payee?c=edit" title="Add New Label Payee"><img src="/production/images/icons/office/Add-(16x16).gif" /></a> <a href="/rps/label_payee?c=edit">Add New Label Payee</a>
                        </xsl:if>
                    </td>
                </tr>
            </table>
        </td>
    </xsl:template>


    <xsl:template name="viewSection">
        <td class="landingView">
            <h2>View <xsl:value-of select="$payeeHeading" /></h2>
            <ul>
                <xsl:if test="Access/rps/ca_publisher/list and Access/rps/publisher/list">
                    <li>For Music Works: 
                        <select name="listPublisherArea" id="listPublisherArea">
                            <option value="ca_publisher">Canadian</option>
                            <option value="publisher">
                                    <xsl:if test="ListPublisherArea = 'publisher'">
                                        <xsl:attribute name="selected">selected</xsl:attribute>
                                    </xsl:if>                           
                                United States
                            </option>
                        </select>
                        <ul>
                            <li><a href="javascript:getAreaFromDropDown('list','listPublisherArea')">All Publishers</a></li>
                            <li><a href="javascript:getAreaFromDropDown('list&amp;filter=direct','listPublisherArea')">Direct Publishers</a></li>
                            <li><a href="javascript:getAreaFromDropDown('list&amp;filter=hasAdmin','listPublisherArea')">Publishers with Admin Only</a></li>
                            <li><a href="javascript:getAreaFromDropDown('list&amp;filter=hasAgent','listPublisherArea')">Publishers with Agent</a></li>
                            <li><a href="javascript:getAreaFromDropDown('list&amp;filter=admin','listPublisherArea')">Administrators</a></li>
                            <li><a href="javascript:getAreaFromDropDown('list&amp;filter=agent','listPublisherArea')">Agents</a></li>
                        </ul>
                    </li>
                </xsl:if>               
                <xsl:if test="Access/rps/ca_publisher/list and not(Access/rps/publisher/list)">
                    <li>For Music Works:
                        <ul>
                            <li><a href="/rps/ca_publisher?c=list">All Publishers</a></li>
                            <li><a href="/rps/ca_publisher?c=list&amp;filter=direct">Direct Publishers</a></li>
                            <li><a href="/rps/ca_publisher?c=list&amp;filter=hasAdmin">Publishers with Admin Only</a></li>
                            <li><a href="/rps/ca_publisher?c=list&amp;filter=hasAgent">Publishers with Agent</a></li>
                            <li><a href="/rps/ca_publisher?c=list&amp;filter=admin">Administrators</a></li>
                            <li><a href="/rps/ca_publisher?c=list&amp;filter=agent">Agents</a></li>
                        </ul>
                    </li>
                </xsl:if>           
                <xsl:if test="Access/rps/publisher/list and not(Access/rps/ca_publisher/list)">
                    <li>For Music Works:
                        <ul>
                            <li><a href="/rps/publisher?c=list">All Publishers</a></li>
                            <li><a href="/rps/publisher?c=list&amp;filter=direct">Direct Publishers</a></li>
                            <li><a href="/rps/publisher?c=list&amp;filter=hasAdmin">Publishers with Admin Only</a></li>
                            <li><a href="/rps/publisher?c=list&amp;filter=hasAgent">Publishers with Agent</a></li>
                            <li><a href="/rps/publisher?c=list&amp;filter=admin">Administrators</a></li>
                            <li><a href="/rps/publisher?c=list&amp;filter=agent">Agents</a></li>
                        </ul>
                    </li>
                </xsl:if>
                <xsl:if test="Access/rps/artist_payee/list">
                    <li>For Sound Recordings:
                        <ul>
                            <li><a href="/rps/artist_payee?c=list">Artist/Producer Payees</a></li>
                        </ul>
                    </li>
                </xsl:if>
                <xsl:if test="Access/rps/label_payee/list">
                    <li>For Distribution:
                        <ul>
                            <li><a href="/rps/label_payee?c=list">Label Payees</a></li>
                        </ul>
                    </li>
                </xsl:if>
            </ul>
        </td>
    </xsl:template>

    <xsl:template name="searchSection">
        <div class="section landingSearch">
            <table>
                <tr>
                    <td>
                        <form method="get" name="payeeLandingSearch" id="payeeLandingSearch">
                            <xsl:attribute name="action">
                                <xsl:choose>
                                    <xsl:when test="Access/rps/artist_payee/search">artist_payee</xsl:when>
                                    <xsl:when test="Access/rps/label_payee/search">label_payee</xsl:when>        
                                    <xsl:when test="Access/rps/ca_publisher/search">ca_publisher</xsl:when>         
                                    <xsl:when test="Access/rps/publisher/search">publisher</xsl:when>
                                </xsl:choose>                       
                            </xsl:attribute>
                            <input type="hidden" name="c" value="search" />
                            <label for="payeeSearch">Search: </label>
                            <select name="searchType" onChange="updateSearchAction('payeeLandingSearch',this.value)">
                                <xsl:if test="Access/rps/artist_payee/search">
                                    <option value="artist_payee">Artist/Producer Payees</option>
                                </xsl:if>
                                <xsl:if test="Access/rps/label_payee/search">
                                    <option value="label_payee">Label Payees</option>
                                </xsl:if>                           
                                <xsl:if test="Access/rps/ca_publisher/search">
                                    <option value="ca_publisher">Publishers (Canadian)</option>
                                </xsl:if>                           
                                <xsl:if test="Access/rps/publisher/search">
                                    <option value="publisher">Publishers (United States)</option>
                                </xsl:if>
                            </select>
                            <input type="text" name="Query" id="payeeSearch" class="searchField" />
                            <input type="submit" name="go" value="Go" />
                            <br />
                            <span class="subtle">
                                <xsl:choose>
                                    <xsl:when test="Access/rps/publisher/search and (Access/rps/artist_payee/search or Access/rps/label_payee/search)">
                                        Search by publisher or payee name.
                                    </xsl:when>
                                    <xsl:when test="Access/rps/publisher/search">
                                        Search by publisher name.
                                    </xsl:when>
                                    <xsl:otherwise>
                                        Search by payee name.
                                    </xsl:otherwise>
                                </xsl:choose>
                            </span>
                        </form>
                        </td>
                    </tr>
                </table>
        </div>
    </xsl:template>

    <xsl:template name="recentList">
        <div class="section">
            <h2>Most Recently Accessed Payees</h2>
            <xsl:if test="RecentlyViewed/Item">
                <table class="textChart hiOn">
                  <tr>
                    <th class="rowLeft">Name</th>
                    <th>Type</th>
                      <th>Client Account #</th>
                    <th class="editCol">Edit</th>
                    </tr>
                    <xsl:for-each select="RecentlyViewed/Item">
                        <xsl:if test="ArtistPayee">
                            <xsl:call-template name="artistPayeeRow" />
                        </xsl:if>
                        <xsl:if test="LabelPayee">
                            <xsl:call-template name="labelPayeeRow" />
                        </xsl:if>
                        <xsl:if test="Publisher">
                            <xsl:call-template name="publisherRow" />
                        </xsl:if>
                        <xsl:if test="CAPublisher">
                            <xsl:call-template name="caPublisherRow" />
                        </xsl:if>                       
                     </xsl:for-each>
                </table>
            </xsl:if>
            <xsl:if test="not(RecentlyViewed/Item)">
                <p>No payees exist in your viewing history.</p>
            </xsl:if>
        </div>
    </xsl:template>
 
 
    <xsl:template name="artistPayeeRow">
      <tr class="row{position() mod 2}">
        <td>
            <a href="artist_payee?c=show&amp;ArtistPayeeID={ArtistPayee/ArtistPayeeID}"><xsl:value-of select="ArtistPayee/Name" /></a>
        </td>
        <td>Artist/Producer</td>
        <td><xsl:value-of select="ArtistPayee/ClientAccountID" /></td>
        <td class="icon">
            <a href="artist_payee?c=edit&amp;ArtistPayeeID={ArtistPayee/ArtistPayeeID}" title="Edit">
            <img src="/production/images/icons/office/Edit-(16x16).gif" />
            </a>
        </td>
      </tr>  
    </xsl:template>
    
    
    <xsl:template name="labelPayeeRow">
        <tr class="row{position() mod 2}">
            <td>
                <a href="label_payee?c=show&amp;LabelPayeeID={LabelPayee/LabelPayeeID}"><xsl:value-of select="LabelPayee/Name" /></a>
            </td>
            <td>Label</td>
          <td><xsl:value-of select="LabelPayee/ClientAccountID" /></td>
            <td class="icon">
                <a href="label_payee?c=edit&amp;LabelPayeeID={LabelPayee/LabelPayeeID}" title="Edit">
            <img src="/production/images/icons/office/Edit-(16x16).gif" />
            </a>
            </td>
        </tr>  
    </xsl:template> 
    
    
    <xsl:template name="publisherRow">
        <tr class="row{position() mod 2}">
            <td>
                <a href="publisher?c=show&amp;PublisherID={Publisher/PublisherID}"><xsl:value-of select="Publisher/PublisherName" /></a>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="Publisher/IsAgency = 1">Agency</xsl:when>
                    <xsl:when test="Publisher/IsAdmin = 1">Administrator</xsl:when>
                    <xsl:otherwise>Publisher</xsl:otherwise>
                </xsl:choose>
                 (United States)
            </td>
            <td><xsl:value-of select="Publisher/ClientAccountID" /></td>
            <td class="icon">
                <a href="publisher?c=edit&amp;PublisherID={Publisher/PublisherID}" title="Edit">
                    <img src="/production/images/icons/office/Edit-(16x16).gif" />
                </a>
            </td>
        </tr>  
    </xsl:template>     


    <xsl:template name="caPublisherRow">
        <tr class="row{position() mod 2}">
            <td>
                <a href="ca_publisher?c=show&amp;PublisherID={CAPublisher/PublisherID}"><xsl:value-of select="CAPublisher/PublisherName" /></a>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="CAPublisher/IsAgency = 1">Agency</xsl:when>
                    <xsl:when test="CAPublisher/IsAdmin = 1">Administrator</xsl:when>
                    <xsl:otherwise>Publisher</xsl:otherwise>
                </xsl:choose>
                (Canadian)
            </td>
            <td><xsl:value-of select="CAPublisher/ClientAccountID" /></td>
            <td class="icon">
                <a href="ca_publisher?c=edit&amp;PublisherID={CAPublisher/PublisherID}" title="Edit">
                    <img src="/production/images/icons/office/Edit-(16x16).gif" />
                </a>
            </td>
        </tr>  
    </xsl:template> 
    

</xsl:stylesheet>
