Commit 52aea36a7d9882430aa345a882741cbb1ba45ece
1 parent
771f8d54
big commti
Showing
7 changed files
with
102 additions
and
59 deletions
Show diff stats
backend/views/layouts/main-sidebar.php
@@ -74,11 +74,6 @@ use yii\widgets\Menu; | @@ -74,11 +74,6 @@ use yii\widgets\Menu; | ||
74 | 'label' => 'Характеристики Модификаций', | 74 | 'label' => 'Характеристики Модификаций', |
75 | 'url' => Url::toRoute(['/rubrication/tax-group', 'level'=> '1']), | 75 | 'url' => Url::toRoute(['/rubrication/tax-group', 'level'=> '1']), |
76 | 'options' => ['class'=>\Yii::$app->user->can('rubrication') ? '' :'hide'], | 76 | 'options' => ['class'=>\Yii::$app->user->can('rubrication') ? '' :'hide'], |
77 | - ], | ||
78 | - [ | ||
79 | - 'label' => 'Зависимости', | ||
80 | - 'url' => ['/relation/manage'], | ||
81 | - 'options' => ['class'=>\Yii::$app->user->can('relation') ? '' :'hide'], | ||
82 | ] | 77 | ] |
83 | ] | 78 | ] |
84 | ], | 79 | ], |
common/modules/product/models/Product.php
@@ -433,6 +433,6 @@ class Product extends \yii\db\ActiveRecord | @@ -433,6 +433,6 @@ class Product extends \yii\db\ActiveRecord | ||
433 | public function getTaxGroupsByLevel($level) | 433 | public function getTaxGroupsByLevel($level) |
434 | { | 434 | { |
435 | $categories = ArrayHelper::getColumn($this->categories, 'category_id'); | 435 | $categories = ArrayHelper::getColumn($this->categories, 'category_id'); |
436 | - return TaxGroup::find()->distinct()->innerJoin('relation', 'entity1_id = tax_group_id')->andWhere(['relation.entity2_id' => $categories])->andWhere(['level' => $level]); | 436 | + return TaxGroup::find()->distinct()->innerJoin('tax_group_to_category', 'tax_group_to_category.tax_group_id = tax_group.tax_group_id')->andWhere(['tax_group_to_category.category_id' => $categories])->andWhere(['level' => $level]); |
437 | } | 437 | } |
438 | } | 438 | } |
common/modules/product/models/ProductVariant.php
@@ -252,7 +252,7 @@ class ProductVariant extends \yii\db\ActiveRecord | @@ -252,7 +252,7 @@ class ProductVariant extends \yii\db\ActiveRecord | ||
252 | public function getTaxGroupsByLevel($level) | 252 | public function getTaxGroupsByLevel($level) |
253 | { | 253 | { |
254 | $categories = ArrayHelper::getColumn($this->categories, 'category_id'); | 254 | $categories = ArrayHelper::getColumn($this->categories, 'category_id'); |
255 | - return TaxGroup::find()->distinct()->innerJoin('relation', 'entity1_id = tax_group_id')->where(['relation.entity2_id' => $categories])->where(['level' => $level]); | 255 | + return TaxGroup::find()->distinct()->innerJoin('tax_group_to_category', 'tax_group_to_category.tax_group_id = tax_group.tax_group_id')->where(['tax_group_to_category.category_id' => $categories])->where(['level' => $level]); |
256 | } | 256 | } |
257 | 257 | ||
258 | // public function afterSave($insert, $changedAttributes) | 258 | // public function afterSave($insert, $changedAttributes) |
common/modules/product/models/TaxGroupToCategory.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +use common\modules\rubrication\models\TaxGroup; | ||
6 | +use Yii; | ||
7 | + | ||
8 | +/** | ||
9 | + * This is the model class for table "tax_group_to_category". | ||
10 | + * | ||
11 | + * @property integer $tax_group_to_category_id | ||
12 | + * @property integer $tax_group_id | ||
13 | + * @property integer $category_id | ||
14 | + * | ||
15 | + * @property Category $category | ||
16 | + * @property TaxGroup $taxGroup | ||
17 | + */ | ||
18 | +class TaxGroupToCategory extends \yii\db\ActiveRecord | ||
19 | +{ | ||
20 | + /** | ||
21 | + * @inheritdoc | ||
22 | + */ | ||
23 | + public static function tableName() | ||
24 | + { | ||
25 | + return 'tax_group_to_category'; | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * @inheritdoc | ||
30 | + */ | ||
31 | + public function rules() | ||
32 | + { | ||
33 | + return [ | ||
34 | + [['tax_group_id', 'category_id'], 'required'], | ||
35 | + [['tax_group_id', 'category_id'], 'integer'], | ||
36 | + [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'category_id']], | ||
37 | + [['tax_group_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxGroup::className(), 'targetAttribute' => ['tax_group_id' => 'tax_group_id']], | ||
38 | + ]; | ||
39 | + } | ||
40 | + | ||
41 | + /** | ||
42 | + * @inheritdoc | ||
43 | + */ | ||
44 | + public function attributeLabels() | ||
45 | + { | ||
46 | + return [ | ||
47 | + 'tax_group_to_category_id' => 'Tax Group To Category ID', | ||
48 | + 'tax_group_id' => 'Tax Group ID', | ||
49 | + 'category_id' => 'Category ID', | ||
50 | + ]; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * @return \yii\db\ActiveQuery | ||
55 | + */ | ||
56 | + public function getCategory() | ||
57 | + { | ||
58 | + return $this->hasOne(Category::className(), ['category_id' => 'category_id']); | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * @return \yii\db\ActiveQuery | ||
63 | + */ | ||
64 | + public function getTaxGroup() | ||
65 | + { | ||
66 | + return $this->hasOne(TaxGroup::className(), ['tax_group_id' => 'tax_group_id']); | ||
67 | + } | ||
68 | +} |
common/modules/product/views/manage/_form.php
@@ -66,58 +66,6 @@ use kartik\select2\Select2; | @@ -66,58 +66,6 @@ use kartik\select2\Select2; | ||
66 | ], | 66 | ], |
67 | ]); ?> | 67 | ]); ?> |
68 | 68 | ||
69 | - <?php /*= $form->field($model, 'variants')->widget(MultipleInput::className(), [ | ||
70 | - 'columns' => [ | ||
71 | - [ | ||
72 | - 'name' => 'product_variant_id', | ||
73 | - 'type' => MultipleInputColumn::TYPE_HIDDEN_INPUT, | ||
74 | - ], | ||
75 | - [ | ||
76 | - 'name' => 'name', | ||
77 | - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | ||
78 | - 'title' => Yii::t('product', 'Name'), | ||
79 | - ], | ||
80 | - [ | ||
81 | - 'name' => 'sku', | ||
82 | - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | ||
83 | - 'title' => Yii::t('product', 'SKU'), | ||
84 | - ], | ||
85 | - [ | ||
86 | - 'name' => 'price', | ||
87 | - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | ||
88 | - 'title' => Yii::t('product', 'Price'), | ||
89 | - ], | ||
90 | - [ | ||
91 | - 'name' => 'price_old', | ||
92 | - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | ||
93 | - 'title' => Yii::t('product', 'Old Price'), | ||
94 | - ], | ||
95 | - [ | ||
96 | - 'name' => 'product_unit_id', | ||
97 | - 'type' => MultipleInputColumn::TYPE_DROPDOWN, | ||
98 | - 'title' => Yii::t('product', 'Unit'), | ||
99 | - 'items' => ArrayHelper::map(\common\modules\product\models\ProductUnit::find()->all(), 'product_unit_id', 'name'), | ||
100 | - ], | ||
101 | - [ | ||
102 | - 'name' => 'stock', | ||
103 | - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT, | ||
104 | - 'title' => Yii::t('product', 'Stock'), | ||
105 | - 'options' => [ | ||
106 | - 'placeholder' => '∞' | ||
107 | - ], | ||
108 | - ], | ||
109 | - [ | ||
110 | - 'name' => 'image', | ||
111 | - 'type' => 'fileInput', | ||
112 | - 'title' => Yii::t('product', 'Image'), | ||
113 | - 'options' => [ | ||
114 | - 'multiple' => false | ||
115 | - ], | ||
116 | - ], | ||
117 | - ], | ||
118 | - ]); | ||
119 | - */ ?> | ||
120 | - | ||
121 | <?php if(isset($groups)) :?> | 69 | <?php if(isset($groups)) :?> |
122 | <?php foreach($groups->all() as $group) :?> | 70 | <?php foreach($groups->all() as $group) :?> |
123 | <?= $form->field($model, 'options')->checkboxList( | 71 | <?= $form->field($model, 'options')->checkboxList( |
console/migrations/m160815_101433_add_name_to_category.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\db\Migration; | ||
4 | + | ||
5 | +class m160815_101433_add_name_to_category extends Migration | ||
6 | +{ | ||
7 | + public function up() | ||
8 | + { | ||
9 | + $this->addColumn('category', 'name', $this->string(255)); | ||
10 | + } | ||
11 | + | ||
12 | + public function down() | ||
13 | + { | ||
14 | + $this->dropColumn('category', 'name'); | ||
15 | + } | ||
16 | +} |
console/migrations/m160815_101441_add_name_to_brand.php
0 → 100644