<!--                                                                  -->
<!--  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="jobsRunningSection" />
	</xsl:template>

	<xsl:template name="jobsRunningSection">
		<xsl:variable name="jobsRunning" select="JobQueue/Jobs[StartDate != '0000-00-00 00:00:00' and EndDate = '0000-00-00 00:00:00']" />
		<fieldset>
			<legend>Running</legend>
			<xsl:choose>
				<xsl:when test="$jobsRunning">
					<table class="textChart">
						<tr>
							<th>Job ID</th>
							<th>Host</th>
							<th>Client</th>
							<th>Class</th>
							<th>Subclass</th>
							<th class="right">Run ID</th>
							<th>Started</th>
							<th>Last Heartbeat</th>
							<th class="right">
								Duration <img src="/production/images/icons/16x16/info.gif" title="HH:MM:SS" alt="HH:MM:SS" />
							</th>
							<th>Paused</th>
						</tr>
						<xsl:for-each select="$jobsRunning">
							<xsl:call-template name="jobRunningRow" />
						</xsl:for-each>
					</table>
				</xsl:when>
				<xsl:otherwise>
					<p class="emptyMessage">No matching jobs are currently running.</p>
					<br />
				</xsl:otherwise>
			</xsl:choose>
		</fieldset>
		<br />
	</xsl:template>

	<xsl:template name="jobRunningRow">
		<tr class="row{position() mod 2}">
			<td>
              <xsl:call-template name="jobDetailLink">
                <xsl:with-param name="job_id" select = "JobID" />
			  </xsl:call-template>
            </td>
			<td><xsl:value-of select="RunHostName" /></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="StartDate" /></td>
			<td>
                <xsl:if test="HeartbeatStale = 1"><xsl:attribute name="class">error</xsl:attribute></xsl:if>
			    <xsl:value-of select="Heartbeat" />
            </td>
			<td class="right">
				<xsl:value-of select="Duration" />
			</td>
            <xsl:call-template name="pauseCheckBox" />
		</tr>
	</xsl:template>

</xsl:stylesheet>
