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

<xsl:include href="/app/tools/support/templates/job_queue/queue_util.xsl" />

	<xsl:template match="Root">
		<xsl:call-template name="jobsInQueueSection" />
	</xsl:template>

	<xsl:template name="jobsInQueueSection">
		<xsl:variable name="jobsInQueue" select="JobQueue/Jobs[StartDate = '0000-00-00 00:00:00']" />
        <xsl:variable name="totalJobCount" select="QueuedJobCount" />
        <xsl:variable name="displayJobCount" select="/Root/JobQueue/Jobs/@size" />
		<fieldset>
			<legend>In Queue : Count = <xsl:value-of select="QueuedJobCount" /></legend>
			<xsl:choose>
				<xsl:when test="$jobsInQueue">
                    <xsl:if test="$totalJobCount > $displayJobCount">
                        <p class="emptyMessage">(Displaying top <xsl:value-of select="$displayJobCount" /> matching jobs in priority order)</p>
                    </xsl:if>
					<table class="textChart">
						<tr>
							<th>Priority</th>
							<th>Job ID</th>
							<th>Parent ID</th>
							<th>Host</th>
							<th>Client</th>
							<th>Class</th>
							<th>Subclass</th>
							<th class="right">Run ID</th>
							<th>Queued</th>
							<th>Min Start Date</th>
							<th>On Hold</th>
						</tr>
						<xsl:for-each select="$jobsInQueue">
							<xsl:sort data-type="number" select="Priority" />
							<xsl:call-template name="jobInQueueRow" />
						</xsl:for-each>
					</table>
				</xsl:when>
				<xsl:otherwise>
					<p class="emptyMessage">No matching jobs are currently in the queue.</p>
					<br />
				</xsl:otherwise>
			</xsl:choose>
		</fieldset>
		<br />
	</xsl:template>

	<xsl:template name="jobInQueueRow">
		<tr class="row{position() mod 2}">
			<td><xsl:value-of select="Priority" /></td>
			<td>
              <xsl:call-template name="jobDetailLink">
                <xsl:with-param name="job_id" select = "JobID" />
			  </xsl:call-template>
            </td>
			<td>
              <xsl:if test="ParentJobID &gt; 0">
                <xsl:call-template name="jobDetailLink">
				  <xsl:with-param name="job_id" select = "ParentJobID" />
			    </xsl:call-template>
			  </xsl:if>
            </td>
			<td><xsl:value-of select="HostName" /></td>
            <td>
				<xsl:call-template name="clientIDToName">
					<xsl:with-param name="clientID" select="ClientID" />
				</xsl:call-template>
            </td>
			<td><xsl:value-of select="Class" /></td>
			<td><xsl:value-of select="Subclass" /></td>
			<td class="right"><xsl:value-of select="RunID" /></td>
			<td><xsl:value-of select="QueueDate" /></td>
			<td><xsl:value-of select="MinStartDate" /></td>
			<xsl:call-template name="onHoldCheckBox" />
		</tr>
	</xsl:template>

</xsl:stylesheet>
