<?php
slot('title', 'Каталог - ' . __(sfConfig::get('app_www_title')));
?>

<div class="breadcrumbs">
    <a href="/" title="Главная">Главная</a>
    <i class="arrow"></i>
    <a href="<?php echo url_for("@catalog"); ?>" title="Каталог">Каталог</a>
    <?php

    $breadcrumbs = $category->getBreadcrumbs();

    if($breadcrumbs)
    {
        foreach($breadcrumbs as $crumb)
        {
            $url = url_for('@catalog_category?alias=' . $crumb['alias']);

            echo '<i class="arrow"></i>';
            echo '<a href="' . $url . '" title="' . $crumb['title'] . '">' . $crumb['title'] . '</a>';
        }

    }


    ?>
</div>

<h1 class="content_title"><?php echo $category->getTitle(); ?></h1>

<div class="catalog_wrap <?php if($viewType == 'onlyProducts' & $viewFilter) echo 'with_filters' ?>">

    <?php

    if($viewType == 'onlyProducts')
    {
        $products = $category->getCatProducts();

        if(count($products > 0))
        {
            ?>


            <table cellspacing="0" cellpadding="0" width="100%">
                <tbody valign="top" align="left">
                <tr>
                    <td width="100%">

                        <?php

                        foreach($products as $product)
                        {
                            include_partial("catalog/product", array("product" => $product));
                        }

                        ?>
                    </td>

                    <?php

                    if($viewFilter)
                    {
                        ?>

                        <td width="1">

                            <div class="catalog_filters custom_slider-ui">

                                <span class="green_link">Тип печи</span>
                                <i class="br10"></i>
                                <label class="custom_checkbox">
                                    <input type="checkbox"><span class="after_checkbox"></span>
                                    <span>Дровяные печи</span>
                                </label>
                                <i class="br10"></i>
                                <label class="custom_checkbox">
                                    <input type="checkbox"><span class="after_checkbox"></span>
                                    <span>Электрические печи</span>
                                </label>


                                <i class="br20"></i>


                                <span class="green_link">Мощность, кВт</span>
                                <i class="br10"></i>
                                <div id="slider_power" class="slider_prop" data-min="2" data-max="40" data-start="[2,40]" data-connect="true"></div>


                                <i class="br50"></i>


                                <span class="green_link">Прогреваемый объем, м³</span>
                                <i class="br10"></i>
                                <div id="slider_amount" class="slider_prop" data-min="2" data-max="40" data-start="[2,40]" data-connect="true"></div>


                                <i class="br50"></i>


                                <span class="green_link">Вес, кг</span>
                                <i class="br10"></i>
                                <div id="slider_weight" class="slider_prop" data-min="45" data-max="90" data-start="45" data-connect="[true,false]"></div>


                                <i class="br50"></i>


                                <span class="green_link">Корпус</span>
                                <i class="br10"></i>
                                <label class="custom_checkbox">
                                    <input type="checkbox"><span class="after_checkbox"></span>
                                    <span>Нержавеющая сталь</span>
                                </label>
                                <i class="br10"></i>
                                <label class="custom_checkbox">
                                    <input type="checkbox"><span class="after_checkbox"></span>
                                    <span>Окрашенная сталь</span>
                                </label>
                                <i class="br10"></i>
                                <label class="custom_checkbox">
                                    <input type="checkbox"><span class="after_checkbox"></span>
                                    <span>Рещетчатая</span>
                                </label>


                                <i class="br20"></i>

                                <a href="" class="bbs_d fs_13 red_link">Сбросить фильтр</a>

                            </div>

                            <script type="text/javascript">
                                $('.slider_prop').each(function(index, element){
                                    window[element.id] = document.getElementById(element.id);

                                    $(window[element.id]).before('<div class="slider_count"><span></span><span></span></div>');

                                    noUiSlider.create(window[element.id], {
                                        start: $(window[element.id]).data('start'),
                                        connect: $(window[element.id]).data('connect'),
                                        margin: 0,
                                        range: {
                                            'min': $(window[element.id]).data('min'),
                                            'max': $(window[element.id]).data('max')
                                        },
                                        step: 1
                                    });

                                    window[element.id].noUiSlider.on('update', function( values, handle ) {
                                        $(this.target).prev().find('span:first-child').text(this.options.range.min);
                                        $(this.target).prev().find('span:last-child').text(this.options.range.max);
                                        var _this = this;

                                        values.forEach(function(value, index, array){
                                            $(_this.target).find('.noUi-origin .noUi-handle[data-handle='+index+']').text(parseInt(value))
                                        });
                                    });
                                });

                                /*var sliderPower = document.getElementById('slider_power');

                                 noUiSlider.create(sliderPower, {
                                 start: [ 2, 40 ],
                                 connect: true,
                                 margin: 0,
                                 range: {
                                 'min': $(sliderPower).data('min'),
                                 'max': $(sliderPower).data('max')
                                 },
                                 step: 1
                                 });

                                 sliderPower.noUiSlider.on('update', function( values, handle ) {
                                 $(this.target).prev().find('span:first-child').text(this.options.range.min);
                                 $(this.target).prev().find('span:last-child').text(this.options.range.max);
                                 var _this = this;

                                 values.forEach(function(value, index, array){
                                 $(_this.target).find('.noUi-origin .noUi-handle[data-handle='+index+']').text(parseInt(value))
                                 });
                                 });


                                 var sliderAmount = document.getElementById('slider_amount');

                                 noUiSlider.create(sliderAmount, {
                                 start: [ 2, 40 ],
                                 connect: true,
                                 margin: 0,
                                 range: {
                                 'min': $(sliderAmount).data('min'),
                                 'max': $(sliderAmount).data('max')
                                 },
                                 step: 1
                                 });

                                 sliderAmount.noUiSlider.on('update', function( values, handle ) {
                                 $(this.target).prev().find('span:first-child').text(this.options.range.min);
                                 $(this.target).prev().find('span:last-child').text(this.options.range.max);
                                 var _this = this;

                                 values.forEach(function(value, index, array){
                                 $(_this.target).find('.noUi-origin .noUi-handle[data-handle='+index+']').text(parseInt(value))
                                 });
                                 });


                                 var sliderWeight = document.getElementById('slider_weight');

                                 noUiSlider.create(sliderWeight, {
                                 start: 45,
                                 connect: [true, false],
                                 margin: 0,
                                 range: {
                                 'min': $(sliderWeight).data('min'),
                                 'max': $(sliderWeight).data('max')
                                 },
                                 step: 1
                                 });

                                 sliderWeight.noUiSlider.on('update', function( values, handle ) {
                                 $(this.target).prev().find('span:first-child').text(this.options.range.min);
                                 $(this.target).prev().find('span:last-child').text(this.options.range.max);
                                 var _this = this;

                                 values.forEach(function(value, index, array){
                                 $(_this.target).find('.noUi-origin .noUi-handle[data-handle='+index+']').text(parseInt(value))
                                 });
                                 });*/
                            </script>

                        </td>

                        <?php
                    }

                    ?>


                </tr>
                </tbody>
            </table>


            <?php



        }
    }
    elseif($viewType == 'onlyCats')
    {
        foreach($category->getCleanChildren() as $child)
        {

            ?>

            <div class="catalog_category_child_item">
                <a href="<?php echo url_for("@catalog_category?alias=" . $child->getAlias()); ?>" class="anb">
                    <img src="/i/n.gif" style="background-image: url(/u/i/<?php echo str_replace('.', '-XS.', $child->getPhoto()); ?>);" alt="">
                    <span class="black_link"><?php echo $child->getTitle(); ?></span>
                </a>
            </div>

            <?php
        }
    }


    ?>

</div>