Blame view

frontend/views/catalog/product.php 8.72 KB
055ecc3b   Karnovsky A   Karnovsky 11052016
1
  <?php
ccc7a9d3   Karnovsky A   Karnovsky 12052016
2
3
4
5
  use yii\widgets\Breadcrumbs;
  use yii\web\View;
  use yii\helpers\Url;
  
060b4806   Karnovsky A   -
6
7
8
  $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)]);
ccc7a9d3   Karnovsky A   Karnovsky 12052016
9
10
  //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]);
  
055ecc3b   Karnovsky A   Karnovsky 11052016
11
12
13
14
  foreach($product->category->getParents()->all() as $parent) {
      $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
  }
  $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]];
060b4806   Karnovsky A   -
15
  $this->params['breadcrumbs'][] = $product->fullname .' #'. $product->variant->sku;
055ecc3b   Karnovsky A   Karnovsky 11052016
16
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
17
  $this->registerJs ('
055ecc3b   Karnovsky A   Karnovsky 11052016
18
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
19
20
          var checkData = function($index)
          {
f307b0a8   Karnovsky A   -
21
22
23
24
              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
25
              var $target = $(".productLeftBar .cost_box");
055ecc3b   Karnovsky A   Karnovsky 11052016
26
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
27
28
              $("#cost").text($source.data("cost"));
              $("#old_cost").text($source.data("old_cost"));
055ecc3b   Karnovsky A   Karnovsky 11052016
29
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
30
31
32
33
34
35
36
37
              if (parseInt ($source.data("old_cost")) == 0)
              {
                  $target.find("strike").hide();
              }
              else
              {
                  $target.find("strike").show();
              }
055ecc3b   Karnovsky A   Karnovsky 11052016
38
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
39
40
41
42
43
44
              $("#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
45
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
46
47
48
          $(".product_mod > li").click(function()
          {
              checkData($(this).index());
055ecc3b   Karnovsky A   Karnovsky 11052016
49
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
50
              Shadowbox.setup($("#picoriginal"));
055ecc3b   Karnovsky A   Karnovsky 11052016
51
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
52
53
              return false;
          });
055ecc3b   Karnovsky A   Karnovsky 11052016
54
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
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
          checkData(0);
  
      ', View::POS_READY, 'fasovka');
  
  $this->registerJs ("
          $('#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');
  
  $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_HEAD, 'depends' => ['yii\web\JqueryAsset']]);
  $this->registerJs ("
          Shadowbox.init({
  
      });
      ", View::POS_READY, 'Shadowbox');
  ?>
  
  
  <nav class="bread-crumbs">
      <?= Breadcrumbs::widget ([
          'links' => [
              ['label' => 'Каталог', 'url' => ['catalog/all']],
              // ['label'=>$catalog->parent->name,'url'=>['catalog/index','translit'=>$catalog->parent->translit]],
              ['label' => $category->name, 'url' => ['catalog/category', 'category' => $category]],
060b4806   Karnovsky A   -
89
              $product->fullname,
ccc7a9d3   Karnovsky A   Karnovsky 12052016
90
91
92
93
94
95
96
97
          ],
      ]) ?>
      <div class="both"></div>
  </nav>
  <?php if ($flash = Yii::$app->session->getFlash ('success')): ?>
      <div class="alert-success"><?= $flash ?></div>
  <?php endif; ?>
  <div class="loyout">
ccc7a9d3   Karnovsky A   Karnovsky 12052016
98
      <div class="productLeftBar">
060b4806   Karnovsky A   -
99
          <h1><?= $product->fullname ?></h1>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
100
101
          <div class="begin">Цветовые решения</div>
          <ul class="product_mod">
83be3cfb   Karnovsky A   -
102
              <?php foreach (array_reverse($product->variants) as $variant): ?>
945d3944   Karnovsky A   -
103
                  <?php if (!is_null($variant->stock) && empty($variant->stock)) continue;?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
104
                  <li>
83be3cfb   Karnovsky A   -
105
                      <a id='m<?= $variant->product_variant_id ?>' href="#<?=$variant->product_variant_id ?>"
ccc7a9d3   Karnovsky A   Karnovsky 12052016
106
107
108
                         data-cost="<?= $variant->price ?>"
                         data-old_cost="<?= $variant->price_old ?>" data-id="<?= $variant->product_variant_id ?>" data-art="<?= $variant->sku ?>"
                         data-color="<?= $variant->name ?>"
f307b0a8   Karnovsky A   -
109
                         data-image="<?= \common\components\artboximage\ArtboxImageHelper::getImageSrc($variant->imageUrl, 'product_view') ?>"
dc2cd017   Karnovsky A   -
110
                         data-imageoriginal="<?= $variant->imageUrl ?>"
060b4806   Karnovsky A   -
111
                         title="<?= $product->fullname ?>">
dc2cd017   Karnovsky A   -
112
113
                          <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant')?>
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
114
115
116
                      </a>
                  </li>
              <?php endforeach; ?>
055ecc3b   Karnovsky A   Karnovsky 11052016
117
          </ul>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
118
          <div class="both"></div>
055ecc3b   Karnovsky A   Karnovsky 11052016
119
  
73bc07bd   Виталий   Веталь
120
          <div class="cost_box product_read_">
ccc7a9d3   Karnovsky A   Karnovsky 12052016
121
              <div class='params'>код: <span id='art'></span><br/> цвет: <span id='color'></span></div>
f307b0a8   Karnovsky A   -
122
123
124
125
126
127
128
129
              <div class="product_read_price">
                  <div class="w">
                      <strike><span id='old_cost'>0</span> грн.</strike>
                      <span class="cost"><span id='cost'>0</span> <span class="valute">грн.</span></span>
                  </div>
                  <input type='hidden' id='product_id'/>
                  <a href="#" rel='product' class="link_buy fl">В Корзину</a>
                  <div class="both"></div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
130
              </div>
055ecc3b   Karnovsky A   Karnovsky 11052016
131
          </div>
7d9935e2   Administrator   проапдейтил роли
132
          <?php /*
ccc7a9d3   Karnovsky A   Karnovsky 12052016
133
134
135
136
137
138
139
140
141
          <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>
7d9935e2   Administrator   проапдейтил роли
142
          </div>*/?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
143
      </div>
055ecc3b   Karnovsky A   Karnovsky 11052016
144
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
145
146
147
148
149
150
151
152
      <div class="productRightBar">
          <ul id="nav_product">
              <li><a href="#">Характеристики</a>
                  <div class="info">
                      <p>Бренд: <?= $product->brand->name ?></p>
                      <?php foreach ($properties as $group): ?>
                          <p><?= $group->name ?> <?php foreach($group->_options as $option) :?>&nbsp;<?= $option->ValueRenderHTML?><?php endforeach?></p>
                      <?php endforeach; ?>
055ecc3b   Karnovsky A   Karnovsky 11052016
153
                  </div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
154
155
156
157
              </li>
              <li><a href="#">Описание</a>
                  <div class="info">
                      <?= $product->description ?>
055ecc3b   Karnovsky A   Karnovsky 11052016
158
                  </div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
159
              </li>
f307b0a8   Karnovsky A   -
160
161
162
              <?php if(!empty($product->video)) :?>
                  <li><a href="#">Видео</a>
                      <div class="info product-thumb-video">
4902c747   Karnovsky A   -
163
                          <?= strpos($product->video, '<iframe') !== FALSE || strpos($product->video, '<object') !== FALSE ? $product->video : \cics\widgets\VideoEmbed::widget(['responsive' => false, 'url' => $product->video]); ?>
f307b0a8   Karnovsky A   -
164
165
166
                      </div>
                  </li>
              <?php endif?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
167
168
          </ul>
      </div>
055ecc3b   Karnovsky A   Karnovsky 11052016
169
  
ccc7a9d3   Karnovsky A   Karnovsky 12052016
170
      <div class="content">
ccc7a9d3   Karnovsky A   Karnovsky 12052016
171
172
          <div class="pic">
              <center>
3c6209a0   Administrator   image size
173
                  <a href="#" rel="shadowbox[gal]" id="picoriginal"><?= \common\components\artboximage\ArtboxImageHelper::getImage($product->imageUrl, 'product_view',['id'=>'pic'])?></a>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
174
              </center>
055ecc3b   Karnovsky A   Karnovsky 11052016
175
          </div>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
176
177
          <ul class="product_colors">
              <?php foreach ($product->images as $image): ?>
2f93d129   Karnovsky A   -
178
                  <li><a href="<?= $image->imageUrl ?>" rel="shadowbox[gal]">
f307b0a8   Karnovsky A   -
179
                          <?= \common\components\artboximage\ArtboxImageHelper::getImage($image->imageUrl, 'product_trumb2')?>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
180
181
182
                      </a></li>
              <?php endforeach; ?>
          </ul>
ccc7a9d3   Karnovsky A   Karnovsky 12052016
183
184
      </div>
      <div class="both"></div>
4902c747   Karnovsky A   -
185
186
187
188
189
  
      <?= \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()?>
463e6d52   Виталий   Веталь
190
  </div>
85235ea6   Виталий   Веталь
191
  <?php
2fcc30a0   Виталий   Веталь
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
  $this->registerJs ("
        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');
  ?>