diff --git a/common/models/UserInfo.php b/common/models/UserInfo.php index 9d9dd1b..db8d8d3 100755 --- a/common/models/UserInfo.php +++ b/common/models/UserInfo.php @@ -61,11 +61,12 @@ class UserInfo extends \yii\db\ActiveRecord public function rules() { return [ - [['user_id', 'view_count', 'contract', 'estimate', 'purchase', 'delivery','is_customer','is_freelancer'], 'integer'], + [['contract', 'estimate', 'purchase', 'delivery','is_customer','is_freelancer'], 'integer'], [['date_visit'], 'safe'], - [['experience', 'soft', 'guarantee', 'about', 'city', 'country', 'image', 'poster', 'social_vk', 'social_fb', 'social_in', 'social_t'], 'string'], + [['soft', 'guarantee', 'about', 'city', 'country', 'image', 'poster', 'social_vk', 'social_fb', 'social_in', 'social_t'], 'string'], [['prepayment'], 'number'], - + [['experience'], 'integer', 'max' => date('Y'), 'min' => 1950], + [['experience'], 'default', 'value' => date('Y')], [['rank', 'location'], 'string', 'max' => 50], [['salary', 'job'], 'string', 'max' => 255], [['busy', 'member'], 'boolean'], diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 7e5e288..4431d69 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -189,8 +189,16 @@ public function actionEmployment() { + $user_info = UserInfo::find() + ->where([ 'user_id' => \Yii::$app->user->getId() ]) + ->one(); + if(empty( $user_info )) { + $user_info = new UserInfo([ 'user_id' => \Yii::$app->user->getId() ]); + } $post = \Yii::$app->request->post(); if(!empty( $post )) { + $user_info->load($post); + $user_info->save(); $job = [ ]; for($i = 0; $i < count($post[ 'Job' ]); $i++) { $job[ $i ] = new Job([ @@ -225,7 +233,9 @@ ])); } } - return $this->render('employment', [ 'job' => $job ]); + return $this->render('employment', [ 'job' => $job, + 'user_info' => $user_info, + ]); } public function actionGallery() diff --git a/frontend/views/accounts/employment.php b/frontend/views/accounts/employment.php index 5631355..ec935b8 100755 --- a/frontend/views/accounts/employment.php +++ b/frontend/views/accounts/employment.php @@ -1,47 +1,46 @@ title = 'Трудовой стаж'; -$this->params['breadcrumbs'][] = $this->title; + /** + * @var Job[] $job + * @var UserInfo $user_info + */ + use common\models\Job; + use common\models\UserInfo; + use yii\helpers\Html; + use yii\jui\DatePicker; + use yii\widgets\ActiveForm; + + $this->title = 'Трудовой стаж'; + $this->params[ 'breadcrumbs' ][] = $this->title; ?>
title ?>
Текущее место работы:
- field ($current, '[0]name') - ->label ('Название') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($current, '[0]name') + ->label('Название') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
- field ($current, '[0]link') - ->label ('Ссылка на компанию на сайте МФП') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($current, '[0]link') + ->label('Ссылка на компанию на сайте МФП') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
- field ($current, '[0]position') - ->label ('Должность') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($current, '[0]position') + ->label('Должность') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
@@ -76,10 +75,9 @@ $current = array_shift ($job);
- field ($current, '[0]date_start') - ->label ('Когда начали заниматься проектированием') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($user_info, 'experience') + ->label('Когда начали заниматься проектированием') + ->input('number', [ 'class' => 'custom-input-2', 'min' => '1950', 'max' => date('Y') ]); ?>
@@ -103,10 +101,9 @@ $current = array_shift ($job);
- field ($job_model, '['. ($index + 1) .']link') - ->label ('Ссылка на компанию на сайте МФП') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($job_model, '[' . ( $index + 1 ) . ']link') + ->label('Ссылка на компанию на сайте МФП') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
@@ -204,12 +201,3 @@ $current = array_shift ($job); }); }); - - -- libgit2 0.21.4