<!--                                                                  -->
<!--  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="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" 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="section">
            <table class="textChart" id="trackLicenseTable">
                <tbody>
                    <!-- Not a bad idea - might add this in later -->
                    <!-- <xsl:call-template name="trackLicenseFilter" /> -->
                    <xsl:choose>
                        <xsl:when test="Form/LicenseList/License">
                            <xsl:call-template name="numericListNav">
                                <xsl:with-param name="pagination">/Root/Form/LicenseList/Pagination</xsl:with-param>
                                <xsl:with-param name="extraParams">&amp;publisherID=<xsl:value-of select="/Root/Params/publisherID" />&amp;payorID=<xsl:value-of select="/Root/Params/payorID" />
                                </xsl:with-param>
                            </xsl:call-template>
                            <xsl:call-template name="trackLicenseHeader" />
                            <xsl:for-each select="Form/LicenseList/License">
                                <xsl:call-template name="trackLicenseRowSwitch" />
                            </xsl:for-each>
                        </xsl:when>
                        <xsl:otherwise>
                	        <tr>
                		        <td colspan="12" class="emptyMessage">No licenses match this criteria.</td>
                            </tr>
                        </xsl:otherwise>
                    </xsl:choose>     
                </tbody>
            </table>
        </div>
        <xsl:call-template name="buttons" />
    </xsl:template>


	<xsl:template name="trackLicenseHeader">
		<tr>
			<th>Album Title</th>
			<th class="trackNumCol">Track</th>
			<th>Track Title</th>
			<th>Product</th>
			<th>Cross</th>
			<th>Region</th>
			<th class="amount">Share</th>
			<th>Admin</th>
			<th>Agent</th>
			<th class="status">Status</th>
			<th class="actionsCol">Actions</th>
		</tr>
	</xsl:template>


    <xsl:template name="trackLicenseRowSwitch">
        <xsl:variable name="rowClass">row<xsl:value-of select="position() mod 2" /></xsl:variable>
        <xsl:call-template name="trackLicenseRow">
            <xsl:with-param name="rowClass" select="$rowClass" />
        </xsl:call-template>
    </xsl:template>


    <xsl:template name="trackLicenseRow">
  	    <xsl:param name="rowClass" />

	        <tr class="{$rowClass}">
	            <td><a href="/rps/catalog?c=show&amp;AlbumID={AlbumID}"><xsl:value-of select="AlbumTitle" /></a></td>
	            <td>
	        	    <xsl:if test="TrackOrder &lt; 10">0</xsl:if><xsl:value-of select="TrackOrder" />
	            </td>
	            <td><a href="/rps/track?c=show&amp;TrackID={TrackID}"><xsl:value-of select="TrackTitle" /></a></td>
	            <td>
                    <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="status">
	      	        <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>
	                <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="amount"><xsl:value-of select="Share" />%</td>
	            <td>
	                <xsl:if test="Type != 4"><xsl:value-of select="AdminName" /></xsl:if>
	            </td>
	            <td>
	                <xsl:if test="Type != 4"><xsl:value-of select="AgentName" /></xsl:if>
	            </td>
                <td class="status">
                    <xsl:if test="Inactive = 1">Inactive</xsl:if>
  				    <xsl:if test="Inactive = 0">Active</xsl:if>
                </td>
                <td>
        	        <a href="/rps/{$licenseArea}?c=edit&amp;TrackLicenseID={TrackLicenseID}" title="Edit Existing License">Edit</a>
                </td>
	        </tr>
    </xsl:template>


    <xsl:template name="submitButton">
        <xsl:attribute name="class" />
    </xsl:template>


    <xsl:template name="cancelButton">
        <input type="button" name="Back" value="Back to Publisher" onClick="location.href='{$area}?c=show&amp;PublisherID={Params/publisherID}'" />
    </xsl:template>


</xsl:stylesheet>
