]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавляем тип в таблицу
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 17 Feb 2025 12:49:49 +0000 (15:49 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 17 Feb 2025 12:49:49 +0000 (15:49 +0300)
erp24/api2/controllers/DataController.php
erp24/migrations/m250217_114306_add_column_type_to_products_1c_nomenclature_table.php [new file with mode: 0644]
erp24/records/Products1c.php
erp24/records/Products1cNomenclature.php

index 7db1e3141b5e5cf6f43ec3f3955dc58dcd95bf4a..a46f2132ef48c0d8fe5f8371218e46ef63f876ea 100644 (file)
@@ -1047,6 +1047,14 @@ class DataController extends BaseController
                             $sortValue = $characteristicsValues['сорт'];
                         }
 
+                        $typeValue = null;
+                        if (isset($characteristicsValues['type']) && !empty($characteristicsValues['type'])) {
+                            $typeValue = $characteristicsValues['type'];
+                        }
+                        if (isset($characteristicsValues['тип']) && !empty($characteristicsValues['тип'])) {
+                            $typeValue = $characteristicsValues['тип'];
+                        }
+
                         $measureValue = null;
                         if (isset($characteristicsValues['measure']) && !empty($characteristicsValues['measure'])) {
                             $measureValue = $characteristicsValues['measure'];
@@ -1062,6 +1070,7 @@ class DataController extends BaseController
 
                         $product1cNomenclature->species = $speciesValue;
                         $product1cNomenclature->sort = $sortValue;
+                        $product1cNomenclature->type = $typeValue;
                         $product1cNomenclature->size = $sizeValue;
                         $product1cNomenclature->measure = $measureValue;
                         $product1cNomenclature->color = $colorValue;
diff --git a/erp24/migrations/m250217_114306_add_column_type_to_products_1c_nomenclature_table.php b/erp24/migrations/m250217_114306_add_column_type_to_products_1c_nomenclature_table.php
new file mode 100644 (file)
index 0000000..c7cff0a
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m250217_114306_add_column_type_to_products_1c_nomenclature_table
+ */
+class m250217_114306_add_column_type_to_products_1c_nomenclature_table extends Migration
+{
+    const TABLE_NAME  = 'erp24.products_1c_nomenclature';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME) === null) {
+            return;
+        }
+
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME)->getColumn('type') === null) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'type',
+                $this->string()->null()->comment('Тип'),
+            );
+        }
+
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME) === null) {
+            return;
+        }
+
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME)->getColumn('type') !== null) {
+            $this->dropColumn(self::TABLE_NAME, 'type');
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m250217_114306_add_column_type_to_products_1c_nomenclature_table cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
index b72a9f232efc26d4d790bfbbedef99b0f2c77238..01f71915a2c62b316ea074adb15af1005553a719 100644 (file)
@@ -20,8 +20,7 @@ use yii\helpers\ArrayHelper;
  */
 class Products1c extends \yii\db\ActiveRecord
 {
-
-    const PRODUCT1C_FIELDS = ['id', 'parent_id', 'tip', 'code', 'name', 'articule', 'view', 'components', 'AdditionCharacteristics'];
+    const PRODUCT1C_FIELDS = ['id', 'parent_id', 'tip', 'type', 'code', 'name', 'articule', 'view', 'components', 'AdditionCharacteristics'];
 
     /**
      * {@inheritdoc}
index 2e60e155a6afcdd8c924dc19405c79d0cb74c76e..57f39e04d13076ae32afec4c138420a015a4a362 100644 (file)
@@ -15,6 +15,7 @@ use Yii;
  * @property string|null $subcategory Подкатегория
  * @property string|null $species Вид
  * @property string|null $sort Сорт
+ * @property string|null $type Тип
  * @property int|null $size Размер
  * @property string|null $measure Единица измерения
  * @property string|null $color Цвет
@@ -36,9 +37,10 @@ class Products1cNomenclature extends \yii\db\ActiveRecord
     {
         return [
             [['id', 'location', 'name', 'type_num', 'category'], 'required'],
-            [['size', 'species', 'subcategory', 'sort', 'measure', 'color'], 'default', 'value' => null],
+            [['size', 'species', 'subcategory', 'sort', 'measure', 'color', 'type'], 'default', 'value' => null],
             [['size'], 'integer'],
-            [['id', 'location', 'name', 'type_num', 'category', 'subcategory', 'species', 'sort', 'measure', 'color'], 'string', 'max' => 255],
+            [['id', 'location', 'name', 'type_num',
+                'category', 'subcategory', 'species', 'sort', 'measure', 'color', 'type'], 'string', 'max' => 255],
             [['id'], 'unique'],
         ];
     }
@@ -57,6 +59,7 @@ class Products1cNomenclature extends \yii\db\ActiveRecord
             'subcategory' => 'Подкатегория',
             'species' => 'Вид',
             'sort' => 'Сорт',
+            'type' => 'Тип',
             'size' => 'Размер',
             'measure' => 'Единица измерения',
             'color' => 'Цвет',