<!-- job/find-file-name.phtml -->

<?php if ($this->msg): ?>
<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 echo $this->msg; ?></strong></p>
	</div>
</div>
<div style="clear: both;"><!--  --></div>
<?php endif; ?>

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

<table id="box-table-minimalist" border="0">
<caption><?php echo $this->escape($this->title); ?></caption>
<thead>
<tr>
     <th scope="col">&nbsp;</th>
	 <th scope="col"> <?php print $this->translate->_("Job Id"); ?> </th>
	 <th scope="col">&nbsp;</th>
	 <th scope="col"> <?php print $this->translate->_("Name File"); ?> </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->_("Client"); ?> </th>
     <th scope="col"> <?php print $this->translate->_("Pool"); ?> </th>
     <th scope="col"> <?php print $this->translate->_("Start Time"); ?></th>
     <th scope="col"> <?php print $this->translate->_("Files"); ?> </th>
     <th scope="col"> <?php print $this->translate->_("Bytes"); ?> </th>
     <th scope="col"> <?php print $this->translate->_("Errors"); ?> </th>
</tr>
</thead>
<tbody>
<?php foreach($this->result as $line) : ?>
<tr>
    <td>
        <?php
            if ( isset($line['poolid'], $line['poolname']) )	{
                echo '<a href="',
                    $this->baseUrl, '/restorejob/main-form/jobid/', $this->escape($line['jobid']),
                    '" title="', $this->translate->_("Restore Job") , '">',
                    '<img src="', $this->baseUrl .'/images/restore.png" alt="',
                    $this->translate->_("Restore Job"), '" border="0" hspace="5"></a>';
            }
        ?>
    </td>
	<td>
		<?php
			if ( isset($line['poolid'], $line['poolname']) )	{
				echo '<a href="',
				    $this->baseUrl, '/job/detail/jobid/', $this->escape($line['jobid']),
				    '" title="', $this->translate->_("Detail Job"), '">';
			}
			echo $line['jobid'];
			if ( isset($line['poolid'], $line['poolname']) )	{
				echo '</a>';
			}
		?>
	</td>

    <!-- restore single file -->
    <td>
        <?php
            if ( isset($line['poolid'], $line['fileid']) )    {
                echo '<a href="',
                    $this->baseUrl, '/restorejob/restore-single-file/fileid/', $this->escape($line['fileid']),
                    '" title="', $this->translate->_("Restore File") , '">',
                    '<img src="', $this->baseUrl .'/images/restore-small.png" alt="',
                    $this->translate->_("Restore File"), '" border="0" hspace="2"></a>';
            }
        ?>
    </td>

	<!-- FileName -->
	<td><?php echo $this->escape($line['path']), $this->escape($line['filename']);?></td>

	<!-- Job.Name -->
	<td><?php echo $this->escape($line['jobname']);?></td>

	<!-- Status -->
	<?php
		$class_td = '';
		if ( $line['joberrors'] != 0 )	{
		    if ( $line['jobstatus'] == 'T' )	{
		        $class_td = 'class="warn"';
		    } else {
		        // 100% что была какая-то ошибка
		        $class_td = 'class="err"';
		    }
			echo '<td ', $class_td, ' align="center"> ', $this->translate->_( $this->escape($line['jobstatuslong']) ), ' </td>';
		}
		elseif	( $line['jobstatus'] == 'T' )	{
			echo '<td align="center">OK</td>';
		} else {
		    // ошибок вроде нет, но что-то не в порядке
		    if ( $line['jobstatus'] == 'f' )	{
		        // fatal error
                $class_td = 'class="err"';
		    } else {
		        $class_td = 'class="warn"';
		    }
			echo '<td ', $class_td, ' align="center">', $this->translate->_( $this->escape($line['jobstatuslong']) ), '</td>';
		}
	?>

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

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

			if ( isset($line['poolid']) && isset($line['poolname']) )	{
				echo $this->escape($line['poolname']);
				echo '</a>';
			}	else {
				echo '&nbsp;';
			}
		?>
	</td>

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

	<?php
		if ( ($line['jobfiles'] == 0) && ($line['type'] != 'D') )
            $class = 'class="warn"';
		else
            $class = '';
		echo '<td ', $class, ' align="right">', number_format($line['jobfiles']), '</td>';
	?>

	<?php
        if ( ($line['jobbytes'] == 0) && ($line['type'] != 'D') )
            $class = 'class="warn"';
        else
            $class = '';
		echo '<td ', $class, ' align="right">', $this->convBytes($line['jobbytes']), '</td>';
	?>

	<!-- Errors -->
	<?php
		if ( $line['joberrors'] == 0 )
			echo '<td align="right">&nbsp;</td>';
		else  {
		    echo '<td class="err" align="right">';
		    echo '<a href="';
			echo $this->baseUrl, '/log/view-log-id/jobid/', $this->escape($line['jobid']),
			     '" title="', $this->translate->_("View Messages"), '" class="lerr">';
			echo $this->escape($line['joberrors']), '</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->_("No Files found."); ?></strong></p>
	</div>
</div>
<div style="clear: both;"><!--  --></div>
<?php endif; ?>
