6310a439
Administrator
firs page
|
1
|
<?php
|
5f49082a
Yarik
test
|
2
3
|
namespace frontend\controllers;
|
84ebac3d
Yarik
test
|
4
|
use common\models\Blog;
|
989c83b0
Yarik
test
|
5
|
use common\models\BlogSearch;
|
5f49082a
Yarik
test
|
6
|
use common\models\CompanyInfo;
|
02524a34
Yarik
test
|
7
|
use common\models\Country;
|
9cc08528
Yarik
test
|
8
|
use common\models\Currency;
|
02524a34
Yarik
test
|
9
|
use common\models\Department;
|
ea09d15d
Yarik
test
|
10
|
use common\models\Employment;
|
37c8e264
Yarik
test
|
11
12
|
use common\models\FeedbackCompany;
use common\models\FeedbackCompanySearch;
|
5f49082a
Yarik
test
|
13
|
use common\models\Fields;
|
83b0052c
Yarik
test
|
14
|
use common\models\File;
|
ea09d15d
Yarik
test
|
15
|
use common\models\Gallery;
|
989c83b0
Yarik
test
|
16
|
use common\models\GallerySearch;
|
5f49082a
Yarik
test
|
17
18
19
|
use common\models\Job;
use common\models\Language;
use common\models\Payment;
|
7eb29439
Yarik
test
|
20
|
use common\models\Portfolio;
|
989c83b0
Yarik
test
|
21
|
use common\models\PortfolioSearch;
|
7eb29439
Yarik
test
|
22
|
use common\models\PortfolioSpecialization;
|
fdc1c9de
Yarik
test
|
23
|
use common\models\PortfolioUser;
|
2f324895
Yarik
test
|
24
|
use common\models\PortfolioUserSearch;
|
84ebac3d
Yarik
test
|
25
|
use common\models\Project;
|
989c83b0
Yarik
test
|
26
|
use common\models\ProjectSearch;
|
5f49082a
Yarik
test
|
27
|
use common\models\Specialization;
|
02524a34
Yarik
test
|
28
|
use common\models\Team;
|
b95371cf
Yarik
test
|
29
|
use common\models\TeamSearch;
|
5f49082a
Yarik
test
|
30
31
|
use common\models\UserPayment;
use common\models\UserSpecialization;
|
ea09d15d
Yarik
test
|
32
|
use common\models\Vacancy;
|
588209fc
Yarik
test
|
33
|
use common\models\VacancySearch;
|
5f49082a
Yarik
test
|
34
35
36
37
|
use Yii;
use common\models\User;
use common\models\UserInfo;
|
a02e2fdb
Yarik
test
|
38
|
use yii\base\ErrorException;
|
2f324895
Yarik
test
|
39
|
use yii\data\Sort;
|
a02e2fdb
Yarik
test
|
40
|
use yii\db\ActiveRecord;
|
5f49082a
Yarik
test
|
41
|
use yii\filters\AccessControl;
|
588209fc
Yarik
test
|
42
|
use yii\filters\VerbFilter;
|
5f49082a
Yarik
test
|
43
44
|
use yii\web\Controller;
use yii\web\NotFoundHttpException;
|
713ccea4
Yarik
test
|
45
|
use yii\web\Response;
|
83b0052c
Yarik
test
|
46
|
use yii\web\UploadedFile;
|
6310a439
Administrator
firs page
|
47
|
|
5f49082a
Yarik
test
|
48
49
50
51
52
|
/**
* Site controller
*/
class AccountsController extends Controller
{
|
6e1510b2
Administrator
firs page
|
53
|
|
5f49082a
Yarik
test
|
54
|
public $layout = 'admin';
|
6e1510b2
Administrator
firs page
|
55
|
|
a02e2fdb
Yarik
test
|
56
57
|
public $defaultAction = 'general';
|
5f49082a
Yarik
test
|
58
59
60
61
62
63
64
|
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
|
5f49082a
Yarik
test
|
65
66
67
|
'allow' => true,
'roles' => [ '@' ],
],
|
6310a439
Administrator
firs page
|
68
69
|
],
],
|
588209fc
Yarik
test
|
70
71
72
|
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
|
989c83b0
Yarik
test
|
73
74
75
76
77
|
'team-delete' => [ 'POST' ],
'vacancy-delete' => [ 'POST' ],
'portfolio-delete' => [ 'POST' ],
'projects-delete' => [ 'POST' ],
'blog-delete' => [ 'POST' ],
|
ce4a4468
Yarik
test
|
78
|
'gallery-cover' => [ 'POST' ],
|
37c8e264
Yarik
test
|
79
|
'feedback-delete' => [ 'POST' ],
|
713ccea4
Yarik
test
|
80
|
'feedback-read' => [ 'POST' ],
|
588209fc
Yarik
test
|
81
82
|
],
],
|
5f49082a
Yarik
test
|
83
84
|
];
}
|
6310a439
Administrator
firs page
|
85
|
|
2f324895
Yarik
test
|
86
87
88
89
90
91
92
93
|
public function beforeAction($action)
{
$portfolio_user_count = PortfolioUser::find()
->where([
'user_id' => \Yii::$app->user->id,
'status' => 2,
])
->count();
|
713ccea4
Yarik
test
|
94
95
96
97
98
99
|
$feedback_company_count = FeedbackCompany::find()
->where([
'user_id' => \Yii::$app->user->id,
'status' => FeedbackCompany::STATUS_NEW,
])
->count();
|
2f324895
Yarik
test
|
100
|
$this->view->params[ 'portfolio_user_count' ] = $portfolio_user_count;
|
713ccea4
Yarik
test
|
101
|
$this->view->params[ 'feedback_company_count' ] = $feedback_company_count;
|
2f324895
Yarik
test
|
102
103
104
|
return parent::beforeAction($action); // TODO: Change the autogenerated stub
}
|
a02e2fdb
Yarik
test
|
105
106
|
/**
* Page of additional skills, consist:
|
a02e2fdb
Yarik
test
|
107
108
109
110
|
* * working with programs;
* * education;
* * own developments and patents;
* * courses and trainings;
|
a02e2fdb
Yarik
test
|
111
112
|
* @return string
*/
|
588209fc
Yarik
test
|
113
114
115
116
117
118
119
120
121
|
public function actionAddSkills()
{
$user = \Yii::$app->user->identity;
if(!empty( \Yii::$app->request->post() )) {
Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru');
}
return $this->render('add-skills', [ 'user' => $user ]);
}
|
a02e2fdb
Yarik
test
|
122
123
|
/**
* Page of blog grid view
|
a02e2fdb
Yarik
test
|
124
125
|
* @return string
*/
|
588209fc
Yarik
test
|
126
127
|
public function actionBlog()
{
|
989c83b0
Yarik
test
|
128
129
130
131
132
133
134
|
$searchModel = new BlogSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('blog', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
588209fc
Yarik
test
|
135
136
|
}
|
a02e2fdb
Yarik
test
|
137
138
|
/**
* Page of creating one record of blog.
|
a02e2fdb
Yarik
test
|
139
140
|
* @return string|\yii\web\Response Page html / Redirect
*/
|
588209fc
Yarik
test
|
141
142
143
144
145
146
|
public function actionBlogCreate()
{
$blog = new Blog();
$post = \Yii::$app->request->post();
if($blog->load($post) && $blog->save()) {
return $this->redirect([
|
4c9663e0
Yarik
test
|
147
|
'blog',
|
588209fc
Yarik
test
|
148
149
150
151
152
153
|
]);
} else {
return $this->render('_blog_form', [ 'blog' => $blog ]);
}
}
|
a02e2fdb
Yarik
test
|
154
155
156
157
158
159
160
161
|
/**
* Page of editting one User's record of blog.
*
* @param integer $id ID of User's record
*
* @return string|\yii\web\Response Page html / Redirect
* @throws NotFoundHttpException if not found or someone else's post
*/
|
588209fc
Yarik
test
|
162
163
|
public function actionBlogUpdate($id)
{
|
a02e2fdb
Yarik
test
|
164
165
166
167
168
169
170
|
$user = \Yii::$app->user->identity;
$blog = $user->getBlog()
->where([ 'blog_id' => $id ])
->one();
if(!$blog instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
588209fc
Yarik
test
|
171
172
173
174
175
176
177
178
|
$post = \Yii::$app->request->post();
if($blog->load($post) && $blog->save()) {
return $this->redirect('blog');
} else {
return $this->render('_blog_form', [ 'blog' => $blog ]);
}
}
|
a02e2fdb
Yarik
test
|
179
180
181
182
183
184
185
186
|
/**
* Delete User's blog record
*
* @param $id ID of User's record
*
* @return \yii\web\Response Redirect
* @throws NotFoundHttpException
*/
|
989c83b0
Yarik
test
|
187
188
|
public function actionBlogDelete($id)
{
|
a02e2fdb
Yarik
test
|
189
190
191
192
193
194
|
$user = \Yii::$app->user->identity;
$blog = $user->getBlog()
->where([ 'blog_id' => $id ])
->one();
if(!$blog instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
|
5f49082a
Yarik
test
|
195
|
}
|
a02e2fdb
Yarik
test
|
196
197
|
$blog->delete();
return $this->redirect('blog');
|
70abf3e7
Administrator
add field v.1
|
198
|
}
|
6310a439
Administrator
firs page
|
199
|
|
a02e2fdb
Yarik
test
|
200
201
|
/**
* Page of contacts. Consist:
|
a02e2fdb
Yarik
test
|
202
203
204
|
* * phones;
* * social pages;
* * sites;
|
a02e2fdb
Yarik
test
|
205
206
|
* @return string page html
*/
|
588209fc
Yarik
test
|
207
|
public function actionContacts()
|
5f49082a
Yarik
test
|
208
|
{
|
a02e2fdb
Yarik
test
|
209
210
|
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
|
588209fc
Yarik
test
|
211
212
213
214
|
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
if(!empty( \Yii::$app->request->post() )) {
|
e4a014b8
Yarik
test
|
215
|
if(!empty( Yii::$app->request->post('Fields') )) {
|
2cee8b86
Yarik
test
|
216
|
|
5346fcf9
Yarik
test
|
217
218
|
Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru');
}
|
588209fc
Yarik
test
|
219
220
221
222
223
224
|
$user_info->load(\Yii::$app->request->post());
$user_info->save();
}
return $this->render('contacts', [ 'user_info' => $user_info ]);
}
|
a02e2fdb
Yarik
test
|
225
226
|
/**
* Page of description. Consist of information about User.
|
a02e2fdb
Yarik
test
|
227
228
|
* @return string page html
*/
|
588209fc
Yarik
test
|
229
230
|
public function actionDescription()
{
|
a02e2fdb
Yarik
test
|
231
232
|
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
|
588209fc
Yarik
test
|
233
234
235
236
237
238
239
240
241
242
243
|
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$user_info->load($post);
$user_info->save();
}
return $this->render('description', [ 'user_info' => $user_info ]);
}
|
a02e2fdb
Yarik
test
|
244
245
|
/**
* Page of seniority. Consist:
|
a02e2fdb
Yarik
test
|
246
247
248
|
* * current job;
* * year of the beginning of designing
* * previous jobs
|
a02e2fdb
Yarik
test
|
249
250
|
* @return string page html
*/
|
588209fc
Yarik
test
|
251
252
|
public function actionEmployment()
{
|
a02e2fdb
Yarik
test
|
253
254
|
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
|
3e842416
Yarik
test
|
255
256
257
|
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
|
588209fc
Yarik
test
|
258
259
|
$post = \Yii::$app->request->post();
if(!empty( $post )) {
|
3e842416
Yarik
test
|
260
261
|
$user_info->load($post);
$user_info->save();
|
588209fc
Yarik
test
|
262
|
$job = [ ];
|
fdc1c9de
Yarik
test
|
263
264
|
foreach($post[ 'Job' ] as $index => $value) {
$job[ $index ] = new Job([
|
588209fc
Yarik
test
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
'user_id' => \Yii::$app->user->getId(),
'current' => 0,
]);
}
if(Job::loadMultiple($job, $post)) {
$job[ 0 ]->current = 1;
if(Job::validateMultiple($job)) {
Job::deleteAll([ 'user_id' => \Yii::$app->user->getId() ]);
foreach($job as $onejob) {
$onejob->save(false);
}
}
}
} else {
|
a02e2fdb
Yarik
test
|
279
280
281
|
$job = $user->getJobs()
->orderBy([ 'current' => SORT_DESC ])
->all();
|
588209fc
Yarik
test
|
282
283
284
285
286
287
288
289
290
291
292
293
294
|
if(empty( $job )) {
$job[] = new Job([
'user_id' => \Yii::$app->user->getId(),
'current' => 0,
]);
}
if(!$job[ 0 ]->current) {
array_unshift($job, new Job([
'user_id' => \Yii::$app->user->getId(),
'current' => 1,
]));
}
}
|
a02e2fdb
Yarik
test
|
295
296
297
|
return $this->render('employment', [
'job' => $job,
'user_info' => $user_info,
|
3e842416
Yarik
test
|
298
|
]);
|
588209fc
Yarik
test
|
299
300
|
}
|
e8236f44
Yarik
test
|
301
|
/**
|
37c8e264
Yarik
test
|
302
303
304
305
306
307
308
|
* Page of Company feedback
* @return string
*/
public function actionFeedbackCompany()
{
$searchModel = new FeedbackCompanySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
713ccea4
Yarik
test
|
309
310
311
312
313
314
315
316
317
|
$dataProvider->pagination = [
'pageSize' => 20,
];
$dataProvider->sort = new Sort([
'defaultOrder' => [
'status' => SORT_ASC,
'date_add' => SORT_DESC,
],
]);
|
37c8e264
Yarik
test
|
318
319
320
321
322
323
324
325
326
|
return $this->render('feedback-company', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Delete company feedback
|
713ccea4
Yarik
test
|
327
328
329
330
331
332
|
*
* @param int $id
*
* @return Response
* @throws NotFoundHttpException
* @throws \Exception
|
37c8e264
Yarik
test
|
333
334
335
336
337
338
339
340
341
342
|
*/
public function actionFeedbackDelete($id)
{
$model = FeedbackCompany::find()
->where([
'feedback_company_id' => $id,
'user_id' => \Yii::$app->user->id,
])
->one();
|
713ccea4
Yarik
test
|
343
|
if(empty( $model )) {
|
37c8e264
Yarik
test
|
344
345
346
|
throw new NotFoundHttpException('Заявка не найдена');
} else {
$model->delete();
|
713ccea4
Yarik
test
|
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
return $this->redirect([ 'accounts/feedback-company' ]);
}
}
/**
* Mark feedback as read
*
* @param int $id
*
* @return Response
* @throws NotFoundHttpException
*/
public function actionFeedbackRead($id)
{
$model = FeedbackCompany::find()
->where([
'feedback_company_id' => $id,
'user_id' => \Yii::$app->user->id,
])
->andWhere([
'not',
[ 'status' => FeedbackCompany::STATUS_READ ],
])
->one();
if(empty( $model )) {
throw new NotFoundHttpException('Заявка не найдена');
} else {
$model->status = FeedbackCompany::STATUS_READ;
$model->save(false);
return $this->redirect([ 'accounts/feedback-company' ]);
|
37c8e264
Yarik
test
|
378
379
380
381
|
}
}
/**
|
e8236f44
Yarik
test
|
382
|
* Page of User's image galleries
|
e8236f44
Yarik
test
|
383
384
|
* @return string
*/
|
588209fc
Yarik
test
|
385
386
|
public function actionGallery()
{
|
989c83b0
Yarik
test
|
387
388
|
$searchModel = new GallerySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
588209fc
Yarik
test
|
389
|
|
989c83b0
Yarik
test
|
390
391
392
393
|
return $this->render('gallery', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
588209fc
Yarik
test
|
394
395
|
}
|
e8236f44
Yarik
test
|
396
397
|
/**
* Page of User's videos
|
e8236f44
Yarik
test
|
398
399
|
* @return string
*/
|
9217ef8e
Administrator
09.02.16
|
400
401
402
403
404
|
public function actionGalleryVideo()
{
$user = \Yii::$app->user->identity;
|
1b56164e
Yarik
test
|
405
|
$video = Fields::getData($user->id, Gallery::className(), 'youtube');
|
9217ef8e
Administrator
09.02.16
|
406
|
|
1b56164e
Yarik
test
|
407
|
if(!empty( Yii::$app->request->post('Fields') )) {
|
3d0e6093
Administrator
15.02.16
|
408
|
Fields::saveFieldVideoData(Yii::$app->request->post('Fields'), $user->id, Gallery::className(), 'ru');
|
9217ef8e
Administrator
09.02.16
|
409
410
411
|
}
return $this->render('gallery-video', [
|
1b56164e
Yarik
test
|
412
|
'video' => $video,
|
9217ef8e
Administrator
09.02.16
|
413
414
415
416
|
'user' => $user,
]);
}
|
e8236f44
Yarik
test
|
417
418
|
/**
* Page of creating a photo gallery
|
e8236f44
Yarik
test
|
419
420
|
* @return string|\yii\web\Response
*/
|
588209fc
Yarik
test
|
421
422
423
424
425
426
|
public function actionGalleryCreate()
{
$gallery = new Gallery();
$user = \Yii::$app->user->identity;
$post = \Yii::$app->request->post();
if($gallery->load($post) && $gallery->save()) {
|
588209fc
Yarik
test
|
427
|
return $this->redirect([
|
bbc81528
Yarik
test
|
428
|
'gallery',
|
588209fc
Yarik
test
|
429
430
431
432
433
434
435
436
437
|
]);
} else {
return $this->render('_gallery_form', [
'gallery' => $gallery,
'user' => $user,
]);
}
}
|
e8236f44
Yarik
test
|
438
439
440
441
442
443
444
|
/**
* Page of updating existing photo gallery
*
* @param $id ID of Gallery
*
* @return string|\yii\web\Response
*/
|
588209fc
Yarik
test
|
445
446
|
public function actionGalleryUpdate($id)
{
|
588209fc
Yarik
test
|
447
|
$user = \Yii::$app->user->identity;
|
2e35d6bd
Yarik
test
|
448
449
450
|
$gallery = $user->getGalleries()
->where([ 'gallery_id' => $id ])
->one();
|
588209fc
Yarik
test
|
451
452
|
$post = \Yii::$app->request->post();
if($gallery->load($post) && $gallery->save()) {
|
588209fc
Yarik
test
|
453
|
return $this->redirect([
|
bbc81528
Yarik
test
|
454
|
'gallery',
|
588209fc
Yarik
test
|
455
456
457
458
459
460
461
|
]);
} else {
return $this->render('_gallery_form', [
'gallery' => $gallery,
'user' => $user,
]);
}
|
5f49082a
Yarik
test
|
462
|
}
|
6310a439
Administrator
firs page
|
463
|
|
e8236f44
Yarik
test
|
464
465
466
467
468
469
470
|
/**
* Page of deleting existing photo gallery
*
* @param $id ID of Gallery
*
* @throws \Exception
*/
|
f59447a7
Yarik
test
|
471
472
473
474
475
476
477
|
public function actionGalleryDelete($id)
{
Gallery::findOne($id)
->delete();
$this->redirect('gallery');
}
|
a02e2fdb
Yarik
test
|
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
/**
* Page of credentials. Consist:
* <ul>
* <li>
* Company info:
* <ul>
* <li>Company name</li>
* <li>Employees count</li>
* <li>Street</li>
* <li>House</li>
* </ul>
* </li>
* <li>
* User info:
* <ul>
* <li>User name</li>
* <li>User surname</li>
* <li>Email</li>
* </ul>
* </li>
* <li>
* Common info:
* <ul>
* <li>Status (free/busy)</li>
* <li>City</li>
* <li>Avatar</li>
* <li>Cover</li>
* <li>Membership</li>
* </ul>
* </li>
* </ul>
|
a02e2fdb
Yarik
test
|
509
510
|
* @return string page html
*/
|
5f49082a
Yarik
test
|
511
|
public function actionGeneral()
|
51e0a262
Yarik
test
|
512
|
{
|
b4142e17
Yarik
test
|
513
514
515
|
/**
* @var User $user
*/
|
a02e2fdb
Yarik
test
|
516
517
518
|
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
$company_info = $user->companyInfo;
|
5f49082a
Yarik
test
|
519
|
if(empty( $user_info )) {
|
76f36646
Yarik
test
|
520
|
//$user_info = new UserInfo([ 'user_id' => $user->id ]);
|
5f49082a
Yarik
test
|
521
|
}
|
54d398c7
Administrator
24.02.16
|
522
|
|
5f49082a
Yarik
test
|
523
|
if(empty( $company_info )) {
|
a02e2fdb
Yarik
test
|
524
|
$company_info = new CompanyInfo([ 'user_id' => $user->id ]);
|
5f49082a
Yarik
test
|
525
|
}
|
54d398c7
Administrator
24.02.16
|
526
|
|
5f49082a
Yarik
test
|
527
528
|
$post = \Yii::$app->request->post();
if(!empty( $post )) {
|
54d398c7
Administrator
24.02.16
|
529
|
|
a41edafc
Yarik
test
|
530
|
if($user_info->load($post)) {
|
54d398c7
Administrator
24.02.16
|
531
532
533
|
$user_info->save();
}
|
a41edafc
Yarik
test
|
534
|
if($company_info->load($post)) {
|
54d398c7
Administrator
24.02.16
|
535
536
537
|
$company_info->save();
}
|
a41edafc
Yarik
test
|
538
|
if($user->load($post) && $user->save()) {
|
5f49082a
Yarik
test
|
539
540
541
542
543
544
545
546
547
548
|
\Yii::$app->session->setFlash('userinfoupdate', 'Информация успешно обновлена');
} else {
\Yii::$app->session->setFlash('userinfoupdate', 'Ошибка обновления. Проверьте форму');
}
}
return $this->render('general', [
'user_info' => $user_info,
'user' => $user,
'company_info' => $company_info,
]);
|
51e0a262
Yarik
test
|
549
|
}
|
5f49082a
Yarik
test
|
550
|
|
e8236f44
Yarik
test
|
551
552
553
554
555
556
557
|
/**
* Renders form via ajax, using lastindex.
*
* @param integer $lastindex Last index of form input of current type
*
* @return string
*/
|
588209fc
Yarik
test
|
558
|
public function actionGetForm($lastindex)
|
84ebac3d
Yarik
test
|
559
|
{
|
588209fc
Yarik
test
|
560
|
return $this->renderAjax('_job_form', [ 'index' => $lastindex + 1 ]);
|
84ebac3d
Yarik
test
|
561
562
|
}
|
2f324895
Yarik
test
|
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
public function actionParticipant()
{
$searchModel = new PortfolioUserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->query->joinWith('portfolio');
$dataProvider->sort = new Sort([
'defaultOrder' => [
'portfolio_user_id' => SORT_ASC,
],
'attributes' => [
'project' => [
'asc' => [
'portfolio.name' => SORT_ASC,
],
'desc' => [
'portfolio.name' => SORT_DESC,
],
],
'portfolio_user_id',
'position',
'time',
'status',
],
]);
$dataProvider->pagination->pageSize = 5;
return $this->render('participant', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
public function actionParticipantConfirm($id)
{
$portfolioUser = PortfolioUser::find()
->where([
'portfolio_user_id' => $id,
'user_id' => \Yii::$app->user->id,
'status' => 2,
])
->one();
if(empty( $portfolioUser )) {
throw new NotFoundHttpException('Приглашение не найдено');
}
$portfolioUser->status = 1;
if($portfolioUser->save(false)) {
return $this->redirect([ 'accounts/participant' ]);
} else {
throw new \Exception('Неизвестная ошибка');
}
}
public function actionParticipantDelete($id)
{
$portfolioUser = PortfolioUser::find()
->where([
'portfolio_user_id' => $id,
'user_id' => \Yii::$app->user->id,
])
->one();
if(empty( $portfolioUser )) {
throw new NotFoundHttpException('Приглашение не найдено');
}
if($portfolioUser->delete()) {
return $this->redirect([ 'accounts/participant' ]);
} else {
throw new \Exception('Неизвестная ошибка');
}
}
public function actionParticipantEdit($id)
{
$portfolioUser = PortfolioUser::find()
->where([
'portfolio_user_id' => $id,
'user_id' => \Yii::$app->user->id,
])
->with('gallery')
->one();
if(empty( $portfolioUser )) {
throw new NotFoundHttpException('Приглашение не найдено');
}
$post = \Yii::$app->request->post();
if(!empty( $post )) {
if($portfolioUser->load($post)) {
$portfolioUser->status = 1;
if($portfolioUser->save()) {
|
25bd78f8
Yarik
test
|
649
|
if(!empty( $portfolioUser->gallery )) {
|
2f324895
Yarik
test
|
650
651
652
|
$portfolioUser->gallery->load($post);
$portfolioUser->portfolioGallery->load($post);
if($portfolioUser->gallery->save() && $portfolioUser->portfolioGallery->save()) {
|
25bd78f8
Yarik
test
|
653
|
return $this->redirect([ 'accounts/participant' ]);
|
2f324895
Yarik
test
|
654
655
|
}
} else {
|
25bd78f8
Yarik
test
|
656
657
658
659
|
return $this->redirect([
'accounts/participant-edit',
'id' => $portfolioUser->portfolio_user_id,
]);
|
2f324895
Yarik
test
|
660
661
662
663
664
665
666
|
}
}
}
}
return $this->render('participant-edit', [ 'model' => $portfolioUser ]);
}
|
e8236f44
Yarik
test
|
667
668
|
/**
* Page of User's portfolio
|
e8236f44
Yarik
test
|
669
670
|
* @return string
*/
|
5f49082a
Yarik
test
|
671
|
public function actionPortfolio()
|
51e0a262
Yarik
test
|
672
|
{
|
989c83b0
Yarik
test
|
673
674
|
$searchModel = new PortfolioSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
1b56164e
Yarik
test
|
675
|
$dataProvider->pagination->pageSize = 5;
|
25bd78f8
Yarik
test
|
676
|
$dataProvider->sort->defaultOrder = [ 'portfolio_id' => SORT_ASC ];
|
989c83b0
Yarik
test
|
677
678
679
680
|
return $this->render('portfolio', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
7eb29439
Yarik
test
|
681
682
|
}
|
e8236f44
Yarik
test
|
683
684
|
/**
* Page of creating User's portfolio records.
|
e8236f44
Yarik
test
|
685
686
|
* @return string|\yii\web\Response
*/
|
7eb29439
Yarik
test
|
687
688
|
public function actionPortfolioCreate()
{
|
2e35d6bd
Yarik
test
|
689
|
$user = \Yii::$app->user->identity;
|
7eb29439
Yarik
test
|
690
|
$portfolio = new Portfolio();
|
fdc1c9de
Yarik
test
|
691
|
|
1b56164e
Yarik
test
|
692
693
694
695
|
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
|
2e35d6bd
Yarik
test
|
696
697
698
699
700
701
702
703
|
$galleries = $user->getGalleries()
->select([
'name',
'gallery_id',
])
->asArray()
->indexBy('gallery_id')
->column();
|
7eb29439
Yarik
test
|
704
|
$post = \Yii::$app->request->post();
|
fdc1c9de
Yarik
test
|
705
|
$portfolioUsers = $portfolio->portfolioUsers;
|
84ebac3d
Yarik
test
|
706
|
if(!empty( $post )) {
|
7eb29439
Yarik
test
|
707
708
709
710
711
712
|
$portfolio->load($post);
$portfolio->validate();
if(!$portfolio->hasErrors()) {
$portfolio->save();
$portfolio->unlinkAll('specializations', true);
foreach($portfolio->specializationInput as $one_specialization) {
|
1b56164e
Yarik
test
|
713
|
$portfolio->link('specializations', Specialization::findOne($one_specialization));
|
7eb29439
Yarik
test
|
714
|
}
|
fdc1c9de
Yarik
test
|
715
716
717
718
719
720
721
|
$portfolio->unlinkAll('portfolioUsers', true);
$success = true;
if(!empty( $post[ 'PortfolioUser' ] )) {
$portfolioUsers = [ ];
foreach($post[ 'PortfolioUser' ] as $index => $item) {
$portfolioUsers[ $index ] = new PortfolioUser([ 'portfolio_id' => $portfolio->portfolio_id ]);
}
|
2f324895
Yarik
test
|
722
|
$success = ( PortfolioUser::loadMultiple($portfolioUsers, $post) && PortfolioUser::validateMultiple($portfolioUsers) );
|
fdc1c9de
Yarik
test
|
723
724
725
726
727
728
729
730
731
|
if($success) {
foreach($portfolioUsers as $index => $portfolioUser) {
$portfolioUser->save(false);
}
}
}
if($success) {
return $this->redirect('portfolio');
}
|
7eb29439
Yarik
test
|
732
733
|
}
}
|
84ebac3d
Yarik
test
|
734
|
return $this->render('_portfolio_form', [
|
1b56164e
Yarik
test
|
735
|
'portfolio' => $portfolio,
|
9fdba9c2
Administrator
15.02.16
|
736
|
'specializations' => $specializations,
|
2e35d6bd
Yarik
test
|
737
|
'galleries' => $galleries,
|
fdc1c9de
Yarik
test
|
738
|
'portfolioUsers' => $portfolioUsers,
|
84ebac3d
Yarik
test
|
739
|
]);
|
7eb29439
Yarik
test
|
740
|
}
|
5f49082a
Yarik
test
|
741
|
|
e8236f44
Yarik
test
|
742
743
744
745
746
747
748
749
|
/**
* Page of updating User's portfolio record.
*
* @param integer $id ID of User's portfolio record
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException if record not found
*/
|
7eb29439
Yarik
test
|
750
751
|
public function actionPortfolioUpdate($id)
{
|
a02e2fdb
Yarik
test
|
752
753
754
|
$user = \Yii::$app->user->identity;
$portfolio = $user->getPortfolios()
->where([ 'portfolio_id' => $id ])
|
fdc1c9de
Yarik
test
|
755
|
->with('portfolioUsers.user')
|
a02e2fdb
Yarik
test
|
756
|
->one();
|
2e35d6bd
Yarik
test
|
757
758
759
760
761
762
763
764
|
$galleries = $user->getGalleries()
->select([
'name',
'gallery_id',
])
->asArray()
->indexBy('gallery_id')
->column();
|
a02e2fdb
Yarik
test
|
765
766
767
|
if(!$portfolio instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
1b56164e
Yarik
test
|
768
769
770
771
|
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
|
f7089e23
Administrator
15.02.16
|
772
|
|
7eb29439
Yarik
test
|
773
|
$post = \Yii::$app->request->post();
|
2f324895
Yarik
test
|
774
775
776
777
778
779
780
|
$portfolioUsers = $portfolio->getPortfolioUsers()
->where([ 'status' => 2 ])
->all();
$portfolioUsersConfirmed = $portfolio->getPortfolioUsers()
->where([ 'status' => 1 ])
->indexBy('user_id')
->all();
|
f7089e23
Administrator
15.02.16
|
781
|
|
84ebac3d
Yarik
test
|
782
|
if(!empty( $post )) {
|
7eb29439
Yarik
test
|
783
784
785
786
787
|
$portfolio->load($post);
$portfolio->validate();
if(!$portfolio->hasErrors()) {
$portfolio->save();
$portfolio->unlinkAll('specializations', true);
|
7eb29439
Yarik
test
|
788
|
foreach($portfolio->specializationInput as $one_specialization) {
|
e4a014b8
Yarik
test
|
789
|
$portfolio->link('specializations', Specialization::findOne($one_specialization));
|
7eb29439
Yarik
test
|
790
|
}
|
2f324895
Yarik
test
|
791
792
793
794
|
PortfolioUser::deleteAll([
'portfolio_id' => $portfolio->portfolio_id,
'status' => 2,
]);
|
fdc1c9de
Yarik
test
|
795
796
797
798
799
800
|
$success = true;
if(!empty( $post[ 'PortfolioUser' ] )) {
$portfolioUsers = [ ];
foreach($post[ 'PortfolioUser' ] as $index => $item) {
$portfolioUsers[ $index ] = new PortfolioUser([ 'portfolio_id' => $portfolio->portfolio_id ]);
}
|
2f324895
Yarik
test
|
801
802
803
804
805
806
807
808
809
|
$success = PortfolioUser::loadMultiple($portfolioUsers, $post);
foreach($portfolioUsers as $index => $portfolioUser) {
if($portfolioUser->status == 1) {
$portfolioUsersConfirmed[ $portfolioUser->user_id ]->position = $portfolioUser->position;
$portfolioUsersConfirmed[ $portfolioUser->user_id ]->time = $portfolioUser->time;
unset( $portfolioUsers[ $index ] );
}
}
$success = ( $success && PortfolioUser::validateMultiple($portfolioUsers) && PortfolioUser::validateMultiple($portfolioUsersConfirmed) );
|
fdc1c9de
Yarik
test
|
810
811
|
if($success) {
foreach($portfolioUsers as $index => $portfolioUser) {
|
2f324895
Yarik
test
|
812
|
$portfolioUser->status = 2;
|
fdc1c9de
Yarik
test
|
813
814
|
$portfolioUser->save(false);
}
|
2f324895
Yarik
test
|
815
816
817
|
foreach($portfolioUsersConfirmed as $index => $portfolioUserConfirmed) {
$portfolioUserConfirmed->save(false);
}
|
fdc1c9de
Yarik
test
|
818
819
820
821
822
|
}
}
if($success) {
return $this->redirect('portfolio');
}
|
7eb29439
Yarik
test
|
823
824
|
}
}
|
f7089e23
Administrator
15.02.16
|
825
|
|
84ebac3d
Yarik
test
|
826
|
return $this->render('_portfolio_form', [
|
2f324895
Yarik
test
|
827
828
829
830
831
|
'portfolio' => $portfolio,
'specializations' => $specializations,
'galleries' => $galleries,
'portfolioUsers' => $portfolioUsers,
'portfolioUsersConfirmed' => $portfolioUsersConfirmed,
|
84ebac3d
Yarik
test
|
832
|
]);
|
51e0a262
Yarik
test
|
833
|
}
|
5f49082a
Yarik
test
|
834
|
|
e8236f44
Yarik
test
|
835
836
837
838
839
840
841
842
|
/**
* Page of deleting User's portfolio record.
*
* @param integer $id ID of User's portfolio record
*
* @throws NotFoundHttpException
* @throws \Exception if record not found
*/
|
989c83b0
Yarik
test
|
843
844
|
public function actionPortfolioDelete($id)
{
|
a02e2fdb
Yarik
test
|
845
846
847
848
849
850
851
852
|
$user = \Yii::$app->user->identity;
$portfolio = $user->getPortfolios()
->where([ 'portfolio_id' => $id ])
->one();
if(!$portfolio instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$portfolio->delete();
|
989c83b0
Yarik
test
|
853
854
855
|
$this->redirect('portfolio');
}
|
e8236f44
Yarik
test
|
856
857
|
/**
* Page of User's projects.
|
e8236f44
Yarik
test
|
858
859
|
* @return string
*/
|
5f49082a
Yarik
test
|
860
861
|
public function actionProjects()
{
|
989c83b0
Yarik
test
|
862
863
864
865
866
867
868
|
$searchModel = new ProjectSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('projects', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
5f49082a
Yarik
test
|
869
|
}
|
6310a439
Administrator
firs page
|
870
|
|
e8236f44
Yarik
test
|
871
872
|
/**
* Page of creating User's project.
|
e8236f44
Yarik
test
|
873
874
|
* @return string|\yii\web\Response
*/
|
84ebac3d
Yarik
test
|
875
876
877
|
public function actionProjectsCreate()
{
$project = new Project();
|
d36bdac6
Administrator
17.02.16
|
878
|
|
1b56164e
Yarik
test
|
879
880
881
882
|
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
|
d36bdac6
Administrator
17.02.16
|
883
|
|
84ebac3d
Yarik
test
|
884
885
886
887
888
889
890
891
|
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
|
aa182b5c
Yarik
test
|
892
893
894
895
896
897
898
899
900
|
$projects = Project::find()
->select([
'name',
'project_id',
])
->where([ 'user_id' => \Yii::$app->user->getId() ])
->indexBy('project_id')
->asArray()
->column();
|
84ebac3d
Yarik
test
|
901
|
$post = \Yii::$app->request->post();
|
aa182b5c
Yarik
test
|
902
|
if(!empty( $post )) {
|
84ebac3d
Yarik
test
|
903
|
$project->load($post);
|
83b0052c
Yarik
test
|
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
|
$project->files = UploadedFile::getInstances($project, 'files');
if(!empty( $project->files )) {
$file_id = [ ];
if(is_array($project->files)) {
foreach($project->files as $file) {
if($file instanceof UploadedFile) {
$file_model = new File();
$file_id[] = $file_model->saveFile($file);
}
}
} else {
if($project->files instanceof UploadedFile) {
$file_model = new File();
$file_id[] = $file_model->saveFile($this->file);
}
}
$project->file = json_encode($file_id);
}
|
84ebac3d
Yarik
test
|
922
923
|
$project->validate();
if(!$project->hasErrors()) {
|
492ed7f7
Yarik
test
|
924
|
$project->save(false);
|
84ebac3d
Yarik
test
|
925
926
|
$project->unlinkAll('specializations', true);
foreach($project->specializationInput as $one_specialization) {
|
aa182b5c
Yarik
test
|
927
|
$project->link('specializations', Specialization::findOne($one_specialization));
|
84ebac3d
Yarik
test
|
928
929
930
|
}
$project->unlinkAll('payments', true);
foreach($project->paymentInput as $one_payment) {
|
aa182b5c
Yarik
test
|
931
|
$project->link('payments', Payment::findOne($one_payment));
|
84ebac3d
Yarik
test
|
932
|
}
|
ea09d15d
Yarik
test
|
933
|
return $this->redirect([
|
420d3dcd
Yarik
test
|
934
|
'projects',
|
ea09d15d
Yarik
test
|
935
|
]);
|
84ebac3d
Yarik
test
|
936
937
|
}
}
|
aa182b5c
Yarik
test
|
938
|
return $this->render('_projects_form', [
|
1b56164e
Yarik
test
|
939
|
'project' => $project,
|
d36bdac6
Administrator
17.02.16
|
940
|
'specializations' => $specializations,
|
1b56164e
Yarik
test
|
941
942
|
'payment' => $payment,
'projects' => $projects,
|
aa182b5c
Yarik
test
|
943
944
945
|
]);
}
|
e8236f44
Yarik
test
|
946
947
948
949
950
951
952
953
|
/**
* Page of updating User's project.
*
* @param integer $id ID of User's project
*
* @return string
* @throws NotFoundHttpException if record not found
*/
|
aa182b5c
Yarik
test
|
954
955
|
public function actionProjectsUpdate($id)
{
|
a02e2fdb
Yarik
test
|
956
957
958
959
960
961
962
|
$user = \Yii::$app->user->identity;
$project = $user->getProjects()
->where([ 'project_id' => $id ])
->one();
if(!$project instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
1b56164e
Yarik
test
|
963
964
965
966
|
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
|
aa182b5c
Yarik
test
|
967
968
969
970
971
972
973
974
|
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
|
a02e2fdb
Yarik
test
|
975
976
977
978
979
980
981
982
983
984
985
986
|
$projects = $user->getProjects()
->select([
'name',
'project_id',
])
->andWhere([
'not',
[ 'project_id' => $project->project_id ],
])
->indexBy('project_id')
->asArray()
->column();
|
aa182b5c
Yarik
test
|
987
988
989
|
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$project->load($post);
|
83b0052c
Yarik
test
|
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
|
$project->files = UploadedFile::getInstances($project, 'files');
if(!empty( $project->files )) {
$file_id = [ ];
if(is_array($project->files)) {
foreach($project->files as $file) {
if($file instanceof UploadedFile) {
$file_model = new File();
$file_id[] = $file_model->saveFile($file);
}
}
} else {
if($project->files instanceof UploadedFile) {
$file_model = new File();
$file_id[] = $file_model->saveFile($this->file);
}
}
$project->file = json_encode($file_id);
}
|
aa182b5c
Yarik
test
|
1008
1009
|
$project->validate();
if(!$project->hasErrors()) {
|
492ed7f7
Yarik
test
|
1010
|
$project->save(false);
|
aa182b5c
Yarik
test
|
1011
1012
1013
1014
1015
1016
1017
1018
|
$project->unlinkAll('specializations', true);
foreach($project->specializationInput as $one_specialization) {
$project->link('specializations', Specialization::findOne($one_specialization));
}
$project->unlinkAll('payments', true);
foreach($project->paymentInput as $one_payment) {
$project->link('payments', Payment::findOne($one_payment));
}
|
a41edafc
Yarik
test
|
1019
|
return $this->redirect([ 'projects' ]);
|
aa182b5c
Yarik
test
|
1020
1021
1022
|
}
}
return $this->render('_projects_form', [
|
1b56164e
Yarik
test
|
1023
|
'project' => $project,
|
d02fd466
Yarik
test
|
1024
|
'specializations' => $specializations,
|
1b56164e
Yarik
test
|
1025
1026
|
'payment' => $payment,
'projects' => $projects,
|
aa182b5c
Yarik
test
|
1027
|
]);
|
84ebac3d
Yarik
test
|
1028
1029
|
}
|
e8236f44
Yarik
test
|
1030
1031
1032
1033
1034
1035
1036
1037
|
/**
* Page of deleting User's project
*
* @param integer $id ID of User's project
*
* @throws NotFoundHttpException
* @throws \Exception
*/
|
989c83b0
Yarik
test
|
1038
1039
|
public function actionProjectsDelete($id)
{
|
a02e2fdb
Yarik
test
|
1040
1041
|
$user = \Yii::$app->user->identity;
$project = $user->getProjects()
|
1b56164e
Yarik
test
|
1042
1043
|
->where([ 'project_id' => $id ])
->one();
|
a02e2fdb
Yarik
test
|
1044
1045
1046
1047
|
if(!$project instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$project->delete();
|
989c83b0
Yarik
test
|
1048
1049
1050
|
$this->redirect('projects');
}
|
e8236f44
Yarik
test
|
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
|
/**
* Page of editting User's service info. Consist of:
* * cost of work;
* * service specializations;
* * work geography;
* * work guarantee;
* * work on contract;
* * providing estimates;
* * purchase of materials;
* * delivery of materials;
* * minimal prepayment;
* * payment types;
|
e8236f44
Yarik
test
|
1063
1064
|
* @return string
*/
|
588209fc
Yarik
test
|
1065
|
public function actionService()
|
ea09d15d
Yarik
test
|
1066
|
{
|
5d627502
Yarik
test
|
1067
1068
1069
|
/**
* @var User $user
*/
|
a2cb610b
Yarik
Commit
|
1070
1071
|
$user = User::find()->where(['id' => \Yii::$app->user->id])->one();
$user->setSpecializationInput($user->getSpecializationInput());
|
a02e2fdb
Yarik
test
|
1072
|
$user_info = $user->userInfo;
|
588209fc
Yarik
test
|
1073
1074
1075
|
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
|
1b56164e
Yarik
test
|
1076
|
$specializations = Specialization::find()
|
a2cb610b
Yarik
Commit
|
1077
|
->with('children')
|
1b56164e
Yarik
test
|
1078
1079
1080
|
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
|
588209fc
Yarik
test
|
1081
1082
1083
1084
1085
1086
1087
1088
|
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
|
1b56164e
Yarik
test
|
1089
|
$currencies = Currency::getCurrencyDropdown();
|
ea09d15d
Yarik
test
|
1090
|
$post = \Yii::$app->request->post();
|
588209fc
Yarik
test
|
1091
1092
1093
1094
1095
1096
1097
|
if(!empty( $post )) {
$user_info->load($post);
$user_info->validate();
if(!$user_info->hasErrors()) {
$user_info->save();
$user->load($post);
$user->unlinkAll('specializations', true);
|
38a6e1dd
Yarik
test
|
1098
1099
1100
1101
|
if(is_array($user->specializationInput)) {
foreach($user->specializationInput as $one_specialization) {
$user->link('specializations', Specialization::findOne($one_specialization));
}
|
588209fc
Yarik
test
|
1102
1103
|
}
$user->unlinkAll('payments', true);
|
38a6e1dd
Yarik
test
|
1104
1105
1106
1107
|
if(is_array($user->paymentInput)) {
foreach($user->paymentInput as $one_payment) {
$user->link('payments', Payment::findOne($one_payment));
}
|
588209fc
Yarik
test
|
1108
1109
|
}
}
|
ea09d15d
Yarik
test
|
1110
|
}
|
588209fc
Yarik
test
|
1111
|
return $this->render('service', [
|
1b56164e
Yarik
test
|
1112
1113
|
'user' => $user,
'user_info' => $user_info,
|
e8236f44
Yarik
test
|
1114
|
'specializations' => $specializations,
|
1b56164e
Yarik
test
|
1115
1116
|
'payment' => $payment,
'currencies' => $currencies,
|
588209fc
Yarik
test
|
1117
|
]);
|
ea09d15d
Yarik
test
|
1118
1119
|
}
|
588209fc
Yarik
test
|
1120
|
/**
|
e8236f44
Yarik
test
|
1121
1122
|
* Page of account setting. Consist of:
* * changing password;
|
e8236f44
Yarik
test
|
1123
|
* @return string
|
588209fc
Yarik
test
|
1124
1125
|
*/
public function actionSetting()
|
ea09d15d
Yarik
test
|
1126
|
{
|
ea09d15d
Yarik
test
|
1127
|
$user = \Yii::$app->user->identity;
|
588209fc
Yarik
test
|
1128
1129
1130
1131
1132
1133
1134
1135
|
$post = \Yii::$app->request->post('User');
if(!empty( $post )) {
if(empty( $post[ 'new_password' ] )) {
$user->addError('new_password', 'Введите новый пароль');
} else {
$user->new_password = $post[ 'new_password' ];
}
if(empty( $post[ 'old_password' ] )) {
|
239b3249
Yarik
test
|
1136
|
$user->addError('old_password', 'Введите старый пароль');
|
588209fc
Yarik
test
|
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
|
} else {
$user->old_password = $post[ 'old_password' ];
}
if(empty( $post[ 'password_reply' ] ) || $post[ 'password_reply' ] !== $post[ 'new_password' ]) {
$user->addError('password_reply', 'Неправильный повтор пароля');
} else {
$user->password_reply = $post[ 'password_reply' ];
}
if(!$user->hasErrors()) {
if($user->validatePassword($user->old_password)) {
$user->setPassword($user->new_password);
$user->generateAuthKey();
if($user->save()) {
\Yii::$app->session->setFlash('passwordupdate', 'Пароль успешно обновлен');
}
} else {
$user->addError('old_password', 'Неправильный старый пароль');
}
}
|
ea09d15d
Yarik
test
|
1156
|
}
|
588209fc
Yarik
test
|
1157
|
return $this->render('setting', [ 'user' => $user ]);
|
ea09d15d
Yarik
test
|
1158
1159
|
}
|
e8236f44
Yarik
test
|
1160
1161
|
/**
* Page of company's team
|
e8236f44
Yarik
test
|
1162
1163
|
* @return string
*/
|
02524a34
Yarik
test
|
1164
1165
|
public function actionTeam()
{
|
b95371cf
Yarik
test
|
1166
1167
|
$searchModel = new TeamSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
e4a014b8
Yarik
test
|
1168
1169
1170
1171
1172
1173
1174
1175
|
$departments = Department::find()
->select([
'name',
'department_id',
])
->indexBy('department_id')
->asArray()
->column();
|
b95371cf
Yarik
test
|
1176
1177
1178
1179
|
return $this->render('team', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
|
e4a014b8
Yarik
test
|
1180
|
'departments' => $departments,
|
b95371cf
Yarik
test
|
1181
|
]);
|
02524a34
Yarik
test
|
1182
1183
|
}
|
e8236f44
Yarik
test
|
1184
1185
|
/**
* Page of creating company's team member
|
e8236f44
Yarik
test
|
1186
1187
|
* @return string|\yii\web\Response
*/
|
02524a34
Yarik
test
|
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
|
public function actionTeamCreate()
{
$team = new Team();
$department = Department::find()
->select([
'name',
'department_id',
])
->indexBy('department_id')
->asArray()
->column();
$country = Country::find()
->select([ 'country_name' ])
->indexBy('country_name')
->asArray()
->column();
$post = \Yii::$app->request->post();
if($team->load($post) && $team->save()) {
return $this->redirect([
|
e4a014b8
Yarik
test
|
1207
|
'team',
|
02524a34
Yarik
test
|
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
|
]);
} else {
return $this->render('_team_form', [
'team' => $team,
'department' => $department,
'country' => $country,
]);
}
}
|
e8236f44
Yarik
test
|
1218
1219
1220
1221
1222
1223
1224
1225
|
/**
* Page of updating company's team member info.
*
* @param integer $id ID of company's team member
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
|
02524a34
Yarik
test
|
1226
1227
|
public function actionTeamUpdate($id)
{
|
a02e2fdb
Yarik
test
|
1228
1229
1230
1231
1232
1233
1234
|
$user = \Yii::$app->user->identity;
$team = $user->getTeams()
->where([ 'team_id' => $id ])
->one();
if(!$team instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
02524a34
Yarik
test
|
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
|
$department = Department::find()
->select([
'name',
'department_id',
])
->indexBy('department_id')
->asArray()
->column();
$country = Country::find()
->select([ 'country_name' ])
->indexBy('country_name')
->asArray()
->column();
$post = \Yii::$app->request->post();
if($team->load($post) && $team->save()) {
|
ce4a4468
Yarik
test
|
1250
1251
|
return $this->redirect([
'team',
|
02524a34
Yarik
test
|
1252
|
]);
|
02524a34
Yarik
test
|
1253
1254
1255
1256
1257
1258
1259
1260
1261
|
} else {
return $this->render('_team_form', [
'team' => $team,
'department' => $department,
'country' => $country,
]);
}
}
|
e8236f44
Yarik
test
|
1262
1263
1264
1265
1266
1267
1268
1269
|
/**
* Page of deleting company's team member.
*
* @param integer $id ID of company's team member
*
* @throws NotFoundHttpException
* @throws \Exception
*/
|
588209fc
Yarik
test
|
1270
1271
|
public function actionTeamDelete($id)
{
|
a02e2fdb
Yarik
test
|
1272
1273
1274
1275
1276
1277
1278
1279
1280
|
$user = \Yii::$app->user->identity;
$team = $user->getTeams()
->where([ 'team_id' => $id ])
->one();
if(!$team instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$team->delete();
|
588209fc
Yarik
test
|
1281
1282
1283
|
$this->redirect('team');
}
|
e8236f44
Yarik
test
|
1284
1285
|
/**
* Page of company's vacancies
|
e8236f44
Yarik
test
|
1286
1287
|
* @return string
*/
|
ea09d15d
Yarik
test
|
1288
1289
|
public function actionVacancy()
{
|
588209fc
Yarik
test
|
1290
1291
1292
1293
1294
1295
1296
|
$searchModel = new VacancySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('vacancy', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
ea09d15d
Yarik
test
|
1297
1298
|
}
|
e8236f44
Yarik
test
|
1299
1300
|
/**
* Page of creating company's vacancies.
|
e8236f44
Yarik
test
|
1301
1302
|
* @return string|\yii\web\Response
*/
|
ea09d15d
Yarik
test
|
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
|
public function actionVacancyCreate()
{
$vacancy = new Vacancy();
$employment = Employment::find()
->select([
'name',
'employment_id',
])
->indexBy('employment_id')
->asArray()
->column();
|
1b56164e
Yarik
test
|
1314
1315
1316
1317
1318
|
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
$currencies = Currency::getCurrencyDropdown();
|
a41edafc
Yarik
test
|
1319
|
$user = \Yii::$app->user->identity;
|
ea09d15d
Yarik
test
|
1320
|
$post = \Yii::$app->request->post();
|
02524a34
Yarik
test
|
1321
|
if(!empty( $post )) {
|
ea09d15d
Yarik
test
|
1322
1323
|
$vacancy->load($post);
$vacancy->validate();
|
a41edafc
Yarik
test
|
1324
1325
1326
|
if(empty( $vacancy->specializationInput )) {
$vacancy->addError('specializationInput');
}
|
ea09d15d
Yarik
test
|
1327
1328
1329
1330
1331
1332
1333
|
if(!$vacancy->hasErrors()) {
$vacancy->save();
Fields::saveFieldData(Yii::$app->request->post('Fields'), $vacancy->vacancy_id, Vacancy::className(), 'ru');
$vacancy->unlinkAll('employments', true);
foreach($vacancy->employmentInput as $one_employment) {
$vacancy->link('employments', Employment::findOne($one_employment));
}
|
1b56164e
Yarik
test
|
1334
1335
1336
1337
|
$vacancy->unlinkAll('specializations', true);
foreach($vacancy->specializationInput as $one_specialization) {
$vacancy->link('specializations', Specialization::findOne($one_specialization));
}
|
02524a34
Yarik
test
|
1338
|
return $this->redirect([
|
ec94728d
Yarik
test
|
1339
|
'vacancy',
|
02524a34
Yarik
test
|
1340
|
]);
|
ea09d15d
Yarik
test
|
1341
1342
1343
|
}
}
return $this->render('_vacancy_form', [
|
1b56164e
Yarik
test
|
1344
1345
1346
1347
|
'vacancy' => $vacancy,
'employment' => $employment,
'currencies' => $currencies,
'specializations' => $specializations,
|
a41edafc
Yarik
test
|
1348
|
'user' => $user,
|
ea09d15d
Yarik
test
|
1349
1350
1351
|
]);
}
|
e8236f44
Yarik
test
|
1352
1353
1354
1355
1356
1357
1358
1359
|
/**
* Page of updating company's vacancy.
*
* @param integer $id ID of company's vacancy.
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
|
ea09d15d
Yarik
test
|
1360
1361
|
public function actionVacancyUpdate($id)
{
|
a02e2fdb
Yarik
test
|
1362
1363
|
$user = \Yii::$app->user->identity;
$vacancy = $user->getVacancies()
|
1b56164e
Yarik
test
|
1364
1365
|
->where([ 'vacancy_id' => $id ])
->one();
|
a02e2fdb
Yarik
test
|
1366
1367
1368
|
if(!$vacancy instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
ea09d15d
Yarik
test
|
1369
1370
1371
1372
1373
1374
1375
1376
|
$employment = Employment::find()
->select([
'name',
'employment_id',
])
->indexBy('employment_id')
->asArray()
->column();
|
1b56164e
Yarik
test
|
1377
1378
1379
1380
|
$specializations = Specialization::find()
->where([ 'specialization_pid' => 0 ])
->orderBy('specialization_id')
->all();
|
a41edafc
Yarik
test
|
1381
|
$user = \Yii::$app->user->identity;
|
1b56164e
Yarik
test
|
1382
|
$currencies = Currency::getCurrencyDropdown();
|
ea09d15d
Yarik
test
|
1383
|
$post = \Yii::$app->request->post();
|
02524a34
Yarik
test
|
1384
|
if(!empty( $post )) {
|
9fd076e8
Administrator
01.03.16
|
1385
|
|
ea09d15d
Yarik
test
|
1386
1387
|
$vacancy->load($post);
$vacancy->validate();
|
ea09d15d
Yarik
test
|
1388
|
if(!$vacancy->hasErrors()) {
|
9fd076e8
Administrator
01.03.16
|
1389
|
|
ea09d15d
Yarik
test
|
1390
1391
1392
1393
1394
1395
|
$vacancy->save();
Fields::saveFieldData(Yii::$app->request->post('Fields'), $vacancy->vacancy_id, Vacancy::className(), 'ru');
$vacancy->unlinkAll('employments', true);
foreach($vacancy->employmentInput as $one_employment) {
$vacancy->link('employments', Employment::findOne($one_employment));
}
|
1b56164e
Yarik
test
|
1396
1397
1398
1399
|
$vacancy->unlinkAll('specializations', true);
foreach($vacancy->specializationInput as $one_specialization) {
$vacancy->link('specializations', Specialization::findOne($one_specialization));
}
|
02524a34
Yarik
test
|
1400
|
return $this->redirect([
|
ec94728d
Yarik
test
|
1401
|
'vacancy',
|
02524a34
Yarik
test
|
1402
|
]);
|
ea09d15d
Yarik
test
|
1403
1404
1405
|
}
}
return $this->render('_vacancy_form', [
|
1b56164e
Yarik
test
|
1406
1407
1408
1409
|
'vacancy' => $vacancy,
'employment' => $employment,
'currencies' => $currencies,
'specializations' => $specializations,
|
a41edafc
Yarik
test
|
1410
|
'user' => $user,
|
ea09d15d
Yarik
test
|
1411
1412
1413
|
]);
}
|
e8236f44
Yarik
test
|
1414
1415
1416
1417
1418
1419
1420
1421
|
/**
* Page of deleting company's vacancy.
*
* @param integer $id ID of company's vacancy
*
* @throws NotFoundHttpException
* @throws \Exception
*/
|
588209fc
Yarik
test
|
1422
|
public function actionVacancyDelete($id)
|
5f49082a
Yarik
test
|
1423
|
{
|
a02e2fdb
Yarik
test
|
1424
1425
|
$user = \Yii::$app->user->identity;
$vacancy = $user->getVacancies()
|
1b56164e
Yarik
test
|
1426
1427
|
->where([ 'vacancy_id' => $id ])
->one();
|
a02e2fdb
Yarik
test
|
1428
1429
1430
1431
1432
|
if(!$vacancy instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$vacancy->delete();
|
588209fc
Yarik
test
|
1433
|
$this->redirect('vacancy');
|
6310a439
Administrator
firs page
|
1434
|
}
|
6310a439
Administrator
firs page
|
1435
|
|
5f49082a
Yarik
test
|
1436
|
/**
|
e8236f44
Yarik
test
|
1437
|
* Used to find model of User and throws exception if not found.
|
5f49082a
Yarik
test
|
1438
|
*
|
e8236f44
Yarik
test
|
1439
1440
1441
1442
|
* @param integer $id ID of User
*
* @return User if User with particular ID found
* @throws NotFoundHttpException if User with particular ID not found
|
5f49082a
Yarik
test
|
1443
1444
1445
|
*/
protected function findUser($id)
{
|
6310a439
Administrator
firs page
|
1446
|
|
5f49082a
Yarik
test
|
1447
1448
1449
1450
1451
1452
|
if($model = User::findOne([ "id" => $id ])) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
|
6310a439
Administrator
firs page
|
1453
|
|
2293c233
Administrator
16.03.16
|
1454
1455
1456
1457
|
public function actionGalleryCover()
{
$gallery_id = Yii::$app->request->post('gallery_id');
|
ce4a4468
Yarik
test
|
1458
1459
1460
1461
1462
|
$cover = Gallery::find()
->select('cover')
->where([ 'gallery_id' => $gallery_id ])
->column();
die( $cover[ 0 ] );
|
2293c233
Administrator
16.03.16
|
1463
1464
1465
|
}
|
5f49082a
Yarik
test
|
1466
|
}
|