From bde47e734a3c7ab36f8cc50661ebfd12983e1d0a Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Tue, 9 Sep 2025 17:25:35 +0300 Subject: [PATCH] =?utf8?q?=D0=92=D1=8B=D0=B2=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../MatrixBouquetActualityController.php | 9 ++++++--- erp24/controllers/MatrixTypeController.php | 7 +++++-- erp24/records/MatrixType.php | 4 +++- erp24/views/matrix-bouquet-actuality/index.php | 16 ++++++++-------- erp24/views/matrix-type/index.php | 4 ++-- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/erp24/controllers/MatrixBouquetActualityController.php b/erp24/controllers/MatrixBouquetActualityController.php index 6468a78f..d6100451 100644 --- a/erp24/controllers/MatrixBouquetActualityController.php +++ b/erp24/controllers/MatrixBouquetActualityController.php @@ -130,7 +130,7 @@ class MatrixBouquetActualityController extends Controller ]); } - if ($filter->date_from || $filter->date_to || $filter->is_archive !== null && $filter->is_archive !== '') { + if ($filter->date_from || $filter->date_to || (int)$filter->is_archive == 1) { $hasDateFrom = !empty($filter->date_from); $hasDateTo = !empty($filter->date_to); @@ -150,7 +150,7 @@ class MatrixBouquetActualityController extends Controller $dateExists = MatrixBouquetActuality::find() ->alias('a') ->where('a.bouquet_id = bc.id'); - if ($filter->is_archive !== null && $filter->is_archive !== '') { + if ((int)$filter->is_archive == 1) { $dateExists->andWhere(['a.is_archive' => (int)$filter->is_archive]); } @@ -173,7 +173,7 @@ class MatrixBouquetActualityController extends Controller } $query->with(['actualities' => function ($subQuery) use ($filter, $hasDateFrom, $hasDateTo, $dateFrom, $dateTo) { - if ($filter->is_archive !== null && $filter->is_archive !== '') { + if ((int)$filter->is_archive == 1) { $subQuery->andWhere(['is_archive' => (int)$filter->is_archive]); } @@ -200,17 +200,20 @@ class MatrixBouquetActualityController extends Controller $rows = []; foreach ($bouquets as $bouquet) { $acts = $bouquet->actualities; + $price = $bouquet->priceRel; if ($acts) { foreach ($acts as $act) { $rows[] = [ 'product' => $bouquet, 'actuality' => $act, + 'price' => $price, ]; } } else { $rows[] = [ 'product' => $bouquet, 'actuality' => null, + 'price' => $price, ]; } } diff --git a/erp24/controllers/MatrixTypeController.php b/erp24/controllers/MatrixTypeController.php index d527cf25..fc234124 100644 --- a/erp24/controllers/MatrixTypeController.php +++ b/erp24/controllers/MatrixTypeController.php @@ -121,12 +121,15 @@ class MatrixTypeController extends Controller return ['success'=>false,'message'=>current($model->getFirstErrors()) ?: 'Ошибка сохранения']; } - public function actionCreateChild($parent_id) + public function actionCreateChild($parent_id = null) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $child = new MatrixType(); $child->load(Yii::$app->request->post(), ''); - $child->parent_id = (int)$parent_id ?? null; + if (!empty($parent_id)) { + $child->parent_id = (int)$parent_id; + } + if ($child->save()) { Yii::$app->session->setFlash('success', 'Запись создана', false); diff --git a/erp24/records/MatrixType.php b/erp24/records/MatrixType.php index 2af17a87..59854073 100644 --- a/erp24/records/MatrixType.php +++ b/erp24/records/MatrixType.php @@ -55,9 +55,11 @@ class MatrixType extends \yii\db\ActiveRecord return [ [['name'], 'filter', 'filter' => 'trim'], [['name'], 'required'], - [['created_by', 'updated_by', 'deleted_by', 'active', 'parent_id', 'deleted'], 'integer'], + [['created_by', 'updated_by', 'deleted_by', 'active', 'deleted'], 'integer'], [['created_at', 'updated_at', 'deleted_at'], 'safe'], [['name'], 'string', 'max' => 255], + [['parent_id'], 'integer'], + [['parent_id'], 'default', 'value' => null], // Уникальность имени в рамках одной группы [ ['name', 'parent_id'], diff --git a/erp24/views/matrix-bouquet-actuality/index.php b/erp24/views/matrix-bouquet-actuality/index.php index 26c733a6..74c85e05 100644 --- a/erp24/views/matrix-bouquet-actuality/index.php +++ b/erp24/views/matrix-bouquet-actuality/index.php @@ -221,11 +221,11 @@ foreach ($subgroups as $sg) { [ 'attribute' => 'price', 'label' => 'Цена', - 'value' => function($row) { return $row['price']; }, + 'value' => function($row) { return $row['price']->price; }, 'format' => ['decimal', 2], ], [ - 'label' => 'Актуальность ассортимента', + 'label' => 'Актуальность', 'format' => 'raw', 'contentOptions' => ['style'=>'white-space:nowrap; min-width:100px;'], 'value' => function ($row, $k, $i) use ($months) { @@ -266,17 +266,17 @@ foreach ($subgroups as $sg) { 'contentOptions' => ['style'=>'width:160px; text-align:center;'], 'value' => function ($row, $key, $index) { $product = $row['product']; - $btnArchOn = Html::button('+ Добавить интервал', [ - 'class' => 'btn btn-xs btn-outline-primary ms-2 add-actuality-row', + $btnArchOn = Html::button('В архив', [ + 'class' => 'btn btn-xs btn-danger ms-2 add-actuality-row', 'type' => 'button', - 'title' => 'Добавить интервал', + 'title' => 'В архив', 'data-guid' => $product->id, 'data-name' => $product->name, ]); - $btnArchOff = Html::button('+ Добавить интервал', [ - 'class' => 'btn btn-xs btn-outline-primary ms-2 add-actuality-row', + $btnArchOff = Html::button('Из архива', [ + 'class' => 'btn btn-xs btn-secondary ms-2 add-actuality-row', 'type' => 'button', - 'title' => 'Добавить интервал', + 'title' => 'Из архива', 'data-guid' => $product->id, 'data-name' => $product->name, ]); diff --git a/erp24/views/matrix-type/index.php b/erp24/views/matrix-type/index.php index 944ff8e2..3ffdd0eb 100644 --- a/erp24/views/matrix-type/index.php +++ b/erp24/views/matrix-type/index.php @@ -45,9 +45,9 @@ $this->registerJsFile('/js/matrix-type/index.js', ['position' => \yii\web\View:: -
+