Blame view

frontend/views/product/view.php 22.1 KB
950817c6   Alex Savenko   first commit
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
57
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
83
84
85
86
87
88
89
90
91
92
  <?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 yii\bootstrap\ActiveForm;
      use yii\bootstrap\Html;
      use yii\helpers\ArrayHelper;
      use yii\helpers\Url;
      use yii\web\View;
      use yii\jui\JuiAsset;
      
      /**
       * @var View         $this
       * @var Product      $model
       * @var Variant      $variant
       * @var SeoComponent $seo
       * @var array        $groups
       * @var Product[]    $similar
       */
      $seo = \Yii::$app->get('seo');
      if (!empty($model->category)) {
  //        if (!empty($model->category->parent)) {
  //            $this->params[ 'breadcrumbs' ][] = [
  //                'label' => $model->category->parent->lang->title,
  //                'url'   => [
  //                    '/category/view',
  //                    'category' => $model->category->parent->lang->alias->value,
  //                ],
  //            ];
  //        }
          $this->params[ 'breadcrumbs' ][] = [
              'label' => $model->category->lang->title,
              'url'   => [
                  '/category/view',
                  'category' => $model->category->lang->alias->value,
              ],
          ];
      }
      $this->params[ 'breadcrumbs' ][] = $seo->title;
      $images = $model->images;
      if (empty($model->images))
      {
        $images = [];
      }
      if (!empty($model->image)) {
          array_unshift($images, $model->image);
      }
      
      $js = <<< JS
      $(document).ready(function() {
          $("#t_buy_credit").on("click", function(e) {
              console.log("credit");
              $('.Oziris_dialog').attr('ProductCode','KS-POTREB');
              Oziris_open();
              return false;
          });
      
          $("#t_buy_installment").on("click", function(e) {
              console.log("installment");
              $('.Oziris_dialog').attr('ProductCode','ECREDIT');
              Oziris_open();
              return false;
          });
      })
  JS;
      
      $this->registerJs($js, View::POS_READY);
  
  ?>
  
  <!--<script>(function(d, s, id) {-->
  <!--        var js, fjs = d.getElementsByTagName(s)[ 0 ];-->
  <!--        if (d.getElementById(id)) {-->
  <!--            return;-->
  <!--        }-->
  <!--        js = d.createElement(s);-->
  <!--        js.id = id;-->
  <!--        js.src = "//xkasa.com.ua/Scripts/Oziris-0.5.1.a.promo.js";-->
  <!--        fjs.parentNode.insertBefore(js, fjs);-->
  <!--    }(document, 'script', 'xkasa-jssdk'));-->
  <!--</script>-->
  
  <div id="content">
    <div class="container">
      <div class="row">
        <div class="col-md-12">
          
          <div class="row" id="productMain">
            <div class="col-xs-12 col-sm-3 col-md-4">
b12c5c53   Виталий   img zoom
93
                <div id="mainImage" class="image-zoom">
950817c6   Alex Savenko   first commit
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
120
121
122
123
124
125
126
127
128
                  <?php
                      if (!empty($images)) {
                          echo ImageHelper::set($images[ 0 ]->getPath())
                                          ->fillResize(555, 555)
                                          ->quality(85)
                                          ->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)
                                          ->quality(85)
                                          ->renderImage(
                                              [
                                                  'class' => 'img-responsive',
                                                  'alt'   => $model->lang->title,
                                                  'title' => $model->lang->title,
                                              ]
                                          );
                      }
                  ?>
              </div>
  
                <?php
                if($model->is('new') || $model->is('akcia') || $model->is('top')){
                ?>
                <div class="status_wrapp">
                    <?php
                    if ($model->is('akcia')) {
                        ?>
                        <div class="ribbon sale">
e226698d   mzavalniuk   translate shop pa...
129
                            <div class="theribbon">АКЦІЯ</div>
950817c6   Alex Savenko   first commit
130
131
132
133
134
135
136
137
                            <div class="ribbon-background"></div>
                        </div>
                        <!-- /.ribbon -->
                        <?php
                    }
                    if ($model->is('new')) {
                        ?>
                        <div class="ribbon new">
e226698d   mzavalniuk   translate shop pa...
138
                            <div class="theribbon">НОВЕ</div>
950817c6   Alex Savenko   first commit
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
                            <div class="ribbon-background"></div>
                        </div>
                        <!-- /.ribbon -->
                        <?php
                    }
                    if ($model->is('top')) {
                        ?>
                        <div class="ribbon top">
                            <div class="theribbon">ТОП</div>
                            <div class="ribbon-background"></div>
                        </div>
                        <!-- /.ribbon -->
                        <?php
                    }
                    ?>
                </div>
                <?php } ?>
  
                <?php if(count($images) > 1) { ?>
              <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)
                                                 ->quality(85)
                                                 ->renderImage(
                                                     [
                                                         'class' => 'img-responsive',
                                                         'alt'   => $model->lang->title,
                                                         'title' => $model->lang->title,
                                                     ]
                                                 ),
                                      ImageHelper::set($image->getPath())
                                                 ->fillResize(555, 555)
                                                 ->quality(85)
                                                 ->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)
                                             ->quality(85)
                                             ->renderImage(
                                                 [
                                                     'class' => 'img-responsive',
                                                     'alt'   => $model->lang->title,
                                                     'title' => $model->lang->title,
                                                 ]
                                             ),
                                  ImageHelper::set('@frontend/web/img/no-image.png')
                                             ->fillResize(555, 555)
                                             ->quality(85)
                                             ->render(),
                                  [
                                      'class' => 'thumb',
                                  ]
                              ),
                              [
                                  'class' => 'col-xs-2',
                              ]
                          );
                      }
                  ?>
              </div>
                <?php } ?>
  
                <?php
                    if (!empty($model->video)) {
                        ?>
                      <div class="product-video">
                        <div class="h3">
e226698d   mzavalniuk   translate shop pa...
224
                            <?php echo \Yii::t('app', 'Відеообзор продукта'); ?>
950817c6   Alex Savenko   first commit
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
                        </div>
                        <div class="video-box">
                            <?php echo $model->video; ?>
                        </div>
                      </div>
                        <?php
                    }
                ?>
            </div>
            <div class="col-xs-12 col-sm-9 col-md-8">
              <div class="box">
                <h1><?php echo $model->lang->title; ?></h1>
                <p class="no-margin"><?php echo $variant->sku; ?><span class="product-id">Код: <?= $model->id ?></span>
                </p>
                <p class="price">
10e74468   mzavalniuk   translate to ua r...
240
                  <span class="price-title"><?=Yii::t('app','Price')?>:</span><?php echo $variant->price ? : 0; ?> грн&ensp;
950817c6   Alex Savenko   first commit
241
242
243
244
245
246
247
248
249
                    <?php
                        if ($variant->canBuy()) {
                            echo Html::a(
                                Html::tag(
                                    'i',
                                    '',
                                    [
                                        'class' => 'fa fa-shopping-cart',
                                    ]
e226698d   mzavalniuk   translate shop pa...
250
                                ) . \Yii::t('app', 'Додати у кошик'),
950817c6   Alex Savenko   first commit
251
252
253
254
255
256
257
258
                                '#',
                                [
                                    'class'   => 'btn btn-success add-to-basket',
                                    'data-id' => $variant->id,
                                ]
                            );
                        } else {
                            echo Html::a(
e226698d   mzavalniuk   translate shop pa...
259
                                \Yii::t('app', 'Немає в наявності'),
950817c6   Alex Savenko   first commit
260
261
262
263
264
265
266
267
268
269
270
271
272
                                '#',
                                [
                                    'class'   => 'btn btn-info disabled',
                                    'data-id' => $variant->id,
                                ]
                            );
                        }
                    ?>
                    <?php
                        if (\Yii::$app->user->isGuest) {
                            echo Html::button(
                                Html::tag('i', '', [ 'class' => 'fa fa-heart-o' ]),
                                [
e226698d   mzavalniuk   translate shop pa...
273
                                    'title' => 'Додати у обране',
950817c6   Alex Savenko   first commit
274
275
276
277
278
279
280
281
282
283
284
                                    'data'  => [
                                        'toggle'    => 'tooltip',
                                        'placement' => 'top',
                                    ],
                                    'class' => 'btn btn-default pull-right disabled',
                                ]
                            );
                        } elseif (in_array($variant->id, \Yii::$app->user->identity->wishlist)) {
                            echo Html::button(
                                Html::tag('i', '', [ 'class' => 'fa fa-heart' ]),
                                [
e226698d   mzavalniuk   translate shop pa...
285
                                    'title' => 'Видалити з обраного',
950817c6   Alex Savenko   first commit
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
                                    'data'  => [
                                        'toggle'    => 'tooltip',
                                        'placement' => 'top',
                                        'product'   => $model->id,
                                        'variant'   => $variant->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' ]),
                                [
e226698d   mzavalniuk   translate shop pa...
301
                                    'title' => 'Додати у обране',
950817c6   Alex Savenko   first commit
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
                                    'data'  => [
                                        'toggle'    => 'tooltip',
                                        'placement' => 'top',
                                        'product'   => $model->id,
                                        'variant'   => $variant->id,
                                        'user'      => \Yii::$app->user->identity->getId(),
                                        'url'       => Url::to([ 'product/wishlist-add' ]),
                                    ],
                                    'class' => 'wishlist-add btn btn-success pull-right',
                                ]
                            );
                        }
                    ?>
                </p>
                <div class="line-card"></div>
                  <div class="row">
                      <?php
                          if ($variant->canBuy()) {
                              echo '<div class="col-xs-12 col-sm-4 card-buttons-wr">';
                              echo Html::a(
                                  Html::icon(
                                      'phone',
                                      [
                                          'prefix' => 'fa fa-',
                                      ]
e226698d   mzavalniuk   translate shop pa...
327
                                  ) . \Yii::t('app', 'Купити в один клік'),
950817c6   Alex Savenko   first commit
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
                                  '#',
                                  [
                                      'data'  => [
                                          'toggle' => 'modal',
                                          'target' => '#oneclick-modal',
                                      ],
                                      'class' => 'btn btn-template-main',
                                  ]
                              );
                              echo '</div>';
                              echo '<div class="col-xs-12 col-sm-4 card-buttons-wr">';
                              echo Html::button(
                                  Html::icon(
                                      'tags',
                                      [
                                          'prefix' => 'fa fa-',
                                      ]
e226698d   mzavalniuk   translate shop pa...
345
                                  ) . \Yii::t('app', 'Купити в кредит'),
950817c6   Alex Savenko   first commit
346
347
348
349
350
351
352
353
354
355
356
357
358
                                  [
                                      'class' => 'btn btn-template-main',
                                      'id'    => 't_buy_credit',
                                  ]
                              );
                              echo '</div>';
                              echo '<div class="col-xs-12 col-sm-4 card-buttons-wr">';
                              echo Html::button(
                                  Html::icon(
                                      'tags',
                                      [
                                          'prefix' => 'fa fa-',
                                      ]
e226698d   mzavalniuk   translate shop pa...
359
                                  ) . \Yii::t('app', 'Купити у розстрочку'),
950817c6   Alex Savenko   first commit
360
361
362
363
364
365
366
367
368
369
370
371
                                  [
                                      'class' => 'btn btn-template-main',
                                      'id'    => 't_buy_installment',
                                  ]
                              );
                              echo '</div>';
                          }
                      ?>
                  </div>
  
              </div>
              <div class="box" id="details">
e226698d   mzavalniuk   translate shop pa...
372
373
                <h2><?php echo \Yii::t('app', 'Опис товару'); ?></h2>
                  <?php echo $model->lang->description ? : \Yii::t('app', 'Немає опису'); ?>
950817c6   Alex Savenko   first commit
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
              </div>
              
              <div class="box" id="details">
                <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 {
e226698d   mzavalniuk   translate shop pa...
413
                          echo \Yii::t('app', 'Немає характеристик');
950817c6   Alex Savenko   first commit
414
415
416
417
418
419
420
421
422
423
                      }
                  ?>
              </div>
            </div>
          </div>
            
            <?php
                if (!empty($similar)) {
                    ?>
                  <div class="heading text-center">
e226698d   mzavalniuk   translate shop pa...
424
                    <h2><?php echo \Yii::t('app', 'Схожі товари'); ?></h2>
950817c6   Alex Savenko   first commit
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
                  </div>
                  
                  <div class="product-carousel">
                    <div class="homepage owl-carousel">
                        <?php
                            $newItemsArrays = array_chunk($similar, 4);
                            foreach ($newItemsArrays as $newItemsArray) {
                                ?>
                              <div class="products sliders_">
                                  <?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>
e226698d   mzavalniuk   translate shop pa...
467
          <h4 class="modal-title callback"><?php echo \Yii::t('app', 'Купити в один клік'); ?></h4>
950817c6   Alex Savenko   first commit
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
        </div>
        <div class="modal-body">
            <?php
                $order = new Order(
                    [
                        'scenario'  => Order::SCENARIO_FAST,
                        'variantId' => $variant->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')
f4c99965   mzavalniuk   translate to ua s...
491
                          ->label(Yii::t('app','name'))
950817c6   Alex Savenko   first commit
492
493
494
495
496
497
                          ->textInput(
                              [
                                  'placeholder' => $order->getAttributeLabel('name'),
                              ]
                          );
                echo $form->field($order, 'phone')
f4c99965   mzavalniuk   translate to ua s...
498
                          ->label(Yii::t('app','phone'))
950817c6   Alex Savenko   first commit
499
500
501
502
503
504
505
506
507
508
509
510
511
                          ->textInput(
                              [
                                  'placeholder' => $order->getAttributeLabel('phone'),
                              ]
                          );
                echo Html::tag(
                    'p',
                    Html::submitButton(
                        Html::icon(
                            'shopping-cart',
                            [
                                'prefix' => 'fa fa-',
                            ]
e226698d   mzavalniuk   translate shop pa...
512
                        ) . \Yii::t('app', ' Відправити'),
950817c6   Alex Savenko   first commit
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
                        [
                            'class' => 'btn btn-template-main',
                        ]
                    ),
                    [
                        'class' => 'text-center',
                    ]
                );
                $form::end();
            ?>
        </div>
      </div>
    </div>
  </div>
  
  <div
    class="Oziris_dialog"
    ProductCode="KS-POTREB"
    Line0Code="<?php echo $variant->sku; ?>"
    Line0Title="<?php echo urlencode($model->lang->title); ?>"
    Line0Price=<?php echo $variant->price ? : 0; ?>
  ></div>