<h1 class="title"><?= __('Tracker') ?></h1>

<ul class="breadcrumber">
    <li><a href="<?= url_to('/') ?>" data-ajax><?= __('Home') ?></a></li>
    <?php if ($category): ?>
        <li><a href="<?= url_to('/trackers') ?>" data-ajax><?= __('Trackers') ?></a></li>
        <li class="active"><?= $category['name'] ?></li>
    <?php else: ?>
        <li class="active"><?= __('Trackers') ?></li>
    <?php endif ?>
</ul>

<div class="text-center">
    <?php foreach ($categories as $cat): ?>
        <a data-ajax href="<?= url_to('/trackers/' . $cat['id']) ?>" class="btn-secondary<?= $cat['id'] === $category['id'] ? ' active' : '' ?>"><?= $cat['name'] ?></a>
    <?php endforeach ?>
</div>

<?php foreach ($versions as $version): ?>
    <h2 class="title"><?= __('Version') ?> <?= $version['version'] ?></h2>
    <ul class="trackers">
        <?php foreach ($version['trackers'] as $tracker): ?>
            <li>
                <span>
                    <a data-ajax href="<?= url_to('/trackers/view/' . $tracker['id']) ?>" data-toggle-visibility="tracker-<?= $tracker['id'] ?>">
                        #<?= $tracker['id'] ?> - <?= $tracker['title'] ?> <?= __('in') ?> <?= util('Date')->dateTime($tracker['create_date']) ?>
                    </a>

                    <?php if ($tracker['closed'] || !logged_in()): ?>
                        <i class="fa fa-thumbs-up vote-up"></i> (<?= $tracker['up'] ?>)
                        <i class="fa fa-thumbs-down vote-down"></i> (<?= $tracker['down'] ?>)
                    <?php else: ?>
                        <a data-ajax-action class="vote-up" href="<?= url_to('/trackers/up/' . $tracker['id']) ?>">
                            <i class="fa fa-thumbs-up"></i> (<?= $tracker['up'] ?>)
                        </a>
                        <a data-ajax-action class="vote-down" href="<?= url_to('/trackers/down/' . $tracker['id']) ?>">
                            <i class="fa fa-thumbs-down"></i> (<?= $tracker['down'] ?>)
                        </a>
                    <?php endif ?>

                    <?php if (!empty($tracker['fixed_in'])): ?>
                        - <strong><?= __('Fixed in version') ?> <?= $tracker['fixed_in'] ?></strong>
                    <?php endif ?>
                </span>
                <span class="badge badge-<?= $tracker['status_color'] ?>"><?= $tracker['status_name'] ?></span>
            </li>
        <?php endforeach ?>
    </ul>
<?php endforeach ?>
