From 388bbb0fd9e33935220bdfb6ea79c2c3dbdc5cf3 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Tue, 25 Mar 2025 12:56:13 +0300 Subject: [PATCH] [ERP-375] statuses filter --- .../controllers/MatrixStatisticsController.php | 10 +++++++--- erp24/records/BouquetForecast.php | 4 ++++ erp24/views/matrix-statistics/index.php | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/erp24/controllers/MatrixStatisticsController.php b/erp24/controllers/MatrixStatisticsController.php index 23b91ef4..d4db025b 100644 --- a/erp24/controllers/MatrixStatisticsController.php +++ b/erp24/controllers/MatrixStatisticsController.php @@ -30,10 +30,11 @@ class MatrixStatisticsController extends Controller { 'store_type_id' => null, 'territory_manager_id' => null, 'kshf_id' => null, + 'statuses' => null, ], [ [[ 'year', 'month', 'store_id', 'city_id', 'region_id', 'raion_id', 'store_type_id', - 'territory_manager_id', 'kshf_id' + 'territory_manager_id', 'kshf_id', 'statuses' ], 'safe'] ]); @@ -65,11 +66,14 @@ class MatrixStatisticsController extends Controller { $saleCountPlan = []; foreach ($boquetCompositionMatrixTypeHistory as $bcmth) { /** @var BouquetCompositionMatrixTypeHistory $bcmth */ - $bouquetForecastQuery = BouquetForecast::find()->where([ - 'bouquet_id' => $bcmth->bouquet_id, + $bouquetForecastQuery = BouquetForecast::find()->alias('bf')->joinWith(['bouquetHistory bh'])->where([ + 'bf.bouquet_id' => $bcmth->bouquet_id, 'year' => $model->year, 'month' => $model->month ]); + if (!empty($model->statuses)) { + $bouquetForecastQuery->andWhere(['bh.matrix_type_id' => $model->statuses]); + } if ($model->sale_type) { $bouquetForecastQuery->andWhere(['type_sales' => $model->sale_type]); } diff --git a/erp24/records/BouquetForecast.php b/erp24/records/BouquetForecast.php index 0884a361..66b38a03 100644 --- a/erp24/records/BouquetForecast.php +++ b/erp24/records/BouquetForecast.php @@ -216,4 +216,8 @@ class BouquetForecast extends ActiveRecord return $errors; } + + public function getBouquetHistory() { + return $this->hasOne(BouquetCompositionMatrixTypeHistory::class, ['bouquet_id' => 'bouquet_id']); + } } \ No newline at end of file diff --git a/erp24/views/matrix-statistics/index.php b/erp24/views/matrix-statistics/index.php index 9f008ce4..28634c7a 100644 --- a/erp24/views/matrix-statistics/index.php +++ b/erp24/views/matrix-statistics/index.php @@ -88,7 +88,6 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\ ])->label(false) ?> -
field($model, 'sale_type')->dropDownList([0 => 'Типы продаж', 1 => 'Оффлайн', @@ -115,6 +114,20 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\ ])->label(false) ?>
+
+
+ field($model, 'statuses')->widget(Select2::class, [ + 'data' => ArrayHelper::map($matrixTypes, 'id', 'name'), + 'language' => 'ru', + 'options' => ['placeholder' => 'Статусы...'], + 'pluginOptions' => [ + 'allowClear' => true, + 'multiple' => true, + ] + ])->label(false) ?> +
+ +
@@ -173,6 +186,7 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
+ statuses) || in_array($matrixType->id, $model->statuses)): ?>
name, ['/bouquet/index' , 'matrix_type_id' => $matrixType->id], ['class' => 'btn btn-link']) ?>
@@ -180,6 +194,7 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
р.
%
+
-- 2.39.5