]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавил артикул в поиск
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 18 Nov 2024 13:47:24 +0000 (16:47 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 18 Nov 2024 13:47:24 +0000 (16:47 +0300)
erp24/controllers/crud/Product1cReplacementController.php
erp24/views/crud/product1c-replacement/_form.php
erp24/views/crud/product1c-replacement/multy-form.php

index 9b10681d857c8c30a9826b5c928e7af85b8bc72a..4f26b9f16f13c94a7020784cd08d9b6da38038d3 100644 (file)
@@ -179,10 +179,10 @@ class Product1cReplacementController extends Controller
 
     public function actionSearch($q = null)
     {
+        Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
 
-                Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         $products = Products1c::find()
-            ->select(['id', 'name'])
+            ->select(['id', 'name', 'articule']) // Добавляем 'articule'
             ->where(['tip' => 'products'])
             ->andWhere(['ilike', 'name', $q])
             ->limit(20)
@@ -190,9 +190,16 @@ class Product1cReplacementController extends Controller
             ->all();
 
 
-        return ['items' => $products];
-    }
+        $items = [];
+        foreach ($products as $product) {
+            $items[] = [
+                'id' => $product['id'],
+                'text' => $product['name'] . (!empty($product['articule']) ? ' (' . $product['articule'] . ')' : ''),
+            ];
+        }
 
+        return ['items' => $items];
+    }
     /**
      * Updates an existing Product1CReplacement model.
      * If update is successful, the browser will be redirected to the 'view' page.
index 2d29b076568df0ae1e03409b9f590665b9849c18..f52415b4c9a92ae10089efe2e686875fe2b5cf69 100644 (file)
@@ -34,7 +34,7 @@ $this->registerJsFile('/js/crud/product1cReplacement/_form.js', ['position' => \
                     results: $.map(data.items, function(item) {
                         return {
                             id: item.id,
-                            text: item.name // Убедитесь, что возвращаете корректные данные
+                            text: item.text 
                         };
                     })
                 };
@@ -63,7 +63,7 @@ $this->registerJsFile('/js/crud/product1cReplacement/_form.js', ['position' => \
                     results: $.map(data.items, function(item) {
                         return {
                             id: item.id,
-                            text: item.name // Убедитесь, что возвращаете корректные данные
+                            text: item.text
                         };
                     })
                 };
index 380cb593f0efafd8565a27e07e2b50a757182d53..f3487daa4b7fd71c91c9435d4cf966037ac14253 100644 (file)
@@ -35,7 +35,7 @@ $this->registerJsFile('/js/crud/product1cReplacement/multy-form.js', ['position'
                         results: $.map(data.items, function(item) {
                             return {
                                 id: item.id,
-                                text: item.name
+                                text: item.text
                             };
                         })
                     };
@@ -68,7 +68,7 @@ $this->registerJsFile('/js/crud/product1cReplacement/multy-form.js', ['position'
                             results: $.map(data.items, function(item) {
                                 return {
                                     id: item.id,
-                                    text: item.name
+                                    text: item.text
                                 };
                             })
                         };