Completed
Push — master ( 913952...f8c7e1 )
by Alexey
06:23
created
system/modules/Ui/widgets/Form/select.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 $aditionalInputs = [];
3 3
 $showedInput = false;
4 4
 if(!empty($options['createBtn'])){
5
-  $optionsHtml = '<option disabled onclick="'.$options['createBtn']['onclick'].'">'.$options['createBtn']['text'].'</option>';
5
+    $optionsHtml = '<option disabled onclick="'.$options['createBtn']['onclick'].'">'.$options['createBtn']['text'].'</option>';
6 6
 }else {
7
-  $optionsHtml = '';
7
+    $optionsHtml = '';
8 8
 }
9 9
 
10 10
 foreach ($options['values'] as $key => $value) {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 $aditionalInputs = [];
3 3
 $showedInput = false;
4
-if(!empty($options['createBtn'])){
4
+if (!empty($options['createBtn'])) {
5 5
   $optionsHtml = '<option disabled onclick="'.$options['createBtn']['onclick'].'">'.$options['createBtn']['text'].'</option>';
6
-}else {
6
+} else {
7 7
   $optionsHtml = '';
8 8
 }
9 9
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     }
18 18
     if (
19 19
             (!is_array($primaryValue) && ($key === $primaryValue || (isset($form->userDataTree[$name]) && $form->userDataTree[$name] === $key))) ||
20
-            (is_array($primaryValue) && (in_array($key,$primaryValue) || (isset($form->userDataTree[$name]) && in_array($key,$form->userDataTree[$name]))))
20
+            (is_array($primaryValue) && (in_array($key, $primaryValue) || (isset($form->userDataTree[$name]) && in_array($key, $form->userDataTree[$name]))))
21 21
             ) {
22 22
         $selected = ' selected="selected"';
23 23
     }
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
             $showedInput = count($aditionalInputs) - 1;
28 28
             $aditionValue = !empty($options['aditionalValue']) ? $options['aditionalValue'] : '';
29 29
         }
30
-        $optionsHtml .= "<option data-aditionalInput='" . ( count($aditionalInputs) - 1) . "' value ='{$key}'{$selected}>{$value['text']}</option>";
30
+        $optionsHtml .= "<option data-aditionalInput='".(count($aditionalInputs) - 1)."' value ='{$key}'{$selected}>{$value['text']}</option>";
31 31
     } else {
32 32
         $optionsHtml .= "<option value ='{$key}'{$selected}>{$value}</option>";
33 33
     }
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 
45 45
     if ($key !== $showedInput) {
46 46
         $input['options']['disabled'] = true;
47
-        $input['options']['class'] = !empty($input['options']['class']) ? $input['options']['class'] . ' hidden' : 'hidden';
47
+        $input['options']['class'] = !empty($input['options']['class']) ? $input['options']['class'].' hidden' : 'hidden';
48 48
     } else {
49 49
         $input['options']['value'] = empty($input['options']['value']) ? $aditionValue : $input['options']['value'];
50 50
     }
51 51
     if ($input['type'] == 'select') {
52 52
         $input['options']['values'] = \Ui\ActiveForm::getOptionsList($input);
53 53
     }
54
-    $form->input($input['type'], empty($input['name']) ? $name . '[aditional]' : $input['name'], false, $input['options']);
54
+    $form->input($input['type'], empty($input['name']) ? $name.'[aditional]' : $input['name'], false, $input['options']);
55 55
 }
56 56
 ?>
57 57
 <?= empty($options['noContainer']) ? '</div>' : ''; ?>
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 $showedInput = false;
4 4
 if(!empty($options['createBtn'])){
5 5
   $optionsHtml = '<option disabled onclick="'.$options['createBtn']['onclick'].'">'.$options['createBtn']['text'].'</option>';
6
-}else {
6
+} else {
7 7
   $optionsHtml = '';
8 8
 }
9 9
 
Please login to merge, or discard this patch.
system/modules/Ui/objects/ActiveForm/Input/Select.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 class Select extends \Ui\ActiveForm\Input {
15 15
 
16
-  public function draw() {
16
+    public function draw() {
17 17
     $inputName = $this->colName();
18 18
     $inputLabel = $this->colLabel();
19 19
     $inputParams = $this->colParams;
@@ -25,41 +25,41 @@  discard block
 block discarded – undo
25 25
     ];
26 26
     $modelName = '';
27 27
     switch ($inputParams['source']) {
28
-      case 'model':
28
+        case 'model':
29 29
         $modelName = $inputParams['model'];
30 30
         break;
31
-      case 'relation':
31
+        case 'relation':
32 32
         if ($this->activeForm->modelName) {
33
-          $itemModelName = $this->activeForm->modelName;
34
-          $relation = $itemModelName::getRelation($inputParams['relation']);
35
-          if ($relation['model'] && class_exists($relation['model'])) {
33
+            $itemModelName = $this->activeForm->modelName;
34
+            $relation = $itemModelName::getRelation($inputParams['relation']);
35
+            if ($relation['model'] && class_exists($relation['model'])) {
36 36
             $modelName = $relation['model'];
37
-          }
37
+            }
38 38
         }
39 39
     }
40 40
     if (!empty($modelName)) {
41
-      $inputOptions['createBtn'] = [
42
-          'text' => 'Создать элемент',
43
-          'onclick' => 'inji.Ui.forms.popUp(\'' . addslashes($modelName) . '\',{},function(elem){'
44
-          . 'return function(data,modal){inji.Ui.forms.submitAjax($(elem).closest(\'form\')[0], {notSave: true});}}(this))'
45
-      ];
41
+        $inputOptions['createBtn'] = [
42
+            'text' => 'Создать элемент',
43
+            'onclick' => 'inji.Ui.forms.popUp(\'' . addslashes($modelName) . '\',{},function(elem){'
44
+            . 'return function(data,modal){inji.Ui.forms.submitAjax($(elem).closest(\'form\')[0], {notSave: true});}}(this))'
45
+        ];
46 46
     }
47 47
     if (!empty($inputOptions['values'][$this->activeForm->model->{$this->colName}]) &&
48 48
             is_array($inputOptions['values'][$this->activeForm->model->{$this->colName}]) &&
49 49
             !empty($inputOptions['values'][$this->activeForm->model->{$this->colName}]['input'])) {
50
-      $aditionalCol = $inputOptions['values'][$this->activeForm->model->{$this->colName}]['input']['name'];
51
-      $inputOptions['aditionalValue'] = $this->activeForm->model->$aditionalCol;
50
+        $aditionalCol = $inputOptions['values'][$this->activeForm->model->{$this->colName}]['input']['name'];
51
+        $inputOptions['aditionalValue'] = $this->activeForm->model->$aditionalCol;
52 52
     }
53 53
 
54 54
     $preset = $this->preset();
55 55
 
56 56
     if ($preset !== null) {
57
-      $inputOptions['disabled'] = true;
58
-      $this->form->input('hidden', $inputName, '', $inputOptions);
59
-      return true;
57
+        $inputOptions['disabled'] = true;
58
+        $this->form->input('hidden', $inputName, '', $inputOptions);
59
+        return true;
60 60
     }
61 61
     $this->form->input('select', $inputName, $inputLabel, $inputOptions);
62 62
     return true;
63
-  }
63
+    }
64 64
 
65 65
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     if (!empty($modelName)) {
41 41
       $inputOptions['createBtn'] = [
42 42
           'text' => 'Создать элемент',
43
-          'onclick' => 'inji.Ui.forms.popUp(\'' . addslashes($modelName) . '\',{},function(elem){'
43
+          'onclick' => 'inji.Ui.forms.popUp(\''.addslashes($modelName).'\',{},function(elem){'
44 44
           . 'return function(data,modal){inji.Ui.forms.submitAjax($(elem).closest(\'form\')[0], {notSave: true});}}(this))'
45 45
       ];
46 46
     }
Please login to merge, or discard this patch.
system/modules/Users/appControllers/content/registration.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@  discard block
 block discarded – undo
6 6
         <?php
7 7
         $socials = Users\Social::getList(['where' => ['active', 1]]);
8 8
         if ($socials) {
9
-          ?>
9
+            ?>
10 10
           <div class="form-group">
11 11
             <label>Регистрация через соц.сети</label><br />
12 12
             <?php
13 13
             foreach (Users\Social::getList(['where' => ['active', 1]]) as $social) {
14
-              echo "<a href = '/users/social/auth/{$social->code}'>{$social->name()}</a> ";
14
+                echo "<a href = '/users/social/auth/{$social->code}'>{$social->name()}</a> ";
15 15
             }
16 16
             ?>
17 17
           </div>
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
           <div class ='row'>
42 42
             <div class="col-sm-6">
43 43
               <?php
44
-              if (!empty(App::$cur->users->config['invites'])) {
44
+                if (!empty(App::$cur->users->config['invites'])) {
45 45
                 ?>
46 46
                 <div class ='form-group'>
47 47
                   <label><?= !empty(App::$cur->users->config['invitesName']) ? App::$cur->users->config['invitesName'] : 'Код приглашения'; ?></label>
48 48
                   <input type ='text' name ='invite_code' class ='form-control' value ="<?= (isset($_POST['invite_code']) ? $_POST['invite_code'] : ((!empty($_COOKIE['invite_code']) ? $_COOKIE['invite_code'] : ((!empty($_GET['invite_code']) ? $_GET['invite_code'] : ''))))); ?>" />
49 49
                 </div>   
50 50
                 <?php
51
-              }
52
-              ?>
51
+                }
52
+                ?>
53 53
             </div>
54 54
           </div>
55 55
           <div class ='form-group'>
Please login to merge, or discard this patch.
system/modules/Ecommerce/widgets/filters.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
     $min = App::$cur->ecommerce->getItems(['sort' => ['price' => 'asc'], 'count' => 1, 'key' => false]);
5 5
     $max = App::$cur->ecommerce->getItems(['sort' => ['price' => 'desc'], 'count' => 1, 'key' => false]);
6 6
     if ($min && $min[0]->getPrice() && $max && $max[0]->getPrice()) {
7
-      ?>
7
+        ?>
8 8
       <h4>Фильтр по цене</h4>
9 9
       <div class="form-group">      
10 10
         <div class="row">
@@ -15,28 +15,28 @@  discard block
 block discarded – undo
15 15
       <?php
16 16
     }
17 17
     foreach ($options as $option) {
18
-      ?>
18
+        ?>
19 19
       <div class="filter">  
20 20
 
21 21
         <?php
22 22
         switch ($option->type) {
23
-          case 'radio':
23
+            case 'radio':
24 24
             echo "<label>{$option->name}</label>";
25 25
             foreach ($option->items as $item) {
26
-              $this->widget('Ui\Form/' . $option->type, [
27
-                  'label' => $item->name,
28
-                  'name' => "filters[options][{$option->id}]",
29
-                  !empty($_GET['filters']['options'][$option->id]) && $_GET['filters']['options'][$option->id] == $item->id ? 'checked' : false,
30
-                  'options' => [
31
-                      'value' => $item->id,
32
-                  ]
33
-              ]);
26
+                $this->widget('Ui\Form/' . $option->type, [
27
+                    'label' => $item->name,
28
+                    'name' => "filters[options][{$option->id}]",
29
+                    !empty($_GET['filters']['options'][$option->id]) && $_GET['filters']['options'][$option->id] == $item->id ? 'checked' : false,
30
+                    'options' => [
31
+                        'value' => $item->id,
32
+                    ]
33
+                ]);
34 34
             }
35 35
             break;
36
-          case 'select':
36
+            case 'select':
37 37
             echo "<label>{$option->name}</label>";
38 38
             foreach ($option->items as $item) {
39
-              ?>
39
+                ?>
40 40
               <div class="radio">
41 41
                 <label>
42 42
                   <input type="checkbox" name = 'filters[options][<?= $option->id; ?>][]' value ="<?= $item->id; ?>" <?= !empty($_GET['filters']['options'][$option->id]) && in_array($item->id, $_GET['filters']['options'][$option->id]) ? 'checked' : ''; ?>>
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
               <?php
47 47
             }
48 48
             break;
49
-          default:
49
+            default:
50 50
             $this->widget('Ui\Form/' . ($option->type ? $option->type : 'text'), [
51 51
                 'label' => $option->name,
52 52
                 'name' => "filters[options][{$option->id}]",
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
           case 'radio':
24 24
             echo "<label>{$option->name}</label>";
25 25
             foreach ($option->items as $item) {
26
-              $this->widget('Ui\Form/' . $option->type, [
26
+              $this->widget('Ui\Form/'.$option->type, [
27 27
                   'label' => $item->name,
28 28
                   'name' => "filters[options][{$option->id}]",
29 29
                   !empty($_GET['filters']['options'][$option->id]) && $_GET['filters']['options'][$option->id] == $item->id ? 'checked' : false,
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             }
48 48
             break;
49 49
           default:
50
-            $this->widget('Ui\Form/' . ($option->type ? $option->type : 'text'), [
50
+            $this->widget('Ui\Form/'.($option->type ? $option->type : 'text'), [
51 51
                 'label' => $option->name,
52 52
                 'name' => "filters[options][{$option->id}]",
53 53
                 'options' => [
Please login to merge, or discard this patch.
system/modules/Ecommerce/models/Item.php 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -13,82 +13,82 @@  discard block
 block discarded – undo
13 13
 
14 14
 class Item extends \Model {
15 15
 
16
-  public static $categoryModel = 'Ecommerce\Category';
17
-  public static $objectName = 'Товар';
18
-  public static $labels = [
19
-      'name' => 'Название',
20
-      'alias' => 'Алиас',
21
-      'category_id' => 'Раздел',
22
-      'description' => 'Описание',
23
-      'item_type_id' => 'Тип товара',
24
-      'image_file_id' => 'Изображение',
25
-      'best' => 'Лучшее предложение',
26
-      'options' => 'Параметры',
27
-      'offers' => 'Торговые предложения',
28
-      'widget' => 'Виджет для отображения в каталоге',
29
-      'view' => 'Шаблон для отображения полной информации',
30
-      'deleted' => 'Удален',
31
-      'imgs' => 'Фото'
32
-  ];
33
-  public static $cols = [
34
-      //Основные параметры
35
-      'category_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'category'],
36
-      'image_file_id' => ['type' => 'image'],
37
-      'name' => ['type' => 'text'],
38
-      'alias' => ['type' => 'text'],
39
-      'description' => ['type' => 'html'],
40
-      'item_type_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'type'],
41
-      'best' => ['type' => 'bool'],
42
-      'deleted' => ['type' => 'bool'],
43
-      //Системные
44
-      'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
45
-      'weight' => ['type' => 'number'],
46
-      'sales' => ['type' => 'number'],
47
-      'imported' => ['type' => 'text'],
48
-      'tree_path' => ['type' => 'text'],
49
-      'search_index' => ['type' => 'text'],
50
-      'date_create' => ['type' => 'dateTime'],
51
-      'widget' => ['type' => 'text'],
52
-      'view' => ['type' => 'text'],
53
-      //Менеджеры
54
-      'options' => ['type' => 'dataManager', 'relation' => 'options'],
55
-      'offers' => ['type' => 'dataManager', 'relation' => 'offers'],
56
-      'imgs' => ['type' => 'dataManager', 'relation' => 'images'],
57
-  ];
58
-  public static $dataManagers = [
59
-      'manager' => [
60
-          'name' => 'Товары',
61
-          'cols' => [
62
-              'name',
63
-              'imgs',
64
-              'category_id',
65
-              'item_type_id',
66
-              'best',
67
-              'deleted',
68
-              'options',
69
-              'offers',
70
-          ],
71
-          'categorys' => [
72
-              'model' => 'Ecommerce\Category',
73
-          ],
74
-          'sortMode' => true
75
-      ]
76
-  ];
77
-  public static $forms = [
78
-      'manager' => [
79
-          'map' => [
80
-              ['name', 'alias'],
81
-              ['category_id', 'item_type_id', 'deleted'],
82
-              ['widget', 'view'],
83
-              ['best', 'image_file_id'],
84
-              ['description'],
85
-              ['imgs'],
86
-              ['options'],
87
-              ['offers'],
88
-          ]
89
-  ]];
16
+    public static $categoryModel = 'Ecommerce\Category';
17
+    public static $objectName = 'Товар';
18
+    public static $labels = [
19
+        'name' => 'Название',
20
+        'alias' => 'Алиас',
21
+        'category_id' => 'Раздел',
22
+        'description' => 'Описание',
23
+        'item_type_id' => 'Тип товара',
24
+        'image_file_id' => 'Изображение',
25
+        'best' => 'Лучшее предложение',
26
+        'options' => 'Параметры',
27
+        'offers' => 'Торговые предложения',
28
+        'widget' => 'Виджет для отображения в каталоге',
29
+        'view' => 'Шаблон для отображения полной информации',
30
+        'deleted' => 'Удален',
31
+        'imgs' => 'Фото'
32
+    ];
33
+    public static $cols = [
34
+        //Основные параметры
35
+        'category_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'category'],
36
+        'image_file_id' => ['type' => 'image'],
37
+        'name' => ['type' => 'text'],
38
+        'alias' => ['type' => 'text'],
39
+        'description' => ['type' => 'html'],
40
+        'item_type_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'type'],
41
+        'best' => ['type' => 'bool'],
42
+        'deleted' => ['type' => 'bool'],
43
+        //Системные
44
+        'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
45
+        'weight' => ['type' => 'number'],
46
+        'sales' => ['type' => 'number'],
47
+        'imported' => ['type' => 'text'],
48
+        'tree_path' => ['type' => 'text'],
49
+        'search_index' => ['type' => 'text'],
50
+        'date_create' => ['type' => 'dateTime'],
51
+        'widget' => ['type' => 'text'],
52
+        'view' => ['type' => 'text'],
53
+        //Менеджеры
54
+        'options' => ['type' => 'dataManager', 'relation' => 'options'],
55
+        'offers' => ['type' => 'dataManager', 'relation' => 'offers'],
56
+        'imgs' => ['type' => 'dataManager', 'relation' => 'images'],
57
+    ];
58
+    public static $dataManagers = [
59
+        'manager' => [
60
+            'name' => 'Товары',
61
+            'cols' => [
62
+                'name',
63
+                'imgs',
64
+                'category_id',
65
+                'item_type_id',
66
+                'best',
67
+                'deleted',
68
+                'options',
69
+                'offers',
70
+            ],
71
+            'categorys' => [
72
+                'model' => 'Ecommerce\Category',
73
+            ],
74
+            'sortMode' => true
75
+        ]
76
+    ];
77
+    public static $forms = [
78
+        'manager' => [
79
+            'map' => [
80
+                ['name', 'alias'],
81
+                ['category_id', 'item_type_id', 'deleted'],
82
+                ['widget', 'view'],
83
+                ['best', 'image_file_id'],
84
+                ['description'],
85
+                ['imgs'],
86
+                ['options'],
87
+                ['offers'],
88
+            ]
89
+    ]];
90 90
 
91
-  public static function indexes() {
91
+    public static function indexes() {
92 92
     return [
93 93
         'ecommerce_item_item_category_id' => [
94 94
             'type' => 'INDEX',
@@ -109,45 +109,45 @@  discard block
 block discarded – undo
109 109
             ]
110 110
         ],
111 111
     ];
112
-  }
112
+    }
113 113
 
114
-  public function beforeSave() {
114
+    public function beforeSave() {
115 115
 
116 116
     if ($this->id) {
117
-      $this->search_index = $this->name . ' ';
118
-      if ($this->category) {
117
+        $this->search_index = $this->name . ' ';
118
+        if ($this->category) {
119 119
         $this->search_index .= $this->category->name . ' ';
120
-      }
121
-      if ($this->options) {
120
+        }
121
+        if ($this->options) {
122 122
         foreach ($this->options as $option) {
123
-          if ($option->item_option_searchable && $option->value) {
123
+            if ($option->item_option_searchable && $option->value) {
124 124
             if ($option->item_option_type != 'select') {
125
-              $this->search_index .= $option->value . ' ';
125
+                $this->search_index .= $option->value . ' ';
126 126
             } elseif (!empty($option->option->items[$option->value])) {
127
-              $option->option->items[$option->value]->value . ' ';
127
+                $option->option->items[$option->value]->value . ' ';
128
+            }
128 129
             }
129
-          }
130 130
         }
131
-      }
132
-      if ($this->offers) {
131
+        }
132
+        if ($this->offers) {
133 133
         foreach ($this->offers as $offer) {
134
-          if ($offer->options) {
134
+            if ($offer->options) {
135 135
             foreach ($offer->options as $option) {
136
-              if ($option->item_offer_option_searchable && $option->value) {
136
+                if ($option->item_offer_option_searchable && $option->value) {
137 137
                 if ($option->item_offer_option_type != 'select') {
138
-                  $this->search_index .= $option->value . ' ';
138
+                    $this->search_index .= $option->value . ' ';
139 139
                 } elseif (!empty($option->option->items[$option->value])) {
140
-                  $option->option->items[$option->value]->value . ' ';
140
+                    $option->option->items[$option->value]->value . ' ';
141
+                }
141 142
                 }
142
-              }
143 143
             }
144
-          }
144
+            }
145 145
         }
146
-      }
146
+        }
147
+    }
147 148
     }
148
-  }
149 149
 
150
-  public static function relations() {
150
+    public static function relations() {
151 151
 
152 152
     return [
153 153
         'category' => [
@@ -185,55 +185,55 @@  discard block
 block discarded – undo
185 185
             'col' => 'user_id'
186 186
         ]
187 187
     ];
188
-  }
188
+    }
189 189
 
190
-  public function getPrice() {
190
+    public function getPrice() {
191 191
     $offers = $this->offers(['key' => false]);
192 192
     $curPrice = null;
193 193
 
194 194
     foreach ($offers[0]->prices as $price) {
195
-      if (!$price->type) {
195
+        if (!$price->type) {
196 196
         $curPrice = $price;
197
-      } elseif (
198
-              (!$price->type->roles && !$curPrice) ||
197
+        } elseif (
198
+                (!$price->type->roles && !$curPrice) ||
199 199
               ($price->type->roles && !$curPrice && strpos($price->type->roles, "|" . \Users\User::$cur->role_id . "|") !== false)
200
-      ) {
200
+        ) {
201 201
         $curPrice = $price;
202
-      }
202
+        }
203 203
     }
204 204
     return $curPrice;
205
-  }
205
+    }
206 206
 
207
-  public function name() {
207
+    public function name() {
208 208
     if (!empty(\App::$primary->ecommerce->config['item_option_as_name'])) {
209
-      $param = Item\Param::get([['item_id', $this->id], ['item_option_id', \App::$primary->ecommerce->config['item_option_as_name']]]);
210
-      if ($param && $param->value) {
209
+        $param = Item\Param::get([['item_id', $this->id], ['item_option_id', \App::$primary->ecommerce->config['item_option_as_name']]]);
210
+        if ($param && $param->value) {
211 211
         return $param->value;
212
-      }
212
+        }
213 213
     }
214 214
     return $this->name;
215
-  }
215
+    }
216 216
 
217
-  public function beforeDelete() {
217
+    public function beforeDelete() {
218 218
     if ($this->id) {
219
-      if ($this->options) {
219
+        if ($this->options) {
220 220
         foreach ($this->options as $option) {
221
-          $option->delete();
221
+            $option->delete();
222
+        }
222 223
         }
223
-      }
224
-      if ($this->offers) {
224
+        if ($this->offers) {
225 225
         foreach ($this->offers as $offer) {
226
-          $offer->delete();
226
+            $offer->delete();
227
+        }
227 228
         }
228
-      }
229
-      if ($this->image) {
229
+        if ($this->image) {
230 230
         $this->image->delete();
231
-      }
231
+        }
232
+    }
232 233
     }
233
-  }
234 234
 
235
-  public function getHref() {
235
+    public function getHref() {
236 236
     return "/ecommerce/view/{$this->pk()}";
237
-  }
237
+    }
238 238
 
239 239
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
   public function beforeSave() {
115 115
 
116 116
     if ($this->id) {
117
-      $this->search_index = $this->name . ' ';
117
+      $this->search_index = $this->name.' ';
118 118
       if ($this->category) {
119
-        $this->search_index .= $this->category->name . ' ';
119
+        $this->search_index .= $this->category->name.' ';
120 120
       }
121 121
       if ($this->options) {
122 122
         foreach ($this->options as $option) {
123 123
           if ($option->item_option_searchable && $option->value) {
124 124
             if ($option->item_option_type != 'select') {
125
-              $this->search_index .= $option->value . ' ';
125
+              $this->search_index .= $option->value.' ';
126 126
             } elseif (!empty($option->option->items[$option->value])) {
127
-              $option->option->items[$option->value]->value . ' ';
127
+              $option->option->items[$option->value]->value.' ';
128 128
             }
129 129
           }
130 130
         }
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
             foreach ($offer->options as $option) {
136 136
               if ($option->item_offer_option_searchable && $option->value) {
137 137
                 if ($option->item_offer_option_type != 'select') {
138
-                  $this->search_index .= $option->value . ' ';
138
+                  $this->search_index .= $option->value.' ';
139 139
                 } elseif (!empty($option->option->items[$option->value])) {
140
-                  $option->option->items[$option->value]->value . ' ';
140
+                  $option->option->items[$option->value]->value.' ';
141 141
                 }
142 142
               }
143 143
             }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             'col' => 'item_id',
161 161
             //'resultKey' => 'code',
162 162
             'resultKey' => 'item_option_id',
163
-            'join' => [Item\Option::table(), Item\Option::index() . ' = ' . Item\Param::colPrefix() . Item\Option::index()]
163
+            'join' => [Item\Option::table(), Item\Option::index().' = '.Item\Param::colPrefix().Item\Option::index()]
164 164
         ],
165 165
         'offers' => [
166 166
             'type' => 'many',
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         $curPrice = $price;
197 197
       } elseif (
198 198
               (!$price->type->roles && !$curPrice) ||
199
-              ($price->type->roles && !$curPrice && strpos($price->type->roles, "|" . \Users\User::$cur->role_id . "|") !== false)
199
+              ($price->type->roles && !$curPrice && strpos($price->type->roles, "|".\Users\User::$cur->role_id."|") !== false)
200 200
       ) {
201 201
         $curPrice = $price;
202 202
       }
Please login to merge, or discard this patch.
system/modules/Money/objects/Sums.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,65 +13,65 @@
 block discarded – undo
13 13
 
14 14
 class Sums extends \Object {
15 15
 
16
-  public $sums = [];
16
+    public $sums = [];
17 17
 
18
-  public function __construct($sums) {
18
+    public function __construct($sums) {
19 19
     $this->sums = $sums;
20
-  }
20
+    }
21 21
 
22
-  function plus(Sums $sums) {
22
+    function plus(Sums $sums) {
23 23
     $newSums = $this->sums;
24 24
     foreach ($sums->sums as $currency_id => $sum) {
25
-      $newSums[$currency_id] = isset($newSums[$currency_id]) ? $newSums[$currency_id] + $sum : $sum;
25
+        $newSums[$currency_id] = isset($newSums[$currency_id]) ? $newSums[$currency_id] + $sum : $sum;
26 26
     }
27 27
     return new Sums($newSums);
28
-  }
28
+    }
29 29
 
30
-  function minus(Sums $sums) {
30
+    function minus(Sums $sums) {
31 31
     $newSums = $this->sums;
32 32
     foreach ($sums->sums as $currency_id => $sum) {
33
-      $newSums[$currency_id] = isset($newSums[$currency_id]) ? $newSums[$currency_id] - $sum : -$sum;
33
+        $newSums[$currency_id] = isset($newSums[$currency_id]) ? $newSums[$currency_id] - $sum : -$sum;
34 34
     }
35 35
     return new Sums($newSums);
36
-  }
36
+    }
37 37
 
38 38
 //Equal, Less and Greater
39
-  public function greater(Sums $sums) {
39
+    public function greater(Sums $sums) {
40 40
     if (count($this->sums) == count($sums->sums) && isset($sums->sums[key($this->sums)])) {
41
-      return current($this->sums) > current($sums->sums);
41
+        return current($this->sums) > current($sums->sums);
42
+    }
42 43
     }
43
-  }
44 44
 
45
-  public function equal(Sums $sums) {
45
+    public function equal(Sums $sums) {
46 46
     if (count($this->sums) == count($sums->sums) && isset($sums->sums[key($this->sums)])) {
47
-      return current($this->sums) == current($sums->sums);
47
+        return current($this->sums) == current($sums->sums);
48
+    }
48 49
     }
49
-  }
50 50
 
51
-  function __toString() {
51
+    function __toString() {
52 52
     $string = '';
53 53
     $first = true;
54 54
     foreach ($this->sums as $currency_id => $sum) {
55
-      if ($first) {
55
+        if ($first) {
56 56
         $first = false;
57
-      } else {
57
+        } else {
58 58
         $string.= '<br />';
59
-      }
60
-      $string.= '<span style="white-space:nowrap;">';
61
-      $string.= number_format($sum, 2, '.', ' ');
62
-      if (\App::$cur->money) {
59
+        }
60
+        $string.= '<span style="white-space:nowrap;">';
61
+        $string.= number_format($sum, 2, '.', ' ');
62
+        if (\App::$cur->money) {
63 63
         $currency = \Money\Currency::get($currency_id);
64 64
         if ($currency) {
65
-          $string.= ' ' . $currency->acronym();
65
+            $string.= ' ' . $currency->acronym();
66 66
         } else {
67
-          $string.= ' руб.';
67
+            $string.= ' руб.';
68 68
         }
69
-      } else {
69
+        } else {
70 70
         $string.= ' руб.';
71
-      }
72
-      $string.= '</span>';
71
+        }
72
+        $string.= '</span>';
73 73
     }
74 74
     return $string;
75
-  }
75
+    }
76 76
 
77 77
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -55,21 +55,21 @@
 block discarded – undo
55 55
       if ($first) {
56 56
         $first = false;
57 57
       } else {
58
-        $string.= '<br />';
58
+        $string .= '<br />';
59 59
       }
60
-      $string.= '<span style="white-space:nowrap;">';
61
-      $string.= number_format($sum, 2, '.', ' ');
60
+      $string .= '<span style="white-space:nowrap;">';
61
+      $string .= number_format($sum, 2, '.', ' ');
62 62
       if (\App::$cur->money) {
63 63
         $currency = \Money\Currency::get($currency_id);
64 64
         if ($currency) {
65
-          $string.= ' ' . $currency->acronym();
65
+          $string .= ' '.$currency->acronym();
66 66
         } else {
67
-          $string.= ' руб.';
67
+          $string .= ' руб.';
68 68
         }
69 69
       } else {
70
-        $string.= ' руб.';
70
+        $string .= ' руб.';
71 71
       }
72
-      $string.= '</span>';
72
+      $string .= '</span>';
73 73
     }
74 74
     return $string;
75 75
   }
Please login to merge, or discard this patch.
system/modules/Ecommerce/appControllers/CartController.php 3 patches
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -271,10 +271,11 @@
 block discarded – undo
271 271
     $item->sales ++;
272 272
     $item->save();
273 273
 
274
-    if (empty($_GET['count']))
275
-      $count = 1;
276
-    else
277
-      $count = (float) $_GET['count'];
274
+    if (empty($_GET['count'])) {
275
+          $count = 1;
276
+    } else {
277
+          $count = (float) $_GET['count'];
278
+    }
278 279
 
279 280
     $cart = $this->ecommerce->getCurCart();
280 281
     $stages = Ecommerce\Cart\Stage::getList();
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.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -10,146 +10,146 @@  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
-          $error = true;
58
-          //Tools::redirect('/ecommerce', 'Ваша корзина пуста');
57
+            $error = true;
58
+            //Tools::redirect('/ecommerce', 'Ваша корзина пуста');
59 59
         }
60 60
         if (empty($this->module->config['sell_over_warehouse'])) {
61
-          foreach ($cart->cartItems as $cartitem) {
61
+            foreach ($cart->cartItems as $cartitem) {
62 62
             $warecount = $cartitem->price->offer->warehouseCount($cart->id);
63 63
             if ($cartitem->count > $warecount) {
64
-              $error = true;
65
-              Msg::add('Вы заказали <b>' . $cartitem->item->name . '</b> больше чем есть на складе. на складе: <b>' . $warecount . '</b>', 'danger');
64
+                $error = true;
65
+                Msg::add('Вы заказали <b>' . $cartitem->item->name . '</b> больше чем есть на складе. на складе: <b>' . $warecount . '</b>', 'danger');
66
+            }
66 67
             }
67
-          }
68 68
         }
69 69
         if ($deliverys && empty($deliverys[$_POST['delivery']])) {
70
-          $error = 1;
71
-          Msg::add('Выберите способ доставки', 'danger');
70
+            $error = 1;
71
+            Msg::add('Выберите способ доставки', 'danger');
72 72
         } elseif ($deliverys && !empty($deliverys[$_POST['delivery']])) {
73
-          $cart->delivery_id = $_POST['delivery'];
74
-          foreach ($deliverys[$cart->delivery_id]->fields as $field) {
73
+            $cart->delivery_id = $_POST['delivery'];
74
+            foreach ($deliverys[$cart->delivery_id]->fields as $field) {
75 75
             if (empty($_POST['deliveryFields'][$field->id]) && $field->required) {
76
-              $error = 1;
77
-              Msg::add('Вы не указали: ' . $field->name, 'danger');
76
+                $error = 1;
77
+                Msg::add('Вы не указали: ' . $field->name, 'danger');
78
+            }
78 79
             }
79
-          }
80 80
         }
81 81
         if ($payTypes && (empty($_POST['payType']) || empty($payTypes[$_POST['payType']]))) {
82
-          $error = 1;
83
-          Msg::add('Выберите способ оплаты', 'danger');
82
+            $error = 1;
83
+            Msg::add('Выберите способ оплаты', 'danger');
84 84
         } elseif ($payTypes && !empty($payTypes[$_POST['payType']])) {
85
-          $payType = $payTypes[$_POST['payType']];
86
-          $cart->paytype_id = $payType->id;
85
+            $payType = $payTypes[$_POST['payType']];
86
+            $cart->paytype_id = $payType->id;
87 87
         } else {
88
-          $payType = null;
88
+            $payType = null;
89 89
         }
90 90
         foreach (\Ecommerce\UserAdds\Field::getList() as $field) {
91
-          if (empty($_POST['userAdds']['fields'][$field->id]) && $field->required) {
91
+            if (empty($_POST['userAdds']['fields'][$field->id]) && $field->required) {
92 92
             $error = 1;
93 93
             Msg::add('Вы не указали: ' . $field->name, 'danger');
94
-          }
94
+            }
95 95
         }
96 96
         if (!empty($_POST['discounts']['card_item_id'])) {
97
-          $userCard = \Ecommerce\Card\Item::get((int) $_POST['discounts']['card_item_id']);
98
-          if (!$userCard) {
97
+            $userCard = \Ecommerce\Card\Item::get((int) $_POST['discounts']['card_item_id']);
98
+            if (!$userCard) {
99 99
             $error = true;
100 100
             Msg::add('Такой карты не существует', 'danger');
101
-          } elseif ($userCard->user_id != $user->id) {
101
+            } elseif ($userCard->user_id != $user->id) {
102 102
             $error = true;
103 103
             Msg::add('Это не ваша карта', 'danger');
104
-          } else {
104
+            } else {
105 105
             $cart->card_item_id = $userCard->id;
106
-          }
106
+            }
107 107
         }
108 108
         $cart->save();
109 109
         if (!$error && !empty($_POST['action']) && $_POST['action'] = 'order') {
110
-          $cart->user_id = $user->user_id;
111
-          $this->module->parseFields($_POST['userAdds']['fields'], $cart);
112
-          if ($payTypes && !empty($payTypes[$cart->paytype_id]) && !empty($_POST['deliveryFields'])) {
110
+            $cart->user_id = $user->user_id;
111
+            $this->module->parseFields($_POST['userAdds']['fields'], $cart);
112
+            if ($payTypes && !empty($payTypes[$cart->paytype_id]) && !empty($_POST['deliveryFields'])) {
113 113
             $this->module->parseDeliveryFields($_POST['deliveryFields'], $cart, $deliverys[$cart->delivery_id]->fields);
114
-          }
115
-          $cart->cart_status_id = 2;
116
-          $cart->comment = !empty($_POST['comment']) ? htmlspecialchars($_POST['comment']) : '';
117
-          $cart->date_status = date('Y-m-d H:i:s');
118
-          $cart->complete_data = date('Y-m-d H:i:s');
119
-          $cart->warehouse_block = 1;
120
-          $cart->save();
114
+            }
115
+            $cart->cart_status_id = 2;
116
+            $cart->comment = !empty($_POST['comment']) ? htmlspecialchars($_POST['comment']) : '';
117
+            $cart->date_status = date('Y-m-d H:i:s');
118
+            $cart->complete_data = date('Y-m-d H:i:s');
119
+            $cart->warehouse_block = 1;
120
+            $cart->save();
121 121
 
122
-          $cart = \Ecommerce\Cart::get($cart->id);
123
-          foreach ($cart->cartItems as $cartItem) {
122
+            $cart = \Ecommerce\Cart::get($cart->id);
123
+            foreach ($cart->cartItems as $cartItem) {
124 124
             $cartItem->discount = $cartItem->discount();
125 125
             $cartItem->final_price = $cartItem->price->price - $cartItem->discount;
126 126
             $cartItem->save();
127
-          }
128
-          $cart = \Ecommerce\Cart::get($cart->id);
129
-          if (!empty(\App::$cur->ecommerce->config['notify_mail'])) {
127
+            }
128
+            $cart = \Ecommerce\Cart::get($cart->id);
129
+            if (!empty(\App::$cur->ecommerce->config['notify_mail'])) {
130 130
             $text = 'Перейдите в админ панель чтобы просмотреть новый заказ <a href = "http://' . idn_to_utf8(INJI_DOMAIN_NAME) . '/admin/ecommerce/Cart">Админ панель</a>';
131 131
             $title = 'Новый заказ в интернет магазине на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME);
132 132
             \Tools::sendMail('noreply@' . INJI_DOMAIN_NAME, \App::$cur->ecommerce->config['notify_mail'], $title, $text);
133
-          }
134
-          if ($this->notifications) {
133
+            }
134
+            if ($this->notifications) {
135 135
             $notification = new Notifications\Notification();
136 136
             $notification->name = 'Новый заказ в интернет магазине на сайте ' . idn_to_utf8(INJI_DOMAIN_NAME);
137 137
             $notification->text = 'Перейдите в админ панель чтобы просмотреть новый заказ';
138 138
             $notification->chanel_id = $this->notifications->getChanel('Ecommerce-orders')->id;
139 139
             $notification->save();
140
-          }
141
-          $handlers = $this->ecommerce->getSnippets('payTypeHandler');
142
-          $redirect = ['/ecommerce/cart/success'];
143
-          if ($payType && !empty($handlers[$payType->handler]['handler'])) {
140
+            }
141
+            $handlers = $this->ecommerce->getSnippets('payTypeHandler');
142
+            $redirect = ['/ecommerce/cart/success'];
143
+            if ($payType && !empty($handlers[$payType->handler]['handler'])) {
144 144
             $newRedirect = $handlers[$payType->handler]['handler']($cart);
145 145
             if (!empty($newRedirect)) {
146
-              $redirect = $newRedirect;
146
+                $redirect = $newRedirect;
147
+            }
147 148
             }
148
-          }
149
-          unset($_SESSION['cart']['cart_id']);
150
-          call_user_func_array(['Tools', 'redirect'], $redirect);
149
+            unset($_SESSION['cart']['cart_id']);
150
+            call_user_func_array(['Tools', 'redirect'], $redirect);
151
+        }
151 152
         }
152
-      }
153 153
     }
154 154
     $this->view->setTitle('Корзина');
155 155
     $bread = [];
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
         'href' => '/ecommerce/cart'
163 163
     ];
164 164
     $this->view->page(['data' => compact('cart', 'items', 'deliverys', 'payTypes', 'packItem', 'bread')]);
165
-  }
165
+    }
166 166
 
167
-  public function orderDetailAction($id = 0) {
167
+    public function orderDetailAction($id = 0) {
168 168
     $cart = Ecommerce\Cart::get((int) $id);
169 169
     if ($cart->user_id != Users\User::$cur->id) {
170
-      $this->url->redirect('/', 'Это не ваша корзина');
170
+        $this->url->redirect('/', 'Это не ваша корзина');
171 171
     }
172 172
     $bread[] = [
173 173
         'text' => 'Каталог',
@@ -183,54 +183,54 @@  discard block
 block discarded – undo
183 183
     ];
184 184
     $this->view->setTitle('Заказ №' . $cart->id);
185 185
     $this->view->page(['data' => compact('cart', 'bread')]);
186
-  }
186
+    }
187 187
 
188
-  public function continueAction($id = 0) {
188
+    public function continueAction($id = 0) {
189 189
     $cart = \Ecommerce\Cart::get((int) $id);
190 190
     if ($cart->user_id != Users\User::$cur->id) {
191
-      Tools::redirect('/', 'Это не ваша корзина');
191
+        Tools::redirect('/', 'Это не ваша корзина');
192 192
     }
193 193
     if ($cart->cart_status_id > 1) {
194
-      Tools::redirect('/', 'Корзина уже оформлена');
194
+        Tools::redirect('/', 'Корзина уже оформлена');
195 195
     }
196 196
     $_SESSION['cart']['cart_id'] = $cart->id;
197 197
     Tools::redirect('/ecommerce/cart');
198
-  }
198
+    }
199 199
 
200
-  public function deleteAction($id = 0) {
200
+    public function deleteAction($id = 0) {
201 201
     $cart = \Ecommerce\Cart::get((int) $id);
202 202
     if ($cart->user_id != Users\User::$cur->id) {
203
-      Tools::redirect('/', 'Это не ваша корзина');
203
+        Tools::redirect('/', 'Это не ваша корзина');
204 204
     }
205 205
     if ($cart->cart_status_id > 1) {
206
-      Tools::redirect('/', 'Корзина уже оформлена');
206
+        Tools::redirect('/', 'Корзина уже оформлена');
207 207
     }
208 208
     if (!empty($_SESSION['cart']['cart_id']) && $_SESSION['cart']['cart_id'] == $cart->id) {
209
-      unset($_SESSION['cart']['cart_id']);
209
+        unset($_SESSION['cart']['cart_id']);
210 210
     }
211 211
     $cart->delete();
212 212
     Tools::redirect('/users/cabinet/ecommerceOrdersHistory', 'Корзина была удалена', 'success');
213
-  }
213
+    }
214 214
 
215
-  public function refillAction($id = 0) {
215
+    public function refillAction($id = 0) {
216 216
     $cart = \Ecommerce\Cart::get((int) $id);
217 217
     if ($cart->user_id != Users\User::$cur->id) {
218
-      Tools::redirect('/', 'Это не ваша корзина');
218
+        Tools::redirect('/', 'Это не ваша корзина');
219 219
     }
220 220
     if (!empty($_SESSION['cart']['cart_id'])) {
221
-      unset($_SESSION['cart']['cart_id']);
221
+        unset($_SESSION['cart']['cart_id']);
222 222
     }
223 223
     $newCart = $this->ecommerce->getCurCart();
224 224
     foreach ($cart->cartItems as $cartitem) {
225
-      $newCart->addItem($cartitem->item_offer_price_id, $cartitem->count);
225
+        $newCart->addItem($cartitem->item_offer_price_id, $cartitem->count);
226 226
     }
227 227
 
228 228
     $newCart->save();
229 229
 
230 230
     Tools::redirect('/ecommerce/cart/');
231
-  }
231
+    }
232 232
 
233
-  public function successAction() {
233
+    public function successAction() {
234 234
     $bread = [];
235 235
     $bread[] = [
236 236
         'text' => 'Каталог',
@@ -246,70 +246,70 @@  discard block
 block discarded – undo
246 246
     ];
247 247
     $this->view->setTitle('Заказ принят');
248 248
     $this->view->page(['data' => compact('bread')]);
249
-  }
249
+    }
250 250
 
251
-  public function addAction() {
251
+    public function addAction() {
252 252
     $result = new Server\Result();
253 253
     if (empty($_GET['itemOfferPriceId'])) {
254
-      $result->success = false;
255
-      $result->content = 'Произошла непредвиденная ошибка при добавлении товара';
256
-      $result->send();
254
+        $result->success = false;
255
+        $result->content = 'Произошла непредвиденная ошибка при добавлении товара';
256
+        $result->send();
257 257
     }
258 258
     $price = \Ecommerce\Item\Offer\Price::get((int) $_GET['itemOfferPriceId']);
259 259
     if (!$price) {
260
-      $result->success = false;
261
-      $result->content = 'Такой цены не найдено';
262
-      $result->send();
260
+        $result->success = false;
261
+        $result->content = 'Такой цены не найдено';
262
+        $result->send();
263 263
     }
264 264
     $item = $price->offer->item;
265 265
 
266 266
     if (!$item) {
267
-      $result->success = false;
268
-      $result->content = 'Такого товара не существует';
269
-      $result->send();
267
+        $result->success = false;
268
+        $result->content = 'Такого товара не существует';
269
+        $result->send();
270 270
     }
271 271
 
272 272
     $item->sales ++;
273 273
     $item->save();
274 274
 
275 275
     if (empty($_GET['count']))
276
-      $count = 1;
276
+        $count = 1;
277 277
     else
278
-      $count = (float) $_GET['count'];
278
+        $count = (float) $_GET['count'];
279 279
 
280 280
     $cart = $this->ecommerce->getCurCart();
281 281
     $stages = Ecommerce\Cart\Stage::getList();
282 282
     if (empty($this->module->config['sell_over_warehouse']) && $price->offer->warehouseCount() < $count) {
283
-      $result->success = false;
284
-      $result->content = 'На складе недостаточно товара! Доступно: ' . $price->offer->warehouseCount();
285
-      $result->send();
283
+        $result->success = false;
284
+        $result->content = 'На складе недостаточно товара! Доступно: ' . $price->offer->warehouseCount();
285
+        $result->send();
286 286
     }
287 287
 
288 288
     $isset = false;
289 289
     foreach ($cart->cartItems as $cartItem) {
290
-      if ($cartItem->item_id == $item->id && $cartItem->item_offer_price_id == $price->id) {
290
+        if ($cartItem->item_id == $item->id && $cartItem->item_offer_price_id == $price->id) {
291 291
         $cartItem->count += $count;
292 292
         $cartItem->save();
293 293
         $isset = true;
294 294
         break;
295
-      }
295
+        }
296 296
     }
297 297
     if (!$isset) {
298
-      $cart->addItem($price->id, $count);
298
+        $cart->addItem($price->id, $count);
299 299
     }
300 300
     $cart->date_last_activ = date('Y-m-d H:i:s');
301 301
     $cart->calc();
302 302
     $result->successMsg = '<a href="/ecommerce/view/' . $item->id . '">' . $item->name() . ($price->offer->name() ? ' (' . $price->offer->name() . ')' : '') . '</a> добавлен <a href="/ecommerce/cart">в корзину покупок</a>!';
303 303
     $result->send();
304
-  }
304
+    }
305 305
 
306
-  public function getcartAction() {
306
+    public function getcartAction() {
307 307
     $result = new Server\Result();
308 308
     ob_start();
309 309
     $this->view->widget('Ecommerce\cart');
310 310
     $result->content = ob_get_contents();
311 311
     ob_end_clean();
312 312
     $result->send();
313
-  }
313
+    }
314 314
 
315 315
 }
Please login to merge, or discard this patch.
system/modules/Ecommerce/widgets/cart/delivery.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -2,57 +2,57 @@
 block discarded – undo
2 2
   <div class="col-md-4">
3 3
     <ul class="nav nav-pills nav-stacked">
4 4
       <?php
5
-      $hiddenId = Tools::randomString();
6
-      foreach ($deliverys as $delivery) {
5
+        $hiddenId = Tools::randomString();
6
+        foreach ($deliverys as $delivery) {
7 7
         if ((!empty($_POST['delivery']) && $_POST['delivery'] == $delivery->id) || ($cart->delivery && $delivery->id == $cart->delivery->id)) {
8
-          $checked = 'checked';
8
+            $checked = 'checked';
9 9
         } else {
10
-          $checked = '';
10
+            $checked = '';
11 11
         }
12 12
         echo '<li' . ($checked ? ' class="active"' : '') . '><a href = "#" onclick = "document.getElementById(\'' . $hiddenId . '\').value=\'' . $delivery->id . '\';inji.Ecommerce.Cart.calcSum();return false;">';
13 13
         echo $delivery->name;
14 14
         echo '</a></li>';
15
-      }
16
-      $form->input('hidden', "delivery", '', [
17
-          'value' => $cart->delivery_id,
18
-          'attributes' => [
19
-              'id' => $hiddenId
20
-          ],
21
-      ]);
22
-      ?>
15
+        }
16
+        $form->input('hidden', "delivery", '', [
17
+            'value' => $cart->delivery_id,
18
+            'attributes' => [
19
+                'id' => $hiddenId
20
+            ],
21
+        ]);
22
+        ?>
23 23
     </ul>
24 24
   </div>
25 25
   <div class="col-md-8">
26 26
     <?php
27 27
     if ($cart->delivery) {
28
-      echo "<h4>Информация о доставке</h4>";
29
-      if ($cart->delivery->price_text || $cart->delivery->price) {
28
+        echo "<h4>Информация о доставке</h4>";
29
+        if ($cart->delivery->price_text || $cart->delivery->price) {
30 30
         echo "<div>Стоимость доставки: <b>" . ($cart->delivery->price_text ? $cart->delivery->price_text : ( $cart->delivery->price . ' ' . ($cart->delivery->currency ? $cart->delivery->currency->acronym() : 'руб.') )) . '</b></div>';
31
-      }
32
-      if ((float) $cart->delivery->max_cart_price) {
31
+        }
32
+        if ((float) $cart->delivery->max_cart_price) {
33 33
         echo '<div>При заказе товаров на сумму от ' . $cart->delivery->max_cart_price . ' руб - бесплатно</div>';
34
-      }
35
-      echo $cart->delivery->info;
36
-      if ($cart->delivery->fields) {
34
+        }
35
+        echo $cart->delivery->info;
36
+        if ($cart->delivery->fields) {
37 37
         echo '<hr />';
38 38
         foreach ($cart->delivery->fields as $field) {
39
-          $options = ['required' => $field->required];
40
-          if ($field->type == 'radio') {
39
+            $options = ['required' => $field->required];
40
+            if ($field->type == 'radio') {
41 41
             $values = $field->fieldItems(['forSelect' => true]);
42 42
             foreach ($values as $key => $value) {
43
-              $options['value'] = $key;
44
-              $form->input($field->type, "deliveryFields[{$field->id}]", $value, $options);
43
+                $options['value'] = $key;
44
+                $form->input($field->type, "deliveryFields[{$field->id}]", $value, $options);
45 45
             }
46
-          } else {
46
+            } else {
47 47
             if ($field->type == 'select') {
48
-              $options['values'] = $field->fieldItems(['forSelect' => true]);
48
+                $options['values'] = $field->fieldItems(['forSelect' => true]);
49 49
             }
50 50
             $form->input($field->type, "deliveryFields[{$field->id}]", $field->name, $options);
51
-          }
51
+            }
52
+        }
52 53
         }
53
-      }
54 54
     } else {
55
-      echo "<h4>Выберите способ доставки</h4>";
55
+        echo "<h4>Выберите способ доставки</h4>";
56 56
     }
57 57
     ?>
58 58
   </div>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
         } else {
10 10
           $checked = '';
11 11
         }
12
-        echo '<li' . ($checked ? ' class="active"' : '') . '><a href = "#" onclick = "document.getElementById(\'' . $hiddenId . '\').value=\'' . $delivery->id . '\';inji.Ecommerce.Cart.calcSum();return false;">';
12
+        echo '<li'.($checked ? ' class="active"' : '').'><a href = "#" onclick = "document.getElementById(\''.$hiddenId.'\').value=\''.$delivery->id.'\';inji.Ecommerce.Cart.calcSum();return false;">';
13 13
         echo $delivery->name;
14 14
         echo '</a></li>';
15 15
       }
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
     if ($cart->delivery) {
28 28
       echo "<h4>Информация о доставке</h4>";
29 29
       if ($cart->delivery->price_text || $cart->delivery->price) {
30
-        echo "<div>Стоимость доставки: <b>" . ($cart->delivery->price_text ? $cart->delivery->price_text : ( $cart->delivery->price . ' ' . ($cart->delivery->currency ? $cart->delivery->currency->acronym() : 'руб.') )) . '</b></div>';
30
+        echo "<div>Стоимость доставки: <b>".($cart->delivery->price_text ? $cart->delivery->price_text : ($cart->delivery->price.' '.($cart->delivery->currency ? $cart->delivery->currency->acronym() : 'руб.'))).'</b></div>';
31 31
       }
32 32
       if ((float) $cart->delivery->max_cart_price) {
33
-        echo '<div>При заказе товаров на сумму от ' . $cart->delivery->max_cart_price . ' руб - бесплатно</div>';
33
+        echo '<div>При заказе товаров на сумму от '.$cart->delivery->max_cart_price.' руб - бесплатно</div>';
34 34
       }
35 35
       echo $cart->delivery->info;
36 36
       if ($cart->delivery->fields) {
Please login to merge, or discard this patch.
system/modules/Ecommerce/models/Cart.php 2 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
 class Cart extends \Model {
15 15
 
16
-  public static $objectName = 'Корзины';
16
+    public static $objectName = 'Корзины';
17 17
 
18
-  public static function indexes() {
18
+    public static function indexes() {
19 19
     return [
20 20
         'ecommerce_cartStatusBlock' => [
21 21
             'type' => 'INDEX',
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
             ]
38 38
         ],
39 39
     ];
40
-  }
40
+    }
41 41
 
42
-  public static function relations() {
42
+    public static function relations() {
43 43
     return [
44 44
         'user' => [
45 45
             'model' => 'Users\User',
@@ -97,279 +97,279 @@  discard block
 block discarded – undo
97 97
             'model' => 'Ecommerce\Discount',
98 98
         ]
99 99
     ];
100
-  }
100
+    }
101 101
 
102
-  public function beforeDelete() {
102
+    public function beforeDelete() {
103 103
     foreach ($this->cartItems as $cartItem) {
104
-      $cartItem->delete();
104
+        $cartItem->delete();
105 105
     }
106 106
     foreach ($this->infos as $info) {
107
-      $info->delete();
107
+        $info->delete();
108 108
     }
109 109
     foreach ($this->extras as $extra) {
110
-      $extra->delete();
110
+        $extra->delete();
111 111
     }
112 112
     foreach ($this->events as $event) {
113
-      $event->delete();
113
+        $event->delete();
114
+    }
114 115
     }
115
-  }
116 116
 
117
-  public static $labels = [
118
-      'user_id' => 'Пользователь',
119
-      'cart_status_id' => 'Статус',
120
-      'delivery_id' => 'Доставка',
121
-      'comment' => 'Комментарий',
122
-      'bonus_used' => 'Выгодные рубли',
123
-      'complete_data' => 'Время заказа',
124
-      'info' => 'Информация',
125
-      'items' => 'Товары',
126
-      'paytype_id' => 'Способ оплаты',
127
-      'payed' => 'Оплачен',
128
-      'exported' => 'Выгружено',
129
-      'warehouse_block' => 'Блокировка товаров',
130
-      'extra' => 'Доп.',
131
-      'card_item_id' => 'Дисконтная карта',
132
-      'info' => 'Информация',
133
-      'contacts' => 'Информация',
134
-      'pay' => 'Счета',
135
-      'sums' => 'Суммы',
136
-      'deliveryInfo' => 'Для доставки',
137
-      'discount' => 'Скидки',
138
-  ];
139
-  public static $cols = [
140
-      //Основные параметры
141
-      'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
142
-      'cart_status_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'status'],
143
-      'delivery_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'delivery'],
144
-      'paytype_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'payType'],
145
-      'card_item_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'card'],
146
-      'warehouse_block' => ['type' => 'bool'],
147
-      'payed' => ['type' => 'bool'],
148
-      'comment' => ['type' => 'textarea'],
149
-      //Системные
150
-      'exported' => ['type' => 'bool'],
151
-      'complete_data' => ['type' => 'dateTime'],
152
-      'date_status' => ['type' => 'dateTime'],
153
-      'date_last_activ' => ['type' => 'dateTime'],
154
-      'date_create' => ['type' => 'dateTime'],
155
-      //Виджеты
156
-      'sums' => [
157
-          'type' => 'void',
158
-          'view' => [
159
-              'type' => 'widget',
160
-              'widget' => 'Ecommerce\adminSums',
161
-          ],
162
-      ],
163
-      'contacts' => [
164
-          'type' => 'void',
165
-          'view' => [
166
-              'type' => 'widget',
167
-              'widget' => 'Ecommerce\admin/contacts',
168
-          ],
169
-      ],
170
-      //Менеджеры
171
-      'extra' => ['type' => 'dataManager', 'relation' => 'extras'],
172
-      'pay' => ['type' => 'dataManager', 'relation' => 'pays'],
173
-      'items' => ['type' => 'dataManager', 'relation' => 'cartItems'],
174
-      'info' => ['type' => 'dataManager', 'relation' => 'infos'],
175
-      'deliveryInfo' => ['type' => 'dataManager', 'relation' => 'deliveryInfos'],
176
-      'discount' => ['type' => 'dataManager', 'relation' => 'discounts'],
177
-  ];
178
-  public static $dataManagers = [
179
-      'manager' => [
180
-          'cols' => [
181
-              'contacts',
182
-              'items',
183
-              'extra',
184
-              'discount',
185
-              'sums',
186
-              'cart_status_id',
187
-              'delivery_id',
188
-              'deliveryInfo',
189
-              'payed',
190
-              'pay',
191
-              'complete_data',
192
-          ],
193
-          'sortable' => [
194
-              'cart_status_id',
195
-              'delivery_id',
196
-              'payed',
197
-              'complete_data',
198
-          ],
199
-          'filters' => [
200
-              'cart_status_id',
201
-              'delivery_id',
202
-              'payed',
203
-              'complete_data',
204
-          ],
205
-          'preSort' => [
206
-              'complete_data' => 'desc'
207
-          ],
208
-          'actions' => [
209
-              'Ecommerce\CloseCartBtn', 'Open', 'Edit', 'Delete'
210
-          ]
211
-      ]
212
-  ];
117
+    public static $labels = [
118
+        'user_id' => 'Пользователь',
119
+        'cart_status_id' => 'Статус',
120
+        'delivery_id' => 'Доставка',
121
+        'comment' => 'Комментарий',
122
+        'bonus_used' => 'Выгодные рубли',
123
+        'complete_data' => 'Время заказа',
124
+        'info' => 'Информация',
125
+        'items' => 'Товары',
126
+        'paytype_id' => 'Способ оплаты',
127
+        'payed' => 'Оплачен',
128
+        'exported' => 'Выгружено',
129
+        'warehouse_block' => 'Блокировка товаров',
130
+        'extra' => 'Доп.',
131
+        'card_item_id' => 'Дисконтная карта',
132
+        'info' => 'Информация',
133
+        'contacts' => 'Информация',
134
+        'pay' => 'Счета',
135
+        'sums' => 'Суммы',
136
+        'deliveryInfo' => 'Для доставки',
137
+        'discount' => 'Скидки',
138
+    ];
139
+    public static $cols = [
140
+        //Основные параметры
141
+        'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
142
+        'cart_status_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'status'],
143
+        'delivery_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'delivery'],
144
+        'paytype_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'payType'],
145
+        'card_item_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'card'],
146
+        'warehouse_block' => ['type' => 'bool'],
147
+        'payed' => ['type' => 'bool'],
148
+        'comment' => ['type' => 'textarea'],
149
+        //Системные
150
+        'exported' => ['type' => 'bool'],
151
+        'complete_data' => ['type' => 'dateTime'],
152
+        'date_status' => ['type' => 'dateTime'],
153
+        'date_last_activ' => ['type' => 'dateTime'],
154
+        'date_create' => ['type' => 'dateTime'],
155
+        //Виджеты
156
+        'sums' => [
157
+            'type' => 'void',
158
+            'view' => [
159
+                'type' => 'widget',
160
+                'widget' => 'Ecommerce\adminSums',
161
+            ],
162
+        ],
163
+        'contacts' => [
164
+            'type' => 'void',
165
+            'view' => [
166
+                'type' => 'widget',
167
+                'widget' => 'Ecommerce\admin/contacts',
168
+            ],
169
+        ],
170
+        //Менеджеры
171
+        'extra' => ['type' => 'dataManager', 'relation' => 'extras'],
172
+        'pay' => ['type' => 'dataManager', 'relation' => 'pays'],
173
+        'items' => ['type' => 'dataManager', 'relation' => 'cartItems'],
174
+        'info' => ['type' => 'dataManager', 'relation' => 'infos'],
175
+        'deliveryInfo' => ['type' => 'dataManager', 'relation' => 'deliveryInfos'],
176
+        'discount' => ['type' => 'dataManager', 'relation' => 'discounts'],
177
+    ];
178
+    public static $dataManagers = [
179
+        'manager' => [
180
+            'cols' => [
181
+                'contacts',
182
+                'items',
183
+                'extra',
184
+                'discount',
185
+                'sums',
186
+                'cart_status_id',
187
+                'delivery_id',
188
+                'deliveryInfo',
189
+                'payed',
190
+                'pay',
191
+                'complete_data',
192
+            ],
193
+            'sortable' => [
194
+                'cart_status_id',
195
+                'delivery_id',
196
+                'payed',
197
+                'complete_data',
198
+            ],
199
+            'filters' => [
200
+                'cart_status_id',
201
+                'delivery_id',
202
+                'payed',
203
+                'complete_data',
204
+            ],
205
+            'preSort' => [
206
+                'complete_data' => 'desc'
207
+            ],
208
+            'actions' => [
209
+                'Ecommerce\CloseCartBtn', 'Open', 'Edit', 'Delete'
210
+            ]
211
+        ]
212
+    ];
213 213
 
214
-  public static function itemName($item) {
214
+    public static function itemName($item) {
215 215
     return $item->pk() . '. ' . $item->name();
216
-  }
216
+    }
217 217
 
218
-  public static $forms = [
219
-      'manager' => [
220
-          'inputs' => [
221
-              'userSearch' => [
222
-                  'type' => 'search',
223
-                  'source' => 'relation',
224
-                  'relation' => 'user',
225
-                  'label' => 'Покупатель',
226
-                  'cols' => [
227
-                      'info:first_name',
228
-                      'info:last_name',
229
-                      'info:middle_name',
230
-                      'mail'
231
-                  ],
232
-                  'col' => 'user_id',
233
-                  'required' => true,
234
-                  'showCol' => [
235
-                      'type' => 'staticMethod',
236
-                      'class' => 'Ecommerce\Cart',
237
-                      'method' => 'itemName',
238
-                  ],
239
-              ],
240
-              'cardSearch' => [
241
-                  'type' => 'search',
242
-                  'source' => 'relation',
243
-                  'relation' => 'card',
244
-                  'label' => 'Дисконтная карта',
245
-                  'cols' => [
246
-                      'code',
247
-                      'user:info:first_name',
248
-                      'user:info:last_name',
249
-                      'user:info:middle_name',
250
-                      'user:mail'
251
-                  ],
252
-                  'col' => 'card_item_id',
253
-              ],
254
-          ],
255
-          'map' => [
256
-              ['userSearch', 'cart_status_id'],
257
-              ['paytype_id', 'delivery_id'],
258
-              ['cardSearch', 'comment'],
259
-              ['warehouse_block', 'complete_data'],
260
-              ['payed'],
261
-              ['items'],
262
-              ['extra'],
263
-              ['pay'],
264
-              ['info'],
265
-              ['deliveryInfo']
266
-          ]
267
-      ],
268
-  ];
218
+    public static $forms = [
219
+        'manager' => [
220
+            'inputs' => [
221
+                'userSearch' => [
222
+                    'type' => 'search',
223
+                    'source' => 'relation',
224
+                    'relation' => 'user',
225
+                    'label' => 'Покупатель',
226
+                    'cols' => [
227
+                        'info:first_name',
228
+                        'info:last_name',
229
+                        'info:middle_name',
230
+                        'mail'
231
+                    ],
232
+                    'col' => 'user_id',
233
+                    'required' => true,
234
+                    'showCol' => [
235
+                        'type' => 'staticMethod',
236
+                        'class' => 'Ecommerce\Cart',
237
+                        'method' => 'itemName',
238
+                    ],
239
+                ],
240
+                'cardSearch' => [
241
+                    'type' => 'search',
242
+                    'source' => 'relation',
243
+                    'relation' => 'card',
244
+                    'label' => 'Дисконтная карта',
245
+                    'cols' => [
246
+                        'code',
247
+                        'user:info:first_name',
248
+                        'user:info:last_name',
249
+                        'user:info:middle_name',
250
+                        'user:mail'
251
+                    ],
252
+                    'col' => 'card_item_id',
253
+                ],
254
+            ],
255
+            'map' => [
256
+                ['userSearch', 'cart_status_id'],
257
+                ['paytype_id', 'delivery_id'],
258
+                ['cardSearch', 'comment'],
259
+                ['warehouse_block', 'complete_data'],
260
+                ['payed'],
261
+                ['items'],
262
+                ['extra'],
263
+                ['pay'],
264
+                ['info'],
265
+                ['deliveryInfo']
266
+            ]
267
+        ],
268
+    ];
269 269
 
270
-  public function checkStage() {
270
+    public function checkStage() {
271 271
     $sum = $this->itemsSum();
272 272
     $stages = Cart\Stage::getList(['order' => ['sum', 'asc']]);
273 273
     $groups = [];
274 274
     foreach ($stages as $stage) {
275
-      if ($sum->greater(new \Money\Sums([$stage->currency_id => $stage->sum])) || $sum->equal(new \Money\Sums([$stage->currency_id => $stage->sum]))) {
275
+        if ($sum->greater(new \Money\Sums([$stage->currency_id => $stage->sum])) || $sum->equal(new \Money\Sums([$stage->currency_id => $stage->sum]))) {
276 276
         $groups[$stage->group] = $stage;
277
-      }
277
+        }
278 278
     }
279 279
     $discounts = Cart\Discount::getList(['where' => ['cart_id', $this->id]]);
280 280
     foreach ($discounts as $discount) {
281
-      if (!isset($groups[$discount->group]) && $discount->auto) {
281
+        if (!isset($groups[$discount->group]) && $discount->auto) {
282 282
         $discount->delete();
283
-      }
284
-      if (isset($groups[$discount->group]) && $groups[$discount->group]->type == 'discount') {
283
+        }
284
+        if (isset($groups[$discount->group]) && $groups[$discount->group]->type == 'discount') {
285 285
         $discount->discount_id = $groups[$discount->group]->value;
286 286
         $discount->save();
287 287
         unset($groups[$discount->group]);
288
-      }
288
+        }
289 289
     }
290 290
     foreach ($groups as $group) {
291
-      if ($group && $group->type == 'discount') {
291
+        if ($group && $group->type == 'discount') {
292 292
         $rel = $this->addRelation('discounts', $group->value);
293 293
         $rel->auto = true;
294 294
         $rel->group = 'discount';
295 295
         $rel->save();
296
-      }
296
+        }
297
+    }
297 298
     }
298
-  }
299 299
 
300
-  public function needDelivery() {
300
+    public function needDelivery() {
301 301
     foreach ($this->cartItems as $cartItem) {
302
-      if ($cartItem->item->type && $cartItem->item->type->delivery) {
302
+        if ($cartItem->item->type && $cartItem->item->type->delivery) {
303 303
         return true;
304
-      }
304
+        }
305 305
     }
306 306
     return false;
307
-  }
307
+    }
308 308
 
309
-  public function deliverySum() {
309
+    public function deliverySum() {
310 310
     $sum = new \Money\Sums([]);
311 311
     if ($this->delivery && $this->needDelivery()) {
312
-      $sums = $this->itemsSum();
313
-      $deliveryPrice = new \Money\Sums([$this->delivery->currency_id => $this->delivery->max_cart_price]);
314
-      if ($this->delivery->max_cart_price && $sums->greater($deliveryPrice) || $sums->equal($deliveryPrice)) {
312
+        $sums = $this->itemsSum();
313
+        $deliveryPrice = new \Money\Sums([$this->delivery->currency_id => $this->delivery->max_cart_price]);
314
+        if ($this->delivery->max_cart_price && $sums->greater($deliveryPrice) || $sums->equal($deliveryPrice)) {
315 315
         $sum->sums = [$this->delivery->currency_id => 0];
316
-      } else if ($this->delivery->prices) {
316
+        } else if ($this->delivery->prices) {
317 317
         foreach ($this->delivery->prices(['order' => ['cart_price', 'asc']]) as $delPrice) {
318
-          $deliveryPrice = new \Money\Sums([$delPrice->currency_id => $delPrice->cart_price]);
319
-          if ($sums->greater($deliveryPrice) || $sums->equal($deliveryPrice)) {
318
+            $deliveryPrice = new \Money\Sums([$delPrice->currency_id => $delPrice->cart_price]);
319
+            if ($sums->greater($deliveryPrice) || $sums->equal($deliveryPrice)) {
320 320
             $sum->sums = [$delPrice->currency_id => $delPrice->price];
321
-          }
321
+            }
322 322
         }
323 323
         if (!$sum->sums) {
324
-          $sum->sums = [$this->delivery->currency_id => $this->delivery->price];
324
+            $sum->sums = [$this->delivery->currency_id => $this->delivery->price];
325 325
         }
326
-      } else {
326
+        } else {
327 327
         $sum->sums = [$this->delivery->currency_id => $this->delivery->price];
328
-      }
328
+        }
329 329
     }
330 330
     return $sum;
331
-  }
331
+    }
332 332
 
333
-  public function hasDiscount() {
333
+    public function hasDiscount() {
334 334
     return (bool) $this->card || $this->discounts;
335
-  }
335
+    }
336 336
 
337
-  public function discountSum() {
337
+    public function discountSum() {
338 338
     $sums = [];
339 339
     foreach ($this->cartItems as $cartItem) {
340
-      $sums[$cartItem->price->currency_id] = isset($sums[$cartItem->price->currency_id]) ? $sums[$cartItem->price->currency_id] + $cartItem->discount() * $cartItem->count : $cartItem->discount() * $cartItem->count;
340
+        $sums[$cartItem->price->currency_id] = isset($sums[$cartItem->price->currency_id]) ? $sums[$cartItem->price->currency_id] + $cartItem->discount() * $cartItem->count : $cartItem->discount() * $cartItem->count;
341 341
     }
342 342
     return new \Money\Sums($sums);
343
-  }
343
+    }
344 344
 
345
-  public function finalSum() {
345
+    public function finalSum() {
346 346
     $sums = $this->itemsSum();
347 347
     $sums = $sums->minus($this->discountSum());
348 348
     $sums = $sums->plus($this->deliverySum());
349 349
     return $sums;
350
-  }
350
+    }
351 351
 
352
-  public function itemsSum() {
352
+    public function itemsSum() {
353 353
     $cart = Cart::get($this->id);
354 354
     $sums = [];
355 355
     foreach ($cart->cartItems as $cartItem) {
356
-      if (!$cartItem->price) {
356
+        if (!$cartItem->price) {
357 357
         continue;
358
-      }
359
-      $sums[$cartItem->price->currency_id] = isset($sums[$cartItem->price->currency_id]) ? $sums[$cartItem->price->currency_id] + $cartItem->price->price * $cartItem->count : $cartItem->price->price * $cartItem->count;
358
+        }
359
+        $sums[$cartItem->price->currency_id] = isset($sums[$cartItem->price->currency_id]) ? $sums[$cartItem->price->currency_id] + $cartItem->price->price * $cartItem->count : $cartItem->price->price * $cartItem->count;
360 360
     }
361 361
     return new \Money\Sums($sums);
362
-  }
362
+    }
363 363
 
364
-  public function addItem($offer_price_id, $count = 1, $final_price = 0) {
364
+    public function addItem($offer_price_id, $count = 1, $final_price = 0) {
365 365
     $price = Item\Offer\Price::get((int) $offer_price_id);
366 366
 
367 367
     if (!$price) {
368
-      return false;
368
+        return false;
369 369
     }
370 370
 
371 371
     if ($count <= 0) {
372
-      $count = 1;
372
+        $count = 1;
373 373
     }
374 374
 
375 375
     $cartItem = new Cart\Item();
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
     $cartItem->final_price = $final_price ? $final_price : $price->price;
381 381
     $cartItem->save();
382 382
     return true;
383
-  }
383
+    }
384 384
 
385
-  public function calc($save = true) {
385
+    public function calc($save = true) {
386 386
     if ($save) {
387
-      $this->save();
387
+        $this->save();
388
+    }
388 389
     }
389
-  }
390 390
 
391 391
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@
 block discarded – undo
212 212
   ];
213 213
 
214 214
   public static function itemName($item) {
215
-    return $item->pk() . '. ' . $item->name();
215
+    return $item->pk().'. '.$item->name();
216 216
   }
217 217
 
218 218
   public static $forms = [
Please login to merge, or discard this patch.