]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-302 Редактирование букета
authormarina <m.zozirova@gmail.com>
Wed, 19 Feb 2025 13:47:21 +0000 (16:47 +0300)
committermarina <m.zozirova@gmail.com>
Wed, 19 Feb 2025 13:47:21 +0000 (16:47 +0300)
erp24/controllers/BouquetController.php
erp24/records/BouquetComposition.php
erp24/views/bouquet/_form.php

index 2a67a63dcf86230e9f130ec3892e82186560afc2..85e9d6fa102832453ff24af7077705a1496ab15f 100644 (file)
@@ -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();
 
index f25682e0e9c2e8c4480c7c76348778948137dcb5..28efe9de836a4b47bd3fda6b893383a2243e40a6 100644 (file)
@@ -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']);
     }
 }
index afeb9b5b179f8067405ac2fcf5f72e428377ecd7..0cc42751afa92c7980d9482d87fe6892c6cdadec 100644 (file)
@@ -41,12 +41,7 @@ $form = ActiveForm::begin([
                 <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>
 
@@ -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) ?>