Blame view

frontend/views/catalog/product.php 18.4 KB
055ecc3b   Karnovsky A   Karnovsky 11052016
1
  <?php
01905ec6   Yarik   Filter fixing
2
3
4
      /**
       * @var Category $category
       */
eed13986   Alex Savenko   base
5
  
e608c5f7   Yarik   Comment added
6
      use common\modules\comment\widgets\CommentWidget;
01905ec6   Yarik   Filter fixing
7
      use common\modules\product\models\Category;
eed13986   Alex Savenko   base
8
9
      use yii\helpers\Html;
      use yii\web\View;
85040b57   Yarik   Comment added
10
11
      use yii\helpers\Url;
      use frontend\widgets\Seo;
eed13986   Alex Savenko   base
12
13
14
      use frontend\assets\FlipclockAsset;
  
      FlipclockAsset::register($this);
01905ec6   Yarik   Filter fixing
15
      $this->params[ 'seo' ][ 'key' ] = $category->categoryName->value;
85040b57   Yarik   Comment added
16
      $this->params[ 'seo' ][ 'fields' ][ 'name' ] = $product->fullname;
cfc5b583   Administrator   14.09.16
17
      $this->params[ 'seo' ][ 'h1' ] = !empty( Seo::widget([ 'row' => 'h1' ]) ) ? Seo::widget([ 'row' => 'h1' ]) : $product->fullnamewithcategory;
85040b57   Yarik   Comment added
18
      
85040b57   Yarik   Comment added
19
      $this->title = $product->fullname;
eed13986   Alex Savenko   base
20
21
22
23
  
      $test = $productProvider->getPagination()->getPage();
      $this->registerLink(['rel' => 'next', 'href' => $test);
  
85040b57   Yarik   Comment added
24
25
26
27
28
      $this->params[ 'breadcrumbs' ][] = [
          'label' => 'Каталог',
          'url'   => [ 'catalog/category' ],
      ];
      $this->params[ 'breadcrumbs' ][] = [
01905ec6   Yarik   Filter fixing
29
          'label' => $category->categoryName->value,
85040b57   Yarik   Comment added
30
31
          'url'   => [
              'catalog/category',
01905ec6   Yarik   Filter fixing
32
              'category' => $category,
85040b57   Yarik   Comment added
33
34
          ],
      ];
3ce8e503   Alex Savenko   хлебные крошки
35
36
37
      $this->params[ 'breadcrumbs' ][] = [
          'label' => $category->name.' '.$product->brand->name,
          'url'   => [
fcbb31d1   Alex Savenko   фикс хлебных крош...
38
39
40
41
42
              'catalog/category',
              'category' => $category,
              'filters' => [
                  'brands' => [$product->brand->alias]
              ]
3ce8e503   Alex Savenko   хлебные крошки
43
44
          ],
      ];
e4cea6a9   Administrator   rm node nodule
45
      $this->params[ 'breadcrumbs' ][] = $product->fullname . ' #' . $product->variant->sku;
85040b57   Yarik   Comment added
46
47
      
      $this->registerJs('
055ecc3b   Karnovsky A   Karnovsky 11052016
48
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
49
50
          var checkData = function($index)
          {
f307b0a8   Karnovsky A   -
51
52
53
54
              var sourceNew = $(".productLeftBar .product_mod > li").eq($index);
              $(".productLeftBar .product_mod > li").removeClass("active")
              sourceNew.addClass("active");
              var $source = sourceNew.find("a");
ccc7a9d3   Karnovsky A   Karnovsky 12052016
55
              var $target = $(".productLeftBar .cost_box");
055ecc3b   Karnovsky A   Karnovsky 11052016
56
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
57
58
              $("#cost").text($source.data("cost"));
              $("#old_cost").text($source.data("old_cost"));
055ecc3b   Karnovsky A   Karnovsky 11052016
59
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
60
61
62
63
64
65
66
67
              if (parseInt ($source.data("old_cost")) == 0)
              {
                  $target.find("strike").hide();
              }
              else
              {
                  $target.find("strike").show();
              }
055ecc3b   Karnovsky A   Karnovsky 11052016
68
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
69
70
71
72
73
74
              $("#product_id").val($source.data("id"));
              $("#art").text($source.data("art"));
              $("#color").text($source.data("color"));
              $("#pic").attr("src",$source.data("image"));
              $("#picoriginal").attr("href",$source.data("imageoriginal"));
          }
055ecc3b   Karnovsky A   Karnovsky 11052016
75
  
e4cea6a9   Administrator   rm node nodule
76
77
78
79
          $("body").on("click", ".link_buy_out_stock", function(e){
              e.preventDefault();
          });
          
ccc7a9d3   Karnovsky A   Karnovsky 12052016
80
81
82
          $(".product_mod > li").click(function()
          {
              checkData($(this).index());
055ecc3b   Karnovsky A   Karnovsky 11052016
83
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
84
              Shadowbox.setup($("#picoriginal"));
055ecc3b   Karnovsky A   Karnovsky 11052016
85
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
86
87
              return false;
          });
055ecc3b   Karnovsky A   Karnovsky 11052016
88
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
89
90
91
          checkData(0);
  
      ', View::POS_READY, 'fasovka');
85040b57   Yarik   Comment added
92
93
      
      $this->registerJs("
ccc7a9d3   Karnovsky A   Karnovsky 12052016
94
95
96
97
98
99
100
101
102
103
104
105
          $('#nav_product li a').addClass('active');
          $('#nav_product li').find('.info').toggle();
  
          $('#nav_product li a').bind('click',function()
          {
              if($(this).parent().find('.info').css('display')=='none')$(this).addClass('active');
              else $(this).removeClass('active');
              $(this).parent().find('.info').toggle();
  
              return false;
          });
      ", View::POS_READY, 'nav_product');
85040b57   Yarik   Comment added
106
107
108
109
110
111
112
      
      $this->registerCssFile(Yii::$app->request->BaseUrl . '/js/shadowbox-3.0.3/shadowbox.css');
      $this->registerJsFile(Yii::$app->request->baseUrl . '/js/shadowbox-3.0.3/shadowbox.js', [
          'position' => View::POS_END,
          'depends'  => [ 'yii\web\JqueryAsset' ],
      ]);
      $this->registerJs("
ccc7a9d3   Karnovsky A   Karnovsky 12052016
113
114
115
116
117
          Shadowbox.init({
  
      });
      ", View::POS_READY, 'Shadowbox');
  ?>
af7fb26a   Administrator   20.07.16
118
  
85040b57   Yarik   Comment added
119
  <?php if($flash = Yii::$app->session->getFlash('success')): ?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
120
121
      <div class="alert-success"><?= $flash ?></div>
  <?php endif; ?>
85040b57   Yarik   Comment added
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
      <div class="loyout">
          <div itemscope itemtype="http://schema.org/Product">
              <div class="productLeftBar">
                  <div itemprop="name"><h1><?= Seo::widget([ 'row' => 'h1' ]) ?></h1></div>
                  <?php foreach($product->enabledVariantsGrouped as $variantGroup) : ?>
                      <div class="begin"><?= $variantGroup->name2 ?></div>
                      <ul class="product_mod">
                          <?php foreach($variantGroup->_variants as $variant): ?>
                              <li>
                                  <a id='m<?= $variant->product_variant_id ?>' href="#<?= $variant->product_variant_id ?>"
                                      data-cost="<?= $variant->price ?>"
                                      data-old_cost="<?= $variant->price_old ?>" data-id="<?= $variant->product_variant_id ?>" data-art="<?= $variant->sku ?>"
                                      data-color="<?= $variant->name ?>"
                                      data-image="<?= \common\components\artboximage\ArtboxImageHelper::getImageSrc($variant->imageUrl, 'product_view') ?>"
                                      data-imageoriginal="<?= $variant->imageUrl ?>"
                                      title="<?= $product->fullname ?>">
                                      <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant', [
01905ec6   Yarik   Filter fixing
139
140
                                          'alt'   => $category->categoryName->value . ' ' . $product->fullname,
                                          'title' => $category->categoryName->value . ' ' . $product->fullname,
85040b57   Yarik   Comment added
141
142
143
144
145
146
147
148
149
150
151
152
153
154
                                      ]) ?>
                                  </a>
                              </li>
                          <?php endforeach; ?>
                      </ul>
                      <div class="both"></div>
                  <?php endforeach; ?>
                  
                  <div class="cost_box product_read_">
                      <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                          <div class='params'>код: <span id='art'></span><br/> цвет:
                              <span id='color'></span></div>
                          <div class="product_read_price">
                              <div class="w">
e4cea6a9   Administrator   rm node nodule
155
156
                                  <strike><span><span id='old_cost'><?= $product->variant->price_old >0 ? $product->variant->price_old : 0?></span></span> грн.</strike>
                                  <span class="cost"><span itemprop="price"><span id='cost'><?= $product->variant->price ?></span></span> <span class="valute">грн.</span></span>
85040b57   Yarik   Comment added
157
158
159
                                  <meta itemprop="priceCurrency" content="UAH">
                              </div>
                              <input type='hidden' id='product_id'/>
e4cea6a9   Administrator   rm node nodule
160
                              <a href="#" rel='<?= $product->variant->price > 0 ? "product" : ""?>' class="<?= $product->variant->price > 0 ? "link_buy" : "link_buy_out_stock"?>"><?= $product->variant->price > 0 ? "Купить" : "Нет в наличии"?></a>
85040b57   Yarik   Comment added
161
162
163
                              <div class="both"></div>
                          </div>
                      </div>
20ef43de   Yarik   Avarage rating st...
164
165
166
167
168
                      <div class="check_price">
                          <span>
                              Наличие и цены уточняйте на момент покупки.
                          </span>
                      </div>
85040b57   Yarik   Comment added
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
                      <div class="product_service">
                          <ul>
                              <?php if(Yii::$app->user->id) : ?>
                                  <li class="item1"><a href="<?= Url::to([
                                          'iam/share',
                                          'id' => $product->product_id,
                                      ]) ?>">Добавить в закладки</a></li>
                              <?php endif ?>
                              <?php if(false && Yii::$app->user->id) : ?>
                                  <li class="item2"><a href="<?= Url::to([
                                          'iam/price',
                                          'id' => $product->product_id,
                                      ]) ?>">Узнать о снижение цены</a></li>
                              <?php endif ?>
                              <?php if(false) : ?>
                                  <li class="item3"><a href="<?= Url::to([
                                          'products/compare',
                                          'id' => $product->product_id,
                                      ]) ?>">Добавить в сравнение</a></li>
                              <?php endif ?>
                          </ul>
                      </div>
                      <div class="artbox_comment_description">
8f36efb7   Yarik   Added comments to...
192
193
194
                          <?php
                              if(!empty( $product->averageRating ) && $product->averageRating->value) {
                                  ?>
20ef43de   Yarik   Avarage rating st...
195
                                  <div itemprop="aggregateRating" class="product_rating_block" itemscope itemtype="http://schema.org/AggregateRating">
14009e7f   Yarik   Structure data fix
196
197
198
199
                                      <span itemprop="ratingValue" style="display: none"><?php echo $product->averageRating->value; ?></span>
                                      <span itemprop="ratingCount" style="display: none"><?php echo count($product->comments); ?></span>
                                      <div class="rateit" data-rateit-value="<?php echo $product->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div>
                                  </div>
8f36efb7   Yarik   Added comments to...
200
201
202
                                  <?php
                              }
                          ?>
20ef43de   Yarik   Avarage rating st...
203
                          <p class="product_review_block"><a href="#artbox-comment" itemprop="interactionCount">
8f36efb7   Yarik   Added comments to...
204
205
206
207
208
                                  <?php
                                      $comment_count = count($product->comments);
                                      if($comment_count) {
                                          echo "Отзывов: " . $comment_count;
                                      } else {
bf6045a8   Yarik   Rating styling fix.
209
                                          echo "Оставить отзыв";
8f36efb7   Yarik   Added comments to...
210
211
212
                                      }
                                  ?>
                              </a></p>
85040b57   Yarik   Comment added
213
214
                      </div>
                      <br>
34587997   Yarik   Commented share b...
215
216
217
218
219
220
221
                      <?php
                          /* Share buttons
                          ?>
                          <div class="ya-share2" data-services="vkontakte,facebook,odnoklassniki,gplus,twitter" data-size="s"></div>
                          <?php
                          */
                      ?>
85040b57   Yarik   Comment added
222
                  </div>
8f36efb7   Yarik   Added comments to...
223
224
225
226
227
228
229
230
                  <div class="labels_block">
                      <div class="labels_item">
                          <img src="/img/icon_100_original_01.png" alt="">
                      </div>
                      <div class="labels_item">
                          <img src="/img/icon_100_quaranty_01.png" alt="">
                      </div>
                  </div>
85040b57   Yarik   Comment added
231
                  <?php /*
ccc7a9d3   Karnovsky A   Karnovsky 12052016
232
233
234
235
236
237
238
239
240
          <div class="product_service">
              <ul>
                  <li class="item1"><a href="<?= Url::to (['iam/share', 'id' => $product->product_id]) ?>">Добавить в закладки</a>
                  </li>
                  <li class="item2"><a href="<?= Url::to (['iam/price', 'id' => $product->product_id]) ?>">Узнать о снижение
                          цены</a></li>
                  <li class="item3"><a href="<?= Url::to (['products/compare', 'id' => $product->product_id]) ?>">Добавить в
                          сравнение</a></li>
              </ul>
85040b57   Yarik   Comment added
241
242
243
244
          </div>*/ ?>
              </div>
              
              <div class="productRightBar">
873e3d80   Administrator   14.09.16
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
                  <?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,'id'=>$event->primaryKey]))?></div>
                              <div class="event_time">До конца осталось:</div>
                              <div class="clock_<?= $event->primaryKey ?> clock_product_first "></div>
                              <script type="text/javascript">
                                  var clock;
  
                                  $(document).ready(function() {
                                      var clock;
  
                                      clock = $('.clock_<?= $event->primaryKey ?>').FlipClock({
                                          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();
  
                                  });
                              </script>
  
                          </div>
                      <?php endif; ?>
                  <?php endforeach; ?>
  
85040b57   Yarik   Comment added
284
285
286
287
                  <ul id="nav_product">
                      <li><a href="#">Характеристики</a>
                          <div class="info">
                              <p>Бренд: <?= $product->brand->name ?></p>
01905ec6   Yarik   Filter fixing
288
                              <?php foreach($product->getActiveProperties($category->category_id) as $group): ?>
85040b57   Yarik   Comment added
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
                                  <p><?= $group->name ?> <?php foreach($group->_options as $option) : ?>&nbsp;<?= $option->ValueRenderHTML ?><?php endforeach ?></p>
                              <?php endforeach; ?>
                          </div>
                      </li>
                      <li><a href="#">Описание</a>
                          <div itemprop="description">
                              <div class="info">
                                  <?= $product->description ?>
                              </div>
                          </div>
                      </li>
                      <?php if(!empty( $product->video ) && strpos($product->video, '.jpg') === false && strpos($product->video, '.png') === false) : ?>
                          <li><a href="#">Видео</a>
                              <div class="info product-thumb-video">
                                  <?php if(strpos($product->video, '<iframe') !== false || strpos($product->video, '<object') !== false) : ?>
                                      <?= $product->video ?>
                                  <?php else : ?>
                                      <?= \cics\widgets\VideoEmbed::widget([
                                          'responsive' => false,
                                          'url'        => $product->video,
                                      ]) ?>
                                  <?php endif ?>
                              </div>
                          </li>
                      <?php endif ?>
                  </ul>
              </div>
14009e7f   Yarik   Structure data fix
316
317
318
              <div class="content">
                  <div class="pic">
                      <center>
e4cea6a9   Administrator   rm node nodule
319
                          <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= \common\components\artboximage\ArtboxImageHelper::getImage($product->variant->imageUrl, 'product_view', [
14009e7f   Yarik   Structure data fix
320
                                  'id'    => 'pic',
01905ec6   Yarik   Filter fixing
321
322
                                  'alt'   => $category->categoryName->value . ' ' . $product->fullname,
                                  'title' => $category->categoryName->value . ' ' . $product->fullname,
14009e7f   Yarik   Structure data fix
323
324
325
326
327
328
329
330
331
332
333
334
335
336
                              ]) ?></a>
                      </center>
                  </div>
                  <ul class="product_colors">
                      <?php foreach($product->images as $image): ?>
                          <li><a href="<?= $image->imageUrl ?>" rel="shadowbox[gal]">
                                  <?= \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'product_trumb2', [
                                      'alt'   => $category->categoryName->value . ' ' . $product->fullname,
                                      'title' => $category->categoryName->value . ' ' . $product->fullname,
                                  ]) ?>
                              </a></li>
                      <?php endforeach; ?>
                  </ul>
              </div>
873e3d80   Administrator   14.09.16
337
338
339
340
341
342
343
344
              <div class="events">
                  <?php foreach($product->events as $event):?>
                      <?php if(!empty($event->banner) && $event->isActive()):?>
                          <?=  Html::a(\common\components\artboximage\ArtboxImageHelper::getImage($event->bannerUrl, 'event_in_product'),Url::to(['event/show','alias'=>$event->alias,'id'=>$event->primaryKey]))?>
                      <?php endif; ?>
                  <?php endforeach; ?>
              </div>
  
14009e7f   Yarik   Structure data fix
345
346
347
348
349
350
351
352
353
              <div class="both"></div>
              <div class="comment-wrapper" style="padding-bottom:25px">
                  <?php
                      echo CommentWidget::widget([
                          'model' => $product,
                      ]);
                  ?>
                  <div class="both"></div>
              </div>
17ca60dd   Yarik   Added comments to...
354
              <div class="both"></div>
85040b57   Yarik   Comment added
355
          </div>
85040b57   Yarik   Comment added
356
357
358
359
360
          <?= \common\modules\product\widgets\similarProducts::widget([ 'product' => $product ]) ?>
          <?= \common\modules\product\widgets\specialProducts::widget([ 'type' => 'promo' ]) ?>
          <?= \common\modules\product\widgets\specialProducts::widget([ 'type' => 'new' ]) ?>
          <?= \common\modules\product\widgets\specialProducts::widget([ 'type' => 'top' ]) ?>
          <?= \common\modules\product\widgets\lastProducts::widget() ?>
e608c5f7   Yarik   Comment added
361
      </div>
85235ea6   Виталий   Веталь
362
  <?php
85040b57   Yarik   Comment added
363
      $this->registerJs("
2fcc30a0   Виталий   Веталь
364
365
366
367
368
369
370
371
372
373
374
375
376
377
        var productHash = window.location.hash;
              productHash = productHash.replace('#','')
  
              var productUl = $('ul.product_mod li')
              var productA = productUl.find('a#'+productHash)
              productUl.removeClass('active')
              productA.parent().addClass('active')
              var dataLink = productA.attr('data-imageoriginal')
              var dataImg = productA.attr('data-image')
  
              $('#pic').attr('src',dataImg)
              $('#pic').parent().attr('href',dataLink)
      ", View::POS_READY, 'new_script');
  ?>