$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,
]);
}
-
-
public function actionCreate() {
$model = new BouquetComposition();
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']);
}
}
<h3 class="ms-3 mb-0"><?= Html::encode("Состав букета: ") ?></h3>
</div>
<div class="col-md-9">
- <?php
- if ($model) { ?>
- <h2 class="ms-2 mb-0"><strong><?= Html::encode($this->title) ?></strong></h2>
- <?php } else {
- echo Html::input('text', 'BouquetComposition[name]', null, ['class' => 'form-control', 'placeholder' => 'Введите название']);
- } ?>
+ <?= Html::input('text', 'BouquetComposition[name]', $model ? $this->title : null, ['class' => 'form-control', 'placeholder' => 'Введите название']); ?>
</div>
</div>
'showCancel' => false,
'mainClass' => 'input-group-lg',
'initialPreview' => $processUrls,
- 'maxFileSize' => 100000, // Максимальный размер файла (в килобайтах)
+ 'maxFileSize' => 100000,
'dropZoneTitle' => 'Выберите видеофайл',
- 'browseOnZoneClick' => true, // Разрешить клик по зоне перетаскивания
+ 'browseOnZoneClick' => true,
'fileActionSettings' => [
- 'showZoom' => false, // Убираем иконку для увеличения
+ 'showZoom' => false,
],
],
])->label(false) ?>