Commit a2cb610bdeb4a25bd6b72846ef1af60ce94e8b7a
1 parent
fe96bcdd
Commit
Showing
6 changed files
with
118 additions
and
16 deletions
Show diff stats
frontend/controllers/AccountsController.php
| @@ -516,7 +516,6 @@ | @@ -516,7 +516,6 @@ | ||
| 516 | $user = \Yii::$app->user->identity; | 516 | $user = \Yii::$app->user->identity; |
| 517 | $user_info = $user->userInfo; | 517 | $user_info = $user->userInfo; |
| 518 | $company_info = $user->companyInfo; | 518 | $company_info = $user->companyInfo; |
| 519 | - $user = \Yii::$app->user->identity; | ||
| 520 | if(empty( $user_info )) { | 519 | if(empty( $user_info )) { |
| 521 | //$user_info = new UserInfo([ 'user_id' => $user->id ]); | 520 | //$user_info = new UserInfo([ 'user_id' => $user->id ]); |
| 522 | } | 521 | } |
| @@ -1068,12 +1067,14 @@ | @@ -1068,12 +1067,14 @@ | ||
| 1068 | /** | 1067 | /** |
| 1069 | * @var User $user | 1068 | * @var User $user |
| 1070 | */ | 1069 | */ |
| 1071 | - $user = \Yii::$app->user->identity; | 1070 | + $user = User::find()->where(['id' => \Yii::$app->user->id])->one(); |
| 1071 | + $user->setSpecializationInput($user->getSpecializationInput()); | ||
| 1072 | $user_info = $user->userInfo; | 1072 | $user_info = $user->userInfo; |
| 1073 | if(empty( $user_info )) { | 1073 | if(empty( $user_info )) { |
| 1074 | $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); | 1074 | $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); |
| 1075 | } | 1075 | } |
| 1076 | $specializations = Specialization::find() | 1076 | $specializations = Specialization::find() |
| 1077 | + ->with('children') | ||
| 1077 | ->where([ 'specialization_pid' => 0 ]) | 1078 | ->where([ 'specialization_pid' => 0 ]) |
| 1078 | ->orderBy('specialization_id') | 1079 | ->orderBy('specialization_id') |
| 1079 | ->all(); | 1080 | ->all(); |
frontend/controllers/SearchController.php
| @@ -109,11 +109,18 @@ use frontend\models\Option; | @@ -109,11 +109,18 @@ use frontend\models\Option; | ||
| 109 | { | 109 | { |
| 110 | $specialization = Specialization::specializationsList(); | 110 | $specialization = Specialization::specializationsList(); |
| 111 | 111 | ||
| 112 | + $specializations = Specialization::find() | ||
| 113 | + ->with('children') | ||
| 114 | + ->where([ 'specialization_pid' => 0 ]) | ||
| 115 | + ->orderBy('specialization_id') | ||
| 116 | + ->all(); | ||
| 117 | + | ||
| 112 | $searchModel = new SearchPerformerForm(); | 118 | $searchModel = new SearchPerformerForm(); |
| 113 | 119 | ||
| 114 | return $this->render('performer',[ | 120 | return $this->render('performer',[ |
| 115 | 'dataProvider' => $searchModel->search(Yii::$app->request->queryParams), | 121 | 'dataProvider' => $searchModel->search(Yii::$app->request->queryParams), |
| 116 | 'specialization' => $specialization, | 122 | 'specialization' => $specialization, |
| 123 | + 'specializations' => $specializations, | ||
| 117 | 'model'=> $searchModel | 124 | 'model'=> $searchModel |
| 118 | ]); | 125 | ]); |
| 119 | } | 126 | } |
frontend/models/SearchPerformerForm.php
| @@ -31,6 +31,8 @@ | @@ -31,6 +31,8 @@ | ||
| 31 | 31 | ||
| 32 | public $search; | 32 | public $search; |
| 33 | 33 | ||
| 34 | + public $portfolio; | ||
| 35 | + | ||
| 34 | /** | 36 | /** |
| 35 | * @inheritdoc | 37 | * @inheritdoc |
| 36 | */ | 38 | */ |
| @@ -47,6 +49,7 @@ | @@ -47,6 +49,7 @@ | ||
| 47 | 'rating', | 49 | 'rating', |
| 48 | 'online', | 50 | 'online', |
| 49 | 'search', | 51 | 'search', |
| 52 | + 'portfolio', | ||
| 50 | ], | 53 | ], |
| 51 | 'safe', | 54 | 'safe', |
| 52 | ], | 55 | ], |
| @@ -55,7 +58,11 @@ | @@ -55,7 +58,11 @@ | ||
| 55 | 'default', | 58 | 'default', |
| 56 | 'value' => 0, | 59 | 'value' => 0, |
| 57 | ], | 60 | ], |
| 58 | - | 61 | + [ |
| 62 | + [ 'portfolio' ], | ||
| 63 | + 'default', | ||
| 64 | + 'value' => 1, | ||
| 65 | + ], | ||
| 59 | ]; | 66 | ]; |
| 60 | } | 67 | } |
| 61 | 68 | ||
| @@ -85,7 +92,6 @@ | @@ -85,7 +92,6 @@ | ||
| 85 | */ | 92 | */ |
| 86 | public function search($params) | 93 | public function search($params) |
| 87 | { | 94 | { |
| 88 | - | ||
| 89 | $this->load($params); | 95 | $this->load($params); |
| 90 | 96 | ||
| 91 | $query = User::find() | 97 | $query = User::find() |
| @@ -100,6 +106,7 @@ | @@ -100,6 +106,7 @@ | ||
| 100 | 'specializations', | 106 | 'specializations', |
| 101 | 'companyInfo', | 107 | 'companyInfo', |
| 102 | ]) | 108 | ]) |
| 109 | + ->innerJoin('portfolio', '"portfolio"."user_id" = "user"."id"') | ||
| 103 | ->where([ 'user_info.is_freelancer' => 1 ]); | 110 | ->where([ 'user_info.is_freelancer' => 1 ]); |
| 104 | 111 | ||
| 105 | $dataProvider = new ActiveDataProvider([ | 112 | $dataProvider = new ActiveDataProvider([ |
| @@ -162,11 +169,14 @@ | @@ -162,11 +169,14 @@ | ||
| 162 | ->innerJoin([ 'spec' => 'user_specialization' ], 'spec.user_id = users.id') | 169 | ->innerJoin([ 'spec' => 'user_specialization' ], 'spec.user_id = users.id') |
| 163 | ->asArray() | 170 | ->asArray() |
| 164 | ->column(); | 171 | ->column(); |
| 165 | - if(empty($query2)) { | 172 | + if(empty( $query2 )) { |
| 166 | $query->where('0=1'); | 173 | $query->where('0=1'); |
| 167 | return $dataProvider; | 174 | return $dataProvider; |
| 168 | } | 175 | } |
| 169 | 176 | ||
| 177 | + // Clear array from empty strings | ||
| 178 | + $this->specialization = array_filter($this->specialization, 'strlen'); | ||
| 179 | + | ||
| 170 | $query->andFilterWhere([ | 180 | $query->andFilterWhere([ |
| 171 | 'user_info.city' => $this->city, | 181 | 'user_info.city' => $this->city, |
| 172 | 'specialization.specialization_id' => $this->specialization, | 182 | 'specialization.specialization_id' => $this->specialization, |
frontend/views/accounts/general.php
| @@ -46,13 +46,18 @@ | @@ -46,13 +46,18 @@ | ||
| 46 | </div> | 46 | </div> |
| 47 | <div class="general-check-right"> | 47 | <div class="general-check-right"> |
| 48 | <div class="general-check-right-txt"> | 48 | <div class="general-check-right-txt"> |
| 49 | - Обязательно должны быть указаны специализации услуг, что бы вы попали в рейтинг исполнителей | 49 | + Обязательно должны быть указаны специализации услуг, а также добавлены проекты в портфолио, что бы вы попали в рейтинг исполнителей |
| 50 | <?php | 50 | <?php |
| 51 | if(!empty( $user->specializations )) { | 51 | if(!empty( $user->specializations )) { |
| 52 | echo "<p>В Вашем профиле указаны специализации: " . count($user->specializations) . "</p>"; | 52 | echo "<p>В Вашем профиле указаны специализации: " . count($user->specializations) . "</p>"; |
| 53 | } else { | 53 | } else { |
| 54 | echo "<p>В Вашем профиле не указаны специализации. Чтобы указать - перейдите по " . Html::a('ссылке', [ 'accounts/service' ], [ 'target' => '_blank' ]) . "</p>"; | 54 | echo "<p>В Вашем профиле не указаны специализации. Чтобы указать - перейдите по " . Html::a('ссылке', [ 'accounts/service' ], [ 'target' => '_blank' ]) . "</p>"; |
| 55 | } | 55 | } |
| 56 | + if(!empty( $user->portfolios )) { | ||
| 57 | + echo "<p>В Вашем портфолио добавлено проектов: " . count($user->portfolios) . "</p>"; | ||
| 58 | + } else { | ||
| 59 | + echo "<p>В Вашем портфолио не добавлены проекты. Чтобы добавить - перейдите по " . Html::a('ссылке', [ 'accounts/portfolio' ], [ 'target' => '_blank' ]) . "</p>"; | ||
| 60 | + } | ||
| 56 | ?> | 61 | ?> |
| 57 | </div> | 62 | </div> |
| 58 | </div> | 63 | </div> |
frontend/views/accounts/service.php
| @@ -51,7 +51,7 @@ | @@ -51,7 +51,7 @@ | ||
| 51 | ?> | 51 | ?> |
| 52 | </div> | 52 | </div> |
| 53 | </div> | 53 | </div> |
| 54 | - | 54 | + |
| 55 | <div class="input-blocks-wrapper admin-menu-list"> | 55 | <div class="input-blocks-wrapper admin-menu-list"> |
| 56 | <div class="input-blocks" style="width: 100%; margin-bottom: 5px"> | 56 | <div class="input-blocks" style="width: 100%; margin-bottom: 5px"> |
| 57 | <label>Специализации</label> | 57 | <label>Специализации</label> |
frontend/views/search/performer.php
| @@ -4,10 +4,9 @@ | @@ -4,10 +4,9 @@ | ||
| 4 | * @var SearchPerformerForm $model | 4 | * @var SearchPerformerForm $model |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | - use common\models\Vacancy; | 7 | + use common\models\Specialization; |
| 8 | use frontend\models\SearchPerformerForm; | 8 | use frontend\models\SearchPerformerForm; |
| 9 | use kartik\select2\Select2; | 9 | use kartik\select2\Select2; |
| 10 | - use yii\helpers\ArrayHelper; | ||
| 11 | use \yii\helpers\Html; | 10 | use \yii\helpers\Html; |
| 12 | use yii\helpers\Url; | 11 | use yii\helpers\Url; |
| 13 | use yii\jui\SliderInput; | 12 | use yii\jui\SliderInput; |
| @@ -21,7 +20,6 @@ | @@ -21,7 +20,6 @@ | ||
| 21 | $active_key = array_keys($sort_array)[ 0 ]; | 20 | $active_key = array_keys($sort_array)[ 0 ]; |
| 22 | $active_value = $sort_array[ $active_key ]; | 21 | $active_value = $sort_array[ $active_key ]; |
| 23 | $sort_name = ( ( $active_value == 4 ) ? '-' : '' ) . $active_key; | 22 | $sort_name = ( ( $active_value == 4 ) ? '-' : '' ) . $active_key; |
| 24 | - | ||
| 25 | $this->title = 'My Yii Application'; | 23 | $this->title = 'My Yii Application'; |
| 26 | ?> | 24 | ?> |
| 27 | 25 | ||
| @@ -54,10 +52,93 @@ | @@ -54,10 +52,93 @@ | ||
| 54 | ], | 52 | ], |
| 55 | ]); ?> | 53 | ]); ?> |
| 56 | 54 | ||
| 55 | + <?php | ||
| 56 | + // New specialization chooser | ||
| 57 | + ?> | ||
| 58 | + <div class="input-blocks-wrapper admin-menu-list"> | ||
| 59 | + <div class="input-blocks" style="width: 100%; margin-bottom: 5px"> | ||
| 60 | + <label>Специализации</label> | ||
| 61 | + <div class="required"></div> | ||
| 62 | + </div> | ||
| 63 | + <div class="style"> | ||
| 64 | + <ul class="content-menu-first"> | ||
| 65 | + <?php foreach($specializations as $specialization): ?> | ||
| 66 | + <li data-img="<?= $specialization->image ?>"> | ||
| 67 | + <span data-menu-bg="<?= $specialization->background ?>" style="background: <?= $specialization->background ?>"></span><a href="#"><?= $specialization->specialization_name ?></a> | ||
| 68 | + <ul> | ||
| 69 | + <?php foreach($specialization->children as $child_first): ?> | ||
| 70 | + | ||
| 71 | + <?php if($child_first instanceof Specialization): ?> | ||
| 72 | + <li> | ||
| 73 | + <a href="#"><?= $child_first->specialization_name ?></a> | ||
| 74 | + <ul> | ||
| 75 | + <?php foreach($child_first->children as $child_second): ?> | ||
| 76 | + <?php if($child_first instanceof Specialization): ?> | ||
| 77 | + <li> | ||
| 78 | + <a href="#" title="<?= $child_second->specialization_name ?>"> | ||
| 79 | + <?= $form->field($model, "specialization[{$child_second->specialization_id}]", [ | ||
| 80 | + 'template' => '{input}{label}{hint}{error}', | ||
| 81 | + ]) | ||
| 82 | + ->label('<span></span>' . $child_second->specialization_name) | ||
| 83 | + ->checkbox([ | ||
| 84 | + 'value' => $child_second->specialization_id, | ||
| 85 | + 'label' => NULL, | ||
| 86 | + 'uncheck' => NULL, | ||
| 87 | + 'class' => 'custom-check', | ||
| 88 | + ], false) ?> | ||
| 89 | + </a> | ||
| 90 | + </li> | ||
| 91 | + <?php endif; ?> | ||
| 92 | + <?php endforeach; ?> | ||
| 93 | + </ul> | ||
| 94 | + </li> | ||
| 95 | + <?php endif; ?> | ||
| 96 | + <?php endforeach; ?> | ||
| 97 | + | ||
| 98 | + </ul> | ||
| 99 | + </li> | ||
| 100 | + <?php endforeach; ?> | ||
| 101 | + </ul> | ||
| 102 | + </div> | ||
| 103 | + <div class="style admn-menu-err"> | ||
| 104 | + <div class="help-block">Необходимо выбрать хотя бы одну «специализацию».</div> | ||
| 105 | + </div> | ||
| 106 | + </div> | ||
| 107 | + | ||
| 108 | + <div class="admin-specialization-selected style"> | ||
| 109 | + <ul></ul> | ||
| 110 | + </div> | ||
| 111 | + | ||
| 112 | + <?php | ||
| 113 | + // End of new specialization chooser | ||
| 114 | + ?> | ||
| 115 | + | ||
| 116 | + <?php | ||
| 117 | + /* | ||
| 118 | + ?> | ||
| 57 | 119 | ||
| 58 | - <?= $form->field($model, 'specialization') | 120 | + <?= $form->field($model, 'specialization[]') |
| 59 | ->dropDownList($specialization, [ 'prompt' => 'Любая' ]); ?> | 121 | ->dropDownList($specialization, [ 'prompt' => 'Любая' ]); ?> |
| 122 | + <?php | ||
| 123 | + */ | ||
| 124 | + ?> | ||
| 60 | 125 | ||
| 126 | + <?= $form->field($model, 'portfolio', [ | ||
| 127 | + 'options' => [ | ||
| 128 | + 'class' => 'blocks-check-list-wrapp', | ||
| 129 | + ], | ||
| 130 | + 'template' => "<div class='blocks-check-title'>{label}</div>\n{input}\n{hint}\n{error}", | ||
| 131 | + ]) | ||
| 132 | + ->label('Искать в') | ||
| 133 | + ->radioList([ | ||
| 134 | + 1 => 'Портфолио', | ||
| 135 | + 0 => 'Услуги', | ||
| 136 | + ], [ | ||
| 137 | + 'item' => function($index, $label, $name, $checked, $value) use ($model) { | ||
| 138 | + return "<div class='blocks-check-list'><input type='radio' id='{$model->formName()}-{$index}-portfolio' name='{$name}' class='check-search' value='{$value}' " . ( $checked ? 'checked' : '' ) . "><label for='{$model->formName()}-{$index}-portfolio'><span></span>{$label}</label></div>"; | ||
| 139 | + }, | ||
| 140 | + 'unselect' => NULL, | ||
| 141 | + ]); ?> | ||
| 61 | 142 | ||
| 62 | <?= $form->field($model, 'type') | 143 | <?= $form->field($model, 'type') |
| 63 | ->dropDownList([ | 144 | ->dropDownList([ |
| @@ -128,8 +209,6 @@ | @@ -128,8 +209,6 @@ | ||
| 128 | 'unselect' => NULL, | 209 | 'unselect' => NULL, |
| 129 | ]); ?> | 210 | ]); ?> |
| 130 | 211 | ||
| 131 | - | ||
| 132 | - | ||
| 133 | <?= $form->field($model, 'additional_parameters') | 212 | <?= $form->field($model, 'additional_parameters') |
| 134 | ->checkboxList([ | 213 | ->checkboxList([ |
| 135 | 'with_portfolio' => 'Только с портфолио', | 214 | 'with_portfolio' => 'Только с портфолио', |
| @@ -176,9 +255,9 @@ | @@ -176,9 +255,9 @@ | ||
| 176 | ?> | 255 | ?> |
| 177 | 256 | ||
| 178 | <?php | 257 | <?php |
| 179 | - if(empty(\Yii::$app->user->id) || empty(\Yii::$app->user->identity->specializations)) { | ||
| 180 | - echo Html::a('Добавить себя в каталог', Url::toRoute('accounts/service'), [ 'class' => 'add-to-catalog-search-worker' ]); | ||
| 181 | - } | 258 | + if(empty( \Yii::$app->user->id ) || empty( \Yii::$app->user->identity->specializations )) { |
| 259 | + echo Html::a('Добавить себя в каталог', Url::toRoute('accounts/service'), [ 'class' => 'add-to-catalog-search-worker' ]); | ||
| 260 | + } | ||
| 182 | ?> | 261 | ?> |
| 183 | 262 | ||
| 184 | <div class="search-worker-sort-wr style"> | 263 | <div class="search-worker-sort-wr style"> |