{block "filter-opener"}
   <label class="btn btn-outlined filter-opener-btn" for="filter-opener">
      {t}Filtrovat{/t}
   </label>
   <input type="checkbox" id="filter-opener" class="custom-control-input filter-opener-input">
{/block}

<div class="filter-wrapper" id="filtr-obal">
   {block "filter-header"}<h2>{t}Filtr{/t}<label class="btn btn-outlined filter-opener-btn" for="filter-opener"></label></h2>{/block}
   <form method="get" action="{url s=category}" data-filter="form">

      {$body.dynamic_filter.price = $body.dynamic_filter.filter->getPriceRange()}

      {if !$body.producer}
         {$body.dynamic_filter.producers = $body.dynamic_filter.filter->getProducers()}
      {else}
         {$body.dynamic_filter.series = $body.dynamic_filter.filter->getSeries()}
      {/if}

      {$body.dynamic_filter.sex = $body.dynamic_filter.filter->getSex()}

      {foreach $body.dynamic_filter.parameters as $id => $parameter}
         {$values = $body.dynamic_filter.filter->getParameter($id, $parameter.value_type)}
         {$body.dynamic_filter.parameters[$id].values = $values.values}
      {/foreach}

      {if $body.category['data']['sizes_filter'] == 'Y'}
         {$body.dynamic_filter.sizes = $body.dynamic_filter.filter->getSizes()}
      {/if}

      {function param}
         {$filterItem = $parameter.name|strip_accent}
         <div class="row filter-row filter-{$filterItem} filter-id-{$id_parameter}">
            <input type="hidden" name="dynamic_filter[parameters][{$id_parameter}][type]" value="{$parameter.value_type}"
                   data-filter-input="{$filterItem}">

            <h4 data-opener=".{$filterItem}-box-wrapper" class="{if $open}active{/if} filter-opener m-b-0">{$parameter.name}</h4>

            <div class="{$filterItem}-box-wrapper opener-content {if $parameter.values > 9}scrollbar" data-simplebar
                 data-simplebar-auto-hide="false{/if}" {if !$open}style="display: none;"{/if}>
               {if $parameter.value_type == "list" or $parameter.value_type == "char"}
                  {foreach $parameter.values as $value}
                     <label class="custom-checkbox custom-control check-{$value.id}">
                        <input class="custom-control-input" type="checkbox" name="dynamic_filter[parameters][{$id_parameter}][value][]"
                               value="{$value.id}"
                               data-filter-input="{$filterItem}">
                        <span class="custom-control-indicator"></span>
                        {$value.name}
                        <small> (<span class="filter-count" data-filter-count="{$value.id}">{$value.count}</span>)</small>
                     </label>
                  {/foreach}
               {elseif $parameter.value_type == "float" and $parameter.values.range.min < $parameter.values.range.max}
                  <input type="text" id="{$filterItem}" name="dynamic_filter[parameters][{$id_parameter}][value]" class="form-control"
                         data-filter-input="{$filterItem}">
                  <div class="p-b-2"></div>
                  <div data-filter-range="{$filterItem}"></div>
                  <div class="p-b-1"></div>
               {else}
                  {t}Neznámý typ parametru{/t}
               {/if}
            </div>
         </div>
      {/function}

      {include "filter/filter.sex.pcch.tpl"}

      {if $body.dynamic_filter.parameters[28].values and $body.dynamic_filter.parameters[29].values}
         {include "filter/filter.productType.tpl"}
      {elseif $body.dynamic_filter.parameters[28].values}
         {param parameter=$body.dynamic_filter.parameters[28] id_parameter=28 open=True}
      {/if}

      {include "filter/filter.section.tpl"}

      {if $body.category.id}
         {foreach $body.dynamic_filter.parameters as $id_parameter => $parameter}
            {if !in_array($id_parameter, [18, 28, 29]) and $parameter.values && $parameter.figure!='N'}
               {param parameter=$parameter id_parameter=$id_parameter}
            {/if}
         {/foreach}
      {/if}

      {assign 'showProducerFilter' {$body.dynamic_filter.producers.values and !$body.producer}}
      {assign 'showSeriesFilter' {$body.dynamic_filter.series.values and $body.producer}}

      {include "filter/filter.producer.tpl" visible_count=9}
      {include "filter/filter.serie.tpl" visible_count=9}
      {include "filter/filter.price.tpl"}
      {include "filter/filter.size.pcch.tpl"}

   </form>
   {block "filter-footer"}{/block}
</div>

{include "filter/filter.script.tpl"}
