Commit c85057452abad0e39da1e1e018af0ab74de0c428
1 parent
c77aa128
Importers CRUD
Showing
21 changed files
with
110 additions
and
41 deletions
Show diff stats
backend/controllers/MarginsGroupsController.php
| @@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
| 2 | 2 | ||
| 3 | namespace backend\controllers; | 3 | namespace backend\controllers; |
| 4 | 4 | ||
| 5 | +use backend\models\Importers; | ||
| 6 | +use common\models\Margins; | ||
| 5 | use Yii; | 7 | use Yii; |
| 6 | use common\models\MarginsGroups; | 8 | use common\models\MarginsGroups; |
| 7 | use common\models\MarginsGroupsSearch; | 9 | use common\models\MarginsGroupsSearch; |
| @@ -64,11 +66,16 @@ class MarginsGroupsController extends Controller | @@ -64,11 +66,16 @@ class MarginsGroupsController extends Controller | ||
| 64 | { | 66 | { |
| 65 | $model = new MarginsGroups(); | 67 | $model = new MarginsGroups(); |
| 66 | 68 | ||
| 69 | + $importers= Importers::find()->all(); | ||
| 70 | + $margin = Margins::find()->all(); | ||
| 71 | + | ||
| 67 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 72 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
| 68 | return $this->redirect(['view', 'id' => $model->id]); | 73 | return $this->redirect(['view', 'id' => $model->id]); |
| 69 | } else { | 74 | } else { |
| 70 | return $this->render('create', [ | 75 | return $this->render('create', [ |
| 71 | 'model' => $model, | 76 | 'model' => $model, |
| 77 | + 'importers' => $importers, | ||
| 78 | + 'margin' => $margin, | ||
| 72 | ]); | 79 | ]); |
| 73 | } | 80 | } |
| 74 | } | 81 | } |
| @@ -83,11 +90,16 @@ class MarginsGroupsController extends Controller | @@ -83,11 +90,16 @@ class MarginsGroupsController extends Controller | ||
| 83 | { | 90 | { |
| 84 | $model = $this->findModel($id); | 91 | $model = $this->findModel($id); |
| 85 | 92 | ||
| 93 | + $importers = Importers::find()->all(); | ||
| 94 | + $margin = Margins::find()->all(); | ||
| 95 | + | ||
| 86 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 96 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
| 87 | return $this->redirect(['view', 'id' => $model->id]); | 97 | return $this->redirect(['view', 'id' => $model->id]); |
| 88 | } else { | 98 | } else { |
| 89 | return $this->render('update', [ | 99 | return $this->render('update', [ |
| 90 | 'model' => $model, | 100 | 'model' => $model, |
| 101 | + 'importers' => $importers, | ||
| 102 | + 'margin' => $margin, | ||
| 91 | ]); | 103 | ]); |
| 92 | } | 104 | } |
| 93 | } | 105 | } |
backend/controllers/MarginsImportersController.php
| @@ -8,6 +8,8 @@ use common\models\MarginsImportersSearch; | @@ -8,6 +8,8 @@ use common\models\MarginsImportersSearch; | ||
| 8 | use yii\web\Controller; | 8 | use yii\web\Controller; |
| 9 | use yii\web\NotFoundHttpException; | 9 | use yii\web\NotFoundHttpException; |
| 10 | use yii\filters\VerbFilter; | 10 | use yii\filters\VerbFilter; |
| 11 | +use backend\models\Importers; | ||
| 12 | +use common\models\Margins; | ||
| 11 | 13 | ||
| 12 | /** | 14 | /** |
| 13 | * MarginsImportersController implements the CRUD actions for MarginsImporters model. | 15 | * MarginsImportersController implements the CRUD actions for MarginsImporters model. |
| @@ -64,12 +66,16 @@ class MarginsImportersController extends Controller | @@ -64,12 +66,16 @@ class MarginsImportersController extends Controller | ||
| 64 | public function actionCreate() | 66 | public function actionCreate() |
| 65 | { | 67 | { |
| 66 | $model = new MarginsImporters(); | 68 | $model = new MarginsImporters(); |
| 69 | + $importers= Importers::find()->all(); | ||
| 70 | + $margin = Margins::find()->all(); | ||
| 67 | 71 | ||
| 68 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 72 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
| 69 | return $this->redirect(['view', 'id' => $model->id]); | 73 | return $this->redirect(['view', 'id' => $model->id]); |
| 70 | } else { | 74 | } else { |
| 71 | return $this->render('create', [ | 75 | return $this->render('create', [ |
| 72 | 'model' => $model, | 76 | 'model' => $model, |
| 77 | + 'importers' => $importers, | ||
| 78 | + 'margin' => $margin, | ||
| 73 | ]); | 79 | ]); |
| 74 | } | 80 | } |
| 75 | } | 81 | } |
| @@ -83,12 +89,16 @@ class MarginsImportersController extends Controller | @@ -83,12 +89,16 @@ class MarginsImportersController extends Controller | ||
| 83 | public function actionUpdate($id) | 89 | public function actionUpdate($id) |
| 84 | { | 90 | { |
| 85 | $model = $this->findModel($id); | 91 | $model = $this->findModel($id); |
| 92 | + $importers= Importers::find()->all(); | ||
| 93 | + $margin = Margins::find()->all(); | ||
| 86 | 94 | ||
| 87 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 95 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
| 88 | return $this->redirect(['view', 'id' => $model->id]); | 96 | return $this->redirect(['view', 'id' => $model->id]); |
| 89 | } else { | 97 | } else { |
| 90 | return $this->render('update', [ | 98 | return $this->render('update', [ |
| 91 | 'model' => $model, | 99 | 'model' => $model, |
| 100 | + 'importers' => $importers, | ||
| 101 | + 'margin' => $margin, | ||
| 92 | ]); | 102 | ]); |
| 93 | } | 103 | } |
| 94 | } | 104 | } |
backend/views/currency/_form.php
| @@ -16,10 +16,6 @@ use yii\widgets\ActiveForm; | @@ -16,10 +16,6 @@ use yii\widgets\ActiveForm; | ||
| 16 | 16 | ||
| 17 | <?= $form->field($model, 'rate')->textInput() ?> | 17 | <?= $form->field($model, 'rate')->textInput() ?> |
| 18 | 18 | ||
| 19 | - <?= $form->field($model, 'is_default')->textInput() ?> | ||
| 20 | - | ||
| 21 | - <?= $form->field($model, 'timestamp')->textInput() ?> | ||
| 22 | - | ||
| 23 | <div class="form-group"> | 19 | <div class="form-group"> |
| 24 | <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | 20 | <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
| 25 | </div> | 21 | </div> |
backend/views/currency/_search.php
| @@ -21,8 +21,6 @@ use yii\widgets\ActiveForm; | @@ -21,8 +21,6 @@ use yii\widgets\ActiveForm; | ||
| 21 | 21 | ||
| 22 | <?= $form->field($model, 'rate') ?> | 22 | <?= $form->field($model, 'rate') ?> |
| 23 | 23 | ||
| 24 | - <?= $form->field($model, 'is_default') ?> | ||
| 25 | - | ||
| 26 | <?= $form->field($model, 'timestamp') ?> | 24 | <?= $form->field($model, 'timestamp') ?> |
| 27 | 25 | ||
| 28 | <div class="form-group"> | 26 | <div class="form-group"> |
backend/views/currency/index.php
| @@ -25,10 +25,8 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -25,10 +25,8 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 25 | 'columns' => [ | 25 | 'columns' => [ |
| 26 | ['class' => 'yii\grid\SerialColumn'], | 26 | ['class' => 'yii\grid\SerialColumn'], |
| 27 | 27 | ||
| 28 | - 'id', | ||
| 29 | 'name', | 28 | 'name', |
| 30 | 'rate', | 29 | 'rate', |
| 31 | - 'is_default', | ||
| 32 | 'timestamp', | 30 | 'timestamp', |
| 33 | 31 | ||
| 34 | ['class' => 'yii\grid\ActionColumn'], | 32 | ['class' => 'yii\grid\ActionColumn'], |
backend/views/currency/view.php
| @@ -31,7 +31,6 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -31,7 +31,6 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 31 | 'id', | 31 | 'id', |
| 32 | 'name', | 32 | 'name', |
| 33 | 'rate', | 33 | 'rate', |
| 34 | - 'is_default', | ||
| 35 | 'timestamp', | 34 | 'timestamp', |
| 36 | ], | 35 | ], |
| 37 | ]) ?> | 36 | ]) ?> |
backend/views/margins-groups/_form.php
| @@ -2,25 +2,23 @@ | @@ -2,25 +2,23 @@ | ||
| 2 | 2 | ||
| 3 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
| 4 | use yii\widgets\ActiveForm; | 4 | use yii\widgets\ActiveForm; |
| 5 | - | 5 | +use yii\helpers\ArrayHelper; |
| 6 | /* @var $this yii\web\View */ | 6 | /* @var $this yii\web\View */ |
| 7 | /* @var $model common\models\MarginsGroups */ | 7 | /* @var $model common\models\MarginsGroups */ |
| 8 | /* @var $form yii\widgets\ActiveForm */ | 8 | /* @var $form yii\widgets\ActiveForm */ |
| 9 | ?> | 9 | ?> |
| 10 | 10 | ||
| 11 | <div class="margins-groups-form"> | 11 | <div class="margins-groups-form"> |
| 12 | - | ||
| 13 | <?php $form = ActiveForm::begin(); ?> | 12 | <?php $form = ActiveForm::begin(); ?> |
| 14 | 13 | ||
| 15 | - <?= $form->field($model, 'importer_id')->textInput() ?> | 14 | + <?= $form->field($model, 'importer_id')->dropDownList(ArrayHelper::map($importers, 'id', 'name'), ['prompt' => 'Выберие город']) ?> |
| 16 | 15 | ||
| 17 | - <?= $form->field($model, 'margin_id')->textInput() ?> | 16 | + <?= $form->field($model, 'margin_id')->dropDownList(ArrayHelper::map($margin, 'id', 'name'), ['prompt' => 'Выберие город']) ?> |
| 18 | 17 | ||
| 19 | <?= $form->field($model, 'group')->textInput(['maxlength' => true]) ?> | 18 | <?= $form->field($model, 'group')->textInput(['maxlength' => true]) ?> |
| 20 | 19 | ||
| 21 | <?= $form->field($model, 'koef')->textInput() ?> | 20 | <?= $form->field($model, 'koef')->textInput() ?> |
| 22 | 21 | ||
| 23 | - <?= $form->field($model, 'timestamp')->textInput() ?> | ||
| 24 | 22 | ||
| 25 | <div class="form-group"> | 23 | <div class="form-group"> |
| 26 | <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | 24 | <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
backend/views/margins-groups/create.php
| @@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 16 | 16 | ||
| 17 | <?= $this->render('_form', [ | 17 | <?= $this->render('_form', [ |
| 18 | 'model' => $model, | 18 | 'model' => $model, |
| 19 | + 'importers' => $importers, | ||
| 20 | + 'margin' => $margin, | ||
| 19 | ]) ?> | 21 | ]) ?> |
| 20 | 22 | ||
| 21 | </div> | 23 | </div> |
backend/views/margins-groups/index.php
| @@ -24,13 +24,17 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -24,13 +24,17 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 24 | 'filterModel' => $searchModel, | 24 | 'filterModel' => $searchModel, |
| 25 | 'columns' => [ | 25 | 'columns' => [ |
| 26 | ['class' => 'yii\grid\SerialColumn'], | 26 | ['class' => 'yii\grid\SerialColumn'], |
| 27 | - | ||
| 28 | - 'id', | ||
| 29 | - 'importer_id', | ||
| 30 | - 'margin_id', | 27 | + [ |
| 28 | + 'attribute' => 'importer_id', | ||
| 29 | + 'value' => 'importers.name' | ||
| 30 | + ], | ||
| 31 | + [ | ||
| 32 | + 'attribute' => 'margin_id', | ||
| 33 | + 'value' => 'margins.name' | ||
| 34 | + ], | ||
| 31 | 'group', | 35 | 'group', |
| 32 | 'koef', | 36 | 'koef', |
| 33 | - // 'timestamp', | 37 | + 'timestamp', |
| 34 | 38 | ||
| 35 | ['class' => 'yii\grid\ActionColumn'], | 39 | ['class' => 'yii\grid\ActionColumn'], |
| 36 | ], | 40 | ], |
backend/views/margins-groups/update.php
| @@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = 'Update'; | @@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = 'Update'; | ||
| 16 | 16 | ||
| 17 | <?= $this->render('_form', [ | 17 | <?= $this->render('_form', [ |
| 18 | 'model' => $model, | 18 | 'model' => $model, |
| 19 | + 'importers' => $importers, | ||
| 20 | + 'margin' => $margin, | ||
| 19 | ]) ?> | 21 | ]) ?> |
| 20 | 22 | ||
| 21 | </div> | 23 | </div> |
backend/views/margins-importers-import/index.php
| @@ -25,7 +25,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -25,7 +25,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 25 | 'columns' => [ | 25 | 'columns' => [ |
| 26 | ['class' => 'yii\grid\SerialColumn'], | 26 | ['class' => 'yii\grid\SerialColumn'], |
| 27 | 27 | ||
| 28 | - 'id', | 28 | + //'id', |
| 29 | 'importer_id', | 29 | 'importer_id', |
| 30 | 'margin_id', | 30 | 'margin_id', |
| 31 | 'koef', | 31 | 'koef', |
backend/views/margins-importers/_form.php
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
| 4 | use yii\widgets\ActiveForm; | 4 | use yii\widgets\ActiveForm; |
| 5 | - | 5 | +use yii\helpers\ArrayHelper; |
| 6 | /* @var $this yii\web\View */ | 6 | /* @var $this yii\web\View */ |
| 7 | /* @var $model common\models\MarginsImporters */ | 7 | /* @var $model common\models\MarginsImporters */ |
| 8 | /* @var $form yii\widgets\ActiveForm */ | 8 | /* @var $form yii\widgets\ActiveForm */ |
| @@ -12,9 +12,9 @@ use yii\widgets\ActiveForm; | @@ -12,9 +12,9 @@ use yii\widgets\ActiveForm; | ||
| 12 | 12 | ||
| 13 | <?php $form = ActiveForm::begin(); ?> | 13 | <?php $form = ActiveForm::begin(); ?> |
| 14 | 14 | ||
| 15 | - <?= $form->field($model, 'importer_id')->textInput() ?> | 15 | + <?= $form->field($model, 'importer_id')->dropDownList(ArrayHelper::map($importers, 'id', 'name'), ['prompt' => 'Выберие город']) ?> |
| 16 | 16 | ||
| 17 | - <?= $form->field($model, 'margin_id')->textInput() ?> | 17 | + <?= $form->field($model, 'margin_id')->dropDownList(ArrayHelper::map($margin, 'id', 'name'), ['prompt' => 'Выберие город']) ?> |
| 18 | 18 | ||
| 19 | <?= $form->field($model, 'koef')->textInput() ?> | 19 | <?= $form->field($model, 'koef')->textInput() ?> |
| 20 | 20 |
backend/views/margins-importers/create.php
| @@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 16 | 16 | ||
| 17 | <?= $this->render('_form', [ | 17 | <?= $this->render('_form', [ |
| 18 | 'model' => $model, | 18 | 'model' => $model, |
| 19 | + 'importers' => $importers, | ||
| 20 | + 'margin' => $margin, | ||
| 19 | ]) ?> | 21 | ]) ?> |
| 20 | 22 | ||
| 21 | </div> | 23 | </div> |
backend/views/margins-importers/index.php
| @@ -25,9 +25,8 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -25,9 +25,8 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 25 | 'columns' => [ | 25 | 'columns' => [ |
| 26 | ['class' => 'yii\grid\SerialColumn'], | 26 | ['class' => 'yii\grid\SerialColumn'], |
| 27 | 27 | ||
| 28 | - 'id', | ||
| 29 | - 'importer_id', | ||
| 30 | - 'margin_id', | 28 | + 'importers.name', |
| 29 | + 'margins.name', | ||
| 31 | 'koef', | 30 | 'koef', |
| 32 | 31 | ||
| 33 | ['class' => 'yii\grid\ActionColumn'], | 32 | ['class' => 'yii\grid\ActionColumn'], |
backend/views/margins-importers/update.php
| @@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = 'Update'; | @@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = 'Update'; | ||
| 16 | 16 | ||
| 17 | <?= $this->render('_form', [ | 17 | <?= $this->render('_form', [ |
| 18 | 'model' => $model, | 18 | 'model' => $model, |
| 19 | + 'importers' => $importers, | ||
| 20 | + 'margin' => $margin, | ||
| 19 | ]) ?> | 21 | ]) ?> |
| 20 | 22 | ||
| 21 | </div> | 23 | </div> |
backend/views/margins/index.php
| @@ -25,7 +25,6 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -25,7 +25,6 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 25 | 'columns' => [ | 25 | 'columns' => [ |
| 26 | ['class' => 'yii\grid\SerialColumn'], | 26 | ['class' => 'yii\grid\SerialColumn'], |
| 27 | 27 | ||
| 28 | - 'id', | ||
| 29 | 'name', | 28 | 'name', |
| 30 | 'koef', | 29 | 'koef', |
| 31 | 30 |
common/models/Currency.php
| @@ -52,4 +52,15 @@ class Currency extends \yii\db\ActiveRecord | @@ -52,4 +52,15 @@ class Currency extends \yii\db\ActiveRecord | ||
| 52 | 'timestamp' => 'Дата обновления', | 52 | 'timestamp' => 'Дата обновления', |
| 53 | ]; | 53 | ]; |
| 54 | } | 54 | } |
| 55 | + | ||
| 56 | + | ||
| 57 | + public function beforeSave($insert) | ||
| 58 | + { | ||
| 59 | + if (parent::beforeSave($insert)) { | ||
| 60 | + $this->timestamp = date("Y-m-d H:i:s"); | ||
| 61 | + return true; | ||
| 62 | + } else { | ||
| 63 | + return false; | ||
| 64 | + } | ||
| 65 | + } | ||
| 55 | } | 66 | } |
common/models/Margins.php
| @@ -41,8 +41,8 @@ class Margins extends \yii\db\ActiveRecord | @@ -41,8 +41,8 @@ class Margins extends \yii\db\ActiveRecord | ||
| 41 | { | 41 | { |
| 42 | return [ | 42 | return [ |
| 43 | 'id' => 'ID', | 43 | 'id' => 'ID', |
| 44 | - 'name' => 'Name', | ||
| 45 | - 'koef' => 'Koef', | 44 | + 'name' => 'Название группы', |
| 45 | + 'koef' => 'Коэффициент', | ||
| 46 | ]; | 46 | ]; |
| 47 | } | 47 | } |
| 48 | } | 48 | } |
common/models/MarginsGroups.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace common\models; | 3 | namespace common\models; |
| 4 | 4 | ||
| 5 | +use backend\models\Importers; | ||
| 5 | use Yii; | 6 | use Yii; |
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| @@ -46,11 +47,31 @@ class MarginsGroups extends \yii\db\ActiveRecord | @@ -46,11 +47,31 @@ class MarginsGroups extends \yii\db\ActiveRecord | ||
| 46 | { | 47 | { |
| 47 | return [ | 48 | return [ |
| 48 | 'id' => 'ID', | 49 | 'id' => 'ID', |
| 49 | - 'importer_id' => 'Importer ID', | ||
| 50 | - 'margin_id' => 'Margin ID', | ||
| 51 | - 'group' => 'Group', | ||
| 52 | - 'koef' => 'Koef', | ||
| 53 | - 'timestamp' => 'Timestamp', | 50 | + 'importer_id' => 'Поставщик', |
| 51 | + 'margin_id' => 'Тип цены', | ||
| 52 | + 'group' => 'ГРУППА', | ||
| 53 | + 'koef' => 'Коэффициент', | ||
| 54 | + 'timestamp' => 'ДАТА', | ||
| 54 | ]; | 55 | ]; |
| 55 | } | 56 | } |
| 57 | + | ||
| 58 | + public function beforeSave($insert) | ||
| 59 | + { | ||
| 60 | + if (parent::beforeSave($insert)) { | ||
| 61 | + $this->timestamp = date("Y-m-d H:i:s"); | ||
| 62 | + return true; | ||
| 63 | + } else { | ||
| 64 | + return false; | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public function getImporters() | ||
| 69 | + { | ||
| 70 | + return $this->hasOne(Importers::className(), ['id' => 'importer_id']); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public function getMargins() | ||
| 74 | + { | ||
| 75 | + return $this->hasOne(Margins::className(), ['id' => 'margin_id']); | ||
| 76 | + } | ||
| 56 | } | 77 | } |
common/models/MarginsGroupsSearch.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace common\models; | 3 | namespace common\models; |
| 4 | 4 | ||
| 5 | +use backend\models\Importers; | ||
| 5 | use Yii; | 6 | use Yii; |
| 6 | use yii\base\Model; | 7 | use yii\base\Model; |
| 7 | use yii\data\ActiveDataProvider; | 8 | use yii\data\ActiveDataProvider; |
| @@ -18,8 +19,8 @@ class MarginsGroupsSearch extends MarginsGroups | @@ -18,8 +19,8 @@ class MarginsGroupsSearch extends MarginsGroups | ||
| 18 | public function rules() | 19 | public function rules() |
| 19 | { | 20 | { |
| 20 | return [ | 21 | return [ |
| 21 | - [['id', 'importer_id', 'margin_id'], 'integer'], | ||
| 22 | - [['group', 'timestamp'], 'safe'], | 22 | + [['id',], 'integer'], |
| 23 | + [['group', 'timestamp', 'importer_id', 'margin_id'], 'safe'], | ||
| 23 | [['koef'], 'number'], | 24 | [['koef'], 'number'], |
| 24 | ]; | 25 | ]; |
| 25 | } | 26 | } |
| @@ -56,15 +57,19 @@ class MarginsGroupsSearch extends MarginsGroups | @@ -56,15 +57,19 @@ class MarginsGroupsSearch extends MarginsGroups | ||
| 56 | return $dataProvider; | 57 | return $dataProvider; |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 60 | + | ||
| 61 | + $query->joinWith(['importers','margins']); | ||
| 62 | + | ||
| 63 | + | ||
| 59 | $query->andFilterWhere([ | 64 | $query->andFilterWhere([ |
| 60 | 'id' => $this->id, | 65 | 'id' => $this->id, |
| 61 | - 'importer_id' => $this->importer_id, | ||
| 62 | - 'margin_id' => $this->margin_id, | ||
| 63 | 'koef' => $this->koef, | 66 | 'koef' => $this->koef, |
| 64 | 'timestamp' => $this->timestamp, | 67 | 'timestamp' => $this->timestamp, |
| 65 | ]); | 68 | ]); |
| 66 | 69 | ||
| 67 | $query->andFilterWhere(['like', 'group', $this->group]); | 70 | $query->andFilterWhere(['like', 'group', $this->group]); |
| 71 | + $query->andFilterWhere(['like', Importers::tableName().'name', $this->importer_id]); | ||
| 72 | + $query->andFilterWhere(['like', Margins::tableName().'.name', $this->margin_id]); | ||
| 68 | 73 | ||
| 69 | return $dataProvider; | 74 | return $dataProvider; |
| 70 | } | 75 | } |
common/models/MarginsImporters.php
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace common\models; | 3 | namespace common\models; |
| 4 | 4 | ||
| 5 | use Yii; | 5 | use Yii; |
| 6 | +use backend\models\Importers; | ||
| 6 | 7 | ||
| 7 | /** | 8 | /** |
| 8 | * This is the model class for table "w_margins_importers". | 9 | * This is the model class for table "w_margins_importers". |
| @@ -42,9 +43,19 @@ class MarginsImporters extends \yii\db\ActiveRecord | @@ -42,9 +43,19 @@ class MarginsImporters extends \yii\db\ActiveRecord | ||
| 42 | { | 43 | { |
| 43 | return [ | 44 | return [ |
| 44 | 'id' => 'ID', | 45 | 'id' => 'ID', |
| 45 | - 'importer_id' => 'Importer ID', | ||
| 46 | - 'margin_id' => 'Margin ID', | ||
| 47 | - 'koef' => 'Koef', | 46 | + 'importer_id' => 'Поставщик', |
| 47 | + 'margin_id' => 'Тип цены', | ||
| 48 | + 'koef' => 'Коэффициент', | ||
| 48 | ]; | 49 | ]; |
| 49 | } | 50 | } |
| 51 | + | ||
| 52 | + public function getImporters() | ||
| 53 | + { | ||
| 54 | + return $this->hasOne(Importers::className(), ['id' => 'importer_id']); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public function getMargins() | ||
| 58 | + { | ||
| 59 | + return $this->hasOne(Margins::className(), ['id' => 'margin_id']); | ||
| 60 | + } | ||
| 50 | } | 61 | } |