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

    <xsl:template name="artistPipelineLayout">
        <div class="AuditReport" id="auditReport">

            <h2 class="AuditReport-header">
                Reserve Pipeline
                <xsl:call-template name="helpIcon">
                    <xsl:with-param name="tip">
                        Lists reserves held for associated albums by payee
                        &lt;ul&gt;
                        &lt;li&gt;
                        Reserves are aggregated across all products;
                        &lt;/li&gt;
                        &lt;li&gt;
                        Units represent the combination of unit based reserves taken for % Retail and % Wholesale terms with approximate units for currency based reserves taken for % Net Revenue terms;
                        &lt;/li&gt;
                        &lt;li&gt;
                        Currency amounts represent the combination of currency based reserves taken for % Net Revenue terms with approximate currency for unit based reserves taken for % Retail and % Wholesales terms;
                        &lt;/li&gt;
                        &lt;li&gt;
                        &quot;Current Period Taken&quot; notes reserves that were taken during that period royalty run;
                        &lt;/li&gt;
                        &lt;li&gt;
                        Downloaded text file contains all eight liquidation periods with associated held reserves.
                        &lt;/li&gt;
                        &lt;/ul&gt;
                    </xsl:with-param>
                </xsl:call-template>
            </h2>

            <xsl:choose>
                <xsl:when test="Report/Line">
                    <xsl:call-template name="showReservePipeline" />
                </xsl:when>
                <xsl:otherwise>
                    <section class="Table-empty-results">
                        <p>No reserves were found.</p>
                    </section>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:call-template name="backToArtistRun" />
        </div>
    </xsl:template>


    <xsl:template name="showReservePipeline">
        <div class="Table-controls Table-controls-top">
            <xsl:if test="count(RegionList/Region) &gt; 1">
                <div class="Table-controls-item AuditReport-controls-mech">

                    <div class="Form-group Form-group-horizontal">
                        <div class="Form-item">
                            <label class="Form-label">
                                <span class="Form-label-caption">Now Viewing</span>
                                <span class="Form-input-wrapper">
                                    <xsl:variable name="auditReportRegionListItems">
                                        <map>
                                            <mapEntry>
                                                <name>All Regions</name>
                                                <value></value>
                                            </mapEntry>
                                            <xsl:for-each select="RegionList/Region">
                                                <mapEntry>
                                                    <name>&#160;&#160;&#160;<xsl:value-of select="Name" /></name>
                                                    <value>
                                                        <xsl:value-of select="RegionID" />
                                                    </value>
                                                </mapEntry>
                                            </xsl:for-each>
                                        </map>
                                    </xsl:variable>
                                    <xsl:call-template name="uiDropdown">
                                        <xsl:with-param name="items" select="$auditReportRegionListItems"/>
                                        <xsl:with-param name="name" select="'region_id'"/>
                                        <xsl:with-param name="id" select="'regionID'"/>
                                        <xsl:with-param name="active" select="/Root/Params/region_id"/>
                                        <xsl:with-param name="className" select="'AuditReport-mech-select'"/>
                                    </xsl:call-template>
                                </span>
                            </label>
                        </div>
                        <div class="Form-item">
                            <div class="Form-input-wrapper">
                                <xsl:call-template name="uiButton">
                                    <xsl:with-param name="content" select="'Update'" />
                                    <xsl:with-param name="elemType" select="'submit'" />
                                    <xsl:with-param name="onClick">
                                        <xsl:text>pipelineRegion(</xsl:text>
                                        <xsl:value-of select="/Root/Params/run_id" />
                                        <xsl:text>)</xsl:text>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </div>
                        </div>
                    </div>
                </div>
            </xsl:if>
            <div class="Table-controls-item AuditReport-controls-download">
                <xsl:call-template name="reportDownloadLink" />
            </div>
            <div class="Table-controls-item Table-controls-item-pagination">
                <xsl:call-template name="reportNav" />
            </div>
        </div>

        <xsl:call-template name="artistPipelineTable" />
        <xsl:call-template name="reportFooter" />
    </xsl:template>


    <xsl:template name="artistPipelineTable">
        <table class="Table Table-with-highlight">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col" rowspan="3">Album Title</th>
                    <th class="Table-col" rowspan="3">Catalog&#160;#</th>
                    <th class="Table-col" rowspan="3">Payee</th>
                    <th class="Table-col" rowspan="3">Label</th>
                    <th class="Table-col" rowspan="3">Region</th>
                    <th class="Table-col" rowspan="2" colspan="2">Total Held</th>
                    <th class="Table-col Table-col-common" colspan="4">Current Period</th>
                    <th class="Table-col"></th>
                    <th class="Table-col Table-col-common" colspan="4">Future Liquidations</th>
                    <th></th>
                </tr>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col Table-col-common" colspan="2">Taken</th>
                    <th class="Table-col Table-col-common" colspan="2">Liquidated</th>
                    <th class="Table-col" rowspan="2"></th>
                    <th class="Table-col Table-col-common" colspan="2">Current+1</th>
                    <th class="Table-col Table-col-common" colspan="2">Current+2</th>
                    <th class="Table-col" rowspan="2"></th>
                </tr>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col Table-col-amount">#</th>
                    <th class="Table-col Table-col-amount"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>

                    <th class="Table-col Table-col-amount">#</th>
                    <th class="Table-col Table-col-amount"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>
                    <th class="Table-col Table-col-amount">#</th>
                    <th class="Table-col Table-col-amount"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>

                    <th class="Table-col Table-col-amount">#</th>
                    <th class="Table-col Table-col-amount"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>
                    <th class="Table-col Table-col-amount">#</th>
                    <th class="Table-col Table-col-amount"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="Report/Line">
                    <xsl:call-template name="reservePipelineRow" />
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>


    <xsl:template name="reservePipelineRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col">
                <a href="catalog?c=show&amp;AlbumID={AlbumID}"><xsl:value-of select="AlbumTitle" /></a>
            </td>
            <td class="Table-col"><xsl:value-of select="CatalogNumber" /></td>
            <td class="Table-col">
                <a href="artist_payee?c=show&amp;ArtistPayeeID={ArtistPayeeID}"><xsl:value-of select="ArtistPayeeName" /></a>
            </td>
            <td class="Table-col"><xsl:value-of select="LabelName" /></td>
            <td class="Table-col">
                <xsl:choose>
                    <xsl:when test="RegionID = 0"><xsl:value-of select="RegionName" /></xsl:when>
                    <xsl:otherwise>
                        <a href="region?c=show&amp;RegionID={RegionID}"><xsl:value-of select="RegionName" /></a>
                    </xsl:otherwise>
                </xsl:choose>
            </td>

            <xsl:call-template name="unitsRevenueValues">
                <xsl:with-param name="units" select="TotalUnits" />
                <xsl:with-param name="revenue" select="TotalRevenueRounded" />
            </xsl:call-template>
            <xsl:call-template name="unitsRevenueValues">
                <xsl:with-param name="units" select="Units0" />
                <xsl:with-param name="revenue" select="Revenue0Rounded" />
            </xsl:call-template>
            <xsl:call-template name="unitsRevenueValues">
                <xsl:with-param name="units" select="Units1" />
                <xsl:with-param name="revenue" select="Revenue1Rounded" />
            </xsl:call-template>
            <td class="Table-col"></td>
            <xsl:call-template name="unitsRevenueValues">
                <xsl:with-param name="units" select="Units2" />
                <xsl:with-param name="revenue" select="Revenue2Rounded" />
            </xsl:call-template>
            <xsl:call-template name="unitsRevenueValues">
                <xsl:with-param name="units" select="Units3" />
                <xsl:with-param name="revenue" select="Revenue3Rounded" />
            </xsl:call-template>

            <td class="Table-col"></td>

        </tr>
    </xsl:template>


    <xsl:template name="unitsRevenueValues">
        <xsl:param name="units" />
        <xsl:param name="revenue" />
        <td class="Table-col Table-col-amount">
            <xsl:value-of select="$units" />
        </td>
        <td class="Table-col Table-col-amount">
            <xsl:if test="normalize-space($units)"><xsl:value-of select="$revenue" /></xsl:if>
        </td>
    </xsl:template>


</xsl:stylesheet>
