<?php
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

if (!defined('NICKELBOX')) {
    die("Direct access denied.");
}   

$dbitems = $binstack->select('items', 'itemid', ['AND' => ['price[>]' => 0], 'LIMIT' => 20]);

$items = [];

foreach ($dbitems as $i) {
    $items[] = new Item($i);
}
?>
<div class="container mt-4">
    <div class="row">
        <div class="col-md-4 col-xl-3 d-none d-md-block">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">Categories</h5>
                    <ul class="list-group list-group-flush">
                        <?php
                        foreach ($categories as $c) {
                            ?>
                            <li class="list-group-item">
                                <a href="./?page=browse&cat=<?php echo $c['id']; ?>">
                                    <?php echo $c['name']; ?>
                                </a>
                            </li>
                            <?php
                        }
                        ?>
                    </ul>
                </div>
            </div>
        </div>

        <div class="col-md-8 col-xl-9 d-flex flex-wrap">
            <?php
            foreach ($items as $i) {
                echo RenderItem::card($i);
            }
            ?>
        </div>
    </div>
</div>