]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-372] marketplace order status dictionary
authorAlexander Smirnov <fredeom@mail.ru>
Fri, 14 Mar 2025 15:52:34 +0000 (18:52 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Fri, 14 Mar 2025 15:52:34 +0000 (18:52 +0300)
erp24/api2/controllers/MarketplaceController.php
erp24/controllers/crud/MarketplaceOrder1cStatusesController.php [new file with mode: 0644]
erp24/migrations/m250314_114026_create_table_marketplace_order_1c_statuses.php [new file with mode: 0755]
erp24/records/MarketplaceOrder1cStatuses.php [new file with mode: 0644]
erp24/views/crud/marketplace-order-1c-statuses/_form.php [new file with mode: 0644]
erp24/views/crud/marketplace-order-1c-statuses/create.php [new file with mode: 0644]
erp24/views/crud/marketplace-order-1c-statuses/index.php [new file with mode: 0644]
erp24/views/crud/marketplace-order-1c-statuses/update.php [new file with mode: 0644]
erp24/views/crud/marketplace-order-1c-statuses/view.php [new file with mode: 0644]

index 11773d84f71fd3b514f0680be1ad3531a2e46dd2..8f18f4c686b7e7996996c3829c9149949b91f953 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace app\controllers;
 
+use Yii;
+use yii_app\records\MarketplaceOrders;
 use yii_app\records\MarketplaceStatus;
 
 class MarketplaceController extends BaseController
@@ -10,4 +12,16 @@ class MarketplaceController extends BaseController
         $this->response->format = \yii\web\Response::FORMAT_JSON;
         return ['response' => MarketplaceStatus::find()->asArray()->all()];
     }
-}
\ No newline at end of file
+
+    public function actionInstructionDictionary() {
+        $this->response->format = \yii\web\Response::FORMAT_JSON;
+        $marketplaceGuid = Yii::$app->request->post('guid');
+        $marketplaceOrder = MarketplaceOrders::find()->where(['guid' => $marketplaceGuid])->one();
+        /** @var $marketplaceOrder MarketplaceOrders */
+        return ['response' => [
+            'marketplace' => $marketplaceOrder->marketplace_id,
+            'status' => 'new',
+            'status_instruction' => 'description'
+        ]];
+    }
+}
diff --git a/erp24/controllers/crud/MarketplaceOrder1cStatusesController.php b/erp24/controllers/crud/MarketplaceOrder1cStatusesController.php
new file mode 100644 (file)
index 0000000..42a698d
--- /dev/null
@@ -0,0 +1,144 @@
+<?php
+
+namespace yii_app\controllers\crud;
+
+use yii_app\records\MarketplaceOrder1cStatuses;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+/**
+ * MarketplaceOrder1cStatusesController implements the CRUD actions for MarketplaceOrder1cStatuses model.
+ */
+class MarketplaceOrder1cStatusesController extends Controller
+{
+    /**
+     * @inheritDoc
+     */
+    public function behaviors()
+    {
+        return array_merge(
+            parent::behaviors(),
+            [
+                'verbs' => [
+                    'class' => VerbFilter::className(),
+                    'actions' => [
+                        'delete' => ['POST'],
+                    ],
+                ],
+            ]
+        );
+    }
+
+    /**
+     * Lists all MarketplaceOrder1cStatuses models.
+     *
+     * @return string
+     */
+    public function actionIndex()
+    {
+        $dataProvider = new ActiveDataProvider([
+            'query' => MarketplaceOrder1cStatuses::find(),
+            /*
+            'pagination' => [
+                'pageSize' => 50
+            ],
+            'sort' => [
+                'defaultOrder' => [
+                    'id' => SORT_DESC,
+                ]
+            ],
+            */
+        ]);
+
+        return $this->render('index', [
+            'dataProvider' => $dataProvider,
+        ]);
+    }
+
+    /**
+     * Displays a single MarketplaceOrder1cStatuses model.
+     * @param int $id ID
+     * @return string
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionView($id)
+    {
+        return $this->render('view', [
+            'model' => $this->findModel($id),
+        ]);
+    }
+
+    /**
+     * Creates a new MarketplaceOrder1cStatuses model.
+     * If creation is successful, the browser will be redirected to the 'view' page.
+     * @return string|\yii\web\Response
+     */
+    public function actionCreate()
+    {
+        $model = new MarketplaceOrder1cStatuses();
+
+        if ($this->request->isPost) {
+            if ($model->load($this->request->post()) && $model->save()) {
+                return $this->redirect(['view', 'id' => $model->id]);
+            }
+        } else {
+            $model->loadDefaultValues();
+        }
+
+        return $this->render('create', [
+            'model' => $model,
+        ]);
+    }
+
+    /**
+     * Updates an existing MarketplaceOrder1cStatuses model.
+     * If update is successful, the browser will be redirected to the 'view' page.
+     * @param int $id ID
+     * @return string|\yii\web\Response
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionUpdate($id)
+    {
+        $model = $this->findModel($id);
+
+        if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
+            return $this->redirect(['view', 'id' => $model->id]);
+        }
+
+        return $this->render('update', [
+            'model' => $model,
+        ]);
+    }
+
+    /**
+     * Deletes an existing MarketplaceOrder1cStatuses model.
+     * If deletion is successful, the browser will be redirected to the 'index' page.
+     * @param int $id ID
+     * @return \yii\web\Response
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    public function actionDelete($id)
+    {
+        $this->findModel($id)->delete();
+
+        return $this->redirect(['index']);
+    }
+
+    /**
+     * Finds the MarketplaceOrder1cStatuses model based on its primary key value.
+     * If the model is not found, a 404 HTTP exception will be thrown.
+     * @param int $id ID
+     * @return MarketplaceOrder1cStatuses the loaded model
+     * @throws NotFoundHttpException if the model cannot be found
+     */
+    protected function findModel($id)
+    {
+        if (($model = MarketplaceOrder1cStatuses::findOne(['id' => $id])) !== null) {
+            return $model;
+        }
+
+        throw new NotFoundHttpException('The requested page does not exist.');
+    }
+}
diff --git a/erp24/migrations/m250314_114026_create_table_marketplace_order_1c_statuses.php b/erp24/migrations/m250314_114026_create_table_marketplace_order_1c_statuses.php
new file mode 100755 (executable)
index 0000000..c02a15a
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m250314_114026_create_table_marketplace_order_1c_statuses
+ */
+class m250314_114026_create_table_marketplace_order_1c_statuses extends Migration
+{
+    const TABLE_NAME = 'erp24.marketplace_order_1c_statuses';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (!isset($tableSchema)) {
+            $this->createTable(self::TABLE_NAME, [
+                'id' => $this->primaryKey(),
+                'marketplace_id' => $this->integer()->notNull()->comment('Маркетплейс'),
+                'status' => $this->string(100)->notNull()->comment('Статус'),
+                'status_instruction' => $this->text()->notNull()->comment('Инструкция к статусу'),
+            ]);
+
+//            $this->batchInsert(self::TABLE_NAME, ['marketplace_id', 'status', 'status_instruction'], [
+//
+//            ]);
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+        if (isset($tableSchema)) {
+            $this->dropTable(self::TABLE_NAME);
+        }
+    }
+}
diff --git a/erp24/records/MarketplaceOrder1cStatuses.php b/erp24/records/MarketplaceOrder1cStatuses.php
new file mode 100644 (file)
index 0000000..38a6c54
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "marketplace_order_1c_statuses".
+ *
+ * @property int $id
+ * @property int $marketplace_id Маркетплейс
+ * @property string $status Статус
+ * @property string $status_instruction Инструкция к статусу
+ */
+class MarketplaceOrder1cStatuses extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'marketplace_order_1c_statuses';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['marketplace_id', 'status', 'status_instruction'], 'required'],
+            [['marketplace_id'], 'default', 'value' => null],
+            [['marketplace_id'], 'integer'],
+            [['status_instruction'], 'string'],
+            [['status'], 'string', 'max' => 100],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'marketplace_id' => 'Маркетплейс ID',
+            'status' => 'Статус',
+            'status_instruction' => 'Инструкция к статусу',
+        ];
+    }
+}
diff --git a/erp24/views/crud/marketplace-order-1c-statuses/_form.php b/erp24/views/crud/marketplace-order-1c-statuses/_form.php
new file mode 100644 (file)
index 0000000..cea0b92
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\MarketplaceOrder1cStatuses $model */
+/** @var yii\widgets\ActiveForm $form */
+?>
+
+<div class="marketplace-order1c-statuses-form">
+
+    <?php $form = ActiveForm::begin(); ?>
+
+    <?= $form->field($model, 'marketplace_id')->dropDownList([1 => 'ФлауВау', 2 => 'ЯндексМаркет']) ?>
+
+    <?= $form->field($model, 'status')->textInput(['maxlength' => true]) ?>
+
+    <?= $form->field($model, 'status_instruction')->textarea(['rows' => 6]) ?>
+
+    <div class="form-group">
+        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+    </div>
+
+    <?php ActiveForm::end(); ?>
+
+</div>
diff --git a/erp24/views/crud/marketplace-order-1c-statuses/create.php b/erp24/views/crud/marketplace-order-1c-statuses/create.php
new file mode 100644 (file)
index 0000000..59eaeed
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+use yii\helpers\Html;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\MarketplaceOrder1cStatuses $model */
+
+$this->title = 'Create Marketplace Order1c Statuses';
+$this->params['breadcrumbs'][] = ['label' => 'Marketplace Order1c Statuses', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="marketplace-order1c-statuses-create m-5">
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+    <?= $this->render('_form', [
+        'model' => $model,
+    ]) ?>
+
+</div>
diff --git a/erp24/views/crud/marketplace-order-1c-statuses/index.php b/erp24/views/crud/marketplace-order-1c-statuses/index.php
new file mode 100644 (file)
index 0000000..011e0ca
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+use yii_app\records\MarketplaceOrder1cStatuses;
+use yii\helpers\Html;
+use yii\helpers\Url;
+use yii\grid\ActionColumn;
+use yii\grid\GridView;
+
+/** @var yii\web\View $this */
+/** @var yii\data\ActiveDataProvider $dataProvider */
+
+$this->title = 'Маркетплейс статусы заказа';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="marketplace-order1c-statuses-index m-5">
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+    <p>
+        <?= Html::a('Создать Маркетплейс Статус Заказа', ['create'], ['class' => 'btn btn-success']) ?>
+    </p>
+
+
+    <?= GridView::widget([
+        'dataProvider' => $dataProvider,
+        'columns' => [
+            ['class' => 'yii\grid\SerialColumn'],
+
+            'id',
+            [
+                'attribute' => 'marketplace_id',
+                'label' => 'Маркетплейс',
+                'value' => function ($model) {
+                    return [1 => 'ФлауВау', 2 => 'ЯндексМаркет'][$model->marketplace_id];
+                }
+            ],
+            'status',
+            'status_instruction:ntext',
+            [
+                'class' => ActionColumn::class,
+                'urlCreator' => function ($action, MarketplaceOrder1cStatuses $model, $key, $index, $column) {
+                    return Url::toRoute([$action, 'id' => $model->id]);
+                }
+            ],
+        ],
+    ]); ?>
+
+
+</div>
diff --git a/erp24/views/crud/marketplace-order-1c-statuses/update.php b/erp24/views/crud/marketplace-order-1c-statuses/update.php
new file mode 100644 (file)
index 0000000..3ed5653
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+use yii\helpers\Html;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\MarketplaceOrder1cStatuses $model */
+
+$this->title = 'Обновить маркетплейс статус заказа: ' . $model->id;
+$this->params['breadcrumbs'][] = ['label' => 'Маркетплейс статус заказа', 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
+$this->params['breadcrumbs'][] = 'Update';
+?>
+<div class="marketplace-order1c-statuses-update m-5">
+
+    <h1>
+        <?= Html::a('Назад', ['index'], ['class' => 'btn btn-secondary btn-sm'])?>
+        <?= Html::encode($this->title) ?>
+    </h1>
+
+    <?= $this->render('_form', [
+        'model' => $model,
+    ]) ?>
+
+</div>
diff --git a/erp24/views/crud/marketplace-order-1c-statuses/view.php b/erp24/views/crud/marketplace-order-1c-statuses/view.php
new file mode 100644 (file)
index 0000000..103faef
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\MarketplaceOrder1cStatuses $model */
+
+$this->title = $model->id;
+$this->params['breadcrumbs'][] = ['label' => 'Маркетплейс статусы заказа', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+\yii\web\YiiAsset::register($this);
+?>
+<div class="marketplace-order1c-statuses-view m-5">
+
+    <h1>
+        <?= Html::a('Назад', ['index'], ['class' => 'btn btn-secondary btn-sm'])?>
+        <?= Html::encode($this->title) ?>
+    </h1>
+
+    <p>
+        <?= Html::a('Обновить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+        <?= Html::a('Удалить', ['delete', 'id' => $model->id], [
+            'class' => 'btn btn-danger',
+            'data' => [
+                'confirm' => 'Вы уверены, что хотите удалить эту запись?',
+                'method' => 'post',
+            ],
+        ]) ?>
+    </p>
+
+    <?= DetailView::widget([
+        'model' => $model,
+        'attributes' => [
+            'id',
+            [
+                'attribute' => 'marketplace_id',
+                'value' => function ($data) {
+                    return [1 => 'ФлауВау', 2 => 'ЯндексМаркет'][$data->marketplace_id];
+                }
+            ],
+            'status',
+            'status_instruction:ntext',
+        ],
+    ]) ?>
+
+</div>