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 = {