From 1ed21d6a235507c8a54704a379a5882b7271eb9d Mon Sep 17 00:00:00 2001 From: fomichev Date: Fri, 4 Apr 2025 17:35:49 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D0=B5=20=D1=82=D0=BE=D0=B2=D1=80=D0=BE=D0=B2=20=D1=81=20=D0=B8?= =?utf8?q?=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B5=D0=B9=20=D0=B8=20=D0=B1?= =?utf8?q?=D0=B5=D0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/CategoryPlanController.php | 74 +++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/erp24/controllers/CategoryPlanController.php b/erp24/controllers/CategoryPlanController.php index 8bf55e87..33a3110e 100644 --- a/erp24/controllers/CategoryPlanController.php +++ b/erp24/controllers/CategoryPlanController.php @@ -272,7 +272,7 @@ class CategoryPlanController extends Controller { public function actionShowHistoryData() { - $request = \Yii::$app->request; + $request = Yii::$app->request; $result = null; $storeList = ArrayHelper::map( @@ -310,42 +310,46 @@ class CategoryPlanController extends Controller { if ($request->isPost) { $post = $request->post(); - $model->attributes = $post; - - - if (!empty($post['category'])) { - $subcategoryList = ArrayHelper::map( - Products1cNomenclature::find() - ->select('subcategory')->distinct() - ->where(['category' => $post['category']]) - ->orderBy('subcategory') - ->asArray()->all(), - 'subcategory', - 'subcategory' - ); - } - - if (!empty($post['subcategory'])) { - $speciesList = ArrayHelper::map( - Products1cNomenclature::find() - ->select('species')->distinct() - ->where(['subcategory' => $post['subcategory']]) - ->orderBy('species') - ->asArray()->all(), - 'species', - 'species' - ); - } - - if ($model->validate()) { - $storeId = $post['storeId']; - $selectedMonth = $post['month']; - $category = $post['category']; - $subcategory = !empty($post['subcategory']) ? $post['subcategory'] : null; - $species = !empty($post['species']) ? $post['species'] : null; + if ($model->load($post)) { + if (!empty($post['DynamicModel']['category'])) { + $subcategoryList = ArrayHelper::map( + Products1cNomenclature::find() + ->select('subcategory')->distinct() + ->where(['category' => $post['DynamicModel']['category']]) + ->orderBy('subcategory') + ->asArray()->all(), + 'subcategory', + 'subcategory' + ); + } + if (!empty($post['DynamicModel']['subcategory'])) { + $speciesList = ArrayHelper::map( + Products1cNomenclature::find() + ->select('species')->distinct() + ->where(['subcategory' => $post['DynamicModel']['subcategory']]) + ->orderBy('species') + ->asArray()->all(), + 'species', + 'species' + ); + } - $result = StorePlanService::calculateHistoricalShare($storeId, $selectedMonth, $category, $subcategory, $species); + if ($model->validate()) { + $storeId = $post['DynamicModel']['storeId']; + $selectedMonth = $post['DynamicModel']['month']; + $category = $post['DynamicModel']['category']; + $subcategory = !empty($post['DynamicModel']['subcategory']) ? $post['DynamicModel']['subcategory'] : null; + $species = !empty($post['DynamicModel']['species']) ? $post['DynamicModel']['species'] : null; + + $result = StorePlanService::calculateHistoricalShare( + $storeId, + $selectedMonth, + $category, + $subcategory, + $species + ); + } } } -- 2.39.5