]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-375] statuses filter
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 25 Mar 2025 09:56:13 +0000 (12:56 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 25 Mar 2025 09:56:13 +0000 (12:56 +0300)
erp24/controllers/MatrixStatisticsController.php
erp24/records/BouquetForecast.php
erp24/views/matrix-statistics/index.php

index 23b91ef4e1e061a4053e2dd477aa5a7a2b3c74fa..d4db025be0985ce8db30787daf87a335031317e1 100644 (file)
@@ -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]);
             }
index 0884a361489a559fbec722b6a78045549b579a9c..66b38a034bdaec1b626d59638fbc1f2112a4e22c 100644 (file)
@@ -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
index 9f008ce4e0a1bc674a12f3840b51e000d10aa213..28634c7a2ac071fe9a5b109134273327e9ac1217 100644 (file)
@@ -88,7 +88,6 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
                     ])->label(false) ?>
                 </div>
             </div>
-
             <div class="row mt-2">
                 <div class="col-4">
                     <?= $form->field($model, 'sale_type')->dropDownList([0 => 'Типы продаж', 1 => 'Оффлайн',
@@ -115,6 +114,20 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
                     ])->label(false) ?>
                 </div>
             </div>
+            <div class="row mt-3">
+                <div class="col-4">
+                    <?= $form->field($model, 'statuses')->widget(Select2::class, [
+                        'data' => ArrayHelper::map($matrixTypes, 'id', 'name'),
+                        'language' => 'ru',
+                        'options' => ['placeholder' => 'Статусы...'],
+                        'pluginOptions' => [
+                            'allowClear' => true,
+                            'multiple' => true,
+                        ]
+                    ])->label(false) ?>
+                </div>
+
+            </div>
         </div>
         <div class="col-4">
             <div class="row">
@@ -173,6 +186,7 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
     </div>
     <?php foreach ($matrixTypes as $matrixType): ?>
         <?php /** @var $matrixType MatrixType */ ?>
+        <?php if (empty($model->statuses) || in_array($matrixType->id, $model->statuses)): ?>
         <div class="row">
             <div class="col-1"></div>
             <div class="col-1"><?= Html::a($matrixType->name, ['/bouquet/index' , 'matrix_type_id' => $matrixType->id], ['class' => 'btn btn-link']) ?></div>
@@ -180,6 +194,7 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
             <div class="col-2"><?= number_format($cost, 0, '.', ' ')?>р.</div>
             <div class="col-2"><?= number_format($total == 0 ? 0 : $cost * 100.0 / $total, 0, '.', '')?>%</div>
         </div>
+        <?php endif; ?>
     <?php endforeach; ?>
     <div class="row">
         <div class="col-10"></div>