From f82df0cd0c6d247f0182d6d478880c797b329460 Mon Sep 17 00:00:00 2001 From: marina Date: Thu, 20 Feb 2025 15:45:40 +0300 Subject: [PATCH] =?utf8?q?ERP-302=20=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82?= =?utf8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B1=D1=83?= =?utf8?q?=D0=BA=D0=B5=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/BouquetController.php | 21 ++++++++++++++++----- erp24/records/BouquetForecast.php | 1 + erp24/views/bouquet/_product_edit.php | 5 +---- erp24/views/bouquet/update.php | 4 +++- 4 files changed, 21 insertions(+), 10 deletions(-) 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 -- 2.39.5