}
} 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');
+ }
}
// Данные для выпадающих списков
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;
[['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,
]);
}
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".
return $this->hasMany(MatrixErpMedia::class, ['guid' => 'guid']);
}
+ public function getMarketplacePrices(): ActiveQueryInterface
+ {
+ return $this->hasMany(MarketplacePrices::class, ['matrix_erp_id' => 'id']);
+ }
+
public function setComponentsArray() : void
{
/** @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']];
// 'id',
'name',
'articule',
- 'price.price',
+ [
+ 'attribute' => 'price.price',
+ 'label' => 'Цена 1С',
+ ],
'group_name',
'code',
'guid',
],
]) ?>
+
+ <h3 class="mt-4">Цены маркетплейсов</h3>
+ <table class="table table-bordered">
+ <thead>
+ <tr>
+ <th>МП</th>
+ <th>Цена</th>
+ <th>Старая цена</th>
+ <th>Действия</th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php
+ $marketplaces = [
+ 1 => 'YM', // Яндекс
+ 2 => 'FW', // Флаувау
+ ];
+
+ foreach ($marketplaces as $marketplaceId => $marketplaceAlias) {
+ $priceRecord = null;
+ foreach ($marketplacePrices as $price) {
+ if ($price->marketplace_id == $marketplaceId) {
+ $priceRecord = $price;
+ break;
+ }
+ }
+ ?>
+ <tr>
+ <td><?= Html::encode($marketplaceAlias) ?></td>
+ <td><?= $priceRecord ? Html::encode($priceRecord->price) : '-' ?></td>
+ <td><?= $priceRecord && $priceRecord->old_price ? Html::encode($priceRecord->old_price) : '-' ?></td>
+ <td>
+ <?php if ($priceRecord): ?>
+ <?= Html::a('Редактировать', ['/marketplace-prices/update', 'id' => $priceRecord->id], ['class' => 'btn btn-sm btn-primary']) ?>
+ <?php else: ?>
+ <?= Html::a('Создать', ['/marketplace-prices/create', 'matrix_erp_id' => $modelMatrixErp->id, 'marketplace_id' => $marketplaceId], ['class' => 'btn btn-sm btn-success']) ?>
+ <?php endif; ?>
+ </td>
+ </tr>
+ <?php } ?>
+ </tbody>
+ </table>
+
<span style="display: none">
<?= DetailView::widget([
'model' => $modelMatrixErp,