Commit 85261b1444345649e5f9c92c0a5c3896ecba479d
1 parent
8df80521
not fixed commite
Showing
31 changed files
with
1669 additions
and
1 deletions
Show diff stats
.gitignore
@@ -35,4 +35,8 @@ common/config/params-local.php | @@ -35,4 +35,8 @@ common/config/params-local.php | ||
35 | backend/config/main-local.php | 35 | backend/config/main-local.php |
36 | backend/config/params-local.php | 36 | backend/config/params-local.php |
37 | frontend/config/main-local.php | 37 | frontend/config/main-local.php |
38 | -frontend/config/params-local.php | ||
39 | \ No newline at end of file | 38 | \ No newline at end of file |
39 | +frontend/config/params-local.php | ||
40 | + | ||
41 | +backend/web/assets/ | ||
42 | +frontend/web/assets/ | ||
43 | +frontend/web/css/node_modules/ | ||
40 | \ No newline at end of file | 44 | \ No newline at end of file |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\controllers; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use common\modules\product\models\Brand; | ||
7 | +use common\modules\product\models\BrandSearch; | ||
8 | +use yii\web\Controller; | ||
9 | +use yii\web\NotFoundHttpException; | ||
10 | +use yii\filters\VerbFilter; | ||
11 | + | ||
12 | +/** | ||
13 | + * BrandController implements the CRUD actions for Brand model. | ||
14 | + */ | ||
15 | +class BrandController extends Controller | ||
16 | +{ | ||
17 | + /** | ||
18 | + * @inheritdoc | ||
19 | + */ | ||
20 | + public function behaviors() | ||
21 | + { | ||
22 | + return [ | ||
23 | + 'verbs' => [ | ||
24 | + 'class' => VerbFilter::className(), | ||
25 | + 'actions' => [ | ||
26 | + 'delete' => ['POST'], | ||
27 | + ], | ||
28 | + ], | ||
29 | + ]; | ||
30 | + } | ||
31 | + | ||
32 | + /** | ||
33 | + * Lists all Brand models. | ||
34 | + * @return mixed | ||
35 | + */ | ||
36 | + public function actionIndex() | ||
37 | + { | ||
38 | + $searchModel = new BrandSearch(); | ||
39 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
40 | + | ||
41 | + return $this->render('index', [ | ||
42 | + 'searchModel' => $searchModel, | ||
43 | + 'dataProvider' => $dataProvider, | ||
44 | + ]); | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Displays a single Brand model. | ||
49 | + * @param integer $id | ||
50 | + * @return mixed | ||
51 | + */ | ||
52 | + public function actionView($id) | ||
53 | + { | ||
54 | + return $this->render('view', [ | ||
55 | + 'model' => $this->findModel($id), | ||
56 | + ]); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a new Brand model. | ||
61 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
62 | + * @return mixed | ||
63 | + */ | ||
64 | + public function actionCreate() | ||
65 | + { | ||
66 | + $model = new Brand(); | ||
67 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
68 | + return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect(['view', 'id' => $model->brand_id]) : $this->redirect(array_merge(['create'], Yii::$app->request->queryParams)); | ||
69 | + } else { | ||
70 | + return $this->render('create', [ | ||
71 | + 'model' => $model, | ||
72 | + ]); | ||
73 | + } | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * Updates an existing Brand model. | ||
78 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
79 | + * @param integer $id | ||
80 | + * @return mixed | ||
81 | + */ | ||
82 | + public function actionUpdate($id) | ||
83 | + { | ||
84 | + $model = $this->findModel($id); | ||
85 | + | ||
86 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
87 | + return $this->redirect(['view', 'id' => $model->brand_id]); | ||
88 | + } else { | ||
89 | + return $this->render('update', [ | ||
90 | + 'model' => $model, | ||
91 | + ]); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Deletes an existing Brand model. | ||
97 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
98 | + * @param integer $id | ||
99 | + * @return mixed | ||
100 | + */ | ||
101 | + public function actionDelete($id) | ||
102 | + { | ||
103 | + $this->findModel($id)->delete(); | ||
104 | + | ||
105 | + return $this->redirect(['index']); | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * Finds the Brand model based on its primary key value. | ||
110 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
111 | + * @param integer $id | ||
112 | + * @return Brand the loaded model | ||
113 | + * @throws NotFoundHttpException if the model cannot be found | ||
114 | + */ | ||
115 | + protected function findModel($id) | ||
116 | + { | ||
117 | + if (($model = Brand::findOne($id)) !== null) { | ||
118 | + return $model; | ||
119 | + } else { | ||
120 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
121 | + } | ||
122 | + } | ||
123 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace backend\controllers; | ||
4 | + | ||
5 | +use common\components\artboxtree\ArtboxTreeHelper; | ||
6 | +use Yii; | ||
7 | +use common\modules\product\models\Category; | ||
8 | +use common\modules\product\models\CategorySearch; | ||
9 | +use yii\helpers\ArrayHelper; | ||
10 | +use yii\web\Controller; | ||
11 | +use yii\web\NotFoundHttpException; | ||
12 | +use yii\filters\VerbFilter; | ||
13 | + | ||
14 | +/** | ||
15 | + * CategoryController implements the CRUD actions for Category model. | ||
16 | + */ | ||
17 | +class CategoryController extends Controller | ||
18 | +{ | ||
19 | + /** | ||
20 | + * @inheritdoc | ||
21 | + */ | ||
22 | + public function behaviors() | ||
23 | + { | ||
24 | + return [ | ||
25 | + 'verbs' => [ | ||
26 | + 'class' => VerbFilter::className(), | ||
27 | + 'actions' => [ | ||
28 | + 'delete' => ['POST'], | ||
29 | + ], | ||
30 | + ], | ||
31 | + ]; | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * Lists all Category models. | ||
36 | + * @return mixed | ||
37 | + */ | ||
38 | + public function actionIndex() | ||
39 | + { | ||
40 | + $searchModel = new CategorySearch(); | ||
41 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
42 | + | ||
43 | + return $this->render('index', [ | ||
44 | + 'searchModel' => $searchModel, | ||
45 | + 'dataProvider' => $dataProvider, | ||
46 | + ]); | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Displays a single Category model. | ||
51 | + * @param integer $id | ||
52 | + * @return mixed | ||
53 | + */ | ||
54 | + public function actionView($id) | ||
55 | + { | ||
56 | + return $this->render('view', [ | ||
57 | + 'model' => $this->findModel($id), | ||
58 | + ]); | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Creates a new Category model. | ||
63 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
64 | + * @return mixed | ||
65 | + */ | ||
66 | + public function actionCreate() | ||
67 | + { | ||
68 | + $model = new Category(); | ||
69 | + | ||
70 | + if ($model->load(Yii::$app->request->post())) { | ||
71 | + $model->save(); | ||
72 | + return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect(['view', 'id' => $model->category_id]) : $this->redirect(array_merge(['create'], Yii::$app->request->queryParams)); | ||
73 | + } else { | ||
74 | + if (!empty(Yii::$app->request->queryParams['parent'])) { | ||
75 | + $model->parent_id = Yii::$app->request->queryParams['parent']; | ||
76 | + } | ||
77 | + return $this->render('create', [ | ||
78 | + 'model' => $model, | ||
79 | + 'categories' => ArtboxTreeHelper::treeMap(Category::find()->getTree(), 'category_id', 'name', '.') | ||
80 | + ]); | ||
81 | + } | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * Updates an existing Category model. | ||
86 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
87 | + * @param integer $id | ||
88 | + * @return mixed | ||
89 | + */ | ||
90 | + public function actionUpdate($id) | ||
91 | + { | ||
92 | + $model = $this->findModel($id); | ||
93 | + | ||
94 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
95 | + return $this->redirect(['view', 'id' => $model->category_id]); | ||
96 | + } else { | ||
97 | + return $this->render('update', [ | ||
98 | + 'model' => $model, | ||
99 | + 'categories' => ArtboxTreeHelper::treeMap(Category::find()->getTree(), 'category_id', 'name', '.') | ||
100 | + ]); | ||
101 | + } | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * Deletes an existing Category model. | ||
106 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
107 | + * @param integer $id | ||
108 | + * @return mixed | ||
109 | + */ | ||
110 | + public function actionDelete($id) | ||
111 | + { | ||
112 | + $this->findModel($id)->delete(); | ||
113 | + | ||
114 | + return $this->redirect(['index']); | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Finds the Category model based on its primary key value. | ||
119 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
120 | + * @param integer $id | ||
121 | + * @return Category the loaded model | ||
122 | + * @throws NotFoundHttpException if the model cannot be found | ||
123 | + */ | ||
124 | + protected function findModel($id) | ||
125 | + { | ||
126 | + if (($model = Category::findOne($id)) !== null) { | ||
127 | + return $model; | ||
128 | + } else { | ||
129 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
130 | + } | ||
131 | + } | ||
132 | +} |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\Brand */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="brand-form"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin(); ?> | ||
14 | + | ||
15 | + <?= $form->field($model, 'name')->textInput() ?> | ||
16 | + | ||
17 | + <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> | ||
18 | + | ||
19 | + <?= \common\modules\file\widgets\ImageUploader::widget([ | ||
20 | + 'model'=> $model, | ||
21 | + 'field'=>'image', | ||
22 | + 'size' => [ | ||
23 | + [ | ||
24 | + 'width'=>102, | ||
25 | + 'height'=>57, | ||
26 | + ] | ||
27 | + ], | ||
28 | + 'multi'=>false, | ||
29 | + 'gallery' => $model->image, | ||
30 | + 'name' => 'Загрузить изображение' | ||
31 | + ]); | ||
32 | + ?> | ||
33 | + | ||
34 | + <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?> | ||
35 | + | ||
36 | + <?= $form->field($model, 'meta_desc')->textarea(['rows' => 6]) ?> | ||
37 | + | ||
38 | + <?= $form->field($model, 'meta_robots')->textInput(['maxlength' => true]) ?> | ||
39 | + | ||
40 | + <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> | ||
41 | + | ||
42 | + <div class="form-group"> | ||
43 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
44 | + <?php if ($model->isNewRecord) :?> | ||
45 | + <?= Html::submitButton(Yii::t('product', 'Create and continue'), ['name' => 'create_and_new', 'class' => 'btn btn-primary']) ?> | ||
46 | + <?php endif?> | ||
47 | + </div> | ||
48 | + | ||
49 | + <?php ActiveForm::end(); ?> | ||
50 | + | ||
51 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\BrandSearch */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="brand-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin([ | ||
14 | + 'action' => ['index'], | ||
15 | + 'method' => 'get', | ||
16 | + ]); ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'brand_id') ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'brand_name_id') ?> | ||
21 | + | ||
22 | + <?= $form->field($model, 'alias') ?> | ||
23 | + | ||
24 | + <?= $form->field($model, 'image') ?> | ||
25 | + | ||
26 | + <?= $form->field($model, 'meta_title') ?> | ||
27 | + | ||
28 | + <?php // echo $form->field($model, 'meta_desc') ?> | ||
29 | + | ||
30 | + <?php // echo $form->field($model, 'meta_robots') ?> | ||
31 | + | ||
32 | + <?php // echo $form->field($model, 'seo_text') ?> | ||
33 | + | ||
34 | + <div class="form-group"> | ||
35 | + <?= Html::submitButton(Yii::t('product', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
36 | + <?= Html::resetButton(Yii::t('product', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
37 | + </div> | ||
38 | + | ||
39 | + <?php ActiveForm::end(); ?> | ||
40 | + | ||
41 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\Brand */ | ||
8 | + | ||
9 | +$this->title = Yii::t('product', 'Create Brand'); | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Brands'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="brand-create"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <?= $this->render('_form', [ | ||
18 | + 'model' => $model, | ||
19 | + ]) ?> | ||
20 | + | ||
21 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\grid\GridView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $searchModel common\modules\product\models\BrandSearch */ | ||
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
9 | + | ||
10 | +$this->title = Yii::t('product', 'Brands'); | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="brand-index"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
17 | + | ||
18 | + <p> | ||
19 | + <?= Html::a(Yii::t('product', 'Create Brand'), ['create'], ['class' => 'btn btn-success']) ?> | ||
20 | + </p> | ||
21 | + <?= GridView::widget([ | ||
22 | + 'dataProvider' => $dataProvider, | ||
23 | +// 'filterModel' => $searchModel, | ||
24 | + 'columns' => [ | ||
25 | + ['class' => 'yii\grid\SerialColumn'], | ||
26 | + | ||
27 | + 'name', | ||
28 | + 'alias', | ||
29 | + | ||
30 | + ['class' => 'yii\grid\ActionColumn'], | ||
31 | + ], | ||
32 | + ]); ?> | ||
33 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | +/* @var $this yii\web\View */ | ||
6 | +/* @var $model common\modules\product\models\Brand */ | ||
7 | + | ||
8 | +$this->title = Yii::t('product', 'Update {modelClass}: ', [ | ||
9 | + 'modelClass' => 'Brand', | ||
10 | +]) . ' ' . $model->brand_id; | ||
11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Brands'), 'url' => ['index']]; | ||
12 | +$this->params['breadcrumbs'][] = ['label' => $model->brand_id, 'url' => ['view', 'id' => $model->brand_id]]; | ||
13 | +$this->params['breadcrumbs'][] = Yii::t('product', 'Update'); | ||
14 | +?> | ||
15 | +<div class="brand-update"> | ||
16 | + | ||
17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
18 | + | ||
19 | + <?= $this->render('_form', [ | ||
20 | + 'model' => $model, | ||
21 | + ]) ?> | ||
22 | + | ||
23 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\DetailView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\Brand */ | ||
8 | + | ||
9 | +$this->title = $model->brand_id; | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Brands'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="brand-view"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <p> | ||
18 | + <?= Html::a(Yii::t('product', 'Update'), ['update', 'id' => $model->brand_id], ['class' => 'btn btn-primary']) ?> | ||
19 | + <?= Html::a(Yii::t('product', 'Delete'), ['delete', 'id' => $model->brand_id], [ | ||
20 | + 'class' => 'btn btn-danger', | ||
21 | + 'data' => [ | ||
22 | + 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), | ||
23 | + 'method' => 'post', | ||
24 | + ], | ||
25 | + ]) ?> | ||
26 | + </p> | ||
27 | + | ||
28 | + <?= DetailView::widget([ | ||
29 | + 'model' => $model, | ||
30 | + 'attributes' => [ | ||
31 | + 'brand_id', | ||
32 | + 'brand_name_id', | ||
33 | + 'alias', | ||
34 | + 'image', | ||
35 | + 'meta_title', | ||
36 | + 'meta_desc:ntext', | ||
37 | + 'meta_robots', | ||
38 | + 'seo_text:ntext', | ||
39 | + ], | ||
40 | + ]) ?> | ||
41 | + | ||
42 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | +use common\modules\file\widgets\ImageUploader; | ||
6 | + | ||
7 | +/* @var $this yii\web\View */ | ||
8 | +/* @var $model common\modules\product\models\Category */ | ||
9 | +/* @var $form yii\widgets\ActiveForm */ | ||
10 | +?> | ||
11 | + | ||
12 | +<div class="category-form"> | ||
13 | + | ||
14 | + <?php $form = ActiveForm::begin(); ?> | ||
15 | + | ||
16 | + <?= $form->field($model, 'name')->textInput() ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'parent_id')->dropDownList($categories, [ | ||
21 | + 'prompt' => Yii::t('rubrication', 'Root category'), | ||
22 | + 'options' => [ | ||
23 | + $model->category_id => ['disabled' => true] | ||
24 | + ] | ||
25 | + ])->label(Yii::t('product', 'Parent category')) ?> | ||
26 | + | ||
27 | + <?= ImageUploader::widget([ | ||
28 | + 'model'=> $model, | ||
29 | + 'field'=>'image', | ||
30 | + 'size' => [ | ||
31 | + [ | ||
32 | + 'width'=>340, | ||
33 | + 'height'=>260, | ||
34 | + ] | ||
35 | + ], | ||
36 | + 'multi'=>false, | ||
37 | + 'gallery' => $model->image, | ||
38 | + 'name' => 'Загрузить изображение' | ||
39 | + ]); | ||
40 | + ?> | ||
41 | + | ||
42 | + <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?> | ||
43 | + | ||
44 | + <?= $form->field($model, 'meta_desc')->textarea(['rows' => 6]) ?> | ||
45 | + | ||
46 | + <?= $form->field($model, 'meta_robots')->textInput(['maxlength' => true]) ?> | ||
47 | + | ||
48 | + <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> | ||
49 | + | ||
50 | + <?php if (!empty($model) && $model->depth == 2) :?> | ||
51 | + <?= $form->field($model, 'populary')->checkbox() ?> | ||
52 | + <?php endif?> | ||
53 | + | ||
54 | + <div class="form-group"> | ||
55 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
56 | + <?php if ($model->isNewRecord) :?> | ||
57 | + <?= Html::submitButton(Yii::t('product', 'Create and continue'), ['name' => 'create_and_new', 'class' => 'btn btn-primary']) ?> | ||
58 | + <?php endif?> | ||
59 | + </div> | ||
60 | + | ||
61 | + <?php ActiveForm::end(); ?> | ||
62 | + | ||
63 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\CategorySearch */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="category-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin([ | ||
14 | + 'action' => ['index'], | ||
15 | + 'method' => 'get', | ||
16 | + ]); ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'category_id') ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'parent_id') ?> | ||
21 | + | ||
22 | + <?= $form->field($model, 'path') ?> | ||
23 | + | ||
24 | + <?= $form->field($model, 'depth') ?> | ||
25 | + | ||
26 | + <?= $form->field($model, 'image') ?> | ||
27 | + | ||
28 | + <?php // echo $form->field($model, 'meta_title') ?> | ||
29 | + | ||
30 | + <?php // echo $form->field($model, 'meta_desc') ?> | ||
31 | + | ||
32 | + <?php // echo $form->field($model, 'meta_robots') ?> | ||
33 | + | ||
34 | + <?php // echo $form->field($model, 'seo_text') ?> | ||
35 | + | ||
36 | + <?php // echo $form->field($model, 'category_name_id') ?> | ||
37 | + | ||
38 | + <?php // echo $form->field($model, 'product_unit_id') ?> | ||
39 | + | ||
40 | + <?php // echo $form->field($model, 'alias') ?> | ||
41 | + | ||
42 | + <div class="form-group"> | ||
43 | + <?= Html::submitButton(Yii::t('product', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
44 | + <?= Html::resetButton(Yii::t('product', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
45 | + </div> | ||
46 | + | ||
47 | + <?php ActiveForm::end(); ?> | ||
48 | + | ||
49 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\Category */ | ||
8 | + | ||
9 | +$this->title = Yii::t('product', 'Create Category'); | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Categories'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="category-create"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <?= $this->render('_form', [ | ||
18 | + 'model' => $model, | ||
19 | + 'categories' => $categories | ||
20 | + ]) ?> | ||
21 | + | ||
22 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\grid\GridView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $searchModel common\modules\product\models\CategorySearch */ | ||
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
9 | + | ||
10 | +$this->title = Yii::t('product', 'Categories'); | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="category-index"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
17 | + | ||
18 | + <p> | ||
19 | + <?= Html::a(Yii::t('product', 'Create Category'), ['create'], ['class' => 'btn btn-success']) ?> | ||
20 | + </p> | ||
21 | + <?= GridView::widget([ | ||
22 | + 'dataProvider' => $dataProvider, | ||
23 | +// 'filterModel' => $searchModel, | ||
24 | + 'columns' => [ | ||
25 | + [ | ||
26 | + 'label'=> Yii::t('rubrication', 'Name'), | ||
27 | + 'content'=>function($data){ | ||
28 | + return str_repeat('-', $data->depth) .' '. $data->name; | ||
29 | + } | ||
30 | + ], | ||
31 | + 'alias', | ||
32 | + 'populary:boolean', | ||
33 | + // 'meta_title', | ||
34 | + // 'meta_desc:ntext', | ||
35 | + // 'meta_robots', | ||
36 | + // 'seo_text:ntext', | ||
37 | + // 'product_unit_id', | ||
38 | + | ||
39 | + ['class' => 'yii\grid\ActionColumn'], | ||
40 | + ], | ||
41 | + ]); ?> | ||
42 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | + | ||
5 | +/* @var $this yii\web\View */ | ||
6 | +/* @var $model common\modules\product\models\Category */ | ||
7 | + | ||
8 | +$this->title = Yii::t('product', 'Update {modelClass}: ', [ | ||
9 | + 'modelClass' => 'Category', | ||
10 | +]) . ' ' . $model->name; | ||
11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Categories'), 'url' => ['index']]; | ||
12 | +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->category_id]]; | ||
13 | +$this->params['breadcrumbs'][] = Yii::t('product', 'Update'); | ||
14 | +?> | ||
15 | +<div class="category-update"> | ||
16 | + | ||
17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
18 | + | ||
19 | + <?= $this->render('_form', [ | ||
20 | + 'model' => $model, | ||
21 | + 'categories' => $categories | ||
22 | + ]) ?> | ||
23 | + | ||
24 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\DetailView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model common\modules\product\models\Category */ | ||
8 | + | ||
9 | +$this->title = $model->name; | ||
10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Categories'), 'url' => ['index']]; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="category-view"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + | ||
17 | + <p> | ||
18 | + <?= Html::a(Yii::t('product', 'Update'), ['update', 'id' => $model->category_id], ['class' => 'btn btn-primary']) ?> | ||
19 | + <?= Html::a(Yii::t('product', 'Delete'), ['delete', 'id' => $model->category_id], [ | ||
20 | + 'class' => 'btn btn-danger', | ||
21 | + 'data' => [ | ||
22 | + 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), | ||
23 | + 'method' => 'post', | ||
24 | + ], | ||
25 | + ]) ?> | ||
26 | + <?= Html::a(Yii::t('product', 'Create category'), ['category/create'], ['class' => 'btn btn-success']) ?> | ||
27 | + <?php if (!empty($model->parent_id)) :?> | ||
28 | + <?= Html::a(Yii::t('product', 'Create category By {name}', ['name' => $model->parent->name]), ['category/create?parent='. $model->parent->category_id], ['class' => 'btn btn-success']) ?> | ||
29 | + <?php endif?> | ||
30 | + </p> | ||
31 | + | ||
32 | + <?= DetailView::widget([ | ||
33 | + 'model' => $model, | ||
34 | + 'attributes' => [ | ||
35 | + 'category_id', | ||
36 | + 'parent_id', | ||
37 | + 'path', | ||
38 | + 'depth', | ||
39 | + 'image', | ||
40 | + 'meta_title', | ||
41 | + 'meta_desc:ntext', | ||
42 | + 'meta_robots', | ||
43 | + 'seo_text:ntext', | ||
44 | + 'category_name_id', | ||
45 | + 'product_unit_id', | ||
46 | + 'alias', | ||
47 | + ], | ||
48 | + ]) ?> | ||
49 | + | ||
50 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | +// NOTE: Make sure this file is not accessible when deployed to production | ||
4 | +if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) { | ||
5 | + die('You are not allowed to access this file.'); | ||
6 | +} | ||
7 | + | ||
8 | +defined('YII_DEBUG') or define('YII_DEBUG', true); | ||
9 | +defined('YII_ENV') or define('YII_ENV', 'test'); | ||
10 | + | ||
11 | +require(__DIR__ . '/../../vendor/autoload.php'); | ||
12 | +require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); | ||
13 | +require(__DIR__ . '/../../common/config/bootstrap.php'); | ||
14 | +require(__DIR__ . '/../config/bootstrap.php'); | ||
15 | + | ||
16 | + | ||
17 | +$config = require(__DIR__ . '/../../tests/codeception/config/backend/acceptance.php'); | ||
18 | + | ||
19 | +(new yii\web\Application($config))->run(); |
1 | +<?php | ||
2 | +defined('YII_DEBUG') or define('YII_DEBUG', true); | ||
3 | +defined('YII_ENV') or define('YII_ENV', 'dev'); | ||
4 | + | ||
5 | +require(__DIR__ . '/../../vendor/autoload.php'); | ||
6 | +require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); | ||
7 | +require(__DIR__ . '/../../common/config/bootstrap.php'); | ||
8 | +require(__DIR__ . '/../config/bootstrap.php'); | ||
9 | + | ||
10 | +$config = yii\helpers\ArrayHelper::merge( | ||
11 | + require(__DIR__ . '/../config/main.php'), | ||
12 | + require(__DIR__ . '/../config/main-local.php'), | ||
13 | + require(__DIR__ . '/../../common/config/main.php'), | ||
14 | + require(__DIR__ . '/../../common/config/main-local.php') | ||
15 | + | ||
16 | +); | ||
17 | + | ||
18 | +$application = new yii\web\Application($config); | ||
19 | +$application->run(); |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +use common\behaviors\Slug; | ||
6 | +use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; | ||
7 | +use Yii; | ||
8 | + | ||
9 | +/** | ||
10 | + * This is the model class for table "brand". | ||
11 | + * | ||
12 | + * @property integer $brand_id | ||
13 | + * @property integer $brand_name_id | ||
14 | + * @property string $alias | ||
15 | + * @property string $image | ||
16 | + * @property string $meta_title | ||
17 | + * @property string $meta_desc | ||
18 | + * @property string $meta_robots | ||
19 | + * @property string $seo_text | ||
20 | + * | ||
21 | + * @property BrandName $brandName | ||
22 | + * @property BrandName[] $brandNames | ||
23 | + * @property Product[] $products | ||
24 | + */ | ||
25 | +class Brand extends \yii\db\ActiveRecord | ||
26 | +{ | ||
27 | + public function behaviors() | ||
28 | + { | ||
29 | + return [ | ||
30 | + 'slug' => [ | ||
31 | + 'class' => Slug::className(), | ||
32 | + 'in_attribute' => 'name', | ||
33 | + 'out_attribute' => 'alias', | ||
34 | + 'translit' => true | ||
35 | + ], | ||
36 | + 'artboxsynonym' => [ | ||
37 | + 'class' => ArtboxSynonymBehavior::className(), | ||
38 | + 'keyNameValue' => 'brand_name_id', | ||
39 | + 'valueModel' => BrandName::className(), | ||
40 | + 'valueOptionId' => 'brand_id', | ||
41 | + 'valueFields' => [ // postKey => DBFieldName | ||
42 | + 'name' => 'value' | ||
43 | + ] | ||
44 | + ] | ||
45 | + ]; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * @inheritdoc | ||
50 | + */ | ||
51 | + public static function tableName() | ||
52 | + { | ||
53 | + return 'brand'; | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * @inheritdoc | ||
58 | + */ | ||
59 | + public function rules() | ||
60 | + { | ||
61 | + return [ | ||
62 | + [['name'], 'required'], | ||
63 | + [['brand_name_id'], 'integer'], | ||
64 | + [['meta_desc', 'seo_text'], 'string'], | ||
65 | + [['alias', 'name'], 'string', 'max' => 250], | ||
66 | + [['image', 'meta_title'], 'string', 'max' => 255], | ||
67 | + [['meta_robots'], 'string', 'max' => 50], | ||
68 | +// [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], | ||
69 | + ]; | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * @inheritdoc | ||
74 | + */ | ||
75 | + public function attributeLabels() | ||
76 | + { | ||
77 | + return [ | ||
78 | + 'brand_id' => Yii::t('product', 'Brand ID'), | ||
79 | + 'brand_name_id' => Yii::t('product', 'Brand Name ID'), | ||
80 | + 'alias' => Yii::t('product', 'Alias'), | ||
81 | + 'image' => Yii::t('product', 'Image'), | ||
82 | + 'meta_title' => Yii::t('product', 'Meta Title'), | ||
83 | + 'meta_desc' => Yii::t('product', 'Meta Desc'), | ||
84 | + 'meta_robots' => Yii::t('product', 'Meta Robots'), | ||
85 | + 'seo_text' => Yii::t('product', 'Seo Text'), | ||
86 | + ]; | ||
87 | + } | ||
88 | + | ||
89 | + /** | ||
90 | + * @return \yii\db\ActiveQuery | ||
91 | + */ | ||
92 | + public function getBrandName() | ||
93 | + { | ||
94 | + return $this->hasOne(BrandName::className(), ['brand_name_id' => 'brand_name_id']); | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * @return \yii\db\ActiveQuery | ||
99 | + */ | ||
100 | + public function getBrandNames() | ||
101 | + { | ||
102 | + return $this->hasMany(BrandName::className(), ['brand_id' => 'brand_id']); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * @return \yii\db\ActiveQuery | ||
107 | + */ | ||
108 | + public function getProducts() | ||
109 | + { | ||
110 | + return $this->hasMany(Product::className(), ['brand_id' => 'brand_id']); | ||
111 | + } | ||
112 | + | ||
113 | + public function getName() { | ||
114 | + $value = $this->getBrandName()->one(); | ||
115 | + return empty($value) ? $this->_getValue('name') : $value->value; | ||
116 | + } | ||
117 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "brand_name". | ||
9 | + * | ||
10 | + * @property integer $brand_name_id | ||
11 | + * @property integer $brand_id | ||
12 | + * @property string $value | ||
13 | + * | ||
14 | + * @property Brand[] $brands | ||
15 | + * @property Brand $brand | ||
16 | + */ | ||
17 | +class BrandName extends \yii\db\ActiveRecord | ||
18 | +{ | ||
19 | + /** | ||
20 | + * @inheritdoc | ||
21 | + */ | ||
22 | + public static function tableName() | ||
23 | + { | ||
24 | + return 'brand_name'; | ||
25 | + } | ||
26 | + | ||
27 | + /** | ||
28 | + * @inheritdoc | ||
29 | + */ | ||
30 | + public function rules() | ||
31 | + { | ||
32 | + return [ | ||
33 | + [['brand_id'], 'integer'], | ||
34 | + [['value'], 'string', 'max' => 250], | ||
35 | +// [['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => Brand::className(), 'targetAttribute' => ['brand_id' => 'brand_id']], | ||
36 | + ]; | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * @inheritdoc | ||
41 | + */ | ||
42 | + public function attributeLabels() | ||
43 | + { | ||
44 | + return [ | ||
45 | + 'brand_name_id' => Yii::t('product', 'Brand Name ID'), | ||
46 | + 'brand_id' => Yii::t('product', 'Brand ID'), | ||
47 | + 'value' => Yii::t('product', 'Value'), | ||
48 | + ]; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * @return \yii\db\ActiveQuery | ||
53 | + */ | ||
54 | + public function getBrands() | ||
55 | + { | ||
56 | + return $this->hasMany(Brand::className(), ['brand_name_id' => 'brand_name_id']); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * @return \yii\db\ActiveQuery | ||
61 | + */ | ||
62 | + public function getBrand() | ||
63 | + { | ||
64 | + return $this->hasOne(Brand::className(), ['brand_id' => 'brand_id']); | ||
65 | + } | ||
66 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +/** | ||
6 | + * This is the ActiveQuery class for [[Brand]]. | ||
7 | + * | ||
8 | + * @see Brand | ||
9 | + */ | ||
10 | +class BrandQuery extends \yii\db\ActiveQuery | ||
11 | +{ | ||
12 | + /*public function active() | ||
13 | + { | ||
14 | + return $this->andWhere('[[status]]=1'); | ||
15 | + }*/ | ||
16 | + | ||
17 | + /** | ||
18 | + * @inheritdoc | ||
19 | + * @return Brand[]|array | ||
20 | + */ | ||
21 | + public function all($db = null) | ||
22 | + { | ||
23 | + return parent::all($db); | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * @inheritdoc | ||
28 | + * @return Brand|array|null | ||
29 | + */ | ||
30 | + public function one($db = null) | ||
31 | + { | ||
32 | + return parent::one($db); | ||
33 | + } | ||
34 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\base\Model; | ||
7 | +use yii\data\ActiveDataProvider; | ||
8 | +use common\modules\product\models\Brand; | ||
9 | + | ||
10 | +/** | ||
11 | + * BrandSearch represents the model behind the search form about `common\modules\product\models\Brand`. | ||
12 | + */ | ||
13 | +class BrandSearch extends Brand | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @inheritdoc | ||
17 | + */ | ||
18 | + public function rules() | ||
19 | + { | ||
20 | + return [ | ||
21 | + [['brand_id', 'brand_name_id'], 'integer'], | ||
22 | + [['alias', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text'], 'safe'], | ||
23 | + ]; | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * @inheritdoc | ||
28 | + */ | ||
29 | + public function scenarios() | ||
30 | + { | ||
31 | + // bypass scenarios() implementation in the parent class | ||
32 | + return Model::scenarios(); | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * Creates data provider instance with search query applied | ||
37 | + * | ||
38 | + * @param array $params | ||
39 | + * | ||
40 | + * @return ActiveDataProvider | ||
41 | + */ | ||
42 | + public function search($params) | ||
43 | + { | ||
44 | + $query = Brand::find(); | ||
45 | + | ||
46 | + // add conditions that should always apply here | ||
47 | + | ||
48 | + $dataProvider = new ActiveDataProvider([ | ||
49 | + 'query' => $query, | ||
50 | + ]); | ||
51 | + | ||
52 | + $this->load($params); | ||
53 | + | ||
54 | + /*if (!$this->validate()) { | ||
55 | + // uncomment the following line if you do not want to return any records when validation fails | ||
56 | + // $query->where('0=1'); | ||
57 | + return $dataProvider; | ||
58 | + }*/ | ||
59 | + | ||
60 | + // grid filtering conditions | ||
61 | + $query->andFilterWhere([ | ||
62 | + 'brand_id' => $this->brand_id, | ||
63 | + 'brand_name_id' => $this->brand_name_id, | ||
64 | + ]); | ||
65 | + | ||
66 | + $query->andFilterWhere(['like', 'alias', $this->alias]) | ||
67 | + ->andFilterWhere(['like', 'image', $this->image]) | ||
68 | + ->andFilterWhere(['like', 'meta_title', $this->meta_title]) | ||
69 | + ->andFilterWhere(['like', 'meta_desc', $this->meta_desc]) | ||
70 | + ->andFilterWhere(['like', 'meta_robots', $this->meta_robots]) | ||
71 | + ->andFilterWhere(['like', 'seo_text', $this->seo_text]); | ||
72 | + | ||
73 | + return $dataProvider; | ||
74 | + } | ||
75 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +use common\behaviors\Slug; | ||
6 | +use common\components\artboxtree\ArtboxTreeBehavior; | ||
7 | +use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; | ||
8 | +use Yii; | ||
9 | + | ||
10 | +/** | ||
11 | + * This is the model class for table "category". | ||
12 | + * | ||
13 | + * @property integer $category_id | ||
14 | + * @property integer $parent_id | ||
15 | + * @property string $path | ||
16 | + * @property integer $depth | ||
17 | + * @property string $image | ||
18 | + * @property string $meta_title | ||
19 | + * @property string $meta_desc | ||
20 | + * @property string $meta_robots | ||
21 | + * @property string $seo_text | ||
22 | + * @property integer $category_name_id | ||
23 | + * @property integer $product_unit_id | ||
24 | + * @property string $alias | ||
25 | + * @property boolean $populary | ||
26 | + * | ||
27 | + * @property CategoryName $categoryName | ||
28 | + * @property ProductUnit $productUnit | ||
29 | + * @property CategoryName[] $categoryNames | ||
30 | + * @property ProductCategory[] $productCategories | ||
31 | + */ | ||
32 | +class Category extends \yii\db\ActiveRecord | ||
33 | +{ | ||
34 | + public function behaviors() | ||
35 | + { | ||
36 | + return [ | ||
37 | + 'artboxtree' => [ | ||
38 | + 'class' => ArtboxTreeBehavior::className(), | ||
39 | + 'keyNameGroup' => null, | ||
40 | + 'keyNamePath' => 'path', | ||
41 | + ], | ||
42 | + 'slug' => [ | ||
43 | + 'class' => Slug::className(), | ||
44 | + 'in_attribute' => 'name', | ||
45 | + 'out_attribute' => 'alias', | ||
46 | + 'translit' => true | ||
47 | + ], | ||
48 | + 'artboxsynonym' => [ | ||
49 | + 'class' => ArtboxSynonymBehavior::className(), | ||
50 | + 'keyNameValue' => 'category_name_id', | ||
51 | + 'valueModel' => CategoryName::className(), | ||
52 | + 'valueOptionId' => 'category_id', | ||
53 | + 'valueFields' => [ // postKey => DBFieldName | ||
54 | + 'name' => 'value' | ||
55 | + ] | ||
56 | + ] | ||
57 | + ]; | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * @inheritdoc | ||
62 | + */ | ||
63 | + public static function tableName() | ||
64 | + { | ||
65 | + return 'category'; | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * @inheritdoc | ||
70 | + */ | ||
71 | + public function rules() | ||
72 | + { | ||
73 | + return [ | ||
74 | + [['name'], 'required'], | ||
75 | + [['parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'], | ||
76 | + [['path', 'meta_desc', 'seo_text'], 'string'], | ||
77 | + [['image', 'meta_title'], 'string', 'max' => 255], | ||
78 | + [['meta_robots'], 'string', 'max' => 50], | ||
79 | + [['alias', 'name'], 'string', 'max' => 250], | ||
80 | + [['populary'], 'boolean'] | ||
81 | +// [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']], | ||
82 | + ]; | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * @inheritdoc | ||
87 | + */ | ||
88 | + public function attributeLabels() | ||
89 | + { | ||
90 | + return [ | ||
91 | + 'category_id' => Yii::t('product', 'Category ID'), | ||
92 | + 'parent_id' => Yii::t('product', 'Parent ID'), | ||
93 | + 'path' => Yii::t('product', 'Path'), | ||
94 | + 'depth' => Yii::t('product', 'Depth'), | ||
95 | + 'image' => Yii::t('product', 'Image'), | ||
96 | + 'meta_title' => Yii::t('product', 'Meta Title'), | ||
97 | + 'meta_desc' => Yii::t('product', 'Meta Desc'), | ||
98 | + 'meta_robots' => Yii::t('product', 'Meta Robots'), | ||
99 | + 'seo_text' => Yii::t('product', 'Seo Text'), | ||
100 | + 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | ||
101 | + 'alias' => Yii::t('product', 'Alias'), | ||
102 | + 'populary' => Yii::t('product', 'Populary'), | ||
103 | + ]; | ||
104 | + } | ||
105 | + | ||
106 | + public static function find() { | ||
107 | + return new CategoryQuery(get_called_class()); | ||
108 | + } | ||
109 | + | ||
110 | + /** | ||
111 | + * @return \yii\db\ActiveQuery | ||
112 | + */ | ||
113 | + public function getProductUnit() | ||
114 | + { | ||
115 | + return $this->hasOne(ProductUnit::className(), ['product_unit_id' => 'product_unit_id']); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * @return \yii\db\ActiveQuery | ||
120 | + */ | ||
121 | + public function getCategoryNames() | ||
122 | + { | ||
123 | + return $this->hasMany(CategoryName::className(), ['category_id' => 'category_id']); | ||
124 | + } | ||
125 | + | ||
126 | + /** | ||
127 | + * @return \yii\db\ActiveQuery | ||
128 | + */ | ||
129 | + public function getProductCategories() | ||
130 | + { | ||
131 | + return $this->hasMany(ProductCategory::className(), ['category_id' => 'category_id']); | ||
132 | + } | ||
133 | + | ||
134 | + public function beforeSave($insert) | ||
135 | + { | ||
136 | + if (parent::beforeSave($insert)) { | ||
137 | + | ||
138 | + if (empty($this->parent_id)) | ||
139 | + $this->parent_id = 0; | ||
140 | + return true; | ||
141 | + } | ||
142 | + return false; | ||
143 | + } | ||
144 | + | ||
145 | + public function getCategoryName() { | ||
146 | + return $this->hasOne(CategoryName::className(), ['category_name_id' => 'category_name_id']); | ||
147 | + } | ||
148 | + | ||
149 | + public function getName() { | ||
150 | + $value = $this->getCategoryName()->one(); | ||
151 | + return empty($value) ? $this->_getValue('name') : $value->value; | ||
152 | + } | ||
153 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "category_name". | ||
9 | + * | ||
10 | + * @property integer $category_name_id | ||
11 | + * @property integer $category_id | ||
12 | + * @property string $value | ||
13 | + * | ||
14 | + * @property Category[] $categories | ||
15 | + * @property Category $category | ||
16 | + */ | ||
17 | +class CategoryName extends \yii\db\ActiveRecord | ||
18 | +{ | ||
19 | + /** | ||
20 | + * @inheritdoc | ||
21 | + */ | ||
22 | + public static function tableName() | ||
23 | + { | ||
24 | + return 'category_name'; | ||
25 | + } | ||
26 | + | ||
27 | + /** | ||
28 | + * @inheritdoc | ||
29 | + */ | ||
30 | + public function rules() | ||
31 | + { | ||
32 | + return [ | ||
33 | + [['category_id'], 'integer'], | ||
34 | + [['value'], 'string', 'max' => 250], | ||
35 | + [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'category_id']], | ||
36 | + ]; | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * @inheritdoc | ||
41 | + */ | ||
42 | + public function attributeLabels() | ||
43 | + { | ||
44 | + return [ | ||
45 | + 'category_name_id' => Yii::t('product', 'Category Name ID'), | ||
46 | + 'category_id' => Yii::t('product', 'Category ID'), | ||
47 | + 'value' => Yii::t('product', 'Value'), | ||
48 | + ]; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * @return \yii\db\ActiveQuery | ||
53 | + */ | ||
54 | + public function getCategories() | ||
55 | + { | ||
56 | + return $this->hasMany(Category::className(), ['category_name_id' => 'category_name_id']); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * @return \yii\db\ActiveQuery | ||
61 | + */ | ||
62 | + public function getCategory() | ||
63 | + { | ||
64 | + return $this->hasOne(Category::className(), ['category_id' => 'category_id']); | ||
65 | + } | ||
66 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | +use common\components\artboxtree\ArtboxTreeQueryTrait; | ||
5 | + | ||
6 | +/** | ||
7 | + * This is the ActiveQuery class for [[Category]]. | ||
8 | + * | ||
9 | + * @see Category | ||
10 | + */ | ||
11 | +class CategoryQuery extends \yii\db\ActiveQuery | ||
12 | +{ | ||
13 | + use ArtboxTreeQueryTrait; | ||
14 | + | ||
15 | + /*public function active() | ||
16 | + { | ||
17 | + return $this->andWhere('[[status]]=1'); | ||
18 | + }*/ | ||
19 | + | ||
20 | + /** | ||
21 | + * @inheritdoc | ||
22 | + * @return Category[]|array | ||
23 | + */ | ||
24 | + public function all($db = null) | ||
25 | + { | ||
26 | + return parent::all($db); | ||
27 | + } | ||
28 | + | ||
29 | + /** | ||
30 | + * @inheritdoc | ||
31 | + * @return Category|array|null | ||
32 | + */ | ||
33 | + public function one($db = null) | ||
34 | + { | ||
35 | + return parent::one($db); | ||
36 | + } | ||
37 | + | ||
38 | + /** | ||
39 | + * Select category by alias | ||
40 | + * @param $slug | ||
41 | + * @return $this | ||
42 | + */ | ||
43 | + public function byAlias($alias) | ||
44 | + { | ||
45 | + $this->andFilterWhere(['alias' => $alias]); | ||
46 | + return $this; | ||
47 | + } | ||
48 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\base\Model; | ||
7 | +use yii\data\ActiveDataProvider; | ||
8 | +use common\modules\product\models\Category; | ||
9 | +use yii\web\NotFoundHttpException; | ||
10 | + | ||
11 | +/** | ||
12 | + * CategorySearch represents the model behind the search form about `common\modules\product\models\Category`. | ||
13 | + */ | ||
14 | +class CategorySearch extends Category | ||
15 | +{ | ||
16 | + public function behaviors() | ||
17 | + { | ||
18 | + $behaviors = parent::behaviors(); | ||
19 | + if (isset($behaviors['slug'])) { | ||
20 | + unset($behaviors['slug']); | ||
21 | + } | ||
22 | + if (isset($behaviors['timestamp'])) { | ||
23 | + unset($behaviors['timestamp']); | ||
24 | + } | ||
25 | + return $behaviors; | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * @inheritdoc | ||
30 | + */ | ||
31 | + public function rules() | ||
32 | + { | ||
33 | + return [ | ||
34 | + [['category_id', 'parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'], | ||
35 | + [['populary'], 'boolean'], | ||
36 | + [['path', 'image', 'meta_title', 'meta_desc', 'meta_robots', 'seo_text', 'alias'], 'safe'], | ||
37 | + ]; | ||
38 | + } | ||
39 | + | ||
40 | + /** | ||
41 | + * @inheritdoc | ||
42 | + */ | ||
43 | + public function scenarios() | ||
44 | + { | ||
45 | + // bypass scenarios() implementation in the parent class | ||
46 | + return Model::scenarios(); | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Creates data provider instance with search query applied | ||
51 | + * | ||
52 | + * @param array $params | ||
53 | + * | ||
54 | + * @return ActiveDataProvider | ||
55 | + */ | ||
56 | + public function search($params) | ||
57 | + { | ||
58 | + $query = Category::find(); | ||
59 | + | ||
60 | + // add conditions that should always apply here | ||
61 | + | ||
62 | + $dataProvider = new ActiveDataProvider([ | ||
63 | + 'query' => $query, | ||
64 | + ]); | ||
65 | + | ||
66 | + $this->load($params); | ||
67 | + | ||
68 | + /*if (!$this->validate()) { | ||
69 | + // uncomment the following line if you do not want to return any records when validation fails | ||
70 | + // $query->where('0=1'); | ||
71 | + return $dataProvider; | ||
72 | + }*/ | ||
73 | + | ||
74 | + // grid filtering conditions | ||
75 | + $query->andFilterWhere([ | ||
76 | + 'category_id' => $this->category_id, | ||
77 | + 'parent_id' => $this->parent_id, | ||
78 | + 'category_name_id' => $this->category_name_id, | ||
79 | + 'product_unit_id' => $this->product_unit_id, | ||
80 | + ]); | ||
81 | + | ||
82 | + $query->andFilterWhere(['like', 'alias', $this->alias]); | ||
83 | + | ||
84 | + $query->orderBy(['path' => SORT_ASC, 'depth' => SORT_ASC]); | ||
85 | + | ||
86 | + return $dataProvider; | ||
87 | + } | ||
88 | + | ||
89 | + public static function findByAlias($alias) { | ||
90 | + /** @var CategoryQuery $query */ | ||
91 | + $query = Category::find(); | ||
92 | + $query->byAlias($alias); | ||
93 | + if (($model = $query->one()) !== null) { | ||
94 | + return $model; | ||
95 | + } else { | ||
96 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
97 | + } | ||
98 | + } | ||
99 | +} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "product_unit". | ||
9 | + * | ||
10 | + * @property integer $product_unit_id | ||
11 | + * @property string $name | ||
12 | + * @property string $code | ||
13 | + * @property boolean $is_default | ||
14 | + * | ||
15 | + * @property Category[] $categories | ||
16 | + * @property ProductVariant[] $productVariants | ||
17 | + */ | ||
18 | +class ProductUnit extends \yii\db\ActiveRecord | ||
19 | +{ | ||
20 | + /** | ||
21 | + * @inheritdoc | ||
22 | + */ | ||
23 | + public static function tableName() | ||
24 | + { | ||
25 | + return 'product_unit'; | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * @inheritdoc | ||
30 | + */ | ||
31 | + public function rules() | ||
32 | + { | ||
33 | + return [ | ||
34 | + [['name', 'code'], 'required'], | ||
35 | + [['is_default'], 'boolean'], | ||
36 | + [['name'], 'string', 'max' => 255], | ||
37 | + [['code'], 'string', 'max' => 50], | ||
38 | + ]; | ||
39 | + } | ||
40 | + | ||
41 | + /** | ||
42 | + * @inheritdoc | ||
43 | + */ | ||
44 | + public function attributeLabels() | ||
45 | + { | ||
46 | + return [ | ||
47 | + 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | ||
48 | + 'name' => Yii::t('product', 'Name'), | ||
49 | + 'code' => Yii::t('product', 'Code'), | ||
50 | + 'is_default' => Yii::t('product', 'Is Default'), | ||
51 | + ]; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * @return \yii\db\ActiveQuery | ||
56 | + */ | ||
57 | + public function getCategories() | ||
58 | + { | ||
59 | + return $this->hasMany(Category::className(), ['product_unit_id' => 'product_unit_id']); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * @return \yii\db\ActiveQuery | ||
64 | + */ | ||
65 | + public function getProductVariants() | ||
66 | + { | ||
67 | + return $this->hasMany(ProductVariant::className(), ['product_unit_id' => 'product_unit_id']); | ||
68 | + } | ||
69 | +} |
common/modules/product/widgets/catalogSubmenuWidget.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\product\widgets; | ||
4 | + | ||
5 | +use common\modules\product\models\Category; | ||
6 | +use yii\base\Widget; | ||
7 | + | ||
8 | +class catalogSubmenuWidget extends Widget { | ||
9 | + public $root_id; | ||
10 | + public $rootClass = ''; | ||
11 | + | ||
12 | + public function init() | ||
13 | + { | ||
14 | + parent::init(); // TODO: Change the autogenerated stub | ||
15 | + } | ||
16 | + | ||
17 | + public function run() { | ||
18 | + $rootCategory = Category::findOne($this->root_id); | ||
19 | + return $this->render('submenu', [ | ||
20 | + 'rootCategory' => $rootCategory, | ||
21 | + 'rootClass' => $this->rootClass, | ||
22 | + 'populary' => $rootCategory->getAllChildren(2, ['populary' => true])->all(), | ||
23 | + 'items' => $rootCategory->getAllChildrenTree(2) | ||
24 | + ]); | ||
25 | + } | ||
26 | +} | ||
0 | \ No newline at end of file | 27 | \ No newline at end of file |
common/modules/rubrication/models/TaxValueFloat.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace common\modules\rubrication\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | + | ||
7 | +/** | ||
8 | + * This is the model class for table "{{%tax_value_int}}". | ||
9 | + * | ||
10 | + * @property integer $tax_value_id | ||
11 | + * @property integer $tax_option_id | ||
12 | + * @property integer $value | ||
13 | + * | ||
14 | + * @property TaxOption $taxOption | ||
15 | + */ | ||
16 | +class TaxValueFloat extends \yii\db\ActiveRecord | ||
17 | +{ | ||
18 | + /** | ||
19 | + * @inheritdoc | ||
20 | + */ | ||
21 | + public static function tableName() | ||
22 | + { | ||
23 | + return '{{%tax_value_float}}'; | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * @inheritdoc | ||
28 | + */ | ||
29 | + public function rules() | ||
30 | + { | ||
31 | + return [ | ||
32 | + [['tax_option_id'], 'required'], | ||
33 | + [['tax_option_id'], 'integer'], | ||
34 | + [['value'], 'number'], | ||
35 | + [['tax_option_id'], 'exist', 'skipOnError' => true, 'targetClass' => TaxOption::className(), 'targetAttribute' => ['tax_option_id' => 'tax_option_id']], | ||
36 | + ]; | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * @inheritdoc | ||
41 | + */ | ||
42 | + public function attributeLabels() | ||
43 | + { | ||
44 | + return [ | ||
45 | + 'tax_value_id' => Yii::t('app', 'Tax Value ID'), | ||
46 | + 'tax_option_id' => Yii::t('app', 'Tax Option ID'), | ||
47 | + 'value' => Yii::t('app', 'Value'), | ||
48 | + ]; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * @return \yii\db\ActiveQuery | ||
53 | + */ | ||
54 | + public function getTaxOption() | ||
55 | + { | ||
56 | + return $this->hasOne(TaxOption::className(), ['tax_option_id' => 'tax_option_id'])->inverseOf('taxValues'); | ||
57 | + } | ||
58 | +} |
common/modules/rubrication/views/tax-option/value/_fields_float.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace frontend\controllers; | ||
4 | + | ||
5 | +use common\modules\product\models\Category; | ||
6 | +use common\modules\product\models\CategorySearch; | ||
7 | +use common\modules\product\models\Product; | ||
8 | +use yii\web\HttpException; | ||
9 | + | ||
10 | +class CatalogController extends \yii\web\Controller | ||
11 | +{ | ||
12 | + public function actionCategory($alias) | ||
13 | + { | ||
14 | + $category = CategorySearch::findByAlias($alias); | ||
15 | + if ($category->depth < 2) { | ||
16 | + return $this->render( | ||
17 | + 'categories', | ||
18 | + [ | ||
19 | + 'category' => $category | ||
20 | + ] | ||
21 | + ); | ||
22 | + } else { | ||
23 | + | ||
24 | + return $this->render( | ||
25 | + 'products', | ||
26 | + [ | ||
27 | + 'category' => $category, | ||
28 | + ] | ||
29 | + ); | ||
30 | + } | ||
31 | + } | ||
32 | + | ||
33 | + public function actionProduct($alias) | ||
34 | + { | ||
35 | + $product = Product::find()->where('like', ['alias' => $alias]); | ||
36 | + if (empty($product->product_id)) { | ||
37 | +// throw new HttpException(404 ,'Page not found'); | ||
38 | +// return $this->redirect('/', 301); | ||
39 | + } | ||
40 | + return $this->render('product'); | ||
41 | + } | ||
42 | + | ||
43 | + public function actionBrands() | ||
44 | + { | ||
45 | + return 'actionBrands'; | ||
46 | + } | ||
47 | + | ||
48 | + public function actionBrand($alias) | ||
49 | + { | ||
50 | + return 'actionBrand:'. $alias; | ||
51 | + } | ||
52 | + | ||
53 | +} |
1 | +<?php | ||
2 | +/** @var $this \yii\web\View */ | ||
3 | +/** @var $dataProvider \yii\data\ActiveDataProvider */ | ||
4 | + | ||
5 | +$this->title = $category->name; | ||
6 | +foreach($category->getParents()->all() as $parent) { | ||
7 | + $this->params['breadcrumbs'][] = ['label' => $parent->name, 'url' => ['catalog/category', 'alias' => $parent->alias]]; | ||
8 | +} | ||
9 | +$this->params['breadcrumbs'][] = $this->title; | ||
10 | +?> | ||
11 | +<h1 class="category_page_main_title"><?= $this->title ?></h1> | ||
12 | + | ||
13 | +<div class="category_wrap"> | ||
14 | + | ||
15 | + <div class="category_wrap_3_colum"><!-- 3 colons for items ================================== 1rst colum --> | ||
16 | + | ||
17 | + <?php foreach($category->getAllChildrenTree(2) as $category) :?> | ||
18 | + <div class="wrap"> | ||
19 | + <div class="cat_li_cont"> | ||
20 | + <?php if (!empty($category['item']->image)) :?> | ||
21 | + <img src="<?= $category['item']->image?>" alt="<?= $category['item']->name?>"> | ||
22 | + <?php else :?> | ||
23 | + <img src="/images/category/1.png" alt=""> | ||
24 | + <?php endif;?> | ||
25 | + <div class="desc"><?= $category['item']->name?><!-- (133)--></div> | ||
26 | + <?php if(!empty($category['children'])) :?> | ||
27 | + <span class="arrow"></span> | ||
28 | + <?php endif?> | ||
29 | + </div> | ||
30 | + <?php if(!empty($category['children'])) :?> | ||
31 | + <div class="cat_li_sub_ul"> | ||
32 | + <ul> | ||
33 | + <?php foreach($category['children'] as $_category) :?> | ||
34 | + <li><a href="<?= \yii\helpers\Url::to(['catalog/category', 'alias' => $_category['item']->alias])?>"><?= $_category['item']->name?><!-- (18)--></a></li> | ||
35 | + <?php endforeach?> | ||
36 | + </ul> | ||
37 | + </div> | ||
38 | + <?php endif?> | ||
39 | + </div> | ||
40 | + <!-- $this->params['breadcrumbs'][] = ['label' => $parent->name, 'url' => ['catalog/category', 'alias' => $parent->alias]];--> | ||
41 | + <?php endforeach?> | ||
42 | + | ||
43 | + </div><!-- end of 3 colons for items --> | ||
44 | + | ||
45 | +</div> | ||
0 | \ No newline at end of file | 46 | \ No newline at end of file |