diff --git a/backend/controllers/MarginsGroupsController.php b/backend/controllers/MarginsGroupsController.php
index e4a9156..7adcc32 100644
--- a/backend/controllers/MarginsGroupsController.php
+++ b/backend/controllers/MarginsGroupsController.php
@@ -2,6 +2,8 @@
namespace backend\controllers;
+use backend\models\Importers;
+use common\models\Margins;
use Yii;
use common\models\MarginsGroups;
use common\models\MarginsGroupsSearch;
@@ -64,11 +66,16 @@ class MarginsGroupsController extends Controller
{
$model = new MarginsGroups();
+ $importers= Importers::find()->all();
+ $margin = Margins::find()->all();
+
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
+ 'importers' => $importers,
+ 'margin' => $margin,
]);
}
}
@@ -83,11 +90,16 @@ class MarginsGroupsController extends Controller
{
$model = $this->findModel($id);
+ $importers = Importers::find()->all();
+ $margin = Margins::find()->all();
+
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
+ 'importers' => $importers,
+ 'margin' => $margin,
]);
}
}
diff --git a/backend/controllers/MarginsImportersController.php b/backend/controllers/MarginsImportersController.php
index de7ef01..56e1a57 100644
--- a/backend/controllers/MarginsImportersController.php
+++ b/backend/controllers/MarginsImportersController.php
@@ -8,6 +8,8 @@ use common\models\MarginsImportersSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
+use backend\models\Importers;
+use common\models\Margins;
/**
* MarginsImportersController implements the CRUD actions for MarginsImporters model.
@@ -64,12 +66,16 @@ class MarginsImportersController extends Controller
public function actionCreate()
{
$model = new MarginsImporters();
+ $importers= Importers::find()->all();
+ $margin = Margins::find()->all();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
+ 'importers' => $importers,
+ 'margin' => $margin,
]);
}
}
@@ -83,12 +89,16 @@ class MarginsImportersController extends Controller
public function actionUpdate($id)
{
$model = $this->findModel($id);
+ $importers= Importers::find()->all();
+ $margin = Margins::find()->all();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
+ 'importers' => $importers,
+ 'margin' => $margin,
]);
}
}
diff --git a/backend/views/currency/_form.php b/backend/views/currency/_form.php
index c134e54..79a296c 100644
--- a/backend/views/currency/_form.php
+++ b/backend/views/currency/_form.php
@@ -16,10 +16,6 @@ use yii\widgets\ActiveForm;
= $form->field($model, 'rate')->textInput() ?>
- = $form->field($model, 'is_default')->textInput() ?>
-
- = $form->field($model, 'timestamp')->textInput() ?>
-
= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/backend/views/currency/_search.php b/backend/views/currency/_search.php
index 41ac8b3..4d1a91b 100644
--- a/backend/views/currency/_search.php
+++ b/backend/views/currency/_search.php
@@ -21,8 +21,6 @@ use yii\widgets\ActiveForm;
= $form->field($model, 'rate') ?>
- = $form->field($model, 'is_default') ?>
-
= $form->field($model, 'timestamp') ?>
diff --git a/backend/views/currency/index.php b/backend/views/currency/index.php
index 431315d..7f2a2cb 100644
--- a/backend/views/currency/index.php
+++ b/backend/views/currency/index.php
@@ -25,10 +25,8 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
- 'id',
'name',
'rate',
- 'is_default',
'timestamp',
['class' => 'yii\grid\ActionColumn'],
diff --git a/backend/views/currency/view.php b/backend/views/currency/view.php
index 76191be..c7e2bf5 100644
--- a/backend/views/currency/view.php
+++ b/backend/views/currency/view.php
@@ -31,7 +31,6 @@ $this->params['breadcrumbs'][] = $this->title;
'id',
'name',
'rate',
- 'is_default',
'timestamp',
],
]) ?>
diff --git a/backend/views/margins-groups/_form.php b/backend/views/margins-groups/_form.php
index 3ac8cfc..71926fd 100644
--- a/backend/views/margins-groups/_form.php
+++ b/backend/views/margins-groups/_form.php
@@ -2,25 +2,23 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
-
+use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model common\models\MarginsGroups */
/* @var $form yii\widgets\ActiveForm */
?>
-
- = $form->field($model, 'importer_id')->textInput() ?>
+ = $form->field($model, 'importer_id')->dropDownList(ArrayHelper::map($importers, 'id', 'name'), ['prompt' => 'Выберие город']) ?>
- = $form->field($model, 'margin_id')->textInput() ?>
+ = $form->field($model, 'margin_id')->dropDownList(ArrayHelper::map($margin, 'id', 'name'), ['prompt' => 'Выберие город']) ?>
= $form->field($model, 'group')->textInput(['maxlength' => true]) ?>
= $form->field($model, 'koef')->textInput() ?>
- = $form->field($model, 'timestamp')->textInput() ?>
= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/backend/views/margins-groups/create.php b/backend/views/margins-groups/create.php
index 05112d5..0c4d6d5 100644
--- a/backend/views/margins-groups/create.php
+++ b/backend/views/margins-groups/create.php
@@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = $this->title;
= $this->render('_form', [
'model' => $model,
+ 'importers' => $importers,
+ 'margin' => $margin,
]) ?>
diff --git a/backend/views/margins-groups/index.php b/backend/views/margins-groups/index.php
index f032914..b487574 100644
--- a/backend/views/margins-groups/index.php
+++ b/backend/views/margins-groups/index.php
@@ -24,13 +24,17 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
-
- 'id',
- 'importer_id',
- 'margin_id',
+ [
+ 'attribute' => 'importer_id',
+ 'value' => 'importers.name'
+ ],
+ [
+ 'attribute' => 'margin_id',
+ 'value' => 'margins.name'
+ ],
'group',
'koef',
- // 'timestamp',
+ 'timestamp',
['class' => 'yii\grid\ActionColumn'],
],
diff --git a/backend/views/margins-groups/update.php b/backend/views/margins-groups/update.php
index da52b39..22ec878 100644
--- a/backend/views/margins-groups/update.php
+++ b/backend/views/margins-groups/update.php
@@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = 'Update';
= $this->render('_form', [
'model' => $model,
+ 'importers' => $importers,
+ 'margin' => $margin,
]) ?>
diff --git a/backend/views/margins-importers-import/index.php b/backend/views/margins-importers-import/index.php
index dca455a..da39077 100644
--- a/backend/views/margins-importers-import/index.php
+++ b/backend/views/margins-importers-import/index.php
@@ -25,7 +25,7 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
- 'id',
+ //'id',
'importer_id',
'margin_id',
'koef',
diff --git a/backend/views/margins-importers/_form.php b/backend/views/margins-importers/_form.php
index 019b3bf..926438a 100644
--- a/backend/views/margins-importers/_form.php
+++ b/backend/views/margins-importers/_form.php
@@ -2,7 +2,7 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
-
+use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model common\models\MarginsImporters */
/* @var $form yii\widgets\ActiveForm */
@@ -12,9 +12,9 @@ use yii\widgets\ActiveForm;
- = $form->field($model, 'importer_id')->textInput() ?>
+ = $form->field($model, 'importer_id')->dropDownList(ArrayHelper::map($importers, 'id', 'name'), ['prompt' => 'Выберие город']) ?>
- = $form->field($model, 'margin_id')->textInput() ?>
+ = $form->field($model, 'margin_id')->dropDownList(ArrayHelper::map($margin, 'id', 'name'), ['prompt' => 'Выберие город']) ?>
= $form->field($model, 'koef')->textInput() ?>
diff --git a/backend/views/margins-importers/create.php b/backend/views/margins-importers/create.php
index 9c75832..00c2d2e 100644
--- a/backend/views/margins-importers/create.php
+++ b/backend/views/margins-importers/create.php
@@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = $this->title;
= $this->render('_form', [
'model' => $model,
+ 'importers' => $importers,
+ 'margin' => $margin,
]) ?>
diff --git a/backend/views/margins-importers/index.php b/backend/views/margins-importers/index.php
index 8545d5b..a4ac91f 100644
--- a/backend/views/margins-importers/index.php
+++ b/backend/views/margins-importers/index.php
@@ -25,9 +25,8 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
- 'id',
- 'importer_id',
- 'margin_id',
+ 'importers.name',
+ 'margins.name',
'koef',
['class' => 'yii\grid\ActionColumn'],
diff --git a/backend/views/margins-importers/update.php b/backend/views/margins-importers/update.php
index ed64d20..1027216 100644
--- a/backend/views/margins-importers/update.php
+++ b/backend/views/margins-importers/update.php
@@ -16,6 +16,8 @@ $this->params['breadcrumbs'][] = 'Update';
= $this->render('_form', [
'model' => $model,
+ 'importers' => $importers,
+ 'margin' => $margin,
]) ?>
diff --git a/backend/views/margins/index.php b/backend/views/margins/index.php
index 4119b5e..5936dbc 100644
--- a/backend/views/margins/index.php
+++ b/backend/views/margins/index.php
@@ -25,7 +25,6 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
['class' => 'yii\grid\SerialColumn'],
- 'id',
'name',
'koef',
diff --git a/common/models/Currency.php b/common/models/Currency.php
index 3aeb719..db06b0b 100644
--- a/common/models/Currency.php
+++ b/common/models/Currency.php
@@ -52,4 +52,15 @@ class Currency extends \yii\db\ActiveRecord
'timestamp' => 'Дата обновления',
];
}
+
+
+ public function beforeSave($insert)
+ {
+ if (parent::beforeSave($insert)) {
+ $this->timestamp = date("Y-m-d H:i:s");
+ return true;
+ } else {
+ return false;
+ }
+ }
}
diff --git a/common/models/Margins.php b/common/models/Margins.php
index 9b64694..2ded5c0 100644
--- a/common/models/Margins.php
+++ b/common/models/Margins.php
@@ -41,8 +41,8 @@ class Margins extends \yii\db\ActiveRecord
{
return [
'id' => 'ID',
- 'name' => 'Name',
- 'koef' => 'Koef',
+ 'name' => 'Название группы',
+ 'koef' => 'Коэффициент',
];
}
}
diff --git a/common/models/MarginsGroups.php b/common/models/MarginsGroups.php
index f6bcc9d..b08a04b 100644
--- a/common/models/MarginsGroups.php
+++ b/common/models/MarginsGroups.php
@@ -2,6 +2,7 @@
namespace common\models;
+use backend\models\Importers;
use Yii;
/**
@@ -46,11 +47,31 @@ class MarginsGroups extends \yii\db\ActiveRecord
{
return [
'id' => 'ID',
- 'importer_id' => 'Importer ID',
- 'margin_id' => 'Margin ID',
- 'group' => 'Group',
- 'koef' => 'Koef',
- 'timestamp' => 'Timestamp',
+ 'importer_id' => 'Поставщик',
+ 'margin_id' => 'Тип цены',
+ 'group' => 'ГРУППА',
+ 'koef' => 'Коэффициент',
+ 'timestamp' => 'ДАТА',
];
}
+
+ public function beforeSave($insert)
+ {
+ if (parent::beforeSave($insert)) {
+ $this->timestamp = date("Y-m-d H:i:s");
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public function getImporters()
+ {
+ return $this->hasOne(Importers::className(), ['id' => 'importer_id']);
+ }
+
+ public function getMargins()
+ {
+ return $this->hasOne(Margins::className(), ['id' => 'margin_id']);
+ }
}
diff --git a/common/models/MarginsGroupsSearch.php b/common/models/MarginsGroupsSearch.php
index f8b521d..f5e43df 100644
--- a/common/models/MarginsGroupsSearch.php
+++ b/common/models/MarginsGroupsSearch.php
@@ -2,6 +2,7 @@
namespace common\models;
+use backend\models\Importers;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
@@ -18,8 +19,8 @@ class MarginsGroupsSearch extends MarginsGroups
public function rules()
{
return [
- [['id', 'importer_id', 'margin_id'], 'integer'],
- [['group', 'timestamp'], 'safe'],
+ [['id',], 'integer'],
+ [['group', 'timestamp', 'importer_id', 'margin_id'], 'safe'],
[['koef'], 'number'],
];
}
@@ -56,15 +57,19 @@ class MarginsGroupsSearch extends MarginsGroups
return $dataProvider;
}
+
+ $query->joinWith(['importers','margins']);
+
+
$query->andFilterWhere([
'id' => $this->id,
- 'importer_id' => $this->importer_id,
- 'margin_id' => $this->margin_id,
'koef' => $this->koef,
'timestamp' => $this->timestamp,
]);
$query->andFilterWhere(['like', 'group', $this->group]);
+ $query->andFilterWhere(['like', Importers::tableName().'name', $this->importer_id]);
+ $query->andFilterWhere(['like', Margins::tableName().'.name', $this->margin_id]);
return $dataProvider;
}
diff --git a/common/models/MarginsImporters.php b/common/models/MarginsImporters.php
index fe797d6..f8bb927 100644
--- a/common/models/MarginsImporters.php
+++ b/common/models/MarginsImporters.php
@@ -3,6 +3,7 @@
namespace common\models;
use Yii;
+use backend\models\Importers;
/**
* This is the model class for table "w_margins_importers".
@@ -42,9 +43,19 @@ class MarginsImporters extends \yii\db\ActiveRecord
{
return [
'id' => 'ID',
- 'importer_id' => 'Importer ID',
- 'margin_id' => 'Margin ID',
- 'koef' => 'Koef',
+ 'importer_id' => 'Поставщик',
+ 'margin_id' => 'Тип цены',
+ 'koef' => 'Коэффициент',
];
}
+
+ public function getImporters()
+ {
+ return $this->hasOne(Importers::className(), ['id' => 'importer_id']);
+ }
+
+ public function getMargins()
+ {
+ return $this->hasOne(Margins::className(), ['id' => 'margin_id']);
+ }
}
--
libgit2 0.21.4