public function actionShowHistoryData()
{
- $request = \Yii::$app->request;
+ $request = Yii::$app->request;
$result = null;
$storeList = ArrayHelper::map(
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
+ );
+ }
}
}