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

index d153b405836c7469402c5b1da560af42524d0be6..f25682e0e9c2e8c4480c7c76348778948137dcb5 100644 (file)
@@ -87,7 +87,7 @@ class BouquetComposition extends ActiveRecord
 
     public function getMatrixType()
     {
-        return $this->hasMany(BouquetCompositionMatrixTypeHistory::class, ['bouquet_id' => 'id'])
+        return $this->hasOne(BouquetCompositionMatrixTypeHistory::class, ['bouquet_id' => 'id'])
             ->andWhere(['is_active' => BouquetCompositionMatrixTypeHistory::IS_ACTIVE]);
     }
 
index 58a2bbb7f0d9afcdb03a0fac958d8ffb2133e306..cfab41e8f9e999f983497d629a2751b4a2fbf678 100644 (file)
@@ -84,7 +84,6 @@ class BouquetCompositionMatrixTypeHistory extends ActiveRecord
 
     public static function setData($value, $bouquetId) {
         if (self::findOne(['bouquet_id' => $bouquetId])) {
-            var_dump(1);die();
             BouquetCompositionMatrixTypeHistory::updateAll(['date_to' => date('Y-m-d H:i:s'), 'bouquet_id' => $bouquetId, 'date_from' => null, 'is_active' => self::IS_ACTIVE]);
         }
 
index 41b21a8d23d897726f1e51c50296c666c1265397..ecc8fecafe60c93540a261deb6805dcbb08e4100 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use kartik\file\FileInput;
+use kartik\select2\Select2;
 use yii\helpers\ArrayHelper;
 use yii\helpers\Html;
 use yii\helpers\Url;
@@ -55,11 +56,18 @@ $form = ActiveForm::begin([
                     <?= Html::label('Тип матрицы', null, ['class' => 'h5 mt-2 mb-0']) ?>
                 </div>
                 <div class="col-md-7">
-                    <?= Html::dropDownList('matrix_type_id',
-                        $model && $model->matrixType ? $model->matrixType->matrix_type_id : null,
-                        ArrayHelper::map(MatrixType::find()->all(), 'id', 'name'),
-                        ['class' => 'form-control', 'prompt' => 'Тип матрицы'])
-                    ?>
+                    <?= Select2::widget([
+                        'name' => 'matrix_type_id',
+                        'value' => isset($model->matrixType) ? $model->matrixType->matrix_type_id : null,
+                        'data' => ArrayHelper::map(MatrixType::find()->all(), 'id', 'name'),
+                        'options' => [
+                            'placeholder' => 'Тип матрицы',
+                        ],
+                        'pluginOptions' => [
+                            'allowClear' => true,
+                        ],
+                    ]) ?>
+
                 </div>
             </div>