]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-150 Присвоить каждому магазину ID склада feature_erp-150_zozirova_marketplace_stores origin/feature_erp-150_zozirova_marketplace_stores
authormarina <m.zozirova@gmail.com>
Thu, 24 Oct 2024 06:45:32 +0000 (09:45 +0300)
committermarina <m.zozirova@gmail.com>
Thu, 24 Oct 2024 06:45:32 +0000 (09:45 +0300)
erp24/controllers/MarketplaceStoreController.php
erp24/migrations/m241023_064710_create_marketplace_store_table.php
erp24/records/MarketplaceStore.php
erp24/views/marketplace-store/_form.php
erp24/views/marketplace-store/create.php
erp24/views/marketplace-store/index.php
erp24/views/marketplace-store/update.php
erp24/views/marketplace-store/view.php

index a5be886c80b3aaef45d7b44e41139cb19f41a032..944533805bb5c3f218ebbbe61b2ebd83e40b290d 100644 (file)
@@ -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
         ]);
     }
 
index bf3cae0e5e7111e9bcba1e8fd3e523a437c7cd5b..8775934d3d4295719b06947c8dcbe7d219fb2af9 100644 (file)
@@ -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('автор создания записи'),
index 7c30aa6ab4db19ed18e97a3c5c787a0bd4afe130..36884a4beab5b64b4feed5f0d32935e9eb42648e 100644 (file)
@@ -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']);
     }
index 7331b3f423dfe8f7ba8d5fc2801aa2ea0a4fcb62..d4acad91f504312e44e91878864bef5de7f2369a 100644 (file)
@@ -12,12 +12,15 @@ use yii\widgets\ActiveForm;
     <?php $form = ActiveForm::begin(); ?>
         <?= $form->field($model, 'store_id')->dropDownList($stores, [
             'prompt' => 'Выберите магазин',
-            'onchange' => 'updateGuid(this.value)' // Вызов функции для обновления guid
+            'onchange' => 'updateGuid(this.value); updateName(this.value)'
         ]) ?>
 
         <?= $form->field($model, 'guid')->textInput(['maxlength' => true, 'value' => $model->guid, 'readonly' => true, 'id' => 'guid-input']) ?>
-    <?= $form->field($model, 'yandex_market_id')->textInput() ?>
-    <?= $form->field($model, 'flowwow_id')->textInput(['type' => 'integer']) ?>
+    <?= $form->field($model, 'name')->textInput(['maxlength' => true, 'value' => $model->name, 'readonly' => true, 'id' => 'name-input']) ?>
+    <?= $form->field($model, 'warehouse_id')->dropDownList($warehouses, [
+        'prompt' => 'Выберите маркетплейс'
+    ]) ?>
+    <?= $form->field($model, 'warehouse_guid')->textInput(['type' => 'integer']) ?>
     <?= $form->field($model, 'firm')->dropDownList($firms, ['prompt' => 'Выберите юр лицо']) ?>
 
     <div class="form-group">
@@ -30,10 +33,16 @@ use yii\widgets\ActiveForm;
 
 
 <script>
-    const storesGuid = <?= json_encode($storesGuid) ?>; // Преобразуем массив GUID в JSON
+    const storesGuid = <?= json_encode($storesGuid) ?>;
+    const storesName = <?= json_encode($stores) ?>
 
     function updateGuid(storeId) {
         const guidInput = document.getElementById('guid-input');
-        guidInput.value = storesGuid[storeId] || ''; // Обновляем значение GUID
+        guidInput.value = storesGuid[storeId] || '';
+    }
+
+    function updateName(storeId) {
+        const nameInput = document.getElementById('name-input');
+        nameInput.value = storesName[storeId] || '';
     }
 </script>
\ No newline at end of file
index c7031baedc58652bfbbac45a5d39a9f86ff5d985..12aca9348c84c5b5719d8296f3e4c7de467843ee 100644 (file)
@@ -16,6 +16,7 @@ $this->params['breadcrumbs'][] = $this->title;
         'stores' => $stores,
         'storesGuid' => $storesGuid,
         'firms' => $firms,
+        'warehouses' => $warehouses
     ]) ?>
 
 </div>
index 43c01573f6cf08f2f79282b4a6b98f1ba2a9a27b..5284725a32bb268235b4801dffd260aa90adcad5 100644 (file)
@@ -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) {
index f5e9bca58faf07f5a7cc9833bc80368dba45d771..63bee730fa60125258335e49aefcc8825b4f0769 100644 (file)
@@ -16,6 +16,7 @@ $this->params['breadcrumbs'][] = $this->title;
         'stores' => $stores,
         'storesGuid' => $storesGuid,
         'firms' => $firms,
+        'warehouses' => $warehouses
     ]) ?>
 
 </div>
index 7c988264b06976ec67d0e303320ded41d7824655..27bb02d995b0b01c47aa2185609c904a1f8b523e 100644 (file)
@@ -36,12 +36,12 @@ $this->params['breadcrumbs'][] = $this->title;
             <td><?= Html::encode($model->guid) ?></td>
         </tr>
         <tr>
-            <th>ID в Яндекс.Маркете</th>
-            <td><?= Html::encode($model->yandex_market_id) ?></td>
+            <th>Маркетплейс</th>
+            <td><?= Html::encode($warehouses[$model->warehouse_id]) ?></td>
         </tr>
         <tr>
-            <th>ID в Flowwow</th>
-            <td><?= Html::encode($model->flowwow_id) ?></td>
+            <th>GUID склада в данном маркетплейсе</th>
+            <td><?= Html::encode($model->warehouse_guid) ?></td>
         </tr>
         <tr>
             <th>Юридическое Лицо</th>