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

    <xsl:include href="/app/tools/rps/templates/global.xsl" />
    <xsl:include href="../shared_layouts/statements.xsl" />

    <xsl:template name="pickLayout">
        <div class="StatementsDocuments" id="statement">
            <xsl:call-template name="summary" />
            <xsl:call-template name="payable_units" />
            <xsl:call-template name="details" />
            <section class="MainBaseSection MainBaseSection-joined">
                <xsl:call-template name="buttons" />
            </section>
        </div>
    </xsl:template>

    <xsl:template name="payable_units">
        <section class="MainBaseSection" id="statementSummary">
            <ul class="ValuePair">
                <li class="ValuePair-item">
                    <span class="ValuePair-label">Royalty Payable Units</span>
                    <div class="ValuePair-value">
                        <xsl:value-of select="Statement/McpsStatement/RoyaltyPayableUnits" />
                    </div>
                </li>
                <li class="ValuePair-item">
                    <span class="ValuePair-label">Estimated Liability</span>
                    <div class="ValuePair-value">
                        <xsl:value-of select="Statement/McpsStatement/EstimatedLiability" />
                    </div>
                </li>
            </ul>
        </section>
    </xsl:template>

    <xsl:template name="summary">

        <xsl:variable name="showDownloads">
            <xsl:choose>
                <xsl:when test="Statement/UKMechanicalRun/CanDownloadPDF = 1 or Statement/UKMechanicalRun/CanDownloadText = 1">
                    <xsl:text>true</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>false</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <section class="MainBaseSection" id="statementSummary">
            <xsl:call-template name="helpLink" />

            <xsl:if test="$showDownloads = 'true'">
                <ul class="StatementsDocuments-download ControlsList">
                    <xsl:if test="Statement/UKMechanicalRun/CanDownloadPDF = 1">
                        <li class="ControlsList-item">
                            <xsl:call-template name="uiDownloadLink">
                                <xsl:with-param name="text" select="'PDF Version'" />
                                <xsl:with-param name="title" select="'Download PDF'" />
                                <xsl:with-param name="url">
                                    <xsl:text>?c=pdf_mcps&amp;McpsStatementID=</xsl:text>
                                    <xsl:value-of select="Statement/McpsStatement/McpsStatementID" />
                                </xsl:with-param>
                            </xsl:call-template>
                        </li>
                    </xsl:if>
                    <xsl:if test="Statement/UKMechanicalRun/CanDownloadText = 1">
                        <li class="ControlsList-item">
                            <xsl:call-template name="uiDownloadLink">
                                <xsl:with-param name="text" select="'Electronic Format'" />
                                <xsl:with-param name="title" select="'Download Electronic Format'" />
                                <xsl:with-param name="url">
                                    <xsl:text>?c=text_mcps&amp;UKMechanicalRunID=</xsl:text>
                                    <xsl:value-of select="Statement/McpsStatement/UKMechanicalRunID" />
                                </xsl:with-param>
                            </xsl:call-template>
                        </li>
                    </xsl:if>
                </ul>
            </xsl:if>

            <section class="StatementsDocuments-publisher">
                <h4><xsl:value-of select="Statement/Payor/Name" /></h4>
                <xsl:if test="normalize-space(Statement/Payor/StreetAddress)">
                    <p>
                        <xsl:call-template name="replaceLineBreak">
                            <xsl:with-param name="string" select="Statement/Payor/StreetAddress"/>
                        </xsl:call-template>
                    </p>
                </xsl:if>
                <xsl:if test="normalize-space(Statement/Payor/City) or normalize-space(Statement/Payor/StateProvince)">
                    <p>
                        <xsl:if test="normalize-space(Statement/Payor/City)"><xsl:value-of select="Statement/Payor/City" /><xsl:if test="normalize-space(Statement/Payor/StateProvince)">, </xsl:if></xsl:if><xsl:value-of select="Statement/Payor/StateProvince" />&#160;<xsl:value-of select="Statement/Payor/PostalCode" />
                    </p>
                </xsl:if>
                <xsl:if test="normalize-space(Statement/Payor/CountryCode)">
                    <p>
                        <xsl:value-of select="Statement/Payor/CountryCode" />
                    </p>
                </xsl:if>

                <p>Account Number: <xsl:value-of select="Statement/Payor/SupplierCode" /></p>
                <p>Reporting Period: Q<xsl:value-of select="Statement/UKMechanicalRun/Quarter" />&#160;<xsl:value-of select="Statement/UKMechanicalRun/Year" /></p>
                <p>Scheme Code: <xsl:value-of select="Statement/McpsStatement/McpsScheme" /></p>
                <p>Mechanical Copyright Protection Society Ltd</p>
                <p>Elgar House</p>
                <p>41 Streatham High Road</p>
                <p>London</p>
                <p>SW161ER</p>
            </section>
        </section>
    </xsl:template>


    <xsl:template name="details">
        <xsl:if test="Statement/McpsStatement/McpsStatementItemList/McpsStatementItem">
            <section class="MainBaseSection">
                <div class="Table-wrapper Table-wrapper-srollleft">
                    <table class="Table statementTable">
                        <thead>
                            <xsl:call-template name="detailsHeader" />
                        </thead>
                        <tbody>
                            <xsl:for-each select="Statement/McpsStatement/McpsStatementItemList/McpsStatementItem">
                                <xsl:call-template name="detailsRow" />
                            </xsl:for-each>
                            <xsl:call-template name="totalRow" />
                        </tbody>
                    </table>
                </div>
            </section>
        </xsl:if>
    </xsl:template>

    <xsl:template name="detailsHeader">
        <tr class="Table-row Table-row-header statementHeader">
            <th class="Table-col">Album Title</th>
            <th class="Table-col">Catalog&#160;#</th>
            <th class="Table-col">MCPS&#160;ID</th>
            <th class="Table-col">Product Format</th>

            <xsl:if test="Statement/McpsStatement/McpsScheme = 'DVD1'">
                <th class="Table-col">DVD Cat</th>
            </xsl:if>

            <th class="Table-col">Release Date</th>
            <th class="Table-col">Country</th>
            <th class="Table-col Table-col-amount">Gross</th>
            <th class="Table-col Table-col-amount">Prior&#160;(&#8209;)</th>
            <th class="Table-col Table-col-amount">Promo</th>
            <th class="Table-col Table-col-amount">Returns</th>
            <th class="Table-col Table-col-amount">Net Royalty Units</th>
            <th class="Table-col Table-col-amount">Retentions</th>
            <th class="Table-col Table-col-amount">TV Retentions</th>
            <th class="Table-col Table-col-amount">Net</th>
            <th class="Table-col Table-col-amount">Price</th>
            <th class="Table-col">Price Type</th>
            <th class="Table-col">Adj?</th>
            <th class="Table-col">Comments</th>
        </tr>
    </xsl:template>


    <xsl:template name="detailsRow">
        <tr class="Table-row Table-row-data">
            <xsl:attribute name="class">
                Table-row Table-row-data
                <xsl:if test="position() = 1">
                    <xsl:text> Table-row-total</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <td class="Table-col">
                <a href="catalog?AlbumID={AlbumID}&amp;c=show">
                    <xsl:value-of select="substring(AlbumTitle,1,20)" /><xsl:if test="substring(AlbumTitle,21,1)">...</xsl:if>
                </a>
            </td>
            <td class="Table-col">
                <xsl:choose>
                    <xsl:when test="(/Root/Client/ClientID = 288 or /Root/Client/ClientID = 315 or /Root/Client/ClientID = 443 or /Root/Client/ClientID = 461) and ProductCode != ''">
                        <xsl:value-of select="ProductCode" />
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="CatalogNumber" />
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col">
                <a href="uk_mech?c=show_mcps_license&amp;McpsLicenseID={McpsLicenseID}"><xsl:value-of select="McpsID" /></a>
            </td>
            <td class="Table-col">
                <xsl:variable name="productTypeID" select="ProductTypeID" />
                <xsl:value-of select="/Root/Statement/TypeList/Type[ProductTypeID = $productTypeID]/Description" />
            </td>

            <xsl:if test="/Root/Statement/McpsStatement/McpsScheme = 'DVD1'">
                <td class="Table-col"><xsl:value-of select="DVDCategory" /></td>
            </xsl:if>

            <td class="Table-col">
                <xsl:value-of select="ReleaseDate" />
            </td>
            <td class="Table-col">
                <xsl:value-of select="CountryCode" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="GrossUnits" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="PriorUnits" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="PromoUnits" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="ReturnUnits" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="NetUnits" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Retentions" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="TVRetentions" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="FinalNetUnits" />
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Price" />
            </td>
            <td class="Table-col">
                <xsl:value-of select="McpsPriceType" />
            </td>
            <td class="Table-col">
                <xsl:if test="Adjustment = 1">Y</xsl:if>
            </td>
            <td class="Table-col">
                <xsl:value-of select="Comments" />
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="totalRow">
        <tr class="Table-row Table-row-data Table-row-total Table-row-subtotal">
            <td colspan="6" class="Table-col Table-col-heading">
                <xsl:if test="/Root/Statement/McpsStatement/McpsScheme = 'DVD1'">
                    <xsl:attribute name="colspan">7</xsl:attribute>
                </xsl:if>
                Gross Units:
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Statement/McpsStatement/GrossUnits" />
            </td>
            <td colspan="6" class="Table-col Table-col-heading">
                Net Units:
            </td>
            <td class="Table-col Table-col-amount">
                <xsl:value-of select="Statement/McpsStatement/NetUnits" />
            </td>
            <td class="Table-col" colspan="5">
            </td>
        </tr>
    </xsl:template>

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

    <xsl:template name="cancelButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="content" select="'Back to Statements'" />
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="name" select="'Back'" />
            <xsl:with-param name="url">
                <xsl:text>uk_mech?UKMechanicalRunID=</xsl:text>
                <xsl:value-of select="Statement/McpsStatement/UKMechanicalRunID" />
                <xsl:text>&amp;c=show</xsl:text>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

</xsl:stylesheet>

