]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавил фильтр по основному гуиду при создании новой замены
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 19 Nov 2024 14:18:34 +0000 (17:18 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 19 Nov 2024 14:18:34 +0000 (17:18 +0300)
erp24/controllers/crud/Product1cReplacementController.php
erp24/views/crud/product1c-replacement/_form.php

index 042988bb0e72fe29ef9777aef2962849a2f42073..9141d669201663f1663f432292627410a97b6774 100644 (file)
@@ -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();
index ff411109e4c67665cb718ec1bbaf251a92e3f4d9..0d40c5c7333f8f611e4b0cefc6061efd0c9646e3 100644 (file)
@@ -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) {