From: marina Date: Thu, 20 Feb 2025 12:45:40 +0000 (+0300) Subject: ERP-302 Редактирование букета X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=f82df0cd0c6d247f0182d6d478880c797b329460;p=erp24_rep%2Fyii-erp24%2F.git ERP-302 Редактирование букета --- diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index a010f1da..33694ed8 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -36,7 +36,6 @@ class BouquetController extends Controller $month = $request->get('month'); $matrixTypeId = $request->get('matrix_type_id'); - // Убираем дублирование joinWith if ($year || $month) { $query->joinWith('bouquetForecast as bf'); } @@ -52,7 +51,6 @@ class BouquetController extends Controller $query->andWhere(['mth.matrix_type_id' => $matrixTypeId, 'mth.is_active' => BouquetCompositionMatrixTypeHistory::IS_ACTIVE]); } - // Предотвращаем дубликаты записей из-за join $query->groupBy('bouquet_composition.id'); $dataProvider = new \yii\data\ActiveDataProvider([ @@ -76,9 +74,7 @@ class BouquetController extends Controller if ($data['matrix_type_id']) { BouquetCompositionMatrixTypeHistory::setData($data['matrix_type_id'], $model->id); } - if ($model->save()) { - return $this->redirect(['index']); - } + $month = $data['month']; $year = $data['year']; @@ -119,6 +115,21 @@ class BouquetController extends Controller } } + if ($data['products_quantity']) { + $bouquetProducts = Yii::$app->request->post('products_quantity'); + foreach ($bouquetProducts as $key => $value) { + $product = new BouquetCompositionProducts([ + 'bouquet_id' => $model->id, + 'product_guid' => $key, + 'count' => $value + ]); + $product->save(); + } + } + + if ($model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } } diff --git a/erp24/records/BouquetForecast.php b/erp24/records/BouquetForecast.php index bd724655..b6d6111b 100644 --- a/erp24/records/BouquetForecast.php +++ b/erp24/records/BouquetForecast.php @@ -111,6 +111,7 @@ class BouquetForecast extends ActiveRecord 'name', new Expression('NULL as value') ]) + ->orderBy("$joinTable.id") ->asArray() ->all(); } diff --git a/erp24/views/bouquet/_product_edit.php b/erp24/views/bouquet/_product_edit.php index a8351654..13fb28ea 100644 --- a/erp24/views/bouquet/_product_edit.php +++ b/erp24/views/bouquet/_product_edit.php @@ -1,8 +1,6 @@ 'dual-list-form']); ?> +?> 'products', 'availableLabel' => 'Выбор', @@ -33,4 +31,3 @@ use yii\widgets\ActiveForm; - \ No newline at end of file diff --git a/erp24/views/bouquet/update.php b/erp24/views/bouquet/update.php index bacbf370..a4921f54 100644 --- a/erp24/views/bouquet/update.php +++ b/erp24/views/bouquet/update.php @@ -45,6 +45,7 @@ $this->registerJsFile('/js/bouquet/bouquet.js', ['position' => \yii\web\View::PO 'btn btn-primary w-100 mb-3', 'id' => 'apply-button']) ?>
+ 'dual-list-form']); ?>
render('_product_edit', [ 'availableItems' => $availableItems, @@ -52,4 +53,5 @@ $this->registerJsFile('/js/bouquet/bouquet.js', ['position' => \yii\web\View::PO 'isCreate' => false, 'listContainerSize' => [], ]); ?> -
+ + \ No newline at end of file