Commit 4c9663e0d402ecff04854e3abf148d9f4c242832

Authored by Yarik
1 parent 04b478b9

test

common/models/Blog.php
... ... @@ -64,7 +64,7 @@
64 64 {
65 65 return [
66 66 [
67   - [ 'name' ],
  67 + [ 'name', 'description' ],
68 68 'required',
69 69 ],
70 70 [
... ...
common/models/BlogSearch.php
... ... @@ -16,6 +16,8 @@
16 16 class BlogSearch extends Blog
17 17 {
18 18  
  19 + public $date_add_from;
  20 + public $date_add_to;
19 21 /**
20 22 * @inheritdoc
21 23 */
... ... @@ -38,9 +40,25 @@
38 40 'date_add',
39 41 'description',
40 42 'cover',
  43 + 'date_add_from',
  44 + 'date_add_to',
41 45 ],
42 46 'safe',
43 47 ],
  48 + [
  49 + [
  50 + 'date_add_from',
  51 + ],
  52 + 'default',
  53 + 'value' => date('Y-m-d', 0),
  54 + ],
  55 + [
  56 + [
  57 + 'date_add_to',
  58 + ],
  59 + 'default',
  60 + 'value' => date('Y-m-d'),
  61 + ],
44 62 ];
45 63 }
46 64  
... ... @@ -89,17 +107,19 @@
89 107 ]);
90 108  
91 109 $query->andFilterWhere([
  110 + 'between',
  111 + 'date_add',
  112 + $this->date_add_from,
  113 + $this->date_add_to,
  114 + ]);
  115 +
  116 + $query->andFilterWhere([
92 117 'like',
93 118 'name',
94 119 $this->name,
95 120 ])
96 121 ->andFilterWhere([
97 122 'like',
98   - 'link',
99   - $this->link,
100   - ])
101   - ->andFilterWhere([
102   - 'like',
103 123 'description',
104 124 $this->description,
105 125 ])
... ...
common/models/GallerySearch.php
... ... @@ -13,6 +13,8 @@
13 13 class GallerySearch extends Gallery
14 14 {
15 15  
  16 + public $date_add_from;
  17 + public $date_add_to;
16 18 /**
17 19 * @inheritdoc
18 20 */
... ... @@ -33,9 +35,25 @@
33 35 'date_add',
34 36 'cover',
35 37 'photo',
  38 + 'date_add_from',
  39 + 'date_add_to',
36 40 ],
37 41 'safe',
38 42 ],
  43 + [
  44 + [
  45 + 'date_add_from',
  46 + ],
  47 + 'default',
  48 + 'value' => date('Y-m-d', 0),
  49 + ],
  50 + [
  51 + [
  52 + 'date_add_to',
  53 + ],
  54 + 'default',
  55 + 'value' => date('Y-m-d'),
  56 + ],
39 57 ];
40 58 }
41 59  
... ... @@ -86,6 +104,13 @@
86 104 ]);
87 105  
88 106 $query->andFilterWhere([
  107 + 'between',
  108 + 'date_add',
  109 + $this->date_add_from,
  110 + $this->date_add_to,
  111 + ]);
  112 +
  113 + $query->andFilterWhere([
89 114 'like',
90 115 'name',
91 116 $this->name,
... ...
common/models/PortfolioSearch.php
... ... @@ -13,6 +13,8 @@
13 13 class PortfolioSearch extends Portfolio
14 14 {
15 15  
  16 + public $date_add_from;
  17 + public $date_add_to;
16 18 /**
17 19 * @inheritdoc
18 20 */
... ... @@ -39,9 +41,25 @@
39 41 'description',
40 42 'cover',
41 43 'specializationString',
  44 + 'date_add_from',
  45 + 'date_add_to',
42 46 ],
43 47 'safe',
44 48 ],
  49 + [
  50 + [
  51 + 'date_add_from',
  52 + ],
  53 + 'default',
  54 + 'value' => date('Y-m-d', 0),
  55 + ],
  56 + [
  57 + [
  58 + 'date_add_to',
  59 + ],
  60 + 'default',
  61 + 'value' => date('Y-m-d'),
  62 + ],
45 63 ];
46 64 }
47 65  
... ... @@ -79,7 +97,19 @@
79 97 return $dataProvider;
80 98 }
81 99  
82   - $query->joinWith('specializations');
  100 + $query2 = [ ];
  101 + if(!empty( $this->specializationString )) {
  102 + $query2 = Portfolio::find()
  103 + ->select([ 'portfolio.portfolio_id' ], 'DISTINCT')
  104 + ->joinWith([ 'specializations' ])
  105 + ->where([
  106 + 'like',
  107 + 'specialization_name',
  108 + $this->specializationString,
  109 + ])
  110 + ->asArray()
  111 + ->column();
  112 + }
83 113  
84 114 $query->andWhere([ 'user_id' => \Yii::$app->user->getId() ]);
85 115  
... ... @@ -93,6 +123,19 @@
93 123 ]);
94 124  
95 125 $query->andFilterWhere([
  126 + 'between',
  127 + 'date_add',
  128 + $this->date_add_from,
  129 + $this->date_add_to,
  130 + ]);
  131 +
  132 + $query->andFilterWhere(
  133 + [
  134 + 'portfolio_id' => $query2,
  135 + ]
  136 + );
  137 +
  138 + $query->andFilterWhere([
96 139 'like',
97 140 'name',
98 141 $this->name,
... ... @@ -126,11 +169,6 @@
126 169 'like',
127 170 'cover',
128 171 $this->cover,
129   - ])
130   - ->andFilterWhere([
131   - 'like',
132   - 'specialization.specialization_name',
133   - $this->specializationString,
134 172 ]);
135 173  
136 174 return $dataProvider;
... ...
common/models/Project.php
... ... @@ -116,12 +116,12 @@
116 116 'value' => [ ],
117 117 ],
118 118 [
119   - ['deadline'],
  119 + [ 'deadline' ],
120 120 'integer',
121 121 'min' => 1,
122 122 ],
123 123 [
124   - ['deadline'],
  124 + [ 'deadline' ],
125 125 'default',
126 126 'value' => 1,
127 127 ],
... ... @@ -190,6 +190,7 @@
190 190 {
191 191 return $this->getSpecializations()
192 192 ->asArray()
  193 + ->indexBy('specialization_id')
193 194 ->column();
194 195 }
195 196  
... ...
common/models/ProjectSearch.php
... ... @@ -87,7 +87,19 @@
87 87 return $dataProvider;
88 88 }
89 89  
90   - $query->joinWith('specializations');
  90 + $query2 = [ ];
  91 + if(!empty( $this->specializationString )) {
  92 + $query2 = Project::find()
  93 + ->select([ 'project.project_id' ], 'DISTINCT')
  94 + ->joinWith([ 'specializations' ])
  95 + ->where([
  96 + 'like',
  97 + 'specialization_name',
  98 + $this->specializationString,
  99 + ])
  100 + ->asArray()
  101 + ->column();
  102 + }
91 103  
92 104 $query->andWhere([ 'user_id' => \Yii::$app->user->getId() ]);
93 105  
... ... @@ -104,6 +116,12 @@
104 116 'contractual' => $this->contractual,
105 117 ]);
106 118  
  119 + $query->andFilterWhere(
  120 + [
  121 + 'project_id' => $query2,
  122 + ]
  123 + );
  124 +
107 125 $query->andFilterWhere([
108 126 'like',
109 127 'name',
... ... @@ -143,11 +161,6 @@
143 161 'like',
144 162 'file',
145 163 $this->file,
146   - ])
147   - ->andFilterWhere([
148   - 'like',
149   - 'specialization.specialization_name',
150   - $this->specializationString,
151 164 ]);
152 165  
153 166 return $dataProvider;
... ...
common/models/User.php
... ... @@ -26,6 +26,7 @@
26 26 */
27 27 class User extends ActiveRecord implements IdentityInterface, UserRbacInterface
28 28 {
  29 +
29 30 const STATUS_DELETED = 0;
30 31 const STATUS_ACTIVE = 10;
31 32  
... ... @@ -294,7 +295,6 @@
294 295  
295 296 /**
296 297 * Returns name of the User
297   - *
298 298 * @return string
299 299 */
300 300 public function getUserName()
... ... @@ -304,7 +304,6 @@
304 304  
305 305 /**
306 306 * Return array of all User's roles
307   - *
308 307 * @return array
309 308 */
310 309 public function getRoles()
... ... @@ -315,9 +314,10 @@
315 314 }
316 315  
317 316 /**
318   - * @param Role[] $roles User roles returned by [ManagerInterface]->[getRolesByUser($id)]
319   - * @param ManagerInterface $auth Auth manager
320   - * @param array $result
  317 + * @param Role[] $roles User roles returned by
  318 + * [ManagerInterface]->[getRolesByUser($id)]
  319 + * @param ManagerInterface $auth Auth manager
  320 + * @param array $result
321 321 *
322 322 * @return array
323 323 */
... ... @@ -339,7 +339,6 @@
339 339  
340 340 /**
341 341 * Return UserInfo for this User
342   - *
343 342 * @return \yii\db\ActiveQuery
344 343 */
345 344 public function getUserInfo()
... ... @@ -349,9 +348,7 @@
349 348  
350 349 /**
351 350 * Check if User is Performer
352   - *
353 351 * <i>currently in development mode</i>
354   - *
355 352 * @return bool
356 353 */
357 354 public function getIsPerformer()
... ... @@ -361,7 +358,6 @@
361 358  
362 359 /**
363 360 * Return CompanyInfo for this User
364   - *
365 361 * @return \yii\db\ActiveQuery
366 362 */
367 363 public function getCompanyInfo()
... ... @@ -371,7 +367,6 @@
371 367  
372 368 /**
373 369 * Return array of User's phones
374   - *
375 370 * @return array
376 371 */
377 372 public function getPhones()
... ... @@ -381,7 +376,6 @@
381 376  
382 377 /**
383 378 * Return array of User's site
384   - *
385 379 * @return array
386 380 */
387 381 public function getSite()
... ... @@ -391,7 +385,6 @@
391 385  
392 386 /**
393 387 * Return full address of User in view like:
394   - *
395 388 * <code>{country}, {city}, {street}, {house}</code>
396 389 * @return string
397 390 */
... ... @@ -402,7 +395,6 @@
402 395  
403 396 /**
404 397 * Return relative interval of time from User registration date until now.
405   - *
406 398 * @return string
407 399 */
408 400 public function getLiveTime()
... ... @@ -414,9 +406,7 @@
414 406  
415 407 /**
416 408 * Check if User is Customer
417   - *
418 409 * <i>currently in development</i>
419   - *
420 410 * @return bool
421 411 */
422 412 public function getIsCustomer()
... ... @@ -426,7 +416,6 @@
426 416  
427 417 /**
428 418 * Return array of payments types accepted by the user.
429   - *
430 419 * @return ActiveQuery
431 420 */
432 421 public function getPayments()
... ... @@ -437,7 +426,6 @@
437 426  
438 427 /**
439 428 * Return array of Payment IDs, accepted by the user.
440   - *
441 429 * @return integer[]
442 430 */
443 431 public function getPaymentInput()
... ... @@ -459,7 +447,6 @@
459 447  
460 448 /**
461 449 * Return array of Specializations in which the User works.
462   - *
463 450 * @return ActiveQuery
464 451 */
465 452 public function getSpecializations()
... ... @@ -470,7 +457,6 @@
470 457  
471 458 /**
472 459 * Return array of User's blogs
473   - *
474 460 * @return ActiveQuery
475 461 */
476 462 public function getBlog()
... ... @@ -480,7 +466,6 @@
480 466  
481 467 /**
482 468 * Return array of User's jobs.
483   - *
484 469 * @return ActiveQuery
485 470 */
486 471 public function getJobs()
... ... @@ -490,24 +475,23 @@
490 475  
491 476 /**
492 477 * Return ActiveRecord of current User's place of work.
493   - *
494 478 * @return ActiveQuery
495 479 */
496 480 public function getCurrentJob()
497 481 {
498   - return $this->hasOne(Job::className(), ['user_id' => 'id'])->where(['current' => 1]);
  482 + return $this->hasOne(Job::className(), [ 'user_id' => 'id' ])
  483 + ->where([ 'current' => 1 ]);
499 484 }
500 485  
501 486 /**
502 487 * Return array of User's specialization IDs
503   - *
504 488 * @return integer[]
505 489 */
506 490 public function getSpecializationInput()
507 491 {
508 492 return $this->getSpecializations()
509 493 ->asArray()
510   - ->indexBy('specialization_id')
  494 + ->indexBy('specialization_id')
511 495 ->column();
512 496 }
513 497  
... ... @@ -523,7 +507,6 @@
523 507  
524 508 /**
525 509 * Return array of User's portfolios.
526   - *
527 510 * @return ActiveQuery
528 511 */
529 512 public function getPortfolios()
... ... @@ -533,7 +516,6 @@
533 516  
534 517 /**
535 518 * Return array of User's projects.
536   - *
537 519 * @return ActiveQuery
538 520 */
539 521 public function getProjects()
... ... @@ -543,7 +525,6 @@
543 525  
544 526 /**
545 527 * Return array of company's Team members.
546   - *
547 528 * @return ActiveQuery
548 529 */
549 530 public function getTeams()
... ... @@ -553,7 +534,6 @@
553 534  
554 535 /**
555 536 * Return array of company's Vacancies.
556   - *
557 537 * @return ActiveQuery
558 538 */
559 539 public function getVacancies()
... ...
frontend/controllers/AccountsController.php
... ... @@ -115,8 +115,7 @@
115 115 $post = \Yii::$app->request->post();
116 116 if($blog->load($post) && $blog->save()) {
117 117 return $this->redirect([
118   - 'blog-update',
119   - 'id' => $blog->blog_id,
  118 + 'blog',
120 119 ]);
121 120 } else {
122 121 return $this->render('_blog_form', [ 'blog' => $blog ]);
... ...
frontend/views/accounts/_projects_form.php
... ... @@ -62,7 +62,7 @@
62 62 <?php if($child_first instanceof Specialization): ?>
63 63 <li>
64 64 <a href="#">
65   - <?= $form->field($project, "specializationInput[{$child_second->specialization_id}]")->checkbox(['value' => $child_second->specialization_id, 'label' => $child_second->specialization_name, 'uncheck' => null, 'checked' => 'checked']) ?>
  65 + <?= $form->field($project, "specializationInput[{$child_second->specialization_id}]")->checkbox(['value' => $child_second->specialization_id, 'label' => $child_second->specialization_name, 'uncheck' => null,]) ?>
66 66 </a>
67 67 </li>
68 68 <?php endif;?>
... ...
frontend/views/accounts/blog.php
... ... @@ -8,6 +8,8 @@
8 8 use yii\grid\ActionColumn;
9 9 use yii\grid\GridView;
10 10 use yii\helpers\Html;
  11 + use yii\jui\DatePicker;
  12 + use yii\widgets\ActiveField;
11 13  
12 14 $this->title = 'Блог';
13 15 $this->params[ 'breadcrumbs' ][] = $this->title;
... ... @@ -26,7 +28,39 @@
26 28 'label' => 'ID',
27 29 ],
28 30 'name',
29   - 'date_add',
  31 + [
  32 + 'attribute' => 'date_add',
  33 + 'filter' => "<div class=\"input-group input-group-xs input-daterange\">
  34 +<span class='field-teamsearch-experience_from_from'>".
  35 +DatePicker::widget([
  36 + 'model' => $searchModel,
  37 + 'attribute' => 'date_add_from',
  38 + 'language' => 'ru',
  39 + 'dateFormat' => 'yyyy-MM-dd',
  40 + 'clientOptions' => [
  41 + 'changeYear' => true,
  42 + 'changeMonth' => true,
  43 + ],
  44 +]).
  45 +"</span>
  46 +<span class=\"input-group-addon kv-field-separator\">
  47 +<i class=\"glyphicon glyphicon-resize-horizontal\"></i>
  48 +</span>
  49 +<span class='field-teamsearch-experience_from_to'>".
  50 + DatePicker::widget([
  51 + 'model' => $searchModel,
  52 + 'attribute' => 'date_add_to',
  53 + 'language' => 'ru',
  54 + 'dateFormat' => 'yyyy-MM-dd',
  55 + 'clientOptions' => [
  56 + 'changeYear' => true,
  57 + 'changeMonth' => true,
  58 + ],
  59 + ])
  60 +."</span>
  61 +</div>",
  62 + 'format' => 'html',
  63 + ],
30 64 'view_count',
31 65 [
32 66 'class' => ActionColumn::className(),
... ...
frontend/views/accounts/gallery.php
... ... @@ -7,6 +7,7 @@
7 7 use yii\data\ActiveDataProvider;
8 8 use yii\grid\GridView;
9 9 use yii\helpers\Html;
  10 + use yii\jui\DatePicker;
10 11  
11 12 $this->title = 'Галерея';
12 13 $this->params[ 'breadcrumbs' ][] = $this->title;
... ... @@ -27,24 +28,38 @@
27 28 'filterOptions' => ['class' => 'text-center']
28 29 ],
29 30 'name',
30   - 'date_add',
31 31 [
32   - 'attribute' => 'type',
33   - 'value' => function($model, $key, $index, $column) {
34   - switch($model->type) {
35   - case 2:
36   - return 'Видео';
37   - break;
38   - default:
39   - return 'Фото';
40   - break;
41   - }
42   - },
43   - 'label' => 'Фото или Видео',
44   - 'filter' => [
45   - 1 => 'Фото',
46   - 2 => 'Видео',
47   - ]
  32 + 'attribute' => 'date_add',
  33 + 'filter' => "<div class=\"input-group input-group-xs input-daterange\">
  34 +<span class='field-teamsearch-experience_from_from'>".
  35 + DatePicker::widget([
  36 + 'model' => $searchModel,
  37 + 'attribute' => 'date_add_from',
  38 + 'language' => 'ru',
  39 + 'dateFormat' => 'yyyy-MM-dd',
  40 + 'clientOptions' => [
  41 + 'changeYear' => true,
  42 + 'changeMonth' => true,
  43 + ],
  44 + ]).
  45 + "</span>
  46 +<span class=\"input-group-addon kv-field-separator\">
  47 +<i class=\"glyphicon glyphicon-resize-horizontal\"></i>
  48 +</span>
  49 +<span class='field-teamsearch-experience_from_to'>".
  50 + DatePicker::widget([
  51 + 'model' => $searchModel,
  52 + 'attribute' => 'date_add_to',
  53 + 'language' => 'ru',
  54 + 'dateFormat' => 'yyyy-MM-dd',
  55 + 'clientOptions' => [
  56 + 'changeYear' => true,
  57 + 'changeMonth' => true,
  58 + ],
  59 + ])
  60 + ."</span>
  61 +</div>",
  62 + 'format' => 'html',
48 63 ],
49 64 [
50 65 'class' => 'yii\grid\ActionColumn',
... ...
frontend/views/accounts/portfolio.php
... ... @@ -8,6 +8,7 @@
8 8 use yii\grid\ActionColumn;
9 9 use yii\grid\GridView;
10 10 use yii\helpers\Html;
  11 + use yii\jui\DatePicker;
11 12  
12 13 $this->title = 'Портфолио';
13 14 $this->params[ 'breadcrumbs' ][] = $this->title;
... ... @@ -26,7 +27,39 @@
26 27 'label' => 'ID',
27 28 ],
28 29 'name',
29   - 'date_add',
  30 + [
  31 + 'attribute' => 'date_add',
  32 + 'filter' => "<div class=\"input-group input-group-xs input-daterange\">
  33 +<span class='field-teamsearch-experience_from_from'>".
  34 + DatePicker::widget([
  35 + 'model' => $searchModel,
  36 + 'attribute' => 'date_add_from',
  37 + 'language' => 'ru',
  38 + 'dateFormat' => 'yyyy-MM-dd',
  39 + 'clientOptions' => [
  40 + 'changeYear' => true,
  41 + 'changeMonth' => true,
  42 + ],
  43 + ]).
  44 + "</span>
  45 +<span class=\"input-group-addon kv-field-separator\">
  46 +<i class=\"glyphicon glyphicon-resize-horizontal\"></i>
  47 +</span>
  48 +<span class='field-teamsearch-experience_from_to'>".
  49 + DatePicker::widget([
  50 + 'model' => $searchModel,
  51 + 'attribute' => 'date_add_to',
  52 + 'language' => 'ru',
  53 + 'dateFormat' => 'yyyy-MM-dd',
  54 + 'clientOptions' => [
  55 + 'changeYear' => true,
  56 + 'changeMonth' => true,
  57 + ],
  58 + ])
  59 + ."</span>
  60 +</div>",
  61 + 'format' => 'html',
  62 + ],
30 63 'view_count',
31 64 [
32 65 'attribute' => 'specializationString',
... ...