From eb0aece36d8657a3062aec081c8a9887a6e096a5 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Wed, 19 Mar 2025 15:30:14 +0300 Subject: [PATCH] =?utf8?q?[ERP-310]=20=D0=9F=D1=80=D0=B8=D0=BC=D0=B5=D0=BD?= =?utf8?q?=D0=B8=D1=82=D1=8C=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D1=8B?= =?utf8?q?=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=BD=D0=B0=D0=B6=D0=B0?= =?utf8?q?=D1=82=D0=B8=D1=8F=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20?= =?utf8?q?=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../MatrixStatisticsController.php | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) 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'); } } -- 2.39.5