<!--                                                                  -->
<!--  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="section" id="auditReport">
    	    <xsl:choose>
    		    <xsl:when test="Report/Line">
                    <xsl:call-template name="showReservePipeline" />
				</xsl:when>
				<xsl:otherwise>
					<p>No reserves were found.</p>
				</xsl:otherwise>
			</xsl:choose>
		</div>		
		<xsl:call-template name="backToArtistRun" />		
	</xsl:template>


    <xsl:template name="showReservePipeline">
	    <div class="reportNavWrapper">
	    
		    <h2>
    			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<xsl:value-of select="$tipBreak" />
    							% Retail and % Wholesale terms with approximate units for currency<xsl:value-of select="$tipBreak" />
    							based reserves taken for % Net Revenue terms
    						&lt;/li&gt;
    						&lt;li&gt;
    					  	    Currency amounts represent the combination of currency based reserves<xsl:value-of select="$tipBreak" />
    					  	    taken for % Net Revenue terms with approximate currency for unit based<xsl:value-of select="$tipBreak" />
    					  	    reserves taken for % Retail and % Wholesales terms
    						&lt;/li&gt;
    						&lt;li&gt;
    					  	    &quot;Current Period Taken&quot; notes reserves that were taken during<xsl:value-of select="$tipBreak" />that period royalty run
    						&lt;/li&gt;
    						&lt;li&gt;
    					  	    Downloaded text file contains all eight liquidation periods with<xsl:value-of select="$tipBreak" />associated held reserves
    					    &lt;/li&gt;
    					&lt;/ul&gt;
    				</xsl:with-param>
    			</xsl:call-template> 
		    </h2>
		
		    <xsl:if test="count(RegionList/Region) &gt; 1">
		        <div style="padding-bottom: 4px;">
    			    <label for="region_id">Now Viewing: </label>
        			<select name="region_id" id="regionID">
        				<option value="">All Regions</option>
        				<xsl:for-each select="RegionList/Region">
        					<option value="{RegionID}">
        						<xsl:if test="RegionID = /Root/Params/region_id">
        							<xsl:attribute name="selected">selected</xsl:attribute>
        						</xsl:if>
        						&#160;&#160;&#160;<xsl:value-of select="Name" />
        					</option>
        				</xsl:for-each>
        			</select>&#160;<input type="button" value="Update" onClick="pipelineRegion({/Root/Params/run_id})" />
    			</div>
		    </xsl:if>
		
		    <xsl:call-template name="reportHeading" />
		    <xsl:call-template name="reportNav" />
		</div>
		
	    <xsl:call-template name="artistPipelineTable" />
	    <xsl:call-template name="reportNav" />
		<br class="superBreak" />
		<br />    
    </xsl:template>


	<xsl:template name="artistPipelineTable">
        <table class="textChart hiOn">
            <tr>
              	<th rowspan="3">Album Title</th>
              	<th rowspan="3">Catalog&#160;#</th>
              	<th rowspan="3">Payee</th>
              	<th rowspan="3">Label</th>
              	<th rowspan="3">Region</th>     	     	
              	<th rowspan="2" colspan="2">Total Held</th>
              	<th colspan="4" class="withSubHeaders">Current Period</th>      
              	<th></th>
                <th colspan="4" class="withSubHeaders">Future Liquidations</th>
                <th></th>
            </tr>
            <tr>
              	<th class="subHeaderLeft subHeaderTop" colspan="2">Taken</th>
              	<th class="subHeaderRight subHeaderTop" colspan="2">Liquidated</th> 
              	<th rowspan="2"></th>           
              	<th class="subHeaderLeft subHeaderTop" colspan="2">Current+1</th>
              	<th class="subHeaderRight subHeaderTop" colspan="2">Current+2</th>
              	<th rowspan="2"></th>
            </tr>	
            <tr>
                <th class="amount">#</th>
                <th class="amount"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>
                
                <th class="amount subHeaderLeft">#</th>
                <th class="amount"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>
                <th class="amount">#</th>
                <th class="amount subHeaderRight"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>
                
                <th class="amount subHeaderLeft">#</th>
                <th class="amount"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>
                <th class="amount">#</th>
                <th class="amount subHeaderRight"><xsl:value-of select="Client/Locale/CurrencyFormat/Symbol" /></th>
            </tr>

            <xsl:for-each select="Report/Line">
                <xsl:call-template name="reservePipelineRow" />
            </xsl:for-each>
        </table>
    </xsl:template>
  
  
    <xsl:template name="reservePipelineRow">
        <tr class="row{position() mod 2}">
    		<td>
    			<a href="catalog?c=show&amp;AlbumID={AlbumID}"><xsl:value-of select="AlbumTitle" /></a>
    		</td>  
    		<td><xsl:value-of select="CatalogNumber" /></td>
        	<td>
        		<a href="artist_payee?c=show&amp;ArtistPayeeID={ArtistPayeeID}"><xsl:value-of select="ArtistPayeeName" /></a>
        	</td>	
        	<td><xsl:value-of select="LabelName" /></td>				      
        	<td>
        		<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></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></td>
		
        </tr>
    </xsl:template>


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


</xsl:stylesheet>
