<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="no" doctype-system="" encoding="utf-8" />

    <xsl:include href="/app/tools/rps/templates/global.xsl" />
    <xsl:include href="/app/tools/common/production/templates/list_nav.xsl" />

    <xsl:variable name="licenseArea">
        <xsl:choose>
            <xsl:when test="$area = 'publisher'">license</xsl:when>
            <xsl:when test="$area = 'ca_publisher'">ca_license</xsl:when>
        </xsl:choose>
    </xsl:variable>


    <xsl:template name="pickLayout">
        <div class="MainBaseSection">
            <div class="PublisherListLicenses">
                <xsl:if test="/Root/Form/LicenseList/Pagination/NumPages &gt; 1">
                    <div class="Table-controls Table-controls-top">
                        <div class="Table-controls-item Table-controls-item-pagination">
                            <xsl:call-template name="uiPagination">
                                <xsl:with-param name="lastPage" select="/Root/Form/LicenseList/Pagination/NumPages"/>
                                <xsl:with-param name="currentPage" select="/Root/Form/LicenseList/Pagination/Page"/>
                                <xsl:with-param name="searchParams">
                                    <xsl:text>&amp;publisherID=</xsl:text>
                                    <xsl:value-of select="/Root/Params/publisherID" />
                                    <xsl:text>&amp;payorID=</xsl:text>
                                    <xsl:value-of select="/Root/Params/payorID" />
                                </xsl:with-param>
                                <xsl:with-param name="searchPreffix">
                                    <xsl:text>c=list_indirect_licenses&amp;</xsl:text>
                                </xsl:with-param>
                            </xsl:call-template>
                        </div>
                    </div>
                </xsl:if>

                <table class="Table" id="trackLicenseTable">
                    <!-- Not a bad idea - might add this in later -->
                    <!-- <xsl:call-template name="trackLicenseFilter" /> -->
                    <xsl:choose>
                        <xsl:when test="Form/LicenseList/License">

                            <thead>
                                <xsl:call-template name="trackLicenseHeader" />
                            </thead>
                            <tbody>
                                <xsl:for-each select="Form/LicenseList/License">
                                    <xsl:call-template name="trackLicenseRowSwitch" />
                                </xsl:for-each>
                            </tbody>
                        </xsl:when>
                        <xsl:otherwise>
                            <tr>
                                <td colspan="12" class="emptyMessage">No licenses match this criteria.</td>
                            </tr>
                        </xsl:otherwise>
                    </xsl:choose>
                </table>
            </div>
            <xsl:call-template name="buttons" />
        </div>
    </xsl:template>


    <xsl:template name="trackLicenseHeader">
        <tr class="Table-row Table-row-header">
            <th class="Table-col">Album Title</th>
            <th class="Table-col">Track</th>
            <th class="Table-col">Track Title</th>
            <th class="Table-col">Product</th>
            <th class="Table-col">Cross</th>
            <th class="Table-col">Region</th>
            <th class="Table-col Table-col-amount">Share</th>
            <th class="Table-col">Admin</th>
            <th class="Table-col">Agent</th>
            <th class="Table-col">Status</th>
            <th class="Table-col Table-col-icon">Actions</th>
        </tr>
    </xsl:template>


    <xsl:template name="trackLicenseRowSwitch">
        <xsl:call-template name="trackLicenseRow" />
    </xsl:template>


    <xsl:template name="trackLicenseRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col"><a href="/rps/catalog?c=show&amp;AlbumID={AlbumID}"><xsl:value-of select="AlbumTitle" /></a></td>
            <td class="Table-col">
                <xsl:if test="TrackOrder &lt; 10">0</xsl:if><xsl:value-of select="TrackOrder" />
            </td>
            <td class="Table-col"><a href="/rps/track?c=show&amp;TrackID={TrackID}"><xsl:value-of select="TrackTitle" /></a></td>
            <td class="Table-col">
                <xsl:call-template name="productTypeName">
                    <xsl:with-param name="productTypeID" select="ProductTypeID" />
                    <xsl:with-param name="typeList" select="/Root/Form/ProductTypeList" />
                </xsl:call-template>
            </td>
            <td class="Table-col">
                <xsl:choose>
                    <xsl:when test="Type = 1">
                        <xsl:choose>
                            <xsl:when test="Crossed = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>N/A</xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col">
                <xsl:if test="normalize-space(RegionID) and RegionID != 0">
                    <xsl:variable name="regionID" select="RegionID" />
                    <xsl:value-of select="RegionName" />
                </xsl:if>
            </td>
            <td class="Table-col Table-col-amount"><xsl:value-of select="Share" />%</td>
            <td class="Table-col">
                <xsl:if test="Type != 4"><xsl:value-of select="AdminName" /></xsl:if>
            </td>
            <td class="Table-col">
                <xsl:if test="Type != 4"><xsl:value-of select="AgentName" /></xsl:if>
            </td>
            <td class="Table-col">
                <xsl:if test="Inactive = 1">Inactive</xsl:if>
                <xsl:if test="Inactive = 0">Active</xsl:if>
            </td>
            <td class="Table-col Table-col-icon">
                <xsl:call-template name="uiEditTrigger">
                    <xsl:with-param name="url">
                        <xsl:text>/rps/</xsl:text>
                        <xsl:value-of select="$licenseArea" />
                        <xsl:text>?c=edit&amp;TrackLicenseID=</xsl:text>
                        <xsl:value-of select="TrackLicenseID" />
                    </xsl:with-param>
                    <xsl:with-param name="title" select="'Edit Existing License'" />
                </xsl:call-template>
            </td>
        </tr>
    </xsl:template>


    <xsl:template name="submitButton">
        <div />
    </xsl:template>


    <xsl:template name="cancelButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="name" select="'Back'" />
            <xsl:with-param name="content" select="'Back to Publisher'" />
            <xsl:with-param name="url">
                <xsl:value-of select="$area" />
                <xsl:text>?c=show&amp;PublisherID=</xsl:text>
                <xsl:value-of select="Params/publisherID" />
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>


</xsl:stylesheet>
