Commit b7e90569af5e745870e04beda7c0eb4e86bab246
1 parent
448cfc19
Namespaces
Showing
36 changed files
with
2082 additions
and
5 deletions
Show diff stats
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace artweb\artbox\ecommerce\controllers; | ||
| 4 | + | ||
| 5 | + use Yii; | ||
| 6 | + use artweb\artbox\ecommerce\models\Brand; | ||
| 7 | + use artweb\artbox\ecommerce\models\BrandSearch; | ||
| 8 | + use yii\web\Controller; | ||
| 9 | + use yii\web\NotFoundHttpException; | ||
| 10 | + use yii\filters\VerbFilter; | ||
| 11 | + use yii\filters\AccessControl; | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * BrandController implements the CRUD actions for Brand model. | ||
| 15 | + */ | ||
| 16 | + class BrandController extends Controller | ||
| 17 | + { | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @inheritdoc | ||
| 21 | + */ | ||
| 22 | + public function behaviors() | ||
| 23 | + { | ||
| 24 | + return [ | ||
| 25 | + 'access' => [ | ||
| 26 | + 'class' => AccessControl::className(), | ||
| 27 | + 'rules' => [ | ||
| 28 | + [ | ||
| 29 | + 'actions' => [ | ||
| 30 | + 'login', | ||
| 31 | + 'error', | ||
| 32 | + ], | ||
| 33 | + 'allow' => true, | ||
| 34 | + ], | ||
| 35 | + [ | ||
| 36 | + 'actions' => [ | ||
| 37 | + 'logout', | ||
| 38 | + 'index', | ||
| 39 | + 'create', | ||
| 40 | + 'update', | ||
| 41 | + 'view', | ||
| 42 | + 'delete', | ||
| 43 | + ], | ||
| 44 | + 'allow' => true, | ||
| 45 | + 'roles' => [ '@' ], | ||
| 46 | + ], | ||
| 47 | + ], | ||
| 48 | + ], | ||
| 49 | + 'verbs' => [ | ||
| 50 | + 'class' => VerbFilter::className(), | ||
| 51 | + 'actions' => [ | ||
| 52 | + 'logout' => [ 'post' ], | ||
| 53 | + ], | ||
| 54 | + ], | ||
| 55 | + ]; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Lists all Brand models. | ||
| 60 | + * @return mixed | ||
| 61 | + */ | ||
| 62 | + public function actionIndex() | ||
| 63 | + { | ||
| 64 | + $searchModel = new BrandSearch(); | ||
| 65 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 66 | + | ||
| 67 | + return $this->render('index', [ | ||
| 68 | + 'searchModel' => $searchModel, | ||
| 69 | + 'dataProvider' => $dataProvider, | ||
| 70 | + ]); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * Displays a single Brand model. | ||
| 75 | + * | ||
| 76 | + * @param integer $id | ||
| 77 | + * | ||
| 78 | + * @return mixed | ||
| 79 | + */ | ||
| 80 | + public function actionView($id) | ||
| 81 | + { | ||
| 82 | + return $this->render('view', [ | ||
| 83 | + 'model' => $this->findModel($id), | ||
| 84 | + ]); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * Creates a new Brand model. | ||
| 89 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 90 | + * @return mixed | ||
| 91 | + */ | ||
| 92 | + public function actionCreate() | ||
| 93 | + { | ||
| 94 | + $model = new Brand(); | ||
| 95 | + $model->generateLangs(); | ||
| 96 | + if($model->load(Yii::$app->request->post())) { | ||
| 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', | ||
| 101 | + 'id' => $model->id, | ||
| 102 | + ]) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + return $this->render('create', [ | ||
| 106 | + 'model' => $model, | ||
| 107 | + 'modelLangs' => $model->modelLangs, | ||
| 108 | + ]); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + /** | ||
| 112 | + * Updates an existing Brand model. | ||
| 113 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 114 | + * | ||
| 115 | + * @param integer $id | ||
| 116 | + * | ||
| 117 | + * @return mixed | ||
| 118 | + */ | ||
| 119 | + public function actionUpdate($id) | ||
| 120 | + { | ||
| 121 | + $model = $this->findModel($id); | ||
| 122 | + $model->generateLangs(); | ||
| 123 | + | ||
| 124 | + if($model->load(Yii::$app->request->post())) { | ||
| 125 | + $model->loadLangs(\Yii::$app->request); | ||
| 126 | + if($model->save() && $model->transactionStatus) { | ||
| 127 | + return $this->redirect([ | ||
| 128 | + 'view', | ||
| 129 | + 'id' => $model->id, | ||
| 130 | + ]); | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + return $this->render('update', [ | ||
| 134 | + 'model' => $model, | ||
| 135 | + 'modelLangs' => $model->modelLangs, | ||
| 136 | + ]); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + /** | ||
| 140 | + * Deletes an existing Brand model. | ||
| 141 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 142 | + * | ||
| 143 | + * @param integer $id | ||
| 144 | + * | ||
| 145 | + * @return mixed | ||
| 146 | + */ | ||
| 147 | + public function actionDelete($id) | ||
| 148 | + { | ||
| 149 | + $this->findModel($id) | ||
| 150 | + ->delete(); | ||
| 151 | + | ||
| 152 | + return $this->redirect([ 'index' ]); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + /** | ||
| 156 | + * Finds the Brand model based on its primary key value. | ||
| 157 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 158 | + * | ||
| 159 | + * @param integer $id | ||
| 160 | + * | ||
| 161 | + * @return Brand the loaded model | ||
| 162 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 163 | + */ | ||
| 164 | + protected function findModel($id) | ||
| 165 | + { | ||
| 166 | + if(( $model = Brand::find()->with('lang')->where(['id' => $id])->one() ) !== NULL) { | ||
| 167 | + return $model; | ||
| 168 | + } else { | ||
| 169 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace artweb\artbox\ecommerce\controllers; | ||
| 4 | + | ||
| 5 | + use developeruz\db_rbac\behaviors\AccessBehavior; | ||
| 6 | + use artweb\artbox\components\artboxtree\ArtboxTreeHelper; | ||
| 7 | + use Yii; | ||
| 8 | + use artweb\artbox\ecommerce\models\Category; | ||
| 9 | + use artweb\artbox\ecommerce\models\CategorySearch; | ||
| 10 | + use yii\helpers\ArrayHelper; | ||
| 11 | + use yii\web\Controller; | ||
| 12 | + use yii\web\NotFoundHttpException; | ||
| 13 | + use yii\filters\VerbFilter; | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * CategoryController implements the CRUD actions for Category model. | ||
| 17 | + */ | ||
| 18 | + class CategoryController extends Controller | ||
| 19 | + { | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * @inheritdoc | ||
| 23 | + */ | ||
| 24 | + public function behaviors() | ||
| 25 | + { | ||
| 26 | + return [ | ||
| 27 | + 'access' => [ | ||
| 28 | + 'class' => AccessBehavior::className(), | ||
| 29 | + 'rules' => [ | ||
| 30 | + 'site' => [ | ||
| 31 | + [ | ||
| 32 | + 'actions' => [ | ||
| 33 | + 'login', | ||
| 34 | + 'error', | ||
| 35 | + ], | ||
| 36 | + 'allow' => true, | ||
| 37 | + ], | ||
| 38 | + ], | ||
| 39 | + ], | ||
| 40 | + ], | ||
| 41 | + 'verbs' => [ | ||
| 42 | + 'class' => VerbFilter::className(), | ||
| 43 | + 'actions' => [ | ||
| 44 | + 'logout' => [ 'post' ], | ||
| 45 | + ], | ||
| 46 | + ], | ||
| 47 | + ]; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * Lists all Category models. | ||
| 52 | + * | ||
| 53 | + * @return mixed | ||
| 54 | + */ | ||
| 55 | + public function actionIndex() | ||
| 56 | + { | ||
| 57 | + $searchModel = new CategorySearch(); | ||
| 58 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 59 | + return $this->render( | ||
| 60 | + 'index', | ||
| 61 | + [ | ||
| 62 | + 'searchModel' => $searchModel, | ||
| 63 | + 'dataProvider' => $dataProvider, | ||
| 64 | + ] | ||
| 65 | + ); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * Displays a single Category model. | ||
| 70 | + * | ||
| 71 | + * @param integer $id | ||
| 72 | + * | ||
| 73 | + * @return mixed | ||
| 74 | + */ | ||
| 75 | + public function actionView($id) | ||
| 76 | + { | ||
| 77 | + $model = $this->findModel($id); | ||
| 78 | + $tree = $model->getParents() | ||
| 79 | + ->with('lang') | ||
| 80 | + ->all(); | ||
| 81 | + return $this->render( | ||
| 82 | + 'view', | ||
| 83 | + [ | ||
| 84 | + 'model' => $model, | ||
| 85 | + 'tree' => $tree, | ||
| 86 | + ] | ||
| 87 | + ); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * Creates a new Category model. | ||
| 92 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 93 | + * | ||
| 94 | + * @return mixed | ||
| 95 | + */ | ||
| 96 | + public function actionCreate() | ||
| 97 | + { | ||
| 98 | + $model = new Category(); | ||
| 99 | + $model->generateLangs(); | ||
| 100 | + if ($model->load(Yii::$app->request->post())) { | ||
| 101 | + $model->loadLangs(\Yii::$app->request); | ||
| 102 | + if ($model->save() && $model->transactionStatus) { | ||
| 103 | + return is_null(Yii::$app->request->post('create_and_new')) ? $this->redirect( | ||
| 104 | + [ | ||
| 105 | + 'view', | ||
| 106 | + 'id' => $model->id, | ||
| 107 | + ] | ||
| 108 | + ) : $this->redirect(array_merge([ 'create' ], Yii::$app->request->queryParams)); | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + if (!empty( Yii::$app->request->queryParams[ 'parent' ] )) { | ||
| 112 | + $model->parent_id = Yii::$app->request->queryParams[ 'parent' ]; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + $parents = ArrayHelper::map( | ||
| 116 | + Category::find() | ||
| 117 | + ->joinWith('lang') | ||
| 118 | + ->asArray() | ||
| 119 | + ->all(), | ||
| 120 | + 'id', | ||
| 121 | + 'lang.title' | ||
| 122 | + ); | ||
| 123 | + | ||
| 124 | + return $this->render( | ||
| 125 | + 'create', | ||
| 126 | + [ | ||
| 127 | + 'model' => $model, | ||
| 128 | + 'modelLangs' => $model->modelLangs, | ||
| 129 | + 'categories' => ArtboxTreeHelper::treeMap( | ||
| 130 | + Category::find() | ||
| 131 | + ->getTree(), | ||
| 132 | + 'id', | ||
| 133 | + 'id', | ||
| 134 | + '.' | ||
| 135 | + ), | ||
| 136 | + 'parents' => $parents, | ||
| 137 | + ] | ||
| 138 | + ); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + /** | ||
| 142 | + * Updates an existing Category model. | ||
| 143 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 144 | + * | ||
| 145 | + * @param integer $id | ||
| 146 | + * | ||
| 147 | + * @return mixed | ||
| 148 | + */ | ||
| 149 | + public function actionUpdate($id) | ||
| 150 | + { | ||
| 151 | + $model = $this->findModel($id); | ||
| 152 | + $model->generateLangs(); | ||
| 153 | + if ($model->load(Yii::$app->request->post())) { | ||
| 154 | + $model->loadLangs(\Yii::$app->request); | ||
| 155 | + if ($model->save() && $model->transactionStatus) { | ||
| 156 | + return $this->redirect( | ||
| 157 | + [ | ||
| 158 | + 'view', | ||
| 159 | + 'id' => $model->id, | ||
| 160 | + ] | ||
| 161 | + ); | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + $parents = ArrayHelper::map( | ||
| 166 | + Category::find() | ||
| 167 | + ->joinWith('lang') | ||
| 168 | + ->where( | ||
| 169 | + [ | ||
| 170 | + '!=', | ||
| 171 | + 'id', | ||
| 172 | + $model->id, | ||
| 173 | + ] | ||
| 174 | + ) | ||
| 175 | + ->asArray() | ||
| 176 | + ->all(), | ||
| 177 | + 'id', | ||
| 178 | + 'lang.title' | ||
| 179 | + ); | ||
| 180 | + | ||
| 181 | + return $this->render( | ||
| 182 | + 'update', | ||
| 183 | + [ | ||
| 184 | + 'model' => $model, | ||
| 185 | + 'modelLangs' => $model->modelLangs, | ||
| 186 | + 'categories' => ArtboxTreeHelper::treeMap( | ||
| 187 | + Category::find() | ||
| 188 | + ->getTree(), | ||
| 189 | + 'id', | ||
| 190 | + 'id', | ||
| 191 | + '.' | ||
| 192 | + ), | ||
| 193 | + 'parents' => $parents, | ||
| 194 | + ] | ||
| 195 | + ); | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + /** | ||
| 199 | + * Deletes an existing Category model. | ||
| 200 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 201 | + * | ||
| 202 | + * @param integer $id | ||
| 203 | + * | ||
| 204 | + * @return mixed | ||
| 205 | + */ | ||
| 206 | + public function actionDelete($id) | ||
| 207 | + { | ||
| 208 | + $this->findModel($id) | ||
| 209 | + ->delete(); | ||
| 210 | + | ||
| 211 | + return $this->redirect([ 'index' ]); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * Finds the Category model based on its primary key value. | ||
| 216 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 217 | + * | ||
| 218 | + * @param integer $id | ||
| 219 | + * | ||
| 220 | + * @return Category the loaded model | ||
| 221 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 222 | + */ | ||
| 223 | + protected function findModel($id) | ||
| 224 | + { | ||
| 225 | + if (( $model = Category::find() | ||
| 226 | + ->where([ 'id' => $id ]) | ||
| 227 | + ->with('lang') | ||
| 228 | + ->one() ) !== NULL | ||
| 229 | + ) { | ||
| 230 | + return $model; | ||
| 231 | + } else { | ||
| 232 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 233 | + } | ||
| 234 | + } | ||
| 235 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace artweb\artbox\ecommerce\controllers; | ||
| 4 | + | ||
| 5 | + use artweb\artbox\ecommerce\models\DeliverySearch; | ||
| 6 | + use Yii; | ||
| 7 | + use artweb\artbox\ecommerce\models\Delivery; | ||
| 8 | + use yii\web\Controller; | ||
| 9 | + use yii\web\NotFoundHttpException; | ||
| 10 | + use yii\filters\VerbFilter; | ||
| 11 | + use yii\helpers\ArrayHelper; | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * DeliveryController implements the CRUD actions for Delivery model. | ||
| 15 | + */ | ||
| 16 | + class DeliveryController extends Controller | ||
| 17 | + { | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @inheritdoc | ||
| 21 | + */ | ||
| 22 | + public function behaviors() | ||
| 23 | + { | ||
| 24 | + return [ | ||
| 25 | + 'verbs' => [ | ||
| 26 | + 'class' => VerbFilter::className(), | ||
| 27 | + 'actions' => [ | ||
| 28 | + 'delete' => [ 'POST' ], | ||
| 29 | + ], | ||
| 30 | + ], | ||
| 31 | + ]; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Lists all Delivery models. | ||
| 36 | + * @return mixed | ||
| 37 | + */ | ||
| 38 | + public function actionIndex() | ||
| 39 | + { | ||
| 40 | + $searchModel = new DeliverySearch(); | ||
| 41 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 42 | + | ||
| 43 | + return $this->render('index', [ | ||
| 44 | + 'dataProvider' => $dataProvider, | ||
| 45 | + 'searchModel' => $searchModel, | ||
| 46 | + ]); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Displays a single Delivery model. | ||
| 51 | + * | ||
| 52 | + * @param integer $id | ||
| 53 | + * | ||
| 54 | + * @return mixed | ||
| 55 | + */ | ||
| 56 | + public function actionView($id) | ||
| 57 | + { | ||
| 58 | + return $this->render('view', [ | ||
| 59 | + 'model' => $this->findModel($id), | ||
| 60 | + ]); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * Creates a new Delivery model. | ||
| 65 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 66 | + * @return mixed | ||
| 67 | + */ | ||
| 68 | + public function actionCreate() | ||
| 69 | + { | ||
| 70 | + $model = new Delivery(); | ||
| 71 | + $model->generateLangs(); | ||
| 72 | + $parent_items = Delivery::find() | ||
| 73 | + ->with('lang') | ||
| 74 | + ->all(); | ||
| 75 | + $parent_items = ArrayHelper::map($parent_items, 'id', 'lang.title'); | ||
| 76 | + if($model->load(Yii::$app->request->post())) { | ||
| 77 | + $model->loadLangs(\Yii::$app->request); | ||
| 78 | + if($model->save() && $model->transactionStatus) { | ||
| 79 | + return $this->redirect([ | ||
| 80 | + 'view', | ||
| 81 | + 'id' => $model->id, | ||
| 82 | + ]); | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + return $this->render('create', [ | ||
| 86 | + 'model' => $model, | ||
| 87 | + 'modelLangs' => $model->modelLangs, | ||
| 88 | + 'parent_items' => $parent_items, | ||
| 89 | + ]); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * Updates an existing Delivery model. | ||
| 94 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 95 | + * | ||
| 96 | + * @param integer $id | ||
| 97 | + * | ||
| 98 | + * @return mixed | ||
| 99 | + */ | ||
| 100 | + public function actionUpdate($id) | ||
| 101 | + { | ||
| 102 | + $model = $this->findModel($id); | ||
| 103 | + $model->generateLangs(); | ||
| 104 | + $parent_items = Delivery::find() | ||
| 105 | + ->with('lang') | ||
| 106 | + ->all(); | ||
| 107 | + $parent_items = ArrayHelper::map($parent_items, 'id', 'lang.title'); | ||
| 108 | + | ||
| 109 | + if($model->load(Yii::$app->request->post())) { | ||
| 110 | + $model->loadLangs(\Yii::$app->request); | ||
| 111 | + if($model->save() && $model->transactionStatus) { | ||
| 112 | + return $this->redirect([ | ||
| 113 | + 'view', | ||
| 114 | + 'id' => $model->id, | ||
| 115 | + ]); | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + return $this->render('update', [ | ||
| 119 | + 'model' => $model, | ||
| 120 | + 'modelLangs' => $model->modelLangs, | ||
| 121 | + 'parent_items' => $parent_items, | ||
| 122 | + ]); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * Deletes an existing Delivery model. | ||
| 127 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 128 | + * | ||
| 129 | + * @param integer $id | ||
| 130 | + * | ||
| 131 | + * @return mixed | ||
| 132 | + */ | ||
| 133 | + public function actionDelete($id) | ||
| 134 | + { | ||
| 135 | + $this->findModel($id) | ||
| 136 | + ->delete(); | ||
| 137 | + | ||
| 138 | + return $this->redirect([ 'index' ]); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + /** | ||
| 142 | + * Finds the Delivery model based on its primary key value. | ||
| 143 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 144 | + * | ||
| 145 | + * @param integer $id | ||
| 146 | + * | ||
| 147 | + * @return Delivery the loaded model | ||
| 148 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 149 | + */ | ||
| 150 | + protected function findModel($id) | ||
| 151 | + { | ||
| 152 | + if(( $model = Delivery::find() | ||
| 153 | + ->with('parent') | ||
| 154 | + ->where([ | ||
| 155 | + 'id' => $id, | ||
| 156 | + ]) | ||
| 157 | + ->one() ) !== NULL | ||
| 158 | + ) { | ||
| 159 | + return $model; | ||
| 160 | + } else { | ||
| 161 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace artweb\artbox\ecommerce\controllers; | ||
| 4 | + | ||
| 5 | + use Yii; | ||
| 6 | + use artweb\artbox\ecommerce\models\Label; | ||
| 7 | + use artweb\artbox\ecommerce\models\LabelSearch; | ||
| 8 | + use yii\web\Controller; | ||
| 9 | + use yii\web\NotFoundHttpException; | ||
| 10 | + use yii\filters\VerbFilter; | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * LabelController implements the CRUD actions for Label model. | ||
| 14 | + */ | ||
| 15 | + class LabelController extends Controller | ||
| 16 | + { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @inheritdoc | ||
| 20 | + */ | ||
| 21 | + public function behaviors() | ||
| 22 | + { | ||
| 23 | + return [ | ||
| 24 | + 'verbs' => [ | ||
| 25 | + 'class' => VerbFilter::className(), | ||
| 26 | + 'actions' => [ | ||
| 27 | + 'delete' => [ 'POST' ], | ||
| 28 | + ], | ||
| 29 | + ], | ||
| 30 | + ]; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * Lists all Label models. | ||
| 35 | + * @return mixed | ||
| 36 | + */ | ||
| 37 | + public function actionIndex() | ||
| 38 | + { | ||
| 39 | + $searchModel = new LabelSearch(); | ||
| 40 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 41 | + | ||
| 42 | + return $this->render('index', [ | ||
| 43 | + 'searchModel' => $searchModel, | ||
| 44 | + 'dataProvider' => $dataProvider, | ||
| 45 | + ]); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * Displays a single Label model. | ||
| 50 | + * | ||
| 51 | + * @param integer $id | ||
| 52 | + * | ||
| 53 | + * @return mixed | ||
| 54 | + */ | ||
| 55 | + public function actionView($id) | ||
| 56 | + { | ||
| 57 | + return $this->render('view', [ | ||
| 58 | + 'model' => $this->findModel($id), | ||
| 59 | + ]); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * Creates a new Label model. | ||
| 64 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 65 | + * @return mixed | ||
| 66 | + */ | ||
| 67 | + public function actionCreate() | ||
| 68 | + { | ||
| 69 | + $model = new Label(); | ||
| 70 | + $model->generateLangs(); | ||
| 71 | + | ||
| 72 | + if($model->load(Yii::$app->request->post())) { | ||
| 73 | + $model->loadLangs(\Yii::$app->request); | ||
| 74 | + if($model->save() && $model->transactionStatus) { | ||
| 75 | + return $this->redirect([ | ||
| 76 | + 'view', | ||
| 77 | + 'id' => $model->id, | ||
| 78 | + ]); | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + return $this->render('create', [ | ||
| 82 | + 'model' => $model, | ||
| 83 | + 'modelLangs' => $model->modelLangs, | ||
| 84 | + ]); | ||
| 85 | + | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * Updates an existing Label model. | ||
| 90 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 91 | + * | ||
| 92 | + * @param integer $id | ||
| 93 | + * | ||
| 94 | + * @return mixed | ||
| 95 | + */ | ||
| 96 | + public function actionUpdate($id) | ||
| 97 | + { | ||
| 98 | + $model = $this->findModel($id); | ||
| 99 | + $model->generateLangs(); | ||
| 100 | + | ||
| 101 | + if($model->load(Yii::$app->request->post())) { | ||
| 102 | + $model->loadLangs(\Yii::$app->request); | ||
| 103 | + if($model->save() && $model->transactionStatus) { | ||
| 104 | + return $this->redirect([ | ||
| 105 | + 'view', | ||
| 106 | + 'id' => $model->id, | ||
| 107 | + ]); | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | + return $this->render('update', [ | ||
| 111 | + 'model' => $model, | ||
| 112 | + 'modelLangs' => $model->modelLangs, | ||
| 113 | + ]); | ||
| 114 | + | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * Deletes an existing Label model. | ||
| 119 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 120 | + * | ||
| 121 | + * @param integer $id | ||
| 122 | + * | ||
| 123 | + * @return mixed | ||
| 124 | + */ | ||
| 125 | + public function actionDelete($id) | ||
| 126 | + { | ||
| 127 | + $this->findModel($id) | ||
| 128 | + ->delete(); | ||
| 129 | + | ||
| 130 | + return $this->redirect([ 'index' ]); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * Finds the Label model based on its primary key value. | ||
| 135 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 136 | + * | ||
| 137 | + * @param integer $id | ||
| 138 | + * | ||
| 139 | + * @return Label the loaded model | ||
| 140 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 141 | + */ | ||
| 142 | + protected function findModel($id) | ||
| 143 | + { | ||
| 144 | + if(( $model = Label::findOne($id) ) !== NULL) { | ||
| 145 | + return $model; | ||
| 146 | + } else { | ||
| 147 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace artweb\artbox\ecommerce\models; | ||
| 4 | + | ||
| 5 | + use artweb\artbox\language\behaviors\LanguageBehavior; | ||
| 6 | + use yii\db\ActiveQuery; | ||
| 7 | + use yii\db\ActiveRecord; | ||
| 8 | + use yii\web\Request; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * Class Label | ||
| 12 | + * | ||
| 13 | + * @property int $id | ||
| 14 | + * @property string $label | ||
| 15 | + * * From language behavior * | ||
| 16 | + * @property orderLabelLang $lang | ||
| 17 | + * @property orderLabelLang[] $langs | ||
| 18 | + * @property orderLabelLang $objectLang | ||
| 19 | + * @property string $ownerKey | ||
| 20 | + * @property string $langKey | ||
| 21 | + * @property orderLabelLang[] $modelLangs | ||
| 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 OrderLabelLang[] generateLangs() | ||
| 30 | + * @method void loadLangs( Request $request ) | ||
| 31 | + * @method bool linkLangs() | ||
| 32 | + * @method bool saveLangs() | ||
| 33 | + * @method bool getTransactionStatus() | ||
| 34 | + * * End language behavior | ||
| 35 | + */ | ||
| 36 | + class Label extends ActiveRecord | ||
| 37 | + { | ||
| 38 | + | ||
| 39 | + public function rules() | ||
| 40 | + { | ||
| 41 | + return [ | ||
| 42 | + [ | ||
| 43 | + [ 'label' ], | ||
| 44 | + 'string', | ||
| 45 | + ], | ||
| 46 | + ]; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public static function tableName() | ||
| 50 | + { | ||
| 51 | + return 'order_label'; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public function behaviors() | ||
| 55 | + { | ||
| 56 | + return [ | ||
| 57 | + 'language' => [ | ||
| 58 | + 'class' => LanguageBehavior::className(), | ||
| 59 | + 'objectLang' => OrderLabelLang::className(), | ||
| 60 | + 'ownerKey' => 'id', | ||
| 61 | + 'langKey' => 'order_label_id', | ||
| 62 | + ], | ||
| 63 | + ]; | ||
| 64 | + } | ||
| 65 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace artweb\artbox\ecommerce\models; | ||
| 4 | + | ||
| 5 | + use yii\base\Model; | ||
| 6 | + use yii\data\ActiveDataProvider; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * LabelSearch represents the model behind the search form about `backend\models\Label`. | ||
| 10 | + */ | ||
| 11 | + class LabelSearch extends Label | ||
| 12 | + { | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * @var string | ||
| 16 | + */ | ||
| 17 | + public $title; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @inheritdoc | ||
| 21 | + */ | ||
| 22 | + public function rules() | ||
| 23 | + { | ||
| 24 | + return [ | ||
| 25 | + [ | ||
| 26 | + [ 'id' ], | ||
| 27 | + 'integer', | ||
| 28 | + ], | ||
| 29 | + [ | ||
| 30 | + [ | ||
| 31 | + 'label', | ||
| 32 | + 'title', | ||
| 33 | + ], | ||
| 34 | + 'safe', | ||
| 35 | + ], | ||
| 36 | + ]; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * @inheritdoc | ||
| 41 | + */ | ||
| 42 | + public function scenarios() | ||
| 43 | + { | ||
| 44 | + // bypass scenarios() implementation in the parent class | ||
| 45 | + return Model::scenarios(); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * Creates data provider instance with search query applied | ||
| 50 | + * | ||
| 51 | + * @param array $params | ||
| 52 | + * | ||
| 53 | + * @return ActiveDataProvider | ||
| 54 | + */ | ||
| 55 | + public function search($params) | ||
| 56 | + { | ||
| 57 | + $query = Label::find() | ||
| 58 | + ->joinWith('lang'); | ||
| 59 | + | ||
| 60 | + // add conditions that should always apply here | ||
| 61 | + | ||
| 62 | + $dataProvider = new ActiveDataProvider( | ||
| 63 | + [ | ||
| 64 | + 'query' => $query, | ||
| 65 | + 'sort' => [ | ||
| 66 | + 'attributes' => [ | ||
| 67 | + 'id', | ||
| 68 | + 'label', | ||
| 69 | + 'title' => [ | ||
| 70 | + 'asc' => [ 'order_label_lang.title' => SORT_ASC ], | ||
| 71 | + 'desc' => [ 'order_label_lang.title' => SORT_DESC ], | ||
| 72 | + ], | ||
| 73 | + ], | ||
| 74 | + ], | ||
| 75 | + ] | ||
| 76 | + ); | ||
| 77 | + | ||
| 78 | + $this->load($params); | ||
| 79 | + | ||
| 80 | + if (!$this->validate()) { | ||
| 81 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 82 | + // $query->where('0=1'); | ||
| 83 | + return $dataProvider; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + // grid filtering conditions | ||
| 87 | + $query->andFilterWhere( | ||
| 88 | + [ | ||
| 89 | + 'id' => $this->id, | ||
| 90 | + ] | ||
| 91 | + ); | ||
| 92 | + | ||
| 93 | + $query->andFilterWhere( | ||
| 94 | + [ | ||
| 95 | + 'like', | ||
| 96 | + 'label', | ||
| 97 | + $this->label, | ||
| 98 | + ] | ||
| 99 | + ) | ||
| 100 | + ->andFilterWhere( | ||
| 101 | + [ | ||
| 102 | + 'like', | ||
| 103 | + 'order_label_lang.title', | ||
| 104 | + $this->title, | ||
| 105 | + ] | ||
| 106 | + ); | ||
| 107 | + | ||
| 108 | + return $dataProvider; | ||
| 109 | + } | ||
| 110 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + namespace artweb\artbox\ecommerce\models; | ||
| 4 | + | ||
| 5 | + use artweb\artbox\language\models\Language; | ||
| 6 | + use Yii; | ||
| 7 | + use yii\db\ActiveRecord; | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * This is the model class for table "order_label_lang". | ||
| 11 | + * | ||
| 12 | + * @property integer $order_label_id | ||
| 13 | + * @property integer $language_id | ||
| 14 | + * @property string $title | ||
| 15 | + * @property Language $language | ||
| 16 | + * @property Label $label | ||
| 17 | + */ | ||
| 18 | + class OrderLabelLang extends ActiveRecord | ||
| 19 | + { | ||
| 20 | + | ||
| 21 | + public static function primaryKey() | ||
| 22 | + { | ||
| 23 | + return [ | ||
| 24 | + 'order_label_id', | ||
| 25 | + 'language_id', | ||
| 26 | + ]; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @inheritdoc | ||
| 31 | + */ | ||
| 32 | + public static function tableName() | ||
| 33 | + { | ||
| 34 | + return 'order_label_lang'; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @inheritdoc | ||
| 39 | + */ | ||
| 40 | + public function rules() | ||
| 41 | + { | ||
| 42 | + return [ | ||
| 43 | + [ | ||
| 44 | + [ 'title' ], | ||
| 45 | + 'required', | ||
| 46 | + ], | ||
| 47 | + [ | ||
| 48 | + [ 'title' ], | ||
| 49 | + 'string', | ||
| 50 | + 'max' => 255, | ||
| 51 | + ], | ||
| 52 | + [ | ||
| 53 | + [ | ||
| 54 | + 'order_label_id', | ||
| 55 | + 'language_id', | ||
| 56 | + ], | ||
| 57 | + 'unique', | ||
| 58 | + 'targetAttribute' => [ | ||
| 59 | + 'order_label_id', | ||
| 60 | + 'language_id', | ||
| 61 | + ], | ||
| 62 | + 'message' => 'The combination of order Label ID and Language ID has already been taken.', | ||
| 63 | + ], | ||
| 64 | + [ | ||
| 65 | + [ 'language_id' ], | ||
| 66 | + 'exist', | ||
| 67 | + 'skipOnError' => true, | ||
| 68 | + 'targetClass' => Language::className(), | ||
| 69 | + 'targetAttribute' => [ 'language_id' => 'id' ], | ||
| 70 | + ], | ||
| 71 | + [ | ||
| 72 | + [ 'order_label_id' ], | ||
| 73 | + 'exist', | ||
| 74 | + 'skipOnError' => true, | ||
| 75 | + 'targetClass' => Label::className(), | ||
| 76 | + 'targetAttribute' => [ 'order_label_id' => 'id' ], | ||
| 77 | + ], | ||
| 78 | + ]; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * @inheritdoc | ||
| 83 | + */ | ||
| 84 | + public function attributeLabels() | ||
| 85 | + { | ||
| 86 | + return [ | ||
| 87 | + 'order_label_id' => Yii::t('app', 'order Label ID'), | ||
| 88 | + 'language_id' => Yii::t('app', 'Language ID'), | ||
| 89 | + 'title' => Yii::t('app', 'Name'), | ||
| 90 | + ]; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * @return \yii\db\ActiveQuery | ||
| 95 | + */ | ||
| 96 | + public function getLanguage() | ||
| 97 | + { | ||
| 98 | + return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * @return \yii\db\ActiveQuery | ||
| 103 | + */ | ||
| 104 | + public function getLabel() | ||
| 105 | + { | ||
| 106 | + return $this->hasOne(Label::className(), [ 'id' => 'order_label_id' ]); | ||
| 107 | + } | ||
| 108 | + } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\language\widgets\LanguageForm; | ||
| 4 | + use common\modules\product\models\Brand; | ||
| 5 | + use common\modules\product\models\BrandLang; | ||
| 6 | + use yii\helpers\Html; | ||
| 7 | + use yii\web\View; | ||
| 8 | + use yii\widgets\ActiveForm; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * @var View $this | ||
| 12 | + * @var Brand $model | ||
| 13 | + * @var ActiveForm $form | ||
| 14 | + * @var BrandLang[] $modelLangs | ||
| 15 | + */ | ||
| 16 | +?> | ||
| 17 | + | ||
| 18 | +<div class="brand-form"> | ||
| 19 | + | ||
| 20 | + <?php $form = ActiveForm::begin([ | ||
| 21 | + 'enableClientValidation' => false, | ||
| 22 | + 'options' => [ 'enctype' => 'multipart/form-data' ], | ||
| 23 | + ]); ?> | ||
| 24 | + | ||
| 25 | + <?= $form->field($model, 'image') | ||
| 26 | + ->widget(\kartik\file\FileInput::className(), [ | ||
| 27 | + 'language' => 'ru', | ||
| 28 | + 'options' => [ | ||
| 29 | + 'accept' => 'image/*', | ||
| 30 | + 'multiple' => false, | ||
| 31 | + ], | ||
| 32 | + 'pluginOptions' => [ | ||
| 33 | + 'allowedFileExtensions' => [ | ||
| 34 | + 'jpg', | ||
| 35 | + 'gif', | ||
| 36 | + 'png', | ||
| 37 | + ], | ||
| 38 | + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '', | ||
| 39 | + 'overwriteInitial' => true, | ||
| 40 | + 'showRemove' => false, | ||
| 41 | + 'showUpload' => false, | ||
| 42 | + 'previewFileType' => 'image', | ||
| 43 | + ], | ||
| 44 | + ]); ?> | ||
| 45 | + | ||
| 46 | + <?= $form->field($model, 'in_menu')->dropDownList([\Yii::t('product', 'No'), \Yii::t('product', 'Yes')]); ?> | ||
| 47 | + | ||
| 48 | + <?= LanguageForm::widget([ | ||
| 49 | + 'modelLangs' => $modelLangs, | ||
| 50 | + 'formView' => '@backend/views/brand/_form_language', | ||
| 51 | + 'form' => $form, | ||
| 52 | + ]) ?> | ||
| 53 | + | ||
| 54 | + <div class="form-group"> | ||
| 55 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?> | ||
| 56 | + <?php if($model->isNewRecord) : ?> | ||
| 57 | + <?= Html::submitButton(Yii::t('product', 'Create and continue'), [ | ||
| 58 | + 'name' => 'create_and_new', | ||
| 59 | + 'class' => 'btn btn-primary', | ||
| 60 | + ]) ?> | ||
| 61 | + <?php endif ?> | ||
| 62 | + </div> | ||
| 63 | + | ||
| 64 | + <?php ActiveForm::end(); ?> | ||
| 65 | + | ||
| 66 | +</div> |
| 1 | +<?php | ||
| 2 | + use common\modules\language\models\Language; | ||
| 3 | + use common\modules\product\models\BrandLang; | ||
| 4 | + use yii\web\View; | ||
| 5 | + use yii\widgets\ActiveForm; | ||
| 6 | + | ||
| 7 | + /** | ||
| 8 | + * @var BrandLang $model_lang | ||
| 9 | + * @var Language $language | ||
| 10 | + * @var ActiveForm $form | ||
| 11 | + * @var View $this | ||
| 12 | + */ | ||
| 13 | +?> | ||
| 14 | +<?= $form->field($model_lang, '[' . $language->id . ']title') | ||
| 15 | + ->textInput([ 'maxlength' => true ]); ?> | ||
| 16 | + | ||
| 17 | +<?= $form->field($model_lang, '[' . $language->id . ']alias') | ||
| 18 | + ->textInput([ 'maxlength' => true ]); ?> | ||
| 19 | + | ||
| 20 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_title') | ||
| 21 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 22 | + | ||
| 23 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_robots') | ||
| 24 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 25 | + | ||
| 26 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_description') | ||
| 27 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 28 | + | ||
| 29 | +<?= $form->field($model_lang, '[' . $language->id . ']seo_text') | ||
| 30 | + ->textarea([ 'rows' => 6 ]) ?> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\product\models\Brand; | ||
| 4 | + use common\modules\product\models\BrandLang; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Brand $model | ||
| 11 | + * @var BrandLang[] $modelLangs | ||
| 12 | + */ | ||
| 13 | + | ||
| 14 | + $this->title = Yii::t('product', 'Create Brand'); | ||
| 15 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 16 | + 'label' => Yii::t('product', 'Brands'), | ||
| 17 | + 'url' => [ 'index' ], | ||
| 18 | + ]; | ||
| 19 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 20 | +?> | ||
| 21 | +<div class="brand-create"> | ||
| 22 | + | ||
| 23 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 24 | + | ||
| 25 | + <?= $this->render('_form', [ | ||
| 26 | + 'model' => $model, | ||
| 27 | + 'modelLangs' => $modelLangs, | ||
| 28 | + ]) ?> | ||
| 29 | + | ||
| 30 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\product\models\Brand; | ||
| 4 | + use common\modules\product\models\BrandSearch; | ||
| 5 | + use yii\data\ActiveDataProvider; | ||
| 6 | + use yii\helpers\Html; | ||
| 7 | + use yii\grid\GridView; | ||
| 8 | + use yii\web\View; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * @var View $this | ||
| 12 | + * @var BrandSearch $searchModel | ||
| 13 | + * @var ActiveDataProvider $dataProvider | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + $this->title = Yii::t('product', 'Brands'); | ||
| 17 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 18 | +?> | ||
| 19 | +<div class="brand-index"> | ||
| 20 | + | ||
| 21 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 22 | + | ||
| 23 | + <p> | ||
| 24 | + <?= Html::a(Yii::t('product', 'Create Brand'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
| 25 | + </p> | ||
| 26 | + <?= GridView::widget([ | ||
| 27 | + 'dataProvider' => $dataProvider, | ||
| 28 | + 'filterModel' => $searchModel, | ||
| 29 | + 'columns' => [ | ||
| 30 | + 'id', | ||
| 31 | + [ | ||
| 32 | + 'attribute' => 'brandName', | ||
| 33 | + 'value' => 'lang.title', | ||
| 34 | + ], | ||
| 35 | + 'imageUrl:image', | ||
| 36 | + [ | ||
| 37 | + 'attribute' => 'in_menu', | ||
| 38 | + 'content' => function($model) { | ||
| 39 | + /** | ||
| 40 | + * @var Brand $model | ||
| 41 | + */ | ||
| 42 | + return Html::tag('span', '', [ | ||
| 43 | + 'class' => 'glyphicon glyphicon-'.($model->in_menu?'ok':'remove'), | ||
| 44 | + ]); | ||
| 45 | + }, | ||
| 46 | + ], | ||
| 47 | + [ 'class' => 'yii\grid\ActionColumn', | ||
| 48 | + ], | ||
| 49 | + ], | ||
| 50 | + ]); ?> | ||
| 51 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\product\models\Brand; | ||
| 4 | + use common\modules\product\models\BrandLang; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Brand $model | ||
| 11 | + * @var BrandLang[] $modelLangs | ||
| 12 | + */ | ||
| 13 | + | ||
| 14 | + $this->title = Yii::t('product', 'Update {modelClass}: ', [ | ||
| 15 | + 'modelClass' => 'Brand', | ||
| 16 | + ]) . ' ' . $model->lang->title; | ||
| 17 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 18 | + 'label' => Yii::t('product', 'Brands'), | ||
| 19 | + 'url' => [ 'index' ], | ||
| 20 | + ]; | ||
| 21 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 22 | + 'label' => $model->lang->title, | ||
| 23 | + 'url' => [ | ||
| 24 | + 'view', | ||
| 25 | + 'id' => $model->id, | ||
| 26 | + ], | ||
| 27 | + ]; | ||
| 28 | + $this->params[ 'breadcrumbs' ][] = Yii::t('product', 'Update'); | ||
| 29 | +?> | ||
| 30 | +<div class="brand-update"> | ||
| 31 | + | ||
| 32 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 33 | + | ||
| 34 | + <?= $this->render('_form', [ | ||
| 35 | + 'model' => $model, | ||
| 36 | + 'modelLangs' => $modelLangs, | ||
| 37 | + ]) ?> | ||
| 38 | + | ||
| 39 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\product\models\Brand; | ||
| 4 | + use yii\helpers\Html; | ||
| 5 | + use yii\web\View; | ||
| 6 | + use yii\widgets\DetailView; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Brand $model | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | + $this->title = $model->lang->title; | ||
| 14 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 15 | + 'label' => Yii::t('product', 'Brands'), | ||
| 16 | + 'url' => [ 'index' ], | ||
| 17 | + ]; | ||
| 18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 19 | +?> | ||
| 20 | +<div class="brand-view"> | ||
| 21 | + | ||
| 22 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 23 | + | ||
| 24 | + <p> | ||
| 25 | + <?= Html::a(Yii::t('product', 'Update'), [ | ||
| 26 | + 'update', | ||
| 27 | + 'id' => $model->id, | ||
| 28 | + ], [ 'class' => 'btn btn-primary' ]) ?> | ||
| 29 | + <?= Html::a(Yii::t('product', 'Delete'), [ | ||
| 30 | + 'delete', | ||
| 31 | + 'id' => $model->id, | ||
| 32 | + ], [ | ||
| 33 | + 'class' => 'btn btn-danger', | ||
| 34 | + 'data' => [ | ||
| 35 | + 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), | ||
| 36 | + 'method' => 'post', | ||
| 37 | + ], | ||
| 38 | + ]) ?> | ||
| 39 | + </p> | ||
| 40 | + | ||
| 41 | + <?= DetailView::widget([ | ||
| 42 | + 'model' => $model, | ||
| 43 | + 'attributes' => [ | ||
| 44 | + 'id', | ||
| 45 | + 'lang.title', | ||
| 46 | + 'lang.alias', | ||
| 47 | + [ | ||
| 48 | + 'attribute' => 'in_menu', | ||
| 49 | + 'value' => Html::tag('span', '', [ | ||
| 50 | + 'class' => 'glyphicon glyphicon-' . ( $model->in_menu ? 'ok' : 'remove' ), | ||
| 51 | + ]), | ||
| 52 | + 'format' => 'html', | ||
| 53 | + ], | ||
| 54 | + 'imageUrl:image', | ||
| 55 | + 'lang.meta_title', | ||
| 56 | + 'lang.meta_robots', | ||
| 57 | + 'lang.meta_description', | ||
| 58 | + 'lang.seo_text', | ||
| 59 | + ], | ||
| 60 | + ]) ?> | ||
| 61 | + | ||
| 62 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\language\widgets\LanguageForm; | ||
| 4 | + use common\modules\product\models\Category; | ||
| 5 | + use common\modules\product\models\CategoryLang; | ||
| 6 | + use yii\helpers\Html; | ||
| 7 | + use yii\web\View; | ||
| 8 | + use yii\widgets\ActiveForm; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * @var View $this | ||
| 12 | + * @var Category $model | ||
| 13 | + * @var CategoryLang[] $modelLangs | ||
| 14 | + * @var string[] $categories | ||
| 15 | + * @var ActiveForm $form | ||
| 16 | + * @var array $parents | ||
| 17 | + */ | ||
| 18 | +?> | ||
| 19 | + | ||
| 20 | +<div class="category-form"> | ||
| 21 | + | ||
| 22 | + <?php $form = ActiveForm::begin( | ||
| 23 | + [ | ||
| 24 | + 'enableClientValidation' => false, | ||
| 25 | + 'options' => [ 'enctype' => 'multipart/form-data' ], | ||
| 26 | + ] | ||
| 27 | + ); ?> | ||
| 28 | + | ||
| 29 | + <?= $form->field($model, 'parent_id') | ||
| 30 | + ->dropDownList( | ||
| 31 | + $parents, | ||
| 32 | + [ | ||
| 33 | + 'prompt' => Yii::t('rubrication', 'Root category'), | ||
| 34 | + 'options' => [ | ||
| 35 | + $model->id => [ 'disabled' => true ], | ||
| 36 | + ], | ||
| 37 | + ] | ||
| 38 | + ) | ||
| 39 | + ->label(Yii::t('product', 'Parent category')) ?> | ||
| 40 | + | ||
| 41 | + <?= $form->field($model, 'image') | ||
| 42 | + ->widget( | ||
| 43 | + \kartik\file\FileInput::className(), | ||
| 44 | + [ | ||
| 45 | + 'language' => 'ru', | ||
| 46 | + 'options' => [ | ||
| 47 | + 'accept' => 'image/*', | ||
| 48 | + 'multiple' => false, | ||
| 49 | + ], | ||
| 50 | + 'pluginOptions' => [ | ||
| 51 | + 'allowedFileExtensions' => [ | ||
| 52 | + 'jpg', | ||
| 53 | + 'gif', | ||
| 54 | + 'png', | ||
| 55 | + ], | ||
| 56 | + 'initialPreview' => !empty( $model->imageUrl ) ? \common\components\artboximage\ArtboxImageHelper::getImage( | ||
| 57 | + $model->imageUrl, | ||
| 58 | + 'list' | ||
| 59 | + ) : '', | ||
| 60 | + 'overwriteInitial' => true, | ||
| 61 | + 'showRemove' => false, | ||
| 62 | + 'showUpload' => false, | ||
| 63 | + 'previewFileType' => 'image', | ||
| 64 | + ], | ||
| 65 | + ] | ||
| 66 | + ) | ||
| 67 | + ->hint( | ||
| 68 | + 'Для корректного отображения на сайте, размер изображения должен быть 262x144 либо соблюдать соотношение сторон примерно 2:1' | ||
| 69 | + ); ?> | ||
| 70 | + | ||
| 71 | + <?= LanguageForm::widget( | ||
| 72 | + [ | ||
| 73 | + 'modelLangs' => $modelLangs, | ||
| 74 | + 'formView' => '@backend/views/category/_form_language', | ||
| 75 | + 'form' => $form, | ||
| 76 | + ] | ||
| 77 | + ) ?> | ||
| 78 | + | ||
| 79 | + <div class="form-group"> | ||
| 80 | + <?= Html::submitButton( | ||
| 81 | + $model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), | ||
| 82 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | ||
| 83 | + ) ?> | ||
| 84 | + <?php if ($model->isNewRecord) : ?> | ||
| 85 | + <?= Html::submitButton( | ||
| 86 | + Yii::t('product', 'Create and continue'), | ||
| 87 | + [ | ||
| 88 | + 'name' => 'create_and_new', | ||
| 89 | + 'class' => 'btn btn-primary', | ||
| 90 | + ] | ||
| 91 | + ) ?> | ||
| 92 | + <?php endif ?> | ||
| 93 | + </div> | ||
| 94 | + | ||
| 95 | + <?php ActiveForm::end(); ?> | ||
| 96 | + | ||
| 97 | +</div> |
| 1 | +<?php | ||
| 2 | + use common\modules\language\models\Language; | ||
| 3 | + use common\modules\product\models\CategoryLang; | ||
| 4 | + use yii\web\View; | ||
| 5 | + use yii\widgets\ActiveForm; | ||
| 6 | + | ||
| 7 | + /** | ||
| 8 | + * @var CategoryLang $model_lang | ||
| 9 | + * @var Language $language | ||
| 10 | + * @var ActiveForm $form | ||
| 11 | + * @var View $this | ||
| 12 | + */ | ||
| 13 | +?> | ||
| 14 | +<?= $form->field($model_lang, '[' . $language->id . ']title') | ||
| 15 | + ->textInput([ 'maxlength' => true ]); ?> | ||
| 16 | + | ||
| 17 | +<?= $form->field($model_lang, '[' . $language->id . ']alias') | ||
| 18 | + ->textInput([ 'maxlength' => true ]); ?> | ||
| 19 | + | ||
| 20 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_title') | ||
| 21 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 22 | + | ||
| 23 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_robots') | ||
| 24 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 25 | + | ||
| 26 | +<?= $form->field($model_lang, '[' . $language->id . ']meta_description') | ||
| 27 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 28 | + | ||
| 29 | +<?= $form->field($model_lang, '[' . $language->id . ']seo_text') | ||
| 30 | + ->textarea([ 'rows' => 6 ]) ?> | ||
| 31 | + | ||
| 32 | +<?= $form->field($model_lang, '[' . $language->id . ']h1') | ||
| 33 | + ->textInput([ 'maxlength' => true ]) ?> | ||
| 0 | \ No newline at end of file | 34 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\product\models\Category; | ||
| 4 | + use common\modules\product\models\CategoryLang; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Category $model | ||
| 11 | + * @var CategoryLang[] $modelLangs | ||
| 12 | + * @var string[] $categories | ||
| 13 | + * @var articles $parents | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + $this->title = Yii::t('product', 'Create Category'); | ||
| 17 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 18 | + 'label' => Yii::t('product', 'Categories'), | ||
| 19 | + 'url' => [ 'index' ], | ||
| 20 | + ]; | ||
| 21 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 22 | +?> | ||
| 23 | +<div class="category-create"> | ||
| 24 | + | ||
| 25 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 26 | + | ||
| 27 | + <?= $this->render( | ||
| 28 | + '_form', | ||
| 29 | + [ | ||
| 30 | + 'model' => $model, | ||
| 31 | + 'modelLangs' => $modelLangs, | ||
| 32 | + 'categories' => $categories, | ||
| 33 | + 'parents' => $parents, | ||
| 34 | + ] | ||
| 35 | + ) ?> | ||
| 36 | + | ||
| 37 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\product\models\Category; | ||
| 4 | + use yii\helpers\Html; | ||
| 5 | + use kartik\grid\GridView; | ||
| 6 | + | ||
| 7 | + /** | ||
| 8 | + * @var $this yii\web\View | ||
| 9 | + * @var $searchModel common\modules\product\models\CategorySearch | ||
| 10 | + * @var $dataProvider yii\data\ActiveDataProvider | ||
| 11 | + */ | ||
| 12 | + $this->title = Yii::t('product', 'Categories'); | ||
| 13 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 14 | +?> | ||
| 15 | +<div class="category-index"> | ||
| 16 | + | ||
| 17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 18 | + | ||
| 19 | + <p> | ||
| 20 | + <?= Html::a(Yii::t('product', 'Create Category'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
| 21 | + </p> | ||
| 22 | + <?= GridView::widget([ | ||
| 23 | + 'dataProvider' => $dataProvider, | ||
| 24 | + 'filterModel' => $searchModel, | ||
| 25 | + 'columns' => [ | ||
| 26 | + [ 'class' => 'yii\grid\SerialColumn' ], | ||
| 27 | + 'id', | ||
| 28 | + [ | ||
| 29 | + 'attribute' => 'categoryName', | ||
| 30 | + 'content' => function($data) { | ||
| 31 | + /** | ||
| 32 | + * @var Category $data | ||
| 33 | + */ | ||
| 34 | + $op = []; | ||
| 35 | + foreach($data->getParents()->with('lang') | ||
| 36 | + ->all() as $parent) { | ||
| 37 | + $op[] = $parent->lang->title; | ||
| 38 | + } | ||
| 39 | + $op[] = $data->lang->title; | ||
| 40 | + return implode(' → ', $op); | ||
| 41 | + }, | ||
| 42 | + ], | ||
| 43 | + 'imageUrl:image', | ||
| 44 | + [ | ||
| 45 | + 'class' => 'yii\grid\ActionColumn', | ||
| 46 | + ], | ||
| 47 | + ], | ||
| 48 | + 'panel' => [ | ||
| 49 | + 'type' => 'success', | ||
| 50 | + ], | ||
| 51 | + ]); ?> | ||
| 52 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\product\models\Category; | ||
| 4 | + use common\modules\product\models\CategoryLang; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Category $model | ||
| 11 | + * @var CategoryLang[] $modelLangs | ||
| 12 | + * @var string[] $categories | ||
| 13 | + * @var array $parents | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + $this->title = Yii::t( | ||
| 17 | + 'product', | ||
| 18 | + 'Update {modelClass}: ', | ||
| 19 | + [ | ||
| 20 | + 'modelClass' => 'Category', | ||
| 21 | + ] | ||
| 22 | + ) . ' ' . $model->lang->title; | ||
| 23 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 24 | + 'label' => Yii::t('product', 'Categories'), | ||
| 25 | + 'url' => [ 'index' ], | ||
| 26 | + ]; | ||
| 27 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 28 | + 'label' => $model->lang->title, | ||
| 29 | + 'url' => [ | ||
| 30 | + 'view', | ||
| 31 | + 'id' => $model->id, | ||
| 32 | + ], | ||
| 33 | + ]; | ||
| 34 | + $this->params[ 'breadcrumbs' ][] = Yii::t('product', 'Update'); | ||
| 35 | +?> | ||
| 36 | +<div class="category-update"> | ||
| 37 | + | ||
| 38 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 39 | + | ||
| 40 | + <?= $this->render( | ||
| 41 | + '_form', | ||
| 42 | + [ | ||
| 43 | + 'model' => $model, | ||
| 44 | + 'modelLangs' => $modelLangs, | ||
| 45 | + 'categories' => $categories, | ||
| 46 | + 'parents' => $parents, | ||
| 47 | + ] | ||
| 48 | + ) ?> | ||
| 49 | + | ||
| 50 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\modules\product\models\Category; | ||
| 4 | + use yii\helpers\Html; | ||
| 5 | + use yii\web\View; | ||
| 6 | + use yii\widgets\DetailView; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Category $model | ||
| 11 | + * @var Category[] $tree | ||
| 12 | + */ | ||
| 13 | + | ||
| 14 | + $this->title = $model->lang->title; | ||
| 15 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 16 | + 'label' => Yii::t('product', 'Categories'), | ||
| 17 | + 'url' => [ 'index' ], | ||
| 18 | + ]; | ||
| 19 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 20 | + $tree_links = []; | ||
| 21 | + foreach($tree as $item) { | ||
| 22 | + $tree_links[] = Html::a($item->lang->title, [ | ||
| 23 | + 'view', | ||
| 24 | + 'id' => $item->id, | ||
| 25 | + ]); | ||
| 26 | + } | ||
| 27 | + if(empty($tree_links)) { | ||
| 28 | + $tree_string = \Yii::t('product', 'No parent categories'); | ||
| 29 | + } else { | ||
| 30 | + $tree_string = implode(' → ', $tree_links); | ||
| 31 | + } | ||
| 32 | +?> | ||
| 33 | +<div class="category-view"> | ||
| 34 | + | ||
| 35 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 36 | + | ||
| 37 | + <p> | ||
| 38 | + <?= Html::a(Yii::t('product', 'Update'), [ | ||
| 39 | + 'update', | ||
| 40 | + 'id' => $model->id, | ||
| 41 | + ], [ 'class' => 'btn btn-primary' ]) ?> | ||
| 42 | + <?= Html::a(Yii::t('product', 'Delete'), [ | ||
| 43 | + 'delete', | ||
| 44 | + 'id' => $model->id, | ||
| 45 | + ], [ | ||
| 46 | + 'class' => 'btn btn-danger', | ||
| 47 | + 'data' => [ | ||
| 48 | + 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), | ||
| 49 | + 'method' => 'post', | ||
| 50 | + ], | ||
| 51 | + ]) ?> | ||
| 52 | + <?= Html::a(Yii::t('product', 'Create Category'), [ 'category/create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
| 53 | + <?php | ||
| 54 | + if(!empty( $model->parent_id )) { | ||
| 55 | + echo Html::a(Yii::t('product', 'Create category By {title}', [ 'title' => $model->parent->lang->title ]), [ 'category/create?parent=' . $model->parent->id ], [ 'class' => 'btn btn-success' ]); | ||
| 56 | + } | ||
| 57 | + ?> | ||
| 58 | + </p> | ||
| 59 | + | ||
| 60 | + <?= DetailView::widget([ | ||
| 61 | + 'model' => $model, | ||
| 62 | + 'attributes' => [ | ||
| 63 | + 'id', | ||
| 64 | + [ | ||
| 65 | + 'label' => \Yii::t('product', 'Category tree'), | ||
| 66 | + 'value' => $tree_string, | ||
| 67 | + 'format' => 'html', | ||
| 68 | + ], | ||
| 69 | + 'imageUrl:image', | ||
| 70 | + 'lang.alias', | ||
| 71 | + 'lang.meta_title', | ||
| 72 | + 'lang.meta_robots', | ||
| 73 | + 'lang.meta_description', | ||
| 74 | + 'lang.seo_text', | ||
| 75 | + 'lang.h1', | ||
| 76 | + ], | ||
| 77 | + ]) ?> | ||
| 78 | + | ||
| 79 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\models\OrderDeliveryLang; | ||
| 4 | + use yii\helpers\Html; | ||
| 5 | + use yii\widgets\ActiveForm; | ||
| 6 | + use common\modules\language\widgets\LanguageForm; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var yii\web\View $this | ||
| 10 | + * @var common\models\Delivery $model | ||
| 11 | + * @var yii\widgets\ActiveForm $form | ||
| 12 | + * @var OrderDeliveryLang[] $modelLangs | ||
| 13 | + */ | ||
| 14 | +?> | ||
| 15 | + | ||
| 16 | +<div class="delivery-form"> | ||
| 17 | + | ||
| 18 | + <?php $form = ActiveForm::begin(); ?> | ||
| 19 | + | ||
| 20 | + <?= $form->field($model, 'parent_id') | ||
| 21 | + ->dropDownList($parent_items, [ | ||
| 22 | + 'prompt' => "Выберите вид доставки..." | ||
| 23 | + ]) ?> | ||
| 24 | + | ||
| 25 | + <?= $form->field($model, 'value') | ||
| 26 | + ->textInput() ?> | ||
| 27 | + | ||
| 28 | + <?= $form->field($model, 'sort') | ||
| 29 | + ->textInput() ?> | ||
| 30 | + | ||
| 31 | + <?= LanguageForm::widget([ | ||
| 32 | + 'modelLangs' => $modelLangs, | ||
| 33 | + 'formView' => '@backend/views/delivery/_form_language', | ||
| 34 | + 'form' => $form, | ||
| 35 | + ]) ?> | ||
| 36 | + | ||
| 37 | + <div class="form-group"> | ||
| 38 | + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]) ?> | ||
| 39 | + </div> | ||
| 40 | + | ||
| 41 | + <?php ActiveForm::end(); ?> | ||
| 42 | + | ||
| 43 | +</div> |
| 1 | +<?php | ||
| 2 | + use common\models\OrderDeliveryLang; | ||
| 3 | + use common\modules\language\models\Language; | ||
| 4 | + use yii\web\View; | ||
| 5 | + use yii\widgets\ActiveForm; | ||
| 6 | + | ||
| 7 | + /** | ||
| 8 | + * @var OrderDeliveryLang $model_lang | ||
| 9 | + * @var Language $language | ||
| 10 | + * @var ActiveForm $form | ||
| 11 | + * @var View $this | ||
| 12 | + */ | ||
| 13 | +?> | ||
| 14 | +<?= $form->field($model_lang, '[' . $language->id . ']title') | ||
| 15 | + ->textInput([ 'maxlength' => true ]); ?> | ||
| 16 | + | ||
| 17 | +<?= $form->field($model_lang, '[' . $language->id . ']text') | ||
| 18 | + ->textarea(); ?> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\models\Delivery; | ||
| 4 | + use common\models\OrderDeliveryLang; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Delivery $model | ||
| 11 | + * @var OrderDeliveryLang[] $modelLangs | ||
| 12 | + * @var array $parent_items | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | + $this->title = \Yii::t('product', 'Create Delivery'); | ||
| 16 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 17 | + 'label' => \Yii::t('product', 'Deliveries'), | ||
| 18 | + 'url' => [ 'index' ], | ||
| 19 | + ]; | ||
| 20 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 21 | +?> | ||
| 22 | +<div class="delivery-create"> | ||
| 23 | + | ||
| 24 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 25 | + | ||
| 26 | + <?= $this->render('_form', [ | ||
| 27 | + 'model' => $model, | ||
| 28 | + 'modelLangs' => $modelLangs, | ||
| 29 | + 'parent_items' => $parent_items, | ||
| 30 | + ]) ?> | ||
| 31 | + | ||
| 32 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use yii\helpers\Html; | ||
| 4 | + use yii\grid\GridView; | ||
| 5 | + use yii\web\View; | ||
| 6 | + use yii\data\ActiveDataProvider; | ||
| 7 | + use common\models\DeliverySearch; | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * @var View $this | ||
| 11 | + * @var ActiveDataProvider $dataProvider | ||
| 12 | + * @var DeliverySearch $searchModel | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | + $this->title = 'Deliveries'; | ||
| 16 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 17 | +?> | ||
| 18 | +<div class="delivery-index"> | ||
| 19 | + | ||
| 20 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 21 | + | ||
| 22 | + <p> | ||
| 23 | + <?= Html::a('Create Delivery', [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
| 24 | + </p> | ||
| 25 | + <?= GridView::widget([ | ||
| 26 | + 'dataProvider' => $dataProvider, | ||
| 27 | + 'filterModel' => $searchModel, | ||
| 28 | + 'columns' => [ | ||
| 29 | + | ||
| 30 | + 'id', | ||
| 31 | + [ | ||
| 32 | + 'attribute' => 'title', | ||
| 33 | + 'value' => 'lang.title', | ||
| 34 | + ], | ||
| 35 | + [ | ||
| 36 | + 'attribute' => 'parentTitle', | ||
| 37 | + 'value' => 'parent.lang.title', | ||
| 38 | + ], | ||
| 39 | + 'value', | ||
| 40 | + [ 'class' => 'yii\grid\ActionColumn' ], | ||
| 41 | + ], | ||
| 42 | + ]); ?> | ||
| 43 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\models\OrderDeliveryLang; | ||
| 4 | + use yii\helpers\Html; | ||
| 5 | + use common\models\Delivery; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Delivery $model | ||
| 11 | + * @var array $parent_items | ||
| 12 | + * @var OrderDeliveryLang[] $modelLangs | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | + $this->title = 'Update Delivery: ' . $model->lang->title; | ||
| 16 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 17 | + 'label' => 'Deliveries', | ||
| 18 | + 'url' => [ 'index' ], | ||
| 19 | + ]; | ||
| 20 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 21 | + 'label' => $model->lang->title, | ||
| 22 | + 'url' => [ | ||
| 23 | + 'view', | ||
| 24 | + 'id' => $model->id, | ||
| 25 | + ], | ||
| 26 | + ]; | ||
| 27 | + $this->params[ 'breadcrumbs' ][] = 'Update'; | ||
| 28 | +?> | ||
| 29 | +<div class="delivery-update"> | ||
| 30 | + | ||
| 31 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 32 | + | ||
| 33 | + <?= $this->render('_form', [ | ||
| 34 | + 'model' => $model, | ||
| 35 | + 'modelLangs' => $modelLangs, | ||
| 36 | + 'parent_items' => $parent_items, | ||
| 37 | + ]) ?> | ||
| 38 | + | ||
| 39 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use common\models\Delivery; | ||
| 4 | + use yii\helpers\Html; | ||
| 5 | + use yii\widgets\DetailView; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Delivery $model | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | + $this->title = $model->lang->title; | ||
| 14 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 15 | + 'label' => 'Deliveries', | ||
| 16 | + 'url' => [ 'index' ], | ||
| 17 | + ]; | ||
| 18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 19 | + | ||
| 20 | + $parent_link = ''; | ||
| 21 | + if(!empty( $model->parent )) { | ||
| 22 | + $parent_link = Html::a($model->parent->lang->title, [ | ||
| 23 | + 'view', | ||
| 24 | + 'id' => $model->parent->id, | ||
| 25 | + ]); | ||
| 26 | + } | ||
| 27 | +?> | ||
| 28 | +<div class="delivery-view"> | ||
| 29 | + | ||
| 30 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 31 | + | ||
| 32 | + <p> | ||
| 33 | + <?= Html::a('Update', [ | ||
| 34 | + 'update', | ||
| 35 | + 'id' => $model->id, | ||
| 36 | + ], [ 'class' => 'btn btn-primary' ]) ?> | ||
| 37 | + <?= Html::a('Delete', [ | ||
| 38 | + 'delete', | ||
| 39 | + 'id' => $model->id, | ||
| 40 | + ], [ | ||
| 41 | + 'class' => 'btn btn-danger', | ||
| 42 | + 'data' => [ | ||
| 43 | + 'confirm' => 'Are you sure you want to delete this item?', | ||
| 44 | + 'method' => 'post', | ||
| 45 | + ], | ||
| 46 | + ]) ?> | ||
| 47 | + </p> | ||
| 48 | + | ||
| 49 | + <?= DetailView::widget([ | ||
| 50 | + 'model' => $model, | ||
| 51 | + 'attributes' => [ | ||
| 52 | + 'id', | ||
| 53 | + [ | ||
| 54 | + 'label' => 'Вид доставки', | ||
| 55 | + 'value' => $parent_link, | ||
| 56 | + 'format' => 'html', | ||
| 57 | + ], | ||
| 58 | + 'lang.title', | ||
| 59 | + 'lang.text', | ||
| 60 | + 'value', | ||
| 61 | + 'sort', | ||
| 62 | + ], | ||
| 63 | + ]) ?> | ||
| 64 | + | ||
| 65 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use backend\models\Label; | ||
| 4 | + use backend\models\OrderLabelLang; | ||
| 5 | + use common\modules\language\widgets\LanguageForm; | ||
| 6 | + use yii\helpers\Html; | ||
| 7 | + use yii\web\View; | ||
| 8 | + use yii\widgets\ActiveForm; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * @var View $this | ||
| 12 | + * @var Label $model | ||
| 13 | + * @var ActiveForm $form | ||
| 14 | + * @var orderLabelLang[] $modelLangs | ||
| 15 | + */ | ||
| 16 | +?> | ||
| 17 | + | ||
| 18 | +<div class="label-form"> | ||
| 19 | + | ||
| 20 | + <?php $form = ActiveForm::begin(); ?> | ||
| 21 | + | ||
| 22 | + <?= $form->field($model, 'label')->textInput(['maxlength' => true]) ?> | ||
| 23 | + | ||
| 24 | + <?= LanguageForm::widget([ | ||
| 25 | + 'modelLangs' => $modelLangs, | ||
| 26 | + 'formView' => '@backend/views/label/_form_language', | ||
| 27 | + 'form' => $form, | ||
| 28 | + ]) ?> | ||
| 29 | + | ||
| 30 | + <div class="form-group"> | ||
| 31 | + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
| 32 | + </div> | ||
| 33 | + | ||
| 34 | + <?php ActiveForm::end(); ?> | ||
| 35 | + | ||
| 36 | +</div> |
| 1 | +<?php | ||
| 2 | + use common\models\OrderDeliveryLang; | ||
| 3 | + use common\modules\language\models\Language; | ||
| 4 | + use yii\web\View; | ||
| 5 | + use yii\widgets\ActiveForm; | ||
| 6 | + | ||
| 7 | + /** | ||
| 8 | + * @var OrderDeliveryLang[] $model_lang | ||
| 9 | + * @var Language $language | ||
| 10 | + * @var ActiveForm $form | ||
| 11 | + * @var View $this | ||
| 12 | + */ | ||
| 13 | +?> | ||
| 14 | +<?= $form->field($model_lang, '[' . $language->id . ']title') | ||
| 15 | + ->textInput([ 'maxlength' => true ]); ?> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use backend\models\Label; | ||
| 4 | + use backend\models\OrderLabelLang; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Label $model | ||
| 11 | + * @var orderLabelLang[] $modelLangs | ||
| 12 | + */ | ||
| 13 | + | ||
| 14 | +$this->title = 'Create Label'; | ||
| 15 | +$this->params['breadcrumbs'][] = ['label' => 'Labels', 'url' => ['index']]; | ||
| 16 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 17 | +?> | ||
| 18 | +<div class="label-create"> | ||
| 19 | + | ||
| 20 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 21 | + | ||
| 22 | + <?= $this->render('_form', [ | ||
| 23 | + 'model' => $model, | ||
| 24 | + 'modelLangs' => $modelLangs, | ||
| 25 | + ]) ?> | ||
| 26 | + | ||
| 27 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use backend\models\LabelSearch; | ||
| 4 | + use yii\data\ActiveDataProvider; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\grid\GridView; | ||
| 7 | + use yii\web\View; | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * @var View $this | ||
| 11 | + * @var LabelSearch $searchModel | ||
| 12 | + * @var ActiveDataProvider $dataProvider | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | + $this->title = 'Labels'; | ||
| 16 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 17 | +?> | ||
| 18 | +<div class="label-index"> | ||
| 19 | + | ||
| 20 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 21 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 22 | + | ||
| 23 | + <p> | ||
| 24 | + <?= Html::a('Create Label', [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
| 25 | + </p> | ||
| 26 | + <?= GridView::widget([ | ||
| 27 | + 'dataProvider' => $dataProvider, | ||
| 28 | + 'filterModel' => $searchModel, | ||
| 29 | + 'columns' => [ | ||
| 30 | + 'id', | ||
| 31 | + 'label', | ||
| 32 | + [ | ||
| 33 | + 'attribute' => 'title', | ||
| 34 | + 'value' => 'lang.title', | ||
| 35 | + ], | ||
| 36 | + [ 'class' => 'yii\grid\ActionColumn' ], | ||
| 37 | + ], | ||
| 38 | + ]); ?> | ||
| 39 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use backend\models\Label; | ||
| 4 | + use backend\models\OrderLabelLang; | ||
| 5 | + use yii\helpers\Html; | ||
| 6 | + use yii\web\View; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Label $model | ||
| 11 | + * @var orderLabelLang[] $modelLangs | ||
| 12 | + */ | ||
| 13 | + | ||
| 14 | + $this->title = 'Update Label: ' . $model->lang->title; | ||
| 15 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 16 | + 'label' => 'Labels', | ||
| 17 | + 'url' => [ 'index' ], | ||
| 18 | + ]; | ||
| 19 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 20 | + 'label' => $model->lang->title, | ||
| 21 | + 'url' => [ | ||
| 22 | + 'view', | ||
| 23 | + 'id' => $model->id, | ||
| 24 | + ], | ||
| 25 | + ]; | ||
| 26 | + $this->params[ 'breadcrumbs' ][] = 'Update'; | ||
| 27 | +?> | ||
| 28 | +<div class="label-update"> | ||
| 29 | + | ||
| 30 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 31 | + | ||
| 32 | + <?= $this->render('_form', [ | ||
| 33 | + 'model' => $model, | ||
| 34 | + 'modelLangs' => $modelLangs, | ||
| 35 | + ]) ?> | ||
| 36 | + | ||
| 37 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + use backend\models\Label; | ||
| 4 | + use yii\helpers\Html; | ||
| 5 | + use yii\web\View; | ||
| 6 | + use yii\widgets\DetailView; | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * @var View $this | ||
| 10 | + * @var Label $model | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | + $this->title = $model->lang->title; | ||
| 14 | + $this->params[ 'breadcrumbs' ][] = [ | ||
| 15 | + 'label' => 'Labels', | ||
| 16 | + 'url' => [ 'index' ], | ||
| 17 | + ]; | ||
| 18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 19 | +?> | ||
| 20 | +<div class="label-view"> | ||
| 21 | + | ||
| 22 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 23 | + | ||
| 24 | + <p> | ||
| 25 | + <?= Html::a('Update', [ | ||
| 26 | + 'update', | ||
| 27 | + 'id' => $model->id, | ||
| 28 | + ], [ 'class' => 'btn btn-primary' ]) ?> | ||
| 29 | + <?= Html::a('Delete', [ | ||
| 30 | + 'delete', | ||
| 31 | + 'id' => $model->id, | ||
| 32 | + ], [ | ||
| 33 | + 'class' => 'btn btn-danger', | ||
| 34 | + 'data' => [ | ||
| 35 | + 'confirm' => 'Are you sure you want to delete this item?', | ||
| 36 | + 'method' => 'post', | ||
| 37 | + ], | ||
| 38 | + ]) ?> | ||
| 39 | + </p> | ||
| 40 | + | ||
| 41 | + <?= DetailView::widget([ | ||
| 42 | + 'model' => $model, | ||
| 43 | + 'attributes' => [ | ||
| 44 | + 'id', | ||
| 45 | + 'label', | ||
| 46 | + [ | ||
| 47 | + 'label' => 'Name', | ||
| 48 | + 'value' => $model->lang->title, | ||
| 49 | + ], | ||
| 50 | + ], | ||
| 51 | + ]) ?> | ||
| 52 | + | ||
| 53 | +</div> |
views/manage/_form.php
| @@ -125,7 +125,7 @@ | @@ -125,7 +125,7 @@ | ||
| 125 | <?= LanguageForm::widget( | 125 | <?= LanguageForm::widget( |
| 126 | [ | 126 | [ |
| 127 | 'modelLangs' => $modelLangs, | 127 | 'modelLangs' => $modelLangs, |
| 128 | - 'formView' => '@common/modules/product/views/manage/_form_language', | 128 | + 'formView' => '@artweb/artbox/ecommerce/views/manage/_form_language', |
| 129 | 'form' => $form, | 129 | 'form' => $form, |
| 130 | ] | 130 | ] |
| 131 | ) ?> | 131 | ) ?> |
views/product-unit/_form.php
| @@ -25,7 +25,7 @@ | @@ -25,7 +25,7 @@ | ||
| 25 | <?= LanguageForm::widget([ | 25 | <?= LanguageForm::widget([ |
| 26 | 'modelLangs' => $modelLangs, | 26 | 'modelLangs' => $modelLangs, |
| 27 | 'form' => $form, | 27 | 'form' => $form, |
| 28 | - 'formView' => '@common/modules/product/views/product-unit/_form_language', | 28 | + 'formView' => '@artweb/artbox/ecommerce/views/product-unit/_form_language', |
| 29 | ]) ?> | 29 | ]) ?> |
| 30 | 30 | ||
| 31 | <div class="form-group"> | 31 | <div class="form-group"> |
views/tax-group/_form.php
| @@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
| 42 | <?php | 42 | <?php |
| 43 | echo LanguageForm::widget([ | 43 | echo LanguageForm::widget([ |
| 44 | 'modelLangs' => $modelLangs, | 44 | 'modelLangs' => $modelLangs, |
| 45 | - 'formView' => '@common/modules/rubrication/views/tax-group/_form_language', | 45 | + 'formView' => '@artweb/artbox/ecommerce/views/tax-group/_form_language', |
| 46 | 'form' => $form, | 46 | 'form' => $form, |
| 47 | ]); | 47 | ]); |
| 48 | ?> | 48 | ?> |
views/tax-option/_form.php
| @@ -75,7 +75,7 @@ | @@ -75,7 +75,7 @@ | ||
| 75 | echo LanguageForm::widget( | 75 | echo LanguageForm::widget( |
| 76 | [ | 76 | [ |
| 77 | 'modelLangs' => $modelLangs, | 77 | 'modelLangs' => $modelLangs, |
| 78 | - 'formView' => '@common/modules/rubrication/views/tax-option/_form_language', | 78 | + 'formView' => '@artweb/artbox/ecommerce/views/tax-option/_form_language', |
| 79 | 'form' => $form, | 79 | 'form' => $form, |
| 80 | ] | 80 | ] |
| 81 | ); | 81 | ); |
views/variant/_form.php
| @@ -87,7 +87,7 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { | @@ -87,7 +87,7 @@ $(".dynamicform_wrapper").on("limitReached", function(e, item) { | ||
| 87 | <?= LanguageForm::widget( | 87 | <?= LanguageForm::widget( |
| 88 | [ | 88 | [ |
| 89 | 'modelLangs' => $modelLangs, | 89 | 'modelLangs' => $modelLangs, |
| 90 | - 'formView' => '@common/modules/product/views/variant/_form_language', | 90 | + 'formView' => '@artweb/artbox/ecommerce/views/variant/_form_language', |
| 91 | 'form' => $form, | 91 | 'form' => $form, |
| 92 | ] | 92 | ] |
| 93 | ) ?> | 93 | ) ?> |