<!-- job/running.phtml -->

<?php if ( $this->resultDirRunningJobs ): ?>
<?php
	if ($this->resultDirRunningJobs[0] == 'NOFOUND') {
		echo '<font color="red"><p>',
		      $this->translate->_("ERROR: Cannot execute bconsole. File not found."), '</p></font>';
	}
 	elseif ($this->resultDirRunningJobs[0] == 'ERROR') {
 		echo '<font color="red"><p>',
 		     $this->translate->_("ERROR: There was a problem executing bconsole. See below."), '</p>';
 		foreach ($this->resultDirRunningJobs as $line) {
			echo $line, '<br>';
		}
		echo '</font>';
 	} else	{
?>

<table id="box-table">
<caption><?php echo $this->escape($this->titleDirRunningJobs); ?></caption>
<thead>
<tr>
	 <th scope="col"> <?php print $this->translate->_("Job Id");   ?> </th>
     <th scope="col"> <?php print $this->translate->_("Level");    ?> </th>
     <th scope="col"> <?php print $this->translate->_("Job Name"); ?> </th>
     <th scope="col"> <?php print $this->translate->_("Status");   ?> </th>
</tr>
</thead>
<tbody>
<?php foreach($this->resultDirRunningJobs as $line) : ?>
<tr>
    <td>
        <a href="<?php echo $this->baseUrl .'/log/view-log-id/jobid/'. $this->escape($line['id']). '/jobname/' . $this->escape($line['name']); ?>">
            <?php echo $this->escape($line['id']);?>
        </a>
    </td>
    <td><?php echo $this->escape($line['level']);?></td>
    <td><?php echo $this->escape($line['name']);?></td>
    <td><?php echo $this->escape($line['status']);?></td>
</tr>
<?php endforeach; ?>
<tbody>
</table>

<?php
}
?>

<?php else : ?>
<div class="ui-widget" style="float: left;">
	<div class="ui-state-highlight ui-corner-all" style="padding: 0pt 0.7em; margin-top: 20px;">
		<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: 0.3em;"></span>
		<strong><?php print $this->translate->_("Information from Director : No Running Jobs found."); ?></strong></p>
	</div>
</div>
<div style="clear: both;"><!--  --></div>
<?php endif; ?>



<div style="margin-top: 1.5em;">&nbsp;</div>



<?php if ( $this->resultRunningJobs ): ?>

<table id="box-table">
<caption><?php echo $this->escape($this->titleRunningJobs); ?></caption>
<thead>
<tr>
	 <th scope="col"> <?php print $this->translate->_("Job Id"); 	 ?> </th>
     <th scope="col"> <?php print $this->translate->_("Job Name"); ?> </th>
     <th scope="col"> <?php print $this->translate->_("Status"); 	 ?> </th>
     <th scope="col"> <?php print $this->translate->_("Level");    ?> </th>
     <th scope="col"> <?php print $this->translate->_("Errors"); ?> </th>
     <th scope="col"> <?php print $this->translate->_("Client");   ?> </th>
     <th scope="col"> <?php print $this->translate->_("Pool"); 	 ?> </th>
     <th scope="col"> <?php print $this->translate->_("Start Time"); ?><br /> <?php print $this->translate->_("yy-mm-dd"); ?> </th>
     <th scope="col"> <?php print $this->translate->_("Duration"); ?> <br /> <?php print $this->translate->_("hh-mm-ss"); ?> </th>
     <th scope="col">&nbsp;</th>
</tr>
</thead>
<tbody>
<?php foreach($this->resultRunningJobs as $line) : ?>
<tr>
    <td>
        <a href="<?php echo $this->baseUrl .'/log/view-log-id/jobid/'. $this->escape($line['jobid']). '/jobname/' . $this->escape($line['jobname']); ?>">
            <?php echo $this->escape($line['jobid']);?>
        </a>
    </td>
    <td><?php echo $this->escape($line['jobname']);?></td>
    <?php
        if ( $this->escape($line['joberrors']) != 0 )	{
            echo '<td class="err" align="center"> ',
                 $this->translate->_( $this->escape($line['jobstatuslong']) ), ' </td>';
        }
        else
            echo '<td align="center">',
                 $this->translate->_( $this->escape($line['jobstatuslong']) ), '</td>';
    ?>

    <td align="center"><?php echo $this->escape($line['level']);?></td>

	<?php
		if ( $this->escape($line['joberrors']) == 0 )
			echo '<td align="center">-</td>';
		else
			echo '<td class="err" align="right">', $this->escape($line['joberrors']), '</td>';
	?>

	<td ><?php echo $this->escape($line['clientname']);?></td>

	<td><a href="<?php echo $this->baseUrl, "/volume/find-pool-id/id/", $this->escape($line['poolid']),
		"/name/", $this->escape($line['poolname']);?>" title="<?php print $this->translate->_("Detail Pool"); ?>">
		<?php echo $this->escape($line['poolname']);?></a>
	</td>

	<td><?php echo $this->escape($line['starttime']);?></td>
	<td align="right"><?php echo $this->escape($line['durationtime']);?></td>

    <!-- cancel jobid -->
    <td style="padding: 0px; width:16px;"><?php
        echo '<a href="';
        echo $this->baseUrl, '/job/cancel-job/jobid/', $this->escape($line['jobid']);
        echo '" title="', $this->translate->_("Cancel"), '">';
        echo '<img src="', $this->baseUrl, '/images/process-stop.png" alt="', $this->translate->_("Cancel"), '" border="0" hspace="1">';
        echo '</a>';
    ?>
    </td>

</tr>
<?php endforeach; ?>
</tbody>
</table>


<?php else: ?>
<div class="ui-widget" style="float: left;">
	<div class="ui-state-highlight ui-corner-all" style="padding: 0pt 0.7em; margin-top: 20px;">
		<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: 0.3em;"></span>
		<strong><?php print $this->translate->_("Information from DB Catalog : No Running Jobs found.");?></strong></p>
	</div>
</div>
<div style="clear: both;"><!--  --></div>
<?php endif; ?>