From: marina Date: Mon, 27 Jan 2025 13:34:12 +0000 (+0300) Subject: ERP-282 Нужно сделать интерфейс настройки магазина X-Git-Tag: 1.7~35^2~14 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=fef1bf23a5b3e29bd3ba651bad251281e02e374f;p=erp24_rep%2Fyii-erp24%2F.git ERP-282 Нужно сделать интерфейс настройки магазина --- diff --git a/erp24/controllers/CityStoreParamsController.php b/erp24/controllers/CityStoreParamsController.php index b80bc70e..f549d26a 100644 --- a/erp24/controllers/CityStoreParamsController.php +++ b/erp24/controllers/CityStoreParamsController.php @@ -71,7 +71,7 @@ class CityStoreParamsController extends Controller if ($model->validate()) { if ($model->save()) { $flash = 'success'; - $value = 'Новая запись успешно создана.'; + $value = 'Данные успешно сохранены'; $selected_store = $model->store_id; } } else { @@ -174,7 +174,7 @@ class CityStoreParamsController extends Controller 'id' => $params->id ?? null, 'storeId' => $storeId, 'name' => $store->name, - 'type' => $params->stores_type ?? $store->type ?? null, + 'type' => $params->store_type ?? $store->type ?? null, 'region' => $params->address_region ?? $store->region ?? null, 'city' => $params->address_city ?? $store->city ?? null, 'district' => $params->address_district ?? $store->district ?? null, diff --git a/erp24/records/CityStoreParams.php b/erp24/records/CityStoreParams.php index ec16b3c7..25502245 100644 --- a/erp24/records/CityStoreParams.php +++ b/erp24/records/CityStoreParams.php @@ -97,6 +97,25 @@ class CityStoreParams extends ActiveRecord ]; } + public function afterSave($insert, $changedAttributes) + { + if (isset($changedAttributes->address_region)) { + CityStore::update(['region' => $changedAttributes->address_region], ['id' => $changedAttributes->store_id]); + } + + if (isset($changedAttributes->address_city)) { + CityStore::update(['city' => $changedAttributes->address_city], ['id' => $changedAttributes->store_id]); + } + + if (isset($changedAttributes->address_district)) { + CityStore::update(['district' => $changedAttributes->address_district], ['id' => $changedAttributes->store_id]); + } + + if (isset($changedAttributes->address_type)) { + CityStore::update(['type' => $changedAttributes->address_type], ['id' => $changedAttributes->store_id]); + } + } + public function getStore() { return $this->hasOne(CityStore::class, ['id' => 'store_id']); } diff --git a/erp24/views/city-store-params/index.php b/erp24/views/city-store-params/index.php index bfe23c8a..8b8598a1 100644 --- a/erp24/views/city-store-params/index.php +++ b/erp24/views/city-store-params/index.php @@ -28,9 +28,19 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
- StoreCityList::TYPE_REGION]), 'id', 'name'), - ['prompt' => 'Выберите регион', 'class' => 'form-select', 'id' => 'address_region']); + 'address_region', + 'value' => null, + 'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_REGION]), 'id', 'name'), + 'options' => [ + 'placeholder' => 'Регион', + 'class' => 'form-select', + 'id' => 'address_region', + ], + 'pluginOptions' => [ + 'allowClear' => true, + ], + ]); ?> 'd-block mt-2 text-decoration-none']); @@ -41,7 +51,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
StoreCityList::TYPE_CITY]), 'id', 'name'), - ['prompt' => 'Выберите город', 'class' => 'form-select', 'id' => 'address_city']); + ['prompt' => 'Город', 'class' => 'form-select', 'id' => 'address_city']); ?>
@@ -49,7 +59,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
StoreCityList::TYPE_DISTRICT]), 'id', 'name'), - ['prompt' => 'Выберите район', 'class' => 'form-select', 'id' => 'address_district']); + ['prompt' => 'Район', 'class' => 'form-select', 'id' => 'address_district']); ?>
@@ -57,7 +67,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
all(), 'id', 'name'), - ['prompt' => 'Выберите тип магазина', 'class' => 'form-select', 'id' => 'store_type']); + ['prompt' => 'Тип магазина', 'class' => 'form-select', 'id' => 'store_type']); ?> 'd-block mt-2 text-decoration-none']); ?>
@@ -66,24 +76,25 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
AdminGroup::GROUP_BUSH_DIRECTOR]), 'id', 'name_full'), - ['prompt' => 'Выберите территориального управляющего', 'class' => 'form-select', 'id' => 'territorial_manager']); + ['prompt' => 'Территориального управляющего', 'class' => 'form-select', 'id' => 'territorial_manager']); ?>
- -
-
-
-
-
\yii_app\records\AdminGroup::GROUP_BUSH_CHEF_FLORIST]), 'id', 'name_full'), - ['prompt' => 'Выберите кустового шеф флориста', 'class' => 'form-select', 'id' => 'bush_chef_florist']); + ['prompt' => 'Кустового шеф флориста', 'class' => 'form-select', 'id' => 'bush_chef_florist']); ?>
+
+
+
+
+
+
+
'btn btn-primary w-100', 'id' => 'apply-button']); ?> @@ -110,7 +121,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
session->hasFlash($flash)): ?> session->getFlash($flash), [ - 'class' => 'alert text-center alert-' . Html::encode($flash), + 'class' => 'alert text-center flash-message alert-' . Html::encode($flash), ]) ?>
diff --git a/erp24/web/js/city-store-params/city-store-params.js b/erp24/web/js/city-store-params/city-store-params.js index fa0a55a5..8e156545 100644 --- a/erp24/web/js/city-store-params/city-store-params.js +++ b/erp24/web/js/city-store-params/city-store-params.js @@ -29,7 +29,8 @@ $('#apply-button').on('click', function () { }); $('#edit-button').on('click', function () { - getData() + $('.flash-message').remove(); + getData(); }); function getData() { @@ -129,14 +130,19 @@ function validateDecimal(input) { $(document).ready(function () { - var selectedValues = $('#selected-store').val(); - if (selectedValues && selectedValues.length > 0) { - $('#edit-button').click(); + if ($('.flash-message').length) { + sessionStorage.setItem('flashMessage', $('.flash-message').html()); } - $('#text-info').text('Для редактирования выберите магазин!').addClass('text-danger') -}) + if ($('#selected-store').val()?.length > 0) { + $('#edit-button').click(); + } + if (sessionStorage.getItem('flashMessage')) { + $('body').prepend('
' + sessionStorage.getItem('flashMessage') + '
'); + sessionStorage.removeItem('flashMessage'); + } +});