From 672bc268204a17f3d227a688c7f324ff47b3fa3b Mon Sep 17 00:00:00 2001 From: marina Date: Wed, 19 Feb 2025 16:47:21 +0300 Subject: [PATCH] =?utf8?q?ERP-302=20=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82?= =?utf8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B1=D1=83?= =?utf8?q?=D0=BA=D0=B5=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/BouquetController.php | 29 +++++++++++++++---------- erp24/records/BouquetComposition.php | 3 +-- erp24/views/bouquet/_form.php | 13 ++++------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index 2a67a63d..85e9d6fa 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -35,15 +35,24 @@ class BouquetController extends Controller $month = $request->get('month'); $matrixTypeId = $request->get('matrix_type_id'); -// if ($year) { -// $query->andWhere(['year' => $year]); -// } -// if ($month) { -// $query->andWhere(['month' => $month]); -// } -// if ($matrixTypeId) { -// $query->andWhere(['matrix_type_id' => $matrixTypeId]); -// } + // Убираем дублирование joinWith + if ($year || $month) { + $query->joinWith('bouquetForecast as bf'); + } + if ($year) { + $query->andWhere(['bf.year' => $year]); + } + if ($month) { + $query->andWhere(['bf.month' => $month]); + } + + if ($matrixTypeId) { + $query->leftJoin('bouquet_composition_matrix_type_history mth', 'mth.bouquet_id = bouquet_composition.id'); + $query->andWhere(['mth.matrix_type_id' => $matrixTypeId, 'mth.is_active' => BouquetCompositionMatrixTypeHistory::IS_ACTIVE]); + } + + // Предотвращаем дубликаты записей из-за join + $query->groupBy('bouquet_composition.id'); $dataProvider = new \yii\data\ActiveDataProvider([ 'query' => $query, @@ -56,8 +65,6 @@ class BouquetController extends Controller ]); } - - public function actionCreate() { $model = new BouquetComposition(); diff --git a/erp24/records/BouquetComposition.php b/erp24/records/BouquetComposition.php index f25682e0..28efe9de 100644 --- a/erp24/records/BouquetComposition.php +++ b/erp24/records/BouquetComposition.php @@ -195,9 +195,8 @@ class BouquetComposition extends ActiveRecord return $selfCost; } - public function getForecastMonthAndYear() + public function getBouquetForecast() { -// var_dump($this->hasOne(BouquetForecast::class, ['bouquet_id' => 'id'])->createCommand()->getRawSql());die(); return $this->hasMany(BouquetForecast::class, ['bouquet_id' => 'id']); } } diff --git a/erp24/views/bouquet/_form.php b/erp24/views/bouquet/_form.php index afeb9b5b..0cc42751 100644 --- a/erp24/views/bouquet/_form.php +++ b/erp24/views/bouquet/_form.php @@ -41,12 +41,7 @@ $form = ActiveForm::begin([

- -

title) ?>

- 'form-control', 'placeholder' => 'Введите название']); - } ?> + title : null, ['class' => 'form-control', 'placeholder' => 'Введите название']); ?>
@@ -186,11 +181,11 @@ $form = ActiveForm::begin([ 'showCancel' => false, 'mainClass' => 'input-group-lg', 'initialPreview' => $processUrls, - 'maxFileSize' => 100000, // Максимальный размер файла (в килобайтах) + 'maxFileSize' => 100000, 'dropZoneTitle' => 'Выберите видеофайл', - 'browseOnZoneClick' => true, // Разрешить клик по зоне перетаскивания + 'browseOnZoneClick' => true, 'fileActionSettings' => [ - 'showZoom' => false, // Убираем иконку для увеличения + 'showZoom' => false, ], ], ])->label(false) ?> -- 2.39.5