Blame view

frontend/views/variant/view.php 22.6 KB
6ba3c88a   Alex Savenko   all
1
2
3
4
5
6
7
8
9
10
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  <?php
      use artbox\catalog\models\OptionGroup;
      use artbox\catalog\models\Product;
      use artbox\catalog\models\Variant;
      use artbox\core\components\SeoComponent;
      use artbox\core\helpers\ImageHelper;
      use frontend\models\Order;
      use frontend\widgets\OptionPicker;
      use yii\bootstrap\ActiveForm;
      use yii\bootstrap\Html;
      use yii\helpers\ArrayHelper;
      use yii\helpers\Url;
      use yii\web\View;
      
      /**
       * @var View         $this
       * @var Variant      $model
       * @var SeoComponent $seo
       * @var array        $groups
       * @var Product[]    $similar
       */
      $seo = \Yii::$app->get('seo');
      if (!empty($model->product->category)) {
          if (!empty($model->product->category->parent)) {
              $this->params[ 'breadcrumbs' ][] = [
                  'label' => $model->product->category->parent->lang->title,
                  'url'   => [
                      '/category/view',
                      'category' => $model->product->category->parent->lang->alias->value,
                  ],
              ];
          }
          $this->params[ 'breadcrumbs' ][] = [
              'label' => $model->product->category->lang->title,
              'url'   => [
                  '/category/view',
                  'category' => $model->product->category->lang->alias->value,
              ],
          ];
      }
      $this->params[ 'breadcrumbs' ][] = $model->product->lang->title;
      $this->params[ 'breadcrumbs' ][] = $seo->title;
      $images = $model->product->images;
      if (!empty($model->product->image)) {
          array_unshift($images, $model->product->image);
      }
      if (!empty($model->image)) {
          array_unshift($images, $model->image);
      }
  ?>
  <div id="content">
    <div class="container">
      <div class="row">
        <div class="col-md-12">
          
          <div class="row" id="productMain">
5f5604e0   Виталий   commit999
57
            <div class="col-sm-4">
6ba3c88a   Alex Savenko   all
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
              <div id="mainImage">
                  <?php
                      if (!empty($images)) {
                          echo ImageHelper::set($images[ 0 ]->getPath())
                                          ->fillResize(555, 555)
                                          ->renderImage(
                                              [
                                                  'class' => 'img-responsive',
                                                  'alt'   => $model->lang->title,
                                                  'title' => $model->lang->title,
                                              ]
                                          );
                      } else {
                          echo ImageHelper::set('@frontend/web/img/no-image.png')
                                          ->fillResize(555, 555)
                                          ->renderImage(
                                              [
                                                  'class' => 'img-responsive',
                                                  'alt'   => $model->lang->title,
                                                  'title' => $model->lang->title,
                                              ]
                                          );
                      }
                  ?>
              </div>
6087306f   Виталий   status fix
83
  
6ba3c88a   Alex Savenko   all
84
                <?php
6087306f   Виталий   status fix
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
                if($model->product->is('akcia') || $model->product->is('new') || $model->product->is('top')){
                 ?>
                <div class="status_wrapp">
                   <?php
                   if ($model->product->is('akcia')) {
                       ?>
                       <div class="ribbon sale">
                           <div class="theribbon">АКЦИЯ</div>
                           <div class="ribbon-background"></div>
                       </div>
                       <!-- /.ribbon -->
                       <?php
                   }
                   if ($model->product->is('new')) {
                       ?>
                       <div class="ribbon new">
                           <div class="theribbon">НОВОЕ</div>
                           <div class="ribbon-background"></div>
                       </div>
                       <!-- /.ribbon -->
                       <?php
                   }
                   if ($model->product->is('top')) {
                       ?>
                       <div class="ribbon top">
                           <div class="theribbon">ТОП</div>
                           <div class="ribbon-background"></div>
                       </div>
                       <!-- /.ribbon -->
                       <?php
                   }
                   ?>
               </div>
                <?php
                }
6ba3c88a   Alex Savenko   all
120
121
                ?>
              
88dba093   Anastasia   delete little pre...
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
181
182
183
184
185
186
187
188
189
190
  <!--            <div class="row" id="thumbs">-->
  <!--                --><?php
  //                    if (!empty($images)) {
  //                        foreach ($images as $image) {
  //                            echo Html::tag(
  //                                'div',
  //                                Html::a(
  //                                    ImageHelper::set($image->getPath())
  //                                               ->fillResize(70, 60)
  //                                               ->renderImage(
  //                                                   [
  //                                                       'class' => 'img-responsive',
  //                                                       'alt'   => $model->lang->title,
  //                                                       'title' => $model->lang->title,
  //                                                   ]
  //                                               ),
  //                                    ImageHelper::set($image->getPath())
  //                                               ->fillResize(555, 555)
  //                                               ->render(),
  //                                    [
  //                                        'class' => 'thumb',
  //                                    ]
  //                                ),
  //                                [
  //                                    'class' => 'col-xs-2',
  //                                ]
  //                            );
  //                        }
  //                    } else {
  //                        echo Html::tag(
  //                            'div',
  //                            Html::a(
  //                                ImageHelper::set('@frontend/web/img/no-image.png')
  //                                           ->fillResize(70, 60)
  //                                           ->renderImage(
  //                                               [
  //                                                   'class' => 'img-responsive',
  //                                                   'alt'   => $model->lang->title,
  //                                                   'title' => $model->lang->title,
  //                                               ]
  //                                           ),
  //                                ImageHelper::set('@frontend/web/img/no-image.png')
  //                                           ->fillResize(555, 555)
  //                                           ->render(),
  //                                [
  //                                    'class' => 'thumb',
  //                                ]
  //                            ),
  //                            [
  //                                'class' => 'col-xs-2',
  //                            ]
  //                        );
  //                    }
  //                ?>
  <!--            </div>-->
  <!--              --><?php
  //                  if (!empty($model->product->video)) {
  //                      ?>
  <!--                    <div class="product-video">-->
  <!--                      <div class="h3">-->
  <!--                          --><?php //echo \Yii::t('app', 'Видеообзор продукта'); ?>
  <!--                      </div>-->
  <!--                      <div class="video-box">-->
  <!--                          --><?php //echo $model->product->video; ?>
  <!--                      </div>-->
  <!--                    </div>-->
  <!--                      --><?php
  //                  }
  //              ?>
6ba3c88a   Alex Savenko   all
191
            </div>
5f5604e0   Виталий   commit999
192
            <div class="col-sm-8">
6ba3c88a   Alex Savenko   all
193
194
195
196
197
198
199
200
201
202
203
204
205
206
              <div class="box">
                <h1><?php echo $model->lang->title; ?></h1>
                <p class="no-margin"><?php echo $model->sku; ?></p>
                <p class="price">
                  <span class="price-title">Цена:</span><?php echo $model->price ? : 0; ?> грн&ensp;
                    <?php
                        if ($model->canBuy()) {
                            echo Html::a(
                                Html::tag(
                                    'i',
                                    '',
                                    [
                                        'class' => 'fa fa-shopping-cart',
                                    ]
2bdb3b90   Виталий   all fix
207
                                ) . \Yii::t('app', 'Купить'),
6ba3c88a   Alex Savenko   all
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
                                '#',
                                [
                                    'class'   => 'btn btn-success add-to-basket',
                                    'data-id' => $model->id,
                                ]
                            );
                        } else {
                            echo Html::a(
                                \Yii::t('app', 'Нет в наличии'),
                                '#',
                                [
                                    'class'   => 'btn btn-info disabled',
                                    'data-id' => $model->id,
                                ]
                            );
                        }
                    ?>
                    <?php
                        if (\Yii::$app->user->isGuest) {
                            echo Html::button(
                                Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]),
                                [
                                    'title' => 'Добавить в избранное',
                                    'data'  => [
2bdb3b90   Виталий   all fix
232
233
                                        'toggle'    => 'modal',
                                        'target' => '#login-modal'
6ba3c88a   Alex Savenko   all
234
                                    ],
2bdb3b90   Виталий   all fix
235
                                    'class' => 'btn btn-default pull-right',
6ba3c88a   Alex Savenko   all
236
237
238
239
240
241
242
243
                                ]
                            );
                        } elseif (in_array($model->id, \Yii::$app->user->identity->wishlist)) {
                            echo Html::button(
                                Html::tag('i', '', [ 'class' => 'fa fa-heart' ]),
                                [
                                    'title' => 'Убрать из избранного',
                                    'data'  => [
6ba3c88a   Alex Savenko   all
244
245
246
247
248
249
250
251
252
253
254
255
256
257
                                        'product'   => $model->product->id,
                                        'variant'   => $model->id,
                                        'user'      => \Yii::$app->user->identity->getId(),
                                        'url'       => Url::to([ 'product/wishlist-rm' ]),
                                    ],
                                    'class' => 'wishlist-rm btn btn-success pull-right',
                                ]
                            );
                        } else {
                            echo Html::button(
                                Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]),
                                [
                                    'title' => 'Добавить в избранное',
                                    'data'  => [
6ba3c88a   Alex Savenko   all
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
284
285
286
287
288
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
                                        'product'   => $model->product->id,
                                        'variant'   => $model->id,
                                        'user'      => \Yii::$app->user->identity->getId(),
                                        'url'       => Url::to([ 'product/wishlist-add' ]),
                                    ],
                                    'class' => 'wishlist-add btn btn-success pull-right',
                                ]
                            );
                        }
                    ?>
                </p>
                <hr>
                  <?php
                      if ($model->canBuy()) {
                          echo Html::a(
                              Html::icon(
                                  'phone',
                                  [
                                      'prefix' => 'fa fa-',
                                  ]
                              ) . \Yii::t('app', 'Купить в один клик'),
                              '#',
                              [
                                  'data'  => [
                                      'toggle' => 'modal',
                                      'target' => '#oneclick-modal',
                                  ],
                                  'class' => 'btn btn-template-main',
                              ]
                          );
                      }
                  ?>
              </div>
              <div class="product-variant-block">
                  <?php
                      $helper = OptionPicker::getHelper($model->product);
                      $productVariantGroups = $helper->getGroups();
                      foreach ($productVariantGroups as $productVariantGroup) {
                          ?>
                        <div class="product-variant-group">
                          <p class="product-variant-group-title">
                              <?php
                                  /**
                                   * @var \artbox\catalog\models\VariantOptionGroupExcl $productVariantGroupModel
                                   */
                                  $productVariantGroupModel = $productVariantGroup[ 'group' ];
                                  echo $productVariantGroupModel->lang->title . ": ";
                              ?>
                          </p>
                          <div class="product-variant-group-options">
                              <?php
                                  /**
                                   * @var \frontend\widgets\VariantOptionHelper $variantOptionHelper
                                   */
                                  $variantOptionHelper = $productVariantGroup[ 'options' ];
                                  foreach ($variantOptionHelper->getOptions() as $option) {
                                      /**
                                       * @var \artbox\catalog\models\VariantOptionExcl $productVariantOptionModel
                                       */
                                      $productVariantOptionModel = $option[ 'option' ];
                                      /**
                                       * @var \frontend\widgets\VariantHelper $variantHelper
                                       */
                                      $variantHelper = $option[ 'variants' ];
                                      $variant = $variantHelper->getVariant();
                                      /**
                                       * @var \artbox\core\models\Image $img
                                       */
                                      $img = $productVariantOptionModel->image ? : $variant->image ? : null;
                                      echo Html::a(
                                          Html::tag(
                                              'div',
                                              $img ? ImageHelper::set($img->getPath())
                                                                ->fillResize(90, 55)
                                                                ->renderImage(
                                                                    [
                                                                        'alt'   => $productVariantOptionModel->lang->value,
                                                                        'title' => $productVariantOptionModel->lang->value,
                                                                        'class' => 'product-variant-group-option-img',
                                                                    ]
                                                                ) : $productVariantOptionModel->lang->value,
                                              [
                                                  'class' => 'product-variant-group-option',
                                              ]
                                          ),
                                          [
                                              'variant/view',
                                              'id' => $variant->id,
                                          ]
                                      );
                                  }
                              ?>
                          </div>
                        </div>
                          <?php
                      }
                  ?>
              </div>
5f5604e0   Виталий   commit999
356
              <div class="box box-tth" id="details">
6ba3c88a   Alex Savenko   all
357
358
359
360
                <h2><?php echo \Yii::t('app', 'Описание товара'); ?></h2>
                  <?php echo $model->lang->description ? : \Yii::t('app', 'Нет описания'); ?>
              </div>
              
5f5604e0   Виталий   commit999
361
              <div class="box box-tth" id="details">
6ba3c88a   Alex Savenko   all
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
                <h2><?php echo \Yii::t('app', 'Характеристики'); ?></h2>
                  <?php
                      if (!empty($groups)) {
                          ?>
                        <table class="table">
                          <tbody>
                              <?php
                                  foreach ($groups as $group) {
                                      foreach ($group as $optionGroup) {
                                          /**
                                           * @var OptionGroup $optionGroup
                                           */
                                          echo Html::tag(
                                              'tr',
                                              Html::tag(
                                                  'td',
                                                  $optionGroup->lang->title,
                                                  [ 'class' => 'td-title' ]
                                              ) . Html::tag(
                                                  'td',
                                                  implode(
                                                      ', ',
                                                      ArrayHelper::getColumn(
                                                          $optionGroup->currentOptions,
                                                          'lang.value'
                                                      )
                                                  )
                                              )
                                          );
                                      }
                                  }
                              ?>
                          </tbody>
                        </table>
                          <?php
                      } else {
                          echo \Yii::t('app', 'Нет характеристик');
                      }
                  ?>
              </div>
            </div>
          
          </div>
            
            <?php
                if (!empty($similar)) {
                    ?>
                  <div class="heading text-center">
                    <h2><?php echo \Yii::t('app', 'Похожие товары'); ?></h2>
                  </div>
                  
                  <div class="product-carousel">
                    <div class="homepage owl-carousel">
                        <?php
                            $newItemsArrays = array_chunk($similar, 4);
                            foreach ($newItemsArrays as $newItemsArray) {
                                ?>
                              <div class="products">
                                  <?php
                                      foreach ($newItemsArray as $product) {
                                          echo $this->render(
                                              '@frontend/views/site/_slider_product',
                                              [
                                                  'product' => $product,
                                              ]
                                          );
                                      }
                                  ?>
                              </div>
                                <?php
                            }
                        ?>
                    </div>
                  </div>
                    <?php
                }
            ?>
        </div>
        <!-- /.col-md-9 -->
      </div>
      <!-- /.row -->
    </div>
    <!-- /.container -->
  </div>
  <!-- /#content -->
  <div class="modal fade" id="oneclick-modal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm">
      
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title callback"><?php echo \Yii::t('app', 'Купить в один клик'); ?></h4>
        </div>
        <div class="modal-body">
            <?php
                $order = new Order(
                    [
                        'scenario'  => Order::SCENARIO_FAST,
                        'variantId' => $model->id,
                        'returnUrl' => \Yii::$app->request->absoluteUrl,
                    ]
                );
                $form = ActiveForm::begin(
                    [
                        'action' => [ 'checkout/fast' ],
                        'id'     => 'fast-buy-form',
                    ]
                );
                echo $form->field($order, 'variantId')
                          ->label(false)
                          ->hiddenInput();
                echo $form->field($order, 'returnUrl')
                          ->label(false)
                          ->hiddenInput();
                echo $form->field($order, 'name')
                          ->label(false)
                          ->textInput(
                              [
                                  'placeholder' => $order->getAttributeLabel('name'),
                              ]
                          );
                echo $form->field($order, 'phone')
                          ->label(false)
                          ->textInput(
                              [
                                  'placeholder' => $order->getAttributeLabel('phone'),
                              ]
                          );
                echo Html::tag(
                    'p',
                    Html::submitButton(
                        Html::icon(
                            'shopping-cart',
                            [
                                'prefix' => 'fa fa-',
                            ]
                        ) . \Yii::t('app', ' Отправить'),
                        [
                            'class' => 'btn btn-template-main',
                        ]
                    ),
                    [
                        'class' => 'text-center',
                    ]
                );
                $form::end();
            ?>
        </div>
      </div>
    </div>
  </div>