]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление полей статусов
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 2 Jul 2025 14:51:44 +0000 (17:51 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 2 Jul 2025 14:51:44 +0000 (17:51 +0300)
erp24/commands/CronController.php
erp24/migrations/m250702_140510_add_allowed_fields_to_marketplace_order_1c_statuses_table.php [new file with mode: 0644]
erp24/records/MarketplaceOrder1cStatuses.php
erp24/views/crud/marketplace-order1c-statuses/_form.php
erp24/views/crud/marketplace-order1c-statuses/index.php
erp24/views/crud/marketplace-order1c-statuses/view.php

index 480b37897896d9d4dc7902fe3b4fa8cbb5f4220c..e31cad29c36f8fee7d620fd28f764fceab53dbdb 100644 (file)
@@ -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 (file)
index 0000000..2075284
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+use yii\db\Migration;
+
+class m250702_140510_add_allowed_fields_to_marketplace_order_1c_statuses_table extends Migration
+{
+    const TABLE_NAME = 'erp24.marketplace_order_1c_statuses';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $table = $this->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;
+    }
+    */
+}
index 4a396ebb72d6a8628004205e729d8e4c7b16fb18..28530fb43634ac0a889ea8f977d2965fdc70d3bc 100644 (file)
@@ -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' => 'Порядок статусов',
index 42247378184084bfdf5d4aa3abe2db221e264d22..8cb9eb6a82fd4f16aeec771613ff662ddaca6470 100644 (file)
@@ -49,6 +49,24 @@ $this->registerJsFile(
 
     <?= $form->field($model, 'status')->textInput(['maxlength' => true]) ?>
 
+    <?= $form->field($model, 'allowed_reserve')
+        ->dropDownList(
+            [0 => 'Нет', 1 => 'Да'],
+            [
+                'prompt' => 'Выберите разрешено ли резервирование',
+                'id' => 'marketplace-order1cstatuses-allowed_reserve',
+            ]
+        ) ?>
+
+    <?= $form->field($model, 'allowed_closing')
+        ->dropDownList(
+            [0 => 'Нет', 1 => 'Да'],
+            [
+                'prompt' => 'Выберите разрешено ли закрытие',
+                'id' => 'marketplace-order1cstatuses-allowed_closing',
+            ]
+        ) ?>
+
     <?= $form->field($model, 'status_instruction')->textarea(['rows' => 4]) ?>
     <div class="form-group">
         <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
index 4808d653f556d2c9784ff4661739db8553303293..cdb0f56a35756d8f668272b0ec19c4ae2acb663f 100644 (file)
@@ -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,
index ef4393e460d4e8ee0a5678c2c2f7693040ba77d8..e3337c83eaac04759f68aa91bd81cf6c2fef953c 100644 (file)
@@ -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' => 'Связанные статусы',