<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="no" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" 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="section" id="runList">
            <xsl:call-template name="helpLink" />
    		<xsl:call-template name="statementSuccessMessages" />    
    		<xsl:choose>
        		<xsl:when test="RoyaltyRunStatus/CAMechanicalRuns/Error &gt; 0">
        		    <xsl:call-template name="errorRunMessage" />
        		</xsl:when>
        		<xsl:when test="RoyaltyRunStatus/USMechanicalRuns/Error &gt; 0">
        		    <xsl:call-template name="errorRunMessage" />
        		</xsl:when>        		
        		<xsl:otherwise>
    	  	        <xsl:call-template name="createRunLink" />
    	  	    </xsl:otherwise>
    	  	</xsl:choose>
			<xsl:choose>
				<xsl:when test="MechanicalRunList/MechanicalRun">
					<xsl:call-template name="runTable" />
				</xsl:when>
				<xsl:otherwise>
					<br class="superBreak" />
					<p>No mechanical royalty runs have been created.</p>
				</xsl:otherwise>
			</xsl:choose>
		</div>
	</xsl:template>
	

	<xsl:template name="runTable">
        <table class="textChart hiOn">
            <tr>
                <th># of Statements</th>
                <th>
                    <xsl:choose>
                        <xsl:when test="$area = 'ca_mechanical'">Reporting Period</xsl:when>
                        <xsl:otherwise>Run Name</xsl:otherwise>
                    </xsl:choose>
                </th>
                <th>Ending Sales Date</th>
              	<th>Payor</th>
                <th>Run Date</th>
                <th>
            	    Status
    				<xsl:call-template name="helpIcon">
    					<xsl:with-param name="tip" select="$statusDescriptions" />
    				</xsl:call-template>
                </th>
                <th>Actions</th>
            </tr>
            <xsl:for-each select="MechanicalRunList/MechanicalRun">
                <xsl:sort select="MechanicalRunID" order="descending" data-type="number" />
                <tr class="row{position() mod 2}">
                    <td>
						<xsl:call-template name="statementCount" />
                    </td>
                    <td>
						<xsl:value-of select="Label" />
                    </td>
                    <td>
          	            <xsl:call-template name="endingSalesDate" >
			              <xsl:with-param name="endingSaleDate"><xsl:value-of select="EndingSaleDate" /></xsl:with-param>
			            </xsl:call-template>
                    </td>
                    <td>
						<xsl:call-template name="payorName" />
                    </td>
                    <td>
						<xsl:call-template name="runDate" />
                    </td>
                    <td>
          	            <xsl:call-template name="statusCodeToName" />
                    </td>
                    <td>
						<xsl:call-template name="runActions" />
                    </td>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>


</xsl:stylesheet>
