From 362dbc616f9877a132f001dde96a6f9ea7eef7c0 Mon Sep 17 00:00:00 2001 From: fomichev Date: Mon, 17 Feb 2025 15:49:49 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5?= =?utf8?q?=D0=BC=20=D1=82=D0=B8=D0=BF=20=D0=B2=20=D1=82=D0=B0=D0=B1=D0=BB?= =?utf8?q?=D0=B8=D1=86=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataController.php | 9 +++ ...type_to_products_1c_nomenclature_table.php | 58 +++++++++++++++++++ erp24/records/Products1c.php | 3 +- erp24/records/Products1cNomenclature.php | 7 ++- 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 erp24/migrations/m250217_114306_add_column_type_to_products_1c_nomenclature_table.php diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index 7db1e314..a46f2132 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -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 index 00000000..c7cff0a2 --- /dev/null +++ b/erp24/migrations/m250217_114306_add_column_type_to_products_1c_nomenclature_table.php @@ -0,0 +1,58 @@ +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; + } + */ +} diff --git a/erp24/records/Products1c.php b/erp24/records/Products1c.php index b72a9f23..01f71915 100644 --- a/erp24/records/Products1c.php +++ b/erp24/records/Products1c.php @@ -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} diff --git a/erp24/records/Products1cNomenclature.php b/erp24/records/Products1cNomenclature.php index 2e60e155..57f39e04 100644 --- a/erp24/records/Products1cNomenclature.php +++ b/erp24/records/Products1cNomenclature.php @@ -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' => 'Цвет', -- 2.39.5