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 | 516 | $user = \Yii::$app->user->identity; |
| 517 | 517 | $user_info = $user->userInfo; |
| 518 | 518 | $company_info = $user->companyInfo; |
| 519 | - $user = \Yii::$app->user->identity; | |
| 520 | 519 | if(empty( $user_info )) { |
| 521 | 520 | //$user_info = new UserInfo([ 'user_id' => $user->id ]); |
| 522 | 521 | } |
| ... | ... | @@ -1068,12 +1067,14 @@ |
| 1068 | 1067 | /** |
| 1069 | 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 | 1072 | $user_info = $user->userInfo; |
| 1073 | 1073 | if(empty( $user_info )) { |
| 1074 | 1074 | $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); |
| 1075 | 1075 | } |
| 1076 | 1076 | $specializations = Specialization::find() |
| 1077 | + ->with('children') | |
| 1077 | 1078 | ->where([ 'specialization_pid' => 0 ]) |
| 1078 | 1079 | ->orderBy('specialization_id') |
| 1079 | 1080 | ->all(); | ... | ... |
frontend/controllers/SearchController.php
| ... | ... | @@ -109,11 +109,18 @@ use frontend\models\Option; |
| 109 | 109 | { |
| 110 | 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 | 118 | $searchModel = new SearchPerformerForm(); |
| 113 | 119 | |
| 114 | 120 | return $this->render('performer',[ |
| 115 | 121 | 'dataProvider' => $searchModel->search(Yii::$app->request->queryParams), |
| 116 | 122 | 'specialization' => $specialization, |
| 123 | + 'specializations' => $specializations, | |
| 117 | 124 | 'model'=> $searchModel |
| 118 | 125 | ]); |
| 119 | 126 | } | ... | ... |
frontend/models/SearchPerformerForm.php
| ... | ... | @@ -31,6 +31,8 @@ |
| 31 | 31 | |
| 32 | 32 | public $search; |
| 33 | 33 | |
| 34 | + public $portfolio; | |
| 35 | + | |
| 34 | 36 | /** |
| 35 | 37 | * @inheritdoc |
| 36 | 38 | */ |
| ... | ... | @@ -47,6 +49,7 @@ |
| 47 | 49 | 'rating', |
| 48 | 50 | 'online', |
| 49 | 51 | 'search', |
| 52 | + 'portfolio', | |
| 50 | 53 | ], |
| 51 | 54 | 'safe', |
| 52 | 55 | ], |
| ... | ... | @@ -55,7 +58,11 @@ |
| 55 | 58 | 'default', |
| 56 | 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 | 92 | */ |
| 86 | 93 | public function search($params) |
| 87 | 94 | { |
| 88 | - | |
| 89 | 95 | $this->load($params); |
| 90 | 96 | |
| 91 | 97 | $query = User::find() |
| ... | ... | @@ -100,6 +106,7 @@ |
| 100 | 106 | 'specializations', |
| 101 | 107 | 'companyInfo', |
| 102 | 108 | ]) |
| 109 | + ->innerJoin('portfolio', '"portfolio"."user_id" = "user"."id"') | |
| 103 | 110 | ->where([ 'user_info.is_freelancer' => 1 ]); |
| 104 | 111 | |
| 105 | 112 | $dataProvider = new ActiveDataProvider([ |
| ... | ... | @@ -162,11 +169,14 @@ |
| 162 | 169 | ->innerJoin([ 'spec' => 'user_specialization' ], 'spec.user_id = users.id') |
| 163 | 170 | ->asArray() |
| 164 | 171 | ->column(); |
| 165 | - if(empty($query2)) { | |
| 172 | + if(empty( $query2 )) { | |
| 166 | 173 | $query->where('0=1'); |
| 167 | 174 | return $dataProvider; |
| 168 | 175 | } |
| 169 | 176 | |
| 177 | + // Clear array from empty strings | |
| 178 | + $this->specialization = array_filter($this->specialization, 'strlen'); | |
| 179 | + | |
| 170 | 180 | $query->andFilterWhere([ |
| 171 | 181 | 'user_info.city' => $this->city, |
| 172 | 182 | 'specialization.specialization_id' => $this->specialization, | ... | ... |
frontend/views/accounts/general.php
| ... | ... | @@ -46,13 +46,18 @@ |
| 46 | 46 | </div> |
| 47 | 47 | <div class="general-check-right"> |
| 48 | 48 | <div class="general-check-right-txt"> |
| 49 | - Обязательно должны быть указаны специализации услуг, что бы вы попали в рейтинг исполнителей | |
| 49 | + Обязательно должны быть указаны специализации услуг, а также добавлены проекты в портфолио, что бы вы попали в рейтинг исполнителей | |
| 50 | 50 | <?php |
| 51 | 51 | if(!empty( $user->specializations )) { |
| 52 | 52 | echo "<p>В Вашем профиле указаны специализации: " . count($user->specializations) . "</p>"; |
| 53 | 53 | } else { |
| 54 | 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 | 62 | </div> |
| 58 | 63 | </div> | ... | ... |
frontend/views/accounts/service.php
frontend/views/search/performer.php
| ... | ... | @@ -4,10 +4,9 @@ |
| 4 | 4 | * @var SearchPerformerForm $model |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | - use common\models\Vacancy; | |
| 7 | + use common\models\Specialization; | |
| 8 | 8 | use frontend\models\SearchPerformerForm; |
| 9 | 9 | use kartik\select2\Select2; |
| 10 | - use yii\helpers\ArrayHelper; | |
| 11 | 10 | use \yii\helpers\Html; |
| 12 | 11 | use yii\helpers\Url; |
| 13 | 12 | use yii\jui\SliderInput; |
| ... | ... | @@ -21,7 +20,6 @@ |
| 21 | 20 | $active_key = array_keys($sort_array)[ 0 ]; |
| 22 | 21 | $active_value = $sort_array[ $active_key ]; |
| 23 | 22 | $sort_name = ( ( $active_value == 4 ) ? '-' : '' ) . $active_key; |
| 24 | - | |
| 25 | 23 | $this->title = 'My Yii Application'; |
| 26 | 24 | ?> |
| 27 | 25 | |
| ... | ... | @@ -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 | 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 | 143 | <?= $form->field($model, 'type') |
| 63 | 144 | ->dropDownList([ |
| ... | ... | @@ -128,8 +209,6 @@ |
| 128 | 209 | 'unselect' => NULL, |
| 129 | 210 | ]); ?> |
| 130 | 211 | |
| 131 | - | |
| 132 | - | |
| 133 | 212 | <?= $form->field($model, 'additional_parameters') |
| 134 | 213 | ->checkboxList([ |
| 135 | 214 | 'with_portfolio' => 'Только с портфолио', |
| ... | ... | @@ -176,9 +255,9 @@ |
| 176 | 255 | ?> |
| 177 | 256 | |
| 178 | 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 | 263 | <div class="search-worker-sort-wr style"> | ... | ... |