From: fomichev Date: Mon, 18 Nov 2024 13:47:24 +0000 (+0300) Subject: Добавил артикул в поиск X-Git-Tag: 1.7~226^2~6 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5b797b695b56aa3e1c1979c658485ab02bade985;p=erp24_rep%2Fyii-erp24%2F.git Добавил артикул в поиск --- diff --git a/erp24/controllers/crud/Product1cReplacementController.php b/erp24/controllers/crud/Product1cReplacementController.php index 9b10681d..4f26b9f1 100644 --- a/erp24/controllers/crud/Product1cReplacementController.php +++ b/erp24/controllers/crud/Product1cReplacementController.php @@ -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. diff --git a/erp24/views/crud/product1c-replacement/_form.php b/erp24/views/crud/product1c-replacement/_form.php index 2d29b076..f52415b4 100644 --- a/erp24/views/crud/product1c-replacement/_form.php +++ b/erp24/views/crud/product1c-replacement/_form.php @@ -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 }; }) }; diff --git a/erp24/views/crud/product1c-replacement/multy-form.php b/erp24/views/crud/product1c-replacement/multy-form.php index 380cb593..f3487daa 100644 --- a/erp24/views/crud/product1c-replacement/multy-form.php +++ b/erp24/views/crud/product1c-replacement/multy-form.php @@ -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 }; }) };