From: marina Date: Wed, 19 Feb 2025 13:47:21 +0000 (+0300) Subject: ERP-302 Редактирование букета X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=672bc268204a17f3d227a688c7f324ff47b3fa3b;p=erp24_rep%2Fyii-erp24%2F.git ERP-302 Редактирование букета --- 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) ?>