Blame view

frontend/views/catalog/products.php 11 KB
8df80521   Alexander Karnovsky   not fixed commite
1
2
  <?php
  /** @var $this \yii\web\View */
6fa713ca   Karnovsky A   Catalog v 1.2
3
4
5
6
7
  /** @var $productProvider \yii\data\ActiveDataProvider */
  /** @var $brandProvider \yii\data\ActiveDataProvider */
  
  use yii\helpers\Url;
  use common\modules\product\helpers\ProductHelper;
8df80521   Alexander Karnovsky   not fixed commite
8
  
14eadb86   Karnovsky A   Eager loading for...
9
  $this->title = $category->categoryName->value;
8df80521   Alexander Karnovsky   not fixed commite
10
  foreach($category->getParents()->all() as $parent) {
6fa713ca   Karnovsky A   Catalog v 1.2
11
      $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
8df80521   Alexander Karnovsky   not fixed commite
12
  }
14eadb86   Karnovsky A   Eager loading for...
13
  $this->params['breadcrumbs'][] = $category->categoryName->value;
8df80521   Alexander Karnovsky   not fixed commite
14
  ?>
b519af22   Karnovsky A   Base-product func...
15
  <script type="text/javascript">
6fa713ca   Karnovsky A   Catalog v 1.2
16
  <?php if ($priceLimits['min'] < $priceLimits['max']) :?>
b519af22   Karnovsky A   Base-product func...
17
18
19
20
      $(document).ready(function() {
          // price rangeslider (filter price slider)
          $("#price_interval").ionRangeSlider({
              type: "double",
6fa713ca   Karnovsky A   Catalog v 1.2
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
              min: <?= $priceLimits['min']?>,
              max: <?= $priceLimits['max']?>,
              from: <?= empty($filter['prices']['min']) ? $priceLimits['min'] : $filter['prices']['min']?>,
              to: <?= empty($filter['prices']['max']) ? $priceLimits['max'] : $filter['prices']['max']?>,
              grid: false,
              onFinish: function(e) {
  <?php
  $filterWhitoutPrice = $filter;
  $filterWhitoutPrice['prices'] = [
      'min' => '{from}',
      'max' => '{to}',
  ];
  ?>
                  var url = "<?= Url::to(['catalog/category', 'category' => $category, 'filter' => $filterWhitoutPrice])?>";
                  var from = e.from;
                  var to = e.to;
                  document.location = url.replace('{from}', from).replace('{to}', to);
              }
          });
      });
  <?php endif?>
  <?php /*
      $(document).ready(function() {
          $('form.filter-catalog-form').each(function() {
              var form = $(this);
              form.submit(function(e) {
                  e.preventDefault();
                  var brands = '';
                  // Get brands values
                  $('input[type=checkbox].brands-option:checked', form).each(function() {
                      var filter_value = $(this).val().replace(',', '~').replace('/', '&s;');
                      if (brands) {
                          brands += ','+ filter_value;
                      } else {
                          brands = filter_value;
                      }
                  });
                  // Formate query and redirect
                  var filter = '';
                  if (brands) {
                      filter += 'brands='+ brands;
                  }
                  filter += ';';
  
                  if (filter) {
                      var request = '<?= Url::toRoute(['catalog/category/filter', 'alias' => $category->alias, 'filter' => '+ filter .'])?>';
                      window.location.href = request;
                  }
              });
b519af22   Karnovsky A   Base-product func...
70
71
          });
      });
6fa713ca   Karnovsky A   Catalog v 1.2
72
  */?>
b519af22   Karnovsky A   Base-product func...
73
74
75
76
77
78
  </script>
  <div class="w_960">
      <!-- side bar with all filters -->
      <div class="cat_p_filter_bar">
          <div class="title">ФИЛЬТРЫ</div>
          <div class="filter_list">
6fa713ca   Karnovsky A   Catalog v 1.2
79
80
81
82
83
84
85
              <form action="#" name="filter_catalog_page_form" class="filter-catalog-form">
                  <?php if (!empty($filter)) :?>
                  <div class="filter_accept_bloc">
                      <!--                    <button type="submit" class="filter_accept_btn">применить</button>-->
                      <a href="<?= Url::to(['catalog/category', 'category' => $category])?>" class="_form_checkbox_reset">сбросить фильтры</a>
                  </div>
                  <?php endif?>
b519af22   Karnovsky A   Base-product func...
86
                  <ul>
6fa713ca   Karnovsky A   Catalog v 1.2
87
                      <?php if ($priceLimits['min'] < $priceLimits['max']) :?>
b519af22   Karnovsky A   Base-product func...
88
89
90
91
92
93
                      <li>Цена:
                          <div class="arrow"><img src="/images/head_up.png" alt=""></i></div>
                          <div class="price_filter first_price_li">
                              <div class="price_slider">
                                  <input type="text" id="price_interval" name="price_interval" value="" />
                              </div>
b519af22   Karnovsky A   Base-product func...
94
95
                          </div>
                      </li>
6fa713ca   Karnovsky A   Catalog v 1.2
96
                      <?php endif?>
b519af22   Karnovsky A   Base-product func...
97
  
6fa713ca   Karnovsky A   Catalog v 1.2
98
99
100
101
102
103
104
105
106
107
108
109
110
                      <?php if ($brandProvider->totalCount > 0) :?>
                          <li>Бренд
                              <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                              <div class="price_filter<?= !empty($filter['brands'])?' active-field':''?>">
                                  <?php foreach($brandProvider->models as $brand) :
                                      $checked = !empty($filter['brands']) && in_array($brand->alias, $filter['brands']);
                                      $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'brands', $brand->alias, $checked)]);
                                      ?>
                                      <div class="checkbox">
                                          <label><input type="checkbox" class="brands-option" <?php /*name="brands[]" value="<?= $brand->alias?>"*/?><?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" /></label>
                                          <a href="<?= $option_url?>"><?= $brand->name?> (<?= $brand->getProducts()->count()?>)</a>
                                      </div>
                                  <?php endforeach?>
b519af22   Karnovsky A   Base-product func...
111
                              </div>
6fa713ca   Karnovsky A   Catalog v 1.2
112
                          </li>
b519af22   Karnovsky A   Base-product func...
113
114
                      <?php endif?>
  
b15c889e   Karnovsky A   Base-product#2 fu...
115
                      <?php if (!empty($groups)) :?>
6fa713ca   Karnovsky A   Catalog v 1.2
116
                          <div class="title_2">ПОДБОР ПО ПАРАМЕТРАМ</div>
b519af22   Karnovsky A   Base-product func...
117
  
b15c889e   Karnovsky A   Base-product#2 fu...
118
                          <?php foreach($groups as $group) :?>
6fa713ca   Karnovsky A   Catalog v 1.2
119
120
121
122
123
124
125
126
127
128
129
130
                              <li><?= $group->name?>
                                  <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                                  <div class="price_filter<?= isset($filter['options'][$group->alias])?' active-field':''?>">
                                      <?php foreach($group->_options as $option) :
                                          $checked = (isset($filter['options'][$group->alias]) && in_array($option->alias, $filter['options'][$group->alias]));
                                          $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'options', [$option->group->alias => [$option->alias]], $checked)]);
                                          ?>
                                          <div class="checkbox">
                                              <label><input type="checkbox" class="features-option" onchange="document.location='<?= $option_url?>'" <?php /* name="option[<?= $group->alias?>][]"value="<?= $option->alias?>"*/?><?= $checked ? ' checked' : ''?> /></label>
                                              <a href="<?= $option_url?>"><?= $option->ValueRenderHTML?>&nbsp;(<?= $option->_items_count?>)</a>
                                          </div>
                                      <?php endforeach?>
b15c889e   Karnovsky A   Base-product#2 fu...
131
                                  </div>
6fa713ca   Karnovsky A   Catalog v 1.2
132
                              </li>
b15c889e   Karnovsky A   Base-product#2 fu...
133
134
                          <?php endforeach?>
                      <?php endif?>
b519af22   Karnovsky A   Base-product func...
135
                  </ul>
b519af22   Karnovsky A   Base-product func...
136
              </form>
b519af22   Karnovsky A   Base-product func...
137
          </div>
b519af22   Karnovsky A   Base-product func...
138
139
140
141
      </div>
  
      <!-- catalog list with all item cards -->
      <div class="cat_p_catalog_list">
6fa713ca   Karnovsky A   Catalog v 1.2
142
          <div class="title"><?= $category->categoryName->value?> <span>(<?= $productProvider->totalCount?>)</span></div>
b519af22   Karnovsky A   Base-product func...
143
  
6fa713ca   Karnovsky A   Catalog v 1.2
144
          <?php if (!$productProvider->count) :?>
2c4d173e   Karnovsky A   Base-product#6 fu...
145
              <h2>По данному запросу товары не найдены.</h2><br>
6fa713ca   Karnovsky A   Catalog v 1.2
146
              <p>Показать <a href="<?= Url::to(['catalog/category', 'category' => $category])?>">все товары из категории "<?= $category->categoryName->value?>"</a></p>
2c4d173e   Karnovsky A   Base-product#6 fu...
147
          <?php else :?>
6fa713ca   Karnovsky A   Catalog v 1.2
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
              <!-- sort menu -->
              <div class="sort_menu">
  
                  <div class="sort_price">
                      <span>Сортировка:</span>
                      <?= \yii\widgets\LinkSorter::widget([
                          'sort' => $productProvider->sort,
                          'attributes' => [
                              'name',
                              'price',
                          ]
                      ]);
                      ?>
                      <!--
                      <select name="sort_price" id="" class="sort_price_select">
                          <option value="price">по цене</option>
                          <option value="popular">новые</option>
                          <option value="sale">по акции</option>
                      </select>
                      <i class="fa fa-angle-down"></i>-->
                  </div>
b519af22   Karnovsky A   Base-product func...
169
  
6fa713ca   Karnovsky A   Catalog v 1.2
170
171
172
173
174
175
176
177
                  <div class="show">
                      <!--<span>Показывать по:</span>
                      <ul>
                          <li><a class="active" href="#">24</a></li>
                          <li><a href="#">48</a></li>
                          <li><a href="#">96</a></li>
                      </ul>-->
                  </div>
b519af22   Karnovsky A   Base-product func...
178
  
6fa713ca   Karnovsky A   Catalog v 1.2
179
180
181
182
183
184
185
186
187
188
                  <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?>
                  <div class="show_pages">
                      Страница:
                      <?= \yii\widgets\LinkPager::widget([
                          'pagination' => $productProvider->pagination,
                          'options' => ['class' => 'pagination pull-right'],
                      ]);
                      ?>
                      <!--<i class="fa fa-caret-right"></i>-->
                  </div>
8df80521   Alexander Karnovsky   not fixed commite
189
                  <?php endif?>
b519af22   Karnovsky A   Base-product func...
190
  
6fa713ca   Karnovsky A   Catalog v 1.2
191
              </div>
b519af22   Karnovsky A   Base-product func...
192
  
6fa713ca   Karnovsky A   Catalog v 1.2
193
194
195
196
197
198
199
200
              <div class="cat_p_item_card_list">
                  <div class="novelty">
                      <div class="content">
                          <div class="novelty_cont">
                              <?php foreach($productProvider->models as $product) :?>
                                  <?php require(__DIR__ .'/product_item.php')?>
                              <?php endforeach?>
                          </div>
b519af22   Karnovsky A   Base-product func...
201
  
6fa713ca   Karnovsky A   Catalog v 1.2
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
                          <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?>
                              <!-- LOAD MORE BUTTON -->
                              <!--button class="load_more_btn">Загрузить еще <?= $productProvider->pagination->pageSize?> товара</button-->
  
                              <div class="show_pages">
                                  Страница:
                                  <?= \yii\widgets\LinkPager::widget([
                                      'pagination' => $productProvider->pagination,
                                      'options' => ['class' => 'pagination pull-right'],
                                  ]);
                                  ?>
                                  <!--<i class="fa fa-caret-right"></i>-->
                              </div>
                          <?php endif ?>
                          <hr>
b519af22   Karnovsky A   Base-product func...
217
  
6fa713ca   Karnovsky A   Catalog v 1.2
218
219
220
                          <?php if(!empty($category->description)) :?>
                              <div class="description">
                                  <?= $category->description?>
b519af22   Karnovsky A   Base-product func...
221
  
6fa713ca   Karnovsky A   Catalog v 1.2
222
223
224
                                  <div class="empty_padding_400"></div>
                              </div>
                          <?php endif?>
b519af22   Karnovsky A   Base-product func...
225
                      </div>
b519af22   Karnovsky A   Base-product func...
226
227
                  </div>
              </div>
2c4d173e   Karnovsky A   Base-product#6 fu...
228
229
  
          <?php endif?>
b519af22   Karnovsky A   Base-product func...
230
      </div>
6fa713ca   Karnovsky A   Catalog v 1.2
231
  </div>