Commit b7d40aed597aee597188060cf01c6d49bb9f57f2
1 parent
7975da13
Another one admin fix
Showing
10 changed files
with
252 additions
and
202 deletions
Show diff stats
backend/views/layouts/main-sidebar.php
@@ -6,9 +6,6 @@ use yii\widgets\Menu; | @@ -6,9 +6,6 @@ use yii\widgets\Menu; | ||
6 | <!-- sidebar: style can be found in sidebar.less --> | 6 | <!-- sidebar: style can be found in sidebar.less --> |
7 | <section class="sidebar"> | 7 | <section class="sidebar"> |
8 | <?php | 8 | <?php |
9 | -//print_r($this->context->id); | ||
10 | -// die(); | ||
11 | - | ||
12 | $items = [ | 9 | $items = [ |
13 | [ | 10 | [ |
14 | 'label' => 'Заказы', | 11 | 'label' => 'Заказы', |
@@ -34,43 +31,50 @@ use yii\widgets\Menu; | @@ -34,43 +31,50 @@ use yii\widgets\Menu; | ||
34 | [ | 31 | [ |
35 | 'label' => 'Товары', | 32 | 'label' => 'Товары', |
36 | 'url' => ['/product/manage'], | 33 | 'url' => ['/product/manage'], |
37 | - 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'] | 34 | + 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], |
35 | + 'active' => preg_match('/^manage.*$/', $this->context->id), | ||
38 | ], | 36 | ], |
39 | [ | 37 | [ |
40 | 'label' => 'Доставка', | 38 | 'label' => 'Доставка', |
41 | 'url' => ['/delivery'], | 39 | 'url' => ['/delivery'], |
42 | - 'options' => ['class'=>\Yii::$app->user->can('delivery') ? '' :'hide'] | 40 | + 'options' => ['class'=>\Yii::$app->user->can('delivery') ? '' :'hide'], |
41 | + 'active' => preg_match('/^delivery.*$/', $this->context->id), | ||
43 | ], | 42 | ], |
44 | [ | 43 | [ |
45 | 'label' => 'Статус товара', | 44 | 'label' => 'Статус товара', |
46 | 'url' => ['/label'], | 45 | 'url' => ['/label'], |
47 | - 'options' => ['class'=>\Yii::$app->user->can('label') ? '' :'hide'] | 46 | + 'options' => ['class'=>\Yii::$app->user->can('label') ? '' :'hide'], |
47 | + 'active' => preg_match('/^label.*$/', $this->context->id), | ||
48 | ], | 48 | ], |
49 | [ | 49 | [ |
50 | 'label' => 'Категории', | 50 | 'label' => 'Категории', |
51 | 'url' => ['/category'], | 51 | 'url' => ['/category'], |
52 | 'options' => ['class'=>\Yii::$app->user->can('category') ? '' :'hide'], | 52 | 'options' => ['class'=>\Yii::$app->user->can('category') ? '' :'hide'], |
53 | - | 53 | + 'active' => preg_match('/^category.*$/', $this->context->id), |
54 | ], | 54 | ], |
55 | [ | 55 | [ |
56 | 'label' => 'Бренды', | 56 | 'label' => 'Бренды', |
57 | 'url' => ['/brand'], | 57 | 'url' => ['/brand'], |
58 | 'options' => ['class'=>\Yii::$app->user->can('brand') ? '' :'hide'], | 58 | 'options' => ['class'=>\Yii::$app->user->can('brand') ? '' :'hide'], |
59 | + 'active' => preg_match('/^brand.*$/', $this->context->id), | ||
59 | ], | 60 | ], |
60 | [ | 61 | [ |
61 | 'label' => 'Единицы измерения', | 62 | 'label' => 'Единицы измерения', |
62 | 'url' => ['/product/product-unit'], | 63 | 'url' => ['/product/product-unit'], |
63 | 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], | 64 | 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], |
65 | + 'active' => preg_match('/^product-unit.*$/', $this->context->id), | ||
64 | ], | 66 | ], |
65 | [ | 67 | [ |
66 | 'label' => 'Импорт товаров', | 68 | 'label' => 'Импорт товаров', |
67 | 'url' => ['/product/manage/import'], | 69 | 'url' => ['/product/manage/import'], |
68 | 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], | 70 | 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], |
71 | + 'active' => preg_match('/^import.*$/', $this->context->id), | ||
69 | ], | 72 | ], |
70 | [ | 73 | [ |
71 | 'label' => 'Экспорт товаров', | 74 | 'label' => 'Экспорт товаров', |
72 | 'url' => ['/product/manage/export'], | 75 | 'url' => ['/product/manage/export'], |
73 | 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], | 76 | 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], |
77 | + 'active' => preg_match('/^export.*$/', $this->context->id), | ||
74 | ], | 78 | ], |
75 | [ | 79 | [ |
76 | 'label' => 'Характеристики Товаров', | 80 | 'label' => 'Характеристики Товаров', |
@@ -227,7 +231,6 @@ use yii\widgets\Menu; | @@ -227,7 +231,6 @@ use yii\widgets\Menu; | ||
227 | echo Menu::widget([ | 231 | echo Menu::widget([ |
228 | 'options' => ['class' => 'sidebar-menu'], | 232 | 'options' => ['class' => 'sidebar-menu'], |
229 | 'submenuTemplate' => "\n<ul class='treeview-menu'>\n{items}\n</ul>\n", | 233 | 'submenuTemplate' => "\n<ul class='treeview-menu'>\n{items}\n</ul>\n", |
230 | - | ||
231 | 'items' =>$items, | 234 | 'items' =>$items, |
232 | 235 | ||
233 | ]); | 236 | ]); |
common/modules/rubrication/controllers/TaxGroupController.php
@@ -42,6 +42,9 @@ | @@ -42,6 +42,9 @@ | ||
42 | { | 42 | { |
43 | $dataProvider = new ActiveDataProvider([ | 43 | $dataProvider = new ActiveDataProvider([ |
44 | 'query' => TaxGroup::find() | 44 | 'query' => TaxGroup::find() |
45 | + ->with('lang') | ||
46 | + ->with('options') | ||
47 | + ->with('categories') | ||
45 | ->where([ 'level' => $level ]), | 48 | ->where([ 'level' => $level ]), |
46 | ]); | 49 | ]); |
47 | 50 | ||
@@ -52,20 +55,6 @@ | @@ -52,20 +55,6 @@ | ||
52 | } | 55 | } |
53 | 56 | ||
54 | /** | 57 | /** |
55 | - * Displays a single TaxGroup model. | ||
56 | - * | ||
57 | - * @param integer $id | ||
58 | - * | ||
59 | - * @return mixed | ||
60 | - */ | ||
61 | - public function actionView($level, $id) | ||
62 | - { | ||
63 | - return $this->render('view', [ | ||
64 | - 'model' => $this->findModel($id), | ||
65 | - ]); | ||
66 | - } | ||
67 | - | ||
68 | - /** | ||
69 | * Creates a new TaxGroup model. | 58 | * Creates a new TaxGroup model. |
70 | * If creation is successful, the browser will be redirected to the 'view' page. | 59 | * If creation is successful, the browser will be redirected to the 'view' page. |
71 | * | 60 | * |
@@ -118,6 +107,7 @@ | @@ -118,6 +107,7 @@ | ||
118 | return $this->render('update', [ | 107 | return $this->render('update', [ |
119 | 'model' => $model, | 108 | 'model' => $model, |
120 | 'model_langs' => $model->model_langs, | 109 | 'model_langs' => $model->model_langs, |
110 | + 'level' => $level, | ||
121 | ]); | 111 | ]); |
122 | } | 112 | } |
123 | 113 | ||
@@ -161,7 +151,11 @@ | @@ -161,7 +151,11 @@ | ||
161 | */ | 151 | */ |
162 | protected function findModel($id) | 152 | protected function findModel($id) |
163 | { | 153 | { |
164 | - if(( $model = TaxGroup::findOne($id) ) !== NULL) { | 154 | + if(( $model = TaxGroup::find() |
155 | + ->with('lang') | ||
156 | + ->where([ 'tax_group_id' => $id ]) | ||
157 | + ->one() ) !== NULL | ||
158 | + ) { | ||
165 | return $model; | 159 | return $model; |
166 | } else { | 160 | } else { |
167 | throw new NotFoundHttpException('The requested page does not exist.'); | 161 | throw new NotFoundHttpException('The requested page does not exist.'); |
common/modules/rubrication/controllers/TaxOptionController.php
@@ -37,10 +37,15 @@ | @@ -37,10 +37,15 @@ | ||
37 | */ | 37 | */ |
38 | public function actionIndex() | 38 | public function actionIndex() |
39 | { | 39 | { |
40 | + $group = $this->findGroup(Yii::$app->request->queryParams[ 'group' ]); | ||
40 | $searchModel = new TaxOptionSearch(); | 41 | $searchModel = new TaxOptionSearch(); |
41 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | 42 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
42 | - | ||
43 | - $group = TaxGroup::findOne(Yii::$app->request->queryParams[ 'group' ]); | 43 | + $dataProvider->query->andWhere([ 'tax_group_id' => $group->tax_group_id ]); |
44 | + if($group->level) { | ||
45 | + $dataProvider->query->with('productVariants'); | ||
46 | + } else { | ||
47 | + $dataProvider->query->with('products'); | ||
48 | + } | ||
44 | 49 | ||
45 | return $this->render('index', [ | 50 | return $this->render('index', [ |
46 | 'searchModel' => $searchModel, | 51 | 'searchModel' => $searchModel, |
@@ -50,32 +55,17 @@ | @@ -50,32 +55,17 @@ | ||
50 | } | 55 | } |
51 | 56 | ||
52 | /** | 57 | /** |
53 | - * Displays a single TaxOption model. | ||
54 | - * | ||
55 | - * @param string $id | ||
56 | - * | ||
57 | - * @return mixed | ||
58 | - */ | ||
59 | - public function actionView($id) | ||
60 | - { | ||
61 | - $model = $this->findModel($id); | ||
62 | - $group = TaxGroup::findOne($model->tax_group_id); | ||
63 | - return $this->render('view', [ | ||
64 | - 'model' => $model, | ||
65 | - 'group' => $group, | ||
66 | - ]); | ||
67 | - } | ||
68 | - | ||
69 | - /** | ||
70 | * Creates a new TaxOption model. | 58 | * Creates a new TaxOption model. |
71 | * If creation is successful, the browser will be redirected to the 'view' page. | 59 | * If creation is successful, the browser will be redirected to the 'view' page. |
72 | * @return mixed | 60 | * @return mixed |
73 | */ | 61 | */ |
74 | public function actionCreate() | 62 | public function actionCreate() |
75 | { | 63 | { |
76 | - $model = new TaxOption(); | 64 | + $group = $this->findGroup(Yii::$app->request->queryParams[ 'group' ]); |
65 | + $model = new TaxOption([ | ||
66 | + 'tax_group_id' => $group->tax_group_id, | ||
67 | + ]); | ||
77 | $model->generateLangs(); | 68 | $model->generateLangs(); |
78 | - $group = TaxGroup::findOne(Yii::$app->request->queryParams[ 'group' ]); | ||
79 | if($model->load(Yii::$app->request->post())) { | 69 | if($model->load(Yii::$app->request->post())) { |
80 | $model->loadLangs(\Yii::$app->request); | 70 | $model->loadLangs(\Yii::$app->request); |
81 | if($model->save() && $model->transactionStatus) { | 71 | if($model->save() && $model->transactionStatus) { |
@@ -85,7 +75,6 @@ | @@ -85,7 +75,6 @@ | ||
85 | ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); | 75 | ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); |
86 | } | 76 | } |
87 | } | 77 | } |
88 | - $model->tax_group_id = $group->tax_group_id; | ||
89 | if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) { | 78 | if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) { |
90 | $model->parent_id = Yii::$app->request->queryParams[ 'parent' ]; | 79 | $model->parent_id = Yii::$app->request->queryParams[ 'parent' ]; |
91 | } | 80 | } |
@@ -107,12 +96,12 @@ | @@ -107,12 +96,12 @@ | ||
107 | public function actionUpdate($id) | 96 | public function actionUpdate($id) |
108 | { | 97 | { |
109 | $model = $this->findModel($id); | 98 | $model = $this->findModel($id); |
99 | + $group = $this->findGroup($model->tax_group_id); | ||
110 | $model->generateLangs(); | 100 | $model->generateLangs(); |
111 | - $group = TaxGroup::findOne($model->tax_group_id); | ||
112 | if($model->load(Yii::$app->request->post())) { | 101 | if($model->load(Yii::$app->request->post())) { |
113 | $model->loadLangs(\Yii::$app->request); | 102 | $model->loadLangs(\Yii::$app->request); |
114 | -// TaxOption::find() | ||
115 | -// ->rebuildMP($model->tax_group_id); | 103 | + // TaxOption::find() |
104 | + // ->rebuildMP($model->tax_group_id); | ||
116 | if($model->save() && $model->transactionStatus) { | 105 | if($model->save() && $model->transactionStatus) { |
117 | return $this->redirect([ | 106 | return $this->redirect([ |
118 | 'view', | 107 | 'view', |
@@ -159,7 +148,30 @@ | @@ -159,7 +148,30 @@ | ||
159 | */ | 148 | */ |
160 | protected function findModel($id) | 149 | protected function findModel($id) |
161 | { | 150 | { |
162 | - if(( $model = TaxOption::findOne($id) ) !== NULL) { | 151 | + if(( $model = TaxOption::find() |
152 | + ->with('lang') | ||
153 | + ->where([ 'tax_option_id' => $id ]) | ||
154 | + ->one() ) !== NULL | ||
155 | + ) { | ||
156 | + return $model; | ||
157 | + } else { | ||
158 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
159 | + } | ||
160 | + } | ||
161 | + | ||
162 | + /** | ||
163 | + * @param int $id | ||
164 | + * | ||
165 | + * @return null|TaxGroup | ||
166 | + * @throws NotFoundHttpException | ||
167 | + */ | ||
168 | + protected function findGroup($id) | ||
169 | + { | ||
170 | + if(( $model = TaxGroup::find() | ||
171 | + ->with('lang') | ||
172 | + ->where([ 'tax_group_id' => $id ]) | ||
173 | + ->one() ) !== NULL | ||
174 | + ) { | ||
163 | return $model; | 175 | return $model; |
164 | } else { | 176 | } else { |
165 | throw new NotFoundHttpException('The requested page does not exist.'); | 177 | throw new NotFoundHttpException('The requested page does not exist.'); |
common/modules/rubrication/models/TaxOption.php
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | use common\behaviors\SaveImgBehavior; | 5 | use common\behaviors\SaveImgBehavior; |
6 | use common\modules\language\behaviors\LanguageBehavior; | 6 | use common\modules\language\behaviors\LanguageBehavior; |
7 | use common\modules\product\models\Product; | 7 | use common\modules\product\models\Product; |
8 | + use common\modules\product\models\ProductVariant; | ||
8 | use Yii; | 9 | use Yii; |
9 | use common\components\artboxtree\ArtboxTreeBehavior; | 10 | use common\components\artboxtree\ArtboxTreeBehavior; |
10 | use yii\db\ActiveQuery; | 11 | use yii\db\ActiveQuery; |
@@ -13,26 +14,27 @@ | @@ -13,26 +14,27 @@ | ||
13 | 14 | ||
14 | /** | 15 | /** |
15 | * This is the model class for table "{{%tax_option}}". | 16 | * This is the model class for table "{{%tax_option}}". |
16 | - * @property string $tax_option_id | ||
17 | - * @property integer $tax_group_id | ||
18 | - * @property integer $parent_id | ||
19 | - * @property integer $tree | ||
20 | - * @property string $path_int | ||
21 | - * @property integer $depth | ||
22 | - * @property integer $sort | ||
23 | - * @property string $image | ||
24 | - * @property TaxGroup $taxGroup | ||
25 | - * @property TaxOption $parent | ||
26 | - * @property TaxOption[] $taxOptions | ||
27 | - * @property Product[] $products | 17 | + * @property string $tax_option_id |
18 | + * @property integer $tax_group_id | ||
19 | + * @property integer $parent_id | ||
20 | + * @property integer $tree | ||
21 | + * @property string $path_int | ||
22 | + * @property integer $depth | ||
23 | + * @property integer $sort | ||
24 | + * @property string $image | ||
25 | + * @property TaxGroup $taxGroup | ||
26 | + * @property TaxOption $parent | ||
27 | + * @property TaxOption[] $taxOptions | ||
28 | + * @property Product[] $products | ||
29 | + * @property ProductVariant[] $productVariants | ||
28 | * * From language behavior * | 30 | * * From language behavior * |
29 | - * @property TaxOptionLang $lang | ||
30 | - * @property TaxOptionLang[] $langs | ||
31 | - * @property TaxOptionLang $object_lang | ||
32 | - * @property string $ownerKey | ||
33 | - * @property string $langKey | ||
34 | - * @property TaxOptionLang[] $model_langs | ||
35 | - * @property bool $transactionStatus | 31 | + * @property TaxOptionLang $lang |
32 | + * @property TaxOptionLang[] $langs | ||
33 | + * @property TaxOptionLang $object_lang | ||
34 | + * @property string $ownerKey | ||
35 | + * @property string $langKey | ||
36 | + * @property TaxOptionLang[] $model_langs | ||
37 | + * @property bool $transactionStatus | ||
36 | * @method string getOwnerKey() | 38 | * @method string getOwnerKey() |
37 | * @method void setOwnerKey( string $value ) | 39 | * @method void setOwnerKey( string $value ) |
38 | * @method string getLangKey() | 40 | * @method string getLangKey() |
@@ -93,12 +95,6 @@ | @@ -93,12 +95,6 @@ | ||
93 | [ | 95 | [ |
94 | [ | 96 | [ |
95 | 'tax_group_id', | 97 | 'tax_group_id', |
96 | - ], | ||
97 | - 'required', | ||
98 | - ], | ||
99 | - [ | ||
100 | - [ | ||
101 | - 'tax_group_id', | ||
102 | 'parent_id', | 98 | 'parent_id', |
103 | 'sort', | 99 | 'sort', |
104 | ], | 100 | ], |
@@ -175,4 +171,10 @@ | @@ -175,4 +171,10 @@ | ||
175 | return $this->hasMany(Product::className(), [ 'product_id' => 'product_id' ]) | 171 | return $this->hasMany(Product::className(), [ 'product_id' => 'product_id' ]) |
176 | ->viaTable('product_option', [ 'option_id' => 'tax_option_id' ]); | 172 | ->viaTable('product_option', [ 'option_id' => 'tax_option_id' ]); |
177 | } | 173 | } |
174 | + | ||
175 | + public function getProductVariants() | ||
176 | + { | ||
177 | + return $this->hasMany(ProductVariant::className(), [ 'product_variant_id' => 'product_variant_id' ]) | ||
178 | + ->viaTable('product_variant_option', [ 'option_id' => 'tax_option_id' ]); | ||
179 | + } | ||
178 | } | 180 | } |
common/modules/rubrication/models/TaxOptionSearch.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | -namespace common\modules\rubrication\models; | ||
4 | - | ||
5 | -use yii\base\Model; | ||
6 | -use yii\data\ActiveDataProvider; | ||
7 | - | ||
8 | -/** | ||
9 | - * TaxOptionSearch represents the model behind the search form about `common\modules\rubrication\models\TaxOption`. | ||
10 | - */ | ||
11 | -class TaxOptionSearch extends TaxOption | ||
12 | -{ | ||
13 | 2 | ||
14 | - public function behaviors() | ||
15 | - { | ||
16 | - $behaviors = parent::behaviors(); | ||
17 | - if(isset($behaviors['language'])) { | ||
18 | - unset($behaviors['language']); | ||
19 | - } | ||
20 | - return $behaviors; | ||
21 | - } | 3 | + namespace common\modules\rubrication\models; |
4 | + | ||
5 | + use yii\base\Model; | ||
6 | + use yii\data\ActiveDataProvider; | ||
22 | 7 | ||
23 | /** | 8 | /** |
24 | - * @inheritdoc | ||
25 | - */ | ||
26 | - public function rules() | ||
27 | - { | ||
28 | - return [ | ||
29 | - [['tax_option_id', 'tax_group_id', 'parent_id', 'sort'], 'integer'], | ||
30 | - ]; | ||
31 | - } | ||
32 | - | ||
33 | - /** | ||
34 | - * @inheritdoc | ||
35 | - */ | ||
36 | - public function scenarios() | ||
37 | - { | ||
38 | - // bypass scenarios() implementation in the parent class | ||
39 | - return Model::scenarios(); | ||
40 | - } | ||
41 | - | ||
42 | - /** | ||
43 | - * Creates data provider instance with search query applied | ||
44 | - * | ||
45 | - * @param array $params | ||
46 | - * | ||
47 | - * @return ActiveDataProvider | 9 | + * TaxOptionSearch represents the model behind the search form about |
10 | + * `common\modules\rubrication\models\TaxOption`. | ||
48 | */ | 11 | */ |
49 | - public function search($params) | 12 | + class TaxOptionSearch extends TaxOption |
50 | { | 13 | { |
51 | - $query = TaxOption::find(); | ||
52 | - // add conditions that should always apply here | ||
53 | - if (!empty($params['group'])) { | ||
54 | - $this->tax_group_id = intval($params['group']); | ||
55 | - unset($params['group']); | 14 | + |
15 | + public $value; | ||
16 | + | ||
17 | + public function behaviors() | ||
18 | + { | ||
19 | + $behaviors = parent::behaviors(); | ||
20 | + if(isset( $behaviors[ 'language' ] )) { | ||
21 | + unset( $behaviors[ 'language' ] ); | ||
22 | + } | ||
23 | + return $behaviors; | ||
56 | } | 24 | } |
57 | - | ||
58 | - $dataProvider = new ActiveDataProvider([ | ||
59 | - 'query' => $query, | ||
60 | - ]); | ||
61 | - | ||
62 | - $this->load($params); | ||
63 | - | ||
64 | -// if (!$this->validate()) { | ||
65 | -// return $dataProvider; | ||
66 | -// } | ||
67 | - | ||
68 | - // grid filtering conditions | ||
69 | - $query->andFilterWhere([ | ||
70 | - 'tax_option_id' => $this->tax_option_id, | ||
71 | - 'tax_group_id' => $this->tax_group_id, | ||
72 | - 'parent_id' => $this->parent_id, | ||
73 | - 'sort' => $this->sort, | ||
74 | - ]); | ||
75 | 25 | ||
76 | - $query->orderBy(['path_int' => SORT_ASC, 'depth' => SORT_ASC, 'sort' => SORT_ASC]); | ||
77 | - | ||
78 | - return $dataProvider; | 26 | + /** |
27 | + * @inheritdoc | ||
28 | + */ | ||
29 | + public function rules() | ||
30 | + { | ||
31 | + return [ | ||
32 | + [ | ||
33 | + [ 'value' ], | ||
34 | + 'safe', | ||
35 | + ], | ||
36 | + [ | ||
37 | + [ 'tax_option_id' ], | ||
38 | + 'integer', | ||
39 | + ], | ||
40 | + ]; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * @inheritdoc | ||
45 | + */ | ||
46 | + public function scenarios() | ||
47 | + { | ||
48 | + // bypass scenarios() implementation in the parent class | ||
49 | + return Model::scenarios(); | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * Creates data provider instance with search query applied | ||
54 | + * | ||
55 | + * @param array $params | ||
56 | + * | ||
57 | + * @return ActiveDataProvider | ||
58 | + */ | ||
59 | + public function search($params) | ||
60 | + { | ||
61 | + $query = TaxOption::find() | ||
62 | + ->joinWith('lang'); | ||
63 | + | ||
64 | + $dataProvider = new ActiveDataProvider([ | ||
65 | + 'query' => $query, | ||
66 | + 'sort' => [ | ||
67 | + 'attributes' => [ | ||
68 | + 'tax_option_id', | ||
69 | + 'value' => [ | ||
70 | + 'asc' => [ 'tax_option_lang.value' => SORT_ASC ], | ||
71 | + 'desc' => [ 'tax_option_lang.value' => SORT_DESC ], | ||
72 | + ], | ||
73 | + ], | ||
74 | + ], | ||
75 | + ]); | ||
76 | + | ||
77 | + $this->load($params); | ||
78 | + | ||
79 | + // if (!$this->validate()) { | ||
80 | + // return $dataProvider; | ||
81 | + // } | ||
82 | + | ||
83 | + // grid filtering conditions | ||
84 | + $query->andFilterWhere([ | ||
85 | + 'tax_option_id' => $this->tax_option_id, | ||
86 | + ]) | ||
87 | + ->andFilterWhere([ | ||
88 | + 'like', | ||
89 | + 'tax_option_lang.value', | ||
90 | + $this->value, | ||
91 | + ]); | ||
92 | + | ||
93 | + return $dataProvider; | ||
94 | + } | ||
79 | } | 95 | } |
80 | -} |
common/modules/rubrication/views/tax-group/index.php
1 | <?php | 1 | <?php |
2 | + use common\modules\rubrication\models\TaxGroup; | ||
2 | use yii\data\ActiveDataProvider; | 3 | use yii\data\ActiveDataProvider; |
3 | use yii\helpers\Html; | 4 | use yii\helpers\Html; |
4 | use yii\grid\GridView; | 5 | use yii\grid\GridView; |
@@ -11,7 +12,7 @@ | @@ -11,7 +12,7 @@ | ||
11 | * @var ActiveDataProvider $dataProvider | 12 | * @var ActiveDataProvider $dataProvider |
12 | */ | 13 | */ |
13 | 14 | ||
14 | - $this->title = Yii::t('rubrication', 'Groups'); | 15 | + $this->title = $level?Yii::t('rubrication', 'Modification Groups'):Yii::t('rubrication', 'Product Groups'); |
15 | $this->params[ 'breadcrumbs' ][] = $this->title; | 16 | $this->params[ 'breadcrumbs' ][] = $this->title; |
16 | ?> | 17 | ?> |
17 | 18 | ||
@@ -31,34 +32,39 @@ | @@ -31,34 +32,39 @@ | ||
31 | [ 'class' => 'yii\grid\SerialColumn' ], | 32 | [ 'class' => 'yii\grid\SerialColumn' ], |
32 | 'tax_group_id', | 33 | 'tax_group_id', |
33 | 'is_filter:boolean', | 34 | 'is_filter:boolean', |
34 | - | 35 | + 'lang.name', |
36 | + [ | ||
37 | + 'label' => \Yii::t('rubrication', 'Options count'), | ||
38 | + 'value' => function($model) { | ||
39 | + /** | ||
40 | + * @var TaxGroup $model | ||
41 | + */ | ||
42 | + return count($model->options); | ||
43 | + } | ||
44 | + ], | ||
45 | + [ | ||
46 | + 'label' => \Yii::t('rubrication', 'Categories count'), | ||
47 | + 'value' => function($model) { | ||
48 | + /** | ||
49 | + * @var TaxGroup $model | ||
50 | + */ | ||
51 | + return count($model->categories); | ||
52 | + } | ||
53 | + ], | ||
35 | [ | 54 | [ |
36 | 'class' => 'yii\grid\ActionColumn', | 55 | 'class' => 'yii\grid\ActionColumn', |
37 | - 'template' => '{update} {options} {relations} {delete} {rebuild}', | 56 | + 'template' => '{update} {options} {delete}', |
38 | 'buttons' => [ | 57 | 'buttons' => [ |
39 | 'options' => function($url, $model) { | 58 | 'options' => function($url, $model) { |
40 | return Html::a('<span class="glyphicon glyphicon-th-list"></span>', $url, [ | 59 | return Html::a('<span class="glyphicon glyphicon-th-list"></span>', $url, [ |
41 | 'title' => Yii::t('rubrication', 'Options'), | 60 | 'title' => Yii::t('rubrication', 'Options'), |
42 | ]); | 61 | ]); |
43 | }, | 62 | }, |
44 | - 'relations' => function($url, $model) { | ||
45 | - return Html::a('<!--span class="glyphicon glyphicon-random"></span-->', $url, [ | ||
46 | - 'title' => Yii::t('rubrication', 'Relations'), | ||
47 | - ]); | ||
48 | - }, | ||
49 | - 'rebuild' => function($url, $model) { | ||
50 | - return Html::a('<!--span class="glyphicon glyphicon-refresh"></span-->', $url, [ | ||
51 | - 'title' => Yii::t('rubrication', 'Rebuild cache'), | ||
52 | - ]); | ||
53 | - }, | ||
54 | ], | 63 | ], |
55 | 'urlCreator' => function($action, $model, $key, $index) use ($level) { | 64 | 'urlCreator' => function($action, $model, $key, $index) use ($level) { |
56 | if($action === 'options') { | 65 | if($action === 'options') { |
57 | $url = '/admin/rubrication/tax-option?group=' . $model->tax_group_id; | 66 | $url = '/admin/rubrication/tax-option?group=' . $model->tax_group_id; |
58 | return $url; | 67 | return $url; |
59 | - } elseif($action === 'relations') { | ||
60 | - $url = '/admin/rubrication/tax-group/relation&id=' . $model->tax_group_id; | ||
61 | - return $url; | ||
62 | } elseif($action === 'update') { | 68 | } elseif($action === 'update') { |
63 | $url = Url::to([ | 69 | $url = Url::to([ |
64 | '/rubrication/tax-group/update', | 70 | '/rubrication/tax-group/update', |
@@ -73,9 +79,6 @@ | @@ -73,9 +79,6 @@ | ||
73 | 'id' => $model->tax_group_id, | 79 | 'id' => $model->tax_group_id, |
74 | ]); | 80 | ]); |
75 | return $url; | 81 | return $url; |
76 | - } elseif($action === 'rebuild') { | ||
77 | - $url = '/admin/rubrication/tax-group/rebuild?id=' . $model->tax_group_id; | ||
78 | - return $url; | ||
79 | } | 82 | } |
80 | return ''; | 83 | return ''; |
81 | }, | 84 | }, |
common/modules/rubrication/views/tax-group/update.php
@@ -9,21 +9,15 @@ | @@ -9,21 +9,15 @@ | ||
9 | * @var View $this | 9 | * @var View $this |
10 | * @var TaxGroup $model | 10 | * @var TaxGroup $model |
11 | * @var TaxGroupLang[] $model_langs | 11 | * @var TaxGroupLang[] $model_langs |
12 | + * @var int $level | ||
12 | */ | 13 | */ |
13 | 14 | ||
14 | $this->title = Yii::t('rubrication', 'Update {modelClass}: ', [ | 15 | $this->title = Yii::t('rubrication', 'Update {modelClass}: ', [ |
15 | 'modelClass' => 'Tax Group', | 16 | 'modelClass' => 'Tax Group', |
16 | - ]) . ' ' . $model->tax_group_id; | 17 | + ]) . ' ' . $model->lang->name; |
17 | $this->params[ 'breadcrumbs' ][] = [ | 18 | $this->params[ 'breadcrumbs' ][] = [ |
18 | - 'label' => Yii::t('rubrication', 'Groups'), | ||
19 | - 'url' => [ 'index' ], | ||
20 | - ]; | ||
21 | - $this->params[ 'breadcrumbs' ][] = [ | ||
22 | - 'label' => $model->tax_group_id, | ||
23 | - 'url' => [ | ||
24 | - 'view', | ||
25 | - 'id' => $model->tax_group_id, | ||
26 | - ], | 19 | + 'label' => $level?Yii::t('rubrication', 'Modification Groups'):Yii::t('rubrication', 'Product Groups'), |
20 | + 'url' => [ 'index', 'level' => $level ], | ||
27 | ]; | 21 | ]; |
28 | $this->params[ 'breadcrumbs' ][] = Yii::t('rubrication', 'Update'); | 22 | $this->params[ 'breadcrumbs' ][] = Yii::t('rubrication', 'Update'); |
29 | ?> | 23 | ?> |
common/modules/rubrication/views/tax-option/create.php
@@ -12,21 +12,26 @@ | @@ -12,21 +12,26 @@ | ||
12 | */ | 12 | */ |
13 | $this->title = Yii::t('rubrication', 'Create Tax Option'); | 13 | $this->title = Yii::t('rubrication', 'Create Tax Option'); |
14 | $this->params[ 'breadcrumbs' ][] = [ | 14 | $this->params[ 'breadcrumbs' ][] = [ |
15 | - 'label' => Yii::t('rubrication', 'Groups'), | ||
16 | - 'url' => [ 'tax-group/index' ], | 15 | + 'label' => $group->level ? Yii::t('rubrication', 'Modification Groups') : Yii::t('rubrication', 'Product Groups'), |
16 | + 'url' => [ | ||
17 | + 'tax-group/index', | ||
18 | + 'level' => $group->level, | ||
19 | + ], | ||
17 | ]; | 20 | ]; |
18 | $this->params[ 'breadcrumbs' ][] = [ | 21 | $this->params[ 'breadcrumbs' ][] = [ |
19 | - 'label' => Yii::t('rubrication', $group->tax_group_id), | 22 | + 'label' => $group->lang->name, |
20 | 'url' => [ | 23 | 'url' => [ |
21 | - 'index', | ||
22 | - 'group' => $group->tax_group_id, | 24 | + 'tax-group/update', |
25 | + 'id' => $group->tax_group_id, | ||
26 | + 'level' => $group->level, | ||
23 | ], | 27 | ], |
24 | ]; | 28 | ]; |
25 | $this->params[ 'breadcrumbs' ][] = [ | 29 | $this->params[ 'breadcrumbs' ][] = [ |
26 | - 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->tax_group_id ])), | 30 | + 'label' => Yii::t('rubrication', 'Options for group {group}', [ 'group' => $group->lang->name ]), |
27 | 'url' => [ | 31 | 'url' => [ |
28 | 'index', | 32 | 'index', |
29 | - 'group' => $group->tax_group_id, | 33 | + 'group' => $group->tax_group_id, |
34 | + 'level' => $group->level, | ||
30 | ], | 35 | ], |
31 | ]; | 36 | ]; |
32 | $this->params[ 'breadcrumbs' ][] = $this->title; | 37 | $this->params[ 'breadcrumbs' ][] = $this->title; |
common/modules/rubrication/views/tax-option/index.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use common\modules\rubrication\models\TaxGroup; | 3 | use common\modules\rubrication\models\TaxGroup; |
4 | + use common\modules\rubrication\models\TaxOption; | ||
4 | use yii\helpers\Html; | 5 | use yii\helpers\Html; |
5 | use yii\grid\GridView; | 6 | use yii\grid\GridView; |
6 | 7 | ||
@@ -11,10 +12,21 @@ | @@ -11,10 +12,21 @@ | ||
11 | * @var TaxGroup $group | 12 | * @var TaxGroup $group |
12 | */ | 13 | */ |
13 | 14 | ||
14 | - $this->title = Yii::t('rubrication', 'Options for group "{group}"', [ 'group' => $group->tax_group_id ]); | 15 | + $this->title = Yii::t('rubrication', 'Options for group {group}', [ 'group' => $group->lang->name ]); |
15 | $this->params[ 'breadcrumbs' ][] = [ | 16 | $this->params[ 'breadcrumbs' ][] = [ |
16 | - 'label' => Yii::t('rubrication', 'Groups'), | ||
17 | - 'url' => [ 'tax-group/index' ], | 17 | + 'label' => $group->level ? Yii::t('rubrication', 'Modification Groups') : Yii::t('rubrication', 'Product Groups'), |
18 | + 'url' => [ | ||
19 | + 'tax-group/index', | ||
20 | + 'level' => $group->level, | ||
21 | + ], | ||
22 | + ]; | ||
23 | + $this->params[ 'breadcrumbs' ][] = [ | ||
24 | + 'label' => $group->lang->name, | ||
25 | + 'url' => [ | ||
26 | + 'tax-group/update', | ||
27 | + 'id' => $group->tax_group_id, | ||
28 | + 'level' => $group->level, | ||
29 | + ], | ||
18 | ]; | 30 | ]; |
19 | $this->params[ 'breadcrumbs' ][] = $this->title; | 31 | $this->params[ 'breadcrumbs' ][] = $this->title; |
20 | ?> | 32 | ?> |
@@ -28,22 +40,27 @@ | @@ -28,22 +40,27 @@ | ||
28 | 40 | ||
29 | <?php echo GridView::widget([ | 41 | <?php echo GridView::widget([ |
30 | 'dataProvider' => $dataProvider, | 42 | 'dataProvider' => $dataProvider, |
43 | + 'filterModel' => $searchModel, | ||
31 | 'columns' => [ | 44 | 'columns' => [ |
32 | [ 'class' => 'yii\grid\SerialColumn' ], | 45 | [ 'class' => 'yii\grid\SerialColumn' ], |
33 | 'tax_option_id', | 46 | 'tax_option_id', |
34 | [ | 47 | [ |
48 | + 'attribute' => 'value', | ||
49 | + 'value' => 'lang.value', | ||
50 | + ], | ||
51 | + 'imageUrl:image', | ||
52 | + [ | ||
53 | + 'label' => $group->level?\Yii::t('rubrication', 'Variants count'):\Yii::t('rubrication', 'Products count'), | ||
54 | + 'value' => function($model)use($group) { | ||
55 | + /** | ||
56 | + * @var TaxOption $model | ||
57 | + */ | ||
58 | + return count($group->level?$model->productVariants:$model->products); | ||
59 | + } | ||
60 | + ], | ||
61 | + [ | ||
35 | 'class' => 'yii\grid\ActionColumn', | 62 | 'class' => 'yii\grid\ActionColumn', |
36 | 'template' => '{update} {delete}', | 63 | 'template' => '{update} {delete}', |
37 | - 'urlCreator' => function($action, $model, $key, $index) { | ||
38 | - if($action === 'update') { | ||
39 | - $url = '/admin/rubrication/tax-option/update?id=' . $model->tax_option_id; | ||
40 | - return $url; | ||
41 | - } elseif($action === 'delete') { | ||
42 | - $url = '/admin/rubrication/tax-option/delete?id=' . $model->tax_option_id; | ||
43 | - return $url; | ||
44 | - } | ||
45 | - return ''; | ||
46 | - }, | ||
47 | ], | 64 | ], |
48 | ], | 65 | ], |
49 | ]); ?> | 66 | ]); ?> |
common/modules/rubrication/views/tax-option/update.php
@@ -12,26 +12,31 @@ | @@ -12,26 +12,31 @@ | ||
12 | */ | 12 | */ |
13 | $this->title = Yii::t('rubrication', 'Update {modelClass}: ', [ | 13 | $this->title = Yii::t('rubrication', 'Update {modelClass}: ', [ |
14 | 'modelClass' => 'Tax Option', | 14 | 'modelClass' => 'Tax Option', |
15 | - ]) . ' ' . $model->tax_option_id; | 15 | + ]) . ' ' . $model->lang->value; |
16 | $this->params[ 'breadcrumbs' ][] = [ | 16 | $this->params[ 'breadcrumbs' ][] = [ |
17 | - 'label' => Yii::t('rubrication', 'Groups'), | ||
18 | - 'url' => [ 'tax-group/index' ], | 17 | + 'label' => $group->level ? Yii::t('rubrication', 'Modification Groups') : Yii::t('rubrication', 'Product Groups'), |
18 | + 'url' => [ | ||
19 | + 'tax-group/index', | ||
20 | + 'level' => $group->level, | ||
21 | + ], | ||
19 | ]; | 22 | ]; |
20 | $this->params[ 'breadcrumbs' ][] = [ | 23 | $this->params[ 'breadcrumbs' ][] = [ |
21 | - 'label' => $group->tax_group_id, | 24 | + 'label' => $group->lang->name, |
22 | 'url' => [ | 25 | 'url' => [ |
23 | - 'view', | ||
24 | - 'id' => $group->tax_group_id, | 26 | + 'tax-group/update', |
27 | + 'id' => $group->tax_group_id, | ||
28 | + 'level' => $group->level, | ||
25 | ], | 29 | ], |
26 | ]; | 30 | ]; |
27 | $this->params[ 'breadcrumbs' ][] = [ | 31 | $this->params[ 'breadcrumbs' ][] = [ |
28 | - 'label' => Yii::t('rubrication', Yii::t('rubrication', 'Options of {name}', [ 'name' => $group->tax_group_id ])), | 32 | + 'label' => Yii::t('rubrication', 'Options for group {group}', [ 'group' => $group->lang->name ]), |
29 | 'url' => [ | 33 | 'url' => [ |
30 | 'index', | 34 | 'index', |
31 | 'group' => $group->tax_group_id, | 35 | 'group' => $group->tax_group_id, |
36 | + 'level' => $group->level, | ||
32 | ], | 37 | ], |
33 | ]; | 38 | ]; |
34 | - $this->params[ 'breadcrumbs' ][] = Yii::t('rubrication', 'Update'); | 39 | + $this->params[ 'breadcrumbs' ][] = $this->title; |
35 | ?> | 40 | ?> |
36 | <div class="tax-option-update"> | 41 | <div class="tax-option-update"> |
37 | 42 |