]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-282 Нужно сделать интерфейс настройки магазина
authormarina <m.zozirova@gmail.com>
Wed, 22 Jan 2025 08:31:16 +0000 (11:31 +0300)
committermarina <m.zozirova@gmail.com>
Wed, 22 Jan 2025 08:31:16 +0000 (11:31 +0300)
erp24/controllers/CityStoreParamsController.php
erp24/migrations/m250121_132357_create_matrix_type_and_store_type_table.php [new file with mode: 0644]
erp24/migrations/m250122_082641_add_new_column_on_city_store.php [new file with mode: 0644]
erp24/views/city-store-params/index.php
erp24/web/js/city-store-params/city-store-params.js

index cd2dcfc56e08dfe0ca119d33d7e9805624fadb1d..a3803326186772e2f368cef8e68083ff20bcadc1 100644 (file)
@@ -121,9 +121,11 @@ class CityStoreParamsController extends Controller
         $addressCity = $data['address_city'] ?? '';
         $addressRegion = $data['address_region'] ?? '';
         $addressDistrict = $data['address_district'] ?? '';
-        $territorialManager = $data['territorial_manager'] ?? '';
         $storeType = $data['store_type'] ?? '';
-        $bushChefFlorist = $data['bush_chef_florist'] ?? '';
+        //добавить колонки верхние
+
+        $territorialManager = $data['territorial_manager'] ?? ''; //номер куста
+        $bushChefFlorist = $data['bush_chef_florist'] ?? ''; //store-dynamic categore 2
 
         $stores = CityStore::find()
             ->andWhere(['=', 'visible', CityStore::IS_VISIBLE])
diff --git a/erp24/migrations/m250121_132357_create_matrix_type_and_store_type_table.php b/erp24/migrations/m250121_132357_create_matrix_type_and_store_type_table.php
new file mode 100644 (file)
index 0000000..13f06f0
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%matrix_type_and_store_type}}`.
+ */
+class m250121_132357_create_matrix_type_and_store_type_table extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $this->createTable('{{%matrix_type}}', [
+            'id' => $this->primaryKey(),
+            'name' => $this->string(255)->comment('Название типа матрицы')
+        ]);
+
+        $this->createTable('{{%store_type}}', [
+            'id' => $this->primaryKey(),
+            'name' => $this->string(255)->comment('Название типа магазина')
+        ]);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->dropTable('{{%matrix_type}}');
+        $this->dropTable('{{%store_type}}');
+    }
+}
diff --git a/erp24/migrations/m250122_082641_add_new_column_on_city_store.php b/erp24/migrations/m250122_082641_add_new_column_on_city_store.php
new file mode 100644 (file)
index 0000000..3ba4ff0
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m250122_082641_add_new_column_on_city_store
+ */
+class m250122_082641_add_new_column_on_city_store extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $this->addColumn('city_store', 'region', $this->integer()->comment('Регион'));
+        $this->addColumn('city_store', 'city', $this->integer()->comment('Город'));
+        $this->addColumn('city_store', 'district', $this->integer()->comment('Район'));
+        $this->addColumn('city_store', 'type', $this->integer()->comment('Тип магазина'));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->dropColumn('city_store', 'region');
+        $this->dropColumn('city_store', 'city');
+        $this->dropColumn('city_store', 'district');
+        $this->dropColumn('city_store', 'type');
+    }
+}
index 435a8659108b77288b9c6aebdd74726d6a056713..00892e56db24391efeb9a2452858ddb36d8d2a9a 100644 (file)
@@ -145,7 +145,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
 
                         </div>
                         <div class="col-md-9">
-                            <?= Html::dropDownList('city', null, [], ['prompt' => 'Город', 'class' => 'form-select']); ?>
+                            <?= Html::label('city'); ?>
                         </div>
                     </div>
                     <div class="row border-bottom">
@@ -159,25 +159,37 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                         </div>
                     </div>
                     <div class="row">
-                        <!-- Лейбл и одиночные дропдауны -->
                         <div class="col-md-4">
-                            <!-- Лейбл для первого города -->
-                            <?= Html::label('Город 1', null, ['class' => 'form-label']); ?>
-                            <?= Html::dropDownList('city1', null, [], ['prompt' => 'Город', 'class' => 'form-select']); ?>
-
-                            <!-- Лейбл для второго города -->
-                            <?= Html::label('Город 2', null, ['class' => 'form-label']); ?>
-                            <?= Html::dropDownList('city2', null, [], ['prompt' => 'Город', 'class' => 'form-select']); ?>
-
-                            <!-- Лейбл для третьего города -->
-                            <?= Html::label('Город 3', null, ['class' => 'form-label']); ?>
-                            <?= Html::dropDownList('city3', null, [], ['prompt' => 'Город', 'class' => 'form-select']); ?>
-
-                            <!-- Лейбл для четвертого города -->
-                            <?= Html::label('Город 4', null, ['class' => 'form-label']); ?>
-                            <?= Html::dropDownList('city4', null, [], ['prompt' => 'Город', 'class' => 'form-select']); ?>
+                            <?= Html::label('Площадь(M2)', null, ['class' => 'form-label']); ?>
+                            <?= Html::input('text', 'store_area', null, [
+                                'class' => 'form-control',
+                                'placeholder' => 'Введите число',
+                                'oninput' => 'validateDecimal(this)'
+                            ]); ?>
+
+                            <?= Html::label('Витрина(M3)', null, ['class' => 'form-label']); ?>
+                            <?= Html::input('text', 'showcase_volume', null, [
+                                'class' => 'form-control',
+                                'placeholder' => 'Введите число',
+                                'oninput' => 'validateDecimal(this)'
+                            ]); ?>
+
+                            <?= Html::label('Холодильник(M2)', null, ['class' => 'form-label']); ?>
+                            <?= Html::input('text', 'freeze_area', null, [
+                                'class' => 'form-control',
+                                'placeholder' => 'Введите число',
+                                'oninput' => 'validateDecimal(this)'
+                            ]); ?>
+
+                            <?= Html::label('Холодильник (M3)', null, ['class' => 'form-label']); ?>
+                            <?= Html::input('text', 'freeze_volume', null, [
+                                'class' => 'form-control',
+                                'placeholder' => 'Введите число',
+                                'oninput' => 'validateDecimal(this)'
+                            ]); ?>
                         </div>
 
+
                         <div class="col-md-8">
                             <div class="container mt-5">
                                 <?= DualListbox::widget([
index 76a64191028b00e35462e261eb93dcfda36af918..07dd2c858e35be7213a42c72a1123c9bf597058d 100644 (file)
@@ -1,4 +1,5 @@
 $(document).ready(function () {
+    // Функция для отправки данных через AJAX
     function sendData() {
         var formData = {
             address_city: $('#address_city').val(),
@@ -9,81 +10,102 @@ $(document).ready(function () {
             bush_chef_florist: $('#bush_chef_florist').val(),
         };
 
+        // Отправка данных через AJAX
         $.ajax({
-            url: 'city-store-params/edit',
-            type: 'GET',
-            data: formData,
+            url: 'city-store-params/edit', // URL контроллера и экшн
+            type: 'GET', // Метод запроса
+            data: formData, // Данные формы
             success: function (response) {
-                if (response && typeof response === 'object') {
-                    var options = '';
-                    $.each(response, function (key, value) {
-                        options += '<option value="' + key + '">' + value + '</option>';
-                    });
-                    $('#selectedValues').html(options);
-                }
-            },
-            error: function (xhr, status, error) {
-                console.error("Ошибка AJAX: " + error);
+            // Ответ от сервера (список магазинов или другие данные)
+            if (response && typeof response === 'object') {
+                // Обновляем dropdown
+                var options = '';
+                $.each(response, function (key, value) {
+                    options += '<option value="' + key + '">' + value + '</option>';
+                });
+
+                // Вставляем полученные опции в select с id selectedValues
+                $('#selected_store').html(options);
             }
-        });
+        },
+        error: function (xhr, status, error) {
+            console.error("Ошибка AJAX: " + error);
+        }
+    });
     }
 
+    // Отслеживаем изменения в полях формы
     $('#address_city, #address_region, #address_district, #store_type, #territorial_manager, #bush_chef_florist').on('change', function () {
         sendData();
     });
 
+    // Также можно отправить запрос при нажатии на кнопку "Применить"
     $('#apply-button').on('click', function () {
         sendData();
     });
-
-    function sendData() {
-        var selectedValues = $('#selectedValues').val();
-
-        if (!selectedValues || selectedValues.length === 0) {
-            return;
-        }
-
-        $.ajax({
-            url: 'city-store-params/get-data',
-            type: 'GET',
-            data: { selectedValues: selectedValues },
-            success: function (response) {
-                if (response.error) {
-                    alert(response.error);
-                    return;
-                }
-
-                if (response.store_types) {
-                    var storeTypeOptions = '<option value="">Тип магазина</option>';
-                    $.each(response.store_types, function (key, value) {
-                        storeTypeOptions += '<option value="' + key + '">' + value + '</option>';
-                    });
-                    $('#store_type').html(storeTypeOptions);
-                }
-
-                if (response.cities) {
-                    var cityOptions = '<option value="">Город</option>';
-                    $.each(response.cities, function (key, value) {
-                        cityOptions += '<option value="' + key + '">' + value + '</option>';
-                    });
-                    $('#city').html(cityOptions);
-                }
-
-                if (response.territorial_managers) {
-                    var territorialManagerOptions = '<option value="">Территориально управляющий</option>';
-                    $.each(response.territorial_managers, function (key, value) {
-                        territorialManagerOptions += '<option value="' + key + '">' + value + '</option>';
-                    });
-                    $('#territorial_manager').html(territorialManagerOptions);
-                }
-            },
-            error: function (xhr, status, error) {
-                console.error("Ошибка AJAX: " + error);
-            }
-        });
-    }
-
-    $('#selected-store').on('change', function () {
-        sendData();
-    });
 });
+//
+// $(document).ready(function () {
+//     // Функция для отправки AJAX-запроса и обновления данных на форме
+//     function sendData() {
+//         // Получаем выбранные значения из select (multiple)
+//         var selectedValues = $('#selectedValues').val();
+//
+//         // Если ничего не выбрано, не отправляем запрос
+//         if (!selectedValues || selectedValues.length === 0) {
+//             return;
+//         }
+//
+//         // Отправка данных через AJAX
+//         $.ajax({
+//             url: '<?= Url::to(['controller/action-edit']) ?>', // URL контроллера и экшн
+//             type: 'GET', // Метод запроса
+//             data: { selectedValues: selectedValues }, // Данные (выбранные значения)
+//         success: function (response) {
+//             // Проверяем, есть ли ошибки в ответе
+//             if (response.error) {
+//                 alert(response.error);
+//                 return;
+//             }
+//
+//             // Обновляем выпадающий список store_type
+//             if (response.store_types) {
+//                 var storeTypeOptions = '<option value="">Тип магазина</option>';
+//                 $.each(response.store_types, function (key, value) {
+//                     storeTypeOptions += '<option value="' + key + '">' + value + '</option>';
+//                 });
+//                 $('#store_type').html(storeTypeOptions);
+//             }
+//
+//             // Обновляем выпадающий список city
+//             if (response.cities) {
+//                 var cityOptions = '<option value="">Город</option>';
+//                 $.each(response.cities, function (key, value) {
+//                     cityOptions += '<option value="' + key + '">' + value + '</option>';
+//                 });
+//                 $('#city').html(cityOptions);
+//             }
+//
+//             // Обновляем выпадающий список territorial_manager
+//             if (response.territorial_managers) {
+//                 var territorialManagerOptions = '<option value="">Территориально управляющий</option>';
+//                 $.each(response.territorial_managers, function (key, value) {
+//                     territorialManagerOptions += '<option value="' + key + '">' + value + '</option>';
+//                 });
+//                 $('#territorial_manager').html(territorialManagerOptions);
+//             }
+//
+//             // В случае необходимости, вы можете обновить другие поля формы
+//         },
+//         error: function (xhr, status, error) {
+//             console.error("Ошибка AJAX: " + error);
+//         }
+//     });
+//     }
+//
+//     // Отслеживаем изменения в множественном select (selectedValues[])
+//     $('#selectedValues').on('change', function () {
+//         sendData(); // Отправляем данные на сервер при изменении
+//     });
+// });
+