d8c1a2e0
Yarik
Big commit artbox
|
1
|
<?php
|
af036678
Yarik
Image behaviors
|
2
3
4
5
|
use common\modules\product\models\Brand;
use common\modules\product\models\Category;
use common\modules\product\models\Product;
|
00731fef
Yarik
Before vitex test
|
6
7
|
use common\modules\product\models\ProductSearch;
use yii\data\ActiveDataProvider;
|
af036678
Yarik
Image behaviors
|
8
9
10
11
12
|
use yii\helpers\Html;
use yii\grid\GridView;
use kartik\select2\Select2;
use common\components\artboxtree\ArtboxTreeHelper;
use common\modules\product\helpers\ProductHelper;
|
00731fef
Yarik
Before vitex test
|
13
|
use yii\web\View;
|
af036678
Yarik
Image behaviors
|
14
|
|
00731fef
Yarik
Before vitex test
|
15
16
17
18
19
|
/**
* @var View $this
* @var ProductSearch $searchModel
* @var ActiveDataProvider $dataProvider
*/
|
af036678
Yarik
Image behaviors
|
20
21
|
$this->title = Yii::t('product', 'Products');
$this->params[ 'breadcrumbs' ][] = $this->title;
|
d8c1a2e0
Yarik
Big commit artbox
|
22
23
|
?>
<div class="product-index">
|
af036678
Yarik
Image behaviors
|
24
|
|
d8c1a2e0
Yarik
Big commit artbox
|
25
|
<h1><?= Html::encode($this->title) ?></h1>
|
af036678
Yarik
Image behaviors
|
26
|
|
d8c1a2e0
Yarik
Big commit artbox
|
27
|
<p>
|
af036678
Yarik
Image behaviors
|
28
|
<?= Html::a(Yii::t('product', 'Create Product'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
|
d8c1a2e0
Yarik
Big commit artbox
|
29
30
31
|
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
|
af036678
Yarik
Image behaviors
|
32
33
|
'filterModel' => $searchModel,
'columns' => [
|
93c267f7
Yarik
Multilanguage big...
|
34
|
'product_id',
|
d8c1a2e0
Yarik
Big commit artbox
|
35
|
[
|
bcc6ba2b
Eugeny Galkovskiy
MESSAGES !!!! EVGEN!
|
36
|
'label' => Yii::t('product', 'Product Name'),
|
00731fef
Yarik
Before vitex test
|
37
38
39
40
41
|
'attribute' => 'product_name',
'value' => 'lang.name',
],
[
'label' => Yii::t('product', 'Brand'),
|
af036678
Yarik
Image behaviors
|
42
|
'attribute' => 'brand_id',
|
00731fef
Yarik
Before vitex test
|
43
44
|
'value' => 'brand.lang.name',
'filter' => Select2::widget([
|
af036678
Yarik
Image behaviors
|
45
46
|
'model' => $searchModel,
'attribute' => 'brand_id',
|
00731fef
Yarik
Before vitex test
|
47
48
49
50
51
52
53
54
55
|
'data' => Brand::find()
->joinWith('lang')
->select([
'brand_lang.name',
'brand.brand_id',
])
->asArray()
->indexBy('brand_id')
->column(),
|
af036678
Yarik
Image behaviors
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
'language' => 'ru',
'options' => [
'placeholder' => Yii::t('product', 'Select brand'),
'multiple' => false,
],
'pluginOptions' => [
'allowClear' => true,
],
]),
],
[
'label' => Yii::t('product', 'Category'),
'attribute' => 'category_id',
'value' => function($model) {
/**
* @var Product $model
*/
$categories = [];
|
00731fef
Yarik
Before vitex test
|
74
75
76
|
foreach($model->getCategories()
->with('lang')
->all() as $category) {
|
af036678
Yarik
Image behaviors
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/**
* @var Category $category
*/
$categories[] = $category->lang->name;
}
return implode(", ", $categories);
},
'filter' => Select2::widget([
'model' => $searchModel,
'attribute' => 'category_id',
'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'lang.name'),
'language' => 'ru',
'options' => [
'placeholder' => Yii::t('product', 'Select category'),
'multiple' => false,
],
'pluginOptions' => [
'allowClear' => true,
],
]),
],
|
00731fef
Yarik
Before vitex test
|
98
|
[
|
bcc6ba2b
Eugeny Galkovskiy
MESSAGES !!!! EVGEN!
|
99
|
'label' => Yii::t('product', 'Variant Count'),
|
00731fef
Yarik
Before vitex test
|
100
101
102
103
104
105
106
107
|
'attribute' => 'variant_count',
'value' => function($model) {
/**
* @var Product $model
*/
return count($model->variants);
},
],
|
af036678
Yarik
Image behaviors
|
108
109
110
111
112
113
|
[
'class' => 'yii\grid\ActionColumn',
'template' => '{items} {view} |{is_top} {is_new} {akciya} | {update} {delete}',
'buttons' => [
'is_top' => function($url, $model) {
return Html::a('<span class="glyphicon glyphicon-star' . ( $model->is_top ? '' : '-empty' ) . '"></span>', $url, [
|
bcc6ba2b
Eugeny Galkovskiy
MESSAGES !!!! EVGEN!
|
114
|
'title' => Yii::t('product', ( $model->is_top ? Yii::t('app', 'Set not is top') : Yii::t('app', 'Set is top') )),
|
d8c1a2e0
Yarik
Big commit artbox
|
115
116
|
]);
},
|
af036678
Yarik
Image behaviors
|
117
118
|
'is_new' => function($url, $model) {
return Html::a('<span class="glyphicon glyphicon-heart' . ( $model->is_new ? '' : '-empty' ) . '"></span>', $url, [
|
bcc6ba2b
Eugeny Galkovskiy
MESSAGES !!!! EVGEN!
|
119
|
'title' => Yii::t('product', ( $model->is_new ? Yii::t('app', 'Set not is new') : Yii::t('app', 'Set is new') )),
|
d8c1a2e0
Yarik
Big commit artbox
|
120
121
|
]);
},
|
af036678
Yarik
Image behaviors
|
122
123
|
'akciya' => function($url, $model) {
return Html::a('<span class="glyphicon glyphicon-tag' . ( $model->akciya ? 's' : '' ) . '"></span>', $url, [
|
bcc6ba2b
Eugeny Galkovskiy
MESSAGES !!!! EVGEN!
|
124
|
'title' => Yii::t('product', ( $model->akciya ? Yii::t('app', 'Set not is promotion') : Yii::t('app', 'Set is promotion') )),
|
d8c1a2e0
Yarik
Big commit artbox
|
125
126
|
]);
},
|
af036678
Yarik
Image behaviors
|
127
|
'items' => function($url, $model) {
|
d8c1a2e0
Yarik
Big commit artbox
|
128
129
130
131
|
return Html::a('<span class="glyphicon glyphicon-th-list"></span>', $url, [
'title' => Yii::t('product', 'Variants'),
]);
},
|
af036678
Yarik
Image behaviors
|
132
|
|
d8c1a2e0
Yarik
Big commit artbox
|
133
|
],
|
af036678
Yarik
Image behaviors
|
134
135
|
'urlCreator' => function($action, $model, $key, $index) {
switch($action) {
|
d8c1a2e0
Yarik
Big commit artbox
|
136
|
case 'items':
|
af036678
Yarik
Image behaviors
|
137
138
139
140
|
return \yii\helpers\Url::to([
'/product/variant',
'product_id' => $model->product_id,
]);
|
d8c1a2e0
Yarik
Big commit artbox
|
141
142
|
break;
case 'is_top':
|
af036678
Yarik
Image behaviors
|
143
144
145
146
|
return \yii\helpers\Url::to([
'manage/is_top',
'id' => $model->product_id,
]);
|
d8c1a2e0
Yarik
Big commit artbox
|
147
148
|
break;
case 'is_new':
|
af036678
Yarik
Image behaviors
|
149
150
151
152
|
return \yii\helpers\Url::to([
'manage/is_new',
'id' => $model->product_id,
]);
|
d8c1a2e0
Yarik
Big commit artbox
|
153
154
|
break;
case 'akciya':
|
af036678
Yarik
Image behaviors
|
155
156
157
158
|
return \yii\helpers\Url::to([
'manage/akciya',
'id' => $model->product_id,
]);
|
d8c1a2e0
Yarik
Big commit artbox
|
159
160
|
break;
case 'view':
|
af036678
Yarik
Image behaviors
|
161
162
163
164
|
return \yii\helpers\Url::to([
'manage/view',
'id' => $model->product_id,
]);
|
d8c1a2e0
Yarik
Big commit artbox
|
165
166
|
break;
case 'update':
|
af036678
Yarik
Image behaviors
|
167
168
169
170
|
return \yii\helpers\Url::to([
'manage/update',
'id' => $model->product_id,
]);
|
d8c1a2e0
Yarik
Big commit artbox
|
171
172
|
break;
case 'delete':
|
af036678
Yarik
Image behaviors
|
173
174
175
176
|
return \yii\helpers\Url::to([
'manage/delete',
'id' => $model->product_id,
]);
|
d8c1a2e0
Yarik
Big commit artbox
|
177
|
break;
|
00731fef
Yarik
Before vitex test
|
178
179
|
default:
return '';
|
d8c1a2e0
Yarik
Big commit artbox
|
180
|
}
|
af036678
Yarik
Image behaviors
|
181
|
},
|
d8c1a2e0
Yarik
Big commit artbox
|
182
183
184
185
|
],
],
]); ?>
</div>
|