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

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

<div class="market">
    <div class="market-search">
        <form action="<?= url_to('/market/items') ?>" type="get">
            <input type="text" value="<?= isset($q) ? $q : '' ?>" name="q" placeholder="<?= __('Search') ?>" />
        </form>

        <p class="title"><?= __('Category') ?></p>
        <ul>
            <?php foreach (config('item.categories') as $index => $category): ?>
                <li><a data-ajax href="<?= url_to('/market/items?category=' . $index) ?>"><?= $category ?></a></li>
            <?php endforeach ?>
        </ul>
    </div>

    <div class="market-items">
        <?php foreach ($items as $item): ?>
            <div class="item">
                <div class="name"><?= util('Item')->getFullName($item['item']) ?></div>

                <div class="image" data-tooltip data-tooltip-url="<?= tooltip_url($item['item']->getHex()) ?>">
                    <img src="<?= util('Item')->getImage($item['item']) ?>" />
                </div>

                <div class="info">
                    <?= util('Market.Market')->price($item['price'], $item['payment_type']) ?> <?= util('Market.Market')->paymentName($item['payment_type'], $item['coin']) ?>
                </div>

                <?php if ($item['allowed']): ?>
                    <div class="buy">
                        <a data-ajax-action data-confirm="<?= __('Are you sure you want to buy this item?') ?>" href="<?= url_to('/market/buy/' . $item['id']) ?>" class="btn"><?= __('Buy') ?></a>
                    </div>
                <?php endif ?>
            </div>
        <?php endforeach ?>

        <div class="clear"></div>

        <?= $paginator->toHtml() ?>
    </div>
</div>