From: Alexander Smirnov Date: Wed, 19 Mar 2025 12:30:14 +0000 (+0300) Subject: [ERP-310] Применить фильтры после нажатия кнопки применить X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=eb0aece36d8657a3062aec081c8a9887a6e096a5;p=erp24_rep%2Fyii-erp24%2F.git [ERP-310] Применить фильтры после нажатия кнопки применить --- diff --git a/erp24/controllers/MatrixStatisticsController.php b/erp24/controllers/MatrixStatisticsController.php index 1f365425..23b91ef4 100644 --- a/erp24/controllers/MatrixStatisticsController.php +++ b/erp24/controllers/MatrixStatisticsController.php @@ -39,6 +39,25 @@ class MatrixStatisticsController extends Controller { $model->load(Yii::$app->request->get()); + $stores = ArrayHelper::map($this->getStores([ + 'territorial_manager_id' => $model->territory_manager_id, + 'kshf_id' => $model->kshf_id, + 'city_id' => $model->city_id, + 'region_id' => $model->region_id, + 'raion_id' => $model->raion_id, + 'store_type_id' => $model->store_type_id, + ]), 'id', 'name'); + + $exist = false; + foreach ($stores as $storeId => $storeName) { + if ($model->store_id == $storeId) { + $exist = true; + break; + } + } + if (!$exist) { + $model->store_id = null; + } /////////////////////////////////////////// $total = 0; $matrixTypes = MatrixType::find()->orderBy(['id' => SORT_ASC])->all(); @@ -191,18 +210,12 @@ class MatrixStatisticsController extends Controller { $year = date("Y") - $i; $years [$year] = $year; } - $stores = ArrayHelper::map(CityStore::find()->andWhere(['visible' => '1'])->all(), 'id', 'name'); - return $this->render('index', compact('model', 'years', 'stores', 'total', 'withoutMatrix', 'withOnlyMatrix', 'saleCountPlan', 'matrixTypes')); } - public function actionGetStores() { - Yii::$app->response->format = Response::FORMAT_JSON; - - $data = Yii::$app->request->post(); - + public function getStores($data) { $territorialManager = $data['territorial_manager_id'] ?? null; $bushChefFlorist = $data['kshf_id'] ?? null; @@ -257,6 +270,16 @@ class MatrixStatisticsController extends Controller { $stores = $query->all(); + return $stores; + } + + public function actionGetStores() { + Yii::$app->response->format = Response::FORMAT_JSON; + + $data = Yii::$app->request->post(); + + $stores = $this->getStores($data); + return ArrayHelper::map($stores, 'id', 'name'); } }