Blame view

frontend/views/catalog/product.php 16.3 KB
055ecc3b   Karnovsky A   Karnovsky 11052016
1
  <?php
e608c5f7   Yarik   Comment added
2
3
4
5
6
      use common\modules\comment\models\Comment;
      use common\modules\comment\models\Rating;
      use common\modules\comment\widgets\CommentWidget;
      use kartik\rating\StarRating;
      use yii\widgets\Breadcrumbs;
85040b57   Yarik   Comment added
7
8
9
      use yii\web\View;
      use yii\helpers\Url;
      use frontend\widgets\Seo;
e608c5f7   Yarik   Comment added
10
      
85040b57   Yarik   Comment added
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
      $this->params[ 'seo' ][ 'key' ] = $product->category->categoryName->value;
      $this->params[ 'seo' ][ 'fields' ][ 'name' ] = $product->fullname;
      $this->params[ 'seo' ][ 'h1' ] = !empty( Seo::widget([ 'row' => 'h1' ]) ) ? Seo::widget([ 'row' => 'h1' ]) : $product->fullname;
      
      //$this->params['seo']['title'] =  "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua";
      //$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua";
      $this->title = $product->fullname;
      //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname;
      //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]);
      //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]);
      
      //foreach($product->category->getParents()->all() as $parent) {
      //    $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
      //}
      $this->params[ 'breadcrumbs' ][] = [
          'label' => 'Каталог',
          'url'   => [ 'catalog/category' ],
      ];
      $this->params[ 'breadcrumbs' ][] = [
          'label' => $product->category->categoryName->value,
          'url'   => [
              'catalog/category',
              'category' => $product->category,
          ],
      ];
      $this->params[ 'breadcrumbs' ][] = $product->fullname . ' #' . $product->enabledVariants[ 0 ]->sku;
      
      $this->registerJs('
055ecc3b   Karnovsky A   Karnovsky 11052016
39
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
40
41
          var checkData = function($index)
          {
f307b0a8   Karnovsky A   -
42
43
44
45
              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
46
              var $target = $(".productLeftBar .cost_box");
055ecc3b   Karnovsky A   Karnovsky 11052016
47
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
48
49
              $("#cost").text($source.data("cost"));
              $("#old_cost").text($source.data("old_cost"));
055ecc3b   Karnovsky A   Karnovsky 11052016
50
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
51
52
53
54
55
56
57
58
              if (parseInt ($source.data("old_cost")) == 0)
              {
                  $target.find("strike").hide();
              }
              else
              {
                  $target.find("strike").show();
              }
055ecc3b   Karnovsky A   Karnovsky 11052016
59
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
60
61
62
63
64
65
              $("#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
66
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
67
68
69
          $(".product_mod > li").click(function()
          {
              checkData($(this).index());
055ecc3b   Karnovsky A   Karnovsky 11052016
70
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
71
              Shadowbox.setup($("#picoriginal"));
055ecc3b   Karnovsky A   Karnovsky 11052016
72
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
73
74
              return false;
          });
055ecc3b   Karnovsky A   Karnovsky 11052016
75
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
76
77
78
          checkData(0);
  
      ', View::POS_READY, 'fasovka');
85040b57   Yarik   Comment added
79
80
      
      $this->registerJs("
ccc7a9d3   Karnovsky A   Karnovsky 12052016
81
82
83
84
85
86
87
88
89
90
91
92
          $('#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
93
94
95
96
97
98
99
      
      $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
100
101
102
103
104
          Shadowbox.init({
  
      });
      ", View::POS_READY, 'Shadowbox');
  ?>
e608c5f7   Yarik   Comment added
105
      
85040b57   Yarik   Comment added
106
107
108
109
110
111
112
      <nav class="bread-crumbs">
          <?= Breadcrumbs::widget([
              'links' => $this->params[ 'breadcrumbs' ],
          ]) ?>
          <div class="both"></div>
      </nav>
  <?php if($flash = Yii::$app->session->getFlash('success')): ?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
113
114
      <div class="alert-success"><?= $flash ?></div>
  <?php endif; ?>
85040b57   Yarik   Comment added
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
      <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', [
                                          'alt'   => $product->category->categoryName->value . ' ' . $product->fullname,
                                          'title' => $product->category->categoryName->value . ' ' . $product->fullname,
                                      ]) ?>
                                  </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">
                                  <strike><span itemprop="price"><span id='old_cost'>0</span></span> грн.</strike>
                                  <span class="cost"><span itemprop="price"><span id='cost'>0</span></span> <span class="valute">грн.</span></span>
                                  <meta itemprop="priceCurrency" content="UAH">
                              </div>
                              <input type='hidden' id='product_id'/>
                              <a href="#" rel='product' class="link_buy fl">Купить</a>
                              <div class="both"></div>
                          </div>
                      </div>
                      
                      <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">
e608c5f7   Yarik   Comment added
181
                          <?php
b5a6d518   Yarik   Comment added
182
183
184
                          /*
                          ?>
                          <?php
85040b57   Yarik   Comment added
185
186
187
188
                              if(!empty( $product->averageRating ) && $product->averageRating->value) {
                                  ?>
                                  <div class="rateit" data-rateit-value="<?php echo $product->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div>
                                  <?php
e608c5f7   Yarik   Comment added
189
190
                              }
                          ?>
85040b57   Yarik   Comment added
191
192
193
194
195
196
197
198
199
200
                          <p><a href="#artbox-comment">
                                  <?php
                                      $comment_count = count($product->comments);
                                      if($comment_count) {
                                          echo "Отзывов: " . $comment_count;
                                      } else {
                                          echo "Оставть отзыв";
                                      }
                                  ?>
                              </a></p>
b5a6d518   Yarik   Comment added
201
202
203
                          <?php
                          */
                          ?>
85040b57   Yarik   Comment added
204
205
206
207
208
                      </div>
                      <br>
                      <div class="ya-share2" data-services="vkontakte,facebook,odnoklassniki,gplus,twitter" data-size="s"></div>
                  </div>
                  <?php /*
ccc7a9d3   Karnovsky A   Karnovsky 12052016
209
210
211
212
213
214
215
216
217
          <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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
          </div>*/ ?>
              </div>
              
              <div class="productRightBar">
                  <ul id="nav_product">
                      <li><a href="#">Характеристики</a>
                          <div class="info">
                              <p>Бренд: <?= $product->brand->name ?></p>
                              <?php foreach($product->properties as $group): ?>
                                  <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>
055ecc3b   Karnovsky A   Karnovsky 11052016
254
          </div>
85040b57   Yarik   Comment added
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
          <div class="content">
              <div class="pic">
                  <center>
                      <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= \common\components\artboximage\ArtboxImageHelper::getImage($product->enabledVariants[ 0 ]->imageUrl, 'product_view', [
                              'id'    => 'pic',
                              'alt'   => $product->category->categoryName->value . ' ' . $product->fullname,
                              'title' => $product->category->categoryName->value . ' ' . $product->fullname,
                          ]) ?></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'   => $product->category->categoryName->value . ' ' . $product->fullname,
                                  'title' => $product->category->categoryName->value . ' ' . $product->fullname,
                              ]) ?>
                          </a></li>
                  <?php endforeach; ?>
              </ul>
          </div>
          <div class="both"></div>
          <div class="comment-wrapper">
              <?php
b5a6d518   Yarik   Comment added
279
                  /*
85040b57   Yarik   Comment added
280
                  echo CommentWidget::widget([
e608c5f7   Yarik   Comment added
281
                      'comment_class' => Comment::className(),
85040b57   Yarik   Comment added
282
283
                      'rating_class'  => Rating::className(),
                      'success_text'  => 'Комментарий успешно добавлен и отобразится после проверки модератором',
e608c5f7   Yarik   Comment added
284
                      'class_options' => [
85040b57   Yarik   Comment added
285
286
287
                          'scenario' => \Yii::$app->user->isGuest ? Comment::SCENARIO_GUEST : Comment::SCENARIO_USER,
                          'status'   => Comment::STATUS_HIDDEN,
                          'user_id'  => \Yii::$app->user->isGuest ? NULL : \Yii::$app->user->id,
e608c5f7   Yarik   Comment added
288
                      ],
85040b57   Yarik   Comment added
289
290
                      'model'         => $product->className(),
                      'model_id'      => $product->product_id,
e608c5f7   Yarik   Comment added
291
292
293
294
295
296
297
298
299
                      'list_options'  => [
                          'view' => 'list-comment-review',
                      ],
                      'form_options'  => [
                          'view' => 'form-comment-review',
                          'tag'  => 'span',
                      ],
                      'options'       => [
                          'class' => 'proektant-comments-wr style',
85040b57   Yarik   Comment added
300
                          'id'    => 'artbox-comment',
e608c5f7   Yarik   Comment added
301
302
                      ],
                  ]);
b5a6d518   Yarik   Comment added
303
                  */
85040b57   Yarik   Comment added
304
305
306
307
308
309
310
311
              ?>
          </div>
          
          <?= \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
312
      </div>
85235ea6   Виталий   Веталь
313
  <?php
85040b57   Yarik   Comment added
314
      $this->registerJs("
2fcc30a0   Виталий   Веталь
315
316
317
318
319
320
321
322
323
324
325
326
327
328
        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');
  ?>