]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
item item site
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 7 May 2024 08:48:12 +0000 (11:48 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 7 May 2024 08:48:12 +0000 (11:48 +0300)
erp24/api3/modules/v1/controllers/search/ItemController.php [new file with mode: 0644]

diff --git a/erp24/api3/modules/v1/controllers/search/ItemController.php b/erp24/api3/modules/v1/controllers/search/ItemController.php
new file mode 100644 (file)
index 0000000..38fa83b
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+namespace yii_app\api3\modules\v1\controllers\search;
+
+use yii\helpers\ArrayHelper;
+use yii_app\api3\controllers\NoActiveController;
+use yii_app\records\Products1c;
+
+class ItemController extends NoActiveController
+{
+    public function actionItemsSite($limit, $name) {
+        $products = Products1c::find()->select(['id', 'name'])->where(['tip' => 'products_group'])->all();
+
+        $parent = ArrayHelper::map($products, 'id', 'name');
+
+        $products2 = Products1c::find()->select('id')->where(['tip' => 'products_group'])->andWhere(['LIKE', 'name', '%категории А%', false])->all();
+
+        $no = ArrayHelper::getColumn($products2, 'id');
+
+        $products3 = Products1c::find()->select(['id', 'parent_id', 'name'])->where(['tip' => 'products'])->andWhere(['view' => '1'])
+            ->andWhere(['NOT IN', 'parent_id', $no])->andWhere(['LIKE', 'name', '%' . $name . '%', false])->orderBy(['name' => SORT_ASC])
+            ->limit($limit)->asArray()->all();
+
+        foreach($products3 as $row) {
+            $p[]=[$row["id"],"".$row["name"]." (".$parent[$row["parent_id"]].")"];
+        }
+
+        return $p;
+    }
+}
\ No newline at end of file