Commit a0821e650099390adc0d758f4b4e2482a64b3f66
1 parent
a41edafc
test
Showing
1 changed file
with
133 additions
and
87 deletions
Show diff stats
frontend/views/accounts/_vacancy_form.php
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @var Vacancy $vacancy | |
4 | - * @var Employment[] $employment | |
5 | - * @var string[] $currencies | |
3 | + * @var Vacancy $vacancy | |
4 | + * @var Employment[] $employment | |
5 | + * @var string[] $currencies | |
6 | 6 | * @var Specialization[] $specializations |
7 | - * @var User $user | |
7 | + * @var User $user | |
8 | 8 | */ |
9 | 9 | use common\components\Request; |
10 | 10 | use common\models\Employment; |
... | ... | @@ -30,47 +30,70 @@ |
30 | 30 | <div class="input-blocks-wrapper"> |
31 | 31 | <div class="input-blocks"> |
32 | 32 | <?= $form->field($vacancy, 'name') |
33 | - ->textInput (['class'=> 'custom-input-2']); ?> | |
33 | + ->textInput([ 'class' => 'custom-input-2' ]); ?> | |
34 | 34 | </div> |
35 | 35 | </div> |
36 | 36 | |
37 | 37 | |
38 | - | |
39 | 38 | <div class="input-blocks-wrapper"> |
40 | 39 | <div class="input-blocks"> |
41 | 40 | <?= $form->field($vacancy, 'user_name') |
42 | - ->textInput (['class'=> 'custom-input-2']); ?> | |
43 | - <span class="admin-hint-vacancy-contact form_auto_data" data-value="<?=$user->firstname.' '.$user->lastname?>">Вы</span> | |
41 | + ->textInput([ 'class' => 'custom-input-2' ]); ?> | |
42 | + <?php | |
43 | + if(!empty( $user->firstname ) && !empty( $user->lastname )) { | |
44 | + echo Html::tag('span', 'Вы', [ | |
45 | + 'class' => 'admin-hint-vacancy-contact form_auto_data', | |
46 | + 'data-value' => $user->firstname . ' ' . $user->lastname, | |
47 | + 'title' => 'Вставить данные с Вашего личного кабинета', | |
48 | + ]); | |
49 | + } | |
50 | + ?> | |
44 | 51 | </div> |
45 | 52 | </div> |
46 | - | |
47 | 53 | <div class="input-blocks-wrapper"> |
48 | 54 | <div class="input-blocks"> |
49 | 55 | <?= $form->field($vacancy, 'phone') |
50 | - ->textInput (['class'=> 'custom-input-2']); ?> | |
56 | + ->textInput([ 'class' => 'custom-input-2' ]); ?> | |
57 | + <?php | |
58 | + if(!empty($user->getPhones()[1]['phone'])) { | |
59 | + echo Html::tag('span', 'Вы', [ | |
60 | + 'class' => 'admin-hint-vacancy-contact form_auto_data', | |
61 | + 'data-value' => $user->getPhones()[1]['phone'], | |
62 | + 'title' => 'Вставить данные с Вашего личного кабинета', | |
63 | + ]); | |
64 | + } | |
65 | + ?> | |
51 | 66 | </div> |
52 | 67 | </div> |
53 | 68 | |
54 | 69 | <div class="input-blocks-wrapper"> |
55 | 70 | <div class="input-blocks"> |
56 | - <?= | |
57 | - $form->field($vacancy, 'city')->widget(Select2::classname(), [ | |
58 | - 'options' => ['placeholder' => 'Выбор города ...'], | |
59 | - 'pluginOptions' => [ | |
60 | - 'allowClear' => true, | |
61 | - 'minimumInputLength' => 3, | |
62 | - 'ajax' => [ | |
63 | - 'url' => \yii\helpers\Url::to(['site/city']), | |
64 | - 'dataType' => 'json', | |
65 | - 'data' => new JsExpression('function(params) { return {q:params.term}; }') | |
66 | - ], | |
67 | - 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), | |
68 | - 'templateResult' => new JsExpression('function(city) { return city.text; }'), | |
69 | - 'templateSelection' => new JsExpression('function (city) { return city.text; }'), | |
70 | - ], | |
71 | - ]); | |
71 | + <?= $form->field($vacancy, 'city') | |
72 | + ->hint('Город, в котором предлагается работа', ['tag' => 'span']) | |
73 | + ->widget(Select2::classname(), [ | |
74 | + 'options' => [ 'placeholder' => 'Выбор города ...' ], | |
75 | + 'pluginOptions' => [ | |
76 | + 'allowClear' => true, | |
77 | + 'minimumInputLength' => 3, | |
78 | + 'ajax' => [ | |
79 | + 'url' => \yii\helpers\Url::to([ 'site/city' ]), | |
80 | + 'dataType' => 'json', | |
81 | + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), | |
82 | + ], | |
83 | + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), | |
84 | + 'templateResult' => new JsExpression('function(city) { return city.text; }'), | |
85 | + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), | |
86 | + ], | |
87 | + ]); ?> | |
88 | + <?php | |
89 | + if(!empty( $user->userInfo->city )) { | |
90 | + echo Html::tag('span', 'Ваш', [ | |
91 | + 'class' => 'admin-hint-vacancy-contact form_auto_data', | |
92 | + 'data-value' => $user->userInfo->city, | |
93 | + 'title' => 'Вставить данные с Вашего личного кабинета', | |
94 | + ]); | |
95 | + } | |
72 | 96 | ?> |
73 | - <span class="admin-hint-vacancy-contact form_auto_data" data-value="<?=$user->userInfo->city?>">Ваш</span> | |
74 | 97 | </div> |
75 | 98 | </div> |
76 | 99 | |
... | ... | @@ -80,18 +103,19 @@ |
80 | 103 | 'template' => "{label}<br /><span class='admn-input-txt'>от</span>{input}\n{hint}\n{error}", |
81 | 104 | 'options' => [ 'class' => 'form-inline' ], |
82 | 105 | ]) |
83 | - ->label('Заработная плата') | |
84 | - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number', 'min' => 0]); | |
85 | - ?> | |
106 | + ->label('Заработная плата') | |
107 | + ->textInput([ | |
108 | + 'class' => 'custom-input-2 custom-input-2-date', | |
109 | + 'type' => 'number', | |
110 | + 'min' => 0, | |
111 | + ]); ?> | |
86 | 112 | </div> |
87 | 113 | <div class="input-blocks admin-currency-second"> |
88 | - <?= | |
89 | - $form->field($vacancy, 'salary_currency', [ | |
114 | + <?= $form->field($vacancy, 'salary_currency', [ | |
90 | 115 | 'template' => "{input}\n{hint}\n{error}", |
91 | 116 | ]) |
92 | - ->label(false) | |
93 | - ->dropDownList($currencies) | |
94 | - ?> | |
117 | + ->label(false) | |
118 | + ->dropDownList($currencies) ?> | |
95 | 119 | </div> |
96 | 120 | </div> |
97 | 121 | |
... | ... | @@ -119,15 +143,15 @@ |
119 | 143 | <li> |
120 | 144 | <a href="#" title="<?= $child_second->specialization_name ?>"> |
121 | 145 | <?= $form->field($vacancy, "specializationInput[{$child_second->specialization_id}]", [ |
122 | - 'template' => '{input}{label}{hint}{error}', | |
146 | + 'template' => '{input}{label}{hint}{error}', | |
123 | 147 | ]) |
124 | - ->label('<span></span>' . $child_second->specialization_name) | |
125 | - ->checkbox([ | |
126 | - 'value' => $child_second->specialization_id, | |
127 | - 'label' => NULL, | |
128 | - 'uncheck' => NULL, | |
129 | - 'class' => 'custom-check', | |
130 | - ], false) ?> | |
148 | + ->label('<span></span>' . $child_second->specialization_name) | |
149 | + ->checkbox([ | |
150 | + 'value' => $child_second->specialization_id, | |
151 | + 'label' => NULL, | |
152 | + 'uncheck' => NULL, | |
153 | + 'class' => 'custom-check', | |
154 | + ], false) ?> | |
131 | 155 | </a> |
132 | 156 | </li> |
133 | 157 | <?php endif; ?> |
... | ... | @@ -148,65 +172,67 @@ |
148 | 172 | </div> |
149 | 173 | </div> |
150 | 174 | |
151 | -<div class="admin-specialization-selected style"><ul></ul></div> | |
175 | +<div class="admin-specialization-selected style"> | |
176 | + <ul></ul> | |
177 | +</div> | |
152 | 178 | |
153 | 179 | <div class="input-blocks-wrapper admin-vacancy-check admin-vacancy-check-fx-marg" style="margin-top: 19px"> |
154 | 180 | <div class="input-blocks"> |
155 | 181 | <?= $form->field($vacancy, 'employmentInput') |
156 | - ->checkboxList($employment, | |
157 | - [ | |
158 | - 'item' => function($index, $label, $name, $checked, $value) { | |
159 | - $return = '<div class="admin-who-check-payment">'; | |
160 | - $return .= '<input class="custom-check" id="select_admin_payment'.$value.'" type="checkbox" name="' . $name . '" value="' . $value . '" '.($checked ? "checked" :"").' >'; | |
161 | - $return .= '<label for="select_admin_payment'.$value.'" >'; | |
162 | - $return .= '<span></span>' . ucwords($label); | |
163 | - $return .= '</label>'; | |
164 | - $return .= '</div>'; | |
165 | - return $return; | |
166 | - } | |
167 | - ] | |
168 | - ) ?> | |
182 | + ->checkboxList($employment, [ | |
183 | + 'item' => function($index, $label, $name, $checked, $value) { | |
184 | + $return = '<div class="admin-who-check-payment">'; | |
185 | + $return .= '<input class="custom-check" id="select_admin_payment' . $value . '" type="checkbox" name="' . $name . '" value="' . $value . '" ' . ( $checked ? "checked" : "" ) . ' >'; | |
186 | + $return .= '<label for="select_admin_payment' . $value . '" >'; | |
187 | + $return .= '<span></span>' . ucwords($label); | |
188 | + $return .= '</label>'; | |
189 | + $return .= '</div>'; | |
190 | + return $return; | |
191 | + }, | |
192 | + ]) ?> | |
169 | 193 | </div> |
170 | 194 | </div> |
171 | 195 | |
172 | 196 | <div class="skills-admin-wrapper style"> |
173 | 197 | <div class="input-blocks-wrapper skills-programs"> |
174 | 198 | <div class="input-blocks"> |
175 | - <?= FieldEditor::widget ( | |
176 | - [ | |
177 | - 'template' => 'requirements', 'item_id' => $vacancy->vacancy_id, 'model' => 'common\models\Vacancy', 'language' => 'ru', | |
178 | - ] | |
179 | - ); ?> | |
199 | + <?= FieldEditor::widget([ | |
200 | + 'template' => 'requirements', | |
201 | + 'item_id' => $vacancy->vacancy_id, | |
202 | + 'model' => 'common\models\Vacancy', | |
203 | + 'language' => 'ru', | |
204 | + ]); ?> | |
180 | 205 | </div> |
181 | 206 | </div> |
182 | 207 | </div> |
183 | 208 | |
184 | 209 | <div class="input-blocks-wrapper full-blocks admin-editor-bl"> |
185 | 210 | <div class="input-blocks"> |
186 | - <?= $form->field($vacancy, 'description')->widget(CKEditor::className()) ?> | |
211 | + <?= $form->field($vacancy, 'description') | |
212 | + ->widget(CKEditor::className()) ?> | |
187 | 213 | </div> |
188 | 214 | </div> |
189 | 215 | |
190 | 216 | <div class="admin-save-btn skills-save-btn admin-add-remove-wr style"> |
191 | - <?= Html::submitButton($vacancy->isNewRecord?'Добавить':'Обновить', [ 'class' => 'input-blocks-wrapper button' ]) ?> | |
217 | + <?= Html::submitButton($vacancy->isNewRecord ? 'Добавить' : 'Обновить', [ 'class' => 'input-blocks-wrapper button' ]) ?> | |
192 | 218 | <div class="admin-remove-note"> |
193 | 219 | <?php |
194 | - if(!$vacancy->isNewRecord) { | |
195 | - echo Html::a('Удалить', [ | |
196 | - 'accounts/vacancy-delete', | |
197 | - 'id' => $vacancy->vacancy_id, | |
198 | - ], [ | |
199 | - 'title' => 'Удалить', | |
200 | - 'aria-label' => 'Удалить', | |
201 | - 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', | |
202 | - 'data-method' => 'post', | |
203 | - 'data-pjax' => 0, | |
204 | - ]); | |
205 | - } | |
220 | + if(!$vacancy->isNewRecord) { | |
221 | + echo Html::a('Удалить', [ | |
222 | + 'accounts/vacancy-delete', | |
223 | + 'id' => $vacancy->vacancy_id, | |
224 | + ], [ | |
225 | + 'title' => 'Удалить', | |
226 | + 'aria-label' => 'Удалить', | |
227 | + 'data-confirm' => 'Вы уверены, что хотите удалить этот элемент?', | |
228 | + 'data-method' => 'post', | |
229 | + 'data-pjax' => 0, | |
230 | + ]); | |
231 | + } | |
206 | 232 | ?> |
207 | 233 | </div> |
208 | 234 | <div class="admin-back-note"> |
209 | - <?= Html::a('вернуться', Request::getIsLocal(\Yii::$app->request->referrer)?\Yii::$app->request->referrer:['accounts/vacancy' ]) ?> | |
235 | + <?= Html::a('вернуться', Request::getIsLocal(\Yii::$app->request->referrer) ? \Yii::$app->request->referrer : [ 'accounts/vacancy' ]) ?> | |
210 | 236 | </div> |
211 | 237 | </div> |
212 | 238 | |
... | ... | @@ -215,14 +241,34 @@ |
215 | 241 | $form->end(); |
216 | 242 | ?> |
217 | 243 | <script> |
218 | - $(function() { | |
219 | - $('.input-blocks.admin-currency-second select').change(function(){ | |
220 | - $(this).blur() | |
221 | - }); | |
222 | - $(document).on('click', '.form_auto_data', function() { | |
223 | - var value = $(this).data('value'); | |
224 | - var container = $(this).parents('.input-blocks').first(); | |
225 | - $('#vacancy-city').select2().val(value).trigger('change'); | |
226 | - }); | |
227 | - }); | |
244 | + $( | |
245 | + function() | |
246 | + { | |
247 | + $('.input-blocks.admin-currency-second select').change( | |
248 | + function() | |
249 | + { | |
250 | + $(this).blur() | |
251 | + } | |
252 | + ); | |
253 | + $(document).on( | |
254 | + 'click', '.form_auto_data', function() | |
255 | + { | |
256 | + var value = $(this).data('value'); | |
257 | + var container = $(this).parents('.input-blocks').first(); | |
258 | + var select = $(container).find('select[data-krajee-select2]').first(); | |
259 | + if(select.length >= 1) | |
260 | + { | |
261 | + $(select) | |
262 | + .append('<option value="' + value + '" selected>' + value + '</option>'); | |
263 | + var id = $(select).attr('id'); | |
264 | + $(container).find('#select2-' + id + '-container').attr('title', value); | |
265 | + $(container).find('#select2-' + id + '-container').text(value); | |
266 | + } else | |
267 | + { | |
268 | + $(container).find('input, textarea').val(value); | |
269 | + } | |
270 | + } | |
271 | + ); | |
272 | + } | |
273 | + ); | |
228 | 274 | </script> |
229 | 275 | \ No newline at end of file | ... | ... |