<?php
    /**
     * @var $model  common\modules\product\models\Product
     */
use yii\helpers\Html;
use yii\helpers\Url;
$category = $model->category;
?>
<div class="catalog_item">
    <div class="wrapper">
        <div class="item_container" >
            <input class="prodInfo" type="hidden" value="[]">
            <div class="title">
                <?= Html::a( $model->name, Url::to(['catalog/product', 'product' => $model->alias]), ['class'=>'btn-product-details'] )?>
            </div>
            <div class="img">
                <a class="btn-product-details" href="<?= Url::to([
                    'catalog/product',
                    'product' => $model->alias
                ]) ?>">
                    <?php
                        foreach($model->events as $event){
                            if($event->banner){
                               echo \common\components\artboximage\ArtboxImageHelper::getImage($event->getImageUrl('banner'), 'banner_list',[
                               'class' => 'banner-in-list'
                               ]);
                            }
                        }

                    ?>
                    <?= \common\components\artboximage\ArtboxImageHelper::getImage($model->variant->imageUrl, 'list', [
                        'alt'   => $model->category->name . ' ' . $model->name,
                        'title' => $model->category->name . ' ' . $model->name,
                        'class' => 'selected'
                    ]) ?>
                </a>
                <div class="info_icons">
                    <a href="#" class="btn buy_button" data-toggle="modal" data-target="#buyForm" data-id="<?=$model->variant->product_variant_id; ?>" lang="145">Купить</a>
                    <ul class="ul wishlike_block hidden">
                        <li class="compare  hidden">
                            <a onclick="add2compare(); return false;" class="compare compare_text_link_3631483" href="#">К сравнению</a>
                            <span class="icon"></span>
                        </li>
                        <li class="like hidden">
                            <a class="like like_text_link_3631483" href="#">В избранное</a><span class="icon"></span>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="price">

              <?php if($model->variant->price_old){?>
                <div class="dlexfduinxipi old_price-wr">
                    <span class="main">
                        <s><?= $model->variant->price_old  ?><span class="currency">грн</span></s>
                    </span>
                </div>
              <?php }?>
                <div class="dlexfduinxipi">
                    Цена:
                    <span class="main">
                        <?= $model->variant->price ?>
                        <span class="currency">грн</span>
                    </span>
                </div>
            </div>
            <div class="additional_info params">
                <div class="block_title">Особенности</div>
                <div class="descr">
                    <div class="info">
                        <ul class="sv">

                            <li><span>Бренд:</span> <?= !empty($model->brand) ? $model->brand->name : '' ?></li>

                            <?php foreach($model->getActiveProperties($category->category_id) as $group): ?>
                                <li><span><?= $group->name ?> <?php foreach($group->_options as $option) : ?>&nbsp;</span><?= $option->ValueRenderHTML ?><?php endforeach ?></li>
                            <?php endforeach; ?>


                        </ul>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="price" style="display: none;">
                    <div class="dlexfduinxipi">
                        Цена:
                        <span class="main">
                            <?php

                            echo '<div class="cost-block" itemprop="offers" itemscope itemtype="http://schema.org/Offer">';

                            // есть скидка
                            echo '<p  class="cost">';
                            if($model->variant->price_old != 0 && $model->variant->price_old != $model->variant->price) {
                                echo '<strike><span id=\'old_cost\' itemprop="price">' . $model->variant->price_old . '</span> грн.</strike>&nbsp;';
                                echo $model->variant->price . ' <span>грн.</span></p>';
                            } else {
                                echo '<span  itemprop="price">'.$model->variant->price . ' </span><span>грн.</span></p>';
                            }
                            echo '<meta itemprop="priceCurrency" content = "UAH">';
                            echo '</div>';

                            ?>
                        </span>
                    </div>
                </div>
            </div>
            <div class="opacity_bg"></div>
        </div>
    </div>
</div>