Commit 72a992f5e8b37ee1836d3507f3fa1691881988e7
1 parent
18d6bf69
Import browser v1.0
Showing
50 changed files
with
942 additions
and
1020 deletions
Show diff stats
backend/controllers/BannerController.php
| @@ -82,26 +82,21 @@ | @@ -82,26 +82,21 @@ | ||
| 82 | public function actionCreate() | 82 | public function actionCreate() |
| 83 | { | 83 | { |
| 84 | $model = new Banner(); | 84 | $model = new Banner(); |
| 85 | - $model_langs = $model->generateLangs(); | 85 | + $model->generateLangs(); |
| 86 | 86 | ||
| 87 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 88 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 89 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 87 | + if($model->load(Yii::$app->request->post())) { |
| 88 | + $model->loadLangs(\Yii::$app->request); | ||
| 89 | + if($model->save() && $model->transactionStatus) { | ||
| 90 | return $this->redirect([ | 90 | return $this->redirect([ |
| 91 | 'view', | 91 | 'view', |
| 92 | 'id' => $model->banner_id, | 92 | 'id' => $model->banner_id, |
| 93 | ]); | 93 | ]); |
| 94 | - } else { | ||
| 95 | - return $this->redirect('update', [ | ||
| 96 | - 'id' => $model->banner_id, | ||
| 97 | - ]); | ||
| 98 | } | 94 | } |
| 99 | - } else { | ||
| 100 | - return $this->render('create', [ | ||
| 101 | - 'model' => $model, | ||
| 102 | - 'model_langs' => $model_langs, | ||
| 103 | - ]); | ||
| 104 | } | 95 | } |
| 96 | + return $this->render('create', [ | ||
| 97 | + 'model' => $model, | ||
| 98 | + 'model_langs' => $model->model_langs, | ||
| 99 | + ]); | ||
| 105 | } | 100 | } |
| 106 | 101 | ||
| 107 | /** | 102 | /** |
| @@ -115,11 +110,10 @@ | @@ -115,11 +110,10 @@ | ||
| 115 | public function actionUpdate($id) | 110 | public function actionUpdate($id) |
| 116 | { | 111 | { |
| 117 | $model = $this->findModel($id); | 112 | $model = $this->findModel($id); |
| 118 | - $model_langs = $model->generateLangs(); | ||
| 119 | - | ||
| 120 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 121 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 122 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 113 | + $model->generateLangs(); |
| 114 | + if($model->load(Yii::$app->request->post())) { | ||
| 115 | + $model->loadLangs(\Yii::$app->request); | ||
| 116 | + if($model->save() && $model->transactionStatus) { | ||
| 123 | return $this->redirect([ | 117 | return $this->redirect([ |
| 124 | 'view', | 118 | 'view', |
| 125 | 'id' => $model->banner_id, | 119 | 'id' => $model->banner_id, |
| @@ -128,7 +122,7 @@ | @@ -128,7 +122,7 @@ | ||
| 128 | } | 122 | } |
| 129 | return $this->render('update', [ | 123 | return $this->render('update', [ |
| 130 | 'model' => $model, | 124 | 'model' => $model, |
| 131 | - 'model_langs' => $model_langs, | 125 | + 'model_langs' => $model->model_langs, |
| 132 | ]); | 126 | ]); |
| 133 | } | 127 | } |
| 134 | 128 |
backend/controllers/BgController.php
| @@ -82,27 +82,21 @@ | @@ -82,27 +82,21 @@ | ||
| 82 | public function actionCreate() | 82 | public function actionCreate() |
| 83 | { | 83 | { |
| 84 | $model = new Bg(); | 84 | $model = new Bg(); |
| 85 | - $model_langs = $model->generateLangs(); | 85 | + $model->generateLangs(); |
| 86 | 86 | ||
| 87 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 88 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 89 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 87 | + if($model->load(Yii::$app->request->post())) { |
| 88 | + $model->loadLangs(\Yii::$app->request); | ||
| 89 | + if($model->save() && $model->transactionStatus) { | ||
| 90 | return $this->redirect([ | 90 | return $this->redirect([ |
| 91 | 'view', | 91 | 'view', |
| 92 | 'id' => $model->id, | 92 | 'id' => $model->id, |
| 93 | ]); | 93 | ]); |
| 94 | - } else { | ||
| 95 | - return $this->redirect([ | ||
| 96 | - 'update', | ||
| 97 | - 'id' => $model->id, | ||
| 98 | - ]); | ||
| 99 | } | 94 | } |
| 100 | - } else { | ||
| 101 | - return $this->render('create', [ | ||
| 102 | - 'model' => $model, | ||
| 103 | - 'model_langs' => $model_langs, | ||
| 104 | - ]); | ||
| 105 | } | 95 | } |
| 96 | + return $this->render('create', [ | ||
| 97 | + 'model' => $model, | ||
| 98 | + 'model_langs' => $model->model_langs, | ||
| 99 | + ]); | ||
| 106 | } | 100 | } |
| 107 | 101 | ||
| 108 | /** | 102 | /** |
| @@ -116,11 +110,11 @@ | @@ -116,11 +110,11 @@ | ||
| 116 | public function actionUpdate($id) | 110 | public function actionUpdate($id) |
| 117 | { | 111 | { |
| 118 | $model = $this->findModel($id); | 112 | $model = $this->findModel($id); |
| 119 | - $model_langs = $model->generateLangs(); | 113 | + $model->generateLangs(); |
| 120 | 114 | ||
| 121 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 122 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 123 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 115 | + if($model->load(Yii::$app->request->post())) { |
| 116 | + $model->loadLangs(\Yii::$app->request); | ||
| 117 | + if($model->save() && $model->transactionStatus) { | ||
| 124 | return $this->redirect([ | 118 | return $this->redirect([ |
| 125 | 'view', | 119 | 'view', |
| 126 | 'id' => $model->id, | 120 | 'id' => $model->id, |
| @@ -129,7 +123,7 @@ | @@ -129,7 +123,7 @@ | ||
| 129 | } | 123 | } |
| 130 | return $this->render('update', [ | 124 | return $this->render('update', [ |
| 131 | 'model' => $model, | 125 | 'model' => $model, |
| 132 | - 'model_langs' => $model_langs, | 126 | + 'model_langs' => $model->model_langs, |
| 133 | ]); | 127 | ]); |
| 134 | } | 128 | } |
| 135 | 129 |
backend/controllers/BrandController.php
| @@ -92,25 +92,19 @@ | @@ -92,25 +92,19 @@ | ||
| 92 | public function actionCreate() | 92 | public function actionCreate() |
| 93 | { | 93 | { |
| 94 | $model = new Brand(); | 94 | $model = new Brand(); |
| 95 | - $model_langs = $model->generateLangs(); | 95 | + $model->generateLangs(); |
| 96 | if($model->load(Yii::$app->request->post())) { | 96 | if($model->load(Yii::$app->request->post())) { |
| 97 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 98 | - if($model->save()) { | ||
| 99 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 100 | - return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ | ||
| 101 | - 'view', | ||
| 102 | - 'id' => $model->brand_id, | ||
| 103 | - ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); | ||
| 104 | - } | ||
| 105 | - } else { | ||
| 106 | - return $this->redirect('update', [ | 97 | + $model->loadLangs(\Yii::$app->request); |
| 98 | + if($model->save() && $model->transactionStatus) { | ||
| 99 | + return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ | ||
| 100 | + 'view', | ||
| 107 | 'id' => $model->brand_id, | 101 | 'id' => $model->brand_id, |
| 108 | - ]); | 102 | + ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); |
| 109 | } | 103 | } |
| 110 | } | 104 | } |
| 111 | return $this->render('create', [ | 105 | return $this->render('create', [ |
| 112 | 'model' => $model, | 106 | 'model' => $model, |
| 113 | - 'model_langs' => $model_langs, | 107 | + 'model_langs' => $model->model_langs, |
| 114 | ]); | 108 | ]); |
| 115 | } | 109 | } |
| 116 | 110 | ||
| @@ -125,22 +119,20 @@ | @@ -125,22 +119,20 @@ | ||
| 125 | public function actionUpdate($id) | 119 | public function actionUpdate($id) |
| 126 | { | 120 | { |
| 127 | $model = $this->findModel($id); | 121 | $model = $this->findModel($id); |
| 128 | - $model_langs = $model->generateLangs(); | 122 | + $model->generateLangs(); |
| 129 | 123 | ||
| 130 | if($model->load(Yii::$app->request->post())) { | 124 | if($model->load(Yii::$app->request->post())) { |
| 131 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 132 | - if($model->save()) { | ||
| 133 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 134 | - return $this->redirect([ | ||
| 135 | - 'view', | ||
| 136 | - 'id' => $model->brand_id, | ||
| 137 | - ]); | ||
| 138 | - } | 125 | + $model->loadLangs(\Yii::$app->request); |
| 126 | + if($model->save() && $model->transactionStatus) { | ||
| 127 | + return $this->redirect([ | ||
| 128 | + 'view', | ||
| 129 | + 'id' => $model->brand_id, | ||
| 130 | + ]); | ||
| 139 | } | 131 | } |
| 140 | } | 132 | } |
| 141 | return $this->render('update', [ | 133 | return $this->render('update', [ |
| 142 | 'model' => $model, | 134 | 'model' => $model, |
| 143 | - 'model_langs' => $model_langs, | 135 | + 'model_langs' => $model->model_langs, |
| 144 | ]); | 136 | ]); |
| 145 | } | 137 | } |
| 146 | 138 |
backend/controllers/CategoryController.php
| @@ -10,7 +10,6 @@ | @@ -10,7 +10,6 @@ | ||
| 10 | use yii\web\Controller; | 10 | use yii\web\Controller; |
| 11 | use yii\web\NotFoundHttpException; | 11 | use yii\web\NotFoundHttpException; |
| 12 | use yii\filters\VerbFilter; | 12 | use yii\filters\VerbFilter; |
| 13 | - use yii\web\UploadedFile; | ||
| 14 | 13 | ||
| 15 | /** | 14 | /** |
| 16 | * CategoryController implements the CRUD actions for Category model. | 15 | * CategoryController implements the CRUD actions for Category model. |
| @@ -84,32 +83,22 @@ | @@ -84,32 +83,22 @@ | ||
| 84 | public function actionCreate() | 83 | public function actionCreate() |
| 85 | { | 84 | { |
| 86 | $model = new Category(); | 85 | $model = new Category(); |
| 87 | - $model_langs = $model->generateLangs(); | ||
| 88 | - | 86 | + $model->generateLangs(); |
| 89 | if($model->load(Yii::$app->request->post())) { | 87 | if($model->load(Yii::$app->request->post())) { |
| 90 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 91 | - | ||
| 92 | - if($model->save()) { | ||
| 93 | - | ||
| 94 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 95 | - return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ | ||
| 96 | - 'view', | ||
| 97 | - 'id' => $model->category_id, | ||
| 98 | - ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); | ||
| 99 | - } else { | ||
| 100 | - return $this->redirect('update', [ | ||
| 101 | - 'id' => $model->category_id, | ||
| 102 | - ]); | ||
| 103 | - } | 88 | + $model->loadLangs(\Yii::$app->request); |
| 89 | + if($model->save() && $model->transactionStatus) { | ||
| 90 | + return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ | ||
| 91 | + 'view', | ||
| 92 | + 'id' => $model->category_id, | ||
| 93 | + ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); | ||
| 104 | } | 94 | } |
| 105 | - | ||
| 106 | } | 95 | } |
| 107 | if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) { | 96 | if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) { |
| 108 | $model->parent_id = Yii::$app->request->queryParams[ 'parent' ]; | 97 | $model->parent_id = Yii::$app->request->queryParams[ 'parent' ]; |
| 109 | } | 98 | } |
| 110 | return $this->render('create', [ | 99 | return $this->render('create', [ |
| 111 | 'model' => $model, | 100 | 'model' => $model, |
| 112 | - 'model_langs' => $model_langs, | 101 | + 'model_langs' => $model->model_langs, |
| 113 | 'categories' => ArtboxTreeHelper::treeMap(Category::find() | 102 | 'categories' => ArtboxTreeHelper::treeMap(Category::find() |
| 114 | ->getTree(), 'category_id', 'category_id', '.'), | 103 | ->getTree(), 'category_id', 'category_id', '.'), |
| 115 | ]); | 104 | ]); |
| @@ -126,23 +115,19 @@ | @@ -126,23 +115,19 @@ | ||
| 126 | public function actionUpdate($id) | 115 | public function actionUpdate($id) |
| 127 | { | 116 | { |
| 128 | $model = $this->findModel($id); | 117 | $model = $this->findModel($id); |
| 129 | - | ||
| 130 | - $model_langs = $model->generateLangs(); | ||
| 131 | - | 118 | + $model->generateLangs(); |
| 132 | if($model->load(Yii::$app->request->post())) { | 119 | if($model->load(Yii::$app->request->post())) { |
| 133 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 134 | - if($model->save()) { | ||
| 135 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 136 | - return $this->redirect([ | ||
| 137 | - 'view', | ||
| 138 | - 'id' => $model->category_id, | ||
| 139 | - ]); | ||
| 140 | - } | 120 | + $model->loadLangs(\Yii::$app->request); |
| 121 | + if($model->save() && $model->transactionStatus) { | ||
| 122 | + return $this->redirect([ | ||
| 123 | + 'view', | ||
| 124 | + 'id' => $model->category_id, | ||
| 125 | + ]); | ||
| 141 | } | 126 | } |
| 142 | } | 127 | } |
| 143 | return $this->render('update', [ | 128 | return $this->render('update', [ |
| 144 | 'model' => $model, | 129 | 'model' => $model, |
| 145 | - 'model_langs' => $model_langs, | 130 | + 'model_langs' => $model->model_langs, |
| 146 | 'categories' => ArtboxTreeHelper::treeMap(Category::find() | 131 | 'categories' => ArtboxTreeHelper::treeMap(Category::find() |
| 147 | ->getTree(), 'category_id', 'category_id', '.'), | 132 | ->getTree(), 'category_id', 'category_id', '.'), |
| 148 | ]); | 133 | ]); |
backend/controllers/EventController.php
| @@ -82,29 +82,22 @@ | @@ -82,29 +82,22 @@ | ||
| 82 | public function actionCreate() | 82 | public function actionCreate() |
| 83 | { | 83 | { |
| 84 | $model = new Event(); | 84 | $model = new Event(); |
| 85 | - $model_langs = $model->generateLangs(); | 85 | + $model->generateLangs(); |
| 86 | 86 | ||
| 87 | if($model->load(Yii::$app->request->post())) { | 87 | if($model->load(Yii::$app->request->post())) { |
| 88 | 88 | ||
| 89 | - $model->loadLangs(\Yii::$app->request, $model_langs); | 89 | + $model->loadLangs(\Yii::$app->request); |
| 90 | 90 | ||
| 91 | - if($model->save()) { | ||
| 92 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 93 | - return $this->redirect([ | ||
| 94 | - 'view', | ||
| 95 | - 'id' => $model->event_id, | ||
| 96 | - ]); | ||
| 97 | - } else { | ||
| 98 | - return $this->redirect([ | ||
| 99 | - 'update', | ||
| 100 | - 'id' => $model->event_id, | ||
| 101 | - ]); | ||
| 102 | - } | 91 | + if($model->save() && $model->transactionStatus) { |
| 92 | + return $this->redirect([ | ||
| 93 | + 'view', | ||
| 94 | + 'id' => $model->event_id, | ||
| 95 | + ]); | ||
| 103 | } | 96 | } |
| 104 | } | 97 | } |
| 105 | return $this->render('create', [ | 98 | return $this->render('create', [ |
| 106 | 'model' => $model, | 99 | 'model' => $model, |
| 107 | - 'model_langs' => $model_langs, | 100 | + 'model_langs' => $model->model_langs, |
| 108 | ]); | 101 | ]); |
| 109 | } | 102 | } |
| 110 | 103 | ||
| @@ -119,24 +112,22 @@ | @@ -119,24 +112,22 @@ | ||
| 119 | public function actionUpdate($id) | 112 | public function actionUpdate($id) |
| 120 | { | 113 | { |
| 121 | $model = $this->findModel($id); | 114 | $model = $this->findModel($id); |
| 122 | - $model_langs = $model->generateLangs(); | 115 | + $model->generateLangs(); |
| 123 | 116 | ||
| 124 | if($model->load(Yii::$app->request->post())) { | 117 | if($model->load(Yii::$app->request->post())) { |
| 125 | 118 | ||
| 126 | - $model->loadLangs(\Yii::$app->request, $model_langs); | 119 | + $model->loadLangs(\Yii::$app->request); |
| 127 | 120 | ||
| 128 | - if($model->save()) { | ||
| 129 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 130 | - return $this->redirect([ | ||
| 131 | - 'view', | ||
| 132 | - 'id' => $model->event_id, | ||
| 133 | - ]); | ||
| 134 | - } | 121 | + if($model->save() && $model->transactionStatus) { |
| 122 | + return $this->redirect([ | ||
| 123 | + 'view', | ||
| 124 | + 'id' => $model->event_id, | ||
| 125 | + ]); | ||
| 135 | } | 126 | } |
| 136 | } | 127 | } |
| 137 | return $this->render('update', [ | 128 | return $this->render('update', [ |
| 138 | 'model' => $model, | 129 | 'model' => $model, |
| 139 | - 'model_langs' => $model_langs, | 130 | + 'model_langs' => $model->model_langs, |
| 140 | ]); | 131 | ]); |
| 141 | } | 132 | } |
| 142 | 133 |
backend/controllers/PageController.php
| @@ -82,26 +82,20 @@ | @@ -82,26 +82,20 @@ | ||
| 82 | public function actionCreate() | 82 | public function actionCreate() |
| 83 | { | 83 | { |
| 84 | $model = new Page(); | 84 | $model = new Page(); |
| 85 | - $model_langs = $model->generateLangs(); | ||
| 86 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 87 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 88 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 85 | + $model->generateLangs(); |
| 86 | + if($model->load(Yii::$app->request->post())) { | ||
| 87 | + $model->loadLangs(\Yii::$app->request); | ||
| 88 | + if($model->save() && $model->transactionStatus) { | ||
| 89 | return $this->redirect([ | 89 | return $this->redirect([ |
| 90 | 'view', | 90 | 'view', |
| 91 | 'id' => $model->id, | 91 | 'id' => $model->id, |
| 92 | ]); | 92 | ]); |
| 93 | - } else { | ||
| 94 | - return $this->redirect([ | ||
| 95 | - 'update', | ||
| 96 | - 'id' => $model->id, | ||
| 97 | - ]); | ||
| 98 | } | 93 | } |
| 99 | - } else { | ||
| 100 | - return $this->render('create', [ | ||
| 101 | - 'model' => $model, | ||
| 102 | - 'model_langs' => $model_langs, | ||
| 103 | - ]); | ||
| 104 | } | 94 | } |
| 95 | + return $this->render('create', [ | ||
| 96 | + 'model' => $model, | ||
| 97 | + 'model_langs' => $model->model_langs, | ||
| 98 | + ]); | ||
| 105 | } | 99 | } |
| 106 | 100 | ||
| 107 | /** | 101 | /** |
| @@ -115,11 +109,11 @@ | @@ -115,11 +109,11 @@ | ||
| 115 | public function actionUpdate($id) | 109 | public function actionUpdate($id) |
| 116 | { | 110 | { |
| 117 | $model = $this->findModel($id); | 111 | $model = $this->findModel($id); |
| 118 | - $model_langs = $model->generateLangs(); | 112 | + $model->generateLangs(); |
| 119 | 113 | ||
| 120 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 121 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 122 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 114 | + if($model->load(Yii::$app->request->post())) { |
| 115 | + $model->loadLangs(\Yii::$app->request); | ||
| 116 | + if($model->save() && $model->transactionStatus) { | ||
| 123 | return $this->redirect([ | 117 | return $this->redirect([ |
| 124 | 'view', | 118 | 'view', |
| 125 | 'id' => $model->id, | 119 | 'id' => $model->id, |
| @@ -128,7 +122,7 @@ | @@ -128,7 +122,7 @@ | ||
| 128 | } | 122 | } |
| 129 | return $this->render('update', [ | 123 | return $this->render('update', [ |
| 130 | 'model' => $model, | 124 | 'model' => $model, |
| 131 | - 'model_langs' => $model_langs, | 125 | + 'model_langs' => $model->model_langs, |
| 132 | ]); | 126 | ]); |
| 133 | } | 127 | } |
| 134 | 128 |
backend/controllers/ProjectController.php
| @@ -89,11 +89,11 @@ | @@ -89,11 +89,11 @@ | ||
| 89 | public function actionCreate() | 89 | public function actionCreate() |
| 90 | { | 90 | { |
| 91 | $model = new Project(); | 91 | $model = new Project(); |
| 92 | - $model_langs = $model->generateLangs(); | 92 | + $model->generateLangs(); |
| 93 | if($model->load(Yii::$app->request->post())) { | 93 | if($model->load(Yii::$app->request->post())) { |
| 94 | - $model->loadLangs(\Yii::$app->request, $model_langs); | 94 | + $model->loadLangs(\Yii::$app->request); |
| 95 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | 95 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
| 96 | - if($model->save()) { | 96 | + if($model->save() && $model->transactionStatus) { |
| 97 | if($model->imagesUpload && ( ( $images = $model->imagesUpload() ) !== false )) { | 97 | if($model->imagesUpload && ( ( $images = $model->imagesUpload() ) !== false )) { |
| 98 | foreach($images as $image) { | 98 | foreach($images as $image) { |
| 99 | $imageModel = new ProjectImage(); | 99 | $imageModel = new ProjectImage(); |
| @@ -102,22 +102,15 @@ | @@ -102,22 +102,15 @@ | ||
| 102 | $imageModel->save(); | 102 | $imageModel->save(); |
| 103 | } | 103 | } |
| 104 | } | 104 | } |
| 105 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 106 | - return $this->redirect([ | ||
| 107 | - 'view', | ||
| 108 | - 'id' => $model->project_id, | ||
| 109 | - ]); | ||
| 110 | - } else { | ||
| 111 | - return $this->redirect([ | ||
| 112 | - 'update', | ||
| 113 | - 'id' => $model->project_id, | ||
| 114 | - ]); | ||
| 115 | - } | 105 | + return $this->redirect([ |
| 106 | + 'view', | ||
| 107 | + 'id' => $model->project_id, | ||
| 108 | + ]); | ||
| 116 | } | 109 | } |
| 117 | } | 110 | } |
| 118 | return $this->render('create', [ | 111 | return $this->render('create', [ |
| 119 | 'model' => $model, | 112 | 'model' => $model, |
| 120 | - 'model_langs' => $model_langs, | 113 | + 'model_langs' => $model->model_langs, |
| 121 | ]); | 114 | ]); |
| 122 | } | 115 | } |
| 123 | 116 | ||
| @@ -132,11 +125,11 @@ | @@ -132,11 +125,11 @@ | ||
| 132 | public function actionUpdate($id) | 125 | public function actionUpdate($id) |
| 133 | { | 126 | { |
| 134 | $model = $this->findModel($id); | 127 | $model = $this->findModel($id); |
| 135 | - $model_langs = $model->generateLangs(); | 128 | + $model->generateLangs(); |
| 136 | if($model->load(Yii::$app->request->post())) { | 129 | if($model->load(Yii::$app->request->post())) { |
| 137 | - $model->loadLangs(\Yii::$app->request, $model_langs); | 130 | + $model->loadLangs(\Yii::$app->request); |
| 138 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | 131 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
| 139 | - if($model->save()) { | 132 | + if($model->save() && $model->transactionStatus) { |
| 140 | if($model->imagesUpload && ( ( $images = $model->imagesUpload() ) !== false )) { | 133 | if($model->imagesUpload && ( ( $images = $model->imagesUpload() ) !== false )) { |
| 141 | foreach($images as $image) { | 134 | foreach($images as $image) { |
| 142 | $imageModel = new ProjectImage(); | 135 | $imageModel = new ProjectImage(); |
| @@ -145,17 +138,15 @@ | @@ -145,17 +138,15 @@ | ||
| 145 | $imageModel->save(); | 138 | $imageModel->save(); |
| 146 | } | 139 | } |
| 147 | } | 140 | } |
| 148 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 149 | - return $this->redirect([ | ||
| 150 | - 'view', | ||
| 151 | - 'id' => $model->project_id, | ||
| 152 | - ]); | ||
| 153 | - } | 141 | + return $this->redirect([ |
| 142 | + 'view', | ||
| 143 | + 'id' => $model->project_id, | ||
| 144 | + ]); | ||
| 154 | } | 145 | } |
| 155 | } | 146 | } |
| 156 | return $this->render('update', [ | 147 | return $this->render('update', [ |
| 157 | 'model' => $model, | 148 | 'model' => $model, |
| 158 | - 'model_langs' => $model_langs, | 149 | + 'model_langs' => $model->model_langs, |
| 159 | ]); | 150 | ]); |
| 160 | } | 151 | } |
| 161 | 152 |
backend/controllers/SeoCategoryController.php
| @@ -80,27 +80,21 @@ | @@ -80,27 +80,21 @@ | ||
| 80 | public function actionCreate() | 80 | public function actionCreate() |
| 81 | { | 81 | { |
| 82 | $model = new SeoCategory(); | 82 | $model = new SeoCategory(); |
| 83 | - $model_langs = $model->generateLangs(); | 83 | + $model->generateLangs(); |
| 84 | 84 | ||
| 85 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 86 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 87 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 85 | + if($model->load(Yii::$app->request->post())) { |
| 86 | + $model->loadLangs(\Yii::$app->request); | ||
| 87 | + if($model->save() && $model->transactionStatus) { | ||
| 88 | return $this->redirect([ | 88 | return $this->redirect([ |
| 89 | 'view', | 89 | 'view', |
| 90 | 'id' => $model->seo_category_id, | 90 | 'id' => $model->seo_category_id, |
| 91 | ]); | 91 | ]); |
| 92 | - } else { | ||
| 93 | - return $this->redirect([ | ||
| 94 | - 'update', | ||
| 95 | - 'id' => $model->seo_category_id, | ||
| 96 | - ]); | ||
| 97 | } | 92 | } |
| 98 | - } else { | ||
| 99 | - return $this->render('create', [ | ||
| 100 | - 'model' => $model, | ||
| 101 | - 'model_langs' => $model_langs, | ||
| 102 | - ]); | ||
| 103 | } | 93 | } |
| 94 | + return $this->render('create', [ | ||
| 95 | + 'model' => $model, | ||
| 96 | + 'model_langs' => $model->model_langs, | ||
| 97 | + ]); | ||
| 104 | } | 98 | } |
| 105 | 99 | ||
| 106 | /** | 100 | /** |
| @@ -114,10 +108,10 @@ | @@ -114,10 +108,10 @@ | ||
| 114 | public function actionUpdate($id) | 108 | public function actionUpdate($id) |
| 115 | { | 109 | { |
| 116 | $model = $this->findModel($id); | 110 | $model = $this->findModel($id); |
| 117 | - $model_langs = $model->generateLangs(); | ||
| 118 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 119 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 120 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 111 | + $model->generateLangs(); |
| 112 | + if($model->load(Yii::$app->request->post())) { | ||
| 113 | + $model->loadLangs(\Yii::$app->request); | ||
| 114 | + if($model->save() && $model->transactionStatus) { | ||
| 121 | return $this->redirect([ | 115 | return $this->redirect([ |
| 122 | 'view', | 116 | 'view', |
| 123 | 'id' => $model->seo_category_id, | 117 | 'id' => $model->seo_category_id, |
| @@ -126,7 +120,7 @@ | @@ -126,7 +120,7 @@ | ||
| 126 | } | 120 | } |
| 127 | return $this->render('update', [ | 121 | return $this->render('update', [ |
| 128 | 'model' => $model, | 122 | 'model' => $model, |
| 129 | - 'model_langs' => $model_langs, | 123 | + 'model_langs' => $model->model_langs, |
| 130 | ]); | 124 | ]); |
| 131 | } | 125 | } |
| 132 | 126 |
backend/controllers/SeoController.php
| @@ -80,27 +80,21 @@ | @@ -80,27 +80,21 @@ | ||
| 80 | public function actionCreate() | 80 | public function actionCreate() |
| 81 | { | 81 | { |
| 82 | $model = new Seo(); | 82 | $model = new Seo(); |
| 83 | - $model_langs = $model->generateLangs(); | 83 | + $model->generateLangs(); |
| 84 | 84 | ||
| 85 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 86 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 87 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 85 | + if($model->load(Yii::$app->request->post())) { |
| 86 | + $model->loadLangs(\Yii::$app->request); | ||
| 87 | + if($model->save() && $model->transactionStatus) { | ||
| 88 | return $this->redirect([ | 88 | return $this->redirect([ |
| 89 | 'view', | 89 | 'view', |
| 90 | 'id' => $model->seo_id, | 90 | 'id' => $model->seo_id, |
| 91 | ]); | 91 | ]); |
| 92 | - } else { | ||
| 93 | - return $this->redirect([ | ||
| 94 | - 'update', | ||
| 95 | - 'id' => $model->seo_id, | ||
| 96 | - ]); | ||
| 97 | } | 92 | } |
| 98 | - } else { | ||
| 99 | - return $this->render('create', [ | ||
| 100 | - 'model' => $model, | ||
| 101 | - 'model_langs' => $model_langs, | ||
| 102 | - ]); | ||
| 103 | } | 93 | } |
| 94 | + return $this->render('create', [ | ||
| 95 | + 'model' => $model, | ||
| 96 | + 'model_langs' => $model->model_langs, | ||
| 97 | + ]); | ||
| 104 | } | 98 | } |
| 105 | 99 | ||
| 106 | /** | 100 | /** |
| @@ -114,10 +108,10 @@ | @@ -114,10 +108,10 @@ | ||
| 114 | public function actionUpdate($id) | 108 | public function actionUpdate($id) |
| 115 | { | 109 | { |
| 116 | $model = $this->findModel($id); | 110 | $model = $this->findModel($id); |
| 117 | - $model_langs = $model->generateLangs(); | ||
| 118 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 119 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 120 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 111 | + $model->generateLangs(); |
| 112 | + if($model->load(Yii::$app->request->post())) { | ||
| 113 | + $model->loadLangs(\Yii::$app->request); | ||
| 114 | + if($model->save() && $model->transactionStatus) { | ||
| 121 | return $this->redirect([ | 115 | return $this->redirect([ |
| 122 | 'view', | 116 | 'view', |
| 123 | 'id' => $model->seo_id, | 117 | 'id' => $model->seo_id, |
| @@ -126,7 +120,7 @@ | @@ -126,7 +120,7 @@ | ||
| 126 | } | 120 | } |
| 127 | return $this->render('update', [ | 121 | return $this->render('update', [ |
| 128 | 'model' => $model, | 122 | 'model' => $model, |
| 129 | - 'model_langs' => $model_langs, | 123 | + 'model_langs' => $model->model_langs, |
| 130 | ]); | 124 | ]); |
| 131 | } | 125 | } |
| 132 | 126 |
backend/controllers/SeoDynamicController.php
| @@ -82,31 +82,22 @@ | @@ -82,31 +82,22 @@ | ||
| 82 | public function actionCreate($seo_category_id) | 82 | public function actionCreate($seo_category_id) |
| 83 | { | 83 | { |
| 84 | $model = new SeoDynamic(); | 84 | $model = new SeoDynamic(); |
| 85 | - $model_langs = $model->generateLangs(); | ||
| 86 | - | 85 | + $model->generateLangs(); |
| 87 | if($model->load(Yii::$app->request->post())) { | 86 | if($model->load(Yii::$app->request->post())) { |
| 88 | - $model->loadLangs(\Yii::$app->request, $model_langs); | 87 | + $model->loadLangs(\Yii::$app->request); |
| 89 | $model->seo_category_id = $seo_category_id; | 88 | $model->seo_category_id = $seo_category_id; |
| 90 | - $model->save(); | ||
| 91 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 89 | + if($model->save() && $model->transactionStatus) { |
| 92 | return $this->redirect([ | 90 | return $this->redirect([ |
| 93 | 'index', | 91 | 'index', |
| 94 | 'seo_category_id' => $model->seo_category_id, | 92 | 'seo_category_id' => $model->seo_category_id, |
| 95 | ]); | 93 | ]); |
| 96 | - } else { | ||
| 97 | - return $this->redirect([ | ||
| 98 | - 'update', | ||
| 99 | - 'seo_category_id' => $model->seo_category_id, | ||
| 100 | - 'id' => $model->seo_dynamic_id, | ||
| 101 | - ]); | ||
| 102 | } | 94 | } |
| 103 | - } else { | ||
| 104 | - return $this->render('create', [ | ||
| 105 | - 'model' => $model, | ||
| 106 | - 'model_langs' => $model_langs, | ||
| 107 | - 'seo_category_id' => $seo_category_id, | ||
| 108 | - ]); | ||
| 109 | } | 95 | } |
| 96 | + return $this->render('create', [ | ||
| 97 | + 'model' => $model, | ||
| 98 | + 'model_langs' => $model->model_langs, | ||
| 99 | + 'seo_category_id' => $seo_category_id, | ||
| 100 | + ]); | ||
| 110 | } | 101 | } |
| 111 | 102 | ||
| 112 | /** | 103 | /** |
| @@ -121,9 +112,9 @@ | @@ -121,9 +112,9 @@ | ||
| 121 | { | 112 | { |
| 122 | $model = $this->findModel($id); | 113 | $model = $this->findModel($id); |
| 123 | $model_langs = $model->generateLangs(); | 114 | $model_langs = $model->generateLangs(); |
| 124 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 125 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 126 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 115 | + if($model->load(Yii::$app->request->post())) { |
| 116 | + $model->loadLangs(\Yii::$app->request); | ||
| 117 | + if($model->save() && $model->transactionStatus) { | ||
| 127 | return $this->redirect([ | 118 | return $this->redirect([ |
| 128 | 'index', | 119 | 'index', |
| 129 | 'seo_category_id' => $model->seo_category_id, | 120 | 'seo_category_id' => $model->seo_category_id, |
backend/controllers/ServiceController.php
| @@ -82,27 +82,20 @@ | @@ -82,27 +82,20 @@ | ||
| 82 | public function actionCreate() | 82 | public function actionCreate() |
| 83 | { | 83 | { |
| 84 | $model = new Service(); | 84 | $model = new Service(); |
| 85 | - $model_langs = $model->generateLangs(); | ||
| 86 | - | ||
| 87 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 88 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 89 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 85 | + $model->generateLangs(); |
| 86 | + if($model->load(Yii::$app->request->post())) { | ||
| 87 | + $model->loadLangs(\Yii::$app->request); | ||
| 88 | + if($model->save() && $model->transactionStatus) { | ||
| 90 | return $this->redirect([ | 89 | return $this->redirect([ |
| 91 | 'view', | 90 | 'view', |
| 92 | 'id' => $model->service_id, | 91 | 'id' => $model->service_id, |
| 93 | ]); | 92 | ]); |
| 94 | - } else { | ||
| 95 | - return $this->redirect([ | ||
| 96 | - 'update', | ||
| 97 | - 'id' => $model->service_id, | ||
| 98 | - ]); | ||
| 99 | } | 93 | } |
| 100 | - } else { | ||
| 101 | - return $this->render('create', [ | ||
| 102 | - 'model' => $model, | ||
| 103 | - 'model_langs' => $model_langs, | ||
| 104 | - ]); | ||
| 105 | } | 94 | } |
| 95 | + return $this->render('create', [ | ||
| 96 | + 'model' => $model, | ||
| 97 | + 'model_langs' => $model->model_langs, | ||
| 98 | + ]); | ||
| 106 | } | 99 | } |
| 107 | 100 | ||
| 108 | /** | 101 | /** |
| @@ -116,11 +109,11 @@ | @@ -116,11 +109,11 @@ | ||
| 116 | public function actionUpdate($id) | 109 | public function actionUpdate($id) |
| 117 | { | 110 | { |
| 118 | $model = $this->findModel($id); | 111 | $model = $this->findModel($id); |
| 119 | - $model_langs = $model->generateLangs(); | 112 | + $model->generateLangs(); |
| 120 | 113 | ||
| 121 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 122 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 123 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 114 | + if($model->load(Yii::$app->request->post())) { |
| 115 | + $model->loadLangs(\Yii::$app->request); | ||
| 116 | + if($model->save() && $model->transactionStatus) { | ||
| 124 | return $this->redirect([ | 117 | return $this->redirect([ |
| 125 | 'view', | 118 | 'view', |
| 126 | 'id' => $model->service_id, | 119 | 'id' => $model->service_id, |
| @@ -128,8 +121,8 @@ | @@ -128,8 +121,8 @@ | ||
| 128 | } | 121 | } |
| 129 | } | 122 | } |
| 130 | return $this->render('update', [ | 123 | return $this->render('update', [ |
| 131 | - 'model' => $model, | ||
| 132 | - 'model_langs' => $model_langs, | 124 | + 'model' => $model, |
| 125 | + 'model_langs' => $model->model_langs, | ||
| 133 | ]); | 126 | ]); |
| 134 | } | 127 | } |
| 135 | 128 |
backend/models/Label.php
| @@ -16,6 +16,8 @@ use yii\web\Request; | @@ -16,6 +16,8 @@ use yii\web\Request; | ||
| 16 | * @property OrdersLabelLang $object_lang | 16 | * @property OrdersLabelLang $object_lang |
| 17 | * @property string $ownerKey | 17 | * @property string $ownerKey |
| 18 | * @property string $langKey | 18 | * @property string $langKey |
| 19 | + * @property OrdersLabelLang[] $model_langs | ||
| 20 | + * @property bool $transactionStatus | ||
| 19 | * @method string getOwnerKey() | 21 | * @method string getOwnerKey() |
| 20 | * @method void setOwnerKey(string $value) | 22 | * @method void setOwnerKey(string $value) |
| 21 | * @method string getLangKey() | 23 | * @method string getLangKey() |
| @@ -23,12 +25,13 @@ use yii\web\Request; | @@ -23,12 +25,13 @@ use yii\web\Request; | ||
| 23 | * @method ActiveQuery getLangs() | 25 | * @method ActiveQuery getLangs() |
| 24 | * @method ActiveQuery getLang( integer $language_id ) | 26 | * @method ActiveQuery getLang( integer $language_id ) |
| 25 | * @method OrdersLabelLang[] generateLangs() | 27 | * @method OrdersLabelLang[] generateLangs() |
| 26 | - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) | ||
| 27 | - * @method bool linkLangs(ActiveRecord[] $model_langs) | ||
| 28 | - * @method bool saveLangs(ActiveRecord[] $model_langs) | ||
| 29 | - * * End language behavior * | 28 | + * @method void loadLangs(Request $request) |
| 29 | + * @method bool linkLangs() | ||
| 30 | + * @method bool saveLangs() | ||
| 31 | + * @method bool getTransactionStatus() | ||
| 32 | + * * End language behavior | ||
| 30 | */ | 33 | */ |
| 31 | -class Label extends \yii\db\ActiveRecord | 34 | +class Label extends ActiveRecord |
| 32 | { | 35 | { |
| 33 | 36 | ||
| 34 | public static function tableName() | 37 | public static function tableName() |
common/behaviors/Slug.php
| @@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
| 12 | 12 | ||
| 13 | public $in_attribute = 'name'; | 13 | public $in_attribute = 'name'; |
| 14 | 14 | ||
| 15 | - public $out_attribute = 'slug'; | 15 | + public $out_attribute = 'alias'; |
| 16 | 16 | ||
| 17 | public $translit = true; | 17 | public $translit = true; |
| 18 | 18 | ||
| @@ -66,18 +66,24 @@ | @@ -66,18 +66,24 @@ | ||
| 66 | 66 | ||
| 67 | private function checkUniqueSlug($slug) | 67 | private function checkUniqueSlug($slug) |
| 68 | { | 68 | { |
| 69 | - $pk = $this->owner->primaryKey(); | ||
| 70 | - $pk = $pk[ 0 ]; | ||
| 71 | - | ||
| 72 | - $condition = $this->out_attribute . ' = :out_attribute'; | ||
| 73 | - $params = [ ':out_attribute' => $slug ]; | ||
| 74 | - if(!$this->owner->isNewRecord) { | ||
| 75 | - $condition .= ' and ' . $pk . ' != :pk'; | ||
| 76 | - $params[ ':pk' ] = $this->owner->{$pk}; | 69 | + /** |
| 70 | + * @var ActiveRecord $owner | ||
| 71 | + */ | ||
| 72 | + $owner = $this->owner; | ||
| 73 | + $query = $owner->find()->where([ | ||
| 74 | + $this->out_attribute => $slug, | ||
| 75 | + ]); | ||
| 76 | + if(!$owner->isNewRecord) { | ||
| 77 | + $pks = $owner->primaryKey(); | ||
| 78 | + if(!empty($pks)) { | ||
| 79 | + $pk_rules = ['and']; | ||
| 80 | + foreach($pks as $pk) { | ||
| 81 | + $pk_rules[] = [$pk => $owner->$pk]; | ||
| 82 | + } | ||
| 83 | + $query->andWhere(['not', $pk_rules]); | ||
| 84 | + } | ||
| 77 | } | 85 | } |
| 78 | - return !$this->owner->find() | ||
| 79 | - ->where($condition, $params) | ||
| 80 | - ->one(); | 86 | + return !$query->exists(); |
| 81 | } | 87 | } |
| 82 | 88 | ||
| 83 | } | 89 | } |
| 84 | \ No newline at end of file | 90 | \ No newline at end of file |
common/models/Banner.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -namespace common\models; | ||
| 4 | - | ||
| 5 | -use common\modules\language\behaviors\LanguageBehavior; | ||
| 6 | -use Yii; | ||
| 7 | -use yii\db\ActiveQuery; | ||
| 8 | -use yii\db\ActiveRecord; | ||
| 9 | -use yii\web\Request; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * This is the model class for table "banner". | ||
| 13 | - * | ||
| 14 | - * @property integer $banner_id | ||
| 15 | - * @property string $url | ||
| 16 | - * @property integer $status | ||
| 17 | - * * From language behavior * | ||
| 18 | - * @property BannerLang $lang | ||
| 19 | - * @property BannerLang[] $langs | ||
| 20 | - * @property BannerLang $object_lang | ||
| 21 | - * @property string $ownerKey | ||
| 22 | - * @property string $langKey | ||
| 23 | - * @method string getOwnerKey() | ||
| 24 | - * @method void setOwnerKey(string $value) | ||
| 25 | - * @method string getLangKey() | ||
| 26 | - * @method void setLangKey(string $value) | ||
| 27 | - * @method ActiveQuery getLangs() | ||
| 28 | - * @method ActiveQuery getLang( integer $language_id ) | ||
| 29 | - * @method BannerLang[] generateLangs() | ||
| 30 | - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) | ||
| 31 | - * @method bool linkLangs(ActiveRecord[] $model_langs) | ||
| 32 | - * @method bool saveLangs(ActiveRecord[] $model_langs) | ||
| 33 | - * * End language behavior * | ||
| 34 | - */ | ||
| 35 | -class Banner extends \yii\db\ActiveRecord | ||
| 36 | -{ | ||
| 37 | - /** | ||
| 38 | - * @inheritdoc | ||
| 39 | - */ | ||
| 40 | - public static function tableName() | ||
| 41 | - { | ||
| 42 | - return 'banner'; | ||
| 43 | - } | ||
| 44 | 2 | ||
| 45 | - public function behaviors() | ||
| 46 | - { | ||
| 47 | - return [ | ||
| 48 | - 'language' => [ | ||
| 49 | - 'class' => LanguageBehavior::className(), | ||
| 50 | - ], | ||
| 51 | - ]; | ||
| 52 | - } | 3 | + namespace common\models; |
| 4 | + | ||
| 5 | + use common\modules\language\behaviors\LanguageBehavior; | ||
| 6 | + use Yii; | ||
| 7 | + use yii\db\ActiveQuery; | ||
| 8 | + use yii\web\Request; | ||
| 53 | 9 | ||
| 54 | /** | 10 | /** |
| 55 | - * @inheritdoc | ||
| 56 | - */ | ||
| 57 | - public function rules() | ||
| 58 | - { | ||
| 59 | - return [ | ||
| 60 | - [['status'], 'integer'], | ||
| 61 | - [['url'], 'string', 'max' => 255], | ||
| 62 | - ]; | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - /** | ||
| 66 | - * @inheritdoc | 11 | + * This is the model class for table "banner". |
| 12 | + * @property integer $banner_id | ||
| 13 | + * @property string $url | ||
| 14 | + * @property integer $status | ||
| 15 | + * * From language behavior * | ||
| 16 | + * @property BannerLang $lang | ||
| 17 | + * @property BannerLang[] $langs | ||
| 18 | + * @property BannerLang $object_lang | ||
| 19 | + * @property string $ownerKey | ||
| 20 | + * @property string $langKey | ||
| 21 | + * @property BannerLang[] $model_langs | ||
| 22 | + * @property bool $transactionStatus | ||
| 23 | + * @method string getOwnerKey() | ||
| 24 | + * @method void setOwnerKey( string $value ) | ||
| 25 | + * @method string getLangKey() | ||
| 26 | + * @method void setLangKey( string $value ) | ||
| 27 | + * @method ActiveQuery getLangs() | ||
| 28 | + * @method ActiveQuery getLang( integer $language_id ) | ||
| 29 | + * @method BannerLang[] generateLangs() | ||
| 30 | + * @method void loadLangs( Request $request ) | ||
| 31 | + * @method bool linkLangs() | ||
| 32 | + * @method bool saveLangs() | ||
| 33 | + * @method bool getTransactionStatus() | ||
| 34 | + * * End language behavior * | ||
| 67 | */ | 35 | */ |
| 68 | - public function attributeLabels() | 36 | + class Banner extends \yii\db\ActiveRecord |
| 69 | { | 37 | { |
| 70 | - return [ | ||
| 71 | - 'banner_id' => Yii::t('app', 'banner_id'), | ||
| 72 | - 'url' => Yii::t('app', 'url'), | ||
| 73 | - 'status' => Yii::t('app', 'status'), | ||
| 74 | - ]; | 38 | + |
| 39 | + /** | ||
| 40 | + * @inheritdoc | ||
| 41 | + */ | ||
| 42 | + public static function tableName() | ||
| 43 | + { | ||
| 44 | + return 'banner'; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public function behaviors() | ||
| 48 | + { | ||
| 49 | + return [ | ||
| 50 | + 'language' => [ | ||
| 51 | + 'class' => LanguageBehavior::className(), | ||
| 52 | + ], | ||
| 53 | + ]; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @inheritdoc | ||
| 58 | + */ | ||
| 59 | + public function rules() | ||
| 60 | + { | ||
| 61 | + return [ | ||
| 62 | + [ | ||
| 63 | + [ 'status' ], | ||
| 64 | + 'integer', | ||
| 65 | + ], | ||
| 66 | + [ | ||
| 67 | + [ 'url' ], | ||
| 68 | + 'string', | ||
| 69 | + 'max' => 255, | ||
| 70 | + ], | ||
| 71 | + ]; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * @inheritdoc | ||
| 76 | + */ | ||
| 77 | + public function attributeLabels() | ||
| 78 | + { | ||
| 79 | + return [ | ||
| 80 | + 'banner_id' => Yii::t('app', 'banner_id'), | ||
| 81 | + 'url' => Yii::t('app', 'url'), | ||
| 82 | + 'status' => Yii::t('app', 'status'), | ||
| 83 | + ]; | ||
| 84 | + } | ||
| 75 | } | 85 | } |
| 76 | -} |
common/models/Bg.php
| @@ -10,12 +10,16 @@ | @@ -10,12 +10,16 @@ | ||
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | * Class Bg | 12 | * Class Bg |
| 13 | + * @property int $id | ||
| 14 | + * @todo Write docs | ||
| 13 | * * From language behavior * | 15 | * * From language behavior * |
| 14 | * @property BgLang $lang | 16 | * @property BgLang $lang |
| 15 | * @property BgLang[] $langs | 17 | * @property BgLang[] $langs |
| 16 | * @property BgLang $object_lang | 18 | * @property BgLang $object_lang |
| 17 | * @property string $ownerKey | 19 | * @property string $ownerKey |
| 18 | * @property string $langKey | 20 | * @property string $langKey |
| 21 | + * @property BgLang[] $model_langs | ||
| 22 | + * @property bool $transactionStatus | ||
| 19 | * @method string getOwnerKey() | 23 | * @method string getOwnerKey() |
| 20 | * @method void setOwnerKey( string $value ) | 24 | * @method void setOwnerKey( string $value ) |
| 21 | * @method string getLangKey() | 25 | * @method string getLangKey() |
| @@ -23,12 +27,13 @@ | @@ -23,12 +27,13 @@ | ||
| 23 | * @method ActiveQuery getLangs() | 27 | * @method ActiveQuery getLangs() |
| 24 | * @method ActiveQuery getLang( integer $language_id ) | 28 | * @method ActiveQuery getLang( integer $language_id ) |
| 25 | * @method BgLang[] generateLangs() | 29 | * @method BgLang[] generateLangs() |
| 26 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 27 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 28 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 30 | + * @method void loadLangs( Request $request ) |
| 31 | + * @method bool linkLangs() | ||
| 32 | + * @method bool saveLangs() | ||
| 33 | + * @method bool getTransactionStatus() | ||
| 29 | * * End language behavior * | 34 | * * End language behavior * |
| 30 | */ | 35 | */ |
| 31 | - class Bg extends \yii\db\ActiveRecord | 36 | + class Bg extends ActiveRecord |
| 32 | { | 37 | { |
| 33 | 38 | ||
| 34 | public static function tableName() | 39 | public static function tableName() |
common/models/Delivery.php
| @@ -10,24 +10,27 @@ | @@ -10,24 +10,27 @@ | ||
| 10 | /** | 10 | /** |
| 11 | * Class Delivery | 11 | * Class Delivery |
| 12 | * * From language behavior * | 12 | * * From language behavior * |
| 13 | - * @property OrdersDeliveryLang $lang | ||
| 14 | - * @property OrdersDeliveryLang[] $langs | ||
| 15 | - * @property OrdersDeliveryLang $object_lang | ||
| 16 | - * @property string $ownerKey | ||
| 17 | - * @property string $langKey | 13 | + * @property OrdersDeliveryLang $lang |
| 14 | + * @property OrdersDeliveryLang[] $langs | ||
| 15 | + * @property OrdersDeliveryLang $object_lang | ||
| 16 | + * @property string $ownerKey | ||
| 17 | + * @property string $langKey | ||
| 18 | + * @property OrdersDeliveryLang[] $model_langs | ||
| 19 | + * @property bool $transactionStatus | ||
| 18 | * @method string getOwnerKey() | 20 | * @method string getOwnerKey() |
| 19 | - * @method void setOwnerKey( string $value ) | 21 | + * @method void setOwnerKey(string $value) |
| 20 | * @method string getLangKey() | 22 | * @method string getLangKey() |
| 21 | - * @method void setLangKey( string $value ) | 23 | + * @method void setLangKey(string $value) |
| 22 | * @method ActiveQuery getLangs() | 24 | * @method ActiveQuery getLangs() |
| 23 | * @method ActiveQuery getLang( integer $language_id ) | 25 | * @method ActiveQuery getLang( integer $language_id ) |
| 24 | * @method OrdersDeliveryLang[] generateLangs() | 26 | * @method OrdersDeliveryLang[] generateLangs() |
| 25 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 26 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 27 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 27 | + * @method void loadLangs(Request $request) |
| 28 | + * @method bool linkLangs() | ||
| 29 | + * @method bool saveLangs() | ||
| 30 | + * @method bool getTransactionStatus() | ||
| 28 | * * End language behavior * | 31 | * * End language behavior * |
| 29 | */ | 32 | */ |
| 30 | - class Delivery extends \yii\db\ActiveRecord | 33 | + class Delivery extends ActiveRecord |
| 31 | { | 34 | { |
| 32 | 35 | ||
| 33 | public function behaviors() | 36 | public function behaviors() |
common/models/Event.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -namespace common\models; | ||
| 4 | - | ||
| 5 | -use common\behaviors\SaveImgBehavior; | ||
| 6 | -use common\modules\language\behaviors\LanguageBehavior; | ||
| 7 | -use Yii; | ||
| 8 | -use yii\behaviors\TimestampBehavior; | ||
| 9 | -use yii\db\ActiveQuery; | ||
| 10 | -use yii\db\ActiveRecord; | ||
| 11 | -use yii\web\Request; | ||
| 12 | - | ||
| 13 | -/** | ||
| 14 | - * This is the model class for table "event". | ||
| 15 | - * | ||
| 16 | - * @property integer $event_id | ||
| 17 | - * @property string $image | ||
| 18 | - * @property integer $created_at | ||
| 19 | - * @property integer $updated_at | ||
| 20 | - * @property integer $end_at | ||
| 21 | - * | ||
| 22 | - * *From language behavior * | ||
| 23 | - * @property EventLang $lang | ||
| 24 | - * @property EventLang[] $langs | ||
| 25 | - * @property EventLang $object_lang | ||
| 26 | - * @property string $ownerKey | ||
| 27 | - * @property string $langKey | ||
| 28 | - * @method string getOwnerKey() | ||
| 29 | - * @method void setOwnerKey(string $value) | ||
| 30 | - * @method string getLangKey() | ||
| 31 | - * @method void setLangKey(string $value) | ||
| 32 | - * @method ActiveQuery getLangs() | ||
| 33 | - * @method ActiveQuery getLang( integer $language_id ) | ||
| 34 | - * @method EventLang[] generateLangs() | ||
| 35 | - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) | ||
| 36 | - * @method bool linkLangs(ActiveRecord[] $model_langs) | ||
| 37 | - * @method bool saveLangs(ActiveRecord[] $model_langs) | ||
| 38 | - * * End language behavior * | ||
| 39 | - */ | ||
| 40 | -class Event extends \yii\db\ActiveRecord | ||
| 41 | -{ | 2 | + |
| 3 | + namespace common\models; | ||
| 4 | + | ||
| 5 | + use common\behaviors\SaveImgBehavior; | ||
| 6 | + use common\modules\language\behaviors\LanguageBehavior; | ||
| 7 | + use Yii; | ||
| 8 | + use yii\behaviors\TimestampBehavior; | ||
| 9 | + use yii\db\ActiveQuery; | ||
| 10 | + use yii\db\ActiveRecord; | ||
| 11 | + use yii\web\Request; | ||
| 12 | + | ||
| 42 | /** | 13 | /** |
| 43 | - * @inheritdoc | 14 | + * This is the model class for table "event". |
| 15 | + * @property integer $event_id | ||
| 16 | + * @property string $image | ||
| 17 | + * @property integer $created_at | ||
| 18 | + * @property integer $updated_at | ||
| 19 | + * @property integer $end_at | ||
| 20 | + * * From language behavior * | ||
| 21 | + * @property EventLang $lang | ||
| 22 | + * @property EventLang[] $langs | ||
| 23 | + * @property EventLang $object_lang | ||
| 24 | + * @property string $ownerKey | ||
| 25 | + * @property string $langKey | ||
| 26 | + * @property EventLang[] $model_langs | ||
| 27 | + * @property bool $transactionStatus | ||
| 28 | + * @method string getOwnerKey() | ||
| 29 | + * @method void setOwnerKey( string $value ) | ||
| 30 | + * @method string getLangKey() | ||
| 31 | + * @method void setLangKey( string $value ) | ||
| 32 | + * @method ActiveQuery getLangs() | ||
| 33 | + * @method ActiveQuery getLang( integer $language_id ) | ||
| 34 | + * @method EventLang[] generateLangs() | ||
| 35 | + * @method void loadLangs( Request $request ) | ||
| 36 | + * @method bool linkLangs() | ||
| 37 | + * @method bool saveLangs() | ||
| 38 | + * @method bool getTransactionStatus() | ||
| 39 | + * * End language behavior * | ||
| 44 | */ | 40 | */ |
| 45 | - public static function tableName() | 41 | + class Event extends ActiveRecord |
| 46 | { | 42 | { |
| 47 | - return 'event'; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - /** | ||
| 51 | - * @inheritdoc | ||
| 52 | - */ | ||
| 53 | - public function behaviors() | ||
| 54 | - { | ||
| 55 | - return [ | ||
| 56 | - TimestampBehavior::className(), | ||
| 57 | - [ | ||
| 58 | - 'class' => 'common\behaviors\ShowImage', | ||
| 59 | - ], | ||
| 60 | - 'language' => [ | ||
| 61 | - 'class' => LanguageBehavior::className(), | ||
| 62 | - ], | ||
| 63 | - [ | ||
| 64 | - 'class' => SaveImgBehavior::className(), | ||
| 65 | - 'fields' => [ | 43 | + |
| 44 | + /** | ||
| 45 | + * @inheritdoc | ||
| 46 | + */ | ||
| 47 | + public static function tableName() | ||
| 48 | + { | ||
| 49 | + return 'event'; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * @inheritdoc | ||
| 54 | + */ | ||
| 55 | + public function behaviors() | ||
| 56 | + { | ||
| 57 | + return [ | ||
| 58 | + TimestampBehavior::className(), | ||
| 59 | + [ | ||
| 60 | + 'class' => 'common\behaviors\ShowImage', | ||
| 61 | + ], | ||
| 62 | + 'language' => [ | ||
| 63 | + 'class' => LanguageBehavior::className(), | ||
| 64 | + ], | ||
| 65 | + [ | ||
| 66 | + 'class' => SaveImgBehavior::className(), | ||
| 67 | + 'fields' => [ | ||
| 68 | + [ | ||
| 69 | + 'name' => 'image', | ||
| 70 | + 'directory' => 'event', | ||
| 71 | + ], | ||
| 72 | + ], | ||
| 73 | + ], | ||
| 74 | + ]; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public function beforeSave($insert) | ||
| 78 | + { | ||
| 79 | + if(parent::beforeSave($insert)) { | ||
| 80 | + $this->end_at = strtotime($this->end_at); | ||
| 81 | + return true; | ||
| 82 | + } else { | ||
| 83 | + return false; | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public function afterFind() | ||
| 88 | + { | ||
| 89 | + $this->end_at = date("Y-m-d", $this->end_at); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * @inheritdoc | ||
| 94 | + */ | ||
| 95 | + public function rules() | ||
| 96 | + { | ||
| 97 | + return [ | ||
| 98 | + [ | ||
| 66 | [ | 99 | [ |
| 67 | - 'name' => 'image', | ||
| 68 | - 'directory' => 'event', | 100 | + 'created_at', |
| 101 | + 'updated_at', | ||
| 69 | ], | 102 | ], |
| 103 | + 'integer', | ||
| 70 | ], | 104 | ], |
| 71 | - ], | ||
| 72 | - ]; | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - | ||
| 76 | - public function beforeSave($insert) | ||
| 77 | - { | ||
| 78 | - if (parent::beforeSave($insert)) { | ||
| 79 | - $this->end_at = strtotime($this->end_at); | ||
| 80 | - return true; | ||
| 81 | - } else { | ||
| 82 | - return false; | 105 | + [ |
| 106 | + [ 'end_at' ], | ||
| 107 | + 'string', | ||
| 108 | + 'max' => 255, | ||
| 109 | + ], | ||
| 110 | + ]; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * @inheritdoc | ||
| 115 | + */ | ||
| 116 | + public function attributeLabels() | ||
| 117 | + { | ||
| 118 | + return [ | ||
| 119 | + 'event_id' => Yii::t('app', 'event_id'), | ||
| 120 | + 'image' => Yii::t('app', 'image'), | ||
| 121 | + 'created_at' => Yii::t('app', 'created_at'), | ||
| 122 | + 'updated_at' => Yii::t('app', 'updated_at'), | ||
| 123 | + 'end_at' => Yii::t('app', 'end_at'), | ||
| 124 | + ]; | ||
| 83 | } | 125 | } |
| 84 | } | 126 | } |
| 85 | - | ||
| 86 | - public function afterFind(){ | ||
| 87 | - $this->end_at = date("Y-m-d", $this->end_at); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - | ||
| 91 | - /** | ||
| 92 | - * @inheritdoc | ||
| 93 | - */ | ||
| 94 | - public function rules() | ||
| 95 | - { | ||
| 96 | - return [ | ||
| 97 | - [['created_at', 'updated_at' ], 'integer'], | ||
| 98 | - [['end_at'], 'string', 'max' => 255], | ||
| 99 | - ]; | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - /** | ||
| 103 | - * @inheritdoc | ||
| 104 | - */ | ||
| 105 | - public function attributeLabels() | ||
| 106 | - { | ||
| 107 | - return [ | ||
| 108 | - 'event_id' => Yii::t('app', 'event_id'), | ||
| 109 | - 'image' => Yii::t('app', 'image'), | ||
| 110 | - 'created_at' => Yii::t('app', 'created_at'), | ||
| 111 | - 'updated_at' => Yii::t('app', 'updated_at'), | ||
| 112 | - 'end_at' => Yii::t('app', 'end_at'), | ||
| 113 | - ]; | ||
| 114 | - } | ||
| 115 | -} |
common/models/Page.php
| @@ -17,6 +17,8 @@ | @@ -17,6 +17,8 @@ | ||
| 17 | * @property PageLang $object_lang | 17 | * @property PageLang $object_lang |
| 18 | * @property string $ownerKey | 18 | * @property string $ownerKey |
| 19 | * @property string $langKey | 19 | * @property string $langKey |
| 20 | + * @property PageLang[] $model_langs | ||
| 21 | + * @property bool $transactionStatus | ||
| 20 | * @method string getOwnerKey() | 22 | * @method string getOwnerKey() |
| 21 | * @method void setOwnerKey( string $value ) | 23 | * @method void setOwnerKey( string $value ) |
| 22 | * @method string getLangKey() | 24 | * @method string getLangKey() |
| @@ -24,9 +26,10 @@ | @@ -24,9 +26,10 @@ | ||
| 24 | * @method ActiveQuery getLangs() | 26 | * @method ActiveQuery getLangs() |
| 25 | * @method ActiveQuery getLang( integer $language_id ) | 27 | * @method ActiveQuery getLang( integer $language_id ) |
| 26 | * @method PageLang[] generateLangs() | 28 | * @method PageLang[] generateLangs() |
| 27 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 28 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 29 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 29 | + * @method void loadLangs( Request $request ) |
| 30 | + * @method bool linkLangs() | ||
| 31 | + * @method bool saveLangs() | ||
| 32 | + * @method bool getTransactionStatus() | ||
| 30 | * * End language behavior * | 33 | * * End language behavior * |
| 31 | */ | 34 | */ |
| 32 | class Page extends ActiveRecord | 35 | class Page extends ActiveRecord |
common/models/ProductSpec.php
| @@ -11,31 +11,33 @@ | @@ -11,31 +11,33 @@ | ||
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | * This is the model class for table "product_spec". | 13 | * This is the model class for table "product_spec". |
| 14 | - * @property integer $product_spec_id | ||
| 15 | - * @property integer $product_id | ||
| 16 | - * @property string $tech_spec_link | ||
| 17 | - * @property string $tech_char_link | ||
| 18 | - * @property Product $product | ||
| 19 | - * | 14 | + * @property integer $product_spec_id |
| 15 | + * @property integer $product_id | ||
| 16 | + * @property string $tech_spec_link | ||
| 17 | + * @property string $tech_char_link | ||
| 18 | + * @property Product $product | ||
| 20 | * * From language behavior * | 19 | * * From language behavior * |
| 21 | - * @property ProductSpecLang $lang | ||
| 22 | - * @property ProductSpecLang[] $langs | ||
| 23 | - * @property ProductSpecLang $object_lang | ||
| 24 | - * @property string $ownerKey | ||
| 25 | - * @property string $langKey | 20 | + * @property ProductSpecLang $lang |
| 21 | + * @property ProductSpecLang[] $langs | ||
| 22 | + * @property ProductSpecLang $object_lang | ||
| 23 | + * @property string $ownerKey | ||
| 24 | + * @property string $langKey | ||
| 25 | + * @property ProductSpecLang[] $model_langs | ||
| 26 | + * @property bool $transactionStatus | ||
| 26 | * @method string getOwnerKey() | 27 | * @method string getOwnerKey() |
| 27 | - * @method void setOwnerKey(string $value) | 28 | + * @method void setOwnerKey( string $value ) |
| 28 | * @method string getLangKey() | 29 | * @method string getLangKey() |
| 29 | - * @method void setLangKey(string $value) | 30 | + * @method void setLangKey( string $value ) |
| 30 | * @method ActiveQuery getLangs() | 31 | * @method ActiveQuery getLangs() |
| 31 | * @method ActiveQuery getLang( integer $language_id ) | 32 | * @method ActiveQuery getLang( integer $language_id ) |
| 32 | * @method ProductSpecLang[] generateLangs() | 33 | * @method ProductSpecLang[] generateLangs() |
| 33 | - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) | ||
| 34 | - * @method bool linkLangs(ActiveRecord[] $model_langs) | ||
| 35 | - * @method bool saveLangs(ActiveRecord[] $model_langs) | 34 | + * @method void loadLangs( Request $request ) |
| 35 | + * @method bool linkLangs() | ||
| 36 | + * @method bool saveLangs() | ||
| 37 | + * @method bool getTransactionStatus() | ||
| 36 | * * End language behavior * | 38 | * * End language behavior * |
| 37 | */ | 39 | */ |
| 38 | - class ProductSpec extends \yii\db\ActiveRecord | 40 | + class ProductSpec extends ActiveRecord |
| 39 | { | 41 | { |
| 40 | 42 | ||
| 41 | /** | 43 | /** |
| @@ -64,7 +66,7 @@ | @@ -64,7 +66,7 @@ | ||
| 64 | ], | 66 | ], |
| 65 | ]; | 67 | ]; |
| 66 | } | 68 | } |
| 67 | - | 69 | + |
| 68 | /** | 70 | /** |
| 69 | * @inheritdoc | 71 | * @inheritdoc |
| 70 | */ | 72 | */ |
| @@ -100,19 +102,19 @@ | @@ -100,19 +102,19 @@ | ||
| 100 | public function upload() | 102 | public function upload() |
| 101 | { | 103 | { |
| 102 | $storage = \Yii::getAlias('@storage'); | 104 | $storage = \Yii::getAlias('@storage'); |
| 103 | - $product_dir = $storage.'/product_spec/'.$this->product_id; | 105 | + $product_dir = $storage . '/product_spec/' . $this->product_id; |
| 104 | if(!is_dir($product_dir)) { | 106 | if(!is_dir($product_dir)) { |
| 105 | mkdir($product_dir); | 107 | mkdir($product_dir); |
| 106 | } | 108 | } |
| 107 | if($this->validate()) { | 109 | if($this->validate()) { |
| 108 | - if(!empty($this->techSpecFile)) { | ||
| 109 | - $path = $product_dir.'/'.$this->techSpecFile->baseName.'.'.$this->techSpecFile->extension; | ||
| 110 | - $this->tech_spec_link = $this->techSpecFile->baseName.'.'.$this->techSpecFile->extension; | 110 | + if(!empty( $this->techSpecFile )) { |
| 111 | + $path = $product_dir . '/' . $this->techSpecFile->baseName . '.' . $this->techSpecFile->extension; | ||
| 112 | + $this->tech_spec_link = $this->techSpecFile->baseName . '.' . $this->techSpecFile->extension; | ||
| 111 | $this->techSpecFile->saveAs($path); | 113 | $this->techSpecFile->saveAs($path); |
| 112 | } | 114 | } |
| 113 | - if(!empty($this->techCharFile)) { | ||
| 114 | - $path = $product_dir.'/'.$this->techCharFile->baseName.'.'.$this->techCharFile->extension; | ||
| 115 | - $this->tech_char_link = $this->techCharFile->baseName.'.'.$this->techCharFile->extension; | 115 | + if(!empty( $this->techCharFile )) { |
| 116 | + $path = $product_dir . '/' . $this->techCharFile->baseName . '.' . $this->techCharFile->extension; | ||
| 117 | + $this->tech_char_link = $this->techCharFile->baseName . '.' . $this->techCharFile->extension; | ||
| 116 | $this->techCharFile->saveAs($path); | 118 | $this->techCharFile->saveAs($path); |
| 117 | } | 119 | } |
| 118 | return true; | 120 | return true; |
| @@ -129,17 +131,19 @@ | @@ -129,17 +131,19 @@ | ||
| 129 | return $this->hasOne(Product::className(), [ 'product_id' => 'product_id' ]); | 131 | return $this->hasOne(Product::className(), [ 'product_id' => 'product_id' ]); |
| 130 | } | 132 | } |
| 131 | 133 | ||
| 132 | - public function getTechSpecUrl() { | ||
| 133 | - if(!empty($this->tech_spec_link)) { | ||
| 134 | - return '/storage/product_spec/'.$this->product_id.'/'.$this->tech_spec_link; | 134 | + public function getTechSpecUrl() |
| 135 | + { | ||
| 136 | + if(!empty( $this->tech_spec_link )) { | ||
| 137 | + return '/storage/product_spec/' . $this->product_id . '/' . $this->tech_spec_link; | ||
| 135 | } else { | 138 | } else { |
| 136 | return false; | 139 | return false; |
| 137 | } | 140 | } |
| 138 | } | 141 | } |
| 139 | - | ||
| 140 | - public function getTechCharUrl() { | ||
| 141 | - if(!empty($this->tech_char_link)) { | ||
| 142 | - return '/storage/product_spec/'.$this->product_id.'/'.$this->tech_char_link; | 142 | + |
| 143 | + public function getTechCharUrl() | ||
| 144 | + { | ||
| 145 | + if(!empty( $this->tech_char_link )) { | ||
| 146 | + return '/storage/product_spec/' . $this->product_id . '/' . $this->tech_char_link; | ||
| 143 | } else { | 147 | } else { |
| 144 | return false; | 148 | return false; |
| 145 | } | 149 | } |
common/models/Project.php
| @@ -10,6 +10,9 @@ | @@ -10,6 +10,9 @@ | ||
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | * This is the model class for table "project". | 12 | * This is the model class for table "project". |
| 13 | + * | ||
| 14 | + * @todo Refactor | ||
| 15 | + * | ||
| 13 | * @property integer $project_id | 16 | * @property integer $project_id |
| 14 | * @property integer $date_add | 17 | * @property integer $date_add |
| 15 | * @property ProjectImage[] $images | 18 | * @property ProjectImage[] $images |
| @@ -23,6 +26,8 @@ | @@ -23,6 +26,8 @@ | ||
| 23 | * @property ProjectLang $object_lang | 26 | * @property ProjectLang $object_lang |
| 24 | * @property string $ownerKey | 27 | * @property string $ownerKey |
| 25 | * @property string $langKey | 28 | * @property string $langKey |
| 29 | + * @property ProjectLang[] $model_langs | ||
| 30 | + * @property bool $transactionStatus | ||
| 26 | * @method string getOwnerKey() | 31 | * @method string getOwnerKey() |
| 27 | * @method void setOwnerKey( string $value ) | 32 | * @method void setOwnerKey( string $value ) |
| 28 | * @method string getLangKey() | 33 | * @method string getLangKey() |
| @@ -30,12 +35,13 @@ | @@ -30,12 +35,13 @@ | ||
| 30 | * @method ActiveQuery getLangs() | 35 | * @method ActiveQuery getLangs() |
| 31 | * @method ActiveQuery getLang( integer $language_id ) | 36 | * @method ActiveQuery getLang( integer $language_id ) |
| 32 | * @method ProjectLang[] generateLangs() | 37 | * @method ProjectLang[] generateLangs() |
| 33 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 34 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 35 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 38 | + * @method void loadLangs( Request $request ) |
| 39 | + * @method bool linkLangs() | ||
| 40 | + * @method bool saveLangs() | ||
| 41 | + * @method bool getTransactionStatus() | ||
| 36 | * * End language behavior * | 42 | * * End language behavior * |
| 37 | */ | 43 | */ |
| 38 | - class Project extends \yii\db\ActiveRecord | 44 | + class Project extends ActiveRecord |
| 39 | { | 45 | { |
| 40 | 46 | ||
| 41 | public $imagesUpload = []; | 47 | public $imagesUpload = []; |
common/models/Seo.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -namespace common\models; | ||
| 4 | - | ||
| 5 | -use common\modules\language\behaviors\LanguageBehavior; | ||
| 6 | -use Yii; | ||
| 7 | -use yii\db\ActiveQuery; | ||
| 8 | -use yii\db\ActiveRecord; | ||
| 9 | -use yii\web\Request; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * This is the model class for table "seo". | ||
| 13 | - * | ||
| 14 | - * @property integer $seo_id | ||
| 15 | - * @property string $url | ||
| 16 | - * | ||
| 17 | - * * From language behavior * | ||
| 18 | - * @property SeoLang $lang | ||
| 19 | - * @property SeoLang[] $langs | ||
| 20 | - * @property SeoLang $object_lang | ||
| 21 | - * @property string $ownerKey | ||
| 22 | - * @property string $langKey | ||
| 23 | - * @method string getOwnerKey() | ||
| 24 | - * @method void setOwnerKey(string $value) | ||
| 25 | - * @method string getLangKey() | ||
| 26 | - * @method void setLangKey(string $value) | ||
| 27 | - * @method ActiveQuery getLangs() | ||
| 28 | - * @method ActiveQuery getLang( integer $language_id ) | ||
| 29 | - * @method SeoLang[] generateLangs() | ||
| 30 | - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) | ||
| 31 | - * @method bool linkLangs(ActiveRecord[] $model_langs) | ||
| 32 | - * @method bool saveLangs(ActiveRecord[] $model_langs) | ||
| 33 | - * * End language behavior * | ||
| 34 | - */ | ||
| 35 | -class Seo extends \yii\db\ActiveRecord | ||
| 36 | -{ | ||
| 37 | - /** | ||
| 38 | - * @inheritdoc | ||
| 39 | - */ | ||
| 40 | - public static function tableName() | ||
| 41 | - { | ||
| 42 | - return 'seo'; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - public function behaviors() | ||
| 46 | - { | ||
| 47 | - return [ | ||
| 48 | - 'language' => [ | ||
| 49 | - 'class' => LanguageBehavior::className(), | ||
| 50 | - ], | ||
| 51 | - ]; | ||
| 52 | - } | 2 | + |
| 3 | + namespace common\models; | ||
| 4 | + | ||
| 5 | + use common\modules\language\behaviors\LanguageBehavior; | ||
| 6 | + use Yii; | ||
| 7 | + use yii\db\ActiveQuery; | ||
| 8 | + use yii\db\ActiveRecord; | ||
| 9 | + use yii\web\Request; | ||
| 53 | 10 | ||
| 54 | /** | 11 | /** |
| 55 | - * @inheritdoc | ||
| 56 | - */ | ||
| 57 | - public function rules() | ||
| 58 | - { | ||
| 59 | - return [ | ||
| 60 | - [['url'], 'required'], | ||
| 61 | - [['url'], 'string', 'max' => 255], | ||
| 62 | - ]; | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - /** | ||
| 66 | - * @inheritdoc | 12 | + * This is the model class for table "seo". |
| 13 | + * @property integer $seo_id | ||
| 14 | + * @property string $url | ||
| 15 | + * * From language behavior * | ||
| 16 | + * @property SeoLang $lang | ||
| 17 | + * @property SeoLang[] $langs | ||
| 18 | + * @property SeoLang $object_lang | ||
| 19 | + * @property string $ownerKey | ||
| 20 | + * @property string $langKey | ||
| 21 | + * @property SeoLang[] $model_langs | ||
| 22 | + * @property bool $transactionStatus | ||
| 23 | + * @method string getOwnerKey() | ||
| 24 | + * @method void setOwnerKey( string $value ) | ||
| 25 | + * @method string getLangKey() | ||
| 26 | + * @method void setLangKey( string $value ) | ||
| 27 | + * @method ActiveQuery getLangs() | ||
| 28 | + * @method ActiveQuery getLang( integer $language_id ) | ||
| 29 | + * @method SeoLang[] generateLangs() | ||
| 30 | + * @method void loadLangs( Request $request ) | ||
| 31 | + * @method bool linkLangs() | ||
| 32 | + * @method bool saveLangs() | ||
| 33 | + * @method bool getTransactionStatus() | ||
| 34 | + * * End language behavior * | ||
| 67 | */ | 35 | */ |
| 68 | - public function attributeLabels() | 36 | + class Seo extends ActiveRecord |
| 69 | { | 37 | { |
| 70 | - return [ | ||
| 71 | - 'seo_id' => Yii::t('app', 'seo_id'), | ||
| 72 | - 'url' => Yii::t('app', 'url'), | ||
| 73 | - ]; | 38 | + |
| 39 | + /** | ||
| 40 | + * @inheritdoc | ||
| 41 | + */ | ||
| 42 | + public static function tableName() | ||
| 43 | + { | ||
| 44 | + return 'seo'; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public function behaviors() | ||
| 48 | + { | ||
| 49 | + return [ | ||
| 50 | + 'language' => [ | ||
| 51 | + 'class' => LanguageBehavior::className(), | ||
| 52 | + ], | ||
| 53 | + ]; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @inheritdoc | ||
| 58 | + */ | ||
| 59 | + public function rules() | ||
| 60 | + { | ||
| 61 | + return [ | ||
| 62 | + [ | ||
| 63 | + [ 'url' ], | ||
| 64 | + 'required', | ||
| 65 | + ], | ||
| 66 | + [ | ||
| 67 | + [ 'url' ], | ||
| 68 | + 'string', | ||
| 69 | + 'max' => 255, | ||
| 70 | + ], | ||
| 71 | + ]; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * @inheritdoc | ||
| 76 | + */ | ||
| 77 | + public function attributeLabels() | ||
| 78 | + { | ||
| 79 | + return [ | ||
| 80 | + 'seo_id' => Yii::t('app', 'seo_id'), | ||
| 81 | + 'url' => Yii::t('app', 'url'), | ||
| 82 | + ]; | ||
| 83 | + } | ||
| 74 | } | 84 | } |
| 75 | -} |
common/models/SeoCategory.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -namespace common\models; | ||
| 4 | - | ||
| 5 | -use common\modules\language\behaviors\LanguageBehavior; | ||
| 6 | -use Yii; | ||
| 7 | -use yii\db\ActiveQuery; | ||
| 8 | -use yii\db\ActiveRecord; | ||
| 9 | -use yii\web\Request; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * This is the model class for table "seo_category". | ||
| 13 | - * | ||
| 14 | - * @property integer $seo_category_id | ||
| 15 | - * @property string $controller | ||
| 16 | - * @property integer $status | ||
| 17 | - * | ||
| 18 | - * * From language behavior * | ||
| 19 | - * @property SeoCategoryLang $lang | ||
| 20 | - * @property SeoCategoryLang[] $langs | ||
| 21 | - * @property SeoCategoryLang $object_lang | ||
| 22 | - * @property string $ownerKey | ||
| 23 | - * @property string $langKey | ||
| 24 | - * @method string getOwnerKey() | ||
| 25 | - * @method void setOwnerKey(string $value) | ||
| 26 | - * @method string getLangKey() | ||
| 27 | - * @method void setLangKey(string $value) | ||
| 28 | - * @method ActiveQuery getLangs() | ||
| 29 | - * @method ActiveQuery getLang( integer $language_id ) | ||
| 30 | - * @method SeoCategoryLang[] generateLangs() | ||
| 31 | - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) | ||
| 32 | - * @method bool linkLangs(ActiveRecord[] $model_langs) | ||
| 33 | - * @method bool saveLangs(ActiveRecord[] $model_langs) | ||
| 34 | - * * End language behavior * | ||
| 35 | - * | ||
| 36 | - * @property SeoDynamic[] $seoDynamics | ||
| 37 | - */ | ||
| 38 | -class SeoCategory extends \yii\db\ActiveRecord | ||
| 39 | -{ | ||
| 40 | - /** | ||
| 41 | - * @inheritdoc | ||
| 42 | - */ | ||
| 43 | - public static function tableName() | ||
| 44 | - { | ||
| 45 | - return 'seo_category'; | ||
| 46 | - } | ||
| 47 | 2 | ||
| 48 | - public function behaviors() | ||
| 49 | - { | ||
| 50 | - return [ | ||
| 51 | - 'language' => [ | ||
| 52 | - 'class' => LanguageBehavior::className(), | ||
| 53 | - ], | ||
| 54 | - ]; | ||
| 55 | - } | 3 | + namespace common\models; |
| 4 | + | ||
| 5 | + use common\modules\language\behaviors\LanguageBehavior; | ||
| 6 | + use Yii; | ||
| 7 | + use yii\db\ActiveQuery; | ||
| 8 | + use yii\db\ActiveRecord; | ||
| 9 | + use yii\web\Request; | ||
| 56 | 10 | ||
| 57 | /** | 11 | /** |
| 58 | - * @inheritdoc | ||
| 59 | - */ | ||
| 60 | - public function rules() | ||
| 61 | - { | ||
| 62 | - return [ | ||
| 63 | - [['status'], 'integer'], | ||
| 64 | - [['controller'], 'string', 'max' => 100], | ||
| 65 | - ]; | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - /** | ||
| 69 | - * @inheritdoc | ||
| 70 | - */ | ||
| 71 | - public function attributeLabels() | ||
| 72 | - { | ||
| 73 | - return [ | ||
| 74 | - 'seo_category_id' => Yii::t('app', 'seo_category_id'), | ||
| 75 | - 'controller' => Yii::t('app', 'controller'), | ||
| 76 | - 'status' => Yii::t('app', 'status'), | ||
| 77 | - ]; | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - /** | ||
| 81 | - * @return \yii\db\ActiveQuery | 12 | + * This is the model class for table "seo_category". |
| 13 | + * @property integer $seo_category_id | ||
| 14 | + * @property string $controller | ||
| 15 | + * @property integer $status | ||
| 16 | + * * From language behavior * | ||
| 17 | + * @property SeoCategoryLang $lang | ||
| 18 | + * @property SeoCategoryLang[] $langs | ||
| 19 | + * @property SeoCategoryLang $object_lang | ||
| 20 | + * @property string $ownerKey | ||
| 21 | + * @property string $langKey | ||
| 22 | + * @property SeoCategoryLang[] $model_langs | ||
| 23 | + * @property bool $transactionStatus | ||
| 24 | + * @method string getOwnerKey() | ||
| 25 | + * @method void setOwnerKey( string $value ) | ||
| 26 | + * @method string getLangKey() | ||
| 27 | + * @method void setLangKey( string $value ) | ||
| 28 | + * @method ActiveQuery getLangs() | ||
| 29 | + * @method ActiveQuery getLang( integer $language_id ) | ||
| 30 | + * @method SeoCategoryLang[] generateLangs() | ||
| 31 | + * @method void loadLangs( Request $request ) | ||
| 32 | + * @method bool linkLangs() | ||
| 33 | + * @method bool saveLangs() | ||
| 34 | + * @method bool getTransactionStatus() | ||
| 35 | + * * End language behavior * | ||
| 36 | + * @property SeoDynamic[] $seoDynamics | ||
| 82 | */ | 37 | */ |
| 83 | - public function getSeoDynamics() | 38 | + class SeoCategory extends ActiveRecord |
| 84 | { | 39 | { |
| 85 | - return $this->hasMany(SeoDynamic::className(), ['seo_category_id' => 'seo_category_id']); | 40 | + |
| 41 | + /** | ||
| 42 | + * @inheritdoc | ||
| 43 | + */ | ||
| 44 | + public static function tableName() | ||
| 45 | + { | ||
| 46 | + return 'seo_category'; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public function behaviors() | ||
| 50 | + { | ||
| 51 | + return [ | ||
| 52 | + 'language' => [ | ||
| 53 | + 'class' => LanguageBehavior::className(), | ||
| 54 | + ], | ||
| 55 | + ]; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @inheritdoc | ||
| 60 | + */ | ||
| 61 | + public function rules() | ||
| 62 | + { | ||
| 63 | + return [ | ||
| 64 | + [ | ||
| 65 | + [ 'status' ], | ||
| 66 | + 'integer', | ||
| 67 | + ], | ||
| 68 | + [ | ||
| 69 | + [ 'controller' ], | ||
| 70 | + 'string', | ||
| 71 | + 'max' => 100, | ||
| 72 | + ], | ||
| 73 | + ]; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * @inheritdoc | ||
| 78 | + */ | ||
| 79 | + public function attributeLabels() | ||
| 80 | + { | ||
| 81 | + return [ | ||
| 82 | + 'seo_category_id' => Yii::t('app', 'seo_category_id'), | ||
| 83 | + 'controller' => Yii::t('app', 'controller'), | ||
| 84 | + 'status' => Yii::t('app', 'status'), | ||
| 85 | + ]; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * @return \yii\db\ActiveQuery | ||
| 90 | + */ | ||
| 91 | + public function getSeoDynamics() | ||
| 92 | + { | ||
| 93 | + return $this->hasMany(SeoDynamic::className(), [ 'seo_category_id' => 'seo_category_id' ]); | ||
| 94 | + } | ||
| 86 | } | 95 | } |
| 87 | -} |
common/models/SeoDynamic.php
| @@ -22,6 +22,8 @@ | @@ -22,6 +22,8 @@ | ||
| 22 | * @property SeoDynamicLang $object_lang | 22 | * @property SeoDynamicLang $object_lang |
| 23 | * @property string $ownerKey | 23 | * @property string $ownerKey |
| 24 | * @property string $langKey | 24 | * @property string $langKey |
| 25 | + * @property SeoDynamicLang[] $model_langs | ||
| 26 | + * @property bool $transactionStatus | ||
| 25 | * @method string getOwnerKey() | 27 | * @method string getOwnerKey() |
| 26 | * @method void setOwnerKey( string $value ) | 28 | * @method void setOwnerKey( string $value ) |
| 27 | * @method string getLangKey() | 29 | * @method string getLangKey() |
| @@ -29,13 +31,14 @@ | @@ -29,13 +31,14 @@ | ||
| 29 | * @method ActiveQuery getLangs() | 31 | * @method ActiveQuery getLangs() |
| 30 | * @method ActiveQuery getLang( integer $language_id ) | 32 | * @method ActiveQuery getLang( integer $language_id ) |
| 31 | * @method SeoDynamicLang[] generateLangs() | 33 | * @method SeoDynamicLang[] generateLangs() |
| 32 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 33 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 34 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 34 | + * @method void loadLangs( Request $request ) |
| 35 | + * @method bool linkLangs() | ||
| 36 | + * @method bool saveLangs() | ||
| 37 | + * @method bool getTransactionStatus() | ||
| 35 | * * End language behavior * | 38 | * * End language behavior * |
| 36 | * @property SeoCategory $seoCategory | 39 | * @property SeoCategory $seoCategory |
| 37 | */ | 40 | */ |
| 38 | - class SeoDynamic extends \yii\db\ActiveRecord | 41 | + class SeoDynamic extends ActiveRecord |
| 39 | { | 42 | { |
| 40 | 43 | ||
| 41 | /** | 44 | /** |
common/models/Service.php
| @@ -22,6 +22,8 @@ | @@ -22,6 +22,8 @@ | ||
| 22 | * @property ServiceLang $object_lang | 22 | * @property ServiceLang $object_lang |
| 23 | * @property string $ownerKey | 23 | * @property string $ownerKey |
| 24 | * @property string $langKey | 24 | * @property string $langKey |
| 25 | + * @property ServiceLang[] $model_langs | ||
| 26 | + * @property bool $transactionStatus | ||
| 25 | * @method string getOwnerKey() | 27 | * @method string getOwnerKey() |
| 26 | * @method void setOwnerKey( string $value ) | 28 | * @method void setOwnerKey( string $value ) |
| 27 | * @method string getLangKey() | 29 | * @method string getLangKey() |
| @@ -29,12 +31,13 @@ | @@ -29,12 +31,13 @@ | ||
| 29 | * @method ActiveQuery getLangs() | 31 | * @method ActiveQuery getLangs() |
| 30 | * @method ActiveQuery getLang( integer $language_id ) | 32 | * @method ActiveQuery getLang( integer $language_id ) |
| 31 | * @method ServiceLang[] generateLangs() | 33 | * @method ServiceLang[] generateLangs() |
| 32 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 33 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 34 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 34 | + * @method void loadLangs( Request $request ) |
| 35 | + * @method bool linkLangs() | ||
| 36 | + * @method bool saveLangs() | ||
| 37 | + * @method bool getTransactionStatus() | ||
| 35 | * * End language behavior * | 38 | * * End language behavior * |
| 36 | */ | 39 | */ |
| 37 | - class Service extends \yii\db\ActiveRecord | 40 | + class Service extends ActiveRecord |
| 38 | { | 41 | { |
| 39 | 42 | ||
| 40 | /** | 43 | /** |
common/models/SliderImage.php
| @@ -25,6 +25,8 @@ | @@ -25,6 +25,8 @@ | ||
| 25 | * @property SliderImageLang $object_lang | 25 | * @property SliderImageLang $object_lang |
| 26 | * @property string $ownerKey | 26 | * @property string $ownerKey |
| 27 | * @property string $langKey | 27 | * @property string $langKey |
| 28 | + * @property SliderImageLang[] $model_langs | ||
| 29 | + * @property bool $transactionStatus | ||
| 28 | * @method string getOwnerKey() | 30 | * @method string getOwnerKey() |
| 29 | * @method void setOwnerKey( string $value ) | 31 | * @method void setOwnerKey( string $value ) |
| 30 | * @method string getLangKey() | 32 | * @method string getLangKey() |
| @@ -32,17 +34,13 @@ | @@ -32,17 +34,13 @@ | ||
| 32 | * @method ActiveQuery getLangs() | 34 | * @method ActiveQuery getLangs() |
| 33 | * @method ActiveQuery getLang( integer $language_id ) | 35 | * @method ActiveQuery getLang( integer $language_id ) |
| 34 | * @method SliderImageLang[] generateLangs() | 36 | * @method SliderImageLang[] generateLangs() |
| 35 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 36 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 37 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | ||
| 38 | - * * End language behavior * | ||
| 39 | - * * From transaction behavior * | ||
| 40 | - * @property SliderImageLang[] $model_langs | ||
| 41 | - * @property bool $transactionStatus | 37 | + * @method void loadLangs( Request $request ) |
| 38 | + * @method bool linkLangs() | ||
| 39 | + * @method bool saveLangs() | ||
| 42 | * @method bool getTransactionStatus() | 40 | * @method bool getTransactionStatus() |
| 43 | - * * End transaction behavior * | 41 | + * * End language behavior * |
| 44 | */ | 42 | */ |
| 45 | - class SliderImage extends \yii\db\ActiveRecord | 43 | + class SliderImage extends ActiveRecord |
| 46 | { | 44 | { |
| 47 | 45 | ||
| 48 | /** | 46 | /** |
common/modules/language/behaviors/LanguageBehavior.php
| @@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
| 2 | namespace common\modules\language\behaviors; | 2 | namespace common\modules\language\behaviors; |
| 3 | 3 | ||
| 4 | use common\modules\language\models\Language; | 4 | use common\modules\language\models\Language; |
| 5 | - use common\modules\product\models\Product; | ||
| 6 | use yii\base\Behavior; | 5 | use yii\base\Behavior; |
| 7 | use yii\base\InvalidConfigException; | 6 | use yii\base\InvalidConfigException; |
| 8 | use yii\db\ActiveQuery; | 7 | use yii\db\ActiveQuery; |
| @@ -252,6 +251,9 @@ | @@ -252,6 +251,9 @@ | ||
| 252 | $owner = $this->owner; | 251 | $owner = $this->owner; |
| 253 | $db = $owner::getDb(); | 252 | $db = $owner::getDb(); |
| 254 | $this->_transaction = $db->beginTransaction(); | 253 | $this->_transaction = $db->beginTransaction(); |
| 254 | + if($owner->hasAttribute('remote_id') && empty($owner->remote_id)) { | ||
| 255 | + $owner->remote_id = strval(microtime(true)*10000); | ||
| 256 | + } | ||
| 255 | } | 257 | } |
| 256 | 258 | ||
| 257 | public function afterSave($event) | 259 | public function afterSave($event) |
| @@ -272,9 +274,6 @@ | @@ -272,9 +274,6 @@ | ||
| 272 | $this->_transaction->commit(); | 274 | $this->_transaction->commit(); |
| 273 | $this->_transaction_status = true; | 275 | $this->_transaction_status = true; |
| 274 | } | 276 | } |
| 275 | - if($owner->hasAttribute('remote_id') && empty($owner->remote_id)) { | ||
| 276 | - $owner->remote_id = (int) $owner->primaryKey(); | ||
| 277 | - } | ||
| 278 | } | 277 | } |
| 279 | 278 | ||
| 280 | /** | 279 | /** |
common/modules/language/readme.txt
| @@ -66,9 +66,9 @@ public function behaviors() { | @@ -66,9 +66,9 @@ public function behaviors() { | ||
| 66 | * @method ActiveQuery getLangs() | 66 | * @method ActiveQuery getLangs() |
| 67 | * @method ActiveQuery getLang( integer $language_id ) | 67 | * @method ActiveQuery getLang( integer $language_id ) |
| 68 | * @method {TableLang}[] generateLangs() | 68 | * @method {TableLang}[] generateLangs() |
| 69 | - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) | ||
| 70 | - * @method bool linkLangs(ActiveRecord[] $model_langs) | ||
| 71 | - * @method bool saveLangs(ActiveRecord[] $model_langs) | 69 | + * @method void loadLangs(Request $request) |
| 70 | + * @method bool linkLangs() | ||
| 71 | + * @method bool saveLangs() | ||
| 72 | * @method bool getTransactionStatus() | 72 | * @method bool getTransactionStatus() |
| 73 | * * End language behavior * | 73 | * * End language behavior * |
| 74 | 3.2. ะฃะฑัะฐัั language behavior ั ะฝะฐัะปะตะดัะตะผัั ัะฐะฑะปะธั ะพั {Table} ({TableSearch}...) | 74 | 3.2. ะฃะฑัะฐัั language behavior ั ะฝะฐัะปะตะดัะตะผัั ัะฐะฑะปะธั ะพั {Table} ({TableSearch}...) |
common/modules/product/controllers/ManageController.php
| @@ -101,7 +101,7 @@ | @@ -101,7 +101,7 @@ | ||
| 101 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | 101 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
| 102 | $model->certificateUpload = UploadedFile::getInstances($model, 'certificateUpload'); | 102 | $model->certificateUpload = UploadedFile::getInstances($model, 'certificateUpload'); |
| 103 | 103 | ||
| 104 | - if($model->save()) { | 104 | + if($model->save() && $model->transactionStatus) { |
| 105 | 105 | ||
| 106 | if(!empty( $model->imagesUpload ) && ( ( $images = $model->imagesUpload() ) !== false )) { | 106 | if(!empty( $model->imagesUpload ) && ( ( $images = $model->imagesUpload() ) !== false )) { |
| 107 | foreach($images as $image) { | 107 | foreach($images as $image) { |
| @@ -127,30 +127,14 @@ | @@ -127,30 +127,14 @@ | ||
| 127 | $product_spec->product_id = $model->product_id; | 127 | $product_spec->product_id = $model->product_id; |
| 128 | $product_spec->techSpecFile = UploadedFile::getInstance($product_spec, 'techSpecFile'); | 128 | $product_spec->techSpecFile = UploadedFile::getInstance($product_spec, 'techSpecFile'); |
| 129 | $product_spec->techCharFile = UploadedFile::getInstance($product_spec, 'techCharFile'); | 129 | $product_spec->techCharFile = UploadedFile::getInstance($product_spec, 'techCharFile'); |
| 130 | - if($product_spec->upload() && $model->linkLangs() && $model->saveLangs()) { | ||
| 131 | - $product_spec->save(false); | ||
| 132 | - if($product_spec->linkLangs() && $product_spec->saveLangs()) { | 130 | + if($product_spec->upload()) { |
| 131 | + if($product_spec->save(false) && $product_spec->transactionStatus) { | ||
| 133 | return $this->redirect([ | 132 | return $this->redirect([ |
| 134 | 'view', | 133 | 'view', |
| 135 | 'id' => $model->product_id, | 134 | 'id' => $model->product_id, |
| 136 | ]); | 135 | ]); |
| 137 | - } else { | ||
| 138 | - return $this->redirect([ | ||
| 139 | - 'update', | ||
| 140 | - 'id' => $model->product_id, | ||
| 141 | - ]); | ||
| 142 | } | 136 | } |
| 143 | } | 137 | } |
| 144 | - } elseif($model->linkLangs() && $model->saveLangs()) { | ||
| 145 | - return $this->redirect([ | ||
| 146 | - 'view', | ||
| 147 | - 'id' => $model->product_id, | ||
| 148 | - ]); | ||
| 149 | - } else { | ||
| 150 | - return $this->redirect([ | ||
| 151 | - 'update', | ||
| 152 | - 'id' => $model->product_id, | ||
| 153 | - ]); | ||
| 154 | } | 138 | } |
| 155 | } | 139 | } |
| 156 | } | 140 | } |
| @@ -173,7 +157,7 @@ | @@ -173,7 +157,7 @@ | ||
| 173 | public function actionUpdate($id) | 157 | public function actionUpdate($id) |
| 174 | { | 158 | { |
| 175 | $model = $this->findModel($id); | 159 | $model = $this->findModel($id); |
| 176 | - $model_langs = $model->generateLangs(); | 160 | + $model->generateLangs(); |
| 177 | if(!empty( $model->productSpec )) { | 161 | if(!empty( $model->productSpec )) { |
| 178 | $product_spec = $model->productSpec; | 162 | $product_spec = $model->productSpec; |
| 179 | } else { | 163 | } else { |
| @@ -181,12 +165,12 @@ | @@ -181,12 +165,12 @@ | ||
| 181 | 'product_id' => $model->product_id, | 165 | 'product_id' => $model->product_id, |
| 182 | ]); | 166 | ]); |
| 183 | } | 167 | } |
| 184 | - $product_spec_langs = $product_spec->generateLangs(); | 168 | + $product_spec->generateLangs(); |
| 185 | if($model->load(Yii::$app->request->post())) { | 169 | if($model->load(Yii::$app->request->post())) { |
| 186 | - $model->loadLangs(\Yii::$app->request, $model_langs); | 170 | + $model->loadLangs(\Yii::$app->request); |
| 187 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | 171 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
| 188 | $model->certificateUpload = UploadedFile::getInstances($model, 'certificateUpload'); | 172 | $model->certificateUpload = UploadedFile::getInstances($model, 'certificateUpload'); |
| 189 | - if($model->save()) { | 173 | + if($model->save() && $model->transactionStatus) { |
| 190 | if(!empty( $model->imagesUpload ) && ( ( $images = $model->imagesUpload() ) !== false )) { | 174 | if(!empty( $model->imagesUpload ) && ( ( $images = $model->imagesUpload() ) !== false )) { |
| 191 | foreach($images as $image) { | 175 | foreach($images as $image) { |
| 192 | $imageModel = new ProductImage(); | 176 | $imageModel = new ProductImage(); |
| @@ -195,7 +179,6 @@ | @@ -195,7 +179,6 @@ | ||
| 195 | $imageModel->save(); | 179 | $imageModel->save(); |
| 196 | } | 180 | } |
| 197 | } | 181 | } |
| 198 | - | ||
| 199 | if(!empty( $model->certificateUpload ) && ( ( $certificates = $model->certificateUpload() ) !== false )) { | 182 | if(!empty( $model->certificateUpload ) && ( ( $certificates = $model->certificateUpload() ) !== false )) { |
| 200 | foreach($certificates as $certificate) { | 183 | foreach($certificates as $certificate) { |
| 201 | $certificateModel = new ProductCertificate([ | 184 | $certificateModel = new ProductCertificate([ |
| @@ -205,35 +188,28 @@ | @@ -205,35 +188,28 @@ | ||
| 205 | $certificateModel->save(false); | 188 | $certificateModel->save(false); |
| 206 | } | 189 | } |
| 207 | } | 190 | } |
| 208 | - | ||
| 209 | if($product_spec->load(Yii::$app->request->post())) { | 191 | if($product_spec->load(Yii::$app->request->post())) { |
| 210 | - $product_spec->loadLangs(\Yii::$app->request, $product_spec_langs); | 192 | + $product_spec->loadLangs(\Yii::$app->request); |
| 211 | $product_spec->techSpecFile = UploadedFile::getInstance($product_spec, 'techSpecFile'); | 193 | $product_spec->techSpecFile = UploadedFile::getInstance($product_spec, 'techSpecFile'); |
| 212 | $product_spec->techCharFile = UploadedFile::getInstance($product_spec, 'techCharFile'); | 194 | $product_spec->techCharFile = UploadedFile::getInstance($product_spec, 'techCharFile'); |
| 213 | - if($product_spec->upload() && $model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 214 | - $product_spec->save(false); | ||
| 215 | - if($product_spec->linkLangs($product_spec_langs) && $product_spec->saveLangs($product_spec_langs)) { | 195 | + if($product_spec->upload()) { |
| 196 | + if($product_spec->save(false) && $product_spec->transactionStatus) { | ||
| 216 | return $this->redirect([ | 197 | return $this->redirect([ |
| 217 | 'view', | 198 | 'view', |
| 218 | 'id' => $model->product_id, | 199 | 'id' => $model->product_id, |
| 219 | ]); | 200 | ]); |
| 220 | } | 201 | } |
| 221 | } | 202 | } |
| 222 | - } elseif($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | ||
| 223 | - return $this->redirect([ | ||
| 224 | - 'view', | ||
| 225 | - 'id' => $model->product_id, | ||
| 226 | - ]); | ||
| 227 | } | 203 | } |
| 228 | } | 204 | } |
| 229 | } | 205 | } |
| 230 | $groups = $model->getTaxGroupsByLevel(0); | 206 | $groups = $model->getTaxGroupsByLevel(0); |
| 231 | return $this->render('update', [ | 207 | return $this->render('update', [ |
| 232 | 'model' => $model, | 208 | 'model' => $model, |
| 233 | - 'model_langs' => $model_langs, | 209 | + 'model_langs' => $model->model_langs, |
| 234 | 'groups' => $groups, | 210 | 'groups' => $groups, |
| 235 | 'product_spec' => $product_spec, | 211 | 'product_spec' => $product_spec, |
| 236 | - 'product_spec_langs' => $product_spec_langs, | 212 | + 'product_spec_langs' => $product_spec->model_langs, |
| 237 | ]); | 213 | ]); |
| 238 | } | 214 | } |
| 239 | 215 |
common/modules/product/controllers/ProductUnitController.php
| @@ -67,27 +67,20 @@ | @@ -67,27 +67,20 @@ | ||
| 67 | public function actionCreate() | 67 | public function actionCreate() |
| 68 | { | 68 | { |
| 69 | $model = new ProductUnit(); | 69 | $model = new ProductUnit(); |
| 70 | - $model_langs = $model->generateLangs(); | ||
| 71 | - | ||
| 72 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 73 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 74 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 70 | + $model->generateLangs(); |
| 71 | + if($model->load(Yii::$app->request->post())) { | ||
| 72 | + $model->loadLangs(\Yii::$app->request); | ||
| 73 | + if($model->save() && $model->transactionStatus) { | ||
| 75 | return $this->redirect([ | 74 | return $this->redirect([ |
| 76 | 'view', | 75 | 'view', |
| 77 | 'id' => $model->product_unit_id, | 76 | 'id' => $model->product_unit_id, |
| 78 | ]); | 77 | ]); |
| 79 | - } else { | ||
| 80 | - return $this->redirect([ | ||
| 81 | - 'update', | ||
| 82 | - 'id' => $model->product_unit_id, | ||
| 83 | - ]); | ||
| 84 | } | 78 | } |
| 85 | - } else { | ||
| 86 | - return $this->render('create', [ | ||
| 87 | - 'model' => $model, | ||
| 88 | - 'model_langs' => $model_langs, | ||
| 89 | - ]); | ||
| 90 | } | 79 | } |
| 80 | + return $this->render('create', [ | ||
| 81 | + 'model' => $model, | ||
| 82 | + 'model_langs' => $model->model_langs, | ||
| 83 | + ]); | ||
| 91 | } | 84 | } |
| 92 | 85 | ||
| 93 | /** | 86 | /** |
| @@ -101,11 +94,10 @@ | @@ -101,11 +94,10 @@ | ||
| 101 | public function actionUpdate($id) | 94 | public function actionUpdate($id) |
| 102 | { | 95 | { |
| 103 | $model = $this->findModel($id); | 96 | $model = $this->findModel($id); |
| 104 | - $model_langs = $model->generateLangs(); | ||
| 105 | - | ||
| 106 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 107 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 108 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 97 | + $model->generateLangs(); |
| 98 | + if($model->load(Yii::$app->request->post())) { | ||
| 99 | + $model->loadLangs(\Yii::$app->request); | ||
| 100 | + if($model->save() && $model->transactionStatus) { | ||
| 109 | return $this->redirect([ | 101 | return $this->redirect([ |
| 110 | 'view', | 102 | 'view', |
| 111 | 'id' => $model->product_unit_id, | 103 | 'id' => $model->product_unit_id, |
| @@ -114,7 +106,7 @@ | @@ -114,7 +106,7 @@ | ||
| 114 | } | 106 | } |
| 115 | return $this->render('update', [ | 107 | return $this->render('update', [ |
| 116 | 'model' => $model, | 108 | 'model' => $model, |
| 117 | - 'model_langs' => $model_langs, | 109 | + 'model_langs' => $model->model_langs, |
| 118 | ]); | 110 | ]); |
| 119 | } | 111 | } |
| 120 | 112 |
common/modules/product/controllers/VariantController.php
| @@ -80,19 +80,15 @@ | @@ -80,19 +80,15 @@ | ||
| 80 | { | 80 | { |
| 81 | $model = new ProductVariant(); | 81 | $model = new ProductVariant(); |
| 82 | $model->product_id = $product_id; | 82 | $model->product_id = $product_id; |
| 83 | - $model_langs = $model->generateLangs(); | 83 | + $model->generateLangs(); |
| 84 | if($model->load(Yii::$app->request->post())) { | 84 | if($model->load(Yii::$app->request->post())) { |
| 85 | - $model->loadLangs(\Yii::$app->request, $model_langs); | 85 | + $model->loadLangs(\Yii::$app->request); |
| 86 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); | 86 | $model->imagesUpload = UploadedFile::getInstances($model, 'imagesUpload'); |
| 87 | - $model->validate(); | ||
| 88 | - | ||
| 89 | - if($model->save()) { | ||
| 90 | - | 87 | + if($model->save() && $model->transactionStatus) { |
| 91 | if(( $image = UploadedFile::getInstance($model, 'image') )) { | 88 | if(( $image = UploadedFile::getInstance($model, 'image') )) { |
| 92 | $imageModel = ProductImage::find() | 89 | $imageModel = ProductImage::find() |
| 93 | ->where([ 'product_variant_id' => $model->product_variant_id ]) | 90 | ->where([ 'product_variant_id' => $model->product_variant_id ]) |
| 94 | ->one(); | 91 | ->one(); |
| 95 | - | ||
| 96 | if($imageModel instanceof ProductImage) { | 92 | if($imageModel instanceof ProductImage) { |
| 97 | $imageModel->product_id = $model->product_id; | 93 | $imageModel->product_id = $model->product_id; |
| 98 | $imageModel->product_variant_id = $model->product_variant_id; | 94 | $imageModel->product_variant_id = $model->product_variant_id; |
| @@ -105,20 +101,14 @@ | @@ -105,20 +101,14 @@ | ||
| 105 | $imageModel->image = $image->name; | 101 | $imageModel->image = $image->name; |
| 106 | $imageModel->save(); | 102 | $imageModel->save(); |
| 107 | } | 103 | } |
| 108 | - | ||
| 109 | $imgDir = Yii::getAlias('@storage/products/'); | 104 | $imgDir = Yii::getAlias('@storage/products/'); |
| 110 | - | ||
| 111 | if(!is_dir($imgDir)) { | 105 | if(!is_dir($imgDir)) { |
| 112 | mkdir($imgDir, 0755, true); | 106 | mkdir($imgDir, 0755, true); |
| 113 | } | 107 | } |
| 114 | - | ||
| 115 | $image->saveAs(Yii::getAlias('@storage/products/' . $image->name)); | 108 | $image->saveAs(Yii::getAlias('@storage/products/' . $image->name)); |
| 116 | } | 109 | } |
| 117 | - | ||
| 118 | $ProductStocks = Yii::$app->request->post('ProductStock'); | 110 | $ProductStocks = Yii::$app->request->post('ProductStock'); |
| 119 | - | ||
| 120 | $total_quantity = 0; | 111 | $total_quantity = 0; |
| 121 | - | ||
| 122 | if(!empty( $ProductStocks ) && is_array($ProductStocks)) { | 112 | if(!empty( $ProductStocks ) && is_array($ProductStocks)) { |
| 123 | $model->unlinkAll('stocks', true); | 113 | $model->unlinkAll('stocks', true); |
| 124 | $sorted_array = []; | 114 | $sorted_array = []; |
| @@ -164,26 +154,18 @@ | @@ -164,26 +154,18 @@ | ||
| 164 | } | 154 | } |
| 165 | 155 | ||
| 166 | $model->stock = $total_quantity; | 156 | $model->stock = $total_quantity; |
| 167 | - $model->save(); | ||
| 168 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 157 | + if($model->save() && $model->transactionStatus) { |
| 169 | return $this->redirect([ | 158 | return $this->redirect([ |
| 170 | 'index', | 159 | 'index', |
| 171 | 'product_id' => $product_id, | 160 | 'product_id' => $product_id, |
| 172 | ]); | 161 | ]); |
| 173 | - } else { | ||
| 174 | - return $this->redirect([ | ||
| 175 | - 'update', | ||
| 176 | - 'product_id' => $product_id, | ||
| 177 | - 'id' => $model->product_variant_id, | ||
| 178 | - ]); | ||
| 179 | } | 162 | } |
| 180 | } | 163 | } |
| 181 | } | 164 | } |
| 182 | $groups = $model->getTaxGroupsByLevel(1); | 165 | $groups = $model->getTaxGroupsByLevel(1); |
| 183 | - | ||
| 184 | return $this->render('create', [ | 166 | return $this->render('create', [ |
| 185 | 'model' => $model, | 167 | 'model' => $model, |
| 186 | - 'model_langs' => $model_langs, | 168 | + 'model_langs' => $model->model_langs, |
| 187 | 'groups' => $groups, | 169 | 'groups' => $groups, |
| 188 | 'stocks' => [ new ProductStock() ], | 170 | 'stocks' => [ new ProductStock() ], |
| 189 | ]); | 171 | ]); |
| @@ -201,16 +183,14 @@ | @@ -201,16 +183,14 @@ | ||
| 201 | public function actionUpdate($product_id, $id) | 183 | public function actionUpdate($product_id, $id) |
| 202 | { | 184 | { |
| 203 | $model = $this->findModel($id); | 185 | $model = $this->findModel($id); |
| 204 | - $model_langs = $model->generateLangs(); | 186 | + $model->generateLangs(); |
| 205 | if($model->load(Yii::$app->request->post())) { | 187 | if($model->load(Yii::$app->request->post())) { |
| 206 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 207 | - if($model->save()) { | ||
| 208 | - | 188 | + $model->loadLangs(\Yii::$app->request); |
| 189 | + if($model->save() && $model->transactionStatus) { | ||
| 209 | if(( $image = UploadedFile::getInstance($model, 'image') )) { | 190 | if(( $image = UploadedFile::getInstance($model, 'image') )) { |
| 210 | $imageModel = ProductImage::find() | 191 | $imageModel = ProductImage::find() |
| 211 | ->where([ 'product_variant_id' => $model->product_variant_id ]) | 192 | ->where([ 'product_variant_id' => $model->product_variant_id ]) |
| 212 | ->one(); | 193 | ->one(); |
| 213 | - | ||
| 214 | if($imageModel instanceof ProductImage) { | 194 | if($imageModel instanceof ProductImage) { |
| 215 | $imageModel->product_id = $model->product_id; | 195 | $imageModel->product_id = $model->product_id; |
| 216 | $imageModel->product_variant_id = $model->product_variant_id; | 196 | $imageModel->product_variant_id = $model->product_variant_id; |
| @@ -223,20 +203,14 @@ | @@ -223,20 +203,14 @@ | ||
| 223 | $imageModel->image = $image->name; | 203 | $imageModel->image = $image->name; |
| 224 | $imageModel->save(); | 204 | $imageModel->save(); |
| 225 | } | 205 | } |
| 226 | - | ||
| 227 | $imgDir = Yii::getAlias('@storage/products/'); | 206 | $imgDir = Yii::getAlias('@storage/products/'); |
| 228 | - | ||
| 229 | if(!is_dir($imgDir)) { | 207 | if(!is_dir($imgDir)) { |
| 230 | mkdir($imgDir, 0755, true); | 208 | mkdir($imgDir, 0755, true); |
| 231 | } | 209 | } |
| 232 | - | ||
| 233 | $image->saveAs(Yii::getAlias('@storage/products/' . $image->name)); | 210 | $image->saveAs(Yii::getAlias('@storage/products/' . $image->name)); |
| 234 | } | 211 | } |
| 235 | - | ||
| 236 | $ProductStocks = Yii::$app->request->post('ProductStock'); | 212 | $ProductStocks = Yii::$app->request->post('ProductStock'); |
| 237 | - | ||
| 238 | $total_quantity = 0; | 213 | $total_quantity = 0; |
| 239 | - | ||
| 240 | if(!empty( $ProductStocks ) && is_array($ProductStocks)) { | 214 | if(!empty( $ProductStocks ) && is_array($ProductStocks)) { |
| 241 | $model->unlinkAll('stocks', true); | 215 | $model->unlinkAll('stocks', true); |
| 242 | $sorted_array = []; | 216 | $sorted_array = []; |
| @@ -280,9 +254,8 @@ | @@ -280,9 +254,8 @@ | ||
| 280 | } else { | 254 | } else { |
| 281 | $model->unlinkAll('stocks', true); | 255 | $model->unlinkAll('stocks', true); |
| 282 | } | 256 | } |
| 283 | - | ||
| 284 | $model->stock = $total_quantity; | 257 | $model->stock = $total_quantity; |
| 285 | - if($model->save() && $model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 258 | + if($model->save() && $model->transactionStatus) { |
| 286 | return $this->redirect([ | 259 | return $this->redirect([ |
| 287 | 'index', | 260 | 'index', |
| 288 | 'product_id' => $product_id, | 261 | 'product_id' => $product_id, |
| @@ -291,20 +264,19 @@ | @@ -291,20 +264,19 @@ | ||
| 291 | } | 264 | } |
| 292 | } | 265 | } |
| 293 | $groups = $model->getTaxGroupsByLevel(1); | 266 | $groups = $model->getTaxGroupsByLevel(1); |
| 294 | - | ||
| 295 | return $this->render('update', [ | 267 | return $this->render('update', [ |
| 296 | 'model' => $model, | 268 | 'model' => $model, |
| 297 | - 'model_langs' => $model_langs, | 269 | + 'model_langs' => $model->model_langs, |
| 298 | 'groups' => $groups, | 270 | 'groups' => $groups, |
| 299 | 'stocks' => ( !empty( $model->variantStocks ) ) ? $model->variantStocks : [ new ProductStock ], | 271 | 'stocks' => ( !empty( $model->variantStocks ) ) ? $model->variantStocks : [ new ProductStock ], |
| 300 | ]); | 272 | ]); |
| 301 | - | ||
| 302 | } | 273 | } |
| 303 | 274 | ||
| 304 | /** | 275 | /** |
| 305 | * Deletes an existing ProductVariant model. | 276 | * Deletes an existing ProductVariant model. |
| 306 | * If deletion is successful, the browser will be redirected to the 'index' page. | 277 | * If deletion is successful, the browser will be redirected to the 'index' page. |
| 307 | * | 278 | * |
| 279 | + * @param integer $product_id | ||
| 308 | * @param integer $id | 280 | * @param integer $id |
| 309 | * | 281 | * |
| 310 | * @return mixed | 282 | * @return mixed |
common/modules/product/helpers/ProductHelper.php
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | public static function getCategories() | 20 | public static function getCategories() |
| 21 | { | 21 | { |
| 22 | return Category::find() | 22 | return Category::find() |
| 23 | - ->getTree(); | 23 | + ->getTree(null, 'lang'); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | public static function getBrands() | 26 | public static function getBrands() |
common/modules/product/models/Brand.php
| @@ -21,6 +21,8 @@ | @@ -21,6 +21,8 @@ | ||
| 21 | * @property BrandLang $object_lang | 21 | * @property BrandLang $object_lang |
| 22 | * @property string $ownerKey | 22 | * @property string $ownerKey |
| 23 | * @property string $langKey | 23 | * @property string $langKey |
| 24 | + * @property BrandLang[] $model_langs | ||
| 25 | + * @property bool $transactionStatus | ||
| 24 | * @method string getOwnerKey() | 26 | * @method string getOwnerKey() |
| 25 | * @method void setOwnerKey( string $value ) | 27 | * @method void setOwnerKey( string $value ) |
| 26 | * @method string getLangKey() | 28 | * @method string getLangKey() |
| @@ -28,12 +30,13 @@ | @@ -28,12 +30,13 @@ | ||
| 28 | * @method ActiveQuery getLangs() | 30 | * @method ActiveQuery getLangs() |
| 29 | * @method ActiveQuery getLang( integer $language_id ) | 31 | * @method ActiveQuery getLang( integer $language_id ) |
| 30 | * @method BrandLang[] generateLangs() | 32 | * @method BrandLang[] generateLangs() |
| 31 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 32 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 33 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 33 | + * @method void loadLangs( Request $request ) |
| 34 | + * @method bool linkLangs() | ||
| 35 | + * @method bool saveLangs() | ||
| 36 | + * @method bool getTransactionStatus() | ||
| 34 | * * End language behavior * | 37 | * * End language behavior * |
| 35 | */ | 38 | */ |
| 36 | - class Brand extends \yii\db\ActiveRecord | 39 | + class Brand extends ActiveRecord |
| 37 | { | 40 | { |
| 38 | 41 | ||
| 39 | public $_items_count = 0; | 42 | public $_items_count = 0; |
| @@ -83,8 +86,8 @@ | @@ -83,8 +86,8 @@ | ||
| 83 | public function attributeLabels() | 86 | public function attributeLabels() |
| 84 | { | 87 | { |
| 85 | return [ | 88 | return [ |
| 86 | - 'brand_id' => Yii::t('product', 'Brand ID'), | ||
| 87 | - 'image' => Yii::t('product', 'Image'), | 89 | + 'brand_id' => Yii::t('product', 'Brand ID'), |
| 90 | + 'image' => Yii::t('product', 'Image'), | ||
| 88 | ]; | 91 | ]; |
| 89 | } | 92 | } |
| 90 | 93 |
common/modules/product/models/Category.php
| @@ -4,7 +4,6 @@ | @@ -4,7 +4,6 @@ | ||
| 4 | 4 | ||
| 5 | use common\behaviors\SaveImgBehavior; | 5 | use common\behaviors\SaveImgBehavior; |
| 6 | use common\components\artboxtree\ArtboxTreeBehavior; | 6 | use common\components\artboxtree\ArtboxTreeBehavior; |
| 7 | - use common\components\artboxtree\ArtboxTreeHelper; | ||
| 8 | use common\modules\language\behaviors\LanguageBehavior; | 7 | use common\modules\language\behaviors\LanguageBehavior; |
| 9 | use common\modules\rubrication\models\TaxGroup; | 8 | use common\modules\rubrication\models\TaxGroup; |
| 10 | use Yii; | 9 | use Yii; |
| @@ -16,7 +15,7 @@ | @@ -16,7 +15,7 @@ | ||
| 16 | /** | 15 | /** |
| 17 | * This is the model class for table "category". | 16 | * This is the model class for table "category". |
| 18 | * @property integer $category_id | 17 | * @property integer $category_id |
| 19 | - * @property string $remote_id | 18 | + * @property integer $remote_id |
| 20 | * @property integer $parent_id | 19 | * @property integer $parent_id |
| 21 | * @property string $path | 20 | * @property string $path |
| 22 | * @property integer $depth | 21 | * @property integer $depth |
| @@ -28,6 +27,8 @@ | @@ -28,6 +27,8 @@ | ||
| 28 | * @property CategoryLang $object_lang | 27 | * @property CategoryLang $object_lang |
| 29 | * @property string $ownerKey | 28 | * @property string $ownerKey |
| 30 | * @property string $langKey | 29 | * @property string $langKey |
| 30 | + * @property CategoryLang[] $model_langs | ||
| 31 | + * @property bool $transactionStatus | ||
| 31 | * @method string getOwnerKey() | 32 | * @method string getOwnerKey() |
| 32 | * @method void setOwnerKey( string $value ) | 33 | * @method void setOwnerKey( string $value ) |
| 33 | * @method string getLangKey() | 34 | * @method string getLangKey() |
| @@ -35,15 +36,16 @@ | @@ -35,15 +36,16 @@ | ||
| 35 | * @method ActiveQuery getLangs() | 36 | * @method ActiveQuery getLangs() |
| 36 | * @method ActiveQuery getLang( integer $language_id ) | 37 | * @method ActiveQuery getLang( integer $language_id ) |
| 37 | * @method CategoryLang[] generateLangs() | 38 | * @method CategoryLang[] generateLangs() |
| 38 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 39 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 40 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 39 | + * @method void loadLangs( Request $request ) |
| 40 | + * @method bool linkLangs() | ||
| 41 | + * @method bool saveLangs() | ||
| 42 | + * @method bool getTransactionStatus() | ||
| 41 | * * End language behavior * | 43 | * * End language behavior * |
| 42 | * @property Product[] $products | 44 | * @property Product[] $products |
| 43 | * @property ProductUnit $productUnit | 45 | * @property ProductUnit $productUnit |
| 44 | * @property ProductCategory[] $productCategories | 46 | * @property ProductCategory[] $productCategories |
| 45 | */ | 47 | */ |
| 46 | - class Category extends \yii\db\ActiveRecord | 48 | + class Category extends ActiveRecord |
| 47 | { | 49 | { |
| 48 | 50 | ||
| 49 | public function behaviors() | 51 | public function behaviors() |
| @@ -160,18 +162,6 @@ | @@ -160,18 +162,6 @@ | ||
| 160 | ->andWhere([ 'level' => $level ]); | 162 | ->andWhere([ 'level' => $level ]); |
| 161 | } | 163 | } |
| 162 | 164 | ||
| 163 | - public function getRemote_category() | ||
| 164 | - { | ||
| 165 | - return ArtboxTreeHelper::getArrayField($this->remote_id); | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | - public function setRemote_category($value) | ||
| 169 | - { | ||
| 170 | - if(!empty( $value ) && is_array($value)) { | ||
| 171 | - $this->remote_id = ArtboxTreeHelper::setArrayField($value, false); | ||
| 172 | - } | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | public function beforeSave($insert) | 165 | public function beforeSave($insert) |
| 176 | { | 166 | { |
| 177 | if(parent::beforeSave($insert)) { | 167 | if(parent::beforeSave($insert)) { |
| @@ -227,14 +217,14 @@ | @@ -227,14 +217,14 @@ | ||
| 227 | 0, | 217 | 0, |
| 228 | ]); | 218 | ]); |
| 229 | $query3 = ( new Query() )->select([ | 219 | $query3 = ( new Query() )->select([ |
| 230 | - 'tax_option.*', | ||
| 231 | - 'tax_group.*', | ||
| 232 | - 'tax_option.alias as option_alias', | ||
| 233 | - 'tax_group.alias as group_alias', | ||
| 234 | - 'tax_option.value as value', | ||
| 235 | - 'tax_option.sort AS tax_option_sort', | ||
| 236 | - 'tax_group.sort AS tax_group_sort', | ||
| 237 | - ]) | 220 | + 'tax_option.*', |
| 221 | + 'tax_group.*', | ||
| 222 | + 'tax_option.alias as option_alias', | ||
| 223 | + 'tax_group.alias as group_alias', | ||
| 224 | + 'tax_option.value as value', | ||
| 225 | + 'tax_option.sort AS tax_option_sort', | ||
| 226 | + 'tax_group.sort AS tax_group_sort', | ||
| 227 | + ]) | ||
| 238 | ->from([ 'tax_option' ]) | 228 | ->from([ 'tax_option' ]) |
| 239 | ->where([ 'tax_option.tax_option_id' => $query1->union($query2) ]) | 229 | ->where([ 'tax_option.tax_option_id' => $query1->union($query2) ]) |
| 240 | ->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id') | 230 | ->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id') |
| @@ -257,12 +247,19 @@ | @@ -257,12 +247,19 @@ | ||
| 257 | ) | 247 | ) |
| 258 | ) | 248 | ) |
| 259 | AND tax_group.is_menu = TRUE AND tax_group_to_category.category_id = :category_id', [ | 249 | AND tax_group.is_menu = TRUE AND tax_group_to_category.category_id = :category_id', [ |
| 260 | - ':category_id' => $this->category_id, | ||
| 261 | - | ||
| 262 | - ]); | 250 | + ':category_id' => $this->category_id, |
| 251 | + | ||
| 252 | + ]); | ||
| 263 | return $command->queryAll(); | 253 | return $command->queryAll(); |
| 264 | } | 254 | } |
| 265 | 255 | ||
| 256 | + /** | ||
| 257 | + * @todo Write doc | ||
| 258 | + * | ||
| 259 | + * @param $value | ||
| 260 | + * | ||
| 261 | + * @return mixed | ||
| 262 | + */ | ||
| 266 | public function setTaxGroup($value) | 263 | public function setTaxGroup($value) |
| 267 | { | 264 | { |
| 268 | return $this->tax_group = $value; | 265 | return $this->tax_group = $value; |
common/modules/product/models/CategoryLang.php
| @@ -57,7 +57,7 @@ class CategoryLang extends \yii\db\ActiveRecord | @@ -57,7 +57,7 @@ class CategoryLang extends \yii\db\ActiveRecord | ||
| 57 | { | 57 | { |
| 58 | return [ | 58 | return [ |
| 59 | [['name'], 'required'], | 59 | [['name'], 'required'], |
| 60 | - [['seo_text'], 'string'], | 60 | + [['seo_text', 'alias'], 'string'], |
| 61 | [['name', 'meta_title', 'meta_robots', 'meta_desc', 'h1'], 'string', 'max' => 255], | 61 | [['name', 'meta_title', 'meta_robots', 'meta_desc', 'h1'], 'string', 'max' => 255], |
| 62 | [['category_id', 'language_id'], 'unique', 'targetAttribute' => ['category_id', 'language_id'], 'message' => 'The combination of Category ID and Language ID has already been taken.'], | 62 | [['category_id', 'language_id'], 'unique', 'targetAttribute' => ['category_id', 'language_id'], 'message' => 'The combination of Category ID and Language ID has already been taken.'], |
| 63 | [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'category_id']], | 63 | [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'category_id']], |
common/modules/product/models/CategorySearch.php
| @@ -71,14 +71,4 @@ class CategorySearch extends Category | @@ -71,14 +71,4 @@ class CategorySearch extends Category | ||
| 71 | 71 | ||
| 72 | return $dataProvider; | 72 | return $dataProvider; |
| 73 | } | 73 | } |
| 74 | - | ||
| 75 | - public static function findByRemoteID($id) { | ||
| 76 | - /** @var CategoryQuery $query */ | ||
| 77 | - $query = Category::find() | ||
| 78 | - ->andFilterWhere(['@>', 'remote_id', ArtboxTreeHelper::setArrayField($id)]); | ||
| 79 | - if (($model = $query->one()) !== null) { | ||
| 80 | - return $model; | ||
| 81 | - } | ||
| 82 | - return null; | ||
| 83 | - } | ||
| 84 | } | 74 | } |
common/modules/product/models/Export.php
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace common\modules\product\models; | 3 | namespace common\modules\product\models; |
| 4 | 4 | ||
| 5 | use common\modules\language\models\Language; | 5 | use common\modules\language\models\Language; |
| 6 | + use common\modules\rubrication\models\TaxOption; | ||
| 6 | use yii\base\Model; | 7 | use yii\base\Model; |
| 7 | 8 | ||
| 8 | class Export extends Model | 9 | class Export extends Model |
| @@ -44,7 +45,10 @@ | @@ -44,7 +45,10 @@ | ||
| 44 | 45 | ||
| 45 | $language = Language::findOne(\Yii::$app->session->get('export_lang', Language::getDefaultLanguage()->language_id)); | 46 | $language = Language::findOne(\Yii::$app->session->get('export_lang', Language::getDefaultLanguage()->language_id)); |
| 46 | Language::setCurrent($language->url); | 47 | Language::setCurrent($language->url); |
| 47 | - | 48 | + |
| 49 | + /** | ||
| 50 | + * @var Product[] $products | ||
| 51 | + */ | ||
| 48 | $products = Product::find() | 52 | $products = Product::find() |
| 49 | ->with('variantsWithFilters', 'brand.lang', 'categories.lang', 'filters') | 53 | ->with('variantsWithFilters', 'brand.lang', 'categories.lang', 'filters') |
| 50 | ->joinWith('lang', true, 'INNER JOIN') | 54 | ->joinWith('lang', true, 'INNER JOIN') |
| @@ -59,23 +63,26 @@ | @@ -59,23 +63,26 @@ | ||
| 59 | $filterString = $this->convertFilterToString($product->filters); | 63 | $filterString = $this->convertFilterToString($product->filters); |
| 60 | 64 | ||
| 61 | foreach($product->variantsWithFilters as $variant) { | 65 | foreach($product->variantsWithFilters as $variant) { |
| 66 | + /** | ||
| 67 | + * @var ProductVariant $variant | ||
| 68 | + */ | ||
| 62 | $color = $variant->lang->name; | 69 | $color = $variant->lang->name; |
| 63 | - $mods[] = $variant->sku . '=' . $this->convertFilterToString($variant->filters) . '=' . $color . '=' . ( ( !empty( $variant->image ) ) ? $variant->image->image : '' ) . '=' . $variant->stock; | 70 | + $mods[] = $variant->sku.$this->generateID($variant->remote_id) . '=' . $this->convertFilterToString($variant->filters) . '=' . $color . '=' . ( ( !empty( $variant->image ) ) ? $variant->image->image : '' ) . '=' . $variant->stock; |
| 64 | } | 71 | } |
| 65 | 72 | ||
| 66 | $fotos = []; | 73 | $fotos = []; |
| 67 | 74 | ||
| 68 | $categories = []; | 75 | $categories = []; |
| 69 | foreach($product->categories as $value) { | 76 | foreach($product->categories as $value) { |
| 70 | - $categories[] = $value->lang->name; | 77 | + $categories[] = $value->lang->name.$this->generateID($value->remote_id); |
| 71 | } | 78 | } |
| 72 | 79 | ||
| 73 | $categories = implode(',', $categories); | 80 | $categories = implode(',', $categories); |
| 74 | 81 | ||
| 75 | $list = [ | 82 | $list = [ |
| 76 | $categories, | 83 | $categories, |
| 77 | - ( ( !empty( $product->brand ) ) ? $product->brand->lang->name : '' ), | ||
| 78 | - $product->lang->name, | 84 | + ( ( !empty( $product->brand ) ) ? $product->brand->lang->name.$this->generateID($product->brand->remote_id) : '' ), |
| 85 | + $product->lang->name.$this->generateID($product->remote_id), | ||
| 79 | '', | 86 | '', |
| 80 | ( ( !empty( $product->lang->description ) ) ? $product->lang->description : '' ), | 87 | ( ( !empty( $product->lang->description ) ) ? $product->lang->description : '' ), |
| 81 | $filterString, | 88 | $filterString, |
| @@ -121,8 +128,11 @@ | @@ -121,8 +128,11 @@ | ||
| 121 | public function convertFilterToString($filters) | 128 | public function convertFilterToString($filters) |
| 122 | { | 129 | { |
| 123 | $fittersArray = []; | 130 | $fittersArray = []; |
| 131 | + /** | ||
| 132 | + * @var TaxOption[] $filters | ||
| 133 | + */ | ||
| 124 | foreach($filters as $filter) { | 134 | foreach($filters as $filter) { |
| 125 | - $fittersArray[ $filter->taxGroup->alias ][] = $filter->lang->value; | 135 | + $fittersArray[ $filter->taxGroup->lang->name.$this->generateID($filter->taxGroup->remote_id) ][] = $filter->lang->value.$this->generateID($filter->remote_id); |
| 126 | } | 136 | } |
| 127 | $filterString = []; | 137 | $filterString = []; |
| 128 | 138 | ||
| @@ -132,4 +142,8 @@ | @@ -132,4 +142,8 @@ | ||
| 132 | } | 142 | } |
| 133 | return implode('*', $filterString); | 143 | return implode('*', $filterString); |
| 134 | } | 144 | } |
| 145 | + | ||
| 146 | + private function generateID(string $id):string { | ||
| 147 | + return sprintf('(#%s#)', $id); | ||
| 148 | + } | ||
| 135 | } | 149 | } |
| 136 | \ No newline at end of file | 150 | \ No newline at end of file |
common/modules/product/models/Import.php
| @@ -352,10 +352,11 @@ | @@ -352,10 +352,11 @@ | ||
| 352 | if(!empty ( $data[ $i ] )) { | 352 | if(!empty ( $data[ $i ] )) { |
| 353 | $mod_arr = explode('=', $data[ $i ]); | 353 | $mod_arr = explode('=', $data[ $i ]); |
| 354 | $mod_art = $mod_arr[ 0 ]; | 354 | $mod_art = $mod_arr[ 0 ]; |
| 355 | + $mod_art_parsed = $this->parseName($mod_art); | ||
| 355 | $variant_filters = explode('*', $mod_arr[ 1 ]); | 356 | $variant_filters = explode('*', $mod_arr[ 1 ]); |
| 356 | $mod_name = $mod_arr[ 2 ]; | 357 | $mod_name = $mod_arr[ 2 ]; |
| 357 | if(empty( $mod_name )) { | 358 | if(empty( $mod_name )) { |
| 358 | - $mod_name = $mod_art; | 359 | + $mod_name = $mod_art_parsed['name']; |
| 359 | } | 360 | } |
| 360 | $mod_image = $mod_arr[ 3 ]; | 361 | $mod_image = $mod_arr[ 3 ]; |
| 361 | $mod_stock = isset( $mod_arr[ 4 ] ) ? $mod_arr[ 4 ] : 1; | 362 | $mod_stock = isset( $mod_arr[ 4 ] ) ? $mod_arr[ 4 ] : 1; |
| @@ -367,12 +368,15 @@ | @@ -367,12 +368,15 @@ | ||
| 367 | */ | 368 | */ |
| 368 | if(( $_productVariant = ProductVariant::find() | 369 | if(( $_productVariant = ProductVariant::find() |
| 369 | ->joinWith('lang') | 370 | ->joinWith('lang') |
| 370 | - ->andFilterWhere([ 'sku' => $mod_art ]) | 371 | + ->andFilterWhere([ 'remote_id' => $mod_art_parsed['remote_id'] ]) |
| 371 | ->andFilterWhere([ 'product_variant.product_id' => $product_id ]) | 372 | ->andFilterWhere([ 'product_variant.product_id' => $product_id ]) |
| 372 | ->one() ) === NULL | 373 | ->one() ) === NULL |
| 373 | ) { | 374 | ) { |
| 374 | $_productVariant = new ProductVariant(); | 375 | $_productVariant = new ProductVariant(); |
| 375 | $_productVariant->product_id = $product_id; | 376 | $_productVariant->product_id = $product_id; |
| 377 | + if(!empty($mod_art_parsed['remote_id'])) { | ||
| 378 | + $_productVariant->remote_id = $mod_art_parsed['remote_id']; | ||
| 379 | + } | ||
| 376 | $_productVariant->generateLangs(); | 380 | $_productVariant->generateLangs(); |
| 377 | $product_variant_langs = $_productVariant->model_langs; | 381 | $product_variant_langs = $_productVariant->model_langs; |
| 378 | foreach($product_variant_langs as $product_variant_lang) { | 382 | foreach($product_variant_langs as $product_variant_lang) { |
| @@ -387,7 +391,7 @@ | @@ -387,7 +391,7 @@ | ||
| 387 | } | 391 | } |
| 388 | } | 392 | } |
| 389 | $_productVariant->product_unit_id = 1; | 393 | $_productVariant->product_unit_id = 1; |
| 390 | - $_productVariant->sku = $mod_art; | 394 | + $_productVariant->sku = $mod_art_parsed['name']; |
| 391 | $_productVariant->price = $mod_cost; | 395 | $_productVariant->price = $mod_cost; |
| 392 | $_productVariant->price_old = $mod_old_cost; | 396 | $_productVariant->price_old = $mod_old_cost; |
| 393 | $_productVariant->stock = $mod_stock; | 397 | $_productVariant->stock = $mod_stock; |
common/modules/product/models/Product.php
| @@ -39,21 +39,24 @@ | @@ -39,21 +39,24 @@ | ||
| 39 | * @property ProductSpec $productSpec | 39 | * @property ProductSpec $productSpec |
| 40 | * @property ProductCertificate[] $productCertificates | 40 | * @property ProductCertificate[] $productCertificates |
| 41 | * * From language behavior * | 41 | * * From language behavior * |
| 42 | - * @property ProductLang $lang | ||
| 43 | - * @property ProductLang[] $langs | ||
| 44 | - * @property ProductLang $object_lang | ||
| 45 | - * @property string $ownerKey | ||
| 46 | - * @property string $langKey | 42 | + * @property ProductLang $lang |
| 43 | + * @property ProductLang[] $langs | ||
| 44 | + * @property ProductLang $object_lang | ||
| 45 | + * @property string $ownerKey | ||
| 46 | + * @property string $langKey | ||
| 47 | + * @property ProductLang[] $model_langs | ||
| 48 | + * @property bool $transactionStatus | ||
| 47 | * @method string getOwnerKey() | 49 | * @method string getOwnerKey() |
| 48 | - * @method void setOwnerKey( string $value ) | 50 | + * @method void setOwnerKey(string $value) |
| 49 | * @method string getLangKey() | 51 | * @method string getLangKey() |
| 50 | - * @method void setLangKey( string $value ) | 52 | + * @method void setLangKey(string $value) |
| 51 | * @method ActiveQuery getLangs() | 53 | * @method ActiveQuery getLangs() |
| 52 | * @method ActiveQuery getLang( integer $language_id ) | 54 | * @method ActiveQuery getLang( integer $language_id ) |
| 53 | * @method ProductLang[] generateLangs() | 55 | * @method ProductLang[] generateLangs() |
| 54 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 55 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 56 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 56 | + * @method void loadLangs(Request $request) |
| 57 | + * @method bool linkLangs() | ||
| 58 | + * @method bool saveLangs() | ||
| 59 | + * @method bool getTransactionStatus() | ||
| 57 | * * End language behavior * | 60 | * * End language behavior * |
| 58 | */ | 61 | */ |
| 59 | class Product extends \yii\db\ActiveRecord | 62 | class Product extends \yii\db\ActiveRecord |
common/modules/product/models/ProductSearch.php
| @@ -110,14 +110,4 @@ class ProductSearch extends Product | @@ -110,14 +110,4 @@ class ProductSearch extends Product | ||
| 110 | 110 | ||
| 111 | return $dataProvider; | 111 | return $dataProvider; |
| 112 | } | 112 | } |
| 113 | - | ||
| 114 | - public static function findByRemoteID($id) { | ||
| 115 | - /** @var CategoryQuery $query */ | ||
| 116 | - $query = Product::find() | ||
| 117 | - ->andFilterWhere(['remote_id' => $id]); | ||
| 118 | - if (($model = $query->one()) !== null) { | ||
| 119 | - return $model; | ||
| 120 | - } | ||
| 121 | - return null; | ||
| 122 | - } | ||
| 123 | } | 113 | } |
common/modules/product/models/ProductUnit.php
| 1 | <?php | 1 | <?php |
| 2 | - | ||
| 3 | -namespace common\modules\product\models; | ||
| 4 | - | ||
| 5 | -use common\modules\language\behaviors\LanguageBehavior; | ||
| 6 | -use Yii; | ||
| 7 | -use yii\db\ActiveQuery; | ||
| 8 | -use yii\db\ActiveRecord; | ||
| 9 | -use yii\web\Request; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * This is the model class for table "product_unit". | ||
| 13 | - * | ||
| 14 | - * @property integer $product_unit_id | ||
| 15 | - * @property boolean $is_default | ||
| 16 | - * | ||
| 17 | - * @property Category[] $categories | ||
| 18 | - * @property ProductVariant[] $productVariants | ||
| 19 | - * | ||
| 20 | - * * From language behavior * | ||
| 21 | - * @property ProductUnitLang $lang | ||
| 22 | - * @property ProductUnitLang[] $langs | ||
| 23 | - * @property ProductUnitLang $object_lang | ||
| 24 | - * @property string $ownerKey | ||
| 25 | - * @property string $langKey | ||
| 26 | - * @method string getOwnerKey() | ||
| 27 | - * @method void setOwnerKey(string $value) | ||
| 28 | - * @method string getLangKey() | ||
| 29 | - * @method void setLangKey(string $value) | ||
| 30 | - * @method ActiveQuery getLangs() | ||
| 31 | - * @method ActiveQuery getLang( integer $language_id ) | ||
| 32 | - * @method ProductUnitLang[] generateLangs() | ||
| 33 | - * @method void loadLangs(Request $request, ActiveRecord[] $model_langs) | ||
| 34 | - * @method bool linkLangs(ActiveRecord[] $model_langs) | ||
| 35 | - * @method bool saveLangs(ActiveRecord[] $model_langs) | ||
| 36 | - * * End language behavior * | ||
| 37 | - */ | ||
| 38 | -class ProductUnit extends \yii\db\ActiveRecord | ||
| 39 | -{ | ||
| 40 | - /** | ||
| 41 | - * @inheritdoc | ||
| 42 | - */ | ||
| 43 | - public static function tableName() | ||
| 44 | - { | ||
| 45 | - return 'product_unit'; | ||
| 46 | - } | ||
| 47 | 2 | ||
| 48 | - public function behaviors() | ||
| 49 | - { | ||
| 50 | - return [ | ||
| 51 | - 'language' => [ | ||
| 52 | - 'class' => LanguageBehavior::className(), | ||
| 53 | - ], | ||
| 54 | - ]; | ||
| 55 | - } | 3 | + namespace common\modules\product\models; |
| 4 | + | ||
| 5 | + use common\modules\language\behaviors\LanguageBehavior; | ||
| 6 | + use Yii; | ||
| 7 | + use yii\db\ActiveQuery; | ||
| 8 | + use yii\db\ActiveRecord; | ||
| 9 | + use yii\web\Request; | ||
| 56 | 10 | ||
| 57 | /** | 11 | /** |
| 58 | - * @inheritdoc | ||
| 59 | - */ | ||
| 60 | - public function rules() | ||
| 61 | - { | ||
| 62 | - return [ | ||
| 63 | - [['is_default'], 'boolean'], | ||
| 64 | - ]; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - /** | ||
| 68 | - * @inheritdoc | ||
| 69 | - */ | ||
| 70 | - public function attributeLabels() | ||
| 71 | - { | ||
| 72 | - return [ | ||
| 73 | - 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | ||
| 74 | - 'is_default' => Yii::t('product', 'Is Default'), | ||
| 75 | - ]; | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - /** | ||
| 79 | - * @return \yii\db\ActiveQuery | ||
| 80 | - */ | ||
| 81 | - public function getCategories() | ||
| 82 | - { | ||
| 83 | - return $this->hasMany(Category::className(), ['product_unit_id' => 'product_unit_id']); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - /** | ||
| 87 | - * @return \yii\db\ActiveQuery | 12 | + * This is the model class for table "product_unit". |
| 13 | + * @property integer $product_unit_id | ||
| 14 | + * @property boolean $is_default | ||
| 15 | + * @property Category[] $categories | ||
| 16 | + * @property ProductVariant[] $productVariants | ||
| 17 | + * * From language behavior * | ||
| 18 | + * @property ProductUnitLang $lang | ||
| 19 | + * @property ProductUnitLang[] $langs | ||
| 20 | + * @property ProductUnitLang $object_lang | ||
| 21 | + * @property string $ownerKey | ||
| 22 | + * @property string $langKey | ||
| 23 | + * @property ProductUnitLang[] $model_langs | ||
| 24 | + * @property bool $transactionStatus | ||
| 25 | + * @method string getOwnerKey() | ||
| 26 | + * @method void setOwnerKey( string $value ) | ||
| 27 | + * @method string getLangKey() | ||
| 28 | + * @method void setLangKey( string $value ) | ||
| 29 | + * @method ActiveQuery getLangs() | ||
| 30 | + * @method ActiveQuery getLang( integer $language_id ) | ||
| 31 | + * @method ProductUnitLang[] generateLangs() | ||
| 32 | + * @method void loadLangs( Request $request ) | ||
| 33 | + * @method bool linkLangs() | ||
| 34 | + * @method bool saveLangs() | ||
| 35 | + * @method bool getTransactionStatus() | ||
| 36 | + * * End language behavior * | ||
| 88 | */ | 37 | */ |
| 89 | - public function getProductVariants() | 38 | + class ProductUnit extends ActiveRecord |
| 90 | { | 39 | { |
| 91 | - return $this->hasMany(ProductVariant::className(), ['product_unit_id' => 'product_unit_id']); | 40 | + |
| 41 | + /** | ||
| 42 | + * @inheritdoc | ||
| 43 | + */ | ||
| 44 | + public static function tableName() | ||
| 45 | + { | ||
| 46 | + return 'product_unit'; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public function behaviors() | ||
| 50 | + { | ||
| 51 | + return [ | ||
| 52 | + 'language' => [ | ||
| 53 | + 'class' => LanguageBehavior::className(), | ||
| 54 | + ], | ||
| 55 | + ]; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @inheritdoc | ||
| 60 | + */ | ||
| 61 | + public function rules() | ||
| 62 | + { | ||
| 63 | + return [ | ||
| 64 | + [ | ||
| 65 | + [ 'is_default' ], | ||
| 66 | + 'boolean', | ||
| 67 | + ], | ||
| 68 | + ]; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * @inheritdoc | ||
| 73 | + */ | ||
| 74 | + public function attributeLabels() | ||
| 75 | + { | ||
| 76 | + return [ | ||
| 77 | + 'product_unit_id' => Yii::t('product', 'Product Unit ID'), | ||
| 78 | + 'is_default' => Yii::t('product', 'Is Default'), | ||
| 79 | + ]; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * @return \yii\db\ActiveQuery | ||
| 84 | + */ | ||
| 85 | + public function getCategories() | ||
| 86 | + { | ||
| 87 | + return $this->hasMany(Category::className(), [ 'product_unit_id' => 'product_unit_id' ]); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * @return \yii\db\ActiveQuery | ||
| 92 | + */ | ||
| 93 | + public function getProductVariants() | ||
| 94 | + { | ||
| 95 | + return $this->hasMany(ProductVariant::className(), [ 'product_unit_id' => 'product_unit_id' ]); | ||
| 96 | + } | ||
| 92 | } | 97 | } |
| 93 | -} |
common/modules/product/models/ProductVariant.php
| @@ -13,9 +13,10 @@ | @@ -13,9 +13,10 @@ | ||
| 13 | 13 | ||
| 14 | /** | 14 | /** |
| 15 | * This is the model class for table "product_variant". | 15 | * This is the model class for table "product_variant". |
| 16 | + * @todo Refactor | ||
| 16 | * @property integer $product_variant_id | 17 | * @property integer $product_variant_id |
| 17 | * @property integer $product_id | 18 | * @property integer $product_id |
| 18 | - * @property string $remote_id | 19 | + * @property integer $remote_id |
| 19 | * @property string $sku | 20 | * @property string $sku |
| 20 | * @property double $price | 21 | * @property double $price |
| 21 | * @property double $price_old | 22 | * @property double $price_old |
| @@ -32,6 +33,8 @@ | @@ -32,6 +33,8 @@ | ||
| 32 | * @property ProductVariantLang $object_lang | 33 | * @property ProductVariantLang $object_lang |
| 33 | * @property string $ownerKey | 34 | * @property string $ownerKey |
| 34 | * @property string $langKey | 35 | * @property string $langKey |
| 36 | + * @property ProductVariantLang[] $model_langs | ||
| 37 | + * @property bool $transactionStatus | ||
| 35 | * @method string getOwnerKey() | 38 | * @method string getOwnerKey() |
| 36 | * @method void setOwnerKey( string $value ) | 39 | * @method void setOwnerKey( string $value ) |
| 37 | * @method string getLangKey() | 40 | * @method string getLangKey() |
| @@ -39,18 +42,21 @@ | @@ -39,18 +42,21 @@ | ||
| 39 | * @method ActiveQuery getLangs() | 42 | * @method ActiveQuery getLangs() |
| 40 | * @method ActiveQuery getLang( integer $language_id ) | 43 | * @method ActiveQuery getLang( integer $language_id ) |
| 41 | * @method ProductVariantLang[] generateLangs() | 44 | * @method ProductVariantLang[] generateLangs() |
| 42 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 43 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 44 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 45 | + * @method void loadLangs( Request $request ) |
| 46 | + * @method bool linkLangs() | ||
| 47 | + * @method bool saveLangs() | ||
| 48 | + * @method bool getTransactionStatus() | ||
| 45 | * * End language behavior * | 49 | * * End language behavior * |
| 46 | */ | 50 | */ |
| 47 | - class ProductVariant extends \yii\db\ActiveRecord | 51 | + class ProductVariant extends ActiveRecord |
| 48 | { | 52 | { |
| 49 | 53 | ||
| 50 | public $sum_cost; | 54 | public $sum_cost; |
| 51 | 55 | ||
| 52 | public $product_name; | 56 | public $product_name; |
| 53 | 57 | ||
| 58 | + private $_options; | ||
| 59 | + | ||
| 54 | /** @var array $_images */ | 60 | /** @var array $_images */ |
| 55 | public $imagesUpload = ''; | 61 | public $imagesUpload = ''; |
| 56 | 62 | ||
| @@ -107,11 +113,6 @@ | @@ -107,11 +113,6 @@ | ||
| 107 | 'max' => 255, | 113 | 'max' => 255, |
| 108 | ], | 114 | ], |
| 109 | [ | 115 | [ |
| 110 | - [ 'remote_id' ], | ||
| 111 | - 'string', | ||
| 112 | - 'max' => 20, | ||
| 113 | - ], | ||
| 114 | - [ | ||
| 115 | [ | 116 | [ |
| 116 | 'options', | 117 | 'options', |
| 117 | 'imagesUpload', | 118 | 'imagesUpload', |
| @@ -269,7 +270,7 @@ | @@ -269,7 +270,7 @@ | ||
| 269 | 270 | ||
| 270 | public function setOptions($values) | 271 | public function setOptions($values) |
| 271 | { | 272 | { |
| 272 | - $this->options = $values; | 273 | + $this->_options = $values; |
| 273 | } | 274 | } |
| 274 | 275 | ||
| 275 | public function getOptions() | 276 | public function getOptions() |
| @@ -333,29 +334,32 @@ | @@ -333,29 +334,32 @@ | ||
| 333 | ->where([ 'tax_group_to_category.category_id' => $categories ]) | 334 | ->where([ 'tax_group_to_category.category_id' => $categories ]) |
| 334 | ->where([ 'level' => $level ]); | 335 | ->where([ 'level' => $level ]); |
| 335 | } | 336 | } |
| 336 | - | 337 | + |
| 337 | public function afterSave($insert, $changedAttributes) | 338 | public function afterSave($insert, $changedAttributes) |
| 338 | { | 339 | { |
| 339 | - | ||
| 340 | - if(!empty($this->_options)){ | 340 | + parent::afterSave($insert, $changedAttributes); |
| 341 | + if(!empty( $this->_options )) { | ||
| 341 | $options = TaxOption::findAll($this->_options); | 342 | $options = TaxOption::findAll($this->_options); |
| 342 | - $this->unlinkAll('options',true); | ||
| 343 | - foreach($options as $option){ | 343 | + $this->unlinkAll('options', true); |
| 344 | + foreach($options as $option) { | ||
| 344 | $this->link('options', $option); | 345 | $this->link('options', $option); |
| 345 | } | 346 | } |
| 346 | } | 347 | } |
| 347 | - | ||
| 348 | - | ||
| 349 | - if (!empty($this->stocks)) { | ||
| 350 | - ProductStock::deleteAll(['product_variant_id' => $this->product_variant_id]); | 348 | + |
| 349 | + if(!empty( $this->stocks )) { | ||
| 350 | + ProductStock::deleteAll([ 'product_variant_id' => $this->product_variant_id ]); | ||
| 351 | $values = []; | 351 | $values = []; |
| 352 | - foreach ($this->stocks as $id => $quantity) { | ||
| 353 | - $productStock = ProductStock::find()->where(['product_variant_id' => $this->product_variant_id, 'stock_id' => $id])->one(); | 352 | + foreach($this->stocks as $id => $quantity) { |
| 353 | + $productStock = ProductStock::find() | ||
| 354 | + ->where([ | ||
| 355 | + 'product_variant_id' => $this->product_variant_id, | ||
| 356 | + 'stock_id' => $id, | ||
| 357 | + ]) | ||
| 358 | + ->one(); | ||
| 354 | $productStock->quantity = $quantity; | 359 | $productStock->quantity = $quantity; |
| 355 | $productStock->save(); | 360 | $productStock->save(); |
| 356 | } | 361 | } |
| 357 | } | 362 | } |
| 358 | - parent::afterSave($insert, $changedAttributes); | ||
| 359 | } | 363 | } |
| 360 | 364 | ||
| 361 | public function imagesUpload() | 365 | public function imagesUpload() |
common/modules/product/models/ProductVariantListSearch.php
| @@ -34,7 +34,6 @@ | @@ -34,7 +34,6 @@ | ||
| 34 | [ | 34 | [ |
| 35 | [ | 35 | [ |
| 36 | 'sku', | 36 | 'sku', |
| 37 | - 'remote_id', | ||
| 38 | ], | 37 | ], |
| 39 | 'safe', | 38 | 'safe', |
| 40 | ], | 39 | ], |
| @@ -102,12 +101,7 @@ | @@ -102,12 +101,7 @@ | ||
| 102 | 'like', | 101 | 'like', |
| 103 | 'sku', | 102 | 'sku', |
| 104 | $this->sku, | 103 | $this->sku, |
| 105 | - ]) | ||
| 106 | - ->andFilterWhere([ | ||
| 107 | - 'like', | ||
| 108 | - 'remote_id', | ||
| 109 | - $this->remote_id, | ||
| 110 | - ]); | 104 | + ]); |
| 111 | 105 | ||
| 112 | return $dataProvider; | 106 | return $dataProvider; |
| 113 | } | 107 | } |
common/modules/product/models/ProductVariantSearch.php
| @@ -138,14 +138,4 @@ class ProductVariantSearch extends ProductVariant | @@ -138,14 +138,4 @@ class ProductVariantSearch extends ProductVariant | ||
| 138 | } | 138 | } |
| 139 | return NULL; | 139 | return NULL; |
| 140 | } | 140 | } |
| 141 | - | ||
| 142 | - public static function findByRemoteID($id) { | ||
| 143 | - /** @var CategoryQuery $query */ | ||
| 144 | - $query = ProductVariant::find() | ||
| 145 | - ->andFilterWhere(['remote_id' => $id]); | ||
| 146 | - if (($model = $query->one()) !== null) { | ||
| 147 | - return $model; | ||
| 148 | - } | ||
| 149 | - return NULL; | ||
| 150 | - } | ||
| 151 | } | 141 | } |
common/modules/product/views/manage/_form.php
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | use common\models\ProductSpecLang; | 4 | use common\models\ProductSpecLang; |
| 5 | use common\modules\language\widgets\LanguageForm; | 5 | use common\modules\language\widgets\LanguageForm; |
| 6 | use common\modules\product\models\ProductLang; | 6 | use common\modules\product\models\ProductLang; |
| 7 | + use common\modules\rubrication\models\TaxGroup; | ||
| 7 | use yii\db\ActiveQuery; | 8 | use yii\db\ActiveQuery; |
| 8 | use yii\helpers\Html; | 9 | use yii\helpers\Html; |
| 9 | use yii\widgets\ActiveForm; | 10 | use yii\widgets\ActiveForm; |
| @@ -41,13 +42,14 @@ | @@ -41,13 +42,14 @@ | ||
| 41 | 42 | ||
| 42 | <?= $form->field($model, 'brand_id') | 43 | <?= $form->field($model, 'brand_id') |
| 43 | ->dropDownList(ArrayHelper::map(ProductHelper::getBrands() | 44 | ->dropDownList(ArrayHelper::map(ProductHelper::getBrands() |
| 44 | - ->all(), 'brand_id', 'brand_id'), [ | 45 | + ->with('lang') |
| 46 | + ->all(), 'brand_id', 'lang.name'), [ | ||
| 45 | 'prompt' => Yii::t('product', 'Select brand'), | 47 | 'prompt' => Yii::t('product', 'Select brand'), |
| 46 | ]) ?> | 48 | ]) ?> |
| 47 | 49 | ||
| 48 | <?= $form->field($model, 'categories') | 50 | <?= $form->field($model, 'categories') |
| 49 | ->widget(Select2::className(), [ | 51 | ->widget(Select2::className(), [ |
| 50 | - 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'category_id'), | 52 | + 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'lang.name'), |
| 51 | 'language' => 'ru', | 53 | 'language' => 'ru', |
| 52 | 'options' => [ | 54 | 'options' => [ |
| 53 | 'placeholder' => Yii::t('product', 'Select categories'), | 55 | 'placeholder' => Yii::t('product', 'Select categories'), |
| @@ -110,16 +112,20 @@ | @@ -110,16 +112,20 @@ | ||
| 110 | ], | 112 | ], |
| 111 | ]); ?> | 113 | ]); ?> |
| 112 | 114 | ||
| 113 | - <?php if(isset( $groups )) : ?> | ||
| 114 | - <?php foreach($groups->all() as $group) : ?> | ||
| 115 | - <?= $form->field($model, 'options') | ||
| 116 | - ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'tax_option_id'), [ | 115 | + <?php if(!empty( $groups )) { |
| 116 | + foreach($groups->with('lang')->all() as $group) { | ||
| 117 | + /** | ||
| 118 | + * @var TaxGroup $group | ||
| 119 | + */ | ||
| 120 | + echo $form->field($model, 'options') | ||
| 121 | + ->checkboxList(ArrayHelper::map($group->getOptions()->with('lang')->all(), 'tax_option_id', 'lang.value'), [ | ||
| 117 | 'multiple' => true, | 122 | 'multiple' => true, |
| 118 | 'unselect' => NULL, | 123 | 'unselect' => NULL, |
| 119 | ]) | 124 | ]) |
| 120 | - ->label($group->tax_group_id); ?> | ||
| 121 | - <?php endforeach ?> | ||
| 122 | - <?php endif ?> | 125 | + ->label($group->lang->name); |
| 126 | + } | ||
| 127 | + } | ||
| 128 | + ?> | ||
| 123 | 129 | ||
| 124 | <hr> | 130 | <hr> |
| 125 | 131 |
common/modules/product/views/variant/_form.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | use common\modules\language\widgets\LanguageForm; | 3 | use common\modules\language\widgets\LanguageForm; |
| 4 | use common\modules\product\models\ProductStock; | 4 | use common\modules\product\models\ProductStock; |
| 5 | + use common\modules\product\models\ProductUnit; | ||
| 5 | use common\modules\product\models\ProductVariant; | 6 | use common\modules\product\models\ProductVariant; |
| 6 | use common\modules\product\models\ProductVariantLang; | 7 | use common\modules\product\models\ProductVariantLang; |
| 7 | use yii\db\ActiveQuery; | 8 | use yii\db\ActiveQuery; |
| @@ -145,22 +146,26 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { | @@ -145,22 +146,26 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { | ||
| 145 | <?php DynamicFormWidget::end(); ?> | 146 | <?php DynamicFormWidget::end(); ?> |
| 146 | 147 | ||
| 147 | <?= $form->field($model, 'product_unit_id') | 148 | <?= $form->field($model, 'product_unit_id') |
| 148 | - ->dropDownList(ArrayHelper::map(\common\modules\product\models\ProductUnit::find() | ||
| 149 | - ->all(), 'product_unit_id', 'product_unit_id'), [ | 149 | + ->dropDownList(ArrayHelper::map(ProductUnit::find() |
| 150 | + ->with('lang') | ||
| 151 | + ->all(), 'product_unit_id', 'lang.name'), [ | ||
| 150 | 'prompt' => Yii::t('product', 'Unit'), | 152 | 'prompt' => Yii::t('product', 'Unit'), |
| 151 | ]) | 153 | ]) |
| 152 | ->label(Yii::t('product', 'Unit')) ?> | 154 | ->label(Yii::t('product', 'Unit')) ?> |
| 153 | 155 | ||
| 154 | - <?php if(isset( $groups )) : ?> | ||
| 155 | - <?php foreach($groups->all() as $group) : ?> | ||
| 156 | - <?= $form->field($model, 'options') | ||
| 157 | - ->checkboxList(ArrayHelper::map($group->options, 'tax_option_id', 'tax_option_id'), [ | ||
| 158 | - 'multiple' => true, | ||
| 159 | - 'unselect' => NULL, | ||
| 160 | - ]) | ||
| 161 | - ->label($group->tax_group_id); ?> | ||
| 162 | - <?php endforeach ?> | ||
| 163 | - <?php endif ?> | 156 | + <?php if(!empty( $groups )) { |
| 157 | + foreach($groups->with('lang') | ||
| 158 | + ->all() as $group) { | ||
| 159 | + echo $form->field($model, 'options') | ||
| 160 | + ->checkboxList(ArrayHelper::map($group->getOptions() | ||
| 161 | + ->with('lang') | ||
| 162 | + ->all(), 'tax_option_id', 'lang.value'), [ | ||
| 163 | + 'multiple' => true, | ||
| 164 | + 'unselect' => NULL, | ||
| 165 | + ]) | ||
| 166 | + ->label($group->lang->name); | ||
| 167 | + } | ||
| 168 | + } ?> | ||
| 164 | 169 | ||
| 165 | <div class="form-group"> | 170 | <div class="form-group"> |
| 166 | <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?> | 171 | <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?> |
common/modules/rubrication/controllers/TaxGroupController.php
| @@ -76,12 +76,11 @@ | @@ -76,12 +76,11 @@ | ||
| 76 | public function actionCreate($level) | 76 | public function actionCreate($level) |
| 77 | { | 77 | { |
| 78 | $model = new TaxGroup(); | 78 | $model = new TaxGroup(); |
| 79 | - $model_langs = $model->generateLangs(); | ||
| 80 | - | 79 | + $model->generateLangs(); |
| 81 | if($model->load(Yii::$app->request->post()) && $model->validate()) { | 80 | if($model->load(Yii::$app->request->post()) && $model->validate()) { |
| 82 | - $model->loadLangs(\Yii::$app->request, $model_langs); | 81 | + $model->loadLangs(\Yii::$app->request); |
| 83 | $model->level = $level; | 82 | $model->level = $level; |
| 84 | - if($model->save() && $model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 83 | + if($model->save() && $model->transactionStatus) { |
| 85 | return $this->redirect([ | 84 | return $this->redirect([ |
| 86 | 'index', | 85 | 'index', |
| 87 | 'level' => $level, | 86 | 'level' => $level, |
| @@ -90,7 +89,7 @@ | @@ -90,7 +89,7 @@ | ||
| 90 | } | 89 | } |
| 91 | return $this->render('create', [ | 90 | return $this->render('create', [ |
| 92 | 'model' => $model, | 91 | 'model' => $model, |
| 93 | - 'model_langs' => $model_langs, | 92 | + 'model_langs' => $model->model_langs, |
| 94 | ]); | 93 | ]); |
| 95 | } | 94 | } |
| 96 | 95 | ||
| @@ -106,11 +105,10 @@ | @@ -106,11 +105,10 @@ | ||
| 106 | public function actionUpdate($level, $id) | 105 | public function actionUpdate($level, $id) |
| 107 | { | 106 | { |
| 108 | $model = $this->findModel($id); | 107 | $model = $this->findModel($id); |
| 109 | - $model_langs = $model->generateLangs(); | ||
| 110 | - | 108 | + $model->generateLangs(); |
| 111 | if($model->load(Yii::$app->request->post())) { | 109 | if($model->load(Yii::$app->request->post())) { |
| 112 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 113 | - if($model->save() && $model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 110 | + $model->loadLangs(\Yii::$app->request); |
| 111 | + if($model->save() && $model->transactionStatus) { | ||
| 114 | return $this->redirect([ | 112 | return $this->redirect([ |
| 115 | 'index', | 113 | 'index', |
| 116 | 'level' => $level, | 114 | 'level' => $level, |
| @@ -119,7 +117,7 @@ | @@ -119,7 +117,7 @@ | ||
| 119 | } | 117 | } |
| 120 | return $this->render('update', [ | 118 | return $this->render('update', [ |
| 121 | 'model' => $model, | 119 | 'model' => $model, |
| 122 | - 'model_langs' => $model_langs, | 120 | + 'model_langs' => $model->model_langs, |
| 123 | ]); | 121 | ]); |
| 124 | } | 122 | } |
| 125 | 123 | ||
| @@ -149,7 +147,6 @@ | @@ -149,7 +147,6 @@ | ||
| 149 | { | 147 | { |
| 150 | TaxOption::find() | 148 | TaxOption::find() |
| 151 | ->rebuildMP($id); | 149 | ->rebuildMP($id); |
| 152 | - | ||
| 153 | return $this->redirect([ 'index' ]); | 150 | return $this->redirect([ 'index' ]); |
| 154 | } | 151 | } |
| 155 | 152 |
common/modules/rubrication/controllers/TaxOptionController.php
| @@ -74,24 +74,16 @@ | @@ -74,24 +74,16 @@ | ||
| 74 | public function actionCreate() | 74 | public function actionCreate() |
| 75 | { | 75 | { |
| 76 | $model = new TaxOption(); | 76 | $model = new TaxOption(); |
| 77 | - $model_langs = $model->generateLangs(); | 77 | + $model->generateLangs(); |
| 78 | $group = TaxGroup::findOne(Yii::$app->request->queryParams[ 'group' ]); | 78 | $group = TaxGroup::findOne(Yii::$app->request->queryParams[ 'group' ]); |
| 79 | - | ||
| 80 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 81 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 82 | - | ||
| 83 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 79 | + if($model->load(Yii::$app->request->post())) { |
| 80 | + $model->loadLangs(\Yii::$app->request); | ||
| 81 | + if($model->save() && $model->transactionStatus) { | ||
| 84 | return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ | 82 | return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect([ |
| 85 | 'view', | 83 | 'view', |
| 86 | 'id' => $model->tax_option_id, | 84 | 'id' => $model->tax_option_id, |
| 87 | ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); | 85 | ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); |
| 88 | - } else { | ||
| 89 | - return $this->redirect([ | ||
| 90 | - 'update', | ||
| 91 | - 'id' => $model->tax_option_id, | ||
| 92 | - ]); | ||
| 93 | } | 86 | } |
| 94 | - | ||
| 95 | } | 87 | } |
| 96 | $model->tax_group_id = $group->tax_group_id; | 88 | $model->tax_group_id = $group->tax_group_id; |
| 97 | if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) { | 89 | if(!empty( Yii::$app->request->queryParams[ 'parent' ] )) { |
| @@ -99,7 +91,7 @@ | @@ -99,7 +91,7 @@ | ||
| 99 | } | 91 | } |
| 100 | return $this->render('create', [ | 92 | return $this->render('create', [ |
| 101 | 'model' => $model, | 93 | 'model' => $model, |
| 102 | - 'model_langs' => $model_langs, | 94 | + 'model_langs' => $model->model_langs, |
| 103 | 'group' => $group, | 95 | 'group' => $group, |
| 104 | ]); | 96 | ]); |
| 105 | } | 97 | } |
| @@ -115,15 +107,13 @@ | @@ -115,15 +107,13 @@ | ||
| 115 | public function actionUpdate($id) | 107 | public function actionUpdate($id) |
| 116 | { | 108 | { |
| 117 | $model = $this->findModel($id); | 109 | $model = $this->findModel($id); |
| 118 | - $model_langs = $model->generateLangs(); | 110 | + $model->generateLangs(); |
| 119 | $group = TaxGroup::findOne($model->tax_group_id); | 111 | $group = TaxGroup::findOne($model->tax_group_id); |
| 120 | - | ||
| 121 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 122 | - $model->loadLangs(\Yii::$app->request, $model_langs); | ||
| 123 | - | 112 | + if($model->load(Yii::$app->request->post())) { |
| 113 | + $model->loadLangs(\Yii::$app->request); | ||
| 124 | TaxOption::find() | 114 | TaxOption::find() |
| 125 | ->rebuildMP($model->tax_group_id); | 115 | ->rebuildMP($model->tax_group_id); |
| 126 | - if($model->linkLangs($model_langs) && $model->saveLangs($model_langs)) { | 116 | + if($model->save() && $model->transactionStatus) { |
| 127 | return $this->redirect([ | 117 | return $this->redirect([ |
| 128 | 'view', | 118 | 'view', |
| 129 | 'id' => $model->tax_option_id, | 119 | 'id' => $model->tax_option_id, |
| @@ -132,7 +122,7 @@ | @@ -132,7 +122,7 @@ | ||
| 132 | } | 122 | } |
| 133 | return $this->render('update', [ | 123 | return $this->render('update', [ |
| 134 | 'model' => $model, | 124 | 'model' => $model, |
| 135 | - 'model_langs' => $model_langs, | 125 | + 'model_langs' => $model->model_langs, |
| 136 | 'group' => $group, | 126 | 'group' => $group, |
| 137 | ]); | 127 | ]); |
| 138 | } | 128 | } |
common/modules/rubrication/models/TaxGroup.php
| @@ -26,6 +26,8 @@ | @@ -26,6 +26,8 @@ | ||
| 26 | * @property TaxGroupLang $object_lang | 26 | * @property TaxGroupLang $object_lang |
| 27 | * @property string $ownerKey | 27 | * @property string $ownerKey |
| 28 | * @property string $langKey | 28 | * @property string $langKey |
| 29 | + * @property TaxGroupLang[] $model_langs | ||
| 30 | + * @property bool $transactionStatus | ||
| 29 | * @method string getOwnerKey() | 31 | * @method string getOwnerKey() |
| 30 | * @method void setOwnerKey( string $value ) | 32 | * @method void setOwnerKey( string $value ) |
| 31 | * @method string getLangKey() | 33 | * @method string getLangKey() |
| @@ -33,12 +35,13 @@ | @@ -33,12 +35,13 @@ | ||
| 33 | * @method ActiveQuery getLangs() | 35 | * @method ActiveQuery getLangs() |
| 34 | * @method ActiveQuery getLang( integer $language_id ) | 36 | * @method ActiveQuery getLang( integer $language_id ) |
| 35 | * @method TaxGroupLang[] generateLangs() | 37 | * @method TaxGroupLang[] generateLangs() |
| 36 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 37 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 38 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 38 | + * @method void loadLangs( Request $request ) |
| 39 | + * @method bool linkLangs() | ||
| 40 | + * @method bool saveLangs() | ||
| 41 | + * @method bool getTransactionStatus() | ||
| 39 | * * End language behavior * | 42 | * * End language behavior * |
| 40 | */ | 43 | */ |
| 41 | - class TaxGroup extends \yii\db\ActiveRecord | 44 | + class TaxGroup extends ActiveRecord |
| 42 | { | 45 | { |
| 43 | 46 | ||
| 44 | /** | 47 | /** |
| @@ -146,12 +149,14 @@ | @@ -146,12 +149,14 @@ | ||
| 146 | ->inverseOf('taxGroup'); | 149 | ->inverseOf('taxGroup'); |
| 147 | } | 150 | } |
| 148 | 151 | ||
| 149 | - public function getAlias() { | 152 | + public function getAlias() |
| 153 | + { | ||
| 150 | $default_lang = Language::getDefaultLanguage(); | 154 | $default_lang = Language::getDefaultLanguage(); |
| 151 | /** | 155 | /** |
| 152 | * @var TaxGroupLang $lang | 156 | * @var TaxGroupLang $lang |
| 153 | */ | 157 | */ |
| 154 | - $lang = $this->getLang($default_lang->language_id)->one(); | 158 | + $lang = $this->getLang($default_lang->language_id) |
| 159 | + ->one(); | ||
| 155 | return $lang->alias; | 160 | return $lang->alias; |
| 156 | } | 161 | } |
| 157 | } | 162 | } |
common/modules/rubrication/models/TaxOption.php
| @@ -31,6 +31,8 @@ | @@ -31,6 +31,8 @@ | ||
| 31 | * @property TaxOptionLang $object_lang | 31 | * @property TaxOptionLang $object_lang |
| 32 | * @property string $ownerKey | 32 | * @property string $ownerKey |
| 33 | * @property string $langKey | 33 | * @property string $langKey |
| 34 | + * @property TaxOptionLang[] $model_langs | ||
| 35 | + * @property bool $transactionStatus | ||
| 34 | * @method string getOwnerKey() | 36 | * @method string getOwnerKey() |
| 35 | * @method void setOwnerKey( string $value ) | 37 | * @method void setOwnerKey( string $value ) |
| 36 | * @method string getLangKey() | 38 | * @method string getLangKey() |
| @@ -38,12 +40,13 @@ | @@ -38,12 +40,13 @@ | ||
| 38 | * @method ActiveQuery getLangs() | 40 | * @method ActiveQuery getLangs() |
| 39 | * @method ActiveQuery getLang( integer $language_id ) | 41 | * @method ActiveQuery getLang( integer $language_id ) |
| 40 | * @method TaxOptionLang[] generateLangs() | 42 | * @method TaxOptionLang[] generateLangs() |
| 41 | - * @method void loadLangs( Request $request, ActiveRecord[] $model_langs ) | ||
| 42 | - * @method bool linkLangs( ActiveRecord[] $model_langs ) | ||
| 43 | - * @method bool saveLangs( ActiveRecord[] $model_langs ) | 43 | + * @method void loadLangs( Request $request ) |
| 44 | + * @method bool linkLangs() | ||
| 45 | + * @method bool saveLangs() | ||
| 46 | + * @method bool getTransactionStatus() | ||
| 44 | * * End language behavior * | 47 | * * End language behavior * |
| 45 | */ | 48 | */ |
| 46 | - class TaxOption extends \yii\db\ActiveRecord | 49 | + class TaxOption extends ActiveRecord |
| 47 | { | 50 | { |
| 48 | 51 | ||
| 49 | public $_items_count; | 52 | public $_items_count; |
common/modules/rubrication/views/tax-group/_form.php
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | <?php $form = ActiveForm::begin([ 'options' => [ 'enctype' => 'multipart/form-data' ] ]); ?> | 22 | <?php $form = ActiveForm::begin([ 'options' => [ 'enctype' => 'multipart/form-data' ] ]); ?> |
| 23 | 23 | ||
| 24 | <?= $form->field($model, 'categories') | 24 | <?= $form->field($model, 'categories') |
| 25 | - ->dropDownList(ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'category_id'), [ | 25 | + ->dropDownList(ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'lang.name'), [ |
| 26 | 'multiple' => true, | 26 | 'multiple' => true, |
| 27 | ]) | 27 | ]) |
| 28 | ->label('Use in the following categories') ?> | 28 | ->label('Use in the following categories') ?> |