<?php
use common\modules\product\helpers\FilterHelper;
use yii\helpers\Url;
use yii\web\View;
use frontend\widgets\FilterList;


?>

<div data-category="<?= $category->category_id?>" id="filters" class="filters">

    <div class="properties">

        <div id="filters_main" class="active_tab tab">


            <div class="filterPanel">

                <div class="filtersList"><br />

                    <div class="properties_block">
                        <div class="finput"><input type="text" id="finput" value="" placeholder="Артикул"></div>
                        <button class="sok" style="display: none;" disabled>Найти</button>
                    </div>


                    <div class="filterCat">
                        <?php foreach($groups as $group_name => $group) :?>
                        <div class="properties_block closed">

                            <div class="block_title"><i></i><?= $group_name?></div>

                            <ul class="chechboxes" style="display: none;">
                            <?php foreach($group as $option) :
                                $checked = (isset($filter[$option['group_alias']]) && in_array($option['option_alias'], $filter[$option['group_alias']]));
                                $option_url = Url::to(['catalog/category', 'category' => $category, 'filters' => FilterHelper::getFilterForOption($filter, $option['group_alias'], $option['option_alias'], $checked)]);
                                ?>
                                <li data-checked="<?= $checked ? ' true' : 'false'?>" data-filter='<?= isset($option['cacheKey'])?$option['cacheKey']:''  ?>'>

                                    <input type="checkbox" id="<?= $option['tax_option_id']?>" onchange='<?=$option_url ?>'  class="features-option"   <?= $checked ? ' checked' : ''?> />
                                    <div>
                                        <label for="#<?= $option['tax_option_id']?>">
                                            <a class="filter-link" href="<?= $option_url?>"><?= $option['value']?> <span></span></a>
                                        </label>
                                    </div>

                                </li>
                            <?php endforeach?>

                            </ul>


                        </div>
                        <?php endforeach?>

                        <?php if ($priceLimits['min'] < $priceLimits['max']) :

                            $filterWhitoutPrice = $filter;
                            $filterWhitoutPrice['prices'] = [
                                'min' => '{from}',
                                'max' => '{to}',
                            ];

                            ?>
                            <div id="price_block" class="properties_block"
                                 data-min="<?=$priceLimits['min']?>"
                                 data-max="<?=$priceLimits['max']?>"
                                 data-from="<?=((isset($filter['prices']) && !empty($filter['prices']['min'])) ? $filter['prices']['min'] : $priceLimits['min'])?>"
                                 data-to="<?=(( isset($filter['prices']) && !empty($filter['prices']['max'])) ? $filter['prices']['max'] :  $priceLimits['max'])?>"
                                 data-url="<?= Url::to(['catalog/category','category' => $category,'filters' => $filterWhitoutPrice])?>"
                            >
                                <div class="block_title"><i></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>
                            </div>
                        <?php endif?>
                    </div>


                </div>

            </div>

        </div>

    </div>

</div>



