From: marina Date: Wed, 22 Jan 2025 08:31:16 +0000 (+0300) Subject: ERP-282 Нужно сделать интерфейс настройки магазина X-Git-Tag: 1.7~35^2~36 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=da1733589e1b89aaad2ec5ba8fa4cb99a9455305;p=erp24_rep%2Fyii-erp24%2F.git ERP-282 Нужно сделать интерфейс настройки магазина --- diff --git a/erp24/controllers/CityStoreParamsController.php b/erp24/controllers/CityStoreParamsController.php index cd2dcfc5..a3803326 100644 --- a/erp24/controllers/CityStoreParamsController.php +++ b/erp24/controllers/CityStoreParamsController.php @@ -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 index 00000000..13f06f09 --- /dev/null +++ b/erp24/migrations/m250121_132357_create_matrix_type_and_store_type_table.php @@ -0,0 +1,34 @@ +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 index 00000000..3ba4ff0a --- /dev/null +++ b/erp24/migrations/m250122_082641_add_new_column_on_city_store.php @@ -0,0 +1,31 @@ +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'); + } +} diff --git a/erp24/views/city-store-params/index.php b/erp24/views/city-store-params/index.php index 435a8659..00892e56 100644 --- a/erp24/views/city-store-params/index.php +++ b/erp24/views/city-store-params/index.php @@ -145,7 +145,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
- 'Город', 'class' => 'form-select']); ?> +
@@ -159,25 +159,37 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
-
- - 'form-label']); ?> - 'Город', 'class' => 'form-select']); ?> - - - 'form-label']); ?> - 'Город', 'class' => 'form-select']); ?> - - - 'form-label']); ?> - 'Город', 'class' => 'form-select']); ?> - - - 'form-label']); ?> - 'Город', 'class' => 'form-select']); ?> + 'form-label']); ?> + 'form-control', + 'placeholder' => 'Введите число', + 'oninput' => 'validateDecimal(this)' + ]); ?> + + 'form-label']); ?> + 'form-control', + 'placeholder' => 'Введите число', + 'oninput' => 'validateDecimal(this)' + ]); ?> + + 'form-label']); ?> + 'form-control', + 'placeholder' => 'Введите число', + 'oninput' => 'validateDecimal(this)' + ]); ?> + + 'form-label']); ?> + 'form-control', + 'placeholder' => 'Введите число', + 'oninput' => 'validateDecimal(this)' + ]); ?>
+
' + value + ''; - }); - $('#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 += ''; + }); + + // Вставляем полученные опции в 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 = ''; - $.each(response.store_types, function (key, value) { - storeTypeOptions += ''; - }); - $('#store_type').html(storeTypeOptions); - } - - if (response.cities) { - var cityOptions = ''; - $.each(response.cities, function (key, value) { - cityOptions += ''; - }); - $('#city').html(cityOptions); - } - - if (response.territorial_managers) { - var territorialManagerOptions = ''; - $.each(response.territorial_managers, function (key, value) { - territorialManagerOptions += ''; - }); - $('#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 контроллера и экшн +// type: 'GET', // Метод запроса +// data: { selectedValues: selectedValues }, // Данные (выбранные значения) +// success: function (response) { +// // Проверяем, есть ли ошибки в ответе +// if (response.error) { +// alert(response.error); +// return; +// } +// +// // Обновляем выпадающий список store_type +// if (response.store_types) { +// var storeTypeOptions = ''; +// $.each(response.store_types, function (key, value) { +// storeTypeOptions += ''; +// }); +// $('#store_type').html(storeTypeOptions); +// } +// +// // Обновляем выпадающий список city +// if (response.cities) { +// var cityOptions = ''; +// $.each(response.cities, function (key, value) { +// cityOptions += ''; +// }); +// $('#city').html(cityOptions); +// } +// +// // Обновляем выпадающий список territorial_manager +// if (response.territorial_managers) { +// var territorialManagerOptions = ''; +// $.each(response.territorial_managers, function (key, value) { +// territorialManagerOptions += ''; +// }); +// $('#territorial_manager').html(territorialManagerOptions); +// } +// +// // В случае необходимости, вы можете обновить другие поля формы +// }, +// error: function (xhr, status, error) { +// console.error("Ошибка AJAX: " + error); +// } +// }); +// } +// +// // Отслеживаем изменения в множественном select (selectedValues[]) +// $('#selectedValues').on('change', function () { +// sendData(); // Отправляем данные на сервер при изменении +// }); +// }); +