Commit 3e8424164d2f6d18c559fe561c0392be8c496d00
1 parent
c758c9b9
test
Showing
3 changed files
with
44 additions
and
45 deletions
Show diff stats
common/models/UserInfo.php
| @@ -61,11 +61,12 @@ class UserInfo extends \yii\db\ActiveRecord | @@ -61,11 +61,12 @@ class UserInfo extends \yii\db\ActiveRecord | ||
| 61 | public function rules() | 61 | public function rules() |
| 62 | { | 62 | { |
| 63 | return [ | 63 | return [ |
| 64 | - [['user_id', 'view_count', 'contract', 'estimate', 'purchase', 'delivery','is_customer','is_freelancer'], 'integer'], | 64 | + [['contract', 'estimate', 'purchase', 'delivery','is_customer','is_freelancer'], 'integer'], |
| 65 | [['date_visit'], 'safe'], | 65 | [['date_visit'], 'safe'], |
| 66 | - [['experience', 'soft', 'guarantee', 'about', 'city', 'country', 'image', 'poster', 'social_vk', 'social_fb', 'social_in', 'social_t'], 'string'], | 66 | + [['soft', 'guarantee', 'about', 'city', 'country', 'image', 'poster', 'social_vk', 'social_fb', 'social_in', 'social_t'], 'string'], |
| 67 | [['prepayment'], 'number'], | 67 | [['prepayment'], 'number'], |
| 68 | - | 68 | + [['experience'], 'integer', 'max' => date('Y'), 'min' => 1950], |
| 69 | + [['experience'], 'default', 'value' => date('Y')], | ||
| 69 | [['rank', 'location'], 'string', 'max' => 50], | 70 | [['rank', 'location'], 'string', 'max' => 50], |
| 70 | [['salary', 'job'], 'string', 'max' => 255], | 71 | [['salary', 'job'], 'string', 'max' => 255], |
| 71 | [['busy', 'member'], 'boolean'], | 72 | [['busy', 'member'], 'boolean'], |
frontend/controllers/AccountsController.php
| @@ -189,8 +189,16 @@ | @@ -189,8 +189,16 @@ | ||
| 189 | 189 | ||
| 190 | public function actionEmployment() | 190 | public function actionEmployment() |
| 191 | { | 191 | { |
| 192 | + $user_info = UserInfo::find() | ||
| 193 | + ->where([ 'user_id' => \Yii::$app->user->getId() ]) | ||
| 194 | + ->one(); | ||
| 195 | + if(empty( $user_info )) { | ||
| 196 | + $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); | ||
| 197 | + } | ||
| 192 | $post = \Yii::$app->request->post(); | 198 | $post = \Yii::$app->request->post(); |
| 193 | if(!empty( $post )) { | 199 | if(!empty( $post )) { |
| 200 | + $user_info->load($post); | ||
| 201 | + $user_info->save(); | ||
| 194 | $job = [ ]; | 202 | $job = [ ]; |
| 195 | for($i = 0; $i < count($post[ 'Job' ]); $i++) { | 203 | for($i = 0; $i < count($post[ 'Job' ]); $i++) { |
| 196 | $job[ $i ] = new Job([ | 204 | $job[ $i ] = new Job([ |
| @@ -225,7 +233,9 @@ | @@ -225,7 +233,9 @@ | ||
| 225 | ])); | 233 | ])); |
| 226 | } | 234 | } |
| 227 | } | 235 | } |
| 228 | - return $this->render('employment', [ 'job' => $job ]); | 236 | + return $this->render('employment', [ 'job' => $job, |
| 237 | + 'user_info' => $user_info, | ||
| 238 | + ]); | ||
| 229 | } | 239 | } |
| 230 | 240 | ||
| 231 | public function actionGallery() | 241 | public function actionGallery() |
frontend/views/accounts/employment.php
| 1 | <?php | 1 | <?php |
| 2 | -/** | ||
| 3 | - * @var Job[] $job | ||
| 4 | - */ | ||
| 5 | -use common\models\Job; | ||
| 6 | -use yii\helpers\Html; | ||
| 7 | -use yii\jui\DatePicker; | ||
| 8 | -use yii\widgets\ActiveForm; | ||
| 9 | -//HUUIISAODASIDSIA | ||
| 10 | -$this->title = 'Трудовой стаж'; | ||
| 11 | -$this->params['breadcrumbs'][] = $this->title; | 2 | + /** |
| 3 | + * @var Job[] $job | ||
| 4 | + * @var UserInfo $user_info | ||
| 5 | + */ | ||
| 6 | + use common\models\Job; | ||
| 7 | + use common\models\UserInfo; | ||
| 8 | + use yii\helpers\Html; | ||
| 9 | + use yii\jui\DatePicker; | ||
| 10 | + use yii\widgets\ActiveForm; | ||
| 11 | + | ||
| 12 | + $this->title = 'Трудовой стаж'; | ||
| 13 | + $this->params[ 'breadcrumbs' ][] = $this->title; | ||
| 12 | ?> | 14 | ?> |
| 13 | <div class="login-left-column-title"><?= $this->title ?></div> | 15 | <div class="login-left-column-title"><?= $this->title ?></div> |
| 14 | <?php | 16 | <?php |
| 15 | -$form = ActiveForm::begin (); | ||
| 16 | -$current = array_shift ($job); | 17 | + $form = ActiveForm::begin(); |
| 18 | + $current = array_shift($job); | ||
| 17 | ?> | 19 | ?> |
| 18 | <div class="current_job_container style"> | 20 | <div class="current_job_container style"> |
| 19 | <div class="login-left-column-title-two style">Текущее место работы:</div> | 21 | <div class="login-left-column-title-two style">Текущее место работы:</div> |
| 20 | <div class="current_job_inputs first_current_job_inputs border-general style"> | 22 | <div class="current_job_inputs first_current_job_inputs border-general style"> |
| 21 | <div class="input-blocks-wrapper"> | 23 | <div class="input-blocks-wrapper"> |
| 22 | <div class="input-blocks"> | 24 | <div class="input-blocks"> |
| 23 | - <?= $form->field ($current, '[0]name') | ||
| 24 | - ->label ('Название') | ||
| 25 | - ->textInput (['class'=> 'custom-input-2']); | ||
| 26 | - ?> | 25 | + <?= $form->field($current, '[0]name') |
| 26 | + ->label('Название') | ||
| 27 | + ->textInput([ 'class' => 'custom-input-2' ]); ?> | ||
| 27 | </div> | 28 | </div> |
| 28 | </div> | 29 | </div> |
| 29 | 30 | ||
| 30 | <div class="input-blocks-wrapper"> | 31 | <div class="input-blocks-wrapper"> |
| 31 | <div class="input-blocks"> | 32 | <div class="input-blocks"> |
| 32 | - <?= $form->field ($current, '[0]link') | ||
| 33 | - ->label ('Ссылка на компанию на сайте МФП') | ||
| 34 | - ->textInput (['class'=> 'custom-input-2']); | ||
| 35 | - ?> | 33 | + <?= $form->field($current, '[0]link') |
| 34 | + ->label('Ссылка на компанию на сайте МФП') | ||
| 35 | + ->textInput([ 'class' => 'custom-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 ($current, '[0]position') | ||
| 42 | - ->label ('Должность') | ||
| 43 | - ->textInput (['class'=> 'custom-input-2']); | ||
| 44 | - ?> | 41 | + <?= $form->field($current, '[0]position') |
| 42 | + ->label('Должность') | ||
| 43 | + ->textInput([ 'class' => 'custom-input-2' ]); ?> | ||
| 45 | </div> | 44 | </div> |
| 46 | </div> | 45 | </div> |
| 47 | 46 | ||
| @@ -76,10 +75,9 @@ $current = array_shift ($job); | @@ -76,10 +75,9 @@ $current = array_shift ($job); | ||
| 76 | <div class="current_job_inputs border-general style"> | 75 | <div class="current_job_inputs border-general style"> |
| 77 | <div class="input-blocks-wrapper"> | 76 | <div class="input-blocks-wrapper"> |
| 78 | <div class="input-blocks"> | 77 | <div class="input-blocks"> |
| 79 | - <?= $form->field ($current, '[0]date_start') | ||
| 80 | - ->label ('Когда начали заниматься проектированием') | ||
| 81 | - ->textInput (['class'=> 'custom-input-2']); | ||
| 82 | - ?> | 78 | + <?= $form->field($user_info, 'experience') |
| 79 | + ->label('Когда начали заниматься проектированием') | ||
| 80 | + ->input('number', [ 'class' => 'custom-input-2', 'min' => '1950', 'max' => date('Y') ]); ?> | ||
| 83 | </div> | 81 | </div> |
| 84 | </div> | 82 | </div> |
| 85 | </div> | 83 | </div> |
| @@ -103,10 +101,9 @@ $current = array_shift ($job); | @@ -103,10 +101,9 @@ $current = array_shift ($job); | ||
| 103 | 101 | ||
| 104 | <div class="input-blocks-wrapper"> | 102 | <div class="input-blocks-wrapper"> |
| 105 | <div class="input-blocks"> | 103 | <div class="input-blocks"> |
| 106 | - <?= $form->field ($job_model, '['. ($index + 1) .']link') | ||
| 107 | - ->label ('Ссылка на компанию на сайте МФП') | ||
| 108 | - ->textInput (['class'=> 'custom-input-2']); | ||
| 109 | - ?> | 104 | + <?= $form->field($job_model, '[' . ( $index + 1 ) . ']link') |
| 105 | + ->label('Ссылка на компанию на сайте МФП') | ||
| 106 | + ->textInput([ 'class' => 'custom-input-2' ]); ?> | ||
| 110 | </div> | 107 | </div> |
| 111 | </div> | 108 | </div> |
| 112 | 109 | ||
| @@ -204,12 +201,3 @@ $current = array_shift ($job); | @@ -204,12 +201,3 @@ $current = array_shift ($job); | ||
| 204 | }); | 201 | }); |
| 205 | }); | 202 | }); |
| 206 | </script> | 203 | </script> |
| 207 | - | ||
| 208 | -<script> | ||
| 209 | -// $(document).ready(function(){ | ||
| 210 | -// var prevEmploy = $('.prev_job_inputs').length | ||
| 211 | -// if(prevEmploy<1){ | ||
| 212 | -// $('.prev_job_container').addClass | ||
| 213 | -// } | ||
| 214 | -// }) | ||
| 215 | -</script> |