Commit 6fdc7b5afe64861a31a76939c750edd2a9650769
1 parent
e0205ce9
Another one admin fix
Showing
9 changed files
with
166 additions
and
109 deletions
Show diff stats
backend/views/delivery/create.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | -use yii\helpers\Html; | ||
4 | - | ||
5 | - | ||
6 | -/* @var $this yii\web\View */ | ||
7 | -/* @var $model common\models\Delivery */ | ||
8 | - | ||
9 | -$this->title = 'Create Delivery'; | ||
10 | -$this->params['breadcrumbs'][] = ['label' => 'Deliveries', 'url' => ['index']]; | ||
11 | -$this->params['breadcrumbs'][] = $this->title; | 2 | + |
3 | + use common\models\Delivery; | ||
4 | + use common\models\OrdersDeliveryLang; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\web\View; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var Delivery $model | ||
11 | + * @var OrdersDeliveryLang[] $model_langs | ||
12 | + * @var array $parent_items | ||
13 | + */ | ||
14 | + | ||
15 | + $this->title = \Yii::t('product', 'Create Delivery'); | ||
16 | + $this->params[ 'breadcrumbs' ][] = [ | ||
17 | + 'label' => \Yii::t('product', 'Deliveries'), | ||
18 | + 'url' => [ 'index' ], | ||
19 | + ]; | ||
20 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
12 | ?> | 21 | ?> |
13 | <div class="delivery-create"> | 22 | <div class="delivery-create"> |
14 | - | 23 | + |
15 | <h1><?= Html::encode($this->title) ?></h1> | 24 | <h1><?= Html::encode($this->title) ?></h1> |
16 | - | 25 | + |
17 | <?= $this->render('_form', [ | 26 | <?= $this->render('_form', [ |
18 | - 'model' => $model, | ||
19 | - 'model_langs' => $model_langs, | 27 | + 'model' => $model, |
28 | + 'model_langs' => $model_langs, | ||
20 | 'parent_items' => $parent_items, | 29 | 'parent_items' => $parent_items, |
21 | ]) ?> | 30 | ]) ?> |
22 | 31 |
common/modules/product/controllers/ProductUnitController.php
@@ -137,7 +137,11 @@ | @@ -137,7 +137,11 @@ | ||
137 | */ | 137 | */ |
138 | protected function findModel($id) | 138 | protected function findModel($id) |
139 | { | 139 | { |
140 | - if(( $model = ProductUnit::findOne($id) ) !== NULL) { | 140 | + if(( $model = ProductUnit::find() |
141 | + ->where([ 'product_unit_id' => $id ]) | ||
142 | + ->with('lang') | ||
143 | + ->one() ) !== NULL | ||
144 | + ) { | ||
141 | return $model; | 145 | return $model; |
142 | } else { | 146 | } else { |
143 | throw new NotFoundHttpException('The requested page does not exist.'); | 147 | throw new NotFoundHttpException('The requested page does not exist.'); |
common/modules/product/models/ProductUnitSearch.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | -namespace common\modules\product\models; | ||
4 | - | ||
5 | -use yii\base\Model; | ||
6 | -use yii\data\ActiveDataProvider; | ||
7 | - | ||
8 | -/** | ||
9 | - * ProductUnitSearch represents the model behind the search form about `common\modules\product\models\ProductUnit`. | ||
10 | - */ | ||
11 | -class ProductUnitSearch extends ProductUnit | ||
12 | -{ | ||
13 | 2 | ||
14 | - public function behaviors() | ||
15 | - { | ||
16 | - return []; | ||
17 | - } | 3 | + namespace common\modules\product\models; |
4 | + | ||
5 | + use yii\base\Model; | ||
6 | + use yii\data\ActiveDataProvider; | ||
18 | 7 | ||
19 | /** | 8 | /** |
20 | - * @inheritdoc | ||
21 | - */ | ||
22 | - public function rules() | ||
23 | - { | ||
24 | - return [ | ||
25 | - [['product_unit_id'], 'integer'], | ||
26 | - [['is_default'], 'boolean'], | ||
27 | - ]; | ||
28 | - } | ||
29 | - | ||
30 | - /** | ||
31 | - * @inheritdoc | ||
32 | - */ | ||
33 | - public function scenarios() | ||
34 | - { | ||
35 | - // bypass scenarios() implementation in the parent class | ||
36 | - return Model::scenarios(); | ||
37 | - } | ||
38 | - | ||
39 | - /** | ||
40 | - * Creates data provider instance with search query applied | ||
41 | - * | ||
42 | - * @param array $params | ||
43 | - * | ||
44 | - * @return ActiveDataProvider | 9 | + * ProductUnitSearch represents the model behind the search form about |
10 | + * `common\modules\product\models\ProductUnit`. | ||
45 | */ | 11 | */ |
46 | - public function search($params) | 12 | + class ProductUnitSearch extends ProductUnit |
47 | { | 13 | { |
48 | - $query = ProductUnit::find(); | ||
49 | - | ||
50 | - // add conditions that should always apply here | ||
51 | - | ||
52 | - $dataProvider = new ActiveDataProvider([ | ||
53 | - 'query' => $query, | ||
54 | - ]); | ||
55 | - | ||
56 | - $this->load($params); | ||
57 | - | ||
58 | - if (!$this->validate()) { | ||
59 | - // uncomment the following line if you do not want to return any records when validation fails | ||
60 | - // $query->where('0=1'); | 14 | + |
15 | + public $name; | ||
16 | + | ||
17 | + public function behaviors() | ||
18 | + { | ||
19 | + return []; | ||
20 | + } | ||
21 | + | ||
22 | + public function attributeLabels() | ||
23 | + { | ||
24 | + $labels = parent::attributeLabels(); | ||
25 | + $new_labels = [ | ||
26 | + 'name' => \Yii::t('product', 'Product Unit Name'), | ||
27 | + ]; | ||
28 | + return array_merge($labels, $new_labels); | ||
29 | + } | ||
30 | + | ||
31 | + /** | ||
32 | + * @inheritdoc | ||
33 | + */ | ||
34 | + public function rules() | ||
35 | + { | ||
36 | + return [ | ||
37 | + [ | ||
38 | + [ 'name' ], | ||
39 | + 'safe', | ||
40 | + ], | ||
41 | + [ | ||
42 | + [ 'product_unit_id' ], | ||
43 | + 'integer', | ||
44 | + ], | ||
45 | + [ | ||
46 | + [ 'is_default' ], | ||
47 | + 'boolean', | ||
48 | + ], | ||
49 | + ]; | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * @inheritdoc | ||
54 | + */ | ||
55 | + public function scenarios() | ||
56 | + { | ||
57 | + // bypass scenarios() implementation in the parent class | ||
58 | + return Model::scenarios(); | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Creates data provider instance with search query applied | ||
63 | + * | ||
64 | + * @param array $params | ||
65 | + * | ||
66 | + * @return ActiveDataProvider | ||
67 | + */ | ||
68 | + public function search($params) | ||
69 | + { | ||
70 | + $query = ProductUnit::find()->joinWith('lang'); | ||
71 | + | ||
72 | + // add conditions that should always apply here | ||
73 | + | ||
74 | + $dataProvider = new ActiveDataProvider([ | ||
75 | + 'query' => $query, | ||
76 | + 'sort' => [ | ||
77 | + 'attributes' => [ | ||
78 | + 'product_unit_id', | ||
79 | + 'is_defaut', | ||
80 | + 'name' => [ | ||
81 | + 'asc' => [ 'product_unit_lang.name' => SORT_ASC ], | ||
82 | + 'desc' => [ 'product_unit_lang.name' => SORT_DESC ], | ||
83 | + ], | ||
84 | + ], | ||
85 | + ], | ||
86 | + ]); | ||
87 | + | ||
88 | + $this->load($params); | ||
89 | + | ||
90 | + if(!$this->validate()) { | ||
91 | + // uncomment the following line if you do not want to return any records when validation fails | ||
92 | + // $query->where('0=1'); | ||
93 | + return $dataProvider; | ||
94 | + } | ||
95 | + | ||
96 | + // grid filtering conditions | ||
97 | + $query->andFilterWhere([ | ||
98 | + 'product_unit_id' => $this->product_unit_id, | ||
99 | + 'is_default' => $this->is_default, | ||
100 | + ]) | ||
101 | + ->andFilterWhere([ | ||
102 | + 'ilike', | ||
103 | + 'product_unit_lang.name', | ||
104 | + $this->name, | ||
105 | + ]); | ||
106 | + | ||
61 | return $dataProvider; | 107 | return $dataProvider; |
62 | } | 108 | } |
63 | - | ||
64 | - // grid filtering conditions | ||
65 | - $query->andFilterWhere([ | ||
66 | - 'product_unit_id' => $this->product_unit_id, | ||
67 | - 'is_default' => $this->is_default, | ||
68 | - ]); | ||
69 | - | ||
70 | - return $dataProvider; | ||
71 | } | 109 | } |
72 | -} |
common/modules/product/views/manage/export-process.php
@@ -3,10 +3,7 @@ | @@ -3,10 +3,7 @@ | ||
3 | * @var View $this | 3 | * @var View $this |
4 | */ | 4 | */ |
5 | 5 | ||
6 | -use yii\helpers\Html; | ||
7 | use yii\web\View; | 6 | use yii\web\View; |
8 | - use yii\widgets\ActiveForm; | ||
9 | - | ||
10 | ?> | 7 | ?> |
11 | <?php | 8 | <?php |
12 | $this->registerJs("var in_process=true; | 9 | $this->registerJs("var in_process=true; |
@@ -102,5 +99,5 @@ $this->registerJs("var in_process=true; | @@ -102,5 +99,5 @@ $this->registerJs("var in_process=true; | ||
102 | ], | 99 | ], |
103 | ]);?> | 100 | ]);?> |
104 | <ul id="process-result"></ul> | 101 | <ul id="process-result"></ul> |
105 | - <a id="result_link" href="" class="hidden">ะะพะปััะฐะน ะะะกะฏ!</a> | 102 | + <a id="result_link" href="" class="hidden"><?php echo \Yii::t('app', 'Get File'); ?></a> |
106 | </div> | 103 | </div> |
common/modules/product/views/manage/export.php
@@ -37,21 +37,8 @@ | @@ -37,21 +37,8 @@ | ||
37 | ->indexBy('language_id') | 37 | ->indexBy('language_id') |
38 | ->column()) ?> | 38 | ->column()) ?> |
39 | 39 | ||
40 | - <?php /*= $form->field($model, 'file')->widget(\kartik\file\FileInput::classname(), [ | ||
41 | - 'language' => 'ru', | ||
42 | - 'options' => [ | ||
43 | - 'multiple' => false, | ||
44 | - ], | ||
45 | - 'pluginOptions' => [ | ||
46 | - 'allowedFileExtensions' => ['csv'], | ||
47 | - 'overwriteInitial' => true, | ||
48 | - 'showRemove' => false, | ||
49 | - 'showUpload' => false, | ||
50 | - ], | ||
51 | - ])*/ ?> | ||
52 | - | ||
53 | <div class="form-group"> | 40 | <div class="form-group"> |
54 | - <?= Html::submitButton(Yii::t('product', 'Import'), [ 'class' => 'btn btn-primary' ]) ?> | 41 | + <?= Html::submitButton(Yii::t('product', 'Export'), [ 'class' => 'btn btn-success' ]) ?> |
55 | </div> | 42 | </div> |
56 | 43 | ||
57 | <?php ActiveForm::end(); ?> | 44 | <?php ActiveForm::end(); ?> |
common/modules/product/views/product-unit/index.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | + use common\modules\product\models\ProductUnitSearch; | ||
4 | + use yii\data\ActiveDataProvider; | ||
3 | use yii\helpers\Html; | 5 | use yii\helpers\Html; |
4 | use yii\grid\GridView; | 6 | use yii\grid\GridView; |
7 | + use yii\web\View; | ||
5 | 8 | ||
6 | - /* @var $this yii\web\View */ | ||
7 | - /* @var $searchModel common\modules\product\models\ProductUnitSearch */ | ||
8 | - /* @var $dataProvider yii\data\ActiveDataProvider */ | 9 | + /** |
10 | + * @var View $this | ||
11 | + * @var ProductUnitSearch $searchModel | ||
12 | + * @var ActiveDataProvider $dataProvider | ||
13 | + */ | ||
9 | 14 | ||
10 | $this->title = Yii::t('product', 'Product Units'); | 15 | $this->title = Yii::t('product', 'Product Units'); |
11 | $this->params[ 'breadcrumbs' ][] = $this->title; | 16 | $this->params[ 'breadcrumbs' ][] = $this->title; |
@@ -21,9 +26,17 @@ | @@ -21,9 +26,17 @@ | ||
21 | 'dataProvider' => $dataProvider, | 26 | 'dataProvider' => $dataProvider, |
22 | 'filterModel' => $searchModel, | 27 | 'filterModel' => $searchModel, |
23 | 'columns' => [ | 28 | 'columns' => [ |
24 | - [ 'class' => 'yii\grid\SerialColumn' ], | ||
25 | 'product_unit_id', | 29 | 'product_unit_id', |
26 | - 'is_default:boolean', | 30 | + [ |
31 | + 'attribute' => 'is_default', | ||
32 | + 'format' => 'boolean', | ||
33 | + 'filter' => [\Yii::$app->formatter->asBoolean(false), \Yii::$app->formatter->asBoolean(true)], | ||
34 | + ], | ||
35 | + [ | ||
36 | + 'attribute' => 'name', | ||
37 | + 'value' => 'lang.name', | ||
38 | + ], | ||
39 | + 'lang.short', | ||
27 | [ 'class' => 'yii\grid\ActionColumn' ], | 40 | [ 'class' => 'yii\grid\ActionColumn' ], |
28 | ], | 41 | ], |
29 | ]); ?> | 42 | ]); ?> |
common/modules/product/views/product-unit/update.php
@@ -13,13 +13,13 @@ | @@ -13,13 +13,13 @@ | ||
13 | 13 | ||
14 | $this->title = Yii::t('product', 'Update {modelClass}: ', [ | 14 | $this->title = Yii::t('product', 'Update {modelClass}: ', [ |
15 | 'modelClass' => 'Product Unit', | 15 | 'modelClass' => 'Product Unit', |
16 | - ]) . $model->product_unit_id; | 16 | + ]) . $model->lang->name; |
17 | $this->params[ 'breadcrumbs' ][] = [ | 17 | $this->params[ 'breadcrumbs' ][] = [ |
18 | 'label' => Yii::t('product', 'Product Units'), | 18 | 'label' => Yii::t('product', 'Product Units'), |
19 | 'url' => [ 'index' ], | 19 | 'url' => [ 'index' ], |
20 | ]; | 20 | ]; |
21 | $this->params[ 'breadcrumbs' ][] = [ | 21 | $this->params[ 'breadcrumbs' ][] = [ |
22 | - 'label' => $model->product_unit_id, | 22 | + 'label' => $model->lang->name, |
23 | 'url' => [ | 23 | 'url' => [ |
24 | 'view', | 24 | 'view', |
25 | 'id' => $model->product_unit_id, | 25 | 'id' => $model->product_unit_id, |
common/modules/product/views/product-unit/view.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | + use common\modules\product\models\ProductUnit; | ||
3 | use yii\helpers\Html; | 4 | use yii\helpers\Html; |
5 | + use yii\web\View; | ||
4 | use yii\widgets\DetailView; | 6 | use yii\widgets\DetailView; |
5 | 7 | ||
6 | - /* @var $this yii\web\View */ | ||
7 | - /* @var $model common\modules\product\models\ProductUnit */ | 8 | + /** |
9 | + * @var View $this | ||
10 | + * @var ProductUnit $model | ||
11 | + */ | ||
8 | 12 | ||
9 | - $this->title = $model->product_unit_id; | 13 | + $this->title = $model->lang->name; |
10 | $this->params[ 'breadcrumbs' ][] = [ | 14 | $this->params[ 'breadcrumbs' ][] = [ |
11 | 'label' => Yii::t('product', 'Product Units'), | 15 | 'label' => Yii::t('product', 'Product Units'), |
12 | 'url' => [ 'index' ], | 16 | 'url' => [ 'index' ], |
@@ -39,6 +43,8 @@ | @@ -39,6 +43,8 @@ | ||
39 | 'attributes' => [ | 43 | 'attributes' => [ |
40 | 'product_unit_id', | 44 | 'product_unit_id', |
41 | 'is_default:boolean', | 45 | 'is_default:boolean', |
46 | + 'lang.name', | ||
47 | + 'lang.short', | ||
42 | ], | 48 | ], |
43 | ]) ?> | 49 | ]) ?> |
44 | 50 |
common/modules/rubrication/views/tax-group/index.php
1 | <?php | 1 | <?php |
2 | + use yii\data\ActiveDataProvider; | ||
2 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
3 | use yii\grid\GridView; | 4 | use yii\grid\GridView; |
4 | use yii\helpers\Url; | 5 | use yii\helpers\Url; |
6 | + use yii\web\View; | ||
5 | 7 | ||
6 | - /* @var $this yii\web\View */ | ||
7 | - /* @var $level integer | ||
8 | - /* @var $dataProvider yii\data\ActiveDataProvider */ | 8 | + /** |
9 | + * @var View $this | ||
10 | + * @var integer $level | ||
11 | + * @var ActiveDataProvider $dataProvider | ||
12 | + */ | ||
9 | 13 | ||
10 | $this->title = Yii::t('rubrication', 'Groups'); | 14 | $this->title = Yii::t('rubrication', 'Groups'); |
11 | $this->params[ 'breadcrumbs' ][] = $this->title; | 15 | $this->params[ 'breadcrumbs' ][] = $this->title; |