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

       	<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>

	</xsl:template>


    <xsl:template name="showMechReservePipeline">
	    <div class="reportNavWrapper">
	    
		    <h2>
        		<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 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<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;
        			<xsl:choose>
						<xsl:when test="$cmd = 'ca_mechanical_reserve_pipeline'">
        					<input type="button" value="Update" onClick="pipelineRegion({/Root/Params/run_id},'ca')" />
						</xsl:when>
        				<xsl:otherwise>
        					<input type="button" value="Update" onClick="pipelineRegion({/Root/Params/run_id},'us')" />
        				</xsl:otherwise>
        			</xsl:choose>
    			</div>
		    </xsl:if>
		
		    <xsl:call-template name="reportHeading" />
		    <xsl:call-template name="reportNav" />
		</div>
		
	    <xsl:call-template name="mechanicalPipelineTable" />
	    <xsl:call-template name="reportNav" />
		<br class="superBreak" />
		<br />    
    </xsl:template>


	<xsl:template name="mechanicalPipelineTable">
        <table class="textChart hiOn">
            <tr>
              	<th rowspan="3">Track</th>
              	<th rowspan="3">Album Title</th>
              	<th rowspan="3">UPC&#160;#</th>
              	<th rowspan="3">Publisher</th>
              	<th rowspan="3">Client Account &#160;#</th>
              	<th rowspan="3">Region</th>     	     	

              	<th rowspan="2" colspan="2">Total Reserves 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="mechReservePipelineRow" />
            </xsl:for-each>
        </table>
    </xsl:template>
  
  
    <xsl:template name="mechReservePipelineRow">
        <tr class="row{position() mod 2}">
    		<td>
    			<a href="track?c=show&amp;TrackID={TrackID}"><xsl:value-of select="TrackTitle" /></a>
    		</td>  
    		<td>
    			<a href="catalog?c=show&amp;AlbumID={AlbumID}"><xsl:value-of select="AlbumTitle" /></a>
    		</td>  
    		<td><xsl:value-of select="UPC" /></td>
        	<td>
        		<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><xsl:value-of select="AccountNumber" /></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>
