From: fomichev Date: Tue, 19 Nov 2024 14:18:34 +0000 (+0300) Subject: Добавил фильтр по основному гуиду при создании новой замены X-Git-Tag: 1.7~226^2~4 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=3d99f79be29bbd45a2ac0033ccb7119760936ace;p=erp24_rep%2Fyii-erp24%2F.git Добавил фильтр по основному гуиду при создании новой замены --- 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) {