Commit 7975da136fb1ee6c1f48b30d33db2df7904ab7c1
1 parent
740819d4
-Label model prettyfied
Showing
13 changed files
with
666 additions
and
127 deletions
Show diff stats
backend/controllers/DeliveryController.php
@@ -73,18 +73,20 @@ | @@ -73,18 +73,20 @@ | ||
73 | ->with('lang') | 73 | ->with('lang') |
74 | ->all(); | 74 | ->all(); |
75 | $parent_items = ArrayHelper::map($parent_items, 'id', 'lang.title'); | 75 | $parent_items = ArrayHelper::map($parent_items, 'id', 'lang.title'); |
76 | - if($model->load(Yii::$app->request->post()) && $model->save()) { | ||
77 | - return $this->redirect([ | ||
78 | - 'view', | ||
79 | - 'id' => $model->id, | ||
80 | - ]); | ||
81 | - } else { | ||
82 | - return $this->render('create', [ | ||
83 | - 'model' => $model, | ||
84 | - 'model_langs' => $model->model_langs, | ||
85 | - 'parent_items' => $parent_items, | ||
86 | - ]); | 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 | + } | ||
87 | } | 84 | } |
85 | + return $this->render('create', [ | ||
86 | + 'model' => $model, | ||
87 | + 'model_langs' => $model->model_langs, | ||
88 | + 'parent_items' => $parent_items, | ||
89 | + ]); | ||
88 | } | 90 | } |
89 | 91 | ||
90 | /** | 92 | /** |
1 | +<?php | ||
2 | + | ||
3 | + namespace backend\controllers; | ||
4 | + | ||
5 | + use Yii; | ||
6 | + use backend\models\Label; | ||
7 | + use backend\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 | + 'model_langs' => $model->model_langs, | ||
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 | + 'model_langs' => $model->model_langs, | ||
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 | + } |
backend/models/Label.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | -namespace backend\models; | ||
4 | - | ||
5 | -use common\modules\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 | - * * From language behavior * | ||
14 | - * @property OrdersLabelLang $lang | ||
15 | - * @property OrdersLabelLang[] $langs | ||
16 | - * @property OrdersLabelLang $object_lang | ||
17 | - * @property string $ownerKey | ||
18 | - * @property string $langKey | ||
19 | - * @property OrdersLabelLang[] $model_langs | ||
20 | - * @property bool $transactionStatus | ||
21 | - * @method string getOwnerKey() | ||
22 | - * @method void setOwnerKey(string $value) | ||
23 | - * @method string getLangKey() | ||
24 | - * @method void setLangKey(string $value) | ||
25 | - * @method ActiveQuery getLangs() | ||
26 | - * @method ActiveQuery getLang( integer $language_id ) | ||
27 | - * @method OrdersLabelLang[] generateLangs() | ||
28 | - * @method void loadLangs(Request $request) | ||
29 | - * @method bool linkLangs() | ||
30 | - * @method bool saveLangs() | ||
31 | - * @method bool getTransactionStatus() | ||
32 | - * * End language behavior | ||
33 | - */ | ||
34 | -class Label extends ActiveRecord | ||
35 | -{ | ||
36 | - | ||
37 | - public static function tableName() | ||
38 | - { | ||
39 | - return 'orders_label'; | ||
40 | - } | ||
41 | 2 | ||
42 | - public function behaviors() | 3 | + namespace backend\models; |
4 | + | ||
5 | + use common\modules\language\behaviors\LanguageBehavior; | ||
6 | + use yii\db\ActiveQuery; | ||
7 | + use yii\db\ActiveRecord; | ||
8 | + use yii\web\Request; | ||
9 | + | ||
10 | + /** | ||
11 | + * Class Label | ||
12 | + * * From language behavior * | ||
13 | + * @property OrdersLabelLang $lang | ||
14 | + * @property OrdersLabelLang[] $langs | ||
15 | + * @property OrdersLabelLang $object_lang | ||
16 | + * @property string $ownerKey | ||
17 | + * @property string $langKey | ||
18 | + * @property OrdersLabelLang[] $model_langs | ||
19 | + * @property bool $transactionStatus | ||
20 | + * @property integer $id | ||
21 | + * @property string $label | ||
22 | + * @method string getOwnerKey() | ||
23 | + * @method void setOwnerKey( string $value ) | ||
24 | + * @method string getLangKey() | ||
25 | + * @method void setLangKey( string $value ) | ||
26 | + * @method ActiveQuery getLangs() | ||
27 | + * @method ActiveQuery getLang( integer $language_id ) | ||
28 | + * @method OrdersLabelLang[] generateLangs() | ||
29 | + * @method void loadLangs( Request $request ) | ||
30 | + * @method bool linkLangs() | ||
31 | + * @method bool saveLangs() | ||
32 | + * @method bool getTransactionStatus() | ||
33 | + * * End language behavior | ||
34 | + */ | ||
35 | + class Label extends ActiveRecord | ||
43 | { | 36 | { |
44 | - return [ | ||
45 | - 'language' => [ | ||
46 | - 'class' => LanguageBehavior::className(), | ||
47 | - ], | ||
48 | - ]; | 37 | + |
38 | + public function rules() | ||
39 | + { | ||
40 | + return [ | ||
41 | + [ | ||
42 | + [ 'label' ], | ||
43 | + 'string', | ||
44 | + ], | ||
45 | + ]; | ||
46 | + } | ||
47 | + | ||
48 | + public static function tableName() | ||
49 | + { | ||
50 | + return 'orders_label'; | ||
51 | + } | ||
52 | + | ||
53 | + public function behaviors() | ||
54 | + { | ||
55 | + return [ | ||
56 | + 'language' => [ | ||
57 | + 'class' => LanguageBehavior::className(), | ||
58 | + 'object_lang' => OrdersLabelLang::className(), | ||
59 | + 'ownerKey' => 'id', | ||
60 | + 'langKey' => 'orders_label_id', | ||
61 | + ], | ||
62 | + ]; | ||
63 | + } | ||
49 | } | 64 | } |
50 | -} |
1 | +<?php | ||
2 | + | ||
3 | + namespace backend\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 $name; | ||
18 | + | ||
19 | + /** | ||
20 | + * @inheritdoc | ||
21 | + */ | ||
22 | + public function rules() | ||
23 | + { | ||
24 | + return [ | ||
25 | + [ | ||
26 | + [ 'id' ], | ||
27 | + 'integer', | ||
28 | + ], | ||
29 | + [ | ||
30 | + [ | ||
31 | + 'label', | ||
32 | + 'name', | ||
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 | + 'query' => $query, | ||
64 | + 'sort' => [ | ||
65 | + 'attributes' => [ | ||
66 | + 'id', | ||
67 | + 'label', | ||
68 | + 'name' => [ | ||
69 | + 'asc' => [ 'orders_label_lang.name' => SORT_ASC ], | ||
70 | + 'desc' => [ 'orders_label_lang.name' => SORT_DESC ], | ||
71 | + ], | ||
72 | + ], | ||
73 | + ], | ||
74 | + ]); | ||
75 | + | ||
76 | + $this->load($params); | ||
77 | + | ||
78 | + if(!$this->validate()) { | ||
79 | + // uncomment the following line if you do not want to return any records when validation fails | ||
80 | + // $query->where('0=1'); | ||
81 | + return $dataProvider; | ||
82 | + } | ||
83 | + | ||
84 | + // grid filtering conditions | ||
85 | + $query->andFilterWhere([ | ||
86 | + 'id' => $this->id, | ||
87 | + ]); | ||
88 | + | ||
89 | + $query->andFilterWhere([ | ||
90 | + 'like', | ||
91 | + 'label', | ||
92 | + $this->label, | ||
93 | + ]) | ||
94 | + ->andFilterWhere([ | ||
95 | + 'like', | ||
96 | + 'orders_label_lang.name', | ||
97 | + $this->name, | ||
98 | + ]); | ||
99 | + | ||
100 | + return $dataProvider; | ||
101 | + } | ||
102 | + } |
backend/models/OrdersLabelLang.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | -namespace backend\models; | ||
4 | - | ||
5 | -use common\modules\language\models\Language; | ||
6 | -use Yii; | ||
7 | - | ||
8 | -/** | ||
9 | - * This is the model class for table "orders_label_lang". | ||
10 | - * | ||
11 | - * @property integer $orders_label_id | ||
12 | - * @property integer $language_id | ||
13 | - * @property string $name | ||
14 | - * | ||
15 | - * @property Language $language | ||
16 | - * @property Label $label | ||
17 | - */ | ||
18 | -class OrdersLabelLang extends \yii\db\ActiveRecord | ||
19 | -{ | ||
20 | 2 | ||
21 | - public static function primaryKey() | ||
22 | - { | ||
23 | - return [ | ||
24 | - 'orders_label_id', | ||
25 | - 'language_id', | ||
26 | - ]; | ||
27 | - } | 3 | + namespace backend\models; |
28 | 4 | ||
29 | - /** | ||
30 | - * @inheritdoc | ||
31 | - */ | ||
32 | - public static function tableName() | ||
33 | - { | ||
34 | - return 'orders_label_lang'; | ||
35 | - } | 5 | + use common\modules\language\models\Language; |
6 | + use Yii; | ||
7 | + use yii\db\ActiveRecord; | ||
36 | 8 | ||
37 | /** | 9 | /** |
38 | - * @inheritdoc | ||
39 | - */ | ||
40 | - public function rules() | ||
41 | - { | ||
42 | - return [ | ||
43 | - [['name'], 'required'], | ||
44 | - [['name'], 'string', 'max' => 255], | ||
45 | - [['orders_label_id', 'language_id'], 'unique', 'targetAttribute' => ['orders_label_id', 'language_id'], 'message' => 'The combination of Orders Label ID and Language ID has already been taken.'], | ||
46 | - [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::className(), 'targetAttribute' => ['language_id' => 'language_id']], | ||
47 | - [['orders_label_id'], 'exist', 'skipOnError' => true, 'targetClass' => OrdersLabel::className(), 'targetAttribute' => ['orders_label_id' => 'id']], | ||
48 | - ]; | ||
49 | - } | ||
50 | - | ||
51 | - /** | ||
52 | - * @inheritdoc | ||
53 | - */ | ||
54 | - public function attributeLabels() | ||
55 | - { | ||
56 | - return [ | ||
57 | - 'orders_label_id' => Yii::t('app', 'Orders Label ID'), | ||
58 | - 'language_id' => Yii::t('app', 'Language ID'), | ||
59 | - 'name' => Yii::t('app', 'Name'), | ||
60 | - ]; | ||
61 | - } | ||
62 | - | ||
63 | - /** | ||
64 | - * @return \yii\db\ActiveQuery | ||
65 | - */ | ||
66 | - public function getLanguage() | ||
67 | - { | ||
68 | - return $this->hasOne(Language::className(), ['language_id' => 'language_id']); | ||
69 | - } | ||
70 | - | ||
71 | - /** | ||
72 | - * @return \yii\db\ActiveQuery | 10 | + * This is the model class for table "orders_label_lang". |
11 | + * @property integer $orders_label_id | ||
12 | + * @property integer $language_id | ||
13 | + * @property string $name | ||
14 | + * @property Language $language | ||
15 | + * @property Label $label | ||
73 | */ | 16 | */ |
74 | - public function getLabel() | 17 | + class OrdersLabelLang extends ActiveRecord |
75 | { | 18 | { |
76 | - return $this->hasOne(Label::className(), ['id' => 'orders_label_id']); | 19 | + |
20 | + public static function primaryKey() | ||
21 | + { | ||
22 | + return [ | ||
23 | + 'orders_label_id', | ||
24 | + 'language_id', | ||
25 | + ]; | ||
26 | + } | ||
27 | + | ||
28 | + /** | ||
29 | + * @inheritdoc | ||
30 | + */ | ||
31 | + public static function tableName() | ||
32 | + { | ||
33 | + return 'orders_label_lang'; | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * @inheritdoc | ||
38 | + */ | ||
39 | + public function rules() | ||
40 | + { | ||
41 | + return [ | ||
42 | + [ | ||
43 | + [ 'name' ], | ||
44 | + 'required', | ||
45 | + ], | ||
46 | + [ | ||
47 | + [ 'name' ], | ||
48 | + 'string', | ||
49 | + 'max' => 255, | ||
50 | + ], | ||
51 | + [ | ||
52 | + [ | ||
53 | + 'orders_label_id', | ||
54 | + 'language_id', | ||
55 | + ], | ||
56 | + 'unique', | ||
57 | + 'targetAttribute' => [ | ||
58 | + 'orders_label_id', | ||
59 | + 'language_id', | ||
60 | + ], | ||
61 | + 'message' => 'The combination of Orders Label ID and Language ID has already been taken.', | ||
62 | + ], | ||
63 | + [ | ||
64 | + [ 'language_id' ], | ||
65 | + 'exist', | ||
66 | + 'skipOnError' => true, | ||
67 | + 'targetClass' => Language::className(), | ||
68 | + 'targetAttribute' => [ 'language_id' => 'language_id' ], | ||
69 | + ], | ||
70 | + [ | ||
71 | + [ 'orders_label_id' ], | ||
72 | + 'exist', | ||
73 | + 'skipOnError' => true, | ||
74 | + 'targetClass' => Label::className(), | ||
75 | + 'targetAttribute' => [ 'orders_label_id' => 'id' ], | ||
76 | + ], | ||
77 | + ]; | ||
78 | + } | ||
79 | + | ||
80 | + /** | ||
81 | + * @inheritdoc | ||
82 | + */ | ||
83 | + public function attributeLabels() | ||
84 | + { | ||
85 | + return [ | ||
86 | + 'orders_label_id' => Yii::t('app', 'Orders Label ID'), | ||
87 | + 'language_id' => Yii::t('app', 'Language ID'), | ||
88 | + 'name' => Yii::t('app', 'Name'), | ||
89 | + ]; | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * @return \yii\db\ActiveQuery | ||
94 | + */ | ||
95 | + public function getLanguage() | ||
96 | + { | ||
97 | + return $this->hasOne(Language::className(), [ 'language_id' => 'language_id' ]); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * @return \yii\db\ActiveQuery | ||
102 | + */ | ||
103 | + public function getLabel() | ||
104 | + { | ||
105 | + return $this->hasOne(Label::className(), [ 'id' => 'orders_label_id' ]); | ||
106 | + } | ||
77 | } | 107 | } |
78 | -} |
1 | +<?php | ||
2 | + | ||
3 | + use backend\models\Label; | ||
4 | + use backend\models\OrdersLabelLang; | ||
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 OrdersLabelLang[] $model_langs | ||
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 | + 'model_langs' => $model_langs, | ||
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\OrdersDeliveryLang; | ||
3 | + use common\modules\language\models\Language; | ||
4 | + use yii\web\View; | ||
5 | + use yii\widgets\ActiveForm; | ||
6 | + | ||
7 | + /** | ||
8 | + * @var OrdersDeliveryLang[] $model_lang | ||
9 | + * @var Language $language | ||
10 | + * @var ActiveForm $form | ||
11 | + * @var View $this | ||
12 | + */ | ||
13 | +?> | ||
14 | +<?= $form->field($model_lang, '[' . $language->language_id . ']name') | ||
15 | + ->textInput([ 'maxlength' => true ]); ?> |
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\widgets\ActiveForm; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $model backend\models\LabelSearch */ | ||
8 | +/* @var $form yii\widgets\ActiveForm */ | ||
9 | +?> | ||
10 | + | ||
11 | +<div class="label-search"> | ||
12 | + | ||
13 | + <?php $form = ActiveForm::begin([ | ||
14 | + 'action' => ['index'], | ||
15 | + 'method' => 'get', | ||
16 | + ]); ?> | ||
17 | + | ||
18 | + <?= $form->field($model, 'id') ?> | ||
19 | + | ||
20 | + <?= $form->field($model, 'label') ?> | ||
21 | + | ||
22 | + <div class="form-group"> | ||
23 | + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> | ||
24 | + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?> | ||
25 | + </div> | ||
26 | + | ||
27 | + <?php ActiveForm::end(); ?> | ||
28 | + | ||
29 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use backend\models\Label; | ||
4 | + use backend\models\OrdersLabelLang; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\web\View; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var Label $model | ||
11 | + * @var OrdersLabelLang[] $model_langs | ||
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 | + 'model_langs' => $model_langs, | ||
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' => 'name', | ||
34 | + 'value' => 'lang.name', | ||
35 | + ], | ||
36 | + [ 'class' => 'yii\grid\ActionColumn' ], | ||
37 | + ], | ||
38 | + ]); ?> | ||
39 | +</div> |
1 | +<?php | ||
2 | + | ||
3 | + use backend\models\Label; | ||
4 | + use backend\models\OrdersLabelLang; | ||
5 | + use yii\helpers\Html; | ||
6 | + use yii\web\View; | ||
7 | + | ||
8 | + /** | ||
9 | + * @var View $this | ||
10 | + * @var Label $model | ||
11 | + * @var OrdersLabelLang[] $model_langs | ||
12 | + */ | ||
13 | + | ||
14 | + $this->title = 'Update Label: ' . $model->lang->name; | ||
15 | + $this->params[ 'breadcrumbs' ][] = [ | ||
16 | + 'label' => 'Labels', | ||
17 | + 'url' => [ 'index' ], | ||
18 | + ]; | ||
19 | + $this->params[ 'breadcrumbs' ][] = [ | ||
20 | + 'label' => $model->lang->name, | ||
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 | + 'model_langs' => $model_langs, | ||
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->name; | ||
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->name, | ||
49 | + ], | ||
50 | + ], | ||
51 | + ]) ?> | ||
52 | + | ||
53 | +</div> |
backend/views/layouts/main-sidebar.php
@@ -23,6 +23,7 @@ use yii\widgets\Menu; | @@ -23,6 +23,7 @@ use yii\widgets\Menu; | ||
23 | 'active' => preg_match('/^manage.*$/', $this->context->id) || | 23 | 'active' => preg_match('/^manage.*$/', $this->context->id) || |
24 | preg_match('/^category.*$/', $this->context->id) || | 24 | preg_match('/^category.*$/', $this->context->id) || |
25 | preg_match('/^delivery.*$/', $this->context->id) || | 25 | preg_match('/^delivery.*$/', $this->context->id) || |
26 | + preg_match('/^label.*$/', $this->context->id) || | ||
26 | preg_match('/^brand.*$/', $this->context->id) || | 27 | preg_match('/^brand.*$/', $this->context->id) || |
27 | preg_match('/^product-unit.*$/', $this->context->id) || | 28 | preg_match('/^product-unit.*$/', $this->context->id) || |
28 | preg_match('/^import.*$/', $this->context->id) || | 29 | preg_match('/^import.*$/', $this->context->id) || |
@@ -41,6 +42,11 @@ use yii\widgets\Menu; | @@ -41,6 +42,11 @@ use yii\widgets\Menu; | ||
41 | 'options' => ['class'=>\Yii::$app->user->can('delivery') ? '' :'hide'] | 42 | 'options' => ['class'=>\Yii::$app->user->can('delivery') ? '' :'hide'] |
42 | ], | 43 | ], |
43 | [ | 44 | [ |
45 | + 'label' => 'Статус товара', | ||
46 | + 'url' => ['/label'], | ||
47 | + 'options' => ['class'=>\Yii::$app->user->can('label') ? '' :'hide'] | ||
48 | + ], | ||
49 | + [ | ||
44 | 'label' => 'Категории', | 50 | 'label' => 'Категории', |
45 | 'url' => ['/category'], | 51 | 'url' => ['/category'], |
46 | 'options' => ['class'=>\Yii::$app->user->can('category') ? '' :'hide'], | 52 | 'options' => ['class'=>\Yii::$app->user->can('category') ? '' :'hide'], |