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

<ul class="breadcrumber">
    <li><a href="<?= url_to('/') ?>" data-ajax><?= __('Home') ?></a></li>
    <li class="active"><?= __('Packages') ?></li>
</ul>

<?= config('packages.info') ?>

<?php if (logged_in()): ?>
    <div class="mb-3">
        <p class="saldo">
            <?= __('Your current balance is %s', [util('Number')->currency(user()->getCredit())]) ?>
            <a data-ajax class="btn bg-orange" href="<?= url_to('/donate') ?>"><?= __('Add credits') ?></a>
        </p>
    </div>

    <hr>
<?php endif ?>

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

<hr>

<ul class="credit-shop">
    <?php foreach ($packages as $package): ?>
        <li>
            <p class="title"><?= $package['package'] ?></p>
            <p class="desc">
                <?php if (empty($package['image'])): ?>
                    <?= nl2br($package['description']) ?>
                <?php else: ?>
                    <img src="<?= upload_to('/packages/' . $package['image']) ?>" width="168" />
                <?php endif ?>
            </p>

            <?php if ($package['max_sold']): ?>
                <div class="sold text-center">
                    <?= $package['sold'] ?>/<?= $package['max_sold'] ?>
                </div>
            <?php endif ?>

            <p class="price"><?= util('Number')->currency($package['price']) ?></p>

            <div class="buy">
                <a data-ajax href="<?= url_to('/packages/view/' . $package['id']) ?>" class="btn"><?= __('View') ?></a>
            </div>
        </li>
    <?php endforeach ?>
</ul>