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

<ul class="breadcrumber">
    <li><a href="<?= url_to('/') ?>" data-ajax><?= __('Home') ?></a></li>
    <li><a href="<?= url_to('/raffles') ?>" data-ajax><?= __('Raffles') ?></a></li>
    <li class="active"><?= $raffle['name'] ?></li>
</ul>

<div class="raffle">

    <?php if (!empty($raffle['description'])): ?>
        <div class="description">
            <?= $raffle['description'] ?>
        </div>
    <?php endif ?>

    <?php if ($raffle['type'] == 1): ?>
        <h2 class="title"><?= __('Rewards') ?></h2>
        <div class="rewards">
            <ul>
                <?php if (!empty($raffle['vip_type'])): ?>
                    <li>
                        <?= __('Vip') ?>
                        <ul>
                            <li><?= $raffle['vip_days'] ?> <?= __('days') ?> <?= util('Account')->vipName($raffle['vip_type']) ?></li>
                        </ul>
                    </li>
                <?php endif ?>

                <?php if (!empty($raffle['credits'])): ?>
                    <li>
                        <?= __('Credits') ?>
                        <ul>
                            <li><?= util('Number')->currency($raffle['credits']) ?></li>
                        </ul>
                    </li>
                <?php endif ?>

                <?php if (!empty($raffle['coins'])): ?>
                    <li>
                        <?= __('Coins') ?>
                        <ul>
                            <?php foreach ($raffle['coins'] as $name => $amount): ?>
                                <li><?= $amount ?> <?= util('Coin')->name($name) ?></li>
                            <?php endforeach ?>
                        </ul>
                    </li>
                <?php endif ?>
            </ul>
        </div>
    <?php endif ?>

    <form data-ajax action="<?= url_to('/raffles/' . $raffle['id'] . '/purchase') ?>" method="post">
        <?= csrf_field() ?>

        <input type="hidden" value="" name="numbers" id="raffle-numbers" />

        <div class="numbers">
            <?php foreach ($numbers as $number): ?>
                <?php if ($number['allowed']): ?>
                    <a href="#" class="number allowed" data-price="<?= $raffle['price'] ?>" data-number="<?= $number['number'] ?>"><?= $number['number'] ?></a>
                <?php else: ?>
                    <span class="number<?= $number['my'] ? ' my' : '' ?>"><?= $number['number'] ?></span>
                <?php endif ?>
            <?php endforeach ?>
        </div>

        <div class="align-center" style="margin:30px 0">
            <span id="raffle-price"></span>
        </div>

        <div class="text-center">
            <button type="submit" class="btn"><?= __('Purchase numbers') ?></button>
        </div>
    </form>
</div>
