From 3d99f79be29bbd45a2ac0033ccb7119760936ace Mon Sep 17 00:00:00 2001 From: fomichev Date: Tue, 19 Nov 2024 17:18:34 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?utf8?q?=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=20=D0=BF=D0=BE=20=D0=BE?= =?utf8?q?=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D0=BE=D0=BC=D1=83=20=D0=B3=D1=83?= =?utf8?q?=D0=B8=D0=B4=D1=83=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BE=D0=B7?= =?utf8?q?=D0=B4=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9?= =?utf8?q?=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../crud/Product1cReplacementController.php | 24 ++++++++++++++----- .../crud/product1c-replacement/_form.php | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/erp24/controllers/crud/Product1cReplacementController.php b/erp24/controllers/crud/Product1cReplacementController.php index 042988bb..9141d669 100644 --- a/erp24/controllers/crud/Product1cReplacementController.php +++ b/erp24/controllers/crud/Product1cReplacementController.php @@ -196,14 +196,26 @@ class Product1cReplacementController extends Controller if ($guid) { - $existingReplacements = Product1cReplacement::find() - ->select('guid_replacement') - ->where(['guid' => $guid]) - ->column(); - if ($existingReplacements) { - $query->andWhere(['not in', 'id', $existingReplacements]); + if ($guid == "guid"){ + $existingGuids = Product1cReplacement::find() + ->select(['guid']) + ->distinct() + ->column(); + if ($existingGuids) { + $query->andWhere(['not in', 'id', $existingGuids]); + } + }else{ + $existingReplacements = Product1cReplacement::find() + ->select('guid_replacement') + ->where(['guid' => $guid]) + ->column(); + + if ($existingReplacements) { + $query->andWhere(['not in', 'id', $existingReplacements]); + } } + } $products = $query->asArray()->all(); diff --git a/erp24/views/crud/product1c-replacement/_form.php b/erp24/views/crud/product1c-replacement/_form.php index ff411109..0d40c5c7 100644 --- a/erp24/views/crud/product1c-replacement/_form.php +++ b/erp24/views/crud/product1c-replacement/_form.php @@ -28,7 +28,7 @@ $this->registerJsFile('/js/crud/product1cReplacement/_form.js', ['position' => \ 'ajax' => [ 'url' => \yii\helpers\Url::to(['/crud/product1c-replacement/search']), 'dataType' => 'json', - 'data' => new JsExpression('function(params) { return {q:params.term}; }'), + 'data' => new JsExpression('function(params) { return {q:params.term, guid: "guid"}; }'), 'processResults' => new JsExpression('function(data) { return { results: $.map(data.items, function(item) { -- 2.39.5