From 70d2ae29357309b226f882e5bfd0f03e1b17b202 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Mon, 27 Dec 2021 14:56:06 +1000 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=80=D0=BC=D0=B8=D0=BD=D0=B0?= =?UTF-8?q?=D0=BB=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controllers/ProfileController.php | 22 ++++++++++ .../system/views/profile/supplies.php | 2 +- mirzaev/skillparts/system/web/js/profile.js | 42 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/mirzaev/skillparts/system/controllers/ProfileController.php b/mirzaev/skillparts/system/controllers/ProfileController.php index 73dbe76..e488ed0 100644 --- a/mirzaev/skillparts/system/controllers/ProfileController.php +++ b/mirzaev/skillparts/system/controllers/ProfileController.php @@ -408,6 +408,28 @@ class ProfileController extends Controller $sidebar = $this->renderPartial('sidebar'); $groups = self::readGroups(); + // Обработка настроек аккаунта + if ($vars = yii::$app->request->post('Warehouse') ?? yii::$app->request->get('Warehouse') and $warehouse = yii::$app->request->post('_key') ?? yii::$app->request->get('_key')) { + // Обнаружены входные параметры + + if (isset($vars['trmn'])) { + // Передан параметр + + if ($warehouse = Warehouse::searchById(Warehouse::collectionName() . "/$warehouse")) { + // Найден склад + + // Запись в буфер + $warehouse->trmn = $vars['trmn']; + + // Запись в базу данных + $warehouse->update(); + } + } else { + /** + * @todo Написать обработчик ошибок + */ + } + } if (yii::$app->request->isPost) { // POST-запрос diff --git a/mirzaev/skillparts/system/views/profile/supplies.php b/mirzaev/skillparts/system/views/profile/supplies.php index 52718af..a7906bf 100644 --- a/mirzaev/skillparts/system/views/profile/supplies.php +++ b/mirzaev/skillparts/system/views/profile/supplies.php @@ -149,7 +149,7 @@ $panel ?? $panel = 'profile_panel_supplies_input_import'; field($warehouse, 'trmn', ['options' => ['class' => "mb-3"]]) ->dropDownList($list, [ - 'onChange' => 'page_profile_settings(this.parentElement.parentElement, \'profile_panel_settings_company\')', + 'onChange' => 'page_supplies_settings(this.parentElement.parentElement, ' . $warehouse->_key . ', \'profile_panel_supplies\')', 'disabled' => count($list) <= 1 ])->label(false); ?> diff --git a/mirzaev/skillparts/system/web/js/profile.js b/mirzaev/skillparts/system/web/js/profile.js index 708d2fb..7a9dda5 100644 --- a/mirzaev/skillparts/system/web/js/profile.js +++ b/mirzaev/skillparts/system/web/js/profile.js @@ -83,6 +83,48 @@ function page_profile_supplies_import_excel(form, warehouse, account, panel) { return false; }; +function page_supplies_settings(form, warehouse, panel) { + if (form == undefined) { + form = { + '_csrf': yii.getCsrfToken() + }; + + if (warehouse !== undefined) { + form._key = warehouse; + }; + + if (panel !== undefined) { + form.panel = panel; + }; + } else { + form = $(form).serializeArray(); + + form.push({ + name: "_key", + value: warehouse + }); + + form.push({ + name: "panel", + value: panel + }); + }; + + $.ajax({ + url: '/profile/supplies', + type: 'post', + dataType: 'json', + data: form, + success: page_profile_response_success, + error: page_profile_response_error + }); + + // Реинициализация + initDropdownOem(); + + return false; +}; + function page_profile_settings(form, panel) { if (form == undefined) { form = {