Commit 588209fc4e908d01ae885a6bf4127ae0d7b987a8
1 parent
47559a4b
test
Showing
14 changed files
with
949 additions
and
425 deletions
Show diff stats
backend/views/blog/articles.php
@@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
2 | use yii\grid\ActionColumn; | 2 | use yii\grid\ActionColumn; |
3 | use yii\grid\Column; | 3 | use yii\grid\Column; |
4 | use yii\grid\GridView; | 4 | use yii\grid\GridView; |
5 | -use common\modules\blog\models\Article; | ||
6 | use common\models\Language; | 5 | use common\models\Language; |
7 | 6 | ||
8 | echo GridView::widget([ | 7 | echo GridView::widget([ |
common/models/Gallery.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | -namespace common\models; | 3 | + namespace common\models; |
4 | 4 | ||
5 | -use Yii; | ||
6 | -use yii\behaviors\BlameableBehavior; | ||
7 | -use yii\behaviors\TimestampBehavior; | ||
8 | -use yii\db\Expression; | 5 | + use Yii; |
6 | + use yii\behaviors\BlameableBehavior; | ||
7 | + use yii\behaviors\TimestampBehavior; | ||
8 | + use yii\db\Expression; | ||
9 | 9 | ||
10 | -/** | ||
11 | - * This is the model class for table "gallery". | ||
12 | - * | ||
13 | - * @property integer $gallery_id | ||
14 | - * @property integer $user_id | ||
15 | - * @property string $name | ||
16 | - * @property string $date_add | ||
17 | - * @property integer $user_add_id | ||
18 | - * @property string $cover | ||
19 | - * @property integer $type | ||
20 | - * @property string $photo | ||
21 | - */ | ||
22 | -class Gallery extends \yii\db\ActiveRecord | ||
23 | -{ | ||
24 | /** | 10 | /** |
25 | - * @inheritdoc | 11 | + * This is the model class for table "gallery". |
12 | + * @property integer $gallery_id | ||
13 | + * @property integer $user_id | ||
14 | + * @property string $name | ||
15 | + * @property string $date_add | ||
16 | + * @property integer $user_add_id | ||
17 | + * @property string $cover | ||
18 | + * @property integer $type | ||
19 | + * @property string $photo | ||
26 | */ | 20 | */ |
27 | - public static function tableName() | 21 | + class Gallery extends \yii\db\ActiveRecord |
28 | { | 22 | { |
29 | - return 'gallery'; | ||
30 | - } | ||
31 | 23 | ||
32 | - /** | ||
33 | - * @inheritdoc | ||
34 | - */ | ||
35 | - public function behaviors() | ||
36 | - { | ||
37 | - return [ | ||
38 | - [ | ||
39 | - 'class' => BlameableBehavior::className(), | ||
40 | - 'createdByAttribute' => 'user_id', | ||
41 | - 'updatedByAttribute' => false, | ||
42 | - ], | ||
43 | - [ | ||
44 | - 'class' => TimestampBehavior::className(), | ||
45 | - 'createdAtAttribute' => 'date_add', | ||
46 | - 'updatedAtAttribute' => false, | ||
47 | - 'value' => new Expression('NOW()'), | ||
48 | - ], | ||
49 | - ]; | ||
50 | - } | 24 | + /** |
25 | + * @inheritdoc | ||
26 | + */ | ||
27 | + public static function tableName() | ||
28 | + { | ||
29 | + return 'gallery'; | ||
30 | + } | ||
51 | 31 | ||
52 | - /** | ||
53 | - * @inheritdoc | ||
54 | - */ | ||
55 | - public function rules() | ||
56 | - { | ||
57 | - return [ | ||
58 | - [['name'], 'required'], | ||
59 | - [['type'], 'integer'], | ||
60 | - [['photo'], 'string'], | ||
61 | - [['name', 'cover'], 'string', 'max' => 255], | ||
62 | - ]; | ||
63 | - } | 32 | + /** |
33 | + * @inheritdoc | ||
34 | + */ | ||
35 | + public function behaviors() | ||
36 | + { | ||
37 | + return [ | ||
38 | + [ | ||
39 | + 'class' => BlameableBehavior::className(), | ||
40 | + 'createdByAttribute' => 'user_id', | ||
41 | + 'updatedByAttribute' => false, | ||
42 | + ], | ||
43 | + [ | ||
44 | + 'class' => TimestampBehavior::className(), | ||
45 | + 'createdAtAttribute' => 'date_add', | ||
46 | + 'updatedAtAttribute' => false, | ||
47 | + 'value' => new Expression('NOW()'), | ||
48 | + ], | ||
49 | + ]; | ||
50 | + } | ||
64 | 51 | ||
65 | - /** | ||
66 | - * @inheritdoc | ||
67 | - */ | ||
68 | - public function attributeLabels() | ||
69 | - { | ||
70 | - return [ | ||
71 | - 'gallery_id' => Yii::t('app', 'Gallery ID'), | ||
72 | - 'user_id' => Yii::t('app', 'User ID'), | ||
73 | - 'name' => Yii::t('app', 'Название'), | ||
74 | - 'date_add' => Yii::t('app', 'Дата добавления'), | ||
75 | - 'user_add_id' => Yii::t('app', 'User Add ID'), | ||
76 | - 'cover' => Yii::t('app', 'Фото главное'), | ||
77 | - 'type' => Yii::t('app', 'Вид галереи'), | ||
78 | - 'photo' => Yii::t('app', 'Фото галереи'), | ||
79 | - ]; | 52 | + /** |
53 | + * @inheritdoc | ||
54 | + */ | ||
55 | + public function rules() | ||
56 | + { | ||
57 | + return [ | ||
58 | + [ | ||
59 | + [ 'name' ], | ||
60 | + 'required', | ||
61 | + ], | ||
62 | + [ | ||
63 | + [ 'type' ], | ||
64 | + 'integer', | ||
65 | + ], | ||
66 | + [ | ||
67 | + [ 'photo' ], | ||
68 | + 'string', | ||
69 | + ], | ||
70 | + [ | ||
71 | + [ | ||
72 | + 'name', | ||
73 | + 'cover', | ||
74 | + ], | ||
75 | + 'string', | ||
76 | + 'max' => 255, | ||
77 | + ], | ||
78 | + ]; | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * @inheritdoc | ||
83 | + */ | ||
84 | + public function attributeLabels() | ||
85 | + { | ||
86 | + return [ | ||
87 | + 'gallery_id' => Yii::t('app', 'Gallery ID'), | ||
88 | + 'user_id' => Yii::t('app', 'User ID'), | ||
89 | + 'name' => Yii::t('app', 'Название'), | ||
90 | + 'date_add' => Yii::t('app', 'Дата добавления'), | ||
91 | + 'user_add_id' => Yii::t('app', 'User Add ID'), | ||
92 | + 'cover' => Yii::t('app', 'Фото главное'), | ||
93 | + 'type' => Yii::t('app', 'Вид галереи'), | ||
94 | + 'photo' => Yii::t('app', 'Фото галереи'), | ||
95 | + ]; | ||
96 | + } | ||
80 | } | 97 | } |
81 | -} |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\base\Model; | ||
7 | +use yii\data\ActiveDataProvider; | ||
8 | +use common\models\Portfolio; | ||
9 | + | ||
10 | +/** | ||
11 | + * PortfolioSearch represents the model behind the search form about `common\models\Portfolio`. | ||
12 | + */ | ||
13 | +class PortfolioSearch extends Portfolio | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @inheritdoc | ||
17 | + */ | ||
18 | + public function rules() | ||
19 | + { | ||
20 | + return [ | ||
21 | + [['portfolio_id', 'user_id', 'user_add_id', 'view_count', 'gallery_id'], 'integer'], | ||
22 | + [['name', 'link', 'date_add', 'city', 'street', 'house', 'description', 'cover'], 'safe'], | ||
23 | + ]; | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * @inheritdoc | ||
28 | + */ | ||
29 | + public function scenarios() | ||
30 | + { | ||
31 | + // bypass scenarios() implementation in the parent class | ||
32 | + return Model::scenarios(); | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * Creates data provider instance with search query applied | ||
37 | + * | ||
38 | + * @param array $params | ||
39 | + * | ||
40 | + * @return ActiveDataProvider | ||
41 | + */ | ||
42 | + public function search($params) | ||
43 | + { | ||
44 | + $query = Portfolio::find(); | ||
45 | + | ||
46 | + // add conditions that should always apply here | ||
47 | + | ||
48 | + $dataProvider = new ActiveDataProvider([ | ||
49 | + 'query' => $query, | ||
50 | + ]); | ||
51 | + | ||
52 | + $this->load($params); | ||
53 | + | ||
54 | + if (!$this->validate()) { | ||
55 | + // uncomment the following line if you do not want to return any records when validation fails | ||
56 | + // $query->where('0=1'); | ||
57 | + return $dataProvider; | ||
58 | + } | ||
59 | + | ||
60 | + // grid filtering conditions | ||
61 | + $query->andFilterWhere([ | ||
62 | + 'portfolio_id' => $this->portfolio_id, | ||
63 | + 'user_id' => $this->user_id, | ||
64 | + 'date_add' => $this->date_add, | ||
65 | + 'user_add_id' => $this->user_add_id, | ||
66 | + 'view_count' => $this->view_count, | ||
67 | + 'gallery_id' => $this->gallery_id, | ||
68 | + ]); | ||
69 | + | ||
70 | + $query->andFilterWhere(['like', 'name', $this->name]) | ||
71 | + ->andFilterWhere(['like', 'link', $this->link]) | ||
72 | + ->andFilterWhere(['like', 'city', $this->city]) | ||
73 | + ->andFilterWhere(['like', 'street', $this->street]) | ||
74 | + ->andFilterWhere(['like', 'house', $this->house]) | ||
75 | + ->andFilterWhere(['like', 'description', $this->description]) | ||
76 | + ->andFilterWhere(['like', 'cover', $this->cover]); | ||
77 | + | ||
78 | + return $dataProvider; | ||
79 | + } | ||
80 | +} |
common/models/Team.php
@@ -79,6 +79,14 @@ | @@ -79,6 +79,14 @@ | ||
79 | [ | 79 | [ |
80 | 'experience_from', | 80 | 'experience_from', |
81 | ], | 81 | ], |
82 | + 'integer', | ||
83 | + 'max' => 2016, | ||
84 | + 'min' => 1950, | ||
85 | + ], | ||
86 | + [ | ||
87 | + [ | ||
88 | + 'experience_from', | ||
89 | + ], | ||
82 | 'safe', | 90 | 'safe', |
83 | ], | 91 | ], |
84 | [ | 92 | [ |
@@ -94,6 +102,11 @@ | @@ -94,6 +102,11 @@ | ||
94 | 'string', | 102 | 'string', |
95 | 'max' => 255, | 103 | 'max' => 255, |
96 | ], | 104 | ], |
105 | + [ | ||
106 | + ['experience_from'], | ||
107 | + 'default', | ||
108 | + 'value' => date('Y'), | ||
109 | + ], | ||
97 | ]; | 110 | ]; |
98 | } | 111 | } |
99 | 112 | ||
@@ -124,4 +137,9 @@ | @@ -124,4 +137,9 @@ | ||
124 | return $this->hasOne(Department::className(), [ 'department_id' => 'department_id' ]); | 137 | return $this->hasOne(Department::className(), [ 'department_id' => 'department_id' ]); |
125 | } | 138 | } |
126 | 139 | ||
140 | + public function getUser() | ||
141 | + { | ||
142 | + return $this->lastname. ' ' . $this->firstname . ' ' . $this->middlename; | ||
143 | + } | ||
144 | + | ||
127 | } | 145 | } |
common/models/TeamSearch.php
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | -namespace common\models; | ||
4 | - | ||
5 | -use Yii; | ||
6 | -use yii\base\Model; | ||
7 | -use yii\data\ActiveDataProvider; | ||
8 | -use common\models\Team; | ||
9 | - | ||
10 | -/** | ||
11 | - * TeamSearch represents the model behind the search form about `common\models\Team`. | ||
12 | - */ | ||
13 | -class TeamSearch extends Team | ||
14 | -{ | ||
15 | - /** | ||
16 | - * @inheritdoc | ||
17 | - */ | ||
18 | - public function rules() | ||
19 | - { | ||
20 | - return [ | ||
21 | - [['team_id', 'user_id', 'department_id', 'user_add_id', 'experience_from'], 'integer'], | ||
22 | - [['firstname', 'lastname', 'middlename', 'link', 'position', 'date_add', 'photo', 'country_id'], 'safe'], | ||
23 | - ]; | ||
24 | - } | 3 | + namespace common\models; |
25 | 4 | ||
26 | - /** | ||
27 | - * @inheritdoc | ||
28 | - */ | ||
29 | - public function scenarios() | ||
30 | - { | ||
31 | - // bypass scenarios() implementation in the parent class | ||
32 | - return Model::scenarios(); | ||
33 | - } | 5 | + use Yii; |
6 | + use yii\base\Model; | ||
7 | + use yii\data\ActiveDataProvider; | ||
8 | + use common\models\Team; | ||
34 | 9 | ||
35 | /** | 10 | /** |
36 | - * Creates data provider instance with search query applied | ||
37 | - * | ||
38 | - * @param array $params | ||
39 | - * | ||
40 | - * @return ActiveDataProvider | 11 | + * TeamSearch represents the model behind the search form about `common\models\Team`. |
41 | */ | 12 | */ |
42 | - public function search($params) | 13 | + class TeamSearch extends Team |
43 | { | 14 | { |
44 | - $query = Team::find(); | ||
45 | 15 | ||
46 | - // add conditions that should always apply here | 16 | + public $user; |
47 | 17 | ||
48 | - $dataProvider = new ActiveDataProvider([ | ||
49 | - 'query' => $query, | ||
50 | - ]); | 18 | + public $department; |
51 | 19 | ||
52 | - $this->load($params); | 20 | + public $experience_from_from; |
53 | 21 | ||
54 | - if (!$this->validate()) { | ||
55 | - // uncomment the following line if you do not want to return any records when validation fails | ||
56 | - // $query->where('0=1'); | ||
57 | - return $dataProvider; | 22 | + public $experience_from_to; |
23 | + | ||
24 | + /** | ||
25 | + * @inheritdoc | ||
26 | + */ | ||
27 | + public function rules() | ||
28 | + { | ||
29 | + return [ | ||
30 | + [ | ||
31 | + [ | ||
32 | + 'team_id', | ||
33 | + 'user_id', | ||
34 | + 'department_id', | ||
35 | + 'user_add_id', | ||
36 | + 'experience_from', | ||
37 | + 'experience_from_from', | ||
38 | + 'experience_from_to', | ||
39 | + ], | ||
40 | + 'integer', | ||
41 | + ], | ||
42 | + [ | ||
43 | + [ | ||
44 | + 'experience_from_from', | ||
45 | + ], | ||
46 | + 'default', | ||
47 | + 'value' => 0, | ||
48 | + ], | ||
49 | + [ | ||
50 | + [ | ||
51 | + 'experience_from_to', | ||
52 | + ], | ||
53 | + 'default', | ||
54 | + 'value' => 100, | ||
55 | + ], | ||
56 | + [ | ||
57 | + [ | ||
58 | + 'department', | ||
59 | + 'firstname', | ||
60 | + 'lastname', | ||
61 | + 'user', | ||
62 | + 'middlename', | ||
63 | + 'link', | ||
64 | + 'position', | ||
65 | + 'date_add', | ||
66 | + 'photo', | ||
67 | + 'country_id', | ||
68 | + ], | ||
69 | + 'safe', | ||
70 | + ], | ||
71 | + ]; | ||
58 | } | 72 | } |
59 | 73 | ||
60 | - // grid filtering conditions | ||
61 | - $query->andFilterWhere([ | ||
62 | - 'team_id' => $this->team_id, | ||
63 | - 'user_id' => $this->user_id, | ||
64 | - 'department_id' => $this->department_id, | ||
65 | - 'date_add' => $this->date_add, | ||
66 | - 'user_add_id' => $this->user_add_id, | ||
67 | - 'experience_from' => $this->experience_from, | ||
68 | - ]); | ||
69 | - | ||
70 | - $query->andFilterWhere(['like', 'firstname', $this->firstname]) | ||
71 | - ->andFilterWhere(['like', 'lastname', $this->lastname]) | ||
72 | - ->andFilterWhere(['like', 'middlename', $this->middlename]) | ||
73 | - ->andFilterWhere(['like', 'link', $this->link]) | ||
74 | - ->andFilterWhere(['like', 'position', $this->position]) | ||
75 | - ->andFilterWhere(['like', 'photo', $this->photo]) | ||
76 | - ->andFilterWhere(['like', 'country_id', $this->country_id]); | ||
77 | - | ||
78 | - return $dataProvider; | 74 | + /** |
75 | + * @inheritdoc | ||
76 | + */ | ||
77 | + public function scenarios() | ||
78 | + { | ||
79 | + // bypass scenarios() implementation in the parent class | ||
80 | + return Model::scenarios(); | ||
81 | + } | ||
82 | + | ||
83 | + /** | ||
84 | + * Creates data provider instance with search query applied | ||
85 | + * | ||
86 | + * @param array $params | ||
87 | + * | ||
88 | + * @return ActiveDataProvider | ||
89 | + */ | ||
90 | + public function search($params) | ||
91 | + { | ||
92 | + $query = Team::find(); | ||
93 | + | ||
94 | + // add conditions that should always apply here | ||
95 | + | ||
96 | + $dataProvider = new ActiveDataProvider([ | ||
97 | + 'query' => $query, | ||
98 | + ]); | ||
99 | + | ||
100 | + $this->load($params); | ||
101 | + | ||
102 | + if(!$this->validate()) { | ||
103 | + // uncomment the following line if you do not want to return any records when validation fails | ||
104 | + // $query->where('0=1'); | ||
105 | + return $dataProvider; | ||
106 | + } | ||
107 | + | ||
108 | + $query->joinWith(Department::tableName()); | ||
109 | + | ||
110 | + $dataProvider->setSort([ | ||
111 | + 'attributes' => [ | ||
112 | + 'team_id', | ||
113 | + 'position', | ||
114 | + 'country_id', | ||
115 | + 'user' => [ | ||
116 | + 'asc' => [ | ||
117 | + 'lastname' => SORT_ASC, | ||
118 | + 'firstname' => SORT_ASC, | ||
119 | + 'middlename' => SORT_ASC, | ||
120 | + ], | ||
121 | + 'desc' => [ | ||
122 | + 'lastname' => SORT_DESC, | ||
123 | + 'firstname' => SORT_DESC, | ||
124 | + 'middlename' => SORT_DESC, | ||
125 | + ], | ||
126 | + ], | ||
127 | + 'link' => [ | ||
128 | + 'asc' => [ | ||
129 | + 'link' => SORT_DESC, | ||
130 | + ], | ||
131 | + 'desc' => [ | ||
132 | + 'link' => SORT_ASC, | ||
133 | + ], | ||
134 | + ], | ||
135 | + 'department' => [ | ||
136 | + 'asc' => [ | ||
137 | + Department::tableName() . '.name' => SORT_ASC, | ||
138 | + ], | ||
139 | + 'desc' => [ | ||
140 | + Department::tableName() . '.name' => SORT_DESC, | ||
141 | + ], | ||
142 | + ], | ||
143 | + 'experience_from' => [ | ||
144 | + 'asc' => [ | ||
145 | + 'experience_from' => SORT_DESC, | ||
146 | + ], | ||
147 | + 'desc' => [ | ||
148 | + 'experience_from' => SORT_ASC, | ||
149 | + ], | ||
150 | + ], | ||
151 | + ], | ||
152 | + ]); | ||
153 | + | ||
154 | + // grid filtering conditions | ||
155 | + $query->andFilterWhere([ | ||
156 | + 'team_id' => $this->team_id, | ||
157 | + 'user_id' => $this->user_id, | ||
158 | + 'department_id' => $this->department_id, | ||
159 | + 'date_add' => $this->date_add, | ||
160 | + 'user_add_id' => $this->user_add_id, | ||
161 | + ]); | ||
162 | + | ||
163 | + $query->andFilterWhere([ | ||
164 | + 'between', | ||
165 | + 'experience_from', | ||
166 | + $this->experience_from_to ? ( date('Y') - $this->experience_from_to ) : ( date('Y') - 100 ), | ||
167 | + $this->experience_from_from ? ( date('Y') - $this->experience_from_from ) : date('Y'), | ||
168 | + ]); | ||
169 | + | ||
170 | + if(!empty( $this->link ) || $this->link === '0') { | ||
171 | + $query->andFilterWhere([ | ||
172 | + $this->link ? '>' : '=', | ||
173 | + 'char_length(link)', | ||
174 | + 0, | ||
175 | + ]); | ||
176 | + } | ||
177 | + | ||
178 | + $query->andFilterWhere([ | ||
179 | + 'like', | ||
180 | + 'firstname', | ||
181 | + $this->firstname, | ||
182 | + ]) | ||
183 | + ->andFilterWhere([ | ||
184 | + 'like', | ||
185 | + 'lastname', | ||
186 | + $this->lastname, | ||
187 | + ]) | ||
188 | + ->andFilterWhere([ | ||
189 | + 'like', | ||
190 | + 'middlename', | ||
191 | + $this->middlename, | ||
192 | + ]) | ||
193 | + ->andFilterWhere([ | ||
194 | + 'like', | ||
195 | + 'position', | ||
196 | + $this->position, | ||
197 | + ]) | ||
198 | + ->andFilterWhere([ | ||
199 | + 'like', | ||
200 | + 'photo', | ||
201 | + $this->photo, | ||
202 | + ]) | ||
203 | + ->andFilterWhere([ | ||
204 | + 'like', | ||
205 | + 'country_id', | ||
206 | + $this->country_id, | ||
207 | + ]) | ||
208 | + ->andFilterWhere([ | ||
209 | + 'or', | ||
210 | + [ | ||
211 | + 'like', | ||
212 | + 'lastname', | ||
213 | + $this->user, | ||
214 | + ], | ||
215 | + [ | ||
216 | + 'like', | ||
217 | + 'firstname', | ||
218 | + $this->user, | ||
219 | + ], | ||
220 | + [ | ||
221 | + 'like', | ||
222 | + 'middlename', | ||
223 | + $this->user, | ||
224 | + ], | ||
225 | + ]) | ||
226 | + ->andFilterWhere([ | ||
227 | + 'like', | ||
228 | + 'department.name', | ||
229 | + $this->department, | ||
230 | + ]); | ||
231 | + | ||
232 | + return $dataProvider; | ||
233 | + } | ||
79 | } | 234 | } |
80 | -} |
common/models/Vacancy.php
@@ -68,10 +68,15 @@ | @@ -68,10 +68,15 @@ | ||
68 | 'string', | 68 | 'string', |
69 | ], | 69 | ], |
70 | [ | 70 | [ |
71 | - ['employmentInput'], | 71 | + [ 'employmentInput' ], |
72 | 'safe', | 72 | 'safe', |
73 | ], | 73 | ], |
74 | [ | 74 | [ |
75 | + [ 'view_count' ], | ||
76 | + 'default', | ||
77 | + 'value' => 0, | ||
78 | + ], | ||
79 | + [ | ||
75 | [ | 80 | [ |
76 | 'name', | 81 | 'name', |
77 | 'link', | 82 | 'link', |
@@ -90,16 +95,16 @@ | @@ -90,16 +95,16 @@ | ||
90 | public function attributeLabels() | 95 | public function attributeLabels() |
91 | { | 96 | { |
92 | return [ | 97 | return [ |
93 | - 'vacancy_id' => Yii::t('app', 'Vacancy ID'), | ||
94 | - 'user_id' => Yii::t('app', 'User ID'), | ||
95 | - 'name' => Yii::t('app', 'Название'), | ||
96 | - 'link' => Yii::t('app', 'URL'), | ||
97 | - 'date_add' => Yii::t('app', 'Дата добавления'), | ||
98 | - 'user_add_id' => Yii::t('app', 'User Add ID'), | ||
99 | - 'view_count' => Yii::t('app', 'Количество просмотров'), | ||
100 | - 'user_name' => Yii::t('app', 'Контактное лицо'), | ||
101 | - 'city' => Yii::t('app', 'Город'), | ||
102 | - 'description' => Yii::t('app', 'Описание'), | 98 | + 'vacancy_id' => Yii::t('app', 'Vacancy ID'), |
99 | + 'user_id' => Yii::t('app', 'User ID'), | ||
100 | + 'name' => Yii::t('app', 'Название'), | ||
101 | + 'link' => Yii::t('app', 'URL'), | ||
102 | + 'date_add' => Yii::t('app', 'Дата добавления'), | ||
103 | + 'user_add_id' => Yii::t('app', 'User Add ID'), | ||
104 | + 'view_count' => Yii::t('app', 'Количество просмотров'), | ||
105 | + 'user_name' => Yii::t('app', 'Контактное лицо'), | ||
106 | + 'city' => Yii::t('app', 'Город'), | ||
107 | + 'description' => Yii::t('app', 'Описание'), | ||
103 | 'employmentInput' => Yii::t('app', 'Вид занятости'), | 108 | 'employmentInput' => Yii::t('app', 'Вид занятости'), |
104 | ]; | 109 | ]; |
105 | } | 110 | } |
1 | +<?php | ||
2 | + | ||
3 | +namespace common\models; | ||
4 | + | ||
5 | +use Yii; | ||
6 | +use yii\base\Model; | ||
7 | +use yii\data\ActiveDataProvider; | ||
8 | +use common\models\Vacancy; | ||
9 | + | ||
10 | +/** | ||
11 | + * VacancySearch represents the model behind the search form about `common\models\Vacancy`. | ||
12 | + */ | ||
13 | +class VacancySearch extends Vacancy | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @inheritdoc | ||
17 | + */ | ||
18 | + public function rules() | ||
19 | + { | ||
20 | + return [ | ||
21 | + [['vacancy_id', 'user_id', 'user_add_id', 'view_count'], 'integer'], | ||
22 | + [['name', 'link', 'date_add', 'user_name', 'city', 'description'], 'safe'], | ||
23 | + ]; | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * @inheritdoc | ||
28 | + */ | ||
29 | + public function scenarios() | ||
30 | + { | ||
31 | + // bypass scenarios() implementation in the parent class | ||
32 | + return Model::scenarios(); | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * Creates data provider instance with search query applied | ||
37 | + * | ||
38 | + * @param array $params | ||
39 | + * | ||
40 | + * @return ActiveDataProvider | ||
41 | + */ | ||
42 | + public function search($params) | ||
43 | + { | ||
44 | + $query = Vacancy::find(); | ||
45 | + | ||
46 | + // add conditions that should always apply here | ||
47 | + | ||
48 | + $dataProvider = new ActiveDataProvider([ | ||
49 | + 'query' => $query, | ||
50 | + ]); | ||
51 | + | ||
52 | + $this->load($params); | ||
53 | + | ||
54 | + if (!$this->validate()) { | ||
55 | + // uncomment the following line if you do not want to return any records when validation fails | ||
56 | + // $query->where('0=1'); | ||
57 | + return $dataProvider; | ||
58 | + } | ||
59 | + | ||
60 | + // grid filtering conditions | ||
61 | + $query->andFilterWhere([ | ||
62 | + 'vacancy_id' => $this->vacancy_id, | ||
63 | + 'user_id' => $this->user_id, | ||
64 | + 'date_add' => $this->date_add, | ||
65 | + 'user_add_id' => $this->user_add_id, | ||
66 | + 'view_count' => $this->view_count, | ||
67 | + ]); | ||
68 | + | ||
69 | + $query->andFilterWhere(['like', 'name', $this->name]) | ||
70 | + ->andFilterWhere(['like', 'link', $this->link]) | ||
71 | + ->andFilterWhere(['like', 'user_name', $this->user_name]) | ||
72 | + ->andFilterWhere(['like', 'city', $this->city]) | ||
73 | + ->andFilterWhere(['like', 'description', $this->description]); | ||
74 | + | ||
75 | + return $dataProvider; | ||
76 | + } | ||
77 | +} |
console/migrations/m160208_091942_vacancies.php
@@ -15,7 +15,7 @@ class m160208_091942_vacancies extends Migration | @@ -15,7 +15,7 @@ class m160208_091942_vacancies extends Migration | ||
15 | 'link' => $this->string(255), | 15 | 'link' => $this->string(255), |
16 | 'date_add' => $this->timestamp(), | 16 | 'date_add' => $this->timestamp(), |
17 | 'user_add_id' => $this->integer(), | 17 | 'user_add_id' => $this->integer(), |
18 | - 'view_count' => $this->integer(), | 18 | + 'view_count' => $this->integer()->defaultValue(0), |
19 | 'user_name' => $this->string(255), | 19 | 'user_name' => $this->string(255), |
20 | 'city' => $this->string(255), | 20 | 'city' => $this->string(255), |
21 | 'description' => $this->text(), | 21 | 'description' => $this->text(), |
frontend/controllers/AccountsController.php
@@ -20,11 +20,13 @@ | @@ -20,11 +20,13 @@ | ||
20 | use common\models\UserPayment; | 20 | use common\models\UserPayment; |
21 | use common\models\UserSpecialization; | 21 | use common\models\UserSpecialization; |
22 | use common\models\Vacancy; | 22 | use common\models\Vacancy; |
23 | + use common\models\VacancySearch; | ||
23 | use Yii; | 24 | use Yii; |
24 | use common\models\User; | 25 | use common\models\User; |
25 | use common\models\UserInfo; | 26 | use common\models\UserInfo; |
26 | 27 | ||
27 | use yii\filters\AccessControl; | 28 | use yii\filters\AccessControl; |
29 | + use yii\filters\VerbFilter; | ||
28 | use yii\web\Controller; | 30 | use yii\web\Controller; |
29 | use yii\web\NotFoundHttpException; | 31 | use yii\web\NotFoundHttpException; |
30 | 32 | ||
@@ -49,9 +51,59 @@ | @@ -49,9 +51,59 @@ | ||
49 | ], | 51 | ], |
50 | ], | 52 | ], |
51 | ], | 53 | ], |
54 | + 'verbs' => [ | ||
55 | + 'class' => VerbFilter::className(), | ||
56 | + 'actions' => [ | ||
57 | + 'team-delete' => [ 'POST' ], | ||
58 | + ], | ||
59 | + ], | ||
52 | ]; | 60 | ]; |
53 | } | 61 | } |
54 | 62 | ||
63 | + public function actionAddSkills() | ||
64 | + { | ||
65 | + $user = \Yii::$app->user->identity; | ||
66 | + if(!empty( \Yii::$app->request->post() )) { | ||
67 | + Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru'); | ||
68 | + } | ||
69 | + return $this->render('add-skills', [ 'user' => $user ]); | ||
70 | + } | ||
71 | + | ||
72 | + public function actionBlog() | ||
73 | + { | ||
74 | + return $this->render('blog'); | ||
75 | + } | ||
76 | + | ||
77 | + public function actionBlogCreate() | ||
78 | + { | ||
79 | + $blog = new Blog(); | ||
80 | + $post = \Yii::$app->request->post(); | ||
81 | + if($blog->load($post) && $blog->save()) { | ||
82 | + return $this->redirect([ | ||
83 | + 'blog-update', | ||
84 | + [ 'id' => $blog->blog_id ], | ||
85 | + ]); | ||
86 | + } else { | ||
87 | + return $this->render('_blog_form', [ 'blog' => $blog ]); | ||
88 | + } | ||
89 | + } | ||
90 | + | ||
91 | + public function actionBlogUpdate($id) | ||
92 | + { | ||
93 | + $blog = Blog::findOne($id); | ||
94 | + $post = \Yii::$app->request->post(); | ||
95 | + if($blog->load($post) && $blog->save()) { | ||
96 | + return $this->redirect('blog'); | ||
97 | + } else { | ||
98 | + return $this->render('_blog_form', [ 'blog' => $blog ]); | ||
99 | + } | ||
100 | + } | ||
101 | + | ||
102 | + public function actionBookmarks() | ||
103 | + { | ||
104 | + return $this->render('bookmarks'); | ||
105 | + } | ||
106 | + | ||
55 | public function actionCabinet() | 107 | public function actionCabinet() |
56 | { | 108 | { |
57 | 109 | ||
@@ -81,9 +133,120 @@ | @@ -81,9 +133,120 @@ | ||
81 | 133 | ||
82 | } | 134 | } |
83 | 135 | ||
84 | - public function actionBookmarks() | 136 | + public function actionContacts() |
85 | { | 137 | { |
86 | - return $this->render('bookmarks'); | 138 | + $user_info = UserInfo::find() |
139 | + ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
140 | + ->one(); | ||
141 | + if(empty( $user_info )) { | ||
142 | + $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); | ||
143 | + } | ||
144 | + if(!empty( \Yii::$app->request->post() )) { | ||
145 | + Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru'); | ||
146 | + $user_info->load(\Yii::$app->request->post()); | ||
147 | + $user_info->save(); | ||
148 | + } | ||
149 | + return $this->render('contacts', [ 'user_info' => $user_info ]); | ||
150 | + } | ||
151 | + | ||
152 | + public function actionDescription() | ||
153 | + { | ||
154 | + $user_info = UserInfo::find() | ||
155 | + ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
156 | + ->one(); | ||
157 | + if(empty( $user_info )) { | ||
158 | + $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); | ||
159 | + } | ||
160 | + $post = \Yii::$app->request->post(); | ||
161 | + if(!empty( $post )) { | ||
162 | + $user_info->load($post); | ||
163 | + $user_info->save(); | ||
164 | + } | ||
165 | + return $this->render('description', [ 'user_info' => $user_info ]); | ||
166 | + } | ||
167 | + | ||
168 | + public function actionEmployment() | ||
169 | + { | ||
170 | + $post = \Yii::$app->request->post(); | ||
171 | + if(!empty( $post )) { | ||
172 | + $job = [ ]; | ||
173 | + for($i = 0; $i < count($post[ 'Job' ]); $i++) { | ||
174 | + $job[ $i ] = new Job([ | ||
175 | + 'user_id' => \Yii::$app->user->getId(), | ||
176 | + 'current' => 0, | ||
177 | + ]); | ||
178 | + } | ||
179 | + if(Job::loadMultiple($job, $post)) { | ||
180 | + $job[ 0 ]->current = 1; | ||
181 | + if(Job::validateMultiple($job)) { | ||
182 | + Job::deleteAll([ 'user_id' => \Yii::$app->user->getId() ]); | ||
183 | + foreach($job as $onejob) { | ||
184 | + $onejob->save(false); | ||
185 | + } | ||
186 | + } | ||
187 | + } | ||
188 | + } else { | ||
189 | + $job = Job::find() | ||
190 | + ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
191 | + ->orderBy([ 'current' => SORT_DESC ]) | ||
192 | + ->all(); | ||
193 | + if(empty( $job )) { | ||
194 | + $job[] = new Job([ | ||
195 | + 'user_id' => \Yii::$app->user->getId(), | ||
196 | + 'current' => 0, | ||
197 | + ]); | ||
198 | + } | ||
199 | + if(!$job[ 0 ]->current) { | ||
200 | + array_unshift($job, new Job([ | ||
201 | + 'user_id' => \Yii::$app->user->getId(), | ||
202 | + 'current' => 1, | ||
203 | + ])); | ||
204 | + } | ||
205 | + } | ||
206 | + return $this->render('employment', [ 'job' => $job ]); | ||
207 | + } | ||
208 | + | ||
209 | + public function actionGallery() | ||
210 | + { | ||
211 | + | ||
212 | + } | ||
213 | + | ||
214 | + public function actionGalleryCreate() | ||
215 | + { | ||
216 | + $gallery = new Gallery(); | ||
217 | + $user = \Yii::$app->user->identity; | ||
218 | + $post = \Yii::$app->request->post(); | ||
219 | + if($gallery->load($post) && $gallery->save()) { | ||
220 | + Fields::saveFieldData(Yii::$app->request->post('Fields'), $gallery->gallery_id, Gallery::className(), 'ru'); | ||
221 | + return $this->redirect([ | ||
222 | + 'gallery-update', | ||
223 | + 'id' => $gallery->gallery_id, | ||
224 | + ]); | ||
225 | + } else { | ||
226 | + return $this->render('_gallery_form', [ | ||
227 | + 'gallery' => $gallery, | ||
228 | + 'user' => $user, | ||
229 | + ]); | ||
230 | + } | ||
231 | + } | ||
232 | + | ||
233 | + public function actionGalleryUpdate($id) | ||
234 | + { | ||
235 | + $gallery = Gallery::findOne($id); | ||
236 | + $user = \Yii::$app->user->identity; | ||
237 | + $post = \Yii::$app->request->post(); | ||
238 | + if($gallery->load($post) && $gallery->save()) { | ||
239 | + Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru'); | ||
240 | + return $this->redirect([ | ||
241 | + 'gallery-update', | ||
242 | + 'id' => $gallery->gallery_id, | ||
243 | + ]); | ||
244 | + } else { | ||
245 | + return $this->render('_gallery_form', [ | ||
246 | + 'gallery' => $gallery, | ||
247 | + 'user' => $user, | ||
248 | + ]); | ||
249 | + } | ||
87 | } | 250 | } |
88 | 251 | ||
89 | public function actionGeneral() | 252 | public function actionGeneral() |
@@ -119,34 +282,9 @@ | @@ -119,34 +282,9 @@ | ||
119 | ]); | 282 | ]); |
120 | } | 283 | } |
121 | 284 | ||
122 | - public function actionBlog() | ||
123 | - { | ||
124 | - return $this->render('blog'); | ||
125 | - } | ||
126 | - | ||
127 | - public function actionBlogCreate() | ||
128 | - { | ||
129 | - $blog = new Blog(); | ||
130 | - $post = \Yii::$app->request->post(); | ||
131 | - if($blog->load($post) && $blog->save()) { | ||
132 | - return $this->redirect([ | ||
133 | - 'blog-update', | ||
134 | - [ 'id' => $blog->blog_id ], | ||
135 | - ]); | ||
136 | - } else { | ||
137 | - return $this->render('_blog_form', [ 'blog' => $blog ]); | ||
138 | - } | ||
139 | - } | ||
140 | - | ||
141 | - public function actionBlogUpdate($id) | 285 | + public function actionGetForm($lastindex) |
142 | { | 286 | { |
143 | - $blog = Blog::findOne($id); | ||
144 | - $post = \Yii::$app->request->post(); | ||
145 | - if($blog->load($post) && $blog->save()) { | ||
146 | - return $this->redirect('blog'); | ||
147 | - } else { | ||
148 | - return $this->render('_blog_form', [ 'blog' => $blog ]); | ||
149 | - } | 287 | + return $this->renderAjax('_job_form', [ 'index' => $lastindex + 1 ]); |
150 | } | 288 | } |
151 | 289 | ||
152 | public function actionPortfolio() | 290 | public function actionPortfolio() |
@@ -214,176 +352,6 @@ | @@ -214,176 +352,6 @@ | ||
214 | ]); | 352 | ]); |
215 | } | 353 | } |
216 | 354 | ||
217 | - /** | ||
218 | - * $user User | ||
219 | - */ | ||
220 | - public function actionSetting() | ||
221 | - { | ||
222 | - $user = \Yii::$app->user->identity; | ||
223 | - $post = \Yii::$app->request->post('User'); | ||
224 | - if(!empty( $post )) { | ||
225 | - if(empty( $post[ 'new_password' ] )) { | ||
226 | - $user->addError('new_password', 'Введите новый пароль'); | ||
227 | - } else { | ||
228 | - $user->new_password = $post[ 'new_password' ]; | ||
229 | - } | ||
230 | - if(empty( $post[ 'old_password' ] )) { | ||
231 | - $user->addError('old_password', 'Введите новый пароль'); | ||
232 | - } else { | ||
233 | - $user->old_password = $post[ 'old_password' ]; | ||
234 | - } | ||
235 | - if(empty( $post[ 'password_reply' ] ) || $post[ 'password_reply' ] !== $post[ 'new_password' ]) { | ||
236 | - $user->addError('password_reply', 'Неправильный повтор пароля'); | ||
237 | - } else { | ||
238 | - $user->password_reply = $post[ 'password_reply' ]; | ||
239 | - } | ||
240 | - if(!$user->hasErrors()) { | ||
241 | - if($user->validatePassword($user->old_password)) { | ||
242 | - $user->setPassword($user->new_password); | ||
243 | - $user->generateAuthKey(); | ||
244 | - if($user->save()) { | ||
245 | - \Yii::$app->session->setFlash('passwordupdate', 'Пароль успешно обновлен'); | ||
246 | - } | ||
247 | - } else { | ||
248 | - $user->addError('old_password', 'Неправильный старый пароль'); | ||
249 | - } | ||
250 | - } | ||
251 | - } | ||
252 | - return $this->render('setting', [ 'user' => $user ]); | ||
253 | - } | ||
254 | - | ||
255 | - public function actionContacts() | ||
256 | - { | ||
257 | - $user_info = UserInfo::find() | ||
258 | - ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
259 | - ->one(); | ||
260 | - if(empty( $user_info )) { | ||
261 | - $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); | ||
262 | - } | ||
263 | - if(!empty( \Yii::$app->request->post() )) { | ||
264 | - Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru'); | ||
265 | - $user_info->load(\Yii::$app->request->post()); | ||
266 | - $user_info->save(); | ||
267 | - } | ||
268 | - return $this->render('contacts', [ 'user_info' => $user_info ]); | ||
269 | - } | ||
270 | - | ||
271 | - public function actionService() | ||
272 | - { | ||
273 | - $user = \Yii::$app->user->identity; | ||
274 | - $user_info = UserInfo::find() | ||
275 | - ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
276 | - ->one(); | ||
277 | - if(empty( $user_info )) { | ||
278 | - $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); | ||
279 | - } | ||
280 | - $specialization = Specialization::find() | ||
281 | - ->select([ | ||
282 | - 'specialization_name', | ||
283 | - 'specialization_id', | ||
284 | - ]) | ||
285 | - ->indexBy('specialization_id') | ||
286 | - ->asArray() | ||
287 | - ->column(); | ||
288 | - $payment = Payment::find() | ||
289 | - ->select([ | ||
290 | - 'name', | ||
291 | - 'payment_id', | ||
292 | - ]) | ||
293 | - ->indexBy('payment_id') | ||
294 | - ->asArray() | ||
295 | - ->column(); | ||
296 | - $post = \Yii::$app->request->post(); | ||
297 | - if(!empty( $post )) { | ||
298 | - $user_info->load($post); | ||
299 | - $user_info->validate(); | ||
300 | - if(!$user_info->hasErrors()) { | ||
301 | - $user_info->save(); | ||
302 | - $user->load($post); | ||
303 | - $user->unlinkAll('specializations', true); | ||
304 | - foreach($user->specializationInput as $one_specialization) { | ||
305 | - $user->link('specializations', Specialization::findOne($one_specialization)); | ||
306 | - } | ||
307 | - $user->unlinkAll('payments', true); | ||
308 | - foreach($user->paymentInput as $one_payment) { | ||
309 | - $user->link('payments', Payment::findOne($one_payment)); | ||
310 | - } | ||
311 | - } | ||
312 | - } | ||
313 | - return $this->render('service', [ | ||
314 | - 'user' => $user, | ||
315 | - 'user_info' => $user_info, | ||
316 | - 'specialization' => $specialization, | ||
317 | - 'payment' => $payment, | ||
318 | - ]); | ||
319 | - } | ||
320 | - | ||
321 | - public function actionAddSkills() | ||
322 | - { | ||
323 | - $user = \Yii::$app->user->identity; | ||
324 | - if(!empty( \Yii::$app->request->post() )) { | ||
325 | - Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru'); | ||
326 | - } | ||
327 | - return $this->render('add-skills', [ 'user' => $user ]); | ||
328 | - } | ||
329 | - | ||
330 | - public function actionDescription() | ||
331 | - { | ||
332 | - $user_info = UserInfo::find() | ||
333 | - ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
334 | - ->one(); | ||
335 | - if(empty( $user_info )) { | ||
336 | - $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); | ||
337 | - } | ||
338 | - $post = \Yii::$app->request->post(); | ||
339 | - if(!empty( $post )) { | ||
340 | - $user_info->load($post); | ||
341 | - $user_info->save(); | ||
342 | - } | ||
343 | - return $this->render('description', [ 'user_info' => $user_info ]); | ||
344 | - } | ||
345 | - | ||
346 | - public function actionEmployment() | ||
347 | - { | ||
348 | - $post = \Yii::$app->request->post(); | ||
349 | - if(!empty( $post )) { | ||
350 | - $job = [ ]; | ||
351 | - for($i = 0; $i < count($post[ 'Job' ]); $i++) { | ||
352 | - $job[ $i ] = new Job([ | ||
353 | - 'user_id' => \Yii::$app->user->getId(), | ||
354 | - 'current' => 0, | ||
355 | - ]); | ||
356 | - } | ||
357 | - if(Job::loadMultiple($job, $post)) { | ||
358 | - $job[ 0 ]->current = 1; | ||
359 | - if(Job::validateMultiple($job)) { | ||
360 | - Job::deleteAll([ 'user_id' => \Yii::$app->user->getId() ]); | ||
361 | - foreach($job as $onejob) { | ||
362 | - $onejob->save(false); | ||
363 | - } | ||
364 | - } | ||
365 | - } | ||
366 | - } else { | ||
367 | - $job = Job::find() | ||
368 | - ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
369 | - ->orderBy([ 'current' => SORT_DESC ]) | ||
370 | - ->all(); | ||
371 | - if(empty( $job )) { | ||
372 | - $job[] = new Job([ | ||
373 | - 'user_id' => \Yii::$app->user->getId(), | ||
374 | - 'current' => 0, | ||
375 | - ]); | ||
376 | - } | ||
377 | - if(!$job[ 0 ]->current) { | ||
378 | - array_unshift($job, new Job([ | ||
379 | - 'user_id' => \Yii::$app->user->getId(), | ||
380 | - 'current' => 1, | ||
381 | - ])); | ||
382 | - } | ||
383 | - } | ||
384 | - return $this->render('employment', [ 'job' => $job ]); | ||
385 | - } | ||
386 | - | ||
387 | public function actionProjects() | 355 | public function actionProjects() |
388 | { | 356 | { |
389 | return $this->render('projects'); | 357 | return $this->render('projects'); |
@@ -532,47 +500,92 @@ | @@ -532,47 +500,92 @@ | ||
532 | ]); | 500 | ]); |
533 | } | 501 | } |
534 | 502 | ||
535 | - public function actionGallery() | ||
536 | - { | ||
537 | - | ||
538 | - } | ||
539 | - | ||
540 | - public function actionGalleryCreate() | 503 | + public function actionService() |
541 | { | 504 | { |
542 | - $gallery = new Gallery(); | ||
543 | $user = \Yii::$app->user->identity; | 505 | $user = \Yii::$app->user->identity; |
506 | + $user_info = UserInfo::find() | ||
507 | + ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
508 | + ->one(); | ||
509 | + if(empty( $user_info )) { | ||
510 | + $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); | ||
511 | + } | ||
512 | + $specialization = Specialization::find() | ||
513 | + ->select([ | ||
514 | + 'specialization_name', | ||
515 | + 'specialization_id', | ||
516 | + ]) | ||
517 | + ->indexBy('specialization_id') | ||
518 | + ->asArray() | ||
519 | + ->column(); | ||
520 | + $payment = Payment::find() | ||
521 | + ->select([ | ||
522 | + 'name', | ||
523 | + 'payment_id', | ||
524 | + ]) | ||
525 | + ->indexBy('payment_id') | ||
526 | + ->asArray() | ||
527 | + ->column(); | ||
544 | $post = \Yii::$app->request->post(); | 528 | $post = \Yii::$app->request->post(); |
545 | - if($gallery->load($post) && $gallery->save()) { | ||
546 | - Fields::saveFieldData(Yii::$app->request->post('Fields'), $gallery->gallery_id, Gallery::className(), 'ru'); | ||
547 | - return $this->redirect([ | ||
548 | - 'gallery-update', | ||
549 | - 'id' => $gallery->gallery_id, | ||
550 | - ]); | ||
551 | - } else { | ||
552 | - return $this->render('_gallery_form', [ | ||
553 | - 'gallery' => $gallery, | ||
554 | - 'user' => $user, | ||
555 | - ]); | 529 | + if(!empty( $post )) { |
530 | + $user_info->load($post); | ||
531 | + $user_info->validate(); | ||
532 | + if(!$user_info->hasErrors()) { | ||
533 | + $user_info->save(); | ||
534 | + $user->load($post); | ||
535 | + $user->unlinkAll('specializations', true); | ||
536 | + foreach($user->specializationInput as $one_specialization) { | ||
537 | + $user->link('specializations', Specialization::findOne($one_specialization)); | ||
538 | + } | ||
539 | + $user->unlinkAll('payments', true); | ||
540 | + foreach($user->paymentInput as $one_payment) { | ||
541 | + $user->link('payments', Payment::findOne($one_payment)); | ||
542 | + } | ||
543 | + } | ||
556 | } | 544 | } |
545 | + return $this->render('service', [ | ||
546 | + 'user' => $user, | ||
547 | + 'user_info' => $user_info, | ||
548 | + 'specialization' => $specialization, | ||
549 | + 'payment' => $payment, | ||
550 | + ]); | ||
557 | } | 551 | } |
558 | 552 | ||
559 | - public function actionGalleryUpdate($id) | 553 | + /** |
554 | + * $user User | ||
555 | + */ | ||
556 | + public function actionSetting() | ||
560 | { | 557 | { |
561 | - $gallery = Gallery::findOne($id); | ||
562 | $user = \Yii::$app->user->identity; | 558 | $user = \Yii::$app->user->identity; |
563 | - $post = \Yii::$app->request->post(); | ||
564 | - if($gallery->load($post) && $gallery->save()) { | ||
565 | - Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru'); | ||
566 | - return $this->redirect([ | ||
567 | - 'gallery-update', | ||
568 | - 'id' => $gallery->gallery_id, | ||
569 | - ]); | ||
570 | - } else { | ||
571 | - return $this->render('_gallery_form', [ | ||
572 | - 'gallery' => $gallery, | ||
573 | - 'user' => $user, | ||
574 | - ]); | 559 | + $post = \Yii::$app->request->post('User'); |
560 | + if(!empty( $post )) { | ||
561 | + if(empty( $post[ 'new_password' ] )) { | ||
562 | + $user->addError('new_password', 'Введите новый пароль'); | ||
563 | + } else { | ||
564 | + $user->new_password = $post[ 'new_password' ]; | ||
565 | + } | ||
566 | + if(empty( $post[ 'old_password' ] )) { | ||
567 | + $user->addError('old_password', 'Введите новый пароль'); | ||
568 | + } else { | ||
569 | + $user->old_password = $post[ 'old_password' ]; | ||
570 | + } | ||
571 | + if(empty( $post[ 'password_reply' ] ) || $post[ 'password_reply' ] !== $post[ 'new_password' ]) { | ||
572 | + $user->addError('password_reply', 'Неправильный повтор пароля'); | ||
573 | + } else { | ||
574 | + $user->password_reply = $post[ 'password_reply' ]; | ||
575 | + } | ||
576 | + if(!$user->hasErrors()) { | ||
577 | + if($user->validatePassword($user->old_password)) { | ||
578 | + $user->setPassword($user->new_password); | ||
579 | + $user->generateAuthKey(); | ||
580 | + if($user->save()) { | ||
581 | + \Yii::$app->session->setFlash('passwordupdate', 'Пароль успешно обновлен'); | ||
582 | + } | ||
583 | + } else { | ||
584 | + $user->addError('old_password', 'Неправильный старый пароль'); | ||
585 | + } | ||
586 | + } | ||
575 | } | 587 | } |
588 | + return $this->render('setting', [ 'user' => $user ]); | ||
576 | } | 589 | } |
577 | 590 | ||
578 | public function actionTeam() | 591 | public function actionTeam() |
@@ -648,9 +661,22 @@ | @@ -648,9 +661,22 @@ | ||
648 | } | 661 | } |
649 | } | 662 | } |
650 | 663 | ||
664 | + public function actionTeamDelete($id) | ||
665 | + { | ||
666 | + Team::findOne($id) | ||
667 | + ->delete(); | ||
668 | + $this->redirect('team'); | ||
669 | + } | ||
670 | + | ||
651 | public function actionVacancy() | 671 | public function actionVacancy() |
652 | { | 672 | { |
653 | - $this->render('vacancy'); | 673 | + $searchModel = new VacancySearch(); |
674 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
675 | + | ||
676 | + return $this->render('vacancy', [ | ||
677 | + 'searchModel' => $searchModel, | ||
678 | + 'dataProvider' => $dataProvider, | ||
679 | + ]); | ||
654 | } | 680 | } |
655 | 681 | ||
656 | public function actionVacancyCreate() | 682 | public function actionVacancyCreate() |
@@ -721,9 +747,11 @@ | @@ -721,9 +747,11 @@ | ||
721 | ]); | 747 | ]); |
722 | } | 748 | } |
723 | 749 | ||
724 | - public function actionGetForm($lastindex) | 750 | + public function actionVacancyDelete($id) |
725 | { | 751 | { |
726 | - return $this->renderAjax('_job_form', [ 'index' => $lastindex + 1 ]); | 752 | + Vacancy::findOne($id) |
753 | + ->delete(); | ||
754 | + $this->redirect('vacancy'); | ||
727 | } | 755 | } |
728 | 756 | ||
729 | /** | 757 | /** |
frontend/views/accounts/_job_form.php
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | * @var integer $index | 3 | * @var integer $index |
4 | */ | 4 | */ |
5 | use common\models\Job; | 5 | use common\models\Job; |
6 | + use yii\helpers\Html; | ||
6 | use yii\jui\DatePicker; | 7 | use yii\jui\DatePicker; |
7 | use yii\widgets\ActiveForm; | 8 | use yii\widgets\ActiveForm; |
8 | 9 | ||
@@ -30,6 +31,7 @@ | @@ -30,6 +31,7 @@ | ||
30 | echo $form->field ($model, '[' . $index . ']complete_count') | 31 | echo $form->field ($model, '[' . $index . ']complete_count') |
31 | ->label ('из них реализовано') | 32 | ->label ('из них реализовано') |
32 | ->input ('number'); | 33 | ->input ('number'); |
34 | + echo Html::button('Удалить', ['class' => 'remove_job_button']); | ||
33 | echo "</div></div>"; | 35 | echo "</div></div>"; |
34 | $form->end (); | 36 | $form->end (); |
35 | ?> | 37 | ?> |
frontend/views/accounts/employment.php
@@ -25,9 +25,9 @@ | @@ -25,9 +25,9 @@ | ||
25 | echo $form->field ($current, '[0]link') | 25 | echo $form->field ($current, '[0]link') |
26 | ->label ('Ссылка на компанию на сайте МФП') | 26 | ->label ('Ссылка на компанию на сайте МФП') |
27 | ->textInput (); | 27 | ->textInput (); |
28 | - echo $form->field ($current, '[0]date_start') | 28 | + echo $form->field ($current, '[0]date_start', ['options' => ['class' => 'test2class']]) |
29 | ->label ('Дата начала работы') | 29 | ->label ('Дата начала работы') |
30 | - ->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']); | 30 | + ->widget (DatePicker::className (), ['options' => ['class' => 'testclass'], 'language' => 'ru', 'dateFormat' => 'dd-MM-yyyy', 'clientOptions' => ['changeYear' => true, 'yearRange' => 'c-20:c', 'changeMonth' => true]]); |
31 | echo $form->field ($current, '[0]position') | 31 | echo $form->field ($current, '[0]position') |
32 | ->label ('Должность') | 32 | ->label ('Должность') |
33 | ->textInput (); | 33 | ->textInput (); |
@@ -67,6 +67,7 @@ | @@ -67,6 +67,7 @@ | ||
67 | echo $form->field ($job_model, '['. ($index + 1) .']complete_count') | 67 | echo $form->field ($job_model, '['. ($index + 1) .']complete_count') |
68 | ->label ('из них реализовано') | 68 | ->label ('из них реализовано') |
69 | ->input ('number'); | 69 | ->input ('number'); |
70 | + echo Html::button('Удалить', ['class' => 'remove_job_button']); | ||
70 | echo "</div>"; | 71 | echo "</div>"; |
71 | } | 72 | } |
72 | ?> | 73 | ?> |
@@ -82,11 +83,20 @@ | @@ -82,11 +83,20 @@ | ||
82 | $(document).on('click', '#add_job_button', function() { | 83 | $(document).on('click', '#add_job_button', function() { |
83 | var inputs = $('.prev_job_inputs').last(); | 84 | var inputs = $('.prev_job_inputs').last(); |
84 | var name = $(inputs).find('input, textarea').first().attr('name'); | 85 | var name = $(inputs).find('input, textarea').first().attr('name'); |
85 | - var lastindex = regexp.exec(name)[1]; | 86 | + var result = regexp.exec(name); |
87 | + var lastindex; | ||
88 | + if(result != null) { | ||
89 | + lastindex = result[1]; | ||
90 | + } else { | ||
91 | + lastindex = 1; | ||
92 | + } | ||
86 | $.get('/accounts/get-form', { lastindex: lastindex }, function(data) { | 93 | $.get('/accounts/get-form', { lastindex: lastindex }, function(data) { |
87 | $('.prev_job_container').append($(data).find('.ajax-loaded').first().html()); | 94 | $('.prev_job_container').append($(data).find('.ajax-loaded').first().html()); |
88 | $(data).filter('script').appendTo('body'); | 95 | $(data).filter('script').appendTo('body'); |
89 | }); | 96 | }); |
90 | }); | 97 | }); |
98 | + $(document).on('click', '.remove_job_button', function() { | ||
99 | + $(this).parents('.prev_job_inputs').remove(); | ||
100 | + }); | ||
91 | }); | 101 | }); |
92 | </script> | 102 | </script> |
frontend/views/accounts/portfolio.php
1 | <?php | 1 | <?php |
2 | -use common\models\Option; | ||
3 | -use yii\helpers\Html; | ||
4 | -use yii\widgets\ActiveForm; | ||
5 | -use \common\widgets\MultiLangForm; | 2 | + /** |
3 | + * @var PortfolioSearch $searchModel | ||
4 | + * @var ActiveDataProvider $dataProvider | ||
5 | + */ | ||
6 | + use common\models\PortfolioSearch; | ||
7 | + use yii\data\ActiveDataProvider; | ||
8 | + use yii\grid\ActionColumn; | ||
9 | + use yii\grid\GridView; | ||
10 | + use yii\helpers\Html; | ||
6 | 11 | ||
7 | - $this->title = 'Мой профиль'; | ||
8 | - $this->params['breadcrumbs'][] = $this->title; | 12 | + $this->title = 'Портфолио'; |
13 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
9 | ?> | 14 | ?> |
10 | -<h1><?= $this->title ?></h1> | ||
11 | \ No newline at end of file | 15 | \ No newline at end of file |
16 | +<h1><?= $this->title ?></h1> | ||
17 | +<p> | ||
18 | + <?= Html::a(Yii::t('app', 'Добавить'), [ 'vacancy-create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
19 | +</p> | ||
20 | +<?= GridView::widget([ | ||
21 | + 'dataProvider' => $dataProvider, | ||
22 | + 'filterModel' => $searchModel, | ||
23 | + 'columns' => [ | ||
24 | + [ | ||
25 | + 'attribute' => 'vacancy_id', | ||
26 | + 'label' => 'ID', | ||
27 | + ], | ||
28 | + 'name', | ||
29 | + 'view_count', | ||
30 | + [ | ||
31 | + 'class' => ActionColumn::className(), | ||
32 | + 'buttons' => [ | ||
33 | + 'update' => function($url, $model, $key) { | ||
34 | + return Html::a('Update', [ | ||
35 | + 'vacancy-update', | ||
36 | + 'id' => $model->vacancy_id, | ||
37 | + ]); | ||
38 | + }, | ||
39 | + 'delete' => function($url, $model, $key) { | ||
40 | + return Html::a('Delete', [ | ||
41 | + 'vacancy-delete', | ||
42 | + 'id' => $model->vacancy_id, | ||
43 | + ], [ | ||
44 | + 'title' => 'Удалить', | ||
45 | + 'aria-label' => 'Удалить', | ||
46 | + 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', | ||
47 | + 'data-method' => 'post', | ||
48 | + 'data-pjax' => '0', | ||
49 | + ]); | ||
50 | + }, | ||
51 | + ], | ||
52 | + 'template' => '{update} {delete}', | ||
53 | + ], | ||
54 | + ], | ||
55 | +]); ?> |
frontend/views/accounts/team.php
@@ -7,58 +7,101 @@ | @@ -7,58 +7,101 @@ | ||
7 | use yii\data\ActiveDataProvider; | 7 | use yii\data\ActiveDataProvider; |
8 | use yii\grid\GridView; | 8 | use yii\grid\GridView; |
9 | use yii\helpers\Html; | 9 | use yii\helpers\Html; |
10 | + use yii\widgets\ActiveField; | ||
10 | 11 | ||
11 | $this->title = 'Команда'; | 12 | $this->title = 'Команда'; |
12 | $this->params[ 'breadcrumbs' ][] = $this->title; | 13 | $this->params[ 'breadcrumbs' ][] = $this->title; |
13 | ?> | 14 | ?> |
14 | - <h1><?= $this->title ?></h1> | ||
15 | - <p> | ||
16 | - <?= Html::a(Yii::t('app', 'Добавить'), [ 'team-create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
17 | - </p> | 15 | +<h1><?= $this->title ?></h1> |
16 | +<p> | ||
17 | + <?= Html::a(Yii::t('app', 'Добавить'), [ 'team-create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
18 | +</p> | ||
18 | <?= GridView::widget([ | 19 | <?= GridView::widget([ |
19 | 'dataProvider' => $dataProvider, | 20 | 'dataProvider' => $dataProvider, |
20 | 'filterModel' => $searchModel, | 21 | 'filterModel' => $searchModel, |
21 | 'columns' => [ | 22 | 'columns' => [ |
22 | [ | 23 | [ |
23 | 'attribute' => 'team_id', | 24 | 'attribute' => 'team_id', |
24 | - 'label' => 'ID', | 25 | + 'label' => 'ID', |
25 | ], | 26 | ], |
26 | [ | 27 | [ |
27 | - 'value' => function($model, $key, $index, $column) { | ||
28 | - return $model->lastname.' '.$model->firstname.' '.$model->middlename; | ||
29 | - }, | ||
30 | - 'label' => 'ФИО', | 28 | + 'attribute' => 'user', |
29 | + 'label' => 'ФИО', | ||
31 | ], | 30 | ], |
32 | [ | 31 | [ |
33 | - 'value' => function($model, $key, $index, $column) { | ||
34 | - return \Yii::$app->formatter->asBoolean(!empty($model->link)); | ||
35 | - }, | ||
36 | - 'label' => 'Участник МФП', | 32 | + 'attribute' => 'link', |
33 | + 'format' => 'boolean', | ||
34 | + 'label' => 'Участник МФП', | ||
35 | + 'filter' => [ | ||
36 | + 1 => 'Да', | ||
37 | + 0 => 'Нет', | ||
38 | + ], | ||
37 | ], | 39 | ], |
38 | [ | 40 | [ |
39 | - 'attribute' => 'department.name', | ||
40 | - 'label' => 'Отдел компании', | 41 | + 'attribute' => 'department', |
42 | + 'value' => 'department.name', | ||
43 | + 'label' => 'Отдел компании', | ||
41 | ], | 44 | ], |
42 | [ | 45 | [ |
43 | - 'value' => function($model, $key, $index, $column) { | 46 | + 'attribute' => 'experience_from', |
47 | + 'value' => function($model, $key, $index, $column) { | ||
44 | return \Yii::$app->formatter->asDate(time(), 'yyyy') - $model->experience_from; | 48 | return \Yii::$app->formatter->asDate(time(), 'yyyy') - $model->experience_from; |
45 | }, | 49 | }, |
46 | - 'label' => 'Опыт, лет', | 50 | + 'label' => 'Опыт, лет', |
51 | + 'filter' => "<div class=\"input-group input-group-xs input-daterange\">" . (new ActiveField([ | ||
52 | + 'template' => '{input}', | ||
53 | + 'inputOptions' => [ | ||
54 | + 'style' => 'width:auto', | ||
55 | + 'class' => 'form-control', | ||
56 | + 'min' => '0', | ||
57 | + 'max' => '100', | ||
58 | + ], | ||
59 | + 'options' => [ | ||
60 | + 'tag' => 'span', | ||
61 | + 'class' => '', | ||
62 | + ], | ||
63 | + 'model' => $searchModel, | ||
64 | + 'attribute' => 'experience_from_from', | ||
65 | + ]))->input('number') . " | ||
66 | +<span class=\"input-group-addon kv-field-separator\"> | ||
67 | +<i class=\"glyphicon glyphicon-resize-horizontal\"></i> | ||
68 | +</span>" . (new ActiveField([ | ||
69 | + 'template' => '{input}', | ||
70 | + 'inputOptions' => [ | ||
71 | + 'style' => 'width:auto', | ||
72 | + 'class' => 'form-control', | ||
73 | + 'min' => '0', | ||
74 | + 'max' => '100', | ||
75 | + ], | ||
76 | + 'options' => [ | ||
77 | + 'tag' => 'span', | ||
78 | + 'class' => '', | ||
79 | + ], | ||
80 | + 'model' => $searchModel, | ||
81 | + 'attribute' => 'experience_from_to', | ||
82 | + ]))->input('number') . " | ||
83 | +</div>", | ||
47 | ], | 84 | ], |
48 | - 'team_id', | ||
49 | - 'user_id', | ||
50 | - 'firstname', | ||
51 | - 'lastname', | ||
52 | - 'middlename', | ||
53 | - // 'link', | ||
54 | - // 'position', | ||
55 | - // 'department_id', | ||
56 | - // 'date_add', | ||
57 | - // 'user_add_id', | ||
58 | - // 'photo', | ||
59 | - // 'country_id', | ||
60 | - // 'experience_from', | 85 | + 'position', |
86 | + 'country_id', | ||
61 | 87 | ||
62 | - [ 'class' => 'yii\grid\ActionColumn' ], | 88 | + [ |
89 | + 'class' => 'yii\grid\ActionColumn', | ||
90 | + 'buttons' => [ | ||
91 | + 'update' => function($url, $model, $key) { | ||
92 | + return Html::a('Update', ['team-update', 'id' => $model->team_id]); | ||
93 | + }, | ||
94 | + 'delete' => function($url, $model, $key) { | ||
95 | + return Html::a('Delete', ['team-delete', 'id' => $model->team_id], [ | ||
96 | + 'title' => 'Удалить', | ||
97 | + 'aria-label' => 'Удалить', | ||
98 | + 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', | ||
99 | + 'data-method' => 'post', | ||
100 | + 'data-pjax' => '0', | ||
101 | + ]); | ||
102 | + }, | ||
103 | + ], | ||
104 | + 'template' => '{update} {delete}' | ||
105 | + ], | ||
63 | ], | 106 | ], |
64 | -]); ?> | ||
65 | \ No newline at end of file | 107 | \ No newline at end of file |
108 | +]); ?> |
1 | +<?php | ||
2 | + /** | ||
3 | + * @var VacancySearch $searchModel | ||
4 | + * @var ActiveDataProvider $dataProvider | ||
5 | + */ | ||
6 | + use common\models\VacancySearch; | ||
7 | + use yii\data\ActiveDataProvider; | ||
8 | + use yii\grid\ActionColumn; | ||
9 | + use yii\grid\GridView; | ||
10 | + use yii\helpers\Html; | ||
11 | + | ||
12 | + $this->title = 'Вакансии'; | ||
13 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
14 | +?> | ||
15 | +<h1><?= $this->title ?></h1> | ||
16 | +<p> | ||
17 | + <?= Html::a(Yii::t('app', 'Добавить'), [ 'vacancy-create' ], [ 'class' => 'btn btn-success' ]) ?> | ||
18 | +</p> | ||
19 | +<?= GridView::widget([ | ||
20 | + 'dataProvider' => $dataProvider, | ||
21 | + 'filterModel' => $searchModel, | ||
22 | + 'columns' => [ | ||
23 | + [ | ||
24 | + 'attribute' => 'vacancy_id', | ||
25 | + 'label' => 'ID', | ||
26 | + ], | ||
27 | + 'name', | ||
28 | + 'view_count', | ||
29 | + [ | ||
30 | + 'class' => ActionColumn::className(), | ||
31 | + 'buttons' => [ | ||
32 | + 'update' => function($url, $model, $key) { | ||
33 | + return Html::a('Update', ['vacancy-update', 'id' => $model->vacancy_id]); | ||
34 | + }, | ||
35 | + 'delete' => function($url, $model, $key) { | ||
36 | + return Html::a('Delete', ['vacancy-delete', 'id' => $model->vacancy_id], [ | ||
37 | + 'title' => 'Удалить', | ||
38 | + 'aria-label' => 'Удалить', | ||
39 | + 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', | ||
40 | + 'data-method' => 'post', | ||
41 | + 'data-pjax' => '0', | ||
42 | + ]); | ||
43 | + }, | ||
44 | + ], | ||
45 | + 'template' => '{update} {delete}' | ||
46 | + ] | ||
47 | + ] | ||
48 | +]); ?> |