From bdc51cc999d90f5c67b655e89c327e8d72d5a0a9 Mon Sep 17 00:00:00 2001 From: marina Date: Wed, 23 Oct 2024 16:59:38 +0300 Subject: [PATCH] =?utf8?q?ERP-150=20=D0=9F=D1=80=D0=B8=D1=81=D0=B2=D0=BE?= =?utf8?q?=D0=B8=D1=82=D1=8C=20=D0=BA=D0=B0=D0=B6=D0=B4=D0=BE=D0=BC=D1=83?= =?utf8?q?=20=D0=BC=D0=B0=D0=B3=D0=B0=D0=B7=D0=B8=D0=BD=D1=83=20ID=20?= =?utf8?q?=D1=81=D0=BA=D0=BB=D0=B0=D0=B4=D0=B0=20=D0=BE=D1=82=D0=BA=D0=B0?= =?utf8?q?=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../MarketplaceStoreController.php | 95 ++++++++++++++++++ ..._064710_create_marketplace_store_table.php | 44 +++++++++ erp24/records/MarketplaceStore.php | 96 +++++++++++++++++++ erp24/views/marketplace-store/_form.php | 39 ++++++++ erp24/views/marketplace-store/create.php | 21 ++++ erp24/views/marketplace-store/index.php | 46 +++++++++ erp24/views/marketplace-store/update.php | 21 ++++ erp24/views/marketplace-store/view.php | 68 +++++++++++++ 8 files changed, 430 insertions(+) create mode 100644 erp24/controllers/MarketplaceStoreController.php create mode 100644 erp24/migrations/m241023_064710_create_marketplace_store_table.php create mode 100644 erp24/records/MarketplaceStore.php create mode 100644 erp24/views/marketplace-store/_form.php create mode 100644 erp24/views/marketplace-store/create.php create mode 100644 erp24/views/marketplace-store/index.php create mode 100644 erp24/views/marketplace-store/update.php create mode 100644 erp24/views/marketplace-store/view.php diff --git a/erp24/controllers/MarketplaceStoreController.php b/erp24/controllers/MarketplaceStoreController.php new file mode 100644 index 00000000..a5be886c --- /dev/null +++ b/erp24/controllers/MarketplaceStoreController.php @@ -0,0 +1,95 @@ + MarketplaceStore::find(), + 'pagination' => false, + ]); + + return $this->render('index', [ + 'dataProvider' => $dataProvider, + 'firms' => $firms + ]); + } + + public function actionView($id) + { + $model = $this->findModel($id); + $firms = Firms::getInn(); + + return $this->render('view', [ + 'model' => $model, + 'firms' => $firms, + ]); + } + + public function actionCreate() + { + $model = new MarketplaceStore(); + $stores = CityStore::getAllActiveIdName(); + $firms = Firms::getInn(); + $storesGuid = CityStore::getAllActiveGuidId(); + + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('create', [ + 'model' => $model, + 'stores' => $stores, + 'storesGuid' => $storesGuid, + 'firms' => $firms, + ]); + } + + public function actionUpdate($id) + { + $model = MarketplaceStore::findOne($id); + $stores = CityStore::getAllActiveIdName(); + $firms = Firms::getInn(); + $storesGuid = CityStore::getAllActiveGuidId(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + 'stores' => $stores, + 'storesGuid' => $storesGuid, + 'firms' => $firms, + ]); + } + + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + protected function findModel($id) + { + if (($model = MarketplaceStore::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/erp24/migrations/m241023_064710_create_marketplace_store_table.php b/erp24/migrations/m241023_064710_create_marketplace_store_table.php new file mode 100644 index 00000000..bf3cae0e --- /dev/null +++ b/erp24/migrations/m241023_064710_create_marketplace_store_table.php @@ -0,0 +1,44 @@ +db->schema->getTableSchema('erp24.marketplace_store', true)) { + $this->createTable('{{%erp24.marketplace_store}}', [ + 'id' => $this->primaryKey(), + 'store_id' => $this->integer()->notNull()->comment('id магазина'), + 'guid' => $this->string(255)->notNull()->comment('гуид магазина'), + 'name' => $this->string()->comment('название магазина(адрес) = название склада'), + 'yandex_market_id' => $this->integer()->comment('id склада в данном маркетплейсе'), + 'flowwow_id' => $this->integer()->comment('id склада в данном маркетплейсе'), + 'firm' => $this->string(255)->comment('юр . лицо, к которому относится магазин'), + 'created_at' => $this->datetime()->notNull()->comment('дата создания записи'), + 'created_by' => $this->integer()->notNull()->comment('автор создания записи'), + 'updated_at' => $this->datetime()->notNull()->comment('дата изменения записи'), + 'updated_by' => $this->integer()->notNull()->comment('автор изменения записи'), + ]); + + $this->addForeignKey('fk_marketplace_store_to_city_store', '{{%erp24.marketplace_store}}', 'store_id', '{{%city_store}}', 'id'); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + if ($this->db->schema->getTableSchema('erp24.marketplace_store', true)) { + $this->dropForeignKey('fk_marketplace_store_to_city_store', '{{%erp24.marketplace_store}}'); + $this->dropTable('{{%erp24.marketplace_store}}'); + } + } +} diff --git a/erp24/records/MarketplaceStore.php b/erp24/records/MarketplaceStore.php new file mode 100644 index 00000000..7c30aa6a --- /dev/null +++ b/erp24/records/MarketplaceStore.php @@ -0,0 +1,96 @@ + CityStore::class, 'targetAttribute' => 'id'], + [['name', 'guid', 'firm'], 'string'], + [['store_id', 'yandex_market_id', 'flowwow_id', 'created_at', 'created_by', 'updated_at', 'updated_by'], 'integer'], + + ]; + } + + public function behaviors() + { + return [ + [ + 'class' => TimestampBehavior::class, + 'createdAtAttribute' => 'created_at', + 'updatedAtAttribute' => 'updated_at', + 'value' => new Expression('NOW()'), + ], + [ + 'class' => BlameableBehavior::class, + 'createdByAttribute' => 'created_by', + 'updatedByAttribute' => 'updated_by', + ], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'store_id' => 'ID магазина', + 'guid' => 'GUID магазина', + 'name' => 'Название магазина(адрес) = Название склада', + 'yandex_market_id' => 'ID склада в Яндекс Маркете', + 'flowwow_id' => 'ID склада в Flowwow', + 'firm' => 'Юр.лицо, к которому относится магазин', + 'created_at' => 'Дата создания записи', + 'created_by' => 'Автор создания записи', + 'updated_at' => 'Дата изменения записи', + 'updated_by' => 'Автор изменения записи' + ]; + } + + public function getStore() { + return $this->hasOne(CityStore::class, ['id' => 'store_id']); + } + + public function getCreatedBy() { + return $this->hasOne(Admin::class, ['id' => 'created_by']); + } + + public function getUpdatedBy() { + return $this->hasOne(Admin::class, ['id' => 'updated_by']); + } +} diff --git a/erp24/views/marketplace-store/_form.php b/erp24/views/marketplace-store/_form.php new file mode 100644 index 00000000..7331b3f4 --- /dev/null +++ b/erp24/views/marketplace-store/_form.php @@ -0,0 +1,39 @@ + + +
+ + + field($model, 'store_id')->dropDownList($stores, [ + 'prompt' => 'Выберите магазин', + 'onchange' => 'updateGuid(this.value)' // Вызов функции для обновления guid + ]) ?> + + field($model, 'guid')->textInput(['maxlength' => true, 'value' => $model->guid, 'readonly' => true, 'id' => 'guid-input']) ?> + field($model, 'yandex_market_id')->textInput() ?> + field($model, 'flowwow_id')->textInput(['type' => 'integer']) ?> + field($model, 'firm')->dropDownList($firms, ['prompt' => 'Выберите юр лицо']) ?> + +
+ isNewRecord ? 'Создать' : 'Сохранить', ['class' => 'btn btn-success']) ?> +
+ + + +
+ + + \ No newline at end of file diff --git a/erp24/views/marketplace-store/create.php b/erp24/views/marketplace-store/create.php new file mode 100644 index 00000000..c7031bae --- /dev/null +++ b/erp24/views/marketplace-store/create.php @@ -0,0 +1,21 @@ +title = 'Создать Магазин'; +$this->params['breadcrumbs'][] = ['label' => 'Список Магазинов', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> + +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + 'stores' => $stores, + 'storesGuid' => $storesGuid, + 'firms' => $firms, + ]) ?> + +
diff --git a/erp24/views/marketplace-store/index.php b/erp24/views/marketplace-store/index.php new file mode 100644 index 00000000..43c01573 --- /dev/null +++ b/erp24/views/marketplace-store/index.php @@ -0,0 +1,46 @@ +title = 'Список Магазинов'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + [ + 'attribute' => 'store_id', + 'value' => function ($model) { + return $model->store->name; + } + ], + 'guid', + 'yandex_market_id', + 'flowwow_id', + [ + 'attribute' => 'firm', + 'value' => function ($model) { + return Firms::getInn()[$model->firm]; + } + ], + 'created_at', + 'updated_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/erp24/views/marketplace-store/update.php b/erp24/views/marketplace-store/update.php new file mode 100644 index 00000000..f5e9bca5 --- /dev/null +++ b/erp24/views/marketplace-store/update.php @@ -0,0 +1,21 @@ +title = 'Обновить Магазин: ' . $model->store->name; +$this->params['breadcrumbs'][] = ['label' => 'Список Магазинов', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> + +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + 'stores' => $stores, + 'storesGuid' => $storesGuid, + 'firms' => $firms, + ]) ?> + +
diff --git a/erp24/views/marketplace-store/view.php b/erp24/views/marketplace-store/view.php new file mode 100644 index 00000000..7c988264 --- /dev/null +++ b/erp24/views/marketplace-store/view.php @@ -0,0 +1,68 @@ +title = 'Просмотр магазина: ' . $model->store->name; +$this->params['breadcrumbs'][] = ['label' => 'Список Магазинов', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> + +
+ +

title) ?>

+ +

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

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDid) ?>
ID Магазинаstore->name) ?>
GUIDguid) ?>
ID в Яндекс.Маркетеyandex_market_id) ?>
ID в Flowwowflowwow_id) ?>
Юридическое Лицоfirm]) ?>
Автор созданияcreatedBy->name) ?>
Дата созданияcreated_at))) ?>
Автор обновленияupdatedBy->name) ?>
Дата обновленияupdated_at))) ?>
+ +
-- 2.39.5