From 322ac982a23a8aeba7a7cec8e19a696e5b74e190 Mon Sep 17 00:00:00 2001 From: fomichev Date: Wed, 2 Jul 2025 17:51:44 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9=20=D1=81=D1=82?= =?utf8?q?=D0=B0=D1=82=D1=83=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/CronController.php | 2 + ...to_marketplace_order_1c_statuses_table.php | 61 +++++++++++++++++++ erp24/records/MarketplaceOrder1cStatuses.php | 8 ++- .../marketplace-order1c-statuses/_form.php | 18 ++++++ .../marketplace-order1c-statuses/index.php | 12 ++++ .../marketplace-order1c-statuses/view.php | 12 ++++ 6 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 erp24/migrations/m250702_140510_add_allowed_fields_to_marketplace_order_1c_statuses_table.php diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index 480b3789..e31cad29 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -111,6 +111,8 @@ class CronController extends Controller $statusesData [] = [ 'index_number' => $status->posit, 'status_name' => $status->status, + 'allowed_reserve' => $status->allowed_reserve, + 'allowed_closing' => $status->allowed_closing, 'hint' => $status->status_instruction, 'status_id' => $status->status_id, 'allowed_statuses' => $relationsToSend diff --git a/erp24/migrations/m250702_140510_add_allowed_fields_to_marketplace_order_1c_statuses_table.php b/erp24/migrations/m250702_140510_add_allowed_fields_to_marketplace_order_1c_statuses_table.php new file mode 100644 index 00000000..20752845 --- /dev/null +++ b/erp24/migrations/m250702_140510_add_allowed_fields_to_marketplace_order_1c_statuses_table.php @@ -0,0 +1,61 @@ +db->schema->getTableSchema(self::TABLE_NAME); + if ($table === null) { + return; + } + + if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('allowed_reserve')) { + $this->addColumn( + self::TABLE_NAME, + 'allowed_reserve', + $this->integer()->defaultValue(0)->comment('Разрешено резервирование'), + ); + } + if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('allowed_closing')) { + $this->addColumn( + self::TABLE_NAME, + 'allowed_closing', + $this->integer()->defaultValue(0)->comment('Разрешено закрытие'), + ); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('allowed_reserve')) { + $this->dropColumn(self::TABLE_NAME, 'allowed_reserve'); + } + if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('allowed_closing')) { + $this->dropColumn(self::TABLE_NAME, 'allowed_closing'); + } + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m250702_140510_add_allowed_fields_to_marketplace_order_1c_statuses_table cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/erp24/records/MarketplaceOrder1cStatuses.php b/erp24/records/MarketplaceOrder1cStatuses.php index 4a396ebb..28530fb4 100644 --- a/erp24/records/MarketplaceOrder1cStatuses.php +++ b/erp24/records/MarketplaceOrder1cStatuses.php @@ -10,6 +10,8 @@ use yii\db\ActiveQuery; * * @property int $id * @property int $marketplace_id Маркетплейс + * @property int $allowed_reserve Разрешено резервирование + * @property int $allowed_closing Разрешено закрытие * @property string $status_id артикул * @property string $status Статус * @property string $status_instruction Инструкция к статусу @@ -50,8 +52,8 @@ class MarketplaceOrder1cStatuses extends \yii\db\ActiveRecord return [ [['marketplace_id', 'status_id', 'status', 'status_instruction'], 'required'], [['marketplace_id'], 'default', 'value' => null], - [['posit'], 'default', 'value' => 0], - [['marketplace_id', 'posit'], 'integer'], + [['posit', 'allowed_reserve', 'allowed_closing'], 'default', 'value' => 0], + [['marketplace_id', 'posit', 'allowed_reserve', 'allowed_closing'], 'integer'], [['status_instruction', 'status_id'], 'string'], [['status_id', 'status'], 'string', 'max' => 100], ]; @@ -66,6 +68,8 @@ class MarketplaceOrder1cStatuses extends \yii\db\ActiveRecord 'id' => 'ID', 'marketplace_id' => 'Маркетплейс ID', 'status_id' => 'артикул', + 'allowed_reserve' => 'Разрешено резервирование', + 'allowed_closing' => 'Разрешено закрытие', 'status' => 'Статус', 'status_instruction' => 'Инструкция к статусу', 'posit' => 'Порядок статусов', diff --git a/erp24/views/crud/marketplace-order1c-statuses/_form.php b/erp24/views/crud/marketplace-order1c-statuses/_form.php index 42247378..8cb9eb6a 100644 --- a/erp24/views/crud/marketplace-order1c-statuses/_form.php +++ b/erp24/views/crud/marketplace-order1c-statuses/_form.php @@ -49,6 +49,24 @@ $this->registerJsFile( field($model, 'status')->textInput(['maxlength' => true]) ?> + field($model, 'allowed_reserve') + ->dropDownList( + [0 => 'Нет', 1 => 'Да'], + [ + 'prompt' => 'Выберите разрешено ли резервирование', + 'id' => 'marketplace-order1cstatuses-allowed_reserve', + ] + ) ?> + + field($model, 'allowed_closing') + ->dropDownList( + [0 => 'Нет', 1 => 'Да'], + [ + 'prompt' => 'Выберите разрешено ли закрытие', + 'id' => 'marketplace-order1cstatuses-allowed_closing', + ] + ) ?> + field($model, 'status_instruction')->textarea(['rows' => 4]) ?>
'btn btn-success']) ?> diff --git a/erp24/views/crud/marketplace-order1c-statuses/index.php b/erp24/views/crud/marketplace-order1c-statuses/index.php index 4808d653..cdb0f56a 100644 --- a/erp24/views/crud/marketplace-order1c-statuses/index.php +++ b/erp24/views/crud/marketplace-order1c-statuses/index.php @@ -47,6 +47,18 @@ $this->params['breadcrumbs'][] = $this->title; } ], 'status', + [ + 'attribute' => 'allowed_reserve', + 'value' => function ($model) { + return $model->allowed_reserve === 0 ? 'Нет' : 'Да'; + } + ], + [ + 'attribute' => 'allowed_closing', + 'value' => function ($model) { + return $model->allowed_closing === 0 ? 'Нет' : 'Да'; + } + ], 'status_instruction:ntext', [ 'class' => ActionColumn::class, diff --git a/erp24/views/crud/marketplace-order1c-statuses/view.php b/erp24/views/crud/marketplace-order1c-statuses/view.php index ef4393e4..e3337c83 100644 --- a/erp24/views/crud/marketplace-order1c-statuses/view.php +++ b/erp24/views/crud/marketplace-order1c-statuses/view.php @@ -42,6 +42,18 @@ $this->params['breadcrumbs'][] = $this->title; } ], 'status', + [ + 'attribute' => 'allowed_reserve', + 'value' => function ($model) { + return $model->allowed_reserve === 0 ? 'Нет' : 'Да'; + } + ], + [ + 'attribute' => 'allowed_closing', + 'value' => function ($model) { + return $model->allowed_closing === 0 ? 'Нет' : 'Да'; + } + ], 'status_instruction:ntext', [ 'label' => 'Связанные статусы', -- 2.39.5