<?php
/**
 * @var $product Product
 * @var $this View
 */
    use common\components\artboximage\ArtboxImageHelper;
    use common\models\Orders;
    use common\modules\product\models\Product;
    use frontend\assets\FotoramaAsset;
    use frontend\widgets\Seo;
    use common\modules\comment\widgets\CommentWidget;
    use yii\bootstrap\ActiveForm;
    use yii\bootstrap\Html;
    use yii\helpers\Url;
    use yii\web\View;
    use yii\widgets\MaskedInput;
    use frontend\assets\FlipclockAsset;
    FlipclockAsset::register($this);
    FotoramaAsset::register($this);
    $this->title = $product->name;


    $this->params[ 'seo' ][ Seo::TITLE ] = $product->name .' купить в Киеве, Украине недорого  - Лінія Світла';
    $this->params[ 'seo' ][ 'fields' ][ 'name' ] = $product->name;
    $this->params[ 'seo' ][ 'h1' ] =  $product->name;


    $this->params[ 'breadcrumbs' ][] = [
        'label' => $category->name,
        'url'   => [
            'catalog/category',
            'category' => $category,
        ],
    ];

    $this->params[ 'breadcrumbs' ][] = [
        'label' => $product->brand->name,
        'url'   => ['catalog/category', 'category' => $category, 'filters' => ['brands' => [$product->brand->alias]]],
    ];
    $this->params[ 'breadcrumbs' ][] = $product->name . ' #' . $product->variant->sku;
?>

<div class="wrapper white item_container">
    <div class="container">
        <div class="product_detail" itemscope itemtype="http://schema.org/Product">
            
            <h1 itemprop="name"><?= Seo::widget([ 'row' => 'h1' ]) ?></h1>
            <div class="product_code">Код:<?= $product->variant->sku ?></div>
            <div class="clearfix"></div>
            <!-- Image part -->
            
            <div class="img_part">
                
                <div class="position">
                    <div class="img_part_big">
                        <?php if(!empty( $product->images )) : ?>
                            <div class="fotorama" data-allowfullscreen="true" data-nav="thumbs"
                                 data-width="342"
                                 data-height="350">

                                <?php foreach($product->images as $image) : ?>
                                    <a href="<?= $image->imageUrl ?>">
                                        <?= ArtboxImageHelper::getImage($image->imageUrl, 'product_show') ?>
                                    </a>
                                <?php endforeach ?>
                            </div>
                        <?php else : ?>
                            <a href="<?= $product->imageUrl ?>" data-lightbox="image-1" data-title="<?= $product->name;?>">
                                <?= ArtboxImageHelper::getImage($product->imageUrl, 'product_show',[
                                    'alt'=>$product->name." фото 1" ,
                                    'title' => $product->name." фото 1",
                                    'itemprop' => 'image'
                                ]) ?>
                                </a>

                        <?php endif ?>
                    </div>
                    
                    <div class="clearfix"></div>
                    
                    
                    <ul class="detail_main_tabs">
                        <li class="properties" data-target="characteristics">
                            <a href="#characteristics">
                                <span class="text">Характеристики и описание</span>
                            </a>
                            <span class="icon"></span>
                            <span class="arr"></span>
                        </li>
                        
                        <li class="product_collection" data-target="collection">
                            <a href="#collection">
                                <span class="text">Коллекция</span>
                            </a>
                            <span class="icon"></span>
                            <span class="arr"></span>
                        </li>
                        
                        <li class="comments" data-target="reviews">
                            <a href="#reviews">
                                <span class="text">Написать отзыв</span>
                            </a>
                            <span class="icon"></span>
                            <span class="arr"></span>
                        </li>
                    </ul>
                    
                    <div class="floating_helper_block_wrapper">
                        <div class="floating_helper_block" style="visibility: visible; opacity: 1;" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                            <table>
                                <tbody>
                                <tr>
                                    <td>
                                        <?php if( $product->variant->price_old ){?>
                                            <strike><span><span id='old_cost'><?= $product->variant->price_old ?></span></span> грн.</strike>
                                        <?php }?>

                                        <span class="cost"><span itemprop="price"><span id='cost'><?= $product->variant->price ?></span></span> <span class="valute">грн.</span></span>
                                        <meta itemprop="priceCurrency" content="UAH">
                                    </td>
                                    <td>
                                        <!-- Купить -->
                                        <?php if($product->variant->status != 1)
                                        {?>
                                            <a lang="5892" class="btn btnBuy buy_button btn-large1" data-id="<?php echo $product->variant->product_variant_id; ?>" data-toggle="modal" data-target="#buyForm">Купить</a>
                                        <?php } else {?>
                                            <a  href="#" style="background-color:dimgrey; background-image:linear-gradient(to bottom, #9d9fa0, #abafb2);cursor:default !important;color:#fff!important;box-shadow: none !important;border-top: 1px solid #256caf !important;border-bottom: 1px solid #256caf !important;" class="btn btn-large btn-default " data-id="<?php echo $product->variant->product_variant_id; ?>" >снят с производства</a>
                                        <?php } ?>

                                    </td>
                                    <td>
                                        <?php
                                            /* Compare and favorites buttons to be done
                                            ?>
                                            <ul class="wishlike_block ul">
                                                <li class="compare">
                                                    <a class="compare compare_href" name="5892" href="javascript:return false;">К сравнению</a>
                                                    <span class="icon"></span>
                                                </li>
                                                <div class="clearfix"></div>
                                                <li class="like">
                                                    <a data-toggle="modal" data-target="#myWishlist" href="#">В избранное</a>
                                                    <span class="icon"></span>
                                                </li>
                                            </ul>
                                            */
                                        ?>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            
                            <span class="arr"></span>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div><!-- EOF Image part -->
            
            <!-- Info table -->

            <div class="info" style="height: auto; opacity: 1;">


                <table class="info_table">
                    <colgroup>
                        <col style="width: 280px;">
                        <col style="width: 35px;">
                        <col>
                    </colgroup>

                    <tbody>
                    <tr>
                        <?php foreach($product->events as $event):?>
                            <?php if(!empty($event->end_at) && $event->isActive()):?>
                                <div class="event_block">

                                    <div class="event_title"> <?=  Html::a('Акция!!! '.$event->name,Url::to(['event/show','alias'=>$event->alias]))?></div>
                                    <div class="event_time">До конца осталось:</div>
                                    <div class="clock_<?= $event->primaryKey ?> clock_product_first "></div>
                                        <?php
                                            $js = "
                                            var clock;

                                            clock = new FlipClock($('.clock_$event->primaryKey'), {
                                                clockFace: 'DailyCounter',
                                                language: 'ru',
                                                classes: {
                                                    active: 'flip-clock-active',
                                                    before: 'flip-clock-before',
                                                    divider: 'flip-clock-divider',
                                                    dot: 'flip-clock-dot',
                                                    label: 'flip-clock-label',
                                                    flip: 'flip',
                                                    play: 'play',
                                                    wrapper: 'flip-clock-wrapper'
                                                },
                                            });

                                            clock.setTime( ".(strtotime($event->end_at) - strtotime(date('Y-m-d H:i:s'))).");
                                            clock.setCountdown(true);
                                            clock.start();
                                            ";
                                        $this->registerJs($js,View::POS_LOAD)
                                        ?>


                                </div>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </tr>
                    <tr>
                        <td class="left_count available">
                            <?php if($product->variant->status == 1){?>
                                снят с производства
                            <?php } elseif($product->variant->stock > 0) {?>
                                в наличии
                            <?php } else {?>
                                под заказ
                            <?php } ?>
                        </td>
                        <td rowspan="2" class="spacer">&nbsp;</td>
                        <td class="right_block" rowspan="2">
                            <table>
                                <tbody>
                                <tr>
                                    <td class="warranty_block">
                                        <div class="">
                                            <ul class="ul">
                                                <li class="delivery">
                                                    <div class="title">Быстрая доставка</div>
                                                    <div class="descr">
                                                        <p>В любой уголок
                                                            <span class="strong black">Украины:</span><br>
                                                            — Самовывоз Новая Почта - 55 грн.<br>
                                                            — Курьер Новая Почта - 88 грн.<br>
                                                            — Курьер «ИнТайм» - 60 грн.</p>
                                                        <?php if($product->variant->price >= 1000){?>
                                                        <p>
                                                            <span class="strong black">Киев</span>:<br>
                                                            — Курьер - <s>50 грн.</s>
                                                            <span class="bold black up">бесплатно!</span>
                                                            <span class="star_info">*</span><br>
                                                            — Самовывоз -
                                                            <span class="up bold black">бесплатно!</span><br>
                                                            — Пункт Новой Почты - <s>55 грн.</s>
                                                            <span class="bold black up">бесплатно!</span>
                                                            <span class="star_info">*</span>
                                                        </p>
                                                        <?php } else {?>
                                                            <p>
                                                                <span class="strong black">Киев</span>:<br>
                                                                — Курьер - 50 грн
                                                                <span class="star_info">*</span><br>
                                                                — Самовывоз -
                                                                <span class="up bold black">бесплатно!</span><br>
                                                                — Пункт Новой Почты - 55 грн.
                                                                <span class="star_info">*</span>
                                                            </p>
                                                        <?php }?>
                                                        <p>
                                                            <span class="star_info">* Стоимость расчитана для оформляемого заказа</span>
                                                        </p>
                                                        <span class="icon"></span>
                                                    </div>
                                                </li>
                                                <li class="product_back">
                                                    <div class="title">14 дней на обмен</div>
                                                    <div class="descr">без лишних вопросов. Почитайте
                                                        <span class="ajax_link" data-toggle="modal" data-target="#returnСonditions" onclick="">условия возврата</span>
                                                    </div>
                                                    <span class="icon"></span>
                                                </li>
                                                <li class="warranty">
                                                    <div class="title">12 месяцев гарантии</div>
                                                    <div class="descr">официальной от производителя</div>
                                                    <span class="icon"></span>
                                                </li>
                                                <li>
                                                    <div class="title">Условия доставки люстра
                                                        Elstead
                                                        : Киев и вся Украина
                                                    </div>
                                                    <div class="descr">
                                                        Лінія світла - электронный магазин, который обеспечит доставку товаров раздела - люстра Элстед жителям городов: Херсон, а так же др. города Украины.
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td class="price_block">
                            <div class="event_info">
                                <div class="events">
                                    <?php foreach($product->events as $event):?>
                                        <?php if(!empty($event->banner) && $event->isActive()):?>
                                            <?=  Html::a(\common\components\artboximage\ArtboxImageHelper::getImage($event->getImageUrl('banner'), 'banner_list'),Url::to(['event/sale','percent'=>$event->percent]))?>
                                        <?php endif; ?>
                                    <?php endforeach; ?>
                                </div>
                            </div>
                            <div class="price_block_container">


                                <div class="price">
                                            <?php if($product->variant->price_old){?>
                                            <span class="main">
                                                <span class="price"><s><?= $product->variant->price_old ?></s></span>
                                                <span class="currency">&nbsp;грн.</span>
                                            </span>
                                            <?php }?>
                                            <span class="main">
                                                <span class="price"><?= $product->variant->price ?></span>
                                                <span class="currency">&nbsp;грн.</span>
                                            </span>
                                </div>
                                
                                <div class="follow_price">
                                    <?php /* Lower price notify
                                            <a href="#" onclick="" data-toggle="modal" data-target="#price_drop">Узнать о снижении цены</a>
                                             */ ?>
                                </div>
                                
                                <div class="buy_button">
                                    <?php if($product->variant->status != 1){?>
                                        <a href="#" class="btn btn-large buy_button" data-toggle="modal" data-id="<?php echo $product->variant->product_variant_id; ?>" data-target="#buyForm" lang="5892">Купить</a>
                                    <?php }else { ?>
                                        <a href="#"  style="background-color:dimgrey; background-image:linear-gradient(to bottom, #9d9fa0, #abafb2);cursor:default !important;color:#fff!important;box-shadow: none !important;border-top: 1px solid #256caf !important;border-bottom: 1px solid #256caf !important;" class="btn btn-large btn-default "  data-id="<?php echo $product->variant->product_variant_id; ?>" >снят с производства</a>
                                    <?php } ?>
                                    <div class="clearfix"></div>
                                </div>

                                <div>
                                    <div class="payment_visa">
                                        Оплатить
                                        <a href="/text/oplata" target="_blank">
                                            <span class="visa" ></span>
                                        </a>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                                <?php if($product->variant->status != 1){?>
                                    <div class="follow_price">
                                        <a href="#" data-toggle="modal" data-target="#where_buy">где купить?</a>
                                    </div>
                                <?php } ?>

                                
                                <div class="follow_price">
                                    <?php
                                        /* Find cheaper form
                                        ?>
                                        <a href="#" data-toggle="modal" data-target="#found_cheaper">нашли дешевле?</a>
                                        */
                                    ?>
                                </div>
                            
                            </div>
                            <?php
                                /*
                                ?>
                                <ul class="wishlike_block ul  hidden">
                                    <li class="compare">
                                        <a class="compare compare_href" name="5892" href="javascript:return false;">К сравнению</a>
                                        <span class="icon"></span>
                                    </li>
                                    <li class="like">
                                        <a data-toggle="modal" data-target="#myWishlist" class="like" href="#">В избранное</a>
                                        <span class="icon"></span>
                                    </li>
                                </ul>
                                */
                            ?>
                        </td>
                    </tr>
                    
                    <tr>
                        <td>
                            <?php
                                if($product->variant->status != 1) {
                                    ?>
                                    <div class="fast_order_form">
                                        <div class="error_text"></div>
                                        <?php
                                            $quickbuy = new Orders([
                                                'scenario' => Orders::SCENARIO_QUICK,
                                            ]);
                                            $form = ActiveForm::begin([
                                                'id' => 'quickbuy-form',
                                            ]);
                                            echo Html::hiddenInput('product_variant_id', $product->variant->product_variant_id);
                                            echo $form->field($quickbuy, 'phone')
                                                      ->widget(MaskedInput::className(), [
                                                          'mask'    => '+38(999)999-99-99',
                                                          'options' => [
                                                              'type'  => 'tel',
                                                              'class' => 'input phone',
                                                          ],
                                                      ])
                                                      ->label(false);
                                            echo Html::submitInput('Заказать в 1 клик', [ 'class' => 'btn' ]);
                                            $form::end();
                                        ?>
                                        <div class="clearfix"></div>
                                    </div>
                                    <?php
                                }
                            ?>
                        </td>
                    </tr>
                    
                    <tr>
                        <td>
                            <?php
                                if(!empty( $product->averageRating )) {
                                    ?>
                                    <div class="rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
                                        <div class="rateit" data-rateit-value="<?php echo $product->averageRating->value; ?>" data-rateit-ispreset="true" data-rateit-readonly="true"></div>
                                        рейтинг: <span id="product_rate_avg" itemprop="ratingValue"><?=$product->averageRating->value?></span>&nbsp;&nbsp;
                                        голосов: <span id="product_vote_count" itemprop="ratingCount">
                                            <?php
                                                echo count($product->comments);
                                            ?>
                                            </span>
                                        <span class="rating_description" id="rating_description"></span>
                                    </div>
                                    <?php
                                }
                            ?>
                        </td>
                        <td></td>
                    </tr>
                    </tbody>
                </table>
                
                <div class="clearfix"></div>
                
                
                <div class="detail_tabs_content">

                    <div class="clear properties tab_div">
                        <h2 id="characteristics">
                            Характеристики:
                        </h2>
                        
                        <!-- Nav tabs -->
                        <ul class="nav nav-tabs property_show_tabs" role="tablist">
                            <li role="presentation" class="active">
                                <a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">
                                    <span>Все характеристики</span>
                                </a>
                            </li>
                            <li role="presentation">
                                <a href="#tab2" aria-controls="profile" role="tab" data-toggle="tab">
                                    <span style="color:#909090">Описание</span>
                                </a>
                            </li>
                        </ul>
                        
                        <!-- Tab panes -->
                        <div class="tab-content">
                            <div role="tabpanel" class="tab-pane active" id="tab1">
                                
                                <table>
                                    <tbody>
                                    <tr class="full short gray">
                                        <td class="name">ID</td>
                                        <td class="value"><?= $product->variant->sku ?> </td>
                                    </tr>
                                    <tr class="full short">
                                        <td class="name">Бренд</td>
                                        <td class="value"><?= !empty($product->brand) ? $product->brand->name : '' ?></td>
                                    </tr>
                                    <?php foreach($product->getActiveProperties($category->category_id) as $group): ?>
                                        <tr class="full short gray">
                                            <td class="name"><?= $group->name ?></td>
                                            <td class="value"><?php foreach($group->_options as $option) : ?>&nbsp;<?= $option->ValueRenderHTML ?><?php endforeach ?></td>
                                        </tr>
                                    <?php endforeach; ?>
                                    
                                    </tbody>
                                </table>
                            </div>
                            <div role="tabpanel" class="tab-pane" id="tab2">
                                
                                <div class="block-100">
                                    <?= $product->description ?>
                                </div>
                            
                            </div>
                        </div>
                        
                        <div class="clearfix"></div>

                        <?php /*

                        <div class="collection">
                            <br/>
                            <h2 id="collection">
                                Коллекция светильников <!--ДЕКОРА-->
                            </h2>

                            <div class="catalog_product_list view_table">
                                <div class="catalog_item">
                                    <div class="wrapper">
                                        <div class="item_container">
                                            <div class="title">
                                                <a href="http://www.linija-svitla.ua/lyustra-elstead-fe-leila3-5893.htm">люстра FE/LEILA3</a>
                                            </div>
                                            <div class="img">
                                                <a href="http://www.linija-svitla.ua/lyustra-elstead-fe-leila3-5893.htm">
                                                    <img src="http://www.linija-svitla.ua/gallery/prod/fe_leila3/5893_5.jpg" alt="люстра FE/LEILA3" class="selected">
                                                </a>
                                                <div class="info_icons">
                                                    <a href="#" class="btn btnBuy buy_button" data-id="<?php echo $product->variant->product_variant_id; ?>" data-toggle="modal" data-target="#buyForm" lang="5893">Купить светильник</a>
                                                    <ul class="ul wishlike_block">
                                                        <li class="compare">
                                                            <a onclick="add2compare(); return false;" class="compare compare_text_link_5893" lang="5893" href="#">К сравнению</a>
                                                            <span class="icon"></span>
                                                        </li>
                                                        <li class="like">
                                                            <a class="like like_text_link_5893" lang="5893" href="#">В избранное</a><span class="icon"></span>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                            <div class="price">
                                                <div class="dlexfduinxipi">
                                                    Цена:
                                                    <span class="main"> 25794.00 <span class="currency">грн</span>
                                                        </span>
                                                </div>
                                            </div>
                                            <div class="additional_info params">
                                            </div>
                                            <div class="opacity_bg"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="catalog_item">
                                    <div class="wrapper">
                                        <div class="item_container">
                                            <div class="title">
                                                <a href="http://www.linija-svitla.ua/elstead-fe-leila1c-6991.htm"> FE/LEILA1C</a>
                                            </div>
                                            <div class="img">
                                                <a href="http://www.linija-svitla.ua/elstead-fe-leila1c-6991.htm">
                                                    <img src="http://www.linija-svitla.ua/gallery/prod/fe_leila1c/6991_5.jpg" alt=" FE/LEILA1C" class="selected">
                                                </a>
                                                <div class="info_icons">
                                                    <a href="#" class="btn btnBuy buy_button" data-toggle="modal" data-id="<?php echo $product->variant->product_variant_id; ?>" data-target="#buyForm" lang="6991">Купить светильник</a>
                                                    <ul class="ul wishlike_block">
                                                        <li class="compare">
                                                            <a onclick="add2compare(); return false;" class="compare compare_text_link_6991" lang="6991" href="#">К сравнению</a>
                                                            <span class="icon"></span>
                                                        </li>
                                                        <li class="like">
                                                            <a class="like like_text_link_6991" lang="6991" href="#">В избранное</a><span class="icon"></span>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                            <div class="price">
                                                <div class="dlexfduinxipi">
                                                    Цена:
                                                    <span class="main"> 14330.40 <span class="currency">грн</span>
                                                        </span>
                                                </div>
                                            </div>
                                            <div class="additional_info params">
                                            </div>
                                            <div class="opacity_bg"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="catalog_item">
                                    <div class="wrapper">
                                        <div class="item_container">
                                            <div class="title">
                                                <a href="http://www.linija-svitla.ua/nastennyy-svetilnik-elstead-fe-leila2-5894.htm">настенный светильник FE/LEILA2</a>
                                            </div>
                                            <div class="img">
                                                <a href="http://www.linija-svitla.ua/nastennyy-svetilnik-elstead-fe-leila2-5894.htm">
                                                    <img src="http://www.linija-svitla.ua/gallery/prod/fe_leila2/5894_5.jpg" alt="настенный светильник FE/LEILA2" class="selected">
                                                </a>
                                                <div class="info_icons">
                                                    <a href="#" class="btn btnBuy buy_button" data-id="<?php echo $product->variant->product_variant_id; ?>" data-toggle="modal" data-target="#buyForm" lang="5894">Купить светильник</a>
                                                    <ul class="ul wishlike_block">
                                                        <li class="compare">
                                                            <a onclick="add2compare(); return false;" class="compare compare_text_link_5894" lang="5894" href="#">К сравнению</a>
                                                            <span class="icon"></span>
                                                        </li>
                                                        <li class="like">
                                                            <a class="like like_text_link_5894" lang="5894" href="#">В избранное</a><span class="icon"></span>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                            <div class="price">
                                                <div class="dlexfduinxipi">
                                                    Цена:
                                                    <span class="main"> 8598.00 <span class="currency">грн</span>
                                                        </span>
                                                </div>
                                            </div>
                                            <div class="additional_info params">
                                            </div>
                                            <div class="opacity_bg"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="clearfix"></div>

                        </div>
                        */?>



                        <div class="clearfix"></div>
                        <br/>
                        <h2 id="reviews">
                            Отзывы
                        </h2>
                        <div class="comment-wrapper comments comments_block" style="padding-bottom:25px">
                            <?php
                                echo CommentWidget::widget([
                                    'model' => $product,
                                ]);
                            ?>
                            <div class="both"></div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- EOF Info table -->
        </div>
    </div>
</div>
<div class="clearfix"></div>
<div class="modal fade" id="where_buy" tabindex="-1" role="dialog" aria-labelledby="myModalLabel44">
    <div class="modal-dialog text-dialog" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <span class="modal-title" id="myModalLabel4">Где купить?</span>
            </div>

            <div class="modal-body" style="text-transform:uppercase">
                <p>Данный товар есть в наличии в наших розничных магазинах</p>
                <br/>
                <div class="shopsList">
                    <ul>
                        <?php foreach($product->variant->variantStocks as $stock){
                            if($stock->quantity > 0 ){?>
                            <li><?= Html::a($stock->stock->siteName, Url::to (['text/main', 'translit' => 'magaziny', '#'=>$stock->stock->stock_id])) ?></li>
                                <?php } ?>
                        <?php } ?>
                    </ul>

                </div>

                <div class="clearfix"></div>
            </div>

        </div>
    </div>
</div>