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

    <xsl:template name="showLicenseIncome">
        <div class="Tracker-edit-page-container">

            <fieldset class="Form-fieldset">
                <div class="ValuePair">
                    <div class="ValuePair-item">
                        <span class="ValuePair-label">File Name</span>
                        <span class="ValuePair-value"><xsl:value-of select="LicenseIncomeFile/OrigFileName" /></span>
                    </div>
                </div>
            </fieldset>
            <fieldset class="Form-fieldset">
                <xsl:call-template name="showLicenseIncomeTable" />
            </fieldset>
            <xsl:call-template name="showLicenseIncomeButtons" />
        </div>
    </xsl:template>

    <xsl:template name="showLicenseIncomeTable">
        <table class="Table">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col Table-col-amount">#</th>
                    <th class="Table-col">Date</th>
                    <th class="Table-col Table-col-amount">Units</th>
                    <th class="Table-col Table-col-amount">Amount</th>
                    <th class="Table-col">Album</th>
                    <th class="Table-col">Track</th>
                    <th class="Table-col">Contract</th>
                    <th class="Table-col">Income Type</th>
                    <th class="Table-col">Memo</th>
                </tr>
            </thead>
            <tbody>
                <xsl:choose>
                    <xsl:when test="LicenseIncomeFile/LicenseIncomeList/LicenseIncome">
                        <xsl:for-each select="LicenseIncomeFile/LicenseIncomeList/LicenseIncome">
                            <xsl:call-template name="showLicenseIncomeRow" />
                        </xsl:for-each>
                    </xsl:when>
                    <xsl:otherwise>
                        <tr><td colspan="9">No license income has been entered for this file.</td></tr>
                    </xsl:otherwise>
                </xsl:choose>
            </tbody>
        </table>
    </xsl:template>


    <xsl:template name="showLicenseIncomeRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="position()" />
            </td>

            <td class="Table-col">
                <xsl:value-of select="Date" />
            </td>

            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Units" />
            </td>

            <td class="Table-col Table-col-amount">
                <xsl:value-of select="/Root/Client/Locale/CurrencyFormat/Symbol" /><xsl:value-of select="Revenue" />
            </td>

            <td class="Table-col">
                <xsl:if test="normalize-space(AlbumID)">(<xsl:value-of select="CatalogNumber" />) <xsl:value-of select="AlbumTitle" /></xsl:if>
            </td>

            <td class="Table-col">
                <xsl:value-of select="TrackTitle" />
            </td>

            <td class="Table-col">
                <xsl:if test="normalize-space(ContractID)">(<xsl:value-of select="ClientContractID" />) <xsl:value-of select="ContractTitle" /></xsl:if>
            </td>

            <td class="Table-col">
                <xsl:value-of select="LicenseIncomeType" />
            </td>

            <td class="Table-col">
                <xsl:value-of select="Memo" />
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="showLicenseIncomeButtons">
        <fieldset class="Form-fieldset Form-fieldset-buttons">
            <xsl:call-template name="uiButton">
                <xsl:with-param name="content" select="'Return to Revenue Tab'" />
                <xsl:with-param name="className" select="'Form-button'" />
                <xsl:with-param name="url">
                    <xsl:text>/app/tracker?period=</xsl:text>
                    <xsl:value-of select="Params/period" />
                </xsl:with-param>
            </xsl:call-template>
            <xsl:if test="Access/app/tracker/license_income = 1 and LicenseIncomeFile/FileStatus = 4">
                <xsl:call-template name="uiButton">
                    <xsl:with-param name="type" select="'primary'" />
                    <xsl:with-param name="content" select="'Edit File'" />
                    <xsl:with-param name="className" select="'Form-button'" />
                    <xsl:with-param name="url">
                        <xsl:text>/app/tracker?c=license_income&amp;file=</xsl:text>
                        <xsl:value-of select="Params/file" />
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:if>
        </fieldset>
    </xsl:template>
</xsl:stylesheet>
