namespace app\controllers;
+use Yii;
+use yii_app\records\MarketplaceOrders;
use yii_app\records\MarketplaceStatus;
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'
+ ]];
+ }
+}
--- /dev/null
+<?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.');
+ }
+}
--- /dev/null
+<?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);
+ }
+ }
+}
--- /dev/null
+<?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' => 'Инструкция к статусу',
+ ];
+ }
+}
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+<?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>
--- /dev/null
+<?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>