Issues (1519)

system/modules/Geography/info.php (5 issues)

1
<?php
2
return [
3
    'name' => 'География',
4
    'autoload' => true,
5
    'widgets' => [
6
        'Geography\cityData' => [
7
            'name' => 'Вариатор данных по городам',
8
            'params' => function() {
9
                App::$cur->Ui;
10
                \App::$cur->libs->loadLib('ckeditor');
11
                $dataSets = Geography\City\Data::getList(['order' => ['code']]);
12
                ?>
13
                <div class="form-group">
14
                    <label>Группа данных</label>
15
                    <select class ="form-control groupSelect" onchange="changeGroupSelect(this);">
16
                        <option value = 0>Выберите группу</option>
17
                        <?php
18
                        $isset = [];
19
                        $datas = [];
20
                        foreach ($dataSets as $set) {
21
                            $datas[$set->code][$set->city_id] = $set->data;
0 ignored issues
show
Bug Best Practice introduced by
The property code does not exist on Inji\Model. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property city_id does not exist on Inji\Model. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property data does not exist on Inji\Model. Since you implemented __get, consider adding a @property annotation.
Loading history...
22
                            if (empty($isset[$set->code])) {
23
                                $isset[$set->code] = true;
24
                                echo "<option value = '{$set->code}'>{$set->code}</option>";
25
                            }
26
                        }
27
                        ?>
28
                        <option value = -1>Создать</option>
29
                    </select>
30
                </div>
31
                <script>
32
                    var changerData = <?= json_encode($datas); ?>;
33
                    function changeGroupSelect(select) {
34
                      var val = $(select).val();
35
                      if (val == "-1") {
36
                        $(this).data('skip', 1);
37
                        $('.newGroup').css('display', 'block');
38
                        $('.newGroup .form-control').data('skip', 0);
39
                      } else {
40
                        $(this).data('skip', 0);
41
                        $('.newGroup').css('display', 'none');
42
                        $('.newGroup .form-control').data('skip', 1);
43
                      }
44
                    }
45
                    function changeCitySelect(select) {
46
                      var instance = $('#params_Geography-cityData .htmleditor').next().attr('id').replace('cke_', '');
47
                      var data = '';
48
                      if ($('.groupSelect').data('skip') == 1) {
49
                        var group = $('.newGroup .form-control').val();
50
                      } else {
51
                        var group = $('.groupSelect').val();
52
                      }
53
                      var city = $('.citySelect .form-control').val();
54
55
                      if (changerData[group] && changerData[group][city]) {
56
                        data = changerData[group][city];
57
                      }
58
59
                      CKEDITOR.instances[instance].setData(data, function () {
60
                        CKEDITOR.instances[instance].updateElement();
61
                      });
62
                    }
63
                </script>
64
                <div class="form-group newGroup" style="display: none;">
65
                    <label>Код группы</label>
66
                    <input class="form-control" data-skip=1 />
67
                </div>
68
                <div class="form-group citySelect">
69
                    <label>Город</label>
70
                    <select class ="form-control" onchange="changeCitySelect(this);">
71
                        <option value = 0>Выберите город</option>
72
                        <?php
73
                        foreach (Geography\City::getList() as $city) {
74
                            echo "<option value = '{$city->id}'>{$city->name}</option>";
0 ignored issues
show
Bug Best Practice introduced by
The property name does not exist on Inji\Model. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property id does not exist on Inji\Model. Since you implemented __get, consider adding a @property annotation.
Loading history...
75
                        }
76
                        ?>
77
                    </select>
78
                </div>
79
                <div class="form-group">
80
                    <textarea class="htmleditor"></textarea>
81
                </div>
82
                <?php
83
            }
84
                ],
85
            ]
86
        ];
87