Commit e4a014b8984be64f35fa8989694833914b5a7eb9

Authored by Yarik
1 parent df1b36d6

test

common/models/TeamSearch.php
@@ -202,31 +202,31 @@ @@ -202,31 +202,31 @@
202 ]) 202 ])
203 ->andFilterWhere([ 203 ->andFilterWhere([
204 'like', 204 'like',
205 - 'country_id',  
206 - $this->country_id, 205 + 'LOWER(country_id)',
  206 + mb_strtolower($this->country_id),
207 ]) 207 ])
208 ->andFilterWhere([ 208 ->andFilterWhere([
209 'or', 209 'or',
210 [ 210 [
211 'like', 211 'like',
212 - 'lastname',  
213 - $this->user, 212 + 'LOWER(lastname)',
  213 + mb_strtolower($this->user),
214 ], 214 ],
215 [ 215 [
216 'like', 216 'like',
217 - 'firstname',  
218 - $this->user, 217 + 'LOWER(firstname)',
  218 + mb_strtolower($this->user),
219 ], 219 ],
220 [ 220 [
221 'like', 221 'like',
222 - 'middlename',  
223 - $this->user, 222 + 'LOWER(middlename)',
  223 + mb_strtolower($this->user),
224 ], 224 ],
225 ]) 225 ])
226 ->andFilterWhere([ 226 ->andFilterWhere([
227 'like', 227 'like',
228 - 'department.name',  
229 - $this->department, 228 + 'LOWER(department.name)',
  229 + mb_strtolower($this->department),
230 ]); 230 ]);
231 231
232 return $dataProvider; 232 return $dataProvider;
frontend/controllers/AccountsController.php
@@ -183,7 +183,7 @@ @@ -183,7 +183,7 @@
183 $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); 183 $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]);
184 } 184 }
185 if(!empty( \Yii::$app->request->post() )) { 185 if(!empty( \Yii::$app->request->post() )) {
186 - if(!empty(Yii::$app->request->post('Fields'))) { 186 + if(!empty( Yii::$app->request->post('Fields') )) {
187 Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru'); 187 Fields::saveFieldData(Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(), 'ru');
188 } 188 }
189 $user_info->load(\Yii::$app->request->post()); 189 $user_info->load(\Yii::$app->request->post());
@@ -519,7 +519,7 @@ @@ -519,7 +519,7 @@
519 $portfolio->save(); 519 $portfolio->save();
520 $portfolio->unlinkAll('specializations', true); 520 $portfolio->unlinkAll('specializations', true);
521 foreach($portfolio->specializationInput as $one_specialization) { 521 foreach($portfolio->specializationInput as $one_specialization) {
522 - $portfolio->link('specializations', Specialization::findOne($one_specialization)); 522 + $portfolio->link('specializations', Specialization::findOne($one_specialization));
523 } 523 }
524 return $this->redirect('portfolio'); 524 return $this->redirect('portfolio');
525 } 525 }
@@ -843,10 +843,19 @@ @@ -843,10 +843,19 @@
843 { 843 {
844 $searchModel = new TeamSearch(); 844 $searchModel = new TeamSearch();
845 $dataProvider = $searchModel->search(Yii::$app->request->queryParams); 845 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  846 + $departments = Department::find()
  847 + ->select([
  848 + 'name',
  849 + 'department_id',
  850 + ])
  851 + ->indexBy('department_id')
  852 + ->asArray()
  853 + ->column();
846 854
847 return $this->render('team', [ 855 return $this->render('team', [
848 'searchModel' => $searchModel, 856 'searchModel' => $searchModel,
849 'dataProvider' => $dataProvider, 857 'dataProvider' => $dataProvider,
  858 + 'departments' => $departments,
850 ]); 859 ]);
851 } 860 }
852 861
@@ -873,8 +882,7 @@ @@ -873,8 +882,7 @@
873 $post = \Yii::$app->request->post(); 882 $post = \Yii::$app->request->post();
874 if($team->load($post) && $team->save()) { 883 if($team->load($post) && $team->save()) {
875 return $this->redirect([ 884 return $this->redirect([
876 - 'team-update',  
877 - 'id' => $team->team_id, 885 + 'team',
878 ]); 886 ]);
879 } else { 887 } else {
880 return $this->render('_team_form', [ 888 return $this->render('_team_form', [
@@ -918,8 +926,7 @@ @@ -918,8 +926,7 @@
918 $post = \Yii::$app->request->post(); 926 $post = \Yii::$app->request->post();
919 if($team->load($post) && $team->save()) { 927 if($team->load($post) && $team->save()) {
920 return $this->redirect([ 928 return $this->redirect([
921 - 'team-update',  
922 - 'id' => $team->team_id, 929 + 'team',
923 ]); 930 ]);
924 } else { 931 } else {
925 return $this->render('_team_form', [ 932 return $this->render('_team_form', [
@@ -991,7 +998,7 @@ @@ -991,7 +998,7 @@
991 if(!empty( $post )) { 998 if(!empty( $post )) {
992 $vacancy->load($post); 999 $vacancy->load($post);
993 $vacancy->validate(); 1000 $vacancy->validate();
994 - if(empty($vacancy->specializationInput)) { 1001 + if(empty( $vacancy->specializationInput )) {
995 $vacancy->addError('specializationInput', 'Cannot be blank'); 1002 $vacancy->addError('specializationInput', 'Cannot be blank');
996 } else { 1003 } else {
997 $vacancy->clearErrors('specializationInput'); 1004 $vacancy->clearErrors('specializationInput');
@@ -1055,7 +1062,7 @@ @@ -1055,7 +1062,7 @@
1055 if(!empty( $post )) { 1062 if(!empty( $post )) {
1056 $vacancy->load($post); 1063 $vacancy->load($post);
1057 $vacancy->validate(); 1064 $vacancy->validate();
1058 - if(empty($vacancy->specializationInput)) { 1065 + if(empty( $vacancy->specializationInput )) {
1059 $vacancy->addError('specializationInput', 'Cannot be blank'); 1066 $vacancy->addError('specializationInput', 'Cannot be blank');
1060 } else { 1067 } else {
1061 $vacancy->clearErrors('specializationInput'); 1068 $vacancy->clearErrors('specializationInput');
frontend/views/accounts/_portfolio_form.php
@@ -5,15 +5,15 @@ @@ -5,15 +5,15 @@
5 */ 5 */
6 use common\models\Option; 6 use common\models\Option;
7 use common\models\Portfolio; 7 use common\models\Portfolio;
8 -use common\models\Specialization;  
9 -use common\widgets\ImageUploader; 8 + use common\models\Specialization;
  9 + use common\widgets\ImageUploader;
10 use mihaildev\ckeditor\CKEditor; 10 use mihaildev\ckeditor\CKEditor;
11 -use yii\helpers\ArrayHelper;  
12 -use yii\helpers\Html; 11 + use yii\helpers\ArrayHelper;
  12 + use yii\helpers\Html;
13 use yii\widgets\ActiveForm; 13 use yii\widgets\ActiveForm;
14 use \common\widgets\MultiLangForm; 14 use \common\widgets\MultiLangForm;
15 -use kartik\select2\Select2;  
16 -use yii\web\JsExpression; 15 + use kartik\select2\Select2;
  16 + use yii\web\JsExpression;
17 17
18 $this->title = 'Портфолио'; 18 $this->title = 'Портфолио';
19 $this->params[ 'breadcrumbs' ][] = $this->title; 19 $this->params[ 'breadcrumbs' ][] = $this->title;
@@ -24,7 +24,7 @@ use yii\web\JsExpression; @@ -24,7 +24,7 @@ use yii\web\JsExpression;
24 $form = ActiveForm::begin(); 24 $form = ActiveForm::begin();
25 ?> 25 ?>
26 <div class="input-blocks-wrapper full-blocks data-block"> 26 <div class="input-blocks-wrapper full-blocks data-block">
27 - <?= !empty($portfolio->date_add) ? "Дата создания: $portfolio->date_add" :""?> 27 + <?= !empty( $portfolio->date_add ) ? "Дата создания: $portfolio->date_add" : "" ?>
28 28
29 </div> 29 </div>
30 <div class="style"> 30 <div class="style">
@@ -32,14 +32,14 @@ use yii\web\JsExpression; @@ -32,14 +32,14 @@ use yii\web\JsExpression;
32 <div class="input-blocks-wrapper"> 32 <div class="input-blocks-wrapper">
33 <div class="input-blocks"> 33 <div class="input-blocks">
34 <?= $form->field($portfolio, 'name') 34 <?= $form->field($portfolio, 'name')
35 - ->textInput (['class'=> 'custom-input-2 fix-input-2']); ?> 35 + ->textInput([ 'class' => 'custom-input-2 fix-input-2' ]); ?>
36 </div> 36 </div>
37 </div> 37 </div>
38 38
39 <div class="input-blocks-wrapper"> 39 <div class="input-blocks-wrapper">
40 <div class="input-blocks"> 40 <div class="input-blocks">
41 <?= $form->field($portfolio, 'link') 41 <?= $form->field($portfolio, 'link')
42 - ->textInput (['class'=> 'custom-input-2 fix-input-2']); ?> 42 + ->textInput([ 'class' => 'custom-input-2 fix-input-2' ]); ?>
43 </div> 43 </div>
44 </div> 44 </div>
45 45
@@ -62,13 +62,13 @@ use yii\web\JsExpression; @@ -62,13 +62,13 @@ use yii\web\JsExpression;
62 <?= $form->field($portfolio, "specializationInput[{$child_second->specialization_id}]", [ 62 <?= $form->field($portfolio, "specializationInput[{$child_second->specialization_id}]", [
63 'template' => '{input}{label}{hint}{error}', 63 'template' => '{input}{label}{hint}{error}',
64 ]) 64 ])
65 - ->label('<span></span>' . $child_second->specialization_name)  
66 - ->checkbox([  
67 - 'value' => $child_second->specialization_id,  
68 - 'label' => NULL,  
69 - 'uncheck' => NULL,  
70 - 'class' => 'custom-check',  
71 - ], false) ?> 65 + ->label('<span></span>' . $child_second->specialization_name)
  66 + ->checkbox([
  67 + 'value' => $child_second->specialization_id,
  68 + 'label' => NULL,
  69 + 'uncheck' => NULL,
  70 + 'class' => 'custom-check',
  71 + ], false) ?>
72 </a> 72 </a>
73 </li> 73 </li>
74 <?php endif; ?> 74 <?php endif; ?>
@@ -85,65 +85,60 @@ use yii\web\JsExpression; @@ -85,65 +85,60 @@ use yii\web\JsExpression;
85 </div> 85 </div>
86 86
87 87
88 -  
89 <div class="input-blocks-wrapper admin-avatar portfolio-foto-admin hidden-foto foto-portfolio-adm"> 88 <div class="input-blocks-wrapper admin-avatar portfolio-foto-admin hidden-foto foto-portfolio-adm">
90 <div class="gen-admin-title">Фото главное</div> 89 <div class="gen-admin-title">Фото главное</div>
91 <div class="not-file-txt-adm">Файл не выбран</div> 90 <div class="not-file-txt-adm">Файл не выбран</div>
92 <?= ImageUploader::widget([ 91 <?= ImageUploader::widget([
93 - 'model'=> $portfolio,  
94 - 'field'=>'cover',  
95 - 'width'=>210,  
96 - 'height'=>150,  
97 - 'multi'=>false,  
98 - 'gallery' =>$portfolio->cover,  
99 - 'name' => 'Загрузить'  
100 - ]);  
101 - ?> 92 + 'model' => $portfolio,
  93 + 'field' => 'cover',
  94 + 'width' => 210,
  95 + 'height' => 150,
  96 + 'multi' => false,
  97 + 'gallery' => $portfolio->cover,
  98 + 'name' => 'Загрузить',
  99 + ]); ?>
102 <div class="not-file-mb-adm">До 3 Мб файл</div> 100 <div class="not-file-mb-adm">До 3 Мб файл</div>
103 </div> 101 </div>
104 102
105 <div class="input-blocks-wrapper"> 103 <div class="input-blocks-wrapper">
106 <div class="input-blocks"> 104 <div class="input-blocks">
107 - <?=  
108 - $form->field($portfolio, 'city')->widget(Select2::classname(), [  
109 - 'options' => ['class' => 'Выбор города ...'],  
110 - 'pluginOptions' => [  
111 - 'allowClear' => true,  
112 - 'minimumInputLength' => 3,  
113 - 'ajax' => [  
114 - 'url' => \yii\helpers\Url::to(['site/city']),  
115 - 'dataType' => 'json',  
116 - 'data' => new JsExpression('function(params) { return {q:params.term}; }')  
117 - ],  
118 - 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),  
119 - 'templateResult' => new JsExpression('function(city) { return city.text; }'),  
120 - 'templateSelection' => new JsExpression('function (city) { return city.text; }'),  
121 - ],  
122 - ]);  
123 - ?> 105 + <?= $form->field($portfolio, 'city')
  106 + ->widget(Select2::classname(), [
  107 + 'options' => [ 'class' => 'Выбор города ...' ],
  108 + 'pluginOptions' => [
  109 + 'allowClear' => true,
  110 + 'minimumInputLength' => 3,
  111 + 'ajax' => [
  112 + 'url' => \yii\helpers\Url::to([ 'site/city' ]),
  113 + 'dataType' => 'json',
  114 + 'data' => new JsExpression('function(params) { return {q:params.term}; }'),
  115 + ],
  116 + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
  117 + 'templateResult' => new JsExpression('function(city) { return city.text; }'),
  118 + 'templateSelection' => new JsExpression('function (city) { return city.text; }'),
  119 + ],
  120 + ]); ?>
124 121
125 </div> 122 </div>
126 123
127 <div class="input-blocks street-input"> 124 <div class="input-blocks street-input">
128 - <?= $form->field ($portfolio, 'street', ['options' => ['class' => 'form-group company_info']])  
129 - ->label ('Улица')  
130 - ->textInput (['class'=> 'custom-input-2']);  
131 - ?> 125 + <?= $form->field($portfolio, 'street', [ 'options' => [ 'class' => 'form-group company_info' ] ])
  126 + ->label('Улица')
  127 + ->textInput([ 'class' => 'custom-input-2' ]); ?>
132 </div> 128 </div>
133 129
134 <div class="input-blocks home-input"> 130 <div class="input-blocks home-input">
135 - <?= $form->field ($portfolio, 'house', ['options' => ['class' => 'form-group company_info']])  
136 - ->label ('Дом')  
137 - ->textInput (['class'=> 'custom-input-2']);  
138 - ?> 131 + <?= $form->field($portfolio, 'house', [ 'options' => [ 'class' => 'form-group company_info' ] ])
  132 + ->label('Дом')
  133 + ->textInput([ 'class' => 'custom-input-2' ]); ?>
139 </div> 134 </div>
140 </div> 135 </div>
141 136
142 137
143 -  
144 <div class="input-blocks-wrapper full-blocks admin-editor-bl"> 138 <div class="input-blocks-wrapper full-blocks admin-editor-bl">
145 <div class="input-blocks"> 139 <div class="input-blocks">
146 - <?= $form->field($portfolio, 'description')->widget(CKEditor::className()) ?> 140 + <?= $form->field($portfolio, 'description')
  141 + ->widget(CKEditor::className()) ?>
147 </div> 142 </div>
148 </div> 143 </div>
149 144
@@ -151,21 +146,21 @@ use yii\web\JsExpression; @@ -151,21 +146,21 @@ use yii\web\JsExpression;
151 146
152 <div class="input-blocks-wrapper"> 147 <div class="input-blocks-wrapper">
153 <div class="admin-save-btn skills-save-btn admin-add-remove-wr style"> 148 <div class="admin-save-btn skills-save-btn admin-add-remove-wr style">
154 - <?= Html::submitButton($portfolio->isNewRecord?'Добавить':'Обновить', [ 'class' => 'input-blocks-wrapper button' ]) ?> 149 + <?= Html::submitButton($portfolio->isNewRecord ? 'Добавить' : 'Обновить', [ 'class' => 'input-blocks-wrapper button' ]) ?>
155 <div class="admin-remove-note"> 150 <div class="admin-remove-note">
156 <?php 151 <?php
157 - if(!$portfolio->isNewRecord) {  
158 - echo Html::a('Удалить', [  
159 - 'accounts/portfolio-delete',  
160 - 'id' => $portfolio->portfolio_id,  
161 - ], [  
162 - 'title' => 'Удалить',  
163 - 'aria-label' => 'Удалить',  
164 - 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?',  
165 - 'data-method' => 'post',  
166 - 'data-pjax' => 0,  
167 - ]);  
168 - } 152 + if(!$portfolio->isNewRecord) {
  153 + echo Html::a('Удалить', [
  154 + 'accounts/portfolio-delete',
  155 + 'id' => $portfolio->portfolio_id,
  156 + ], [
  157 + 'title' => 'Удалить',
  158 + 'aria-label' => 'Удалить',
  159 + 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?',
  160 + 'data-method' => 'post',
  161 + 'data-pjax' => 0,
  162 + ]);
  163 + }
169 ?> 164 ?>
170 </div> 165 </div>
171 166
@@ -178,7 +173,10 @@ use yii\web\JsExpression; @@ -178,7 +173,10 @@ use yii\web\JsExpression;
178 $form->end(); 173 $form->end();
179 ?> 174 ?>
180 <script> 175 <script>
181 - $(document).ready(function(){ 176 + $(document).ready(
  177 + function()
  178 + {
182 179
183 - }) 180 + }
  181 + )
184 </script> 182 </script>
frontend/views/accounts/team.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 /** 2 /**
3 * @var TeamSearch $searchModel 3 * @var TeamSearch $searchModel
4 * @var ActiveDataProvider $dataProvider 4 * @var ActiveDataProvider $dataProvider
  5 + * @var string[] $departments
5 */ 6 */
6 use common\models\TeamSearch; 7 use common\models\TeamSearch;
7 use yii\data\ActiveDataProvider; 8 use yii\data\ActiveDataProvider;
@@ -19,7 +20,7 @@ @@ -19,7 +20,7 @@
19 20
20 21
21 <?= GridView::widget([ 22 <?= GridView::widget([
22 - 'options' => ['class'=>'style admin-all-pages-wr'], 23 + 'options' => [ 'class' => 'style admin-all-pages-wr' ],
23 'dataProvider' => $dataProvider, 24 'dataProvider' => $dataProvider,
24 'filterModel' => $searchModel, 25 'filterModel' => $searchModel,
25 'columns' => [ 26 'columns' => [
@@ -44,7 +45,9 @@ @@ -44,7 +45,9 @@
44 'attribute' => 'department', 45 'attribute' => 'department',
45 'value' => 'department.name', 46 'value' => 'department.name',
46 'label' => 'Отдел компании', 47 'label' => 'Отдел компании',
  48 + 'filter' => $departments,
47 ], 49 ],
  50 + 'position',
48 [ 51 [
49 'attribute' => 'experience_from', 52 'attribute' => 'experience_from',
50 'value' => function($model, $key, $index, $column) { 53 'value' => function($model, $key, $index, $column) {
@@ -53,40 +56,43 @@ @@ -53,40 +56,43 @@
53 'label' => 'Опыт, лет', 56 'label' => 'Опыт, лет',
54 'filter' => "<div class=\"input-group input-group-xs input-daterange\"> 57 'filter' => "<div class=\"input-group input-group-xs input-daterange\">
55 <span class='field-teamsearch-experience_from_from'> 58 <span class='field-teamsearch-experience_from_from'>
56 -<input type='number' id='teamsearch-experience_from_from' class='form-control' name='TeamSearch[experience_from_from]' value='" . \Yii::$app->request->get('TeamSearch')['experience_from_from'] . "' min='0' max='" . \Yii::$app->request->get('TeamSearch')['experience_from_to'] . "'> 59 +<input type='number' id='teamsearch-experience_from_from' class='form-control' name='TeamSearch[experience_from_from]' value='" . \Yii::$app->request->get('TeamSearch')[ 'experience_from_from' ] . "' min='0' max='" . \Yii::$app->request->get('TeamSearch')[ 'experience_from_to' ] . "'>
57 </span> 60 </span>
58 <span class=\"input-group-addon kv-field-separator\"> 61 <span class=\"input-group-addon kv-field-separator\">
59 <i class=\"glyphicon glyphicon-resize-horizontal\"></i> 62 <i class=\"glyphicon glyphicon-resize-horizontal\"></i>
60 </span> 63 </span>
61 <span class='field-teamsearch-experience_from_to'> 64 <span class='field-teamsearch-experience_from_to'>
62 -<input type='number' id='teamsearch-experience_from_to' class='form-control' name='TeamSearch[experience_from_to]' value='" . \Yii::$app->request->get('TeamSearch')['experience_from_to'] . "' min='" . \Yii::$app->request->get('TeamSearch')['experience_from_from'] . "' max='100'> 65 +<input type='number' id='teamsearch-experience_from_to' class='form-control' name='TeamSearch[experience_from_to]' value='" . \Yii::$app->request->get('TeamSearch')[ 'experience_from_to' ] . "' min='" . \Yii::$app->request->get('TeamSearch')[ 'experience_from_from' ] . "' max='100'>
63 </span> 66 </span>
64 </div>", 67 </div>",
65 ], 68 ],
66 - 'position',  
67 'country_id', 69 'country_id',
68 70
69 [ 71 [
70 - 'class' => 'yii\grid\ActionColumn',  
71 - 'buttons' => [ 72 + 'class' => 'yii\grid\ActionColumn',
  73 + 'buttons' => [
72 'update' => function($url, $model, $key) { 74 'update' => function($url, $model, $key) {
73 return Html::a('<img src="/images/ico_pencil.png" alt="">', [ 75 return Html::a('<img src="/images/ico_pencil.png" alt="">', [
74 - 'team-update', 'id' => $model->team_id  
75 - ],[  
76 - 'title' => 'Редактировать', 76 + 'team-update',
  77 + 'id' => $model->team_id,
  78 + ], [
  79 + 'title' => 'Редактировать',
77 ]); 80 ]);
78 }, 81 },
79 'delete' => function($url, $model, $key) { 82 'delete' => function($url, $model, $key) {
80 - return Html::a('<img src="/images/delete-ico.png" alt="">', ['team-delete', 'id' => $model->team_id], [  
81 - 'title' => 'Удалить',  
82 - 'aria-label' => 'Удалить', 83 + return Html::a('<img src="/images/delete-ico.png" alt="">', [
  84 + 'team-delete',
  85 + 'id' => $model->team_id,
  86 + ], [
  87 + 'title' => 'Удалить',
  88 + 'aria-label' => 'Удалить',
83 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', 89 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?',
84 - 'data-method' => 'post',  
85 - 'data-pjax' => '0', 90 + 'data-method' => 'post',
  91 + 'data-pjax' => '0',
86 ]); 92 ]);
87 }, 93 },
88 ], 94 ],
89 - 'template' => '{update} {delete}' 95 + 'template' => '{update} {delete}',
90 ], 96 ],
91 ], 97 ],
92 ]); ?> 98 ]); ?>
frontend/web/js/fieldWidget.js
1 $(function(){ 1 $(function(){
  2 +
2 $(document).on('click', '.delete-field-item', function(){ 3 $(document).on('click', '.delete-field-item', function(){
3 var container = $(this).parents('.field_list').first(); 4 var container = $(this).parents('.field_list').first();
4 $(this).parent('.form-group').remove(); 5 $(this).parent('.form-group').remove();