<?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.");
}
$catid = $_GET['cat'];
$cat = $binstack->get('categories', 'catname', ['catid' => $catid]);

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

$items = [];

foreach ($dbitems as $i) {
    $items[] = new Item($i);
}
?>
<div class="container mt-4">
    <h1 class="display-4"><?php echo $cat; ?></h1>

    <div class="list-group list-group-flush">
        <?php
        foreach ($items as $i) {
            echo RenderItem::line($i);
        }
        ?>
    </div>
</div>