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
8
|
use common\models\Country;
use common\models\Department;
|
ea09d15d
Yarik
test
|
9
|
use common\models\Employment;
|
5f49082a
Yarik
test
|
10
|
use common\models\Fields;
|
ea09d15d
Yarik
test
|
11
|
use common\models\Gallery;
|
989c83b0
Yarik
test
|
12
|
use common\models\GallerySearch;
|
5f49082a
Yarik
test
|
13
14
15
|
use common\models\Job;
use common\models\Language;
use common\models\Payment;
|
7eb29439
Yarik
test
|
16
|
use common\models\Portfolio;
|
989c83b0
Yarik
test
|
17
|
use common\models\PortfolioSearch;
|
7eb29439
Yarik
test
|
18
|
use common\models\PortfolioSpecialization;
|
84ebac3d
Yarik
test
|
19
|
use common\models\Project;
|
989c83b0
Yarik
test
|
20
|
use common\models\ProjectSearch;
|
5f49082a
Yarik
test
|
21
|
use common\models\Specialization;
|
02524a34
Yarik
test
|
22
|
use common\models\Team;
|
b95371cf
Yarik
test
|
23
|
use common\models\TeamSearch;
|
5f49082a
Yarik
test
|
24
25
|
use common\models\UserPayment;
use common\models\UserSpecialization;
|
ea09d15d
Yarik
test
|
26
|
use common\models\Vacancy;
|
588209fc
Yarik
test
|
27
|
use common\models\VacancySearch;
|
5f49082a
Yarik
test
|
28
29
30
31
|
use Yii;
use common\models\User;
use common\models\UserInfo;
|
a02e2fdb
Yarik
test
|
32
33
|
use yii\base\ErrorException;
use yii\db\ActiveRecord;
|
5f49082a
Yarik
test
|
34
|
use yii\filters\AccessControl;
|
588209fc
Yarik
test
|
35
|
use yii\filters\VerbFilter;
|
5f49082a
Yarik
test
|
36
37
|
use yii\web\Controller;
use yii\web\NotFoundHttpException;
|
6310a439
Administrator
firs page
|
38
|
|
5f49082a
Yarik
test
|
39
40
41
42
43
|
/**
* Site controller
*/
class AccountsController extends Controller
{
|
6e1510b2
Administrator
firs page
|
44
|
|
5f49082a
Yarik
test
|
45
|
public $layout = 'admin';
|
6e1510b2
Administrator
firs page
|
46
|
|
a02e2fdb
Yarik
test
|
47
48
|
public $defaultAction = 'general';
|
5f49082a
Yarik
test
|
49
50
51
52
53
54
55
56
57
58
59
|
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
//'actions' => ['cabinet','change-password', 'bookmarks', 'projects'],
'allow' => true,
'roles' => [ '@' ],
],
|
6310a439
Administrator
firs page
|
60
61
|
],
],
|
588209fc
Yarik
test
|
62
63
64
|
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
|
989c83b0
Yarik
test
|
65
66
67
68
69
|
'team-delete' => [ 'POST' ],
'vacancy-delete' => [ 'POST' ],
'portfolio-delete' => [ 'POST' ],
'projects-delete' => [ 'POST' ],
'blog-delete' => [ 'POST' ],
|
588209fc
Yarik
test
|
70
71
|
],
],
|
5f49082a
Yarik
test
|
72
73
|
];
}
|
6310a439
Administrator
firs page
|
74
|
|
a02e2fdb
Yarik
test
|
75
76
77
78
79
80
81
82
83
84
|
/**
* Page of additional skills, consist:
*
* * working with programs;
* * education;
* * own developments and patents;
* * courses and trainings;
*
* @return string
*/
|
588209fc
Yarik
test
|
85
86
87
88
89
90
91
92
93
|
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
|
94
95
96
97
98
|
/**
* Page of blog grid view
*
* @return string
*/
|
588209fc
Yarik
test
|
99
100
|
public function actionBlog()
{
|
989c83b0
Yarik
test
|
101
102
103
104
105
106
107
|
$searchModel = new BlogSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('blog', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
588209fc
Yarik
test
|
108
109
|
}
|
a02e2fdb
Yarik
test
|
110
111
112
113
114
|
/**
* Page of creating one record of blog.
*
* @return string|\yii\web\Response Page html / Redirect
*/
|
588209fc
Yarik
test
|
115
116
117
118
119
120
121
|
public function actionBlogCreate()
{
$blog = new Blog();
$post = \Yii::$app->request->post();
if($blog->load($post) && $blog->save()) {
return $this->redirect([
'blog-update',
|
989c83b0
Yarik
test
|
122
|
'id' => $blog->blog_id,
|
588209fc
Yarik
test
|
123
124
125
126
127
128
|
]);
} else {
return $this->render('_blog_form', [ 'blog' => $blog ]);
}
}
|
a02e2fdb
Yarik
test
|
129
130
131
132
133
134
135
136
|
/**
* 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
|
137
138
|
public function actionBlogUpdate($id)
{
|
a02e2fdb
Yarik
test
|
139
140
141
142
143
144
145
|
$user = \Yii::$app->user->identity;
$blog = $user->getBlog()
->where([ 'blog_id' => $id ])
->one();
if(!$blog instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
588209fc
Yarik
test
|
146
147
148
149
150
151
152
153
|
$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
|
154
155
156
157
158
159
160
161
|
/**
* Delete User's blog record
*
* @param $id ID of User's record
*
* @return \yii\web\Response Redirect
* @throws NotFoundHttpException
*/
|
989c83b0
Yarik
test
|
162
163
|
public function actionBlogDelete($id)
{
|
a02e2fdb
Yarik
test
|
164
165
166
167
168
169
|
$user = \Yii::$app->user->identity;
$blog = $user->getBlog()
->where([ 'blog_id' => $id ])
->one();
if(!$blog instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
|
5f49082a
Yarik
test
|
170
|
}
|
a02e2fdb
Yarik
test
|
171
172
|
$blog->delete();
return $this->redirect('blog');
|
70abf3e7
Administrator
add field v.1
|
173
|
}
|
6310a439
Administrator
firs page
|
174
|
|
a02e2fdb
Yarik
test
|
175
176
177
178
179
180
181
182
183
|
/**
* Page of contacts. Consist:
*
* * phones;
* * social pages;
* * sites;
*
* @return string page html
*/
|
588209fc
Yarik
test
|
184
|
public function actionContacts()
|
5f49082a
Yarik
test
|
185
|
{
|
a02e2fdb
Yarik
test
|
186
187
|
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
|
588209fc
Yarik
test
|
188
189
190
191
192
193
194
195
196
197
198
|
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
if(!empty( \Yii::$app->request->post() )) {
Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru');
$user_info->load(\Yii::$app->request->post());
$user_info->save();
}
return $this->render('contacts', [ 'user_info' => $user_info ]);
}
|
a02e2fdb
Yarik
test
|
199
200
201
202
203
|
/**
* Page of description. Consist of information about User.
*
* @return string page html
*/
|
588209fc
Yarik
test
|
204
205
|
public function actionDescription()
{
|
a02e2fdb
Yarik
test
|
206
207
|
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
|
588209fc
Yarik
test
|
208
209
210
211
212
213
214
215
216
217
218
|
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
|
219
220
221
222
223
224
225
226
227
|
/**
* Page of seniority. Consist:
*
* * current job;
* * year of the beginning of designing
* * previous jobs
*
* @return string page html
*/
|
588209fc
Yarik
test
|
228
229
|
public function actionEmployment()
{
|
a02e2fdb
Yarik
test
|
230
231
|
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
|
3e842416
Yarik
test
|
232
233
234
|
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
|
588209fc
Yarik
test
|
235
236
|
$post = \Yii::$app->request->post();
if(!empty( $post )) {
|
3e842416
Yarik
test
|
237
238
|
$user_info->load($post);
$user_info->save();
|
588209fc
Yarik
test
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
$job = [ ];
for($i = 0; $i < count($post[ 'Job' ]); $i++) {
$job[ $i ] = new Job([
'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
|
256
257
258
|
$job = $user->getJobs()
->orderBy([ 'current' => SORT_DESC ])
->all();
|
588209fc
Yarik
test
|
259
260
261
262
263
264
265
266
267
268
269
270
271
|
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
|
272
273
274
|
return $this->render('employment', [
'job' => $job,
'user_info' => $user_info,
|
3e842416
Yarik
test
|
275
|
]);
|
588209fc
Yarik
test
|
276
277
278
279
|
}
public function actionGallery()
{
|
989c83b0
Yarik
test
|
280
281
|
$searchModel = new GallerySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
588209fc
Yarik
test
|
282
|
|
989c83b0
Yarik
test
|
283
284
285
286
|
return $this->render('gallery', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
588209fc
Yarik
test
|
287
288
|
}
|
9217ef8e
Administrator
09.02.16
|
289
290
291
292
293
294
295
296
297
298
|
public function actionGalleryVideo()
{
$user = \Yii::$app->user->identity;
$video = Fields::getData($user->id,Gallery::className(),'youtube');
if(!empty(Yii::$app->request->post('Fields'))) {
|
3d0e6093
Administrator
15.02.16
|
299
|
Fields::saveFieldVideoData(Yii::$app->request->post('Fields'), $user->id, Gallery::className(), 'ru');
|
9217ef8e
Administrator
09.02.16
|
300
301
302
303
304
305
306
307
308
|
}
return $this->render('gallery-video', [
'video' => $video,
'user' => $user,
]);
}
|
588209fc
Yarik
test
|
309
310
311
312
313
314
|
public function actionGalleryCreate()
{
$gallery = new Gallery();
$user = \Yii::$app->user->identity;
$post = \Yii::$app->request->post();
if($gallery->load($post) && $gallery->save()) {
|
9217ef8e
Administrator
09.02.16
|
315
|
|
588209fc
Yarik
test
|
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
return $this->redirect([
'gallery-update',
'id' => $gallery->gallery_id,
]);
} else {
return $this->render('_gallery_form', [
'gallery' => $gallery,
'user' => $user,
]);
}
}
public function actionGalleryUpdate($id)
{
$gallery = Gallery::findOne($id);
$user = \Yii::$app->user->identity;
$post = \Yii::$app->request->post();
if($gallery->load($post) && $gallery->save()) {
Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru');
return $this->redirect([
'gallery-update',
'id' => $gallery->gallery_id,
]);
} else {
return $this->render('_gallery_form', [
'gallery' => $gallery,
'user' => $user,
]);
}
|
5f49082a
Yarik
test
|
345
|
}
|
6310a439
Administrator
firs page
|
346
|
|
f59447a7
Yarik
test
|
347
348
349
350
351
352
353
|
public function actionGalleryDelete($id)
{
Gallery::findOne($id)
->delete();
$this->redirect('gallery');
}
|
a02e2fdb
Yarik
test
|
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
/**
* 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>
*
* @return string page html
*/
|
5f49082a
Yarik
test
|
388
|
public function actionGeneral()
|
51e0a262
Yarik
test
|
389
|
{
|
a02e2fdb
Yarik
test
|
390
391
392
|
$user = \Yii::$app->user->identity;
$user_info = $user->userInfo;
$company_info = $user->companyInfo;
|
5f49082a
Yarik
test
|
393
394
|
$user = \Yii::$app->user->identity;
if(empty( $user_info )) {
|
a02e2fdb
Yarik
test
|
395
|
$user_info = new UserInfo([ 'user_id' => $user->id ]);
|
5f49082a
Yarik
test
|
396
397
|
}
if(empty( $company_info )) {
|
a02e2fdb
Yarik
test
|
398
|
$company_info = new CompanyInfo([ 'user_id' => $user->id ]);
|
5f49082a
Yarik
test
|
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
}
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$user_info->load($post);
$company_info->load($post);
$user->load($post);
if($user_info->save() && $user->save() && $company_info->save()) {
\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
|
416
|
}
|
5f49082a
Yarik
test
|
417
|
|
588209fc
Yarik
test
|
418
|
public function actionGetForm($lastindex)
|
84ebac3d
Yarik
test
|
419
|
{
|
588209fc
Yarik
test
|
420
|
return $this->renderAjax('_job_form', [ 'index' => $lastindex + 1 ]);
|
84ebac3d
Yarik
test
|
421
422
|
}
|
5f49082a
Yarik
test
|
423
|
public function actionPortfolio()
|
51e0a262
Yarik
test
|
424
|
{
|
989c83b0
Yarik
test
|
425
426
|
$searchModel = new PortfolioSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
9fdba9c2
Administrator
15.02.16
|
427
|
$dataProvider->pagination->pageSize=5;
|
989c83b0
Yarik
test
|
428
429
430
431
|
return $this->render('portfolio', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
7eb29439
Yarik
test
|
432
433
434
435
436
|
}
public function actionPortfolioCreate()
{
$portfolio = new Portfolio();
|
34e7b1a4
Administrator
15.02.16
|
437
|
$specializations = Specialization::find()->where(['specialization_pid' => 0])->orderBy('specialization_id')->all();
|
7eb29439
Yarik
test
|
438
|
$post = \Yii::$app->request->post();
|
84ebac3d
Yarik
test
|
439
|
if(!empty( $post )) {
|
7eb29439
Yarik
test
|
440
441
442
443
444
445
|
$portfolio->load($post);
$portfolio->validate();
if(!$portfolio->hasErrors()) {
$portfolio->save();
$portfolio->unlinkAll('specializations', true);
foreach($portfolio->specializationInput as $one_specialization) {
|
34e7b1a4
Administrator
15.02.16
|
446
447
448
449
|
if($one_specialization){
$portfolio->link('specializations', Specialization::findOne($one_specialization));
}
|
7eb29439
Yarik
test
|
450
|
}
|
84ebac3d
Yarik
test
|
451
|
return $this->redirect('portfolio');
|
7eb29439
Yarik
test
|
452
453
|
}
}
|
84ebac3d
Yarik
test
|
454
455
|
return $this->render('_portfolio_form', [
'portfolio' => $portfolio,
|
9fdba9c2
Administrator
15.02.16
|
456
|
'specializations' => $specializations,
|
84ebac3d
Yarik
test
|
457
|
]);
|
7eb29439
Yarik
test
|
458
|
}
|
5f49082a
Yarik
test
|
459
|
|
7eb29439
Yarik
test
|
460
461
|
public function actionPortfolioUpdate($id)
{
|
a02e2fdb
Yarik
test
|
462
463
464
465
466
467
468
|
$user = \Yii::$app->user->identity;
$portfolio = $user->getPortfolios()
->where([ 'portfolio_id' => $id ])
->one();
if(!$portfolio instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
34e7b1a4
Administrator
15.02.16
|
469
|
$specializations = Specialization::find()->where(['specialization_pid' => 0])->orderBy('specialization_id')->all();
|
7eb29439
Yarik
test
|
470
|
$post = \Yii::$app->request->post();
|
84ebac3d
Yarik
test
|
471
|
if(!empty( $post )) {
|
7eb29439
Yarik
test
|
472
473
474
475
476
|
$portfolio->load($post);
$portfolio->validate();
if(!$portfolio->hasErrors()) {
$portfolio->save();
$portfolio->unlinkAll('specializations', true);
|
34e7b1a4
Administrator
15.02.16
|
477
|
|
7eb29439
Yarik
test
|
478
|
foreach($portfolio->specializationInput as $one_specialization) {
|
34e7b1a4
Administrator
15.02.16
|
479
480
481
|
if($one_specialization){
$portfolio->link('specializations', Specialization::findOne($one_specialization));
}
|
7eb29439
Yarik
test
|
482
|
}
|
84ebac3d
Yarik
test
|
483
|
return $this->redirect('portfolio');
|
7eb29439
Yarik
test
|
484
485
|
}
}
|
84ebac3d
Yarik
test
|
486
487
|
return $this->render('_portfolio_form', [
'portfolio' => $portfolio,
|
9fdba9c2
Administrator
15.02.16
|
488
|
'specializations' => $specializations,
|
84ebac3d
Yarik
test
|
489
|
]);
|
51e0a262
Yarik
test
|
490
|
}
|
5f49082a
Yarik
test
|
491
|
|
989c83b0
Yarik
test
|
492
493
|
public function actionPortfolioDelete($id)
{
|
a02e2fdb
Yarik
test
|
494
495
496
497
498
499
500
501
|
$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
|
502
503
504
|
$this->redirect('portfolio');
}
|
5f49082a
Yarik
test
|
505
506
|
public function actionProjects()
{
|
989c83b0
Yarik
test
|
507
508
509
510
511
512
513
|
$searchModel = new ProjectSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('projects', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
5f49082a
Yarik
test
|
514
|
}
|
6310a439
Administrator
firs page
|
515
|
|
84ebac3d
Yarik
test
|
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
public function actionProjectsCreate()
{
$project = new Project();
$specialization = Specialization::find()
->select([
'specialization_name',
'specialization_id',
])
->indexBy('specialization_id')
->asArray()
->column();
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
|
aa182b5c
Yarik
test
|
535
536
537
538
539
540
541
542
543
|
$projects = Project::find()
->select([
'name',
'project_id',
])
->where([ 'user_id' => \Yii::$app->user->getId() ])
->indexBy('project_id')
->asArray()
->column();
|
84ebac3d
Yarik
test
|
544
|
$post = \Yii::$app->request->post();
|
aa182b5c
Yarik
test
|
545
|
if(!empty( $post )) {
|
84ebac3d
Yarik
test
|
546
547
548
|
$project->load($post);
$project->validate();
if(!$project->hasErrors()) {
|
b95371cf
Yarik
test
|
549
550
551
552
553
554
555
556
557
558
559
560
|
$date_end = new \DateTime();
switch($post[ 'Project' ][ 'date_end' ]) {
case 2:
$date_end->modify('+14 day');
break;
case 3:
$date_end->modify('+30 day');
break;
default:
$date_end->modify('+7 day');
};
$project->date_end = \Yii::$app->formatter->asDate($date_end->getTimestamp(), 'short');
|
84ebac3d
Yarik
test
|
561
562
563
|
$project->save();
$project->unlinkAll('specializations', true);
foreach($project->specializationInput as $one_specialization) {
|
aa182b5c
Yarik
test
|
564
|
$project->link('specializations', Specialization::findOne($one_specialization));
|
84ebac3d
Yarik
test
|
565
566
567
|
}
$project->unlinkAll('payments', true);
foreach($project->paymentInput as $one_payment) {
|
aa182b5c
Yarik
test
|
568
|
$project->link('payments', Payment::findOne($one_payment));
|
84ebac3d
Yarik
test
|
569
|
}
|
ea09d15d
Yarik
test
|
570
571
572
573
|
return $this->redirect([
'projects-update',
'id' => $project->project_id,
]);
|
84ebac3d
Yarik
test
|
574
575
|
}
}
|
aa182b5c
Yarik
test
|
576
577
578
579
580
581
582
583
584
585
|
return $this->render('_projects_form', [
'project' => $project,
'specialization' => $specialization,
'payment' => $payment,
'projects' => $projects,
]);
}
public function actionProjectsUpdate($id)
{
|
a02e2fdb
Yarik
test
|
586
587
588
589
590
591
592
|
$user = \Yii::$app->user->identity;
$project = $user->getProjects()
->where([ 'project_id' => $id ])
->one();
if(!$project instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
aa182b5c
Yarik
test
|
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
|
$specialization = Specialization::find()
->select([
'specialization_name',
'specialization_id',
])
->indexBy('specialization_id')
->asArray()
->column();
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
|
a02e2fdb
Yarik
test
|
609
610
611
612
613
614
615
616
617
618
619
620
|
$projects = $user->getProjects()
->select([
'name',
'project_id',
])
->andWhere([
'not',
[ 'project_id' => $project->project_id ],
])
->indexBy('project_id')
->asArray()
->column();
|
aa182b5c
Yarik
test
|
621
622
623
624
625
|
$post = \Yii::$app->request->post();
if(!empty( $post )) {
$project->load($post);
$project->validate();
if(!$project->hasErrors()) {
|
b95371cf
Yarik
test
|
626
627
628
629
630
631
632
633
634
635
636
637
|
$date_end = new \DateTime();
switch($post[ 'Project' ][ 'date_end' ]) {
case 2:
$date_end->modify('+14 day');
break;
case 3:
$date_end->modify('+30 day');
break;
default:
$date_end->modify('+7 day');
};
$project->date_end = \Yii::$app->formatter->asDate($date_end->getTimestamp(), 'short');
|
aa182b5c
Yarik
test
|
638
639
640
641
642
643
644
645
646
|
$project->save();
$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));
}
|
aa182b5c
Yarik
test
|
647
648
649
650
651
652
653
654
|
}
}
return $this->render('_projects_form', [
'project' => $project,
'specialization' => $specialization,
'payment' => $payment,
'projects' => $projects,
]);
|
84ebac3d
Yarik
test
|
655
656
|
}
|
989c83b0
Yarik
test
|
657
658
|
public function actionProjectsDelete($id)
{
|
a02e2fdb
Yarik
test
|
659
660
661
662
663
664
665
666
|
$user = \Yii::$app->user->identity;
$project = $user->getProjects()
->where([ 'project_id' => $id ])
->one();
if(!$project instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$project->delete();
|
989c83b0
Yarik
test
|
667
668
669
|
$this->redirect('projects');
}
|
588209fc
Yarik
test
|
670
|
public function actionService()
|
ea09d15d
Yarik
test
|
671
|
{
|
ea09d15d
Yarik
test
|
672
|
$user = \Yii::$app->user->identity;
|
a02e2fdb
Yarik
test
|
673
|
$user_info = $user->userInfo;
|
588209fc
Yarik
test
|
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
|
if(empty( $user_info )) {
$user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
}
$specialization = Specialization::find()
->select([
'specialization_name',
'specialization_id',
])
->indexBy('specialization_id')
->asArray()
->column();
$payment = Payment::find()
->select([
'name',
'payment_id',
])
->indexBy('payment_id')
->asArray()
->column();
|
ea09d15d
Yarik
test
|
693
|
$post = \Yii::$app->request->post();
|
588209fc
Yarik
test
|
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
if(!empty( $post )) {
$user_info->load($post);
$user_info->validate();
if(!$user_info->hasErrors()) {
$user_info->save();
$user->load($post);
$user->unlinkAll('specializations', true);
foreach($user->specializationInput as $one_specialization) {
$user->link('specializations', Specialization::findOne($one_specialization));
}
$user->unlinkAll('payments', true);
foreach($user->paymentInput as $one_payment) {
$user->link('payments', Payment::findOne($one_payment));
}
}
|
ea09d15d
Yarik
test
|
709
|
}
|
588209fc
Yarik
test
|
710
711
712
713
714
715
|
return $this->render('service', [
'user' => $user,
'user_info' => $user_info,
'specialization' => $specialization,
'payment' => $payment,
]);
|
ea09d15d
Yarik
test
|
716
717
|
}
|
588209fc
Yarik
test
|
718
719
720
721
|
/**
* $user User
*/
public function actionSetting()
|
ea09d15d
Yarik
test
|
722
|
{
|
ea09d15d
Yarik
test
|
723
|
$user = \Yii::$app->user->identity;
|
588209fc
Yarik
test
|
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
|
$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' ] )) {
$user->addError('old_password', 'Введите новый пароль');
} 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
|
752
|
}
|
588209fc
Yarik
test
|
753
|
return $this->render('setting', [ 'user' => $user ]);
|
ea09d15d
Yarik
test
|
754
755
|
}
|
02524a34
Yarik
test
|
756
757
|
public function actionTeam()
{
|
b95371cf
Yarik
test
|
758
759
760
761
762
763
764
|
$searchModel = new TeamSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('team', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
02524a34
Yarik
test
|
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
|
}
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([
'team-update',
'id' => $team->team_id,
]);
} else {
return $this->render('_team_form', [
'team' => $team,
'department' => $department,
'country' => $country,
]);
}
}
public function actionTeamUpdate($id)
{
|
a02e2fdb
Yarik
test
|
800
801
802
803
804
805
806
|
$user = \Yii::$app->user->identity;
$team = $user->getTeams()
->where([ 'team_id' => $id ])
->one();
if(!$team instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
02524a34
Yarik
test
|
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
|
$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([
'team-update',
'id' => $team->team_id,
]);
} else {
return $this->render('_team_form', [
'team' => $team,
'department' => $department,
'country' => $country,
]);
}
}
|
588209fc
Yarik
test
|
835
836
|
public function actionTeamDelete($id)
{
|
a02e2fdb
Yarik
test
|
837
838
839
840
841
842
843
844
845
|
$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
|
846
847
848
|
$this->redirect('team');
}
|
ea09d15d
Yarik
test
|
849
850
|
public function actionVacancy()
{
|
588209fc
Yarik
test
|
851
852
853
854
855
856
857
|
$searchModel = new VacancySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('vacancy', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
|
ea09d15d
Yarik
test
|
858
859
860
861
862
863
864
865
866
867
868
869
870
871
|
}
public function actionVacancyCreate()
{
$vacancy = new Vacancy();
$employment = Employment::find()
->select([
'name',
'employment_id',
])
->indexBy('employment_id')
->asArray()
->column();
$post = \Yii::$app->request->post();
|
02524a34
Yarik
test
|
872
|
if(!empty( $post )) {
|
ea09d15d
Yarik
test
|
873
874
875
876
877
878
879
880
881
|
$vacancy->load($post);
$vacancy->validate();
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));
}
|
02524a34
Yarik
test
|
882
883
884
885
|
return $this->redirect([
'vacancy-update',
'id' => $vacancy->vacancy_id,
]);
|
ea09d15d
Yarik
test
|
886
887
888
|
}
}
return $this->render('_vacancy_form', [
|
02524a34
Yarik
test
|
889
|
'vacancy' => $vacancy,
|
ea09d15d
Yarik
test
|
890
891
892
893
894
895
|
'employment' => $employment,
]);
}
public function actionVacancyUpdate($id)
{
|
a02e2fdb
Yarik
test
|
896
897
898
899
900
901
902
|
$user = \Yii::$app->user->identity;
$vacancy = $user->getVacancies()
->where([ 'vacancy_id' => $id ])
->one();
if(!$vacancy instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
|
ea09d15d
Yarik
test
|
903
904
905
906
907
908
909
910
911
|
$employment = Employment::find()
->select([
'name',
'employment_id',
])
->indexBy('employment_id')
->asArray()
->column();
$post = \Yii::$app->request->post();
|
02524a34
Yarik
test
|
912
|
if(!empty( $post )) {
|
ea09d15d
Yarik
test
|
913
914
915
916
917
918
919
920
921
|
$vacancy->load($post);
$vacancy->validate();
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));
}
|
02524a34
Yarik
test
|
922
923
924
925
|
return $this->redirect([
'vacancy-update',
'id' => $vacancy->vacancy_id,
]);
|
ea09d15d
Yarik
test
|
926
927
928
|
}
}
return $this->render('_vacancy_form', [
|
02524a34
Yarik
test
|
929
|
'vacancy' => $vacancy,
|
ea09d15d
Yarik
test
|
930
931
932
933
|
'employment' => $employment,
]);
}
|
588209fc
Yarik
test
|
934
|
public function actionVacancyDelete($id)
|
5f49082a
Yarik
test
|
935
|
{
|
a02e2fdb
Yarik
test
|
936
937
938
939
940
941
942
943
944
|
$user = \Yii::$app->user->identity;
$vacancy = $user->getVacancies()
->where([ 'vacancy_id' => $id ])
->one();
if(!$vacancy instanceof ActiveRecord) {
throw new NotFoundHttpException('Запись не найдена');
}
$vacancy->delete();
|
588209fc
Yarik
test
|
945
|
$this->redirect('vacancy');
|
6310a439
Administrator
firs page
|
946
|
}
|
6310a439
Administrator
firs page
|
947
|
|
5f49082a
Yarik
test
|
948
949
950
951
952
953
954
955
|
/**
* @param $id
*
* @return User
* @throws NotFoundHttpException
*/
protected function findUser($id)
{
|
6310a439
Administrator
firs page
|
956
|
|
5f49082a
Yarik
test
|
957
958
959
960
961
962
|
if($model = User::findOne([ "id" => $id ])) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
|
6310a439
Administrator
firs page
|
963
|
|
5f49082a
Yarik
test
|
964
|
}
|