<?php
/**
 * YAWIK
 *
 * @filesource
 * @copyright https://yawik.org/COPYRIGHT.php
 * @license   MIT
 */

if (count($jobs)):
$isRecruiter = $this->acl()->isRole( Auth\Entity\User::ROLE_RECRUITER );

?>
<table class="table table-striped table-bordered table-hover" id="jobs-list">
<thead>
<tr>
    <th><?=$this->translate('Date of receipt')?></th>
    <th><?=$this->translate('Title of the job')?></th>
    <th><?=$this->translate('Companyname') ?></th>
    <th><?=$this->translate('Name') ?></th>
    <th><?=$this->translate('Status')?></th>
    <th><?=$this->translate('Action')?></th>
</tr>
</thead>

<tbody>
<?php /* @var Jobs\Entity\Job $job */?>
<?php foreach ($jobs as $job):?>
<tr>
    <td>
        <?php if ($job->getDatePublishStart()): echo $this->dateFormat($job->getDatePublishStart(), 'short', 'none');
              elseif ($job->getDateCreated()): echo $this->dateFormat($job->getDateCreated(), 'short', 'none');
        endif?>
    </td>
    <td>
    <?php $href = $this->url('lang/jobs/view', array(), array('query' => array('id' => $job->getId())), true); ?>
        <a href="<?php echo $href ?>" target="_blank" rel="nofollow"><?php echo strip_tags($job->getTitle())?></a></td>
    <td><?php echo $job->getCompany() ?></td>
        <td>
            <?php
            $displayName = '';
            $user = $job->getUser();
            if (isset($user)) {
                $displayName = $user->getInfo()->getDisplayName();
            }
            echo $displayName

            ?>
        </td>
        <td><?php echo $this->translate($job->getStatus()->getName()); ?></td>
        <td class="btn-group btn-toolbar">
                <a data-title="title"
                   data-toggle="modal"
                   class="btn btn-default btn-xs"
                   data-target="#job-application-history"
                   href="<?php echo $this->url( 'lang/jobs/history', array('id' => $job->getId() , 'lang' => $this->params('lang'))); ?>"
                   title="<?php echo $this->translate('Status history')?>">
                    <i class="yk-icon yk-icon-history"></i>
                </a>
                <a href="<?php echo $this->url('lang/jobs/approval', array('action' => 'edit'), array('query' => array('id' => $job->getId())), true) ?>" class="btn btn-default btn-xs"><span class="yk-icon yk-icon-edit"></span></a>
        </td>
</tr>
<?php endforeach?>
</tbody>

</table>
<?php echo $this->paginationControl($jobs, 'Sliding', 'pagination-control', array('lang' => $this->params('lang'), 'route' => 'lang/jobs/listOpenJobs'));?>



<?php endif ?>