]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
api integrations update
authorkirostumm <kirostumm@gmail.com>
Wed, 10 Jan 2024 07:05:47 +0000 (10:05 +0300)
committerkirostumm <kirostumm@gmail.com>
Wed, 10 Jan 2024 07:05:47 +0000 (10:05 +0300)
erp24/controllers/ApiController.php [new file with mode: 0644]
erp24/records/Admin.php
erp24/records/ApiIntegrationLogs.php [new file with mode: 0644]
erp24/records/ExportImportIntegrations.php [new file with mode: 0644]
erp24/records/InfoItemsTableShop0.php [new file with mode: 0644]
erp24/views/api/integrations_index.php [new file with mode: 0644]

diff --git a/erp24/controllers/ApiController.php b/erp24/controllers/ApiController.php
new file mode 100644 (file)
index 0000000..fec55e3
--- /dev/null
@@ -0,0 +1,355 @@
+<?php
+
+namespace app\controllers;
+
+use kartik\select2\Select2;
+use Yii;
+use yii\data\ArrayDataProvider;
+use yii\helpers\ArrayHelper;
+use yii\helpers\Html;
+use yii\web\Controller;
+use yii\web\JsExpression;
+use yii_app\records\Admin;
+use yii_app\records\ApiIntegrationLogs;
+use yii_app\records\Balances;
+use yii_app\records\CityStore;
+use yii_app\records\ExportImportIntegrations;
+use yii_app\records\ExportImportTable;
+use yii_app\records\InfoItemsTableShop0;
+use yii_app\records\Products1c;
+
+class ApiController extends Controller
+{
+    public function actionIntegrations($entity = "city_store", $export_id = 1)
+    {
+        $exportImportIntegrationsList = ExportImportIntegrations::find()
+            ->select([
+                'id',
+                'name'
+            ])
+            ->asArray()
+            ->all();
+
+        $entityArr = [];
+        $cnt = 0;
+
+        if ($entity === 'admin') {
+            $admins = Admin::find()
+                ->select([
+                    'id',
+                    'name'
+                ])
+                ->where(['>', 'group_id', 3])
+                ->asArray()
+                ->all();
+
+            $entityArr = $admins;
+            $cnt = count($entityArr);
+
+        } else if ($entity === 'city_store') {
+            $cityStore = CityStore::find()
+                ->select([
+                    'name',
+                    'id'
+                ])
+                ->asArray()
+                ->all();
+
+            $entityArr = $cityStore;
+            $cnt = count($entityArr);
+
+        } else if ($entity === 'products') {
+            $infoItemsTableShop0 = InfoItemsTableShop0::find()
+                ->select([
+                    'name' => 'title',
+                    'id' => 'item_id'
+                ])
+                ->where([
+                    'cat_items_id' => [
+                        2,
+                        1219,
+                        1220,
+                        1224,
+                        1225,
+                        1226,
+                        1227
+                    ]
+                ])
+                ->orderBy([
+                    'cat_items_id' => SORT_ASC,
+                    'title' => SORT_ASC
+                ])
+                ->limit(3000)
+                ->asArray()
+                ->all();
+
+            $entityArr = $infoItemsTableShop0;
+
+            $balancesItems = Balances::find()
+                ->select([
+                    'product_id',
+                    'quantity'
+                ])
+                ->where([
+                    'store_id' => "dbd70103-2c7b-11e9-9b87-c85b76f0e893"
+                ])
+                ->asArray()
+                ->all();
+
+            $balances = ArrayHelper::map($balancesItems, 'product_id', 'quantity');
+            $cnt = count($balances);
+
+        }
+
+        $expotImportTableItems = ExportImportTable::find()
+            ->where([
+                'entity' => $entity,
+                'export_id' => $export_id
+            ])
+            ->asArray()
+            ->all();
+
+        $inSore = ArrayHelper::map($expotImportTableItems, 'entity_id', 'export_val');
+        $idgrid = ArrayHelper::getColumn($expotImportTableItems, 'export_val');
+
+        $products1C = [];
+        $entity___arr = [];
+        $entity___arr0 = [];
+        if ($entity === 'city_store') {
+            $products1C = Products1c::find()
+                ->where([
+                    'AND',
+                    ['tip' => 'city_store'],
+                    ['view' => 1]
+                ])
+                ->asArray()
+                ->all();
+
+
+        } else if ($entity === 'admin') {
+            $expotImportTableItems = ExportImportTable::find()
+                ->select([
+                    'export_val',
+                    'entity_id'
+                ])
+                ->where([
+                    'AND',
+                    ['entity' => 'admin'],
+                    ['export_id' => 1]
+                ])
+                ->asArray()
+                ->all();
+
+            foreach ($expotImportTableItems as $expotImportTableItem) {
+                Admin::updateAll(['guid' => $expotImportTableItem['export_val']], ['id' => $expotImportTableItem['entity_id']]);
+            }
+
+            Products1c::updateAll(['tip' => 'admin'], ['tip' => 'sellers']);
+            $products1C = Products1c::find()
+                ->where([
+                    'tip' => 'admin'
+                ])
+                ->asArray()
+                ->all();
+
+            foreach ($products1C as $row) {
+                $entity___arr[$row["id"]] = $row["name"] . "";
+                $entity___arr0[$row["id"]] = $row["name"];
+            }
+
+        } else if ($entity === 'products') {
+            $products1C = Products1c::find()
+                ->where([
+                    'tip' => 'products_group'
+                ])
+                ->asArray()
+                ->all();
+
+            $group = ArrayHelper::map($products1C, 'id', 'name');
+
+            $products1C = Products1c::find()
+                ->select([
+                    'name',
+                    'id',
+                    'parent_id'
+                ])
+                ->where([
+                    'tip' => 'products'
+                ])
+                ->asArray()
+                ->all();
+
+            foreach ($products1C as $row) {
+                $entity___arr[$row["id"]] = $row["name"] . " <small>(" . $group[$row["parent_id"]] . ")</small>";
+                $entity___arr0[$row["id"]] = $row["name"];
+            }
+        }
+
+        $dataProvider = new ArrayDataProvider([
+            'allModels' => $entityArr
+        ]);
+
+        $columns = [
+            [
+                'label' => 'ID в ERP',
+                'value' => function ($model) {
+                    return $model['id'];
+                }
+            ],
+            [
+                'label' => 'Название в ERP',
+                'value' => function ($model) {
+                    return $model['name'];
+                }
+            ],
+            [
+                'label' => 'Название в интеграции',
+                'format' => 'raw',
+                'value' => function ($model) use ($entity___arr, $inSore) {
+                    if (isset($inSore[$model['id']])) {
+                        return $entity___arr[$inSore[$model['id']]] ?? '';
+                    }
+                    return '';
+                }
+            ],
+            [
+                'label' => 'GUID или ID',
+                'format' => 'raw',
+                'value' => function ($model) use ($inSore) {
+                    return Html::input('string', '', $inSore[$model['id']] ?? '', ['class' => 'form-control guid_input']);
+                }
+            ],
+            [
+                'label' => 'Поиск и сопоставление в интеграции',
+                'format' => 'raw',
+                'value' => function ($model) use ($inSore) {
+                    return Select2::widget([
+                        'name' => $model['id'],
+                        'pluginOptions' => [
+                            'allowClear' => true,
+                            'minimumInputLength' => 3,
+                            'language' => [
+                                'errorLoading' => new JsExpression("function () { return 'Waiting for results...'; }"),
+                            ],
+                            'ajax' => [
+                                'url' => 'poisk-item',
+                                'dataType' => 'json',
+                                'data' => new JsExpression('function(params) { return {q:params.term}; }')
+                            ],
+                            'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
+                            'templateResult' => new JsExpression('function(city) { return city.text; }'),
+                            'templateSelection' => new JsExpression('function (city) { return city.text; }'),
+                        ],
+                    ]);
+                }
+            ],
+        ];
+
+        return $this->render('integrations_index', [
+            'entity' => $entity,
+            'export_id' => $export_id,
+            'exportImportIntegrationsList' => $exportImportIntegrationsList,
+            'products1C' => $products1C,
+            'idgrid' => $idgrid,
+            'dataProvider' => $dataProvider,
+            'columns' => $columns
+        ]);
+    }
+
+    public function actionIntegrationSave()
+    {
+        if (Yii::$app->request->post('id')) {
+            $entity = Yii::$app->request->post('entity');
+            $export_id = Yii::$app->request->post('export_id');
+            $value = Yii::$app->request->post('val');
+            $inid = Yii::$app->request->post('id');
+            $expold = Yii::$app->request->post('expold');
+
+            if ($entity == "admin" && $export_id == 1) {
+                $admin = Admin::findOne(['id' => $inid]);
+                $admin->guid = $value;
+                $admin->save();
+                return "Обновили admin id=$inid guid= $value ";
+            }
+
+            if ($expold != $value or $expold == '') {
+
+                $exportImportTableItem = new ExportImportTable(['export_id' => $export_id, 'entity' => $entity, 'entity_id' => $inid, 'export_val' => $value]);
+                $exportImportTableItem->save();
+
+                $apiIntegrationLogs = new ApiIntegrationLogs(['admin_id' => Yii::$app->user->id, 'date' => time(), 'export_id' => $export_id, 'entity' => $entity, 'entity_id' => $inid, 'export_val' => $value, 'export_val_old' => $expold]);
+                $apiIntegrationLogs->save();
+                return "Данные сохранены";
+            }
+        }
+    }
+
+    public function actionPoiskItem()
+    {
+        $tip = "admin";
+
+        $s = Yii::$app->request->post('search');
+        $id = Yii::$app->request->post('id');
+        $tip = Yii::$app->request->post('tip');
+        $tip = Yii::$app->request->post('entity') ?? $tip;
+
+        if (strlen($s) > 2) {
+
+            if ($tip == "products" or $tip == "product") {
+                $products1C = Products1c::find()
+                    ->select([
+                        'id',
+                        'name'
+                    ])
+                    ->where([
+                        'tip' => 'products_group'
+                    ])
+                    ->asArray()
+                    ->all();
+
+                $group = ArrayHelper::map($products1C, 'id', 'name');
+
+                $data = Products1c::find()
+                    ->select([
+                        'products_1c.id',
+                        'products_1c.parent_id',
+                        'products_1c.name',
+                        'products_1c.code',
+                        'products_1c.articule',
+                        'prices.price'
+                    ])
+                    ->innerJoin('prices', 'products_1c.id = prices.product_id')
+                    ->where([
+                        'AND',
+                        ['products_1c.tip' => 'products'],
+                        ['LIKE', 'products_1c.name', '%' . $s . '%', false],
+                    ])
+                    ->orderBy(['prices.price' => SORT_DESC])
+                    ->limit(20)
+                    ->asArray()
+                    ->all();
+
+            } else if ($tip == 'admin') {
+                $data = Products1c::find()
+                    ->select([
+                        'products_1c.id',
+                        'products_1c.name',
+                    ])
+                    ->where([
+                        'AND',
+                        ['products_1c.tip' => 'admin'],
+                        ['LIKE', 'products_1c.name', '%' . $s . '%', false],
+                    ])
+                    ->orderBy(['products_1c.name' => SORT_ASC])
+                    ->limit(20)
+                    ->asArray()
+                    ->all();
+
+            }
+
+
+
+            return $data;
+        }
+    }
+}
\ No newline at end of file
index 9906770a8e4d04bad719be1c2d498e07a3e13290..58a3d02828de19e706f7d232410266e33df61686 100755 (executable)
@@ -25,6 +25,7 @@ use yii\web\IdentityInterface;
  * @property int $vcompany Пользователь является человеком
  * @property string store_arr
  * @property string $popular_modules
+ * @property string $guid
  * @package yii_app\records
  */
 class Admin extends ActiveRecord implements IdentityInterface
diff --git a/erp24/records/ApiIntegrationLogs.php b/erp24/records/ApiIntegrationLogs.php
new file mode 100644 (file)
index 0000000..b887ac4
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "api_integration_logs".
+ *
+ * @property int $id
+ * @property int $export_id
+ * @property string $entity_id
+ * @property string $entity
+ * @property string $date
+ * @property string $export_val
+ * @property string $export_val_old
+ * @property int $admin_id
+ */
+class ApiIntegrationLogs extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'api_integration_logs';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['export_id', 'entity_id', 'entity', 'date', 'export_val', 'export_val_old', 'admin_id'], 'required'],
+            [['export_id', 'admin_id'], 'integer'],
+            [['date'], 'safe'],
+            [['entity_id', 'entity'], 'string', 'max' => 36],
+            [['export_val', 'export_val_old'], 'string', 'max' => 120],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'export_id' => 'Export ID',
+            'entity_id' => 'Entity ID',
+            'entity' => 'Entity',
+            'date' => 'Date',
+            'export_val' => 'Export Val',
+            'export_val_old' => 'Export Val Old',
+            'admin_id' => 'Admin ID',
+        ];
+    }
+}
diff --git a/erp24/records/ExportImportIntegrations.php b/erp24/records/ExportImportIntegrations.php
new file mode 100644 (file)
index 0000000..73cc2a4
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "export_import_integrations".
+ *
+ * @property int $id ID интеграции
+ * @property string $name Название интеграции
+ */
+class ExportImportIntegrations extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'export_import_integrations';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['name'], 'required'],
+            [['name'], 'string', 'max' => 200],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'name' => 'Name',
+        ];
+    }
+}
diff --git a/erp24/records/InfoItemsTableShop0.php b/erp24/records/InfoItemsTableShop0.php
new file mode 100644 (file)
index 0000000..f18285b
--- /dev/null
@@ -0,0 +1,257 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "info_items_table_shop_0".
+ *
+ * @property int $item_id
+ * @property string $title Наименование
+ * @property float $price
+ * @property int $f_id ID товара в сторонней программе
+ * @property string $kod штрих код
+ * @property string $id_1c GUID
+ * @property int $cat_items_id
+ * @property int $cat_id_ishod
+ * @property string $cat_items_id_dop
+ * @property string $cat_items_catalog_arr
+ * @property string $group_arr
+ * @property string $tag_arr тэги, свойства товара
+ * @property string $tags
+ * @property int $tag_main главный тэг
+ * @property int $site_id
+ * @property string $sites_arr
+ * @property int $modul_id
+ * @property string $data
+ * @property string $data_edit
+ * @property string $data_edit_images
+ * @property int $admin_id_edit
+ * @property string $data_start
+ * @property string $data_end
+ * @property string $title_from_url title для url
+ * @property string $title_url
+ * @property string $title_url_dop
+ * @property string $description
+ * @property string $description2
+ * @property int $proizvoditel_id
+ * @property string $content
+ * @property string $url
+ * @property string $image
+ * @property string $image_sm
+ * @property float $price_zakup
+ * @property int $price_zakup_up
+ * @property float $price_old
+ * @property string $price_individ
+ * @property string $price_m2
+ * @property float $m2_korobka
+ * @property int $counter
+ * @property int $counter_down
+ * @property int $counter_com
+ * @property int $counter_poll
+ * @property float $avg_ball
+ * @property int $order
+ * @property string $seo_title
+ * @property string $seo_description
+ * @property string $seo_keywords
+ * @property string $user_ip
+ * @property int $user_access
+ * @property int $user_id
+ * @property string $nick
+ * @property int $admin_id
+ * @property string $moderator
+ * @property string|null $comments
+ * @property string $video
+ * @property string|null $rss
+ * @property int $status
+ * @property string $visible
+ * @property string $rasprodazha
+ * @property string $sale распродажа
+ * @property int $sale_city_id
+ * @property string $instock в наличии
+ * @property int $price_down
+ * @property int $price_30day
+ * @property string $action акция
+ * @property string $exclusive
+ * @property string $novinka
+ * @property string $hit Хит продаж
+ * @property int $speed_delivery Быстрая доставка - матричные букеты
+ * @property string $super_price
+ * @property string $in_lp
+ * @property string $shop_dop Доп. модули
+ * @property int $shop_table
+ * @property int $show_in_catalog видимый (выводить на сайт)
+ * @property string $dop_items
+ * @property int $default_on
+ * @property int $kol
+ * @property string $razmer
+ * @property int $dlina
+ * @property int $glubina
+ * @property int $visota
+ * @property int $shirina
+ * @property int $kol_mest
+ * @property float $massa
+ * @property float $molar_volume объём м3
+ * @property string $srok
+ * @property string $title_proizv
+ * @property string $articul_proizv
+ * @property string $shop_vmeste_array
+ * @property int $price_idivid
+ * @property string $colors_array
+ * @property string $mmebel
+ * @property int $krovat_osnova
+ * @property int $clear_tag
+ * @property int $items_id_site
+ * @property int $items_id_clon
+ * @property string $archive
+ * @property int $sostav составной товар
+ * @property string $setka_arr
+ * @property string $city_arr
+ * @property int $city_all
+ * @property int $no_bonus
+ */
+class InfoItemsTableShop0 extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'info_items_table_shop_0';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['item_id', 'title', 'f_id', 'kod', 'id_1c', 'cat_id_ishod', 'cat_items_id_dop', 'cat_items_catalog_arr', 'group_arr', 'tag_arr', 'tags', 'tag_main', 'sites_arr', 'data_edit_images', 'title_from_url', 'title_url', 'title_url_dop', 'description', 'description2', 'proizvoditel_id', 'content', 'url', 'price_zakup', 'price_old', 'm2_korobka', 'seo_title', 'seo_description', 'seo_keywords', 'video', 'sale_city_id', 'price_down', 'price_30day', 'dop_items', 'razmer', 'dlina', 'glubina', 'visota', 'shirina', 'kol_mest', 'massa', 'molar_volume', 'srok', 'title_proizv', 'articul_proizv', 'shop_vmeste_array', 'colors_array', 'items_id_site', 'setka_arr', 'city_arr'], 'required'],
+            [['item_id', 'f_id', 'cat_items_id', 'cat_id_ishod', 'tag_main', 'site_id', 'modul_id', 'admin_id_edit', 'proizvoditel_id', 'price_zakup_up', 'counter', 'counter_down', 'counter_com', 'counter_poll', 'order', 'user_access', 'user_id', 'admin_id', 'status', 'sale_city_id', 'price_down', 'price_30day', 'speed_delivery', 'shop_table', 'show_in_catalog', 'default_on', 'kol', 'dlina', 'glubina', 'visota', 'shirina', 'kol_mest', 'price_idivid', 'krovat_osnova', 'clear_tag', 'items_id_site', 'items_id_clon', 'sostav', 'city_all', 'no_bonus'], 'integer'],
+            [['title', 'cat_items_id_dop', 'cat_items_catalog_arr', 'group_arr', 'tag_arr', 'tags', 'sites_arr', 'title_url_dop', 'description', 'description2', 'content', 'url', 'price_individ', 'price_m2', 'seo_title', 'seo_description', 'seo_keywords', 'moderator', 'comments', 'video', 'rss', 'visible', 'rasprodazha', 'sale', 'instock', 'action', 'exclusive', 'novinka', 'hit', 'super_price', 'in_lp', 'shop_dop', 'dop_items', 'shop_vmeste_array', 'colors_array', 'mmebel', 'archive', 'city_arr'], 'string'],
+            [['price', 'price_zakup', 'price_old', 'm2_korobka', 'avg_ball', 'massa', 'molar_volume'], 'number'],
+            [['data', 'data_edit', 'data_edit_images', 'data_start', 'data_end'], 'safe'],
+            [['kod'], 'string', 'max' => 32],
+            [['id_1c'], 'string', 'max' => 36],
+            [['title_from_url', 'title_url', 'image', 'image_sm', 'title_proizv'], 'string', 'max' => 255],
+            [['user_ip'], 'string', 'max' => 15],
+            [['nick'], 'string', 'max' => 35],
+            [['razmer', 'articul_proizv'], 'string', 'max' => 155],
+            [['srok'], 'string', 'max' => 20],
+            [['setka_arr'], 'string', 'max' => 150],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'item_id' => 'Item ID',
+            'title' => 'Title',
+            'price' => 'Price',
+            'f_id' => 'F ID',
+            'kod' => 'Kod',
+            'id_1c' => 'Id 1c',
+            'cat_items_id' => 'Cat Items ID',
+            'cat_id_ishod' => 'Cat Id Ishod',
+            'cat_items_id_dop' => 'Cat Items Id Dop',
+            'cat_items_catalog_arr' => 'Cat Items Catalog Arr',
+            'group_arr' => 'Group Arr',
+            'tag_arr' => 'Tag Arr',
+            'tags' => 'Tags',
+            'tag_main' => 'Tag Main',
+            'site_id' => 'Site ID',
+            'sites_arr' => 'Sites Arr',
+            'modul_id' => 'Modul ID',
+            'data' => 'Data',
+            'data_edit' => 'Data Edit',
+            'data_edit_images' => 'Data Edit Images',
+            'admin_id_edit' => 'Admin Id Edit',
+            'data_start' => 'Data Start',
+            'data_end' => 'Data End',
+            'title_from_url' => 'Title From Url',
+            'title_url' => 'Title Url',
+            'title_url_dop' => 'Title Url Dop',
+            'description' => 'Description',
+            'description2' => 'Description2',
+            'proizvoditel_id' => 'Proizvoditel ID',
+            'content' => 'Content',
+            'url' => 'Url',
+            'image' => 'Image',
+            'image_sm' => 'Image Sm',
+            'price_zakup' => 'Price Zakup',
+            'price_zakup_up' => 'Price Zakup Up',
+            'price_old' => 'Price Old',
+            'price_individ' => 'Price Individ',
+            'price_m2' => 'Price M2',
+            'm2_korobka' => 'M2 Korobka',
+            'counter' => 'Counter',
+            'counter_down' => 'Counter Down',
+            'counter_com' => 'Counter Com',
+            'counter_poll' => 'Counter Poll',
+            'avg_ball' => 'Avg Ball',
+            'order' => 'Order',
+            'seo_title' => 'Seo Title',
+            'seo_description' => 'Seo Description',
+            'seo_keywords' => 'Seo Keywords',
+            'user_ip' => 'User Ip',
+            'user_access' => 'User Access',
+            'user_id' => 'User ID',
+            'nick' => 'Nick',
+            'admin_id' => 'Admin ID',
+            'moderator' => 'Moderator',
+            'comments' => 'Comments',
+            'video' => 'Video',
+            'rss' => 'Rss',
+            'status' => 'Status',
+            'visible' => 'Visible',
+            'rasprodazha' => 'Rasprodazha',
+            'sale' => 'Sale',
+            'sale_city_id' => 'Sale City ID',
+            'instock' => 'Instock',
+            'price_down' => 'Price Down',
+            'price_30day' => 'Price 30day',
+            'action' => 'Action',
+            'exclusive' => 'Exclusive',
+            'novinka' => 'Novinka',
+            'hit' => 'Hit',
+            'speed_delivery' => 'Speed Delivery',
+            'super_price' => 'Super Price',
+            'in_lp' => 'In Lp',
+            'shop_dop' => 'Shop Dop',
+            'shop_table' => 'Shop Table',
+            'show_in_catalog' => 'Show In Catalog',
+            'dop_items' => 'Dop Items',
+            'default_on' => 'Default On',
+            'kol' => 'Kol',
+            'razmer' => 'Razmer',
+            'dlina' => 'Dlina',
+            'glubina' => 'Glubina',
+            'visota' => 'Visota',
+            'shirina' => 'Shirina',
+            'kol_mest' => 'Kol Mest',
+            'massa' => 'Massa',
+            'molar_volume' => 'Molar Volume',
+            'srok' => 'Srok',
+            'title_proizv' => 'Title Proizv',
+            'articul_proizv' => 'Articul Proizv',
+            'shop_vmeste_array' => 'Shop Vmeste Array',
+            'price_idivid' => 'Price Idivid',
+            'colors_array' => 'Colors Array',
+            'mmebel' => 'Mmebel',
+            'krovat_osnova' => 'Krovat Osnova',
+            'clear_tag' => 'Clear Tag',
+            'items_id_site' => 'Items Id Site',
+            'items_id_clon' => 'Items Id Clon',
+            'archive' => 'Archive',
+            'sostav' => 'Sostav',
+            'setka_arr' => 'Setka Arr',
+            'city_arr' => 'City Arr',
+            'city_all' => 'City All',
+            'no_bonus' => 'No Bonus',
+        ];
+    }
+}
diff --git a/erp24/views/api/integrations_index.php b/erp24/views/api/integrations_index.php
new file mode 100644 (file)
index 0000000..e416e82
--- /dev/null
@@ -0,0 +1,104 @@
+<?php
+
+use yii\data\ArrayDataProvider;
+use yii\grid\GridView;
+use yii\helpers\Html;
+use yii\web\View;
+
+/**
+ * @var $this View
+ * @var $export_id integer
+ * @var $entity string
+ * @var $exportImportIntegrationsList []
+ * @var $products1C []
+ * @var $idgrid []
+ * @var $dataProvider ArrayDataProvider
+ * @var $columns
+ */
+
+$this->registerJs(<<<JS
+    function ajaxLogSave(id,val) {
+        var old=$('#expold_'+id).val();    
+        $.ajax({
+            url: '/api/integration-save/',
+            method: 'POST',
+            data: '&id='+id+'&val='+val+'&entity=" . $entity . "&export_id=" . $export_id . "&expold='+old,
+            success: function(data){
+                alert(data);
+            }
+        });
+    }
+    
+    $('td.tdd').each(function (index, element) {
+        input_search($(element).attr('id'),$(element).attr('data-id'));
+    });
+
+    $('.poisk-item').change(function() {
+        var id=$(this).attr('data-id');
+        get_select_search(id);
+    });
+
+
+    $('.guid_input').change(function() {
+        var id=$(this).attr('id-data');
+        var val=$(this).val();
+        ajaxLogSave(id,val);
+    });
+
+    $('.poisk-item').click(function() {
+        var id=$(this).attr('data-id');
+        if($(this).val()!=='' && $(this).val()!==' ') get_select_search(id);
+    });
+
+    function get_select_search(id) {
+        $.ajax({
+            url: '/api/poisk-item/',
+            method: 'POST',
+            data: '&id='+id+'&search='+$('#std_'+id).val()+'&tip=" . $entity . "',
+            success: function(data){
+                $('#std_'+id).after('<div style=\"position:absolute;\">'+data+'</div>');
+            }
+        });
+    }
+
+JS);
+?>
+
+<div class="p-8">
+    <h1>Интеграции</h1>
+    <?php foreach ($exportImportIntegrationsList as $item) : ?>
+        <?= Html::a(
+            $item['name'],
+            ['api/integrations', 'export_id' => $item['id'], 'entity' => $entity],
+            [
+                'class' => 'btn btn-' . (($export_id == $item['id']) ? 'success' : 'info'),
+            ]
+        ) ?>
+    <?php endforeach; ?>
+
+    <h1>Списки для Интеграции</h1>
+    <?php $ent = array("city_store" => "Магазины", "products" => "Товары и услуги", "admin" => "Сотрудники"); ?>
+
+    <?php foreach ($ent as $key => $item) : ?>
+        <?= Html::a(
+            $item,
+            ['api/integrations', 'export_id' => $export_id, 'entity' => $key],
+            [
+                'class' => 'btn btn-' . (($entity == $key) ? 'success' : 'info'),
+            ]
+        ) ?>
+    <?php endforeach; ?>
+
+    <?php if ($entity === 'city_store') : ?>
+        <?php foreach ($products1C as $item): ?>
+            <?php if (!in_array($item["id"], $idgrid)): ?>
+                <br><?= $item['id'] ?> <?= $item['name'] ?>
+            <?php endif; ?>
+        <?php endforeach; ?>
+    <?php endif; ?>
+
+    <?= GridView::widget([
+        'dataProvider' => $dataProvider,
+        'columns' => $columns
+    ]) ?>
+</div>