<!--                                                                  -->
<!--  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="mechanicalPipelineLayout">
        <div class="AuditReport" id="auditReport">

            <h2 class="AuditReport-header">
                <xsl:choose>
                    <xsl:when test="$cmd = 'ca_mechanical_reserve_pipeline'">
                        CA Mechanical Reserve Pipeline
                    </xsl:when>
                    <xsl:otherwise>
                        Mechanical Reserve Pipeline
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:call-template name="helpIcon">
                    <xsl:with-param name="tip">
                        Lists reserves held for associated tracks by&#160;publisher
                        &lt;ul&gt;
                        &lt;li&gt;
                        Reserves are aggregated across all products;
                        &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="showMechReservePipeline" />
                </xsl:when>
                <xsl:otherwise>
                    <section class="Table-empty-results">
                        <p>No reserves were found.</p>
                    </section>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="$cmd = 'ca_mechanical_reserve_pipeline'">
                    <xsl:call-template name="backToCAMechRun" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="backToMechRun" />
                </xsl:otherwise>
            </xsl:choose>
        </div>
    </xsl:template>

    <xsl:template name="showMechReservePipeline">
        <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:choose>
                                            <xsl:when test="$cmd = 'ca_mechanical_reserve_pipeline'">
                                                <xsl:text>pipelineRegion(</xsl:text>
                                                <xsl:value-of select="/Root/Params/run_id" />
                                                <xsl:text>,'ca')</xsl:text>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:text>pipelineRegion(</xsl:text>
                                                <xsl:value-of select="/Root/Params/run_id" />
                                                <xsl:text>,'us')</xsl:text>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </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="mechanicalPipelineTable" />
        <xsl:call-template name="reportFooter" />
    </xsl:template>


    <xsl:template name="mechanicalPipelineTable">
        <table class="Table Table-with-highlight">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col" rowspan="3">Track</th>
                    <th class="Table-col" rowspan="3">Album Title</th>
                    <th class="Table-col" rowspan="3">UPC&#160;#</th>
                    <th class="Table-col" rowspan="3">Publisher</th>
                    <th class="Table-col" rowspan="3">Client Account &#160;#</th>
                    <th class="Table-col" rowspan="3">Region</th>

                    <th class="Table-col Table-col-common" rowspan="2" colspan="2">Total Reserves Held</th>
                    <th class="Table-col Table-col-common" colspan="4">Current Period</th>
                    <th></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 Table-col-common">#</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 Table-col-common"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>

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


    <xsl:template name="mechReservePipelineRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col">
                <a href="track?c=show&amp;TrackID={TrackID}"><xsl:value-of select="TrackTitle" /></a>
            </td>
            <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="UPC" /></td>
            <td class="Table-col">
                <xsl:choose>
                    <xsl:when test="$cmd = 'ca_mechanical_reserve_pipeline'">
                        <a href="ca_publisher?c=show&amp;PublisherID={CAPublisherID}"><xsl:value-of select="PublisherName" /></a>
                    </xsl:when>
                    <xsl:otherwise>
                        <a href="publisher?c=show&amp;PublisherID={PublisherID}"><xsl:value-of select="PublisherName" /></a>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <td class="Table-col"><xsl:value-of select="AccountNumber" /></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:stylesheet>
