From: marina Date: Thu, 24 Oct 2024 06:45:32 +0000 (+0300) Subject: ERP-150 Присвоить каждому магазину ID склада X-Git-Tag: 1.6~27^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=d32da7b1f61e8a8f65e3eeeb985133e9dbf0204b;p=erp24_rep%2Fyii-erp24%2F.git ERP-150 Присвоить каждому магазину ID склада --- diff --git a/erp24/controllers/MarketplaceStoreController.php b/erp24/controllers/MarketplaceStoreController.php index a5be886c..94453380 100644 --- a/erp24/controllers/MarketplaceStoreController.php +++ b/erp24/controllers/MarketplaceStoreController.php @@ -31,10 +31,12 @@ class MarketplaceStoreController extends Controller { $model = $this->findModel($id); $firms = Firms::getInn(); + $warehouses = MarketplaceStore::getWarehouseId(); return $this->render('view', [ 'model' => $model, 'firms' => $firms, + 'warehouses' => $warehouses ]); } @@ -44,6 +46,7 @@ class MarketplaceStoreController extends Controller $stores = CityStore::getAllActiveIdName(); $firms = Firms::getInn(); $storesGuid = CityStore::getAllActiveGuidId(); + $warehouses = MarketplaceStore::getWarehouseId(); if ($model->load(Yii::$app->request->post()) && $model->save()) { @@ -55,6 +58,7 @@ class MarketplaceStoreController extends Controller 'stores' => $stores, 'storesGuid' => $storesGuid, 'firms' => $firms, + 'warehouses' => $warehouses ]); } @@ -64,6 +68,7 @@ class MarketplaceStoreController extends Controller $stores = CityStore::getAllActiveIdName(); $firms = Firms::getInn(); $storesGuid = CityStore::getAllActiveGuidId(); + $warehouses = MarketplaceStore::getWarehouseId(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); @@ -74,6 +79,7 @@ class MarketplaceStoreController extends Controller 'stores' => $stores, 'storesGuid' => $storesGuid, 'firms' => $firms, + 'warehouses' => $warehouses ]); } diff --git a/erp24/migrations/m241023_064710_create_marketplace_store_table.php b/erp24/migrations/m241023_064710_create_marketplace_store_table.php index bf3cae0e..8775934d 100644 --- a/erp24/migrations/m241023_064710_create_marketplace_store_table.php +++ b/erp24/migrations/m241023_064710_create_marketplace_store_table.php @@ -18,8 +18,8 @@ class m241023_064710_create_marketplace_store_table extends Migration '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 склада в данном маркетплейсе'), + 'warehouse_id' => $this->integer()->comment('id маркетплейса'), + 'warehouse_guid' => $this->integer()->comment('guid склада в данном маркетплейсе'), 'firm' => $this->string(255)->comment('юр . лицо, к которому относится магазин'), 'created_at' => $this->datetime()->notNull()->comment('дата создания записи'), 'created_by' => $this->integer()->notNull()->comment('автор создания записи'), diff --git a/erp24/records/MarketplaceStore.php b/erp24/records/MarketplaceStore.php index 7c30aa6a..36884a4b 100644 --- a/erp24/records/MarketplaceStore.php +++ b/erp24/records/MarketplaceStore.php @@ -13,8 +13,8 @@ use yii\db\Expression; * @property int $id * @property int $store_id * @property string $guid - * @property int $yandex_market_id - * @property int $flowwow_id + * @property int $warehouse_id + * @property string $warehouse_guid * @property string $firm * @property int $created_at * @property int $created_by @@ -37,10 +37,11 @@ class MarketplaceStore extends \yii\db\ActiveRecord public function rules() { return [ - [['store_id', 'guid', 'yandex_market_id', 'flowwow_id', 'firm'], 'required'], + [['store_id', 'guid', 'warehouse_id', 'warehouse_guid', 'firm'], 'required'], [['store_id'], 'exist', 'targetClass' => CityStore::class, 'targetAttribute' => 'id'], - [['name', 'guid', 'firm'], 'string'], - [['store_id', 'yandex_market_id', 'flowwow_id', 'created_at', 'created_by', 'updated_at', 'updated_by'], 'integer'], + [['name', 'guid', 'firm', 'warehouse_guid',], 'string'], + [['created_at', 'updated_at'], 'datetime', 'format' => 'php:Y-m-d H:i:s'], + [['store_id', 'created_by', 'updated_by', 'warehouse_id',], 'integer'], ]; } @@ -52,7 +53,7 @@ class MarketplaceStore extends \yii\db\ActiveRecord 'class' => TimestampBehavior::class, 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at', - 'value' => new Expression('NOW()'), + 'value' => new Expression('NOW()') ], [ 'class' => BlameableBehavior::class, @@ -72,8 +73,8 @@ class MarketplaceStore extends \yii\db\ActiveRecord 'store_id' => 'ID магазина', 'guid' => 'GUID магазина', 'name' => 'Название магазина(адрес) = Название склада', - 'yandex_market_id' => 'ID склада в Яндекс Маркете', - 'flowwow_id' => 'ID склада в Flowwow', + 'warehouse_id' => 'Маркетплейс', + 'warehouse_guid' => 'GUID склада в данном маркетплейсе', 'firm' => 'Юр.лицо, к которому относится магазин', 'created_at' => 'Дата создания записи', 'created_by' => 'Автор создания записи', @@ -82,6 +83,13 @@ class MarketplaceStore extends \yii\db\ActiveRecord ]; } + public static function getWarehouseId() { + return array( + '1' => 'Flowwow', + '2' => 'Яндекс Маркет', + ); + } + public function getStore() { return $this->hasOne(CityStore::class, ['id' => 'store_id']); } diff --git a/erp24/views/marketplace-store/_form.php b/erp24/views/marketplace-store/_form.php index 7331b3f4..d4acad91 100644 --- a/erp24/views/marketplace-store/_form.php +++ b/erp24/views/marketplace-store/_form.php @@ -12,12 +12,15 @@ use yii\widgets\ActiveForm; field($model, 'store_id')->dropDownList($stores, [ 'prompt' => 'Выберите магазин', - 'onchange' => 'updateGuid(this.value)' // Вызов функции для обновления guid + 'onchange' => 'updateGuid(this.value); updateName(this.value)' ]) ?> 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, 'name')->textInput(['maxlength' => true, 'value' => $model->name, 'readonly' => true, 'id' => 'name-input']) ?> + field($model, 'warehouse_id')->dropDownList($warehouses, [ + 'prompt' => 'Выберите маркетплейс' + ]) ?> + field($model, 'warehouse_guid')->textInput(['type' => 'integer']) ?> field($model, 'firm')->dropDownList($firms, ['prompt' => 'Выберите юр лицо']) ?>
@@ -30,10 +33,16 @@ use yii\widgets\ActiveForm; \ No newline at end of file diff --git a/erp24/views/marketplace-store/create.php b/erp24/views/marketplace-store/create.php index c7031bae..12aca934 100644 --- a/erp24/views/marketplace-store/create.php +++ b/erp24/views/marketplace-store/create.php @@ -16,6 +16,7 @@ $this->params['breadcrumbs'][] = $this->title; 'stores' => $stores, 'storesGuid' => $storesGuid, 'firms' => $firms, + 'warehouses' => $warehouses ]) ?>
diff --git a/erp24/views/marketplace-store/index.php b/erp24/views/marketplace-store/index.php index 43c01573..5284725a 100644 --- a/erp24/views/marketplace-store/index.php +++ b/erp24/views/marketplace-store/index.php @@ -3,6 +3,7 @@ use yii\helpers\Html; use yii\grid\GridView; use yii_app\records\Firms; +use yii_app\records\MarketplaceStore; $this->title = 'Список Магазинов'; $this->params['breadcrumbs'][] = $this->title; @@ -28,8 +29,13 @@ $this->params['breadcrumbs'][] = $this->title; } ], 'guid', - 'yandex_market_id', - 'flowwow_id', + [ + 'attribute' => 'warehouse_id', + 'value' => function ($model) { + return MarketplaceStore::getWarehouseId()[$model->warehouse_id]; + } + ], + 'warehouse_guid', [ 'attribute' => 'firm', 'value' => function ($model) { diff --git a/erp24/views/marketplace-store/update.php b/erp24/views/marketplace-store/update.php index f5e9bca5..63bee730 100644 --- a/erp24/views/marketplace-store/update.php +++ b/erp24/views/marketplace-store/update.php @@ -16,6 +16,7 @@ $this->params['breadcrumbs'][] = $this->title; 'stores' => $stores, 'storesGuid' => $storesGuid, 'firms' => $firms, + 'warehouses' => $warehouses ]) ?> diff --git a/erp24/views/marketplace-store/view.php b/erp24/views/marketplace-store/view.php index 7c988264..27bb02d9 100644 --- a/erp24/views/marketplace-store/view.php +++ b/erp24/views/marketplace-store/view.php @@ -36,12 +36,12 @@ $this->params['breadcrumbs'][] = $this->title; guid) ?> - ID в Яндекс.Маркете - yandex_market_id) ?> + Маркетплейс + warehouse_id]) ?> - ID в Flowwow - flowwow_id) ?> + GUID склада в данном маркетплейсе + warehouse_guid) ?> Юридическое Лицо