From: Alexander Smirnov Date: Fri, 14 Mar 2025 15:52:34 +0000 (+0300) Subject: [ERP-372] marketplace order status dictionary X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=088009c866eb1750ee0d584aa9418b8276eb7368;p=erp24_rep%2Fyii-erp24%2F.git [ERP-372] marketplace order status dictionary --- diff --git a/erp24/api2/controllers/MarketplaceController.php b/erp24/api2/controllers/MarketplaceController.php index 11773d84..8f18f4c6 100644 --- a/erp24/api2/controllers/MarketplaceController.php +++ b/erp24/api2/controllers/MarketplaceController.php @@ -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 index 00000000..42a698d4 --- /dev/null +++ b/erp24/controllers/crud/MarketplaceOrder1cStatusesController.php @@ -0,0 +1,144 @@ + [ + '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 index 00000000..c02a15a9 --- /dev/null +++ b/erp24/migrations/m250314_114026_create_table_marketplace_order_1c_statuses.php @@ -0,0 +1,42 @@ +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 index 00000000..38a6c542 --- /dev/null +++ b/erp24/records/MarketplaceOrder1cStatuses.php @@ -0,0 +1,51 @@ + 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 index 00000000..cea0b927 --- /dev/null +++ b/erp24/views/crud/marketplace-order-1c-statuses/_form.php @@ -0,0 +1,27 @@ + + +
+ + + + field($model, 'marketplace_id')->dropDownList([1 => 'ФлауВау', 2 => 'ЯндексМаркет']) ?> + + field($model, 'status')->textInput(['maxlength' => true]) ?> + + field($model, 'status_instruction')->textarea(['rows' => 6]) ?> + +
+ 'btn btn-success']) ?> +
+ + + +
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 index 00000000..59eaeedd --- /dev/null +++ b/erp24/views/crud/marketplace-order-1c-statuses/create.php @@ -0,0 +1,20 @@ +title = 'Create Marketplace Order1c Statuses'; +$this->params['breadcrumbs'][] = ['label' => 'Marketplace Order1c Statuses', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
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 index 00000000..011e0caa --- /dev/null +++ b/erp24/views/crud/marketplace-order-1c-statuses/index.php @@ -0,0 +1,49 @@ +title = 'Маркетплейс статусы заказа'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ 'btn btn-success']) ?> +

+ + + $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]); + } + ], + ], + ]); ?> + + +
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 index 00000000..3ed56535 --- /dev/null +++ b/erp24/views/crud/marketplace-order-1c-statuses/update.php @@ -0,0 +1,24 @@ +title = 'Обновить маркетплейс статус заказа: ' . $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Маркетплейс статус заказа', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

+ 'btn btn-secondary btn-sm'])?> + title) ?> +

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
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 index 00000000..103faefa --- /dev/null +++ b/erp24/views/crud/marketplace-order-1c-statuses/view.php @@ -0,0 +1,47 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Маркетплейс статусы заказа', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ +

+ 'btn btn-secondary btn-sm'])?> + title) ?> +

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Вы уверены, что хотите удалить эту запись?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + [ + 'attribute' => 'marketplace_id', + 'value' => function ($data) { + return [1 => 'ФлауВау', 2 => 'ЯндексМаркет'][$data->marketplace_id]; + } + ], + 'status', + 'status_instruction:ntext', + ], + ]) ?> + +