From fef1bf23a5b3e29bd3ba651bad251281e02e374f Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 27 Jan 2025 16:34:12 +0300 Subject: [PATCH] =?utf8?q?ERP-282=20=D0=9D=D1=83=D0=B6=D0=BD=D0=BE=20?= =?utf8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20=D0=B8=D0=BD=D1=82?= =?utf8?q?=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=20=D0=BD=D0=B0=D1=81=D1=82?= =?utf8?q?=D1=80=D0=BE=D0=B9=D0=BA=D0=B8=20=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7?= =?utf8?q?=D0=B8=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../controllers/CityStoreParamsController.php | 4 +- erp24/records/CityStoreParams.php | 19 +++++++++ erp24/views/city-store-params/index.php | 41 ++++++++++++------- .../js/city-store-params/city-store-params.js | 18 +++++--- 4 files changed, 59 insertions(+), 23 deletions(-) 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'); + } +}); -- 2.39.5