Completed
Push — master ( 8e3681...c9e152 )
by Alexey
04:35
created
system/modules/Exchange1c/objects/Parser/Item/Images.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -13,40 +13,40 @@  discard block
 block discarded – undo
13 13
 
14 14
 class Images extends \Migrations\Parser {
15 15
 
16
-  public function parse() {
16
+    public function parse() {
17 17
     if (is_null($this->data)) {
18
-      return;
18
+        return;
19 19
     }
20 20
     $value = $this->data;
21 21
     if (!is_array($value)) {
22
-      $value = [$value];
22
+        $value = [$value];
23 23
     }
24 24
     $ids = [];
25 25
     $dir = pathinfo($this->object->walker->migtarionLog->source, PATHINFO_DIRNAME);
26 26
     $this->model->image_file_id = 0;
27 27
     foreach ($value as $key => $imagePath) {
28
-      if (!$imagePath || !file_exists($dir . '/' . $imagePath)) {
28
+        if (!$imagePath || !file_exists($dir . '/' . $imagePath)) {
29 29
         continue;
30
-      }
31
-      $notEq = true;
32
-      $md5Cur = md5_file($dir . '/' . $imagePath);
33
-      foreach ($this->model->images as $imageId => $image) {
30
+        }
31
+        $notEq = true;
32
+        $md5Cur = md5_file($dir . '/' . $imagePath);
33
+        foreach ($this->model->images as $imageId => $image) {
34 34
         $file = $image->file;
35 35
         $md5File = '';
36 36
         if ($file->md5) {
37
-          $md5File = $file->md5;
37
+            $md5File = $file->md5;
38 38
         } elseif (file_exists($file->getRealPath())) {
39
-          $md5File = $file->md5 = md5_file($file->getRealPath());
40
-          $file->save();
39
+            $md5File = $file->md5 = md5_file($file->getRealPath());
40
+            $file->save();
41 41
         }
42 42
 
43 43
         if ($file && file_exists($file->getRealPath()) && $md5Cur == $md5File) {
44
-          $notEq = false;
45
-          $ids[] = $imageId;
46
-          break;
44
+            $notEq = false;
45
+            $ids[] = $imageId;
46
+            break;
47
+        }
47 48
         }
48
-      }
49
-      if ($notEq) {
49
+        if ($notEq) {
50 50
         $file_id = \App::$primary->files->uploadFromUrl($dir . '/' . $imagePath, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']);
51 51
         $image = new \Ecommerce\Item\Image([
52 52
             'item_id' => $this->model->pk(),
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
         ]);
55 55
         $image->save();
56 56
         $ids[] = $image->id;
57
-      } else {
57
+        } else {
58 58
         $image->weight = $key;
59
-      }
60
-      if ($image && !$this->model->image_file_id) {
59
+        }
60
+        if ($image && !$this->model->image_file_id) {
61 61
         $this->model->image_file_id = $image->file_id;
62
-      }
62
+        }
63 63
     }
64 64
     foreach ($this->model->images as $imageId => $image) {
65
-      if (!in_array($imageId, $ids)) {
65
+        if (!in_array($imageId, $ids)) {
66 66
         $image->delete();
67
-      }
67
+        }
68
+    }
68 69
     }
69
-  }
70 70
 
71 71
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
     $dir = pathinfo($this->object->walker->migtarionLog->source, PATHINFO_DIRNAME);
26 26
     $this->model->image_file_id = 0;
27 27
     foreach ($value as $key => $imagePath) {
28
-      if (!$imagePath || !file_exists($dir . '/' . $imagePath)) {
28
+      if (!$imagePath || !file_exists($dir.'/'.$imagePath)) {
29 29
         continue;
30 30
       }
31 31
       $notEq = true;
32
-      $md5Cur = md5_file($dir . '/' . $imagePath);
32
+      $md5Cur = md5_file($dir.'/'.$imagePath);
33 33
       foreach ($this->model->images as $imageId => $image) {
34 34
         $file = $image->file;
35 35
         $md5File = '';
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         }
48 48
       }
49 49
       if ($notEq) {
50
-        $file_id = \App::$primary->files->uploadFromUrl($dir . '/' . $imagePath, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']);
50
+        $file_id = \App::$primary->files->uploadFromUrl($dir.'/'.$imagePath, ['accept_group' => 'image', 'upload_code' => 'MigrationUpload']);
51 51
         $image = new \Ecommerce\Item\Image([
52 52
             'item_id' => $this->model->pk(),
53 53
             'file_id' => $file_id
Please login to merge, or discard this patch.
system/modules/Ecommerce/appControllers/CartController.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -10,145 +10,145 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class CartController extends Controller {
12 12
 
13
-  public function indexAction() {
13
+    public function indexAction() {
14 14
     $cart = '';
15 15
     $deliverys = \Ecommerce\Delivery::getList(['order' => ['weight', 'ASC']]);
16 16
     $payTypes = \Ecommerce\PayType::getList(['order' => ['weight', 'ASC']]);
17 17
     if (!empty($_SESSION['cart']['cart_id'])) {
18
-      $cart = Ecommerce\Cart::get($_SESSION['cart']['cart_id']);
19
-      if (!empty($_POST)) {
18
+        $cart = Ecommerce\Cart::get($_SESSION['cart']['cart_id']);
19
+        if (!empty($_POST)) {
20 20
         $error = false;
21 21
         if (!Users\User::$cur->id) {
22
-          $user_id = $this->Users->registration($_POST, true);
23
-          if (!$user_id) {
22
+            $user_id = $this->Users->registration($_POST, true);
23
+            if (!$user_id) {
24 24
             $error = true;
25
-          } else {
25
+            } else {
26 26
             $user = Users\User::get($user_id);
27
-          }
27
+            }
28 28
         } else {
29
-          $user = Users\User::$cur;
29
+            $user = Users\User::$cur;
30 30
         }
31 31
         $ids = [];
32 32
         if (!empty($_POST['cartItems'])) {
33
-          foreach ($_POST['cartItems'] as $cartItemId => $cartItemCont) {
33
+            foreach ($_POST['cartItems'] as $cartItemId => $cartItemCont) {
34 34
             $cartItem = \Ecommerce\Cart\Item::get((int) $cartItemId);
35 35
             if (!$cartItem) {
36
-              continue;
36
+                continue;
37 37
             }
38 38
             if ($cartItem->cart_id != $cart->id) {
39
-              continue;
39
+                continue;
40 40
             }
41 41
             $count = (float) $cartItemCont;
42 42
             if ($count < 0.001) {
43
-              $count = 1;
43
+                $count = 1;
44 44
             }
45 45
             $cartItem->count = $count;
46 46
             $cartItem->save();
47 47
             $ids[] = $cartItemId;
48
-          }
48
+            }
49 49
         }
50 50
         foreach ($cart->cartItems as $cartItem) {
51
-          if (!in_array($cartItem->id, $ids)) {
51
+            if (!in_array($cartItem->id, $ids)) {
52 52
             $cartItem->delete();
53
-          }
53
+            }
54 54
         }
55 55
         $cart = Ecommerce\Cart::get($cart->id);
56 56
         if (!$cart->cartItems) {
57
-          Tools::redirect('/ecommerce', 'Ваша корзина пуста');
57
+            Tools::redirect('/ecommerce', 'Ваша корзина пуста');
58 58
         }
59 59
         if (empty($this->module->config['sell_over_warehouse'])) {
60
-          foreach ($cart->cartItems as $cartitem) {
60
+            foreach ($cart->cartItems as $cartitem) {
61 61
             $warecount = $cartitem->price->offer->warehouseCount($cart->id);
62 62
             if ($cartitem->count > $warecount) {
63
-              $error = true;
64
-              Msg::add('Вы заказали <b>' . $cartitem->item->name . '</b> больше чем есть на складе. на складе: <b>' . $warecount . '</b>', 'danger');
63
+                $error = true;
64
+                Msg::add('Вы заказали <b>' . $cartitem->item->name . '</b> больше чем есть на складе. на складе: <b>' . $warecount . '</b>', 'danger');
65
+            }
65 66
             }
66
-          }
67 67
         }
68 68
         if ($deliverys && empty($deliverys[$_POST['delivery']])) {
69
-          $error = 1;
70
-          Msg::add('Выберите способ доставки', 'danger');
69
+            $error = 1;
70
+            Msg::add('Выберите способ доставки', 'danger');
71 71
         } elseif ($deliverys && !empty($deliverys[$_POST['delivery']])) {
72
-          $cart->delivery_id = $_POST['delivery'];
73
-          foreach ($deliverys[$cart->delivery_id]->fields as $field) {
72
+            $cart->delivery_id = $_POST['delivery'];
73
+            foreach ($deliverys[$cart->delivery_id]->fields as $field) {
74 74
             if (empty($_POST['deliveryFields'][$field->id]) && $field->required) {
75
-              $error = 1;
76
-              Msg::add('Вы не указали: ' . $field->name, 'danger');
75
+                $error = 1;
76
+                Msg::add('Вы не указали: ' . $field->name, 'danger');
77
+            }
77 78
             }
78
-          }
79 79
         }
80 80
         if ($payTypes && (empty($_POST['payType']) || empty($payTypes[$_POST['payType']]))) {
81
-          $error = 1;
82
-          Msg::add('Выберите способ оплаты', 'danger');
81
+            $error = 1;
82
+            Msg::add('Выберите способ оплаты', 'danger');
83 83
         } elseif ($payTypes && !empty($payTypes[$_POST['payType']])) {
84
-          $payType = $payTypes[$_POST['payType']];
85
-          $cart->paytype_id = $payType->id;
84
+            $payType = $payTypes[$_POST['payType']];
85
+            $cart->paytype_id = $payType->id;
86 86
         } else {
87
-          $payType = null;
87
+            $payType = null;
88 88
         }
89 89
         foreach (\Ecommerce\UserAdds\Field::getList() as $field) {
90
-          if (empty($_POST['userAdds']['fields'][$field->id]) && $field->required) {
90
+            if (empty($_POST['userAdds']['fields'][$field->id]) && $field->required) {
91 91
             $error = 1;
92 92
             Msg::add('Вы не указали: ' . $field->name, 'danger');
93
-          }
93
+            }
94 94
         }
95 95
         if (!empty($_POST['discounts']['card_item_id'])) {
96
-          $userCard = \Ecommerce\Card\Item::get((int) $_POST['discounts']['card_item_id']);
97
-          if (!$userCard) {
96
+            $userCard = \Ecommerce\Card\Item::get((int) $_POST['discounts']['card_item_id']);
97
+            if (!$userCard) {
98 98
             $error = true;
99 99
             Msg::add('Такой карты не существует', 'danger');
100
-          } elseif ($userCard->user_id != $user->id) {
100
+            } elseif ($userCard->user_id != $user->id) {
101 101
             $error = true;
102 102
             Msg::add('Это не ваша карта', 'danger');
103
-          } else {
103
+            } else {
104 104
             $cart->card_item_id = $userCard->id;
105
-          }
105
+            }
106 106
         }
107 107
         $cart->save();
108 108
         if (!$error && !empty($_POST['action']) && $_POST['action'] = 'order') {
109
-          $cart->user_id = $user->user_id;
110
-          $this->module->parseFields($_POST['userAdds']['fields'], $cart);
111
-          if ($payTypes && !empty($payTypes[$cart->paytype_id]) && !empty($_POST['deliveryFields'])) {
109
+            $cart->user_id = $user->user_id;
110
+            $this->module->parseFields($_POST['userAdds']['fields'], $cart);
111
+            if ($payTypes && !empty($payTypes[$cart->paytype_id]) && !empty($_POST['deliveryFields'])) {
112 112
             $this->module->parseDeliveryFields($_POST['deliveryFields'], $cart, $deliverys[$cart->delivery_id]->fields);
113
-          }
114
-          $cart->cart_status_id = 2;
115
-          $cart->comment = !empty($_POST['comment']) ? htmlspecialchars($_POST['comment']) : '';
116
-          $cart->date_status = date('Y-m-d H:i:s');
117
-          $cart->complete_data = date('Y-m-d H:i:s');
118
-          $cart->warehouse_block = 1;
119
-          $cart->save();
113
+            }
114
+            $cart->cart_status_id = 2;
115
+            $cart->comment = !empty($_POST['comment']) ? htmlspecialchars($_POST['comment']) : '';
116
+            $cart->date_status = date('Y-m-d H:i:s');
117
+            $cart->complete_data = date('Y-m-d H:i:s');
118
+            $cart->warehouse_block = 1;
119
+            $cart->save();
120 120
 
121
-          $cart = \Ecommerce\Cart::get($cart->id);
122
-          foreach ($cart->cartItems as $cartItem) {
121
+            $cart = \Ecommerce\Cart::get($cart->id);
122
+            foreach ($cart->cartItems as $cartItem) {
123 123
             $cartItem->discount = $cartItem->discount();
124 124
             $cartItem->final_price = $cartItem->price->price - $cartItem->discount;
125 125
             $cartItem->save();
126
-          }
127
-          $cart = \Ecommerce\Cart::get($cart->id);
128
-          if (!empty(\App::$cur->ecommerce->config['notify_mail'])) {
126
+            }
127
+            $cart = \Ecommerce\Cart::get($cart->id);
128
+            if (!empty(\App::$cur->ecommerce->config['notify_mail'])) {
129 129
             $text = 'Перейдите в админ панель чтобы просмотреть новый заказ <a href = "http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/admin/ecommerce/Cart">Админ панель</a>';
130 130
             $title = 'Новый заказ в интернет магазине на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME);
131 131
             \Tools::sendMail('noreply@' . INJI_DOMAIN_NAME, \App::$cur->ecommerce->config['notify_mail'], $title, $text);
132
-          }
133
-          if ($this->notifications) {
132
+            }
133
+            if ($this->notifications) {
134 134
             $notification = new Notifications\Notification();
135 135
             $notification->name = 'Новый заказ в интернет магазине на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME);
136 136
             $notification->text = 'Перейдите в админ панель чтобы просмотреть новый заказ';
137 137
             $notification->chanel_id = $this->notifications->getChanel('Ecommerce-orders')->id;
138 138
             $notification->save();
139
-          }
140
-          $handlers = $this->ecommerce->getSnippets('payTypeHandler');
141
-          $redirect = ['/ecommerce/cart/success'];
142
-          if ($payType && !empty($handlers[$payType->handler]['handler'])) {
139
+            }
140
+            $handlers = $this->ecommerce->getSnippets('payTypeHandler');
141
+            $redirect = ['/ecommerce/cart/success'];
142
+            if ($payType && !empty($handlers[$payType->handler]['handler'])) {
143 143
             $newRedirect = $handlers[$payType->handler]['handler']($cart);
144 144
             if (!empty($newRedirect)) {
145
-              $redirect = $newRedirect;
145
+                $redirect = $newRedirect;
146
+            }
146 147
             }
147
-          }
148
-          unset($_SESSION['cart']['cart_id']);
149
-          call_user_func_array(['Tools', 'redirect'], $redirect);
148
+            unset($_SESSION['cart']['cart_id']);
149
+            call_user_func_array(['Tools', 'redirect'], $redirect);
150
+        }
150 151
         }
151
-      }
152 152
     }
153 153
     $this->view->setTitle('Корзина');
154 154
     $bread = [];
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
         'href' => '/ecommerce/cart'
162 162
     ];
163 163
     $this->view->page(['data' => compact('cart', 'items', 'deliverys', 'payTypes', 'packItem', 'bread')]);
164
-  }
164
+    }
165 165
 
166
-  public function orderDetailAction($id = 0) {
166
+    public function orderDetailAction($id = 0) {
167 167
     $cart = Ecommerce\Cart::get((int) $id);
168 168
     if ($cart->user_id != Users\User::$cur->id) {
169
-      $this->url->redirect('/', 'Это не ваша корзина');
169
+        $this->url->redirect('/', 'Это не ваша корзина');
170 170
     }
171 171
     $bread[] = [
172 172
         'text' => 'Каталог',
@@ -182,54 +182,54 @@  discard block
 block discarded – undo
182 182
     ];
183 183
     $this->view->setTitle('Заказ №' . $cart->id);
184 184
     $this->view->page(['data' => compact('cart', 'bread')]);
185
-  }
185
+    }
186 186
 
187
-  public function continueAction($id = 0) {
187
+    public function continueAction($id = 0) {
188 188
     $cart = \Ecommerce\Cart::get((int) $id);
189 189
     if ($cart->user_id != Users\User::$cur->id) {
190
-      Tools::redirect('/', 'Это не ваша корзина');
190
+        Tools::redirect('/', 'Это не ваша корзина');
191 191
     }
192 192
     if ($cart->cart_status_id > 1) {
193
-      Tools::redirect('/', 'Корзина уже оформлена');
193
+        Tools::redirect('/', 'Корзина уже оформлена');
194 194
     }
195 195
     $_SESSION['cart']['cart_id'] = $cart->id;
196 196
     Tools::redirect('/ecommerce/cart');
197
-  }
197
+    }
198 198
 
199
-  public function deleteAction($id = 0) {
199
+    public function deleteAction($id = 0) {
200 200
     $cart = \Ecommerce\Cart::get((int) $id);
201 201
     if ($cart->user_id != Users\User::$cur->id) {
202
-      Tools::redirect('/', 'Это не ваша корзина');
202
+        Tools::redirect('/', 'Это не ваша корзина');
203 203
     }
204 204
     if ($cart->cart_status_id > 1) {
205
-      Tools::redirect('/', 'Корзина уже оформлена');
205
+        Tools::redirect('/', 'Корзина уже оформлена');
206 206
     }
207 207
     if (!empty($_SESSION['cart']['cart_id']) && $_SESSION['cart']['cart_id'] == $cart->id) {
208
-      unset($_SESSION['cart']['cart_id']);
208
+        unset($_SESSION['cart']['cart_id']);
209 209
     }
210 210
     $cart->delete();
211 211
     Tools::redirect('/users/cabinet/ecommerceOrdersHistory', 'Корзина была удалена', 'success');
212
-  }
212
+    }
213 213
 
214
-  public function refillAction($id = 0) {
214
+    public function refillAction($id = 0) {
215 215
     $cart = \Ecommerce\Cart::get((int) $id);
216 216
     if ($cart->user_id != Users\User::$cur->id) {
217
-      Tools::redirect('/', 'Это не ваша корзина');
217
+        Tools::redirect('/', 'Это не ваша корзина');
218 218
     }
219 219
     if (!empty($_SESSION['cart']['cart_id'])) {
220
-      unset($_SESSION['cart']['cart_id']);
220
+        unset($_SESSION['cart']['cart_id']);
221 221
     }
222 222
     $newCart = $this->ecommerce->getCurCart();
223 223
     foreach ($cart->cartItems as $cartitem) {
224
-      $newCart->addItem($cartitem->item_offer_price_id, $cartitem->count);
224
+        $newCart->addItem($cartitem->item_offer_price_id, $cartitem->count);
225 225
     }
226 226
 
227 227
     $newCart->save();
228 228
 
229 229
     Tools::redirect('/ecommerce/cart/');
230
-  }
230
+    }
231 231
 
232
-  public function successAction() {
232
+    public function successAction() {
233 233
     $bread = [];
234 234
     $bread[] = [
235 235
         'text' => 'Каталог',
@@ -245,70 +245,70 @@  discard block
 block discarded – undo
245 245
     ];
246 246
     $this->view->setTitle('Заказ принят');
247 247
     $this->view->page(['data' => compact('bread')]);
248
-  }
248
+    }
249 249
 
250
-  public function addAction() {
250
+    public function addAction() {
251 251
     $result = new Server\Result();
252 252
     if (empty($_GET['itemOfferPriceId'])) {
253
-      $result->success = false;
254
-      $result->content = 'Произошла непредвиденная ошибка при добавлении товара';
255
-      $result->send();
253
+        $result->success = false;
254
+        $result->content = 'Произошла непредвиденная ошибка при добавлении товара';
255
+        $result->send();
256 256
     }
257 257
     $price = \Ecommerce\Item\Offer\Price::get((int) $_GET['itemOfferPriceId']);
258 258
     if (!$price) {
259
-      $result->success = false;
260
-      $result->content = 'Такой цены не найдено';
261
-      $result->send();
259
+        $result->success = false;
260
+        $result->content = 'Такой цены не найдено';
261
+        $result->send();
262 262
     }
263 263
     $item = $price->offer->item;
264 264
 
265 265
     if (!$item) {
266
-      $result->success = false;
267
-      $result->content = 'Такого товара не существует';
268
-      $result->send();
266
+        $result->success = false;
267
+        $result->content = 'Такого товара не существует';
268
+        $result->send();
269 269
     }
270 270
 
271 271
     $item->sales ++;
272 272
     $item->save();
273 273
 
274 274
     if (empty($_GET['count']))
275
-      $count = 1;
275
+        $count = 1;
276 276
     else
277
-      $count = (float) $_GET['count'];
277
+        $count = (float) $_GET['count'];
278 278
 
279 279
     $cart = $this->ecommerce->getCurCart();
280 280
     $stages = Ecommerce\Cart\Stage::getList();
281 281
     if (empty($this->module->config['sell_over_warehouse']) && $price->offer->warehouseCount() < $count) {
282
-      $result->success = false;
283
-      $result->content = 'На складе недостаточно товара! Доступно: ' . $price->offer->warehouseCount();
284
-      $result->send();
282
+        $result->success = false;
283
+        $result->content = 'На складе недостаточно товара! Доступно: ' . $price->offer->warehouseCount();
284
+        $result->send();
285 285
     }
286 286
 
287 287
     $isset = false;
288 288
     foreach ($cart->cartItems as $cartItem) {
289
-      if ($cartItem->item_id == $item->id && $cartItem->item_offer_price_id == $price->id) {
289
+        if ($cartItem->item_id == $item->id && $cartItem->item_offer_price_id == $price->id) {
290 290
         $cartItem->count += $count;
291 291
         $cartItem->save();
292 292
         $isset = true;
293 293
         break;
294
-      }
294
+        }
295 295
     }
296 296
     if (!$isset) {
297
-      $cart->addItem($price->id, $count);
297
+        $cart->addItem($price->id, $count);
298 298
     }
299 299
     $cart->date_last_activ = date('Y-m-d H:i:s');
300 300
     $cart->calc();
301 301
     $result->successMsg = '<a href="/ecommerce/view/' . $item->id . '">' . $item->name() . ($price->offer->name() ? ' (' . $price->offer->name() . ')' : '') . '</a> добавлен <a href="/ecommerce/cart">в корзину покупок</a>!';
302 302
     $result->send();
303
-  }
303
+    }
304 304
 
305
-  public function getcartAction() {
305
+    public function getcartAction() {
306 306
     $result = new Server\Result();
307 307
     ob_start();
308 308
     $this->view->widget('Ecommerce\cart');
309 309
     $result->content = ob_get_contents();
310 310
     ob_end_clean();
311 311
     $result->send();
312
-  }
312
+    }
313 313
 
314 314
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             $warecount = $cartitem->price->offer->warehouseCount($cart->id);
62 62
             if ($cartitem->count > $warecount) {
63 63
               $error = true;
64
-              Msg::add('Вы заказали <b>' . $cartitem->item->name . '</b> больше чем есть на складе. на складе: <b>' . $warecount . '</b>', 'danger');
64
+              Msg::add('Вы заказали <b>'.$cartitem->item->name.'</b> больше чем есть на складе. на складе: <b>'.$warecount.'</b>', 'danger');
65 65
             }
66 66
           }
67 67
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
           foreach ($deliverys[$cart->delivery_id]->fields as $field) {
74 74
             if (empty($_POST['deliveryFields'][$field->id]) && $field->required) {
75 75
               $error = 1;
76
-              Msg::add('Вы не указали: ' . $field->name, 'danger');
76
+              Msg::add('Вы не указали: '.$field->name, 'danger');
77 77
             }
78 78
           }
79 79
         }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         foreach (\Ecommerce\UserAdds\Field::getList() as $field) {
90 90
           if (empty($_POST['userAdds']['fields'][$field->id]) && $field->required) {
91 91
             $error = 1;
92
-            Msg::add('Вы не указали: ' . $field->name, 'danger');
92
+            Msg::add('Вы не указали: '.$field->name, 'danger');
93 93
           }
94 94
         }
95 95
         if (!empty($_POST['discounts']['card_item_id'])) {
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
           }
127 127
           $cart = \Ecommerce\Cart::get($cart->id);
128 128
           if (!empty(\App::$cur->ecommerce->config['notify_mail'])) {
129
-            $text = 'Перейдите в админ панель чтобы просмотреть новый заказ <a href = "http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/admin/ecommerce/Cart">Админ панель</a>';
130
-            $title = 'Новый заказ в интернет магазине на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME);
131
-            \Tools::sendMail('noreply@' . INJI_DOMAIN_NAME, \App::$cur->ecommerce->config['notify_mail'], $title, $text);
129
+            $text = 'Перейдите в админ панель чтобы просмотреть новый заказ <a href = "http://'.idn_to_utf8(INJI_DOMAIN_NAME).'/admin/ecommerce/Cart">Админ панель</a>';
130
+            $title = 'Новый заказ в интернет магазине на сайте '.idn_to_utf8(INJI_DOMAIN_NAME);
131
+            \Tools::sendMail('noreply@'.INJI_DOMAIN_NAME, \App::$cur->ecommerce->config['notify_mail'], $title, $text);
132 132
           }
133 133
           if ($this->notifications) {
134 134
             $notification = new Notifications\Notification();
135
-            $notification->name = 'Новый заказ в интернет магазине на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME);
135
+            $notification->name = 'Новый заказ в интернет магазине на сайте '.idn_to_utf8(INJI_DOMAIN_NAME);
136 136
             $notification->text = 'Перейдите в админ панель чтобы просмотреть новый заказ';
137 137
             $notification->chanel_id = $this->notifications->getChanel('Ecommerce-orders')->id;
138 138
             $notification->save();
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
         'href' => '/ecommerce/cart'
178 178
     ];
179 179
     $bread[] = [
180
-        'text' => 'Заказ: №' . $cart->id,
181
-        'href' => '/ecommerce/cart/orderDetail/' . $cart->id
180
+        'text' => 'Заказ: №'.$cart->id,
181
+        'href' => '/ecommerce/cart/orderDetail/'.$cart->id
182 182
     ];
183
-    $this->view->setTitle('Заказ №' . $cart->id);
183
+    $this->view->setTitle('Заказ №'.$cart->id);
184 184
     $this->view->page(['data' => compact('cart', 'bread')]);
185 185
   }
186 186
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
       $result->send();
269 269
     }
270 270
 
271
-    $item->sales ++;
271
+    $item->sales++;
272 272
     $item->save();
273 273
 
274 274
     if (empty($_GET['count']))
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     $stages = Ecommerce\Cart\Stage::getList();
281 281
     if (empty($this->module->config['sell_over_warehouse']) && $price->offer->warehouseCount() < $count) {
282 282
       $result->success = false;
283
-      $result->content = 'На складе недостаточно товара! Доступно: ' . $price->offer->warehouseCount();
283
+      $result->content = 'На складе недостаточно товара! Доступно: '.$price->offer->warehouseCount();
284 284
       $result->send();
285 285
     }
286 286
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     }
299 299
     $cart->date_last_activ = date('Y-m-d H:i:s');
300 300
     $cart->calc();
301
-    $result->successMsg = '<a href="/ecommerce/view/' . $item->id . '">' . $item->name() . ($price->offer->name() ? ' (' . $price->offer->name() . ')' : '') . '</a> добавлен <a href="/ecommerce/cart">в корзину покупок</a>!';
301
+    $result->successMsg = '<a href="/ecommerce/view/'.$item->id.'">'.$item->name().($price->offer->name() ? ' ('.$price->offer->name().')' : '').'</a> добавлен <a href="/ecommerce/cart">в корзину покупок</a>!';
302 302
     $result->send();
303 303
   }
304 304
 
Please login to merge, or discard this patch.
system/modules/Ecommerce/appControllers/EcommerceController.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -10,42 +10,42 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class ecommerceController extends Controller {
12 12
 
13
-  public function buyCardAction() {
13
+    public function buyCardAction() {
14 14
     $this->view->setTitle('Покупка карты');
15 15
     $bread = [];
16 16
     $bread[] = ['text' => 'Покупка карты'];
17 17
     $user = Users\User::$cur;
18 18
     if (!empty($_POST) && !empty($_POST['card_id'])) {
19
-      $error = false;
20
-      $card = \Ecommerce\Card::get((int) $_POST['card_id']);
21
-      if (!$card) {
19
+        $error = false;
20
+        $card = \Ecommerce\Card::get((int) $_POST['card_id']);
21
+        if (!$card) {
22 22
         $error = true;
23 23
         Msg::add('Такой карты не существует', 'danger');
24
-      }
24
+        }
25 25
 
26
-      if (!Users\User::$cur->id) {
26
+        if (!Users\User::$cur->id) {
27 27
         $user_id = $this->Users->registration($_POST, true);
28 28
         if (!$user_id) {
29
-          $error = true;
30
-          $user = null;
29
+            $error = true;
30
+            $user = null;
31 31
         } else {
32
-          $user = Users\User::get($user_id);
32
+            $user = Users\User::get($user_id);
33
+        }
33 34
         }
34
-      }
35
-      $userCard = \Ecommerce\Card\Item::get([['card_id', $card->id], ['user_id', $user->id]]);
36
-      if ($userCard) {
35
+        $userCard = \Ecommerce\Card\Item::get([['card_id', $card->id], ['user_id', $user->id]]);
36
+        if ($userCard) {
37 37
         $error = true;
38 38
         Msg::add('У вас уже есть такая карта', 'danger');
39
-      }
39
+        }
40 40
 
41
-      $fields = \Ecommerce\UserAdds\Field::getList();
42
-      foreach ($fields as $field) {
41
+        $fields = \Ecommerce\UserAdds\Field::getList();
42
+        foreach ($fields as $field) {
43 43
         if (empty($_POST['userAdds']['fields'][$field->id]) && $field->required) {
44
-          $error = 1;
45
-          Msg::add('Вы не указали: ' . $field->name);
44
+            $error = 1;
45
+            Msg::add('Вы не указали: ' . $field->name);
46
+        }
46 47
         }
47
-      }
48
-      if (!$error) {
48
+        if (!$error) {
49 49
         $cardItem = new \Ecommerce\Card\Item();
50 50
         $cardItem->card_id = $card->id;
51 51
         $cardItem->user_id = $user->id;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $cart->date_status = date('Y-m-d H:i:s');
59 59
         $cart->complete_data = date('Y-m-d H:i:s');
60 60
         if (!empty($_SESSION['cart']['cart_id'])) {
61
-          $cart->card_item_id = $cardItem->id;
61
+            $cart->card_item_id = $cardItem->id;
62 62
         }
63 63
         $cart->save();
64 64
 
@@ -73,69 +73,69 @@  discard block
 block discarded – undo
73 73
         $extra->info = 'card:' . $card->id . '|cardItem:' . $cardItem->id;
74 74
         $extra->save();
75 75
         Tools::redirect('/ecommerce/cart/success');
76
-      }
76
+        }
77 77
     }
78 78
     $this->view->page(['data' => compact('bread')]);
79
-  }
79
+    }
80 80
 
81
-  public function autoCompleteAction() {
81
+    public function autoCompleteAction() {
82 82
     $return = Cache::get('itemsAutocomplete');
83 83
     if (!$return) {
84
-      $items = $this->ecommerce->getItems();
85
-      $return = [];
86
-      foreach ($items as $item) {
84
+        $items = $this->ecommerce->getItems();
85
+        $return = [];
86
+        foreach ($items as $item) {
87 87
         $return[] = ['name' => $item->name(), 'search' => $item->search_index . ' ' . $item->name];
88
-      }
89
-      $return = json_encode($return);
90
-      Cache::set('itemsAutocomplete', [], $return);
88
+        }
89
+        $return = json_encode($return);
90
+        Cache::set('itemsAutocomplete', [], $return);
91 91
     }
92 92
     echo $return;
93
-  }
93
+    }
94 94
 
95
-  public function indexAction() {
95
+    public function indexAction() {
96 96
     if (empty($this->module->config['catalogPresentPage'])) {
97
-      Tools::redirect('/ecommerce/itemList');
97
+        Tools::redirect('/ecommerce/itemList');
98 98
     }
99 99
     //$this->view->setTitle('Каталог');
100 100
     $this->view->page();
101
-  }
101
+    }
102 102
 
103
-  public function itemListAction($category_id = 0) {
103
+    public function itemListAction($category_id = 0) {
104 104
     //search
105 105
     if (!empty($_GET['search'])) {
106
-      if (!empty($_GET['inCatalog'])) {
106
+        if (!empty($_GET['inCatalog'])) {
107 107
         $category_id = (int) $_GET['inCatalog'];
108
-      }
109
-      $search = $_GET['search'];
108
+        }
109
+        $search = $_GET['search'];
110 110
     } else {
111
-      $search = '';
111
+        $search = '';
112 112
     }
113 113
 
114 114
     //sort
115 115
     if (!empty($_GET['sort'])) {
116
-      $sort = $_GET['sort'];
116
+        $sort = $_GET['sort'];
117 117
     } elseif (!empty($this->ecommerce->config['defaultSort'])) {
118
-      $sort = $this->ecommerce->config['defaultSort'];
118
+        $sort = $this->ecommerce->config['defaultSort'];
119 119
     } else {
120
-      $sort = ['name' => 'asc'];
120
+        $sort = ['name' => 'asc'];
121 121
     }
122 122
 
123 123
     //category
124 124
     $category = null;
125 125
     if ($category_id) {
126
-      if (is_numeric($category_id)) {
126
+        if (is_numeric($category_id)) {
127 127
         $category = \Ecommerce\Category::get($category_id);
128
-      }
129
-      if (!$category) {
128
+        }
129
+        if (!$category) {
130 130
         $category = \Ecommerce\Category::get($category_id, 'alias');
131
-      }
132
-      if ($category) {
131
+        }
132
+        if ($category) {
133 133
         $category_id = $category->id;
134
-      } else {
134
+        } else {
135 135
         $category_id = 0;
136
-      }
136
+        }
137 137
     } else {
138
-      $category_id = 0;
138
+        $category_id = 0;
139 139
     }
140 140
     $active = $category_id;
141 141
 
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
     //bread
152 152
     $bread = [];
153 153
     if (!$category || !$category->name) {
154
-      $bread[] = array('text' => 'Каталог');
155
-      $this->view->setTitle('Каталог');
154
+        $bread[] = array('text' => 'Каталог');
155
+        $this->view->setTitle('Каталог');
156 156
     } else {
157
-      $bread[] = array('text' => 'Каталог', 'href' => '/ecommerce');
158
-      $categoryIds = array_values(array_filter(explode('/', $category->tree_path)));
159
-      foreach ($categoryIds as $id) {
157
+        $bread[] = array('text' => 'Каталог', 'href' => '/ecommerce');
158
+        $categoryIds = array_values(array_filter(explode('/', $category->tree_path)));
159
+        foreach ($categoryIds as $id) {
160 160
         $cat = Ecommerce\Category::get($id);
161 161
         $bread[] = array('text' => $cat->name, 'href' => '/ecommerce/itemList/' . $cat->id);
162
-      }
163
-      $bread[] = array('text' => $category->name);
164
-      $this->view->setTitle($category->name);
162
+        }
163
+        $bread[] = array('text' => $category->name);
164
+        $this->view->setTitle($category->name);
165 165
     }
166 166
 
167 167
     //items
@@ -176,30 +176,30 @@  discard block
 block discarded – undo
176 176
 
177 177
     //params 
178 178
     if (empty(App::$cur->ecommerce->config['filtersInLast'])) {
179
-      $options = \Ecommerce\Item\Option::getList(['where' => ['item_option_searchable', 1]]);
179
+        $options = \Ecommerce\Item\Option::getList(['where' => ['item_option_searchable', 1]]);
180 180
     } else {
181
-      $params = $this->ecommerce->getItemsParams([
182
-          'parent' => $category_id,
183
-          'search' => trim($search),
184
-          'filters' => !empty($_GET['filters']) ? $_GET['filters'] : []
185
-      ]);
186
-      $ids = [];
187
-      foreach ($params as $param) {
181
+        $params = $this->ecommerce->getItemsParams([
182
+            'parent' => $category_id,
183
+            'search' => trim($search),
184
+            'filters' => !empty($_GET['filters']) ? $_GET['filters'] : []
185
+        ]);
186
+        $ids = [];
187
+        foreach ($params as $param) {
188 188
         $ids[] = $param->item_option_id;
189
-      }
190
-      if ($ids) {
189
+        }
190
+        if ($ids) {
191 191
         $options = \Ecommerce\Item\Option::getList(['where' => ['id', $ids, 'IN']]);
192
-      } else {
192
+        } else {
193 193
         $options = [];
194
-      }
194
+        }
195 195
     }
196 196
 
197 197
 
198 198
     //child categorys
199 199
     if ($category) {
200
-      $categorys = $category->catalogs;
200
+        $categorys = $category->catalogs;
201 201
     } else {
202
-      $categorys = \Ecommerce\Category::getList(['where' => ['parent_id', 0]]);
202
+        $categorys = \Ecommerce\Category::getList(['where' => ['parent_id', 0]]);
203 203
     }
204 204
 
205 205
     //view content
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
         'page' => $category ? $category->resolveTemplate() : (!empty(App::$cur->ecommerce->config['defaultCategoryTemplate']) ? App::$cur->ecommerce->config['defaultCategoryTemplate'] : 'current'),
208 208
         'content' => $category ? $category->resolveViewer() : (!empty(App::$cur->ecommerce->config['defaultCategoryView']) ? App::$cur->ecommerce->config['defaultCategoryView'] : 'itemList'),
209 209
         'data' => compact('active', 'category', 'sort', 'search', 'pages', 'items', 'categorys', 'bread', 'options')]);
210
-  }
210
+    }
211 211
 
212
-  public function viewAction($id = '') {
212
+    public function viewAction($id = '') {
213 213
     $item = \Ecommerce\Item::get((int) $id);
214 214
     if (!$item) {
215
-      Tools::redirect('/ecommerce/', 'Такой товар не найден');
215
+        Tools::redirect('/ecommerce/', 'Такой товар не найден');
216 216
     }
217 217
     $active = $item->category_id;
218 218
     $catalog = $item->category;
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 
222 222
     $catalogIds = array_values(array_filter(explode('/', $item->tree_path)));
223 223
     foreach ($catalogIds as $id) {
224
-      $cat = Ecommerce\Category::get($id);
225
-      if ($cat) {
224
+        $cat = Ecommerce\Category::get($id);
225
+        if ($cat) {
226 226
         $bread[] = ['text' => $cat->name, 'href' => '/ecommerce/itemList/' . $cat->id];
227
-      }
227
+        }
228 228
     }
229 229
     $bread[] = ['text' => $item->name()];
230 230
     $this->view->setTitle($item->name());
@@ -233,17 +233,17 @@  discard block
 block discarded – undo
233 233
         'content' => $item->view ? $item->view : 'view'
234 234
     ];
235 235
     if (isset($_GET['quickview'])) {
236
-      $options['page'] = 'blank';
236
+        $options['page'] = 'blank';
237 237
     }
238 238
 
239 239
     $this->view->addMetaTag(['property' => 'og:title', 'content' => $item->name]);
240 240
     $this->view->addMetaTag(['property' => 'og:description', 'content' => $item->description]);
241 241
     if ($item->image) {
242
-      $this->view->addMetaTag(['property' => 'og:image', 'content' => 'http://' . INJI_DOMAIN_NAME . $item->image->path]);
242
+        $this->view->addMetaTag(['property' => 'og:image', 'content' => 'http://' . INJI_DOMAIN_NAME . $item->image->path]);
243 243
     }
244 244
     $this->view->addMetaTag(['property' => 'og:url', 'content' => 'http://' . INJI_DOMAIN_NAME . '/view/' . $item->id]);
245 245
 
246 246
     $this->view->page($options);
247
-  }
247
+    }
248 248
 
249 249
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
       foreach ($fields as $field) {
43 43
         if (empty($_POST['userAdds']['fields'][$field->id]) && $field->required) {
44 44
           $error = 1;
45
-          Msg::add('Вы не указали: ' . $field->name);
45
+          Msg::add('Вы не указали: '.$field->name);
46 46
         }
47 47
       }
48 48
       if (!$error) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $extra->price = $card->price;
71 71
         $extra->count = 1;
72 72
         $extra->cart_id = $cart->id;
73
-        $extra->info = 'card:' . $card->id . '|cardItem:' . $cardItem->id;
73
+        $extra->info = 'card:'.$card->id.'|cardItem:'.$cardItem->id;
74 74
         $extra->save();
75 75
         Tools::redirect('/ecommerce/cart/success');
76 76
       }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
       $items = $this->ecommerce->getItems();
85 85
       $return = [];
86 86
       foreach ($items as $item) {
87
-        $return[] = ['name' => $item->name(), 'search' => $item->search_index . ' ' . $item->name];
87
+        $return[] = ['name' => $item->name(), 'search' => $item->search_index.' '.$item->name];
88 88
       }
89 89
       $return = json_encode($return);
90 90
       Cache::set('itemsAutocomplete', [], $return);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
       $categoryIds = array_values(array_filter(explode('/', $category->tree_path)));
159 159
       foreach ($categoryIds as $id) {
160 160
         $cat = Ecommerce\Category::get($id);
161
-        $bread[] = array('text' => $cat->name, 'href' => '/ecommerce/itemList/' . $cat->id);
161
+        $bread[] = array('text' => $cat->name, 'href' => '/ecommerce/itemList/'.$cat->id);
162 162
       }
163 163
       $bread[] = array('text' => $category->name);
164 164
       $this->view->setTitle($category->name);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
     foreach ($catalogIds as $id) {
224 224
       $cat = Ecommerce\Category::get($id);
225 225
       if ($cat) {
226
-        $bread[] = ['text' => $cat->name, 'href' => '/ecommerce/itemList/' . $cat->id];
226
+        $bread[] = ['text' => $cat->name, 'href' => '/ecommerce/itemList/'.$cat->id];
227 227
       }
228 228
     }
229 229
     $bread[] = ['text' => $item->name()];
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
     $this->view->addMetaTag(['property' => 'og:title', 'content' => $item->name]);
240 240
     $this->view->addMetaTag(['property' => 'og:description', 'content' => $item->description]);
241 241
     if ($item->image) {
242
-      $this->view->addMetaTag(['property' => 'og:image', 'content' => 'http://' . INJI_DOMAIN_NAME . $item->image->path]);
242
+      $this->view->addMetaTag(['property' => 'og:image', 'content' => 'http://'.INJI_DOMAIN_NAME.$item->image->path]);
243 243
     }
244
-    $this->view->addMetaTag(['property' => 'og:url', 'content' => 'http://' . INJI_DOMAIN_NAME . '/view/' . $item->id]);
244
+    $this->view->addMetaTag(['property' => 'og:url', 'content' => 'http://'.INJI_DOMAIN_NAME.'/view/'.$item->id]);
245 245
 
246 246
     $this->view->page($options);
247 247
   }
Please login to merge, or discard this patch.
system/modules/Ecommerce/models/Category.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -13,50 +13,50 @@  discard block
 block discarded – undo
13 13
 
14 14
 class Category extends \Model {
15 15
 
16
-  public static $objectName = 'Категория магазина';
17
-  public static $treeCategory = 'Ecommerce\Item';
18
-  public static $cols = [
19
-      //Основные параметры
20
-      'parent_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'parent'],
21
-      'name' => ['type' => 'text'],
22
-      'alias' => ['type' => 'text'],
23
-      'viewer' => ['type' => 'select', 'source' => 'method', 'method' => 'viewsCategoryList', 'module' => 'Ecommerce'],
24
-      'template' => ['type' => 'select', 'source' => 'method', 'method' => 'templatesCategoryList', 'module' => 'Ecommerce'],
25
-      'description' => ['type' => 'html'],
26
-      'image_file_id' => ['type' => 'image'],
27
-      'options_inherit' => ['type' => 'bool'],
28
-      //Системные
29
-      'imported' => ['type' => 'bool'],
30
-      'weight' => ['type' => 'number'],
31
-      'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
32
-      'tree_path' => ['type' => 'text'],
33
-      'date_create' => ['type' => 'dateTime'],
34
-      //Менеджеры
35
-      'options' => ['type' => 'dataManager', 'relation' => 'options'],
36
-  ];
37
-  public static $labels = [
38
-      'name' => 'Название',
39
-      'alias' => 'Алиас',
40
-      'parent_id' => 'Родительская категория',
41
-      'image_file_id' => 'Изображение',
42
-      'description' => 'Описание',
43
-      'options_inherit' => 'Наследовать набор свойств',
44
-      'options' => 'Свойства товаров',
45
-  ];
46
-  public static $forms = [
47
-      'manager' => [
48
-          'map' => [
49
-              ['name', 'alias'],
50
-              ['parent_id', 'image_file_id'],
51
-              ['viewer', 'template'],
52
-              ['options_inherit'],
53
-              ['options'],
54
-              ['description']
55
-          ]
56
-      ]
57
-  ];
16
+    public static $objectName = 'Категория магазина';
17
+    public static $treeCategory = 'Ecommerce\Item';
18
+    public static $cols = [
19
+        //Основные параметры
20
+        'parent_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'parent'],
21
+        'name' => ['type' => 'text'],
22
+        'alias' => ['type' => 'text'],
23
+        'viewer' => ['type' => 'select', 'source' => 'method', 'method' => 'viewsCategoryList', 'module' => 'Ecommerce'],
24
+        'template' => ['type' => 'select', 'source' => 'method', 'method' => 'templatesCategoryList', 'module' => 'Ecommerce'],
25
+        'description' => ['type' => 'html'],
26
+        'image_file_id' => ['type' => 'image'],
27
+        'options_inherit' => ['type' => 'bool'],
28
+        //Системные
29
+        'imported' => ['type' => 'bool'],
30
+        'weight' => ['type' => 'number'],
31
+        'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
32
+        'tree_path' => ['type' => 'text'],
33
+        'date_create' => ['type' => 'dateTime'],
34
+        //Менеджеры
35
+        'options' => ['type' => 'dataManager', 'relation' => 'options'],
36
+    ];
37
+    public static $labels = [
38
+        'name' => 'Название',
39
+        'alias' => 'Алиас',
40
+        'parent_id' => 'Родительская категория',
41
+        'image_file_id' => 'Изображение',
42
+        'description' => 'Описание',
43
+        'options_inherit' => 'Наследовать набор свойств',
44
+        'options' => 'Свойства товаров',
45
+    ];
46
+    public static $forms = [
47
+        'manager' => [
48
+            'map' => [
49
+                ['name', 'alias'],
50
+                ['parent_id', 'image_file_id'],
51
+                ['viewer', 'template'],
52
+                ['options_inherit'],
53
+                ['options'],
54
+                ['description']
55
+            ]
56
+        ]
57
+    ];
58 58
 
59
-  public static function indexes() {
59
+    public static function indexes() {
60 60
     return [
61 61
         'ecommerce_category_category_parent_id' => [
62 62
             'type' => 'INDEX',
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
             ]
72 72
         ],
73 73
     ];
74
-  }
74
+    }
75 75
 
76
-  public static function relations() {
76
+    public static function relations() {
77 77
     return [
78 78
         'items' => [
79 79
             'type' => 'many',
@@ -103,50 +103,50 @@  discard block
 block discarded – undo
103 103
             'col' => 'parent_id',
104 104
         ]
105 105
     ];
106
-  }
106
+    }
107 107
 
108
-  public static $dataManagers = [
109
-      'manager' => [
110
-          'name' => 'Категории товаров',
111
-          'cols' => [
112
-              'name',
113
-              'parent_id',
114
-          ],
115
-          'sortMode' => true
116
-      ]
117
-  ];
108
+    public static $dataManagers = [
109
+        'manager' => [
110
+            'name' => 'Категории товаров',
111
+            'cols' => [
112
+                'name',
113
+                'parent_id',
114
+            ],
115
+            'sortMode' => true
116
+        ]
117
+    ];
118 118
 
119
-  public function beforeSave() {
119
+    public function beforeSave() {
120 120
     if ($this->id && $this->id == $this->parent_id) {
121
-      $this->parent_id = 0;
122
-      \Msg::add('Категория не может быть сама себе родителем');
121
+        $this->parent_id = 0;
122
+        \Msg::add('Категория не может быть сама себе родителем');
123
+    }
123 124
     }
124
-  }
125 125
 
126
-  public function beforeDelete() {
126
+    public function beforeDelete() {
127 127
     foreach ($this->catalogs as $category) {
128
-      $category->delete();
128
+        $category->delete();
129
+    }
129 130
     }
130
-  }
131 131
 
132
-  public function resolveTemplate() {
132
+    public function resolveTemplate() {
133 133
     if ($this->template !== 'inherit') {
134
-      return $this->template;
134
+        return $this->template;
135 135
     } elseif ($this->template == 'inherit' && $this->category) {
136
-      return $this->category->resolveTemplate(true);
136
+        return $this->category->resolveTemplate(true);
137 137
     } else {
138
-      return (!empty(\App::$cur->ecommerce->config['defaultCategoryTemplate']) ? \App::$cur->ecommerce->config['defaultCategoryTemplate'] : 'current');
138
+        return (!empty(\App::$cur->ecommerce->config['defaultCategoryTemplate']) ? \App::$cur->ecommerce->config['defaultCategoryTemplate'] : 'current');
139
+    }
139 140
     }
140
-  }
141 141
 
142
-  public function resolveViewer() {
142
+    public function resolveViewer() {
143 143
     if ($this->viewer !== 'inherit') {
144
-      return $this->viewer;
144
+        return $this->viewer;
145 145
     } elseif ($this->viewer == 'inherit' && $this->category) {
146
-      return $this->category->resolveViewer(true);
146
+        return $this->category->resolveViewer(true);
147 147
     } else {
148
-      return (!empty(\App::$cur->ecommerce->config['defaultCategoryView']) ? \App::$cur->ecommerce->config['defaultCategoryView'] : 'itemList');
148
+        return (!empty(\App::$cur->ecommerce->config['defaultCategoryView']) ? \App::$cur->ecommerce->config['defaultCategoryView'] : 'itemList');
149
+    }
149 150
     }
150
-  }
151 151
 
152 152
 }
Please login to merge, or discard this patch.