Completed
Push — master ( 0fc305...2f7f6c )
by Alexey
06:05
created
system/modules/Ecommerce/Ecommerce.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         $name = '';
53 53
         foreach ($fields as $field) {
54 54
             if ($field->save && !empty($data[$field->id])) {
55
-                $name .= htmlspecialchars($data[$field->id]) . ' ';
55
+                $name .= htmlspecialchars($data[$field->id]).' ';
56 56
             }
57 57
         }
58 58
         $name = trim($name);
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         $name = '';
110 110
         foreach ($fields as $field) {
111 111
             if ($field->save && !empty($data[$field->id])) {
112
-                $name .= htmlspecialchars($data[$field->id]) . ' ';
112
+                $name .= htmlspecialchars($data[$field->id]).' ';
113 113
             }
114 114
         }
115 115
         $name = trim($name);
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             foreach ($options['sort'] as $col => $direction) {
197 197
                 switch ($col) {
198 198
                     case 'price':
199
-                        $selectOptions['order'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
199
+                        $selectOptions['order'][] = [Ecommerce\Item\Offer\Price::colPrefix().'price', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
200 200
                         break;
201 201
                     case 'name':
202 202
                         $selectOptions['order'][] = ['name', strtolower($direction) == 'desc' ? 'desc' : 'asc'];
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
         if (!empty($this->config['view_filter'])) {
218 218
             if (!empty($this->config['view_filter']['options'])) {
219 219
                 foreach ($this->config['view_filter']['options'] as $optionId => $optionValue) {
220
-                    $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' .
221
-                        'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' = "' . (int) $optionId . '" AND ' .
222
-                        'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . 'value = "' . (int) $optionValue . '"',
223
-                        'inner', 'option' . $optionId];
220
+                    $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index().' = '.'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().Ecommerce\Item::index().' AND '.
221
+                        'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().Ecommerce\Item\Option::index().' = "'.(int) $optionId.'" AND '.
222
+                        'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().'value = "'.(int) $optionValue.'"',
223
+                        'inner', 'option'.$optionId];
224 224
                 }
225 225
             }
226 226
         }
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
                 switch ($col) {
231 231
                     case 'price':
232 232
                         if (!empty($filter['min'])) {
233
-                            $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', (float) $filter['min'], '>='];
233
+                            $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix().'price', (float) $filter['min'], '>='];
234 234
                         }
235 235
                         if (!empty($filter['max'])) {
236
-                            $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix() . 'price', (float) $filter['max'], '<='];
236
+                            $selectOptions['where'][] = [Ecommerce\Item\Offer\Price::colPrefix().'price', (float) $filter['max'], '<='];
237 237
                         }
238 238
                         break;
239 239
                     case 'options':
240 240
                         foreach ($filter as $optionId => $optionValue) {
241
-                            $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index() . ' = ' . 'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item::index() . ' AND ' .
242
-                                'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . Ecommerce\Item\Option::index() . ' = "' . (int) $optionId . '" AND ' .
243
-                                'option' . $optionId . '.' . Ecommerce\Item\Param::colPrefix() . 'value = "' . (int) $optionValue . '"',
244
-                                'inner', 'option' . $optionId];
241
+                            $selectOptions['join'][] = [Ecommerce\Item\Param::table(), Ecommerce\Item::index().' = '.'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().Ecommerce\Item::index().' AND '.
242
+                                'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().Ecommerce\Item\Option::index().' = "'.(int) $optionId.'" AND '.
243
+                                'option'.$optionId.'.'.Ecommerce\Item\Param::colPrefix().'value = "'.(int) $optionValue.'"',
244
+                                'inner', 'option'.$optionId];
245 245
                         }
246 246
                         break;
247 247
                 }
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
                     continue;
257 257
                 }
258 258
                 $category = \Ecommerce\Category::get($categoryId);
259
-                $where[] = ['tree_path', $category->tree_path . (int) $categoryId . '/%', 'LIKE', $first ? 'AND' : 'OR'];
259
+                $where[] = ['tree_path', $category->tree_path.(int) $categoryId.'/%', 'LIKE', $first ? 'AND' : 'OR'];
260 260
                 $first = false;
261 261
             }
262 262
             $selectOptions['where'][] = $where;
263 263
         } elseif (!empty($options['parent'])) {
264 264
             $category = \Ecommerce\Category::get($options['parent']);
265
-            $selectOptions['where'][] = ['tree_path', $category->tree_path . (int) $options['parent'] . '/%', 'LIKE'];
265
+            $selectOptions['where'][] = ['tree_path', $category->tree_path.(int) $options['parent'].'/%', 'LIKE'];
266 266
         }
267 267
 
268 268
         //search
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             foreach (explode(' ', $searchStr) as $part) {
273 273
                 $part = trim($part);
274 274
                 if ($part && strlen($part) > 2) {
275
-                    $searchArr[] = ['search_index', '%' . $part . '%', 'LIKE'];
275
+                    $searchArr[] = ['search_index', '%'.$part.'%', 'LIKE'];
276 276
                 }
277 277
             }
278 278
             if (!empty($searchArr)) {
@@ -291,19 +291,19 @@  discard block
 block discarded – undo
291 291
             }
292 292
             $selectOptions['where'][] = [
293 293
                 '(
294
-          (SELECT COALESCE(sum(`' . \Ecommerce\Item\Offer\Warehouse::colPrefix() . 'count`),0) 
295
-            FROM ' . \App::$cur->db->table_prefix . \Ecommerce\Item\Offer\Warehouse::table() . ' iciw 
296
-            WHERE iciw.' . \Ecommerce\Item\Offer\Warehouse::colPrefix() . \Ecommerce\Item\Offer::index() . ' = ' . \Ecommerce\Item\Offer::index() . '
297
-                ' . ($warehouseIds ? ' AND iciw.' . \Ecommerce\Item\Offer\Warehouse::colPrefix() . \Ecommerce\Warehouse::index() . ' IN(' . implode(',', $warehouseIds) . ')' : '') . '
294
+          (SELECT COALESCE(sum(`' . \Ecommerce\Item\Offer\Warehouse::colPrefix().'count`),0) 
295
+            FROM ' . \App::$cur->db->table_prefix.\Ecommerce\Item\Offer\Warehouse::table().' iciw 
296
+            WHERE iciw.' . \Ecommerce\Item\Offer\Warehouse::colPrefix().\Ecommerce\Item\Offer::index().' = '.\Ecommerce\Item\Offer::index().'
297
+                ' . ($warehouseIds ? ' AND iciw.'.\Ecommerce\Item\Offer\Warehouse::colPrefix().\Ecommerce\Warehouse::index().' IN('.implode(',', $warehouseIds).')' : '').'
298 298
             )
299 299
           -
300
-          (SELECT COALESCE(sum(' . \Ecommerce\Warehouse\Block::colPrefix() . 'count) ,0)
301
-            FROM ' . \App::$cur->db->table_prefix . \Ecommerce\Warehouse\Block::table() . ' iewb
302
-            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 (
303
-                (`' . \Ecommerce\Cart::colPrefix() . 'warehouse_block` = 1 and `' . \Ecommerce\Cart::colPrefix() . 'cart_status_id` in(2,3,6)) ||
304
-                (`' . \Ecommerce\Cart::colPrefix() . \Ecommerce\Cart\Status::index() . '` in(0,1) and `' . \Ecommerce\Cart::colPrefix() . 'date_last_activ` >=subdate(now(),INTERVAL 30 MINUTE))
300
+          (SELECT COALESCE(sum(' . \Ecommerce\Warehouse\Block::colPrefix().'count) ,0)
301
+            FROM ' . \App::$cur->db->table_prefix.\Ecommerce\Warehouse\Block::table().' iewb
302
+            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 (
303
+                (`' . \Ecommerce\Cart::colPrefix().'warehouse_block` = 1 and `'.\Ecommerce\Cart::colPrefix().'cart_status_id` in(2,3,6)) ||
304
+                (`' . \Ecommerce\Cart::colPrefix().\Ecommerce\Cart\Status::index().'` in(0,1) and `'.\Ecommerce\Cart::colPrefix().'date_last_activ` >=subdate(now(),INTERVAL 30 MINUTE))
305 305
             )
306
-            WHERE iewb.' . \Ecommerce\Warehouse\Block::colPrefix() . \Ecommerce\Item\Offer::index() . ' = ' . \Ecommerce\Item\Offer::index() . ')
306
+            WHERE iewb.' . \Ecommerce\Warehouse\Block::colPrefix().\Ecommerce\Item\Offer::index().' = '.\Ecommerce\Item\Offer::index().')
307 307
           )',
308 308
                 0,
309 309
                 '>'
@@ -311,22 +311,22 @@  discard block
 block discarded – undo
311 311
         }
312 312
 
313 313
 
314
-        $selectOptions['join'][] = [Ecommerce\Item\Offer::table(), Ecommerce\Item::index() . ' = ' . Ecommerce\Item\Offer::colPrefix() . Ecommerce\Item::index(), 'inner'];
314
+        $selectOptions['join'][] = [Ecommerce\Item\Offer::table(), Ecommerce\Item::index().' = '.Ecommerce\Item\Offer::colPrefix().Ecommerce\Item::index(), 'inner'];
315 315
 
316 316
         $selectOptions['join'][] = [Ecommerce\Item\Offer\Price::table(),
317
-            Ecommerce\Item\Offer::index() . ' = ' . Ecommerce\Item\Offer\Price::colPrefix() . Ecommerce\Item\Offer::index() .
318
-            (empty($this->config['show_zero_price']) ? ' and ' . Ecommerce\Item\Offer\Price::colPrefix() . 'price>0' : ''),
317
+            Ecommerce\Item\Offer::index().' = '.Ecommerce\Item\Offer\Price::colPrefix().Ecommerce\Item\Offer::index().
318
+            (empty($this->config['show_zero_price']) ? ' and '.Ecommerce\Item\Offer\Price::colPrefix().'price>0' : ''),
319 319
             empty($this->config['show_without_price']) ? 'inner' : 'left'];
320 320
 
321 321
         $selectOptions['join'][] = [
322
-            Ecommerce\Item\Offer\Price\Type::table(), Ecommerce\Item\Offer\Price::colPrefix() . Ecommerce\Item\Offer\Price\Type::index() . ' = ' . Ecommerce\Item\Offer\Price\Type::index()
322
+            Ecommerce\Item\Offer\Price\Type::table(), Ecommerce\Item\Offer\Price::colPrefix().Ecommerce\Item\Offer\Price\Type::index().' = '.Ecommerce\Item\Offer\Price\Type::index()
323 323
         ];
324 324
 
325 325
         $selectOptions['where'][] = [
326 326
             [Ecommerce\Item\Offer\Price\Type::index(), NULL, 'is'],
327 327
             [
328
-                [Ecommerce\Item\Offer\Price\Type::colPrefix() . 'roles', '', '=', 'OR'],
329
-                [Ecommerce\Item\Offer\Price\Type::colPrefix() . 'roles', '%|' . \Users\User::$cur->role_id . '|%', 'LIKE', 'OR'],
328
+                [Ecommerce\Item\Offer\Price\Type::colPrefix().'roles', '', '=', 'OR'],
329
+                [Ecommerce\Item\Offer\Price\Type::colPrefix().'roles', '%|'.\Users\User::$cur->role_id.'|%', 'LIKE', 'OR'],
330 330
             ],   
331 331
         ];
332 332
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         $items = Ecommerce\Item::getList($selectOptions);
350 350
         $items = Ecommerce\Item\Param::getList([
351 351
                     'where' => ['item_id', array_keys($items), 'IN'],
352
-                    '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']],
352
+                    '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']],
353 353
                     'distinct' => \Ecommerce\Item\Option::index()
354 354
         ]);
355 355
         return $items;
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         if (is_array($counts)) {
383 383
             $sum = 0;
384 384
             foreach ($counts as $count) {
385
-                $sum +=$count['count'];
385
+                $sum += $count['count'];
386 386
             }
387 387
             return $sum;
388 388
         }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 
419 419
         if (!empty($conf['files']['aditionTemplateFiels'])) {
420 420
             foreach ($conf['files']['aditionTemplateFiels'] as $file) {
421
-                $return[$file['file']] = '- ' . $file['name'];
421
+                $return[$file['file']] = '- '.$file['name'];
422 422
             }
423 423
         }
424 424
         return $return;
Please login to merge, or discard this patch.