From: Vladimir Fomichev Date: Thu, 2 Oct 2025 09:12:31 +0000 (+0300) Subject: Цены в MatrixErpController.php X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ba769dd36117093123d61739187a8510ea20805e;p=erp24_rep%2Fyii-erp24%2F.git Цены в MatrixErpController.php --- diff --git a/erp24/controllers/MarketplacePricesController.php b/erp24/controllers/MarketplacePricesController.php index d672e186..106b3a34 100644 --- a/erp24/controllers/MarketplacePricesController.php +++ b/erp24/controllers/MarketplacePricesController.php @@ -167,6 +167,13 @@ class MarketplacePricesController extends Controller } } else { $model->loadDefaultValues(); + // Предзаполняем модель из GET параметров + if (Yii::$app->request->get('matrix_erp_id')) { + $model->matrix_erp_id = Yii::$app->request->get('matrix_erp_id'); + } + if (Yii::$app->request->get('marketplace_id')) { + $model->marketplace_id = Yii::$app->request->get('marketplace_id'); + } } // Данные для выпадающих списков diff --git a/erp24/controllers/MatrixErpController.php b/erp24/controllers/MatrixErpController.php index aec0f927..18af09c1 100644 --- a/erp24/controllers/MatrixErpController.php +++ b/erp24/controllers/MatrixErpController.php @@ -16,6 +16,7 @@ use yii\helpers\Json; use yii\web\UploadedFile; use yii_app\records\Files; use yii_app\records\Images; +use yii_app\records\MarketplacePrices; use yii_app\records\MatrixErp; use yii_app\records\MatrixErpMedia; use yii_app\records\MatrixErpProperty; @@ -247,10 +248,16 @@ class MatrixErpController extends Controller [['imageFile',], 'image',], ]); + // Получаем цены для маркетплейсов + $marketplacePrices = MarketplacePrices::find() + ->where(['matrix_erp_id' => $modelMatrixErp->id]) + ->all(); + return $this->render('/matrix_erp/update', [ 'modelMatrixErp' => $modelMatrixErp, 'modelMatrixErpProperty' => $modelMatrixErpProperty, 'filterModel' => $filterModel, + 'marketplacePrices' => $marketplacePrices, ]); } diff --git a/erp24/records/MatrixErp.php b/erp24/records/MatrixErp.php index 2d468f71..be0e23ca 100644 --- a/erp24/records/MatrixErp.php +++ b/erp24/records/MatrixErp.php @@ -7,6 +7,7 @@ use yii\behaviors\TimestampBehavior; use yii\db\ActiveQueryInterface; use yii\db\Expression; use yii_app\helpers\DataHelper; +use yii_app\records\MarketplacePrices; /** * This is the model class for table "matrix_erp". @@ -109,6 +110,11 @@ class MatrixErp extends \yii\db\ActiveRecord return $this->hasMany(MatrixErpMedia::class, ['guid' => 'guid']); } + public function getMarketplacePrices(): ActiveQueryInterface + { + return $this->hasMany(MarketplacePrices::class, ['matrix_erp_id' => 'id']); + } + public function setComponentsArray() : void { diff --git a/erp24/views/matrix_erp/update.php b/erp24/views/matrix_erp/update.php index 79b219d1..ca12c909 100644 --- a/erp24/views/matrix_erp/update.php +++ b/erp24/views/matrix_erp/update.php @@ -9,6 +9,7 @@ use yii\widgets\DetailView; /** @var yii_app\records\MatrixErp $modelMatrixErp */ /** @var yii_app\records\MatrixErpProperty $modelMatrixErpProperty */ +/** @var array $marketplacePrices */ $this->title = 'Изменение свойств матричного букета: ' . $modelMatrixErp->name; $this->params['breadcrumbs'][] = ['label' => 'Matrix Erps', 'url' => ['index']]; @@ -30,7 +31,10 @@ $this->params['breadcrumbs'][] = 'Update'; // 'id', 'name', 'articule', - 'price.price', + [ + 'attribute' => 'price.price', + 'label' => 'Цена 1С', + ], 'group_name', 'code', 'guid', @@ -48,6 +52,49 @@ $this->params['breadcrumbs'][] = 'Update'; ], ]) ?> + +

Цены маркетплейсов

+ + + + + + + + + + + 'YM', // Яндекс + 2 => 'FW', // Флаувау + ]; + + foreach ($marketplaces as $marketplaceId => $marketplaceAlias) { + $priceRecord = null; + foreach ($marketplacePrices as $price) { + if ($price->marketplace_id == $marketplaceId) { + $priceRecord = $price; + break; + } + } + ?> + + + + + + + + +
МПЦенаСтарая ценаДействия
price) : '-' ?>old_price ? Html::encode($priceRecord->old_price) : '-' ?> + + $priceRecord->id], ['class' => 'btn btn-sm btn-primary']) ?> + + $modelMatrixErp->id, 'marketplace_id' => $marketplaceId], ['class' => 'btn btn-sm btn-success']) ?> + +
+ $modelMatrixErp,