<?php
$escape = $this->plugin('escapeHtml');
$this->htmlElement('body')->appendAttribute('class', 'job show');
if ($job->started()) {
    $started = $this->i18n()->dateFormat($job->started(), 'long', 'long');
} else {
    $started = $this->translate('[not started]');
}
if ($job->ended()) {
    $ended = $this->i18n()->dateFormat($job->ended(), 'long', 'long');
} else {
    $ended = $this->translate('[not ended]');
}
if ($owner = $job->owner()) {
    $ownerText = $this->escapeHtml($owner->email());
} else {
    $ownerText = $this->translate('[no owner]');
}
?>
<h1><?php echo sprintf($this->translate('Job #%s'), $escape($job->id())); ?></h1>
<div id="page-actions">
    <?php if ('in_progress' == $job->status()): ?>
        <?php echo $this->form($confirmForm); ?>
    <?php endif; ?>
</div>

<div class="meta-group">
    <h4><?php echo $this->translate('Status'); ?></h4>
    <div class="value"><?php echo $job->statusLabel(); ?></div>
</div>
<div class="meta-group">
    <h4><?php echo $this->translate('Started'); ?></h4>
    <div class="value"><?php echo $started; ?></div>
</div>
<div class="meta-group">
    <h4><?php echo $this->translate('Ended'); ?></h4>
    <div class="value"><?php echo $ended; ?></div>
</div>
<div class="meta-group">
    <h4><?php echo $this->translate('Class'); ?></h4>
    <div class="value"><?php echo $job->jobClass(); ?></div>
</div>
<div class="meta-group">
    <h4><?php echo $this->translate('Owner'); ?></h4>
    <div class="value"><?php echo $ownerText; ?></div>
</div>
<div class="meta-group">
    <h4><?php echo $this->translate('Args'); ?></h4>
    <?php if ($job->args()): ?>
        <?php $args = json_encode($job->args(), JSON_PRETTY_PRINT); ?>
        <div class="value"><pre><?php echo $args; ?></pre></div>
    <?php else: ?>
    <div class="value"><?php echo $this->translate('[no args]') ?></div>
    <?php endif; ?>
</div>
<div class="meta-group">
    <h4><?php echo $this->translate('Log'); ?></h4>
    <div class="value">
    <?php if ($job->log()): ?>
    <?php echo $this->hyperlink($this->translate('view log'),
        $this->url(null, ['action' => 'log'], true),
        ['target' => '_blank']) ?>
    <?php else: ?>
    <?php echo $this->translate('[no log]') ?>
    <?php endif; ?>
    </div>
</div>
