Completed
Push — master ( d4133d...2ce86d )
by Alexey
04:49
created
system/modules/Ecommerce/Ecommerce.php 2 patches
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -10,172 +10,172 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class Ecommerce extends Module {
12 12
 
13
-  public function init() {
13
+    public function init() {
14 14
     App::$primary->view->customAsset('js', '/moduleAsset/Ecommerce/js/cart.js');
15
-  }
15
+    }
16 16
 
17
-  public function getPayTypeHandlers($forSelect = false) {
17
+    public function getPayTypeHandlers($forSelect = false) {
18 18
     if (!$forSelect) {
19
-      return $this->getSnippets('payTypeHandler');
19
+        return $this->getSnippets('payTypeHandler');
20 20
     }
21 21
     $handlers = ['' => 'Не выбрано'];
22 22
     foreach ($this->getSnippets('payTypeHandler') as $key => $handler) {
23
-      if (empty($handler)) {
23
+        if (empty($handler)) {
24 24
         continue;
25
-      }
26
-      $handlers[$key] = $handler['name'];
25
+        }
26
+        $handlers[$key] = $handler['name'];
27 27
     }
28 28
     return $handlers;
29
-  }
29
+    }
30 30
 
31
-  public function cartPayRecive($data) {
31
+    public function cartPayRecive($data) {
32 32
     $cart = Ecommerce\Cart::get($data['pay']->data);
33 33
     if ($cart) {
34
-      $payed = true;
35
-      foreach ($cart->pays as $pay) {
34
+        $payed = true;
35
+        foreach ($cart->pays as $pay) {
36 36
         if ($pay->pay_status_id != 2) {
37
-          $payed = false;
38
-          break;
37
+            $payed = false;
38
+            break;
39 39
         }
40
-      }
41
-      $cart->payed = $payed;
42
-      $cart->save();
40
+        }
41
+        $cart->payed = $payed;
42
+        $cart->save();
43
+    }
43 44
     }
44
-  }
45 45
 
46
-  public function parseFields($data, $cart) {
46
+    public function parseFields($data, $cart) {
47 47
     $fields = \Ecommerce\UserAdds\Field::getList();
48 48
     $name = '';
49 49
     foreach ($fields as $field) {
50
-      if ($field->save && !empty($data[$field->id])) {
50
+        if ($field->save && !empty($data[$field->id])) {
51 51
         $name .= htmlspecialchars($data[$field->id]) . ' ';
52
-      }
52
+        }
53 53
     }
54 54
     $name = trim($name);
55 55
 
56 56
     $userAdds = Ecommerce\UserAdds::get([['user_id', $cart->user->id], ['name', $name]]);
57 57
     if (!$userAdds) {
58
-      $userAdds = new Ecommerce\UserAdds();
59
-      $userAdds->user_id = $cart->user->id;
60
-      $userAdds->name = $name;
61
-      $userAdds->save();
62
-      foreach ($fields as $field) {
58
+        $userAdds = new Ecommerce\UserAdds();
59
+        $userAdds->user_id = $cart->user->id;
60
+        $userAdds->name = $name;
61
+        $userAdds->save();
62
+        foreach ($fields as $field) {
63 63
         if (!$field->save) {
64
-          continue;
64
+            continue;
65 65
         }
66 66
         $userAddsValue = new Ecommerce\UserAdds\Value();
67 67
         $userAddsValue->value = htmlspecialchars($data[$field->id]);
68 68
         $userAddsValue->useradds_field_id = $field->id;
69 69
         $userAddsValue->useradds_id = $userAdds->id;
70 70
         $userAddsValue->save();
71
-      }
71
+        }
72 72
     }
73 73
     $user = \Users\User::get($cart->user_id);
74 74
     foreach ($fields as $field) {
75
-      $info = new \Ecommerce\Cart\Info();
76
-      $info->name = $field->name;
77
-      $info->value = htmlspecialchars($data[$field->id]);
78
-      $info->useradds_field_id = $field->id;
79
-      $info->cart_id = $cart->id;
80
-      $info->save();
81
-      $relations = [];
82
-      if ($field->userfield) {
75
+        $info = new \Ecommerce\Cart\Info();
76
+        $info->name = $field->name;
77
+        $info->value = htmlspecialchars($data[$field->id]);
78
+        $info->useradds_field_id = $field->id;
79
+        $info->cart_id = $cart->id;
80
+        $info->save();
81
+        $relations = [];
82
+        if ($field->userfield) {
83 83
         if (strpos($field->userfield, ':')) {
84
-          $path = explode(':', $field->userfield);
85
-          if (!$user->{$path[0]}->{$path[1]}) {
84
+            $path = explode(':', $field->userfield);
85
+            if (!$user->{$path[0]}->{$path[1]}) {
86 86
             $user->{$path[0]}->{$path[1]} = $info->value;
87 87
             $relations[$path[0]] = $path[0];
88
-          }
88
+            }
89 89
         } else {
90
-          if (!$user->{$field->userfield}) {
90
+            if (!$user->{$field->userfield}) {
91 91
             $user->{$field->userfield} = $info->value;
92
-          }
92
+            }
93 93
         }
94
-      }
95
-      foreach ($relations as $rel) {
94
+        }
95
+        foreach ($relations as $rel) {
96 96
         $user->$rel->save();
97
-      }
98
-      $user->save();
97
+        }
98
+        $user->save();
99 99
     }
100 100
     return $userAdds;
101
-  }
101
+    }
102 102
 
103
-  public function parseDeliveryFields($data, $cart, $fields) {
103
+    public function parseDeliveryFields($data, $cart, $fields) {
104 104
     $name = '';
105 105
     foreach ($fields as $field) {
106
-      if ($field->save && !empty($data[$field->id])) {
106
+        if ($field->save && !empty($data[$field->id])) {
107 107
         $name .= htmlspecialchars($data[$field->id]) . ' ';
108
-      }
108
+        }
109 109
     }
110 110
     $name = trim($name);
111 111
 
112 112
     $save = Ecommerce\Delivery\Save::get([['user_id', $cart->user->id], ['name', $name]]);
113 113
     if (!$save) {
114
-      $save = new Ecommerce\Delivery\Save();
115
-      $save->user_id = $cart->user->id;
116
-      $save->name = $name;
117
-      $save->save();
118
-      foreach ($fields as $field) {
114
+        $save = new Ecommerce\Delivery\Save();
115
+        $save->user_id = $cart->user->id;
116
+        $save->name = $name;
117
+        $save->save();
118
+        foreach ($fields as $field) {
119 119
         if (!$field->save) {
120
-          continue;
120
+            continue;
121 121
         }
122 122
         $saveValue = new Ecommerce\Delivery\Value();
123 123
         $saveValue->value = htmlspecialchars($data[$field->id]);
124 124
         $saveValue->delivery_field_id = $field->id;
125 125
         $saveValue->delivery_save_id = $save->id;
126 126
         $saveValue->save();
127
-      }
127
+        }
128 128
     }
129 129
     $user = \Users\User::get($cart->user_id);
130 130
     foreach ($fields as $field) {
131
-      $info = new \Ecommerce\Cart\DeliveryInfo();
132
-      $info->name = $field->name;
133
-      $info->value = htmlspecialchars($data[$field->id]);
134
-      $info->delivery_field_id = $field->id;
135
-      $info->cart_id = $cart->id;
136
-      $info->save();
137
-      $relations = [];
138
-      if ($field->userfield) {
131
+        $info = new \Ecommerce\Cart\DeliveryInfo();
132
+        $info->name = $field->name;
133
+        $info->value = htmlspecialchars($data[$field->id]);
134
+        $info->delivery_field_id = $field->id;
135
+        $info->cart_id = $cart->id;
136
+        $info->save();
137
+        $relations = [];
138
+        if ($field->userfield) {
139 139
         if (strpos($field->userfield, ':')) {
140
-          $path = explode(':', $field->userfield);
141
-          if (!$user->{$path[0]}->{$path[1]}) {
140
+            $path = explode(':', $field->userfield);
141
+            if (!$user->{$path[0]}->{$path[1]}) {
142 142
             $user->{$path[0]}->{$path[1]} = $info->value;
143 143
             $relations[$path[0]] = $path[0];
144
-          }
144
+            }
145 145
         } else {
146
-          if (!$user->{$field->userfield}) {
146
+            if (!$user->{$field->userfield}) {
147 147
             $user->{$field->userfield} = $info->value;
148
-          }
148
+            }
149 149
         }
150
-      }
151
-      foreach ($relations as $rel) {
150
+        }
151
+        foreach ($relations as $rel) {
152 152
         $user->$rel->save();
153
-      }
154
-      $user->save();
153
+        }
154
+        $user->save();
155 155
     }
156 156
     return $save;
157
-  }
157
+    }
158 158
 
159
-  public function getCurCart($create = true) {
159
+    public function getCurCart($create = true) {
160 160
     $cart = false;
161 161
     if (!empty($_SESSION['cart']['cart_id'])) {
162
-      $cart = Ecommerce\Cart::get((int) $_SESSION['cart']['cart_id']);
162
+        $cart = Ecommerce\Cart::get((int) $_SESSION['cart']['cart_id']);
163 163
     }
164 164
     if (!$cart && $create) {
165
-      $cart = new Ecommerce\Cart();
166
-      $cart->cart_status_id = 1;
167
-      $cart->user_id = Users\User::$cur->id;
168
-      $userCard = \Ecommerce\Card\Item::get(\Users\User::$cur->id, 'user_id');
169
-      if ($userCard) {
165
+        $cart = new Ecommerce\Cart();
166
+        $cart->cart_status_id = 1;
167
+        $cart->user_id = Users\User::$cur->id;
168
+        $userCard = \Ecommerce\Card\Item::get(\Users\User::$cur->id, 'user_id');
169
+        if ($userCard) {
170 170
         $cart->card_item_id = $userCard->id;
171
-      }
172
-      $cart->save();
173
-      $_SESSION['cart']['cart_id'] = $cart->id;
171
+        }
172
+        $cart->save();
173
+        $_SESSION['cart']['cart_id'] = $cart->id;
174 174
     }
175 175
     return $cart;
176
-  }
176
+    }
177 177
 
178
-  public function parseOptions($options = []) {
178
+    public function parseOptions($options = []) {
179 179
     $selectOptions = [
180 180
         'where' => !empty($options['where']) ? $options['where'] : [],
181 181
         'distinct' => false,
@@ -186,26 +186,26 @@  discard block
 block discarded – undo
186 186
         'limit' => !empty($options['count']) ? (int) $options['count'] : 0,
187 187
     ];
188 188
     if (!empty($options['sort']) && is_array($options['sort'])) {
189
-      foreach ($options['sort'] as $col => $direction) {
189
+        foreach ($options['sort'] as $col => $direction) {
190 190
         switch ($col) {
191
-          case 'price':
191
+            case 'price':
192 192
             $selectOptions['order'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
193 193
             break;
194
-          case 'name':
194
+            case 'name':
195 195
             $selectOptions['order'][] = ['name', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
196 196
             break;
197
-          case 'sales':
197
+            case 'sales':
198 198
             $selectOptions['order'][] = ['sales', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
199 199
             break;
200
-          case 'weight':
200
+            case 'weight':
201 201
             $selectOptions['order'][] = ['weight', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
202 202
             break;
203 203
         }
204
-      }
204
+        }
205 205
     }
206 206
     $selectOptions['where'][] = ['deleted', 0];
207 207
     if (empty($this->config['view_empty_image'])) {
208
-      $selectOptions['where'][] = ['image_file_id', 0, '!='];
208
+        $selectOptions['where'][] = ['image_file_id', 0, '!='];
209 209
     }
210 210
 
211 211
     $selectOptions['join'][] = [Ecommerce\Item\Offer::table(), Ecommerce\Item::index() . ' = ' . Ecommerce\Item\Offer::colPrefix() . Ecommerce\Item::index(), 'inner'];
@@ -229,111 +229,111 @@  discard block
 block discarded – undo
229 229
 
230 230
 
231 231
     if (!empty($this->config['view_filter'])) {
232
-      if (!empty($this->config['view_filter']['options'])) {
232
+        if (!empty($this->config['view_filter']['options'])) {
233 233
         foreach ($this->config['view_filter']['options'] as $optionId => $optionValue) {
234
-          $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' .
235
-              'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' = "' . (int) $optionId . '" AND ' .
236
-              'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . 'value = "' . (int) $optionValue . '"',
237
-              'inner', 'option' . $optionId];
234
+            $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' .
235
+                'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' = "' . (int) $optionId . '" AND ' .
236
+                'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . 'value = "' . (int) $optionValue . '"',
237
+                'inner', 'option' . $optionId];
238
+        }
238 239
         }
239
-      }
240 240
     }
241 241
     //filters
242 242
     if (!empty($options['filters'])) {
243
-      foreach ($options['filters'] as $col => $filter) {
243
+        foreach ($options['filters'] as $col => $filter) {
244 244
         switch ($col) {
245
-          case 'price':
245
+            case 'price':
246 246
             if (!empty($filter['min'])) {
247
-              $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', (float) $filter['min'], '>='];
247
+                $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', (float) $filter['min'], '>='];
248 248
             }
249 249
             if (!empty($filter['max'])) {
250
-              $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', (float) $filter['max'], '<='];
250
+                $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', (float) $filter['max'], '<='];
251 251
             }
252 252
             break;
253
-          case 'options':
253
+            case 'options':
254 254
             foreach ($filter as $optionId => $optionValue) {
255
-              $optionId = (int) $optionId;
256
-              if (is_array($optionValue)) {
255
+                $optionId = (int) $optionId;
256
+                if (is_array($optionValue)) {
257 257
                 $optionValueArr = [];
258 258
                 foreach ($optionValue as $val) {
259
-                  $optionValueArr[] = \App::$cur->db->connection->pdo->quote($val);
259
+                    $optionValueArr[] = \App::$cur->db->connection->pdo->quote($val);
260 260
                 }
261 261
                 $qstr = 'IN (' . implode(',', $optionValueArr) . ')';
262
-              } else {
262
+                } else {
263 263
                 $qstr = '= ' . \App::$cur->db->connection->pdo->quote($optionValue);
264
-              }
265
-              $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' .
266
-                  'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' = "' . (int) $optionId . '" AND ' .
267
-                  'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . 'value ' . $qstr . '',
268
-                  'inner', 'option' . $optionId];
264
+                }
265
+                $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' .
266
+                    'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' = "' . (int) $optionId . '" AND ' .
267
+                    'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . 'value ' . $qstr . '',
268
+                    'inner', 'option' . $optionId];
269 269
             }
270 270
             break;
271
-          case 'offerOptions':
271
+            case 'offerOptions':
272 272
             //$selectOptions['join'][] = [Ecommerce\Item\Offer::table(), Ecommerce\Item::index() . ' = offer.' . Ecommerce\Item\Offer::colPrefix() . Ecommerce\Item::index(), 'left', 'offer'];
273 273
             foreach ($filter as $optionId => $optionValue) {
274
-              $optionId = (int) $optionId;
275
-              if (is_array($optionValue)) {
274
+                $optionId = (int) $optionId;
275
+                if (is_array($optionValue)) {
276 276
                 $optionValueArr = [];
277 277
                 foreach ($optionValue as $val) {
278
-                  $optionValueArr[] = \App::$cur->db->connection->pdo->quote($val);
278
+                    $optionValueArr[] = \App::$cur->db->connection->pdo->quote($val);
279 279
                 }
280 280
                 $qstr = 'IN (' . implode(',', $optionValueArr) . ')';
281
-              } else {
281
+                } else {
282 282
                 $qstr = '= ' . \App::$cur->db->connection->pdo->quote($optionValue);
283
-              }
284
-              $selectOptions['join'][] = [Ecommerce\Item\Offer\Param::table(), Ecommerce\Item\Offer::index() . ' = ' . 'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . Ecommerce\Item\Offer::index() . ' AND ' .
285
-                  'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . Ecommerce\Item\Offer\Option::index() . ' = "' . (int) $optionId . '" AND ' .
286
-                  'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . 'value ' . $qstr,
287
-                  'inner', 'offerOption' . $optionId];
283
+                }
284
+                $selectOptions['join'][] = [Ecommerce\Item\Offer\Param::table(), Ecommerce\Item\Offer::index() . ' = ' . 'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . Ecommerce\Item\Offer::index() . ' AND ' .
285
+                    'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . Ecommerce\Item\Offer\Option::index() . ' = "' . (int) $optionId . '" AND ' .
286
+                    'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . 'value ' . $qstr,
287
+                    'inner', 'offerOption' . $optionId];
288 288
             }
289 289
             break;
290 290
         }
291
-      }
291
+        }
292 292
     }
293 293
     //parents
294 294
     if (!empty($options['parent']) && strpos($options['parent'], ',') !== false) {
295
-      $first = true;
296
-      $where = [];
297
-      foreach (explode(',', $options['parent']) as $categoryId) {
295
+        $first = true;
296
+        $where = [];
297
+        foreach (explode(',', $options['parent']) as $categoryId) {
298 298
         if (!$categoryId) {
299
-          continue;
299
+            continue;
300 300
         }
301 301
         $category = \Ecommerce\Category::get($categoryId);
302 302
         $where[] = ['tree_path', $category->tree_path . (int) $categoryId . '/%', 'LIKE', $first ? 'AND' : 'OR'];
303 303
         $first = false;
304
-      }
305
-      $selectOptions['where'][] = $where;
304
+        }
305
+        $selectOptions['where'][] = $where;
306 306
     } elseif (!empty($options['parent'])) {
307
-      $category = \Ecommerce\Category::get($options['parent']);
308
-      $selectOptions['where'][] = ['tree_path', $category->tree_path . (int) $options['parent'] . '/%', 'LIKE'];
307
+        $category = \Ecommerce\Category::get($options['parent']);
308
+        $selectOptions['where'][] = ['tree_path', $category->tree_path . (int) $options['parent'] . '/%', 'LIKE'];
309 309
     }
310 310
 
311 311
     //search
312 312
     if (!empty($options['search'])) {
313
-      $searchStr = preg_replace('![^A-zА-я0-9 ]!iSu', ' ', $options['search']);
314
-      $searchArr = [];
315
-      foreach (explode(' ', $searchStr) as $part) {
313
+        $searchStr = preg_replace('![^A-zА-я0-9 ]!iSu', ' ', $options['search']);
314
+        $searchArr = [];
315
+        foreach (explode(' ', $searchStr) as $part) {
316 316
         $part = trim($part);
317 317
         if ($part && strlen($part) > 2) {
318
-          $searchArr[] = ['search_index', '%' . $part . '%', 'LIKE'];
318
+            $searchArr[] = ['search_index', '%' . $part . '%', 'LIKE'];
319
+        }
319 320
         }
320
-      }
321
-      if (!empty($searchArr)) {
321
+        if (!empty($searchArr)) {
322 322
         $selectOptions['where'][] = $searchArr;
323
-      }
323
+        }
324 324
     }
325 325
     if (empty($this->config['view_empty_warehouse'])) {
326
-      $warehouseIds = [];
327
-      if (class_exists('Geography\City\Data')) {
326
+        $warehouseIds = [];
327
+        if (class_exists('Geography\City\Data')) {
328 328
         $warehouses = \Geography\City\Data::get([['code', 'warehouses'], ['city_id', \Geography\City::$cur->id]]);
329 329
         if ($warehouses && $warehouses->data) {
330
-          foreach (explode(',', $warehouses->data) as $id) {
330
+            foreach (explode(',', $warehouses->data) as $id) {
331 331
             $warehouseIds[$id] = $id;
332
-          }
332
+            }
333
+        }
333 334
         }
334
-      }
335
-      $selectOptions['where'][] = [
336
-          '(
335
+        $selectOptions['where'][] = [
336
+            '(
337 337
           (SELECT COALESCE(sum(`' . \Ecommerce\Item\Offer\Warehouse::colPrefix() . 'count`),0) 
338 338
             FROM ' . \App::$cur->db->table_prefix . \Ecommerce\Item\Offer\Warehouse::table() . ' iciw 
339 339
             WHERE iciw.' . \Ecommerce\Item\Offer\Warehouse::colPrefix() . \Ecommerce\Item\Offer::index() . ' = ' . \Ecommerce\Item\Offer::index() . '
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
             )
349 349
             WHERE iewb.' . \Ecommerce\Warehouse\Block::colPrefix() . \Ecommerce\Item\Offer::index() . ' = ' . \Ecommerce\Item\Offer::index() . ')
350 350
           )',
351
-          0,
352
-          '>'
353
-      ];
351
+            0,
352
+            '>'
353
+        ];
354 354
     }
355 355
 
356 356
 
@@ -361,15 +361,15 @@  discard block
 block discarded – undo
361 361
     $selectOptions['group'] = Ecommerce\Item::index();
362 362
 
363 363
     return $selectOptions;
364
-  }
365
-
366
-  /**
367
-   * Getting items params with params
368
-   * 
369
-   * @param array $params
370
-   * @return array
371
-   */
372
-  public function getItemsParams($params = []) {
364
+    }
365
+
366
+    /**
367
+     * Getting items params with params
368
+     * 
369
+     * @param array $params
370
+     * @return array
371
+     */
372
+    public function getItemsParams($params = []) {
373 373
     $selectOptions = $this->parseOptions($params);
374 374
     $items = Ecommerce\Item::getList($selectOptions);
375 375
     $items = Ecommerce\Item\Param::getList([
@@ -378,58 +378,58 @@  discard block
 block discarded – undo
378 378
                 'distinct' => \Ecommerce\Item\Option::index()
379 379
     ]);
380 380
     return $items;
381
-  }
382
-
383
-  /**
384
-   * Getting items with params
385
-   * 
386
-   * @param array $params
387
-   * @return array
388
-   */
389
-  public function getItems($params = []) {
381
+    }
382
+
383
+    /**
384
+     * Getting items with params
385
+     * 
386
+     * @param array $params
387
+     * @return array
388
+     */
389
+    public function getItems($params = []) {
390 390
     $selectOptions = $this->parseOptions($params);
391 391
     $items = Ecommerce\Item::getList($selectOptions);
392 392
     return $items;
393
-  }
394
-
395
-  /**
396
-   * Return count of items with params
397
-   * 
398
-   * @param array $params
399
-   * @return int
400
-   */
401
-  public function getItemsCount($params = []) {
393
+    }
394
+
395
+    /**
396
+     * Return count of items with params
397
+     * 
398
+     * @param array $params
399
+     * @return int
400
+     */
401
+    public function getItemsCount($params = []) {
402 402
     $selectOptions = $this->parseOptions($params);
403 403
     $selectOptions['distinct'] = \Ecommerce\Item::index();
404 404
     $counts = Ecommerce\Item::getCount($selectOptions);
405 405
     if (is_array($counts)) {
406
-      $sum = 0;
407
-      foreach ($counts as $count) {
406
+        $sum = 0;
407
+        foreach ($counts as $count) {
408 408
         $sum +=$count['count'];
409
-      }
410
-      return $sum;
409
+        }
410
+        return $sum;
411 411
     }
412 412
     return $counts;
413
-  }
413
+    }
414 414
 
415
-  public function viewsCategoryList($inherit = true) {
415
+    public function viewsCategoryList($inherit = true) {
416 416
     $return = [];
417 417
     if ($inherit) {
418
-      $return['inherit'] = 'Как у родителя';
418
+        $return['inherit'] = 'Как у родителя';
419 419
     }
420 420
     $return['itemList'] = 'Список товаров';
421 421
     $conf = App::$primary->view->template->config;
422 422
     if (!empty($conf['files']['modules']['Ecommerce'])) {
423
-      foreach ($conf['files']['modules']['Ecommerce'] as $file) {
423
+        foreach ($conf['files']['modules']['Ecommerce'] as $file) {
424 424
         if ($file['type'] == 'Category') {
425
-          $return[$file['file']] = $file['name'];
425
+            $return[$file['file']] = $file['name'];
426
+        }
426 427
         }
427
-      }
428 428
     }
429 429
     return $return;
430
-  }
430
+    }
431 431
 
432
-  public function templatesCategoryList() {
432
+    public function templatesCategoryList() {
433 433
     $return = [
434 434
         'inherit' => 'Как у родителя',
435 435
         'current' => 'Текущая тема'
@@ -438,107 +438,107 @@  discard block
 block discarded – undo
438 438
     $conf = App::$primary->view->template->config;
439 439
 
440 440
     if (!empty($conf['files']['aditionTemplateFiels'])) {
441
-      foreach ($conf['files']['aditionTemplateFiels'] as $file) {
441
+        foreach ($conf['files']['aditionTemplateFiels'] as $file) {
442 442
         $return[$file['file']] = '- ' . $file['name'];
443
-      }
443
+        }
444 444
     }
445 445
     return $return;
446
-  }
446
+    }
447 447
 
448
-  public function cartStatusDetector($event) {
448
+    public function cartStatusDetector($event) {
449 449
     $cart = $event['eventObject'];
450 450
     if (!empty($cart->_changedParams['cart_cart_status_id'])) {
451
-      $cart->date_status = date('Y-m-d H:i:s');
452
-      $event = new Ecommerce\Cart\Event(['cart_id' => $cart->id, 'user_id' => \Users\User::$cur->id, 'cart_event_type_id' => 5, 'info' => $cart->cart_status_id]);
453
-      $event->save();
451
+        $cart->date_status = date('Y-m-d H:i:s');
452
+        $event = new Ecommerce\Cart\Event(['cart_id' => $cart->id, 'user_id' => \Users\User::$cur->id, 'cart_event_type_id' => 5, 'info' => $cart->cart_status_id]);
453
+        $event->save();
454 454
 
455
-      $prev_status_id = $cart->_changedParams['cart_cart_status_id'];
456
-      $now_status_id = $cart->cart_status_id;
455
+        $prev_status_id = $cart->_changedParams['cart_cart_status_id'];
456
+        $now_status_id = $cart->cart_status_id;
457 457
 
458
-      $status = Ecommerce\Cart\Status::getList(['where' => ['id', implode(',', [$prev_status_id, $now_status_id]), 'IN']]);
458
+        $status = Ecommerce\Cart\Status::getList(['where' => ['id', implode(',', [$prev_status_id, $now_status_id]), 'IN']]);
459 459
 
460
-      $prefix = isset(App::$cur->ecommerce->config['orderPrefix']) ? $config = App::$cur->ecommerce->config['orderPrefix'] : '';
461
-      \App::$cur->users->AddUserActivity($cart->user_id, 3, "Статус вашего заказа номер {$prefix}{$cart->id} изменился с {$status[$prev_status_id]->name} на {$status[$now_status_id]->name}");
460
+        $prefix = isset(App::$cur->ecommerce->config['orderPrefix']) ? $config = App::$cur->ecommerce->config['orderPrefix'] : '';
461
+        \App::$cur->users->AddUserActivity($cart->user_id, 3, "Статус вашего заказа номер {$prefix}{$cart->id} изменился с {$status[$prev_status_id]->name} на {$status[$now_status_id]->name}");
462 462
 
463
-      if ($cart->cart_status_id == 5) {
463
+        if ($cart->cart_status_id == 5) {
464 464
         Inji::$inst->event('ecommerceCartClosed', $cart);
465
-      }
465
+        }
466 466
     }
467 467
     return $cart;
468
-  }
468
+    }
469 469
 
470
-  public function cardTrigger($event) {
470
+    public function cardTrigger($event) {
471 471
     $cart = $event['eventObject'];
472 472
     if ($cart->card) {
473
-      $sum = 0;
474
-      foreach ($cart->cartItems as $cartItem) {
473
+        $sum = 0;
474
+        foreach ($cart->cartItems as $cartItem) {
475 475
         $sum += $cartItem->final_price * $cartItem->count;
476
-      }
477
-      $cardItemHistory = new Ecommerce\Card\Item\History();
478
-      $cardItemHistory->amount = $sum;
479
-      $cardItemHistory->card_item_id = $cart->card_item_id;
480
-      $cardItemHistory->save();
481
-      $cart->card->sum += $sum;
482
-      $cart->card->save();
476
+        }
477
+        $cardItemHistory = new Ecommerce\Card\Item\History();
478
+        $cardItemHistory->amount = $sum;
479
+        $cardItemHistory->card_item_id = $cart->card_item_id;
480
+        $cardItemHistory->save();
481
+        $cart->card->sum += $sum;
482
+        $cart->card->save();
483 483
     }
484 484
     return $cart;
485
-  }
485
+    }
486 486
 
487
-  public function bonusTrigger($event) {
487
+    public function bonusTrigger($event) {
488 488
     $cart = $event['eventObject'];
489 489
     foreach ($cart->cartItems as $cartItem) {
490
-      foreach ($cartItem->price->offer->bonuses as $bonus) {
490
+        foreach ($cartItem->price->offer->bonuses as $bonus) {
491 491
         if ($bonus->limited && $bonus->left <= 0) {
492
-          continue;
492
+            continue;
493 493
         } elseif ($bonus->limited && $bonus->left > 0) {
494
-          $bonus->left -= 1;
495
-          $bonus->save();
494
+            $bonus->left -= 1;
495
+            $bonus->save();
496 496
         }
497 497
         switch ($bonus->type) {
498
-          case'currency':
498
+            case'currency':
499 499
             $currency = \Money\Currency::get($bonus->value);
500 500
             $wallets = App::$cur->money->getUserWallets($cart->user->id);
501 501
             $wallets[$currency->id]->diff($bonus->count, 'Бонус за покупку');
502 502
             break;
503 503
         }
504
-      }
504
+        }
505 505
     }
506 506
     return $cart;
507
-  }
507
+    }
508 508
 
509
-  function sitemap() {
509
+    function sitemap() {
510 510
     $map = [];
511 511
     $zeroItems = \Ecommerce\Item::getList(['where' => ['category_id', 0]]);
512 512
     foreach ($zeroItems as $item) {
513
-      $map[] = [
514
-          'name' => $item->name,
515
-          'url' => [
516
-              'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
517
-          ],
518
-      ];
513
+        $map[] = [
514
+            'name' => $item->name,
515
+            'url' => [
516
+                'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
517
+            ],
518
+        ];
519 519
     }
520 520
 
521 521
     $categorys = \Ecommerce\Category::getList(['where' => ['parent_id', 0]]);
522 522
     $scan = function($category, $scan) {
523
-      $map = [];
523
+        $map = [];
524 524
 
525
-      foreach ($category->items as $item) {
525
+        foreach ($category->items as $item) {
526 526
         $map[] = [
527 527
             'name' => $item->name,
528 528
             'url' => [
529 529
                 'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
530 530
             ],
531 531
         ];
532
-      }
533
-      foreach ($category->catalogs as $child) {
532
+        }
533
+        foreach ($category->catalogs as $child) {
534 534
         $map = array_merge($map, $scan($child, $scan));
535
-      }
536
-      return $map;
535
+        }
536
+        return $map;
537 537
     };
538 538
     foreach ($categorys as $category) {
539
-      $map = array_merge($map, $scan($category, $scan));
539
+        $map = array_merge($map, $scan($category, $scan));
540 540
     }
541 541
     return $map;
542
-  }
542
+    }
543 543
 
544 544
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     $name = '';
49 49
     foreach ($fields as $field) {
50 50
       if ($field->save && !empty($data[$field->id])) {
51
-        $name .= htmlspecialchars($data[$field->id]) . ' ';
51
+        $name .= htmlspecialchars($data[$field->id]).' ';
52 52
       }
53 53
     }
54 54
     $name = trim($name);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     $name = '';
105 105
     foreach ($fields as $field) {
106 106
       if ($field->save && !empty($data[$field->id])) {
107
-        $name .= htmlspecialchars($data[$field->id]) . ' ';
107
+        $name .= htmlspecialchars($data[$field->id]).' ';
108 108
       }
109 109
     }
110 110
     $name = trim($name);
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
       foreach ($options['sort'] as $col => $direction) {
190 190
         switch ($col) {
191 191
           case 'price':
192
-            $selectOptions['order'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
192
+            $selectOptions['order'][] = [Ecommerce\Item\Offer\Price::colPrefix().'price', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
193 193
             break;
194 194
           case 'name':
195 195
             $selectOptions['order'][] = ['name', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
@@ -208,22 +208,22 @@  discard block
 block discarded – undo
208 208
       $selectOptions['where'][] = ['image_file_id', 0, '!='];
209 209
     }
210 210
 
211
-    $selectOptions['join'][] = [Ecommerce\Item\Offer::table(), Ecommerce\Item::index() . ' = ' . Ecommerce\Item\Offer::colPrefix() . Ecommerce\Item::index(), 'inner'];
211
+    $selectOptions['join'][] = [Ecommerce\Item\Offer::table(), Ecommerce\Item::index().' = '.Ecommerce\Item\Offer::colPrefix().Ecommerce\Item::index(), 'inner'];
212 212
 
213 213
     $selectOptions['join'][] = [Ecommerce\Item\Offer\Price::table(),
214
-        Ecommerce\Item\Offer::index() . ' = ' . Ecommerce\Item\Offer\Price::colPrefix() . Ecommerce\Item\Offer::index() .
215
-        (empty($this->config['show_zero_price']) ? ' and ' . Ecommerce\Item\Offer\Price::colPrefix() . 'price>0' : ''),
214
+        Ecommerce\Item\Offer::index().' = '.Ecommerce\Item\Offer\Price::colPrefix().Ecommerce\Item\Offer::index().
215
+        (empty($this->config['show_zero_price']) ? ' and '.Ecommerce\Item\Offer\Price::colPrefix().'price>0' : ''),
216 216
         empty($this->config['show_without_price']) ? 'inner' : 'left'];
217 217
 
218 218
     $selectOptions['join'][] = [
219
-        Ecommerce\Item\Offer\Price\Type::table(), Ecommerce\Item\Offer\Price::colPrefix() . Ecommerce\Item\Offer\Price\Type::index() . ' = ' . Ecommerce\Item\Offer\Price\Type::index()
219
+        Ecommerce\Item\Offer\Price\Type::table(), Ecommerce\Item\Offer\Price::colPrefix().Ecommerce\Item\Offer\Price\Type::index().' = '.Ecommerce\Item\Offer\Price\Type::index()
220 220
     ];
221 221
 
222 222
     $selectOptions['where'][] = [
223 223
         [Ecommerce\Item\Offer\Price\Type::index(), NULL, 'is'],
224 224
         [
225
-            [Ecommerce\Item\Offer\Price\Type::colPrefix() . 'roles', '', '=', 'OR'],
226
-            [Ecommerce\Item\Offer\Price\Type::colPrefix() . 'roles', '%|' . \Users\User::$cur->role_id . '|%', 'LIKE', 'OR'],
225
+            [Ecommerce\Item\Offer\Price\Type::colPrefix().'roles', '', '=', 'OR'],
226
+            [Ecommerce\Item\Offer\Price\Type::colPrefix().'roles', '%|'.\Users\User::$cur->role_id.'|%', 'LIKE', 'OR'],
227 227
         ],
228 228
     ];
229 229
 
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
     if (!empty($this->config['view_filter'])) {
232 232
       if (!empty($this->config['view_filter']['options'])) {
233 233
         foreach ($this->config['view_filter']['options'] as $optionId => $optionValue) {
234
-          $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' .
235
-              'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' = "' . (int) $optionId . '" AND ' .
236
-              'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . 'value = "' . (int) $optionValue . '"',
237
-              'inner', 'option' . $optionId];
234
+          $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index().' = '.'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().Ecommerce\Item::index().' AND '.
235
+              'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().Ecommerce\Item\Option::index().' = "'.(int) $optionId.'" AND '.
236
+              'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().'value = "'.(int) $optionValue.'"',
237
+              'inner', 'option'.$optionId];
238 238
         }
239 239
       }
240 240
     }
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
         switch ($col) {
245 245
           case 'price':
246 246
             if (!empty($filter['min'])) {
247
-              $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', (float) $filter['min'], '>='];
247
+              $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix().'price', (float) $filter['min'], '>='];
248 248
             }
249 249
             if (!empty($filter['max'])) {
250
-              $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', (float) $filter['max'], '<='];
250
+              $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix().'price', (float) $filter['max'], '<='];
251 251
             }
252 252
             break;
253 253
           case 'options':
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
                 foreach ($optionValue as $val) {
259 259
                   $optionValueArr[] = \App::$cur->db->connection->pdo->quote($val);
260 260
                 }
261
-                $qstr = 'IN (' . implode(',', $optionValueArr) . ')';
261
+                $qstr = 'IN ('.implode(',', $optionValueArr).')';
262 262
               } else {
263
-                $qstr = '= ' . \App::$cur->db->connection->pdo->quote($optionValue);
263
+                $qstr = '= '.\App::$cur->db->connection->pdo->quote($optionValue);
264 264
               }
265
-              $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' .
266
-                  'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' = "' . (int) $optionId . '" AND ' .
267
-                  'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . 'value ' . $qstr . '',
268
-                  'inner', 'option' . $optionId];
265
+              $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index().' = '.'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().Ecommerce\Item::index().' AND '.
266
+                  'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().Ecommerce\Item\Option::index().' = "'.(int) $optionId.'" AND '.
267
+                  'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().'value '.$qstr.'',
268
+                  'inner', 'option'.$optionId];
269 269
             }
270 270
             break;
271 271
           case 'offerOptions':
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
                 foreach ($optionValue as $val) {
278 278
                   $optionValueArr[] = \App::$cur->db->connection->pdo->quote($val);
279 279
                 }
280
-                $qstr = 'IN (' . implode(',', $optionValueArr) . ')';
280
+                $qstr = 'IN ('.implode(',', $optionValueArr).')';
281 281
               } else {
282
-                $qstr = '= ' . \App::$cur->db->connection->pdo->quote($optionValue);
282
+                $qstr = '= '.\App::$cur->db->connection->pdo->quote($optionValue);
283 283
               }
284
-              $selectOptions['join'][] = [Ecommerce\Item\Offer\Param::table(), Ecommerce\Item\Offer::index() . ' = ' . 'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . Ecommerce\Item\Offer::index() . ' AND ' .
285
-                  'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . Ecommerce\Item\Offer\Option::index() . ' = "' . (int) $optionId . '" AND ' .
286
-                  'offerOption' . $optionId . '.' . Ecommerce\Item\Offer\Param::colPrefix() . 'value ' . $qstr,
287
-                  'inner', 'offerOption' . $optionId];
284
+              $selectOptions['join'][] = [Ecommerce\Item\Offer\Param::table(), Ecommerce\Item\Offer::index().' = '.'offerOption'.$optionId.'.'.Ecommerce\Item\Offer\Param::colPrefix().Ecommerce\Item\Offer::index().' AND '.
285
+                  'offerOption'.$optionId.'.'.Ecommerce\Item\Offer\Param::colPrefix().Ecommerce\Item\Offer\Option::index().' = "'.(int) $optionId.'" AND '.
286
+                  'offerOption'.$optionId.'.'.Ecommerce\Item\Offer\Param::colPrefix().'value '.$qstr,
287
+                  'inner', 'offerOption'.$optionId];
288 288
             }
289 289
             break;
290 290
         }
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
           continue;
300 300
         }
301 301
         $category = \Ecommerce\Category::get($categoryId);
302
-        $where[] = ['tree_path', $category->tree_path . (int) $categoryId . '/%', 'LIKE', $first ? 'AND' : 'OR'];
302
+        $where[] = ['tree_path', $category->tree_path.(int) $categoryId.'/%', 'LIKE', $first ? 'AND' : 'OR'];
303 303
         $first = false;
304 304
       }
305 305
       $selectOptions['where'][] = $where;
306 306
     } elseif (!empty($options['parent'])) {
307 307
       $category = \Ecommerce\Category::get($options['parent']);
308
-      $selectOptions['where'][] = ['tree_path', $category->tree_path . (int) $options['parent'] . '/%', 'LIKE'];
308
+      $selectOptions['where'][] = ['tree_path', $category->tree_path.(int) $options['parent'].'/%', 'LIKE'];
309 309
     }
310 310
 
311 311
     //search
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
       foreach (explode(' ', $searchStr) as $part) {
316 316
         $part = trim($part);
317 317
         if ($part && strlen($part) > 2) {
318
-          $searchArr[] = ['search_index', '%' . $part . '%', 'LIKE'];
318
+          $searchArr[] = ['search_index', '%'.$part.'%', 'LIKE'];
319 319
         }
320 320
       }
321 321
       if (!empty($searchArr)) {
@@ -334,19 +334,19 @@  discard block
 block discarded – undo
334 334
       }
335 335
       $selectOptions['where'][] = [
336 336
           '(
337
-          (SELECT COALESCE(sum(`' . \Ecommerce\Item\Offer\Warehouse::colPrefix() . 'count`),0) 
338
-            FROM ' . \App::$cur->db->table_prefix . \Ecommerce\Item\Offer\Warehouse::table() . ' iciw 
339
-            WHERE iciw.' . \Ecommerce\Item\Offer\Warehouse::colPrefix() . \Ecommerce\Item\Offer::index() . ' = ' . \Ecommerce\Item\Offer::index() . '
340
-                ' . ($warehouseIds ? ' AND iciw.' . \Ecommerce\Item\Offer\Warehouse::colPrefix() . \Ecommerce\Warehouse::index() . ' IN(' . implode(',', $warehouseIds) . ')' : '') . '
337
+          (SELECT COALESCE(sum(`' . \Ecommerce\Item\Offer\Warehouse::colPrefix().'count`),0) 
338
+            FROM ' . \App::$cur->db->table_prefix.\Ecommerce\Item\Offer\Warehouse::table().' iciw 
339
+            WHERE iciw.' . \Ecommerce\Item\Offer\Warehouse::colPrefix().\Ecommerce\Item\Offer::index().' = '.\Ecommerce\Item\Offer::index().'
340
+                ' . ($warehouseIds ? ' AND iciw.'.\Ecommerce\Item\Offer\Warehouse::colPrefix().\Ecommerce\Warehouse::index().' IN('.implode(',', $warehouseIds).')' : '').'
341 341
             )
342 342
           -
343
-          (SELECT COALESCE(sum(' . \Ecommerce\Warehouse\Block::colPrefix() . 'count) ,0)
344
-            FROM ' . \App::$cur->db->table_prefix . \Ecommerce\Warehouse\Block::table() . ' iewb
345
-            inner JOIN ' . \App::$cur->db->table_prefix . \Ecommerce\Cart::table() . ' icc ON icc.' . \Ecommerce\Cart::index() . ' = iewb.' . \Ecommerce\Warehouse\Block::colPrefix() . \Ecommerce\Cart::index() . ' AND (
346
-                (`' . \Ecommerce\Cart::colPrefix() . 'warehouse_block` = 1 and `' . \Ecommerce\Cart::colPrefix() . 'cart_status_id` in(2,3,6)) ||
347
-                (`' . \Ecommerce\Cart::colPrefix() . \Ecommerce\Cart\Status::index() . '` in(0,1) and `' . \Ecommerce\Cart::colPrefix() . 'date_last_activ` >=subdate(now(),INTERVAL 30 MINUTE))
343
+          (SELECT COALESCE(sum(' . \Ecommerce\Warehouse\Block::colPrefix().'count) ,0)
344
+            FROM ' . \App::$cur->db->table_prefix.\Ecommerce\Warehouse\Block::table().' iewb
345
+            inner JOIN ' . \App::$cur->db->table_prefix.\Ecommerce\Cart::table().' icc ON icc.'.\Ecommerce\Cart::index().' = iewb.'.\Ecommerce\Warehouse\Block::colPrefix().\Ecommerce\Cart::index().' AND (
346
+                (`' . \Ecommerce\Cart::colPrefix().'warehouse_block` = 1 and `'.\Ecommerce\Cart::colPrefix().'cart_status_id` in(2,3,6)) ||
347
+                (`' . \Ecommerce\Cart::colPrefix().\Ecommerce\Cart\Status::index().'` in(0,1) and `'.\Ecommerce\Cart::colPrefix().'date_last_activ` >=subdate(now(),INTERVAL 30 MINUTE))
348 348
             )
349
-            WHERE iewb.' . \Ecommerce\Warehouse\Block::colPrefix() . \Ecommerce\Item\Offer::index() . ' = ' . \Ecommerce\Item\Offer::index() . ')
349
+            WHERE iewb.' . \Ecommerce\Warehouse\Block::colPrefix().\Ecommerce\Item\Offer::index().' = '.\Ecommerce\Item\Offer::index().')
350 350
           )',
351 351
           0,
352 352
           '>'
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
     $items = Ecommerce\Item::getList($selectOptions);
375 375
     $items = Ecommerce\Item\Param::getList([
376 376
                 'where' => ['item_id', array_keys($items), 'IN'],
377
-                'join' => [[Ecommerce\Item\Option::table(), Ecommerce\Item\Option::index() . ' = ' . \Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' and ' . \Ecommerce\Item\Option::colPrefix() . 'searchable = 1', 'inner']],
377
+                'join' => [[Ecommerce\Item\Option::table(), Ecommerce\Item\Option::index().' = '.\Ecommerce\Item\Param::colPrefix().Ecommerce\Item\Option::index().' and '.\Ecommerce\Item\Option::colPrefix().'searchable = 1', 'inner']],
378 378
                 'distinct' => \Ecommerce\Item\Option::index()
379 379
     ]);
380 380
     return $items;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
     if (is_array($counts)) {
406 406
       $sum = 0;
407 407
       foreach ($counts as $count) {
408
-        $sum +=$count['count'];
408
+        $sum += $count['count'];
409 409
       }
410 410
       return $sum;
411 411
     }
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 
440 440
     if (!empty($conf['files']['aditionTemplateFiels'])) {
441 441
       foreach ($conf['files']['aditionTemplateFiels'] as $file) {
442
-        $return[$file['file']] = '- ' . $file['name'];
442
+        $return[$file['file']] = '- '.$file['name'];
443 443
       }
444 444
     }
445 445
     return $return;
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
       $map[] = [
514 514
           'name' => $item->name,
515 515
           'url' => [
516
-              'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
516
+              'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http').'://'.INJI_DOMAIN_NAME.($item->getHref())
517 517
           ],
518 518
       ];
519 519
     }
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         $map[] = [
527 527
             'name' => $item->name,
528 528
             'url' => [
529
-                'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . INJI_DOMAIN_NAME . ($item->getHref())
529
+                'loc' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http').'://'.INJI_DOMAIN_NAME.($item->getHref())
530 530
             ],
531 531
         ];
532 532
       }
Please login to merge, or discard this patch.