<?php
/** @var $this \yii\web\View */
/** @var $dataProvider \yii\data\ActiveDataProvider */

$this->title = $category->categoryName->value;
foreach($category->getParents()->all() as $parent) {
    $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'alias' => $parent->alias]];
}
$this->params['breadcrumbs'][] = $category->categoryName->value;
?>
<script type="text/javascript">
    $(document).ready(function() {
        // price rangeslider (filter price slider)
        $("#price_interval").ionRangeSlider({
            type: "double",
            min: <?= $priceMin?>,
            max: <?= $priceMax?>,
            from: <?= $priceMinCurr?>,
            to: <?= $priceMaxCurr?>,
            grid: false
        });
    });
</script>
<div class="w_960">
    <!-- side bar with all filters -->
    <div class="cat_p_filter_bar">
        <div class="title">ФИЛЬТРЫ</div>
        <div class="filter_list">
            <form action="#" name="filter_catalog_page_form">
                <ul>
                    <li>Цена:
                        <div class="arrow"><img src="/images/head_up.png" alt=""></i></div>
                        <div class="price_filter first_price_li">
                            <div class="price_slider">
                                <input type="text" id="price_interval" name="price_interval" value="" />
                            </div>
                            <!--<div class="checkbox">
                                <label><input type="checkbox" name="venecia" value="0" /></label>
                                <a href="#">Акции</a>
                            </div>
                            <div class="checkbox">
                                <label><input type="checkbox" name="venecia" value="0" /></label>
                                <a href="#">Товар в наличии</a>
                            </div>
                            <div class="checkbox">
                                <label><input type="checkbox" name="venecia" value="0" /></label>
                                <a href="#">Хит продаж</a>
                            </div>-->
                        </div>
                    </li>

                    <?php if ($brands_count) :?>
                    <li>Бренд
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter<?= !empty($_brands)?' active-field':''?>">
                        <?php foreach($brands as $brand) :?>
                            <div class="checkbox">
                                <label><input type="checkbox" name="brand[]" value="<?= $brand->alias?>"<?= isset($_GET['brand']) && in_array($brand->alias, $_GET['brand']) ? ' checked' : ''?> /></label>
                                <a href="#<?php /*= \yii\helpers\Url::to(['brand', 'alias' => $brand->alias])*/?>"><?= $brand->name?><!-- (<?php /*= $brand->getProducts()->count()*/?>)--></a>
                            </div>
                        <?php endforeach?>
                            <!--<div class="checkbox see_all">
                                <i class="fa fa-plus-circle"></i>
                                <a href="#">посмотреть все</a>
                            </div>-->
                        </div>
                    </li>
                    <?php endif?>

                    <?php if (!empty($groups)) :?>
                    <div class="title_2">ПОДБОР ПО ПАРАМЕТРАМ</div>

                        <?php foreach($groups as $group) :?>
                        <li><?= $group->name?>
                            <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                            <div class="price_filter<?= isset($options[$group->alias])?' active-field':''?>">
                                <?php foreach($group->_options as $option) :?>
                                <div class="checkbox">
                                    <label><input type="checkbox" name="option[<?= $group->alias?>][]" value="<?= $option->alias?>"<?= (isset($options[$group->alias]) && in_array($option->alias, $options[$group->alias])) ? ' checked' : ''?> /></label>
                                    <a href="#"><?= $option->ValueRenderHTML?>&nbsp;(<?= $option->_items_count?>)</a>
                                </div>
                                <?php endforeach?>
                            </div>
                        </li>
                        <?php endforeach?>
                    <?php endif?>

                </ul>

                <div class="filter_accept_bloc">
                    <button type="submit" class="filter_accept_btn">применить</button>
                    <a href="#" class="form_checkbox_reset">сбросить фильтры</a>
                </div>
            </form>
            <!--<div class="product_list">
                <h2 class="title">КАТАЛОГ ТОВАРОВ</h2>
                <ul>
                    <li>Битумная черепица
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>Комплектация кровли
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>Водосточные системы
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>Чердачные лестницы
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>Мансардные окна
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>Металлочерепица
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>Плоская кровля
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>Профнастил
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>Ондулин
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                    <li>OSB плиты
                        <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                        <div class="price_filter">
                            <a href="#">RUUKI</a>
                            <a href="#">Venecia</a>
                        </div>
                    </li>

                </ul>
            </div>-->
        </div>


    </div>

    <!-- catalog list with all item cards -->
    <div class="cat_p_catalog_list">
        <div class="title"><?= $category->categoryName->value?> <span>(<?= $all_count?>)</span></div>

        <?php if (empty($products)) :?>
            <h2>По данному запросу товары не найдены.</h2><br>
            <p>Показать <a href="<?= \yii\helpers\Url::to(['catalog/category', 'alias' => $category->alias])?>">все товары из категории "<?= $category->categoryName->value?>"</a></p>
        <?php else :?>
        <!-- sort menu -->
        <div class="sort_menu">

            <div class="sort_price">
                <span>Сортировка:</span>
                <?= \yii\widgets\LinkSorter::widget([
                    'sort' => $sort,
                    'attributes' => [
                        'name',
                        'price',
                    ]
                ]);
                ?>
                <!--
                <select name="sort_price" id="" class="sort_price_select">
                    <option value="price">по цене</option>
                    <option value="popular">новые</option>
                    <option value="sale">по акции</option>
                </select>
                <i class="fa fa-angle-down"></i>-->
            </div>

            <div class="show">
                <!--<span>Показывать по:</span>
                <ul>
                    <li><a class="active" href="#">24</a></li>
                    <li><a href="#">48</a></li>
                    <li><a href="#">96</a></li>
                </ul>-->
            </div>

            <div class="show_pages">
                <?php if ($pages->totalCount > $pages->pageSize) :?>
                <span>Страница:</span>
                <?= \yii\widgets\LinkPager::widget([
                    'pagination' => $pages,
                    'options' => ['class' => 'pagination pull-right'],
                ]);
                ?>
                <!--<i class="fa fa-caret-right"></i>-->
                <?php endif?>
            </div>

        </div>


        <div class="cat_p_item_card_list">
            <div class="novelty">
                <div class="content">
                    <div class="novelty_cont">
                    <?php foreach($products as $product) :?>
                        <?php require(__DIR__ .'/product_item.php')?>
                    <?php endforeach?>
                    </div>

                    <?php if ($pages->totalCount > $pages->pageSize) :?>
                    <!-- LOAD MORE BUTTON -->
                    <!--button class="load_more_btn">Загрузить еще <?= $per_page?> товара</button-->

                    <div class="show_pages">
                        Страница:
                        <?= \yii\widgets\LinkPager::widget([
                            'pagination' => $pages,
                            'options' => ['class' => 'pagination pull-right'],
                        ]);
                        ?>
                        <!--<i class="fa fa-caret-right"></i>-->
                    </div>
                    <?php endif?>
                    <hr>

                    <?php if(!empty($category->description)) :?>
                    <div class="description">
                        <?= $category->description?>

                        <div class="empty_padding_400"></div>
                    </div>
                    <?php endif?>
                </div>
            </div>
        </div>

        <?php endif?>
    </div>
</div>

