diff --git a/common/models/Job.php b/common/models/Job.php index f15732c..d82d374 100755 --- a/common/models/Job.php +++ b/common/models/Job.php @@ -84,22 +84,43 @@ 'string', 'max' => 255, ], + [ + [ + 'link', + ], + 'match', + 'pattern' => '/^(?:https?:\/\/)?(?:w{3}\.)?'.preg_quote($_SERVER['HTTP_HOST']).'\/company\/\w+\/\d+$/i', + ], ]; } public function getExpTime() { - if($this->date_end && $this->date_start) { - $date = new \DateTime(date('Y-m-d H:i:s', $this->date_start)); - return \Yii::$app->formatter->asRelativeTime($date->diff(new \DateTime(date('Y-m-d H:i:s', $this->date_end)))); - } elseif($this->date_start) { - $now = new \DateTime(); - $date = new \DateTime(date('Y-m-d H:i:s', strtotime($this->date_start))); - return \Yii::$app->formatter->asRelativeTime($date->diff(new \DateTime())); + if(!empty($this->date_start) && !empty($this->date_end)) { + $result = ''; + $start = new \DateTime($this->date_start); + $end = new \DateTime($this->date_end); + $interval = $end->diff($start); + if(!empty($interval->y)) { + if($interval->y) { + $result + } + } + } elseif(!empty($this->date_start)) { + } else { - return 'неизвестна дата начала'; + return false; } - +// if($this->date_end && $this->date_start) { +// $date = new \DateTime(date('Y-m-d H:i:s', $this->date_start)); +// return \Yii::$app->formatter->asRelativeTime($date->diff(new \DateTime(date('Y-m-d H:i:s', $this->date_end)))); +// } elseif($this->date_start) { +// $now = new \DateTime(); +// $date = new \DateTime(date('Y-m-d H:i:s', strtotime($this->date_start))); +// return \Yii::$app->formatter->asRelativeTime($date->diff(new \DateTime())); +// } else { +// return 'неизвестна дата начала'; +// } } /** diff --git a/common/models/User.php b/common/models/User.php index 7649808..4c0a3f5 100755 --- a/common/models/User.php +++ b/common/models/User.php @@ -523,7 +523,7 @@ public function getJobs() { return $this->hasMany(Job::className(), [ 'user_id' => 'id' ]) - ->orderBy([ 'current' => SORT_DESC ]); + ->orderBy([ 'current' => SORT_DESC, 'date_start' => SORT_DESC]); } /** diff --git a/frontend/controllers/PerformerController.php b/frontend/controllers/PerformerController.php index ee1c271..7019972 100755 --- a/frontend/controllers/PerformerController.php +++ b/frontend/controllers/PerformerController.php @@ -250,7 +250,7 @@ public function actionWorkplace($performer_id) { - $user = User::findOne($performer_id); + $user = User::find()->where(['id' => $performer_id])->with('jobs')->one(); if(!$user instanceof User) { throw new BadRequestHttpException('Пользователь не найден'); } diff --git a/frontend/views/accounts/_job_form.php b/frontend/views/accounts/_job_form.php index 785a4b4..b17364d 100755 --- a/frontend/views/accounts/_job_form.php +++ b/frontend/views/accounts/_job_form.php @@ -1,75 +1,98 @@ \Yii::$app->user->getId (), 'current' => 0]); -$form = ActiveForm::begin (); + $model = new Job([ + 'user_id' => \Yii::$app->user->getId(), + 'current' => 0, + ]); + $form = ActiveForm::begin(); ?> -
+
+
- field ($model, '[' . $index . ']name') - ->label ('Название') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($model, '[' . $index . ']name') + ->label('Название') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
- field ($model, '[' . $index . ']link') - ->label ('Ссылка на компанию на сайте МФП') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($model, '[' . $index . ']link') + ->label('Ссылка на компанию на сайте МФП') + ->hint('Пример: ' . $_SERVER[ 'HTTP_HOST' ] . '/company/common/1') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
- field ($model, '[' . $index . ']date_start') - ->label ('Дата начала работы') - ->widget (DatePicker::className (), ['options' => ['class' => 'custom-input-2'], 'language' => 'ru', 'dateFormat' => 'dd-MM-yyyy', 'clientOptions' => ['changeYear' => true, 'yearRange' => 'c-20:c', 'changeMonth' => true]]); - ?> + field($model, '[' . $index . ']date_start') + ->label('Дата начала работы') + ->widget(DatePicker::className(), [ + 'options' => [ 'class' => 'custom-input-2' ], + 'language' => 'ru', + 'dateFormat' => 'dd-MM-yyyy', + 'clientOptions' => [ + 'changeYear' => true, + 'yearRange' => 'c-20:c', + 'changeMonth' => true, + ], + ]); ?>
- field ($model, '[' . $index . ']date_end') - ->label ('Дата окончания работы') - ->widget (DatePicker::className (), ['options' => ['class' => 'custom-input-2'], 'language' => 'ru', 'dateFormat' => 'dd-MM-yyyy', 'clientOptions' => ['changeYear' => true, 'yearRange' => 'c-20:c', 'changeMonth' => true]]); - ?> + field($model, '[' . $index . ']date_end') + ->label('Дата окончания работы') + ->widget(DatePicker::className(), [ + 'options' => [ 'class' => 'custom-input-2' ], + 'language' => 'ru', + 'dateFormat' => 'dd-MM-yyyy', + 'clientOptions' => [ + 'changeYear' => true, + 'yearRange' => 'c-20:c', + 'changeMonth' => true, + ], + ]); ?>
- field ($model, '[' . $index . ']position') - ->label ('Должность') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($model, '[' . $index . ']position') + ->label('Должность') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
- field ($model, '[' . $index . ']total_count') - ->label ('Количество проектов, в которых принимали участие') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number']); - ?> + field($model, '[' . $index . ']total_count') + ->label('Количество проектов, в которых принимали участие') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date', + 'type' => 'number', + ]); ?>
- field ($model, '[' . $index . ']complete_count') - ->label ('из них реализовано') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number']); - ?> + field($model, '[' . $index . ']complete_count') + ->label('из них реализовано') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date', + 'type' => 'number', + ]); ?>
- 'remove_job_button']);?> -
-end (); ?> + 'remove_job_button' ]); ?> +
+
+end(); ?> diff --git a/frontend/views/accounts/employment.php b/frontend/views/accounts/employment.php index 5e22dde..ae8254d 100755 --- a/frontend/views/accounts/employment.php +++ b/frontend/views/accounts/employment.php @@ -32,6 +32,7 @@
field($current, '[0]link') ->label('Ссылка на компанию на сайте МФП') + ->hint('Пример: ' . $_SERVER[ 'HTTP_HOST' ] . '/company/common/1') ->textInput([ 'class' => 'custom-input-2' ]); ?>
@@ -46,29 +47,40 @@
- field ($current, '[0]date_start', ['options' => ['class' => 'test2class']]) - ->label ('Дата начала работы') - ->widget (DatePicker::className (), ['options' => ['class' => 'custom-input-2'], 'language' => 'ru', 'dateFormat' => 'dd-MM-yyyy', 'clientOptions' => ['changeYear' => true, 'yearRange' => 'c-20:c', 'changeMonth' => true]]); - ?> + field($current, '[0]date_start', [ 'options' => [ 'class' => 'test2class' ] ]) + ->label('Дата начала работы') + ->widget(DatePicker::className(), [ + 'options' => [ 'class' => 'custom-input-2' ], + 'language' => 'ru', + 'dateFormat' => 'dd-MM-yyyy', + 'clientOptions' => [ + 'changeYear' => true, + 'yearRange' => 'c-20:c', + 'changeMonth' => true, + ], + ]); ?>
- field ($current, '[0]total_count') - ->label ('Количество проектов, в которых принимали участие') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number']); - ?> + field($current, '[0]total_count') + ->label('Количество проектов, в которых принимали участие') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date', + 'type' => 'number', + ]); ?>
- field ($current, '[0]complete_count') - ->label ('из них реализовано') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number']); - ?> + field($current, '[0]complete_count') + ->label('из них реализовано') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date', + 'type' => 'number', + ]); ?>
-
@@ -77,7 +89,11 @@
field($user_info, 'experience') ->label('Когда начали заниматься проектированием') - ->input('number', [ 'class' => 'custom-input-2', 'min' => '1950', 'max' => date('Y') ]); ?> + ->input('number', [ + 'class' => 'custom-input-2', + 'min' => '1950', + 'max' => date('Y'), + ]); ?>
@@ -85,17 +101,15 @@
Предыдущие места работы
$job_model) - { - ?> + foreach($job as $index => $job_model) { + ?> -
+
- field ($job_model, '['. ($index + 1) .']name') - ->label ('Название') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($job_model, '[' . ( $index + 1 ) . ']name') + ->label('Название') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
@@ -103,100 +117,143 @@
field($job_model, '[' . ( $index + 1 ) . ']link') ->label('Ссылка на компанию на сайте МФП') + ->hint('Пример: ' . $_SERVER[ 'HTTP_HOST' ] . '/company/common/1') ->textInput([ 'class' => 'custom-input-2' ]); ?>
- field ($job_model, '['. ($index + 1) .']date_start') - ->label ('Дата начала работы') - ->widget (DatePicker::className (), ['options' => ['class' => 'custom-input-2'], 'language' => 'ru', 'dateFormat' => 'dd-MM-yyyy', 'clientOptions' => ['changeYear' => true, 'yearRange' => 'c-20:c', 'changeMonth' => true]]); - ?> + field($job_model, '[' . ( $index + 1 ) . ']date_start') + ->label('Дата начала работы') + ->widget(DatePicker::className(), [ + 'options' => [ 'class' => 'custom-input-2' ], + 'language' => 'ru', + 'dateFormat' => 'dd-MM-yyyy', + 'clientOptions' => [ + 'changeYear' => true, + 'yearRange' => 'c-20:c', + 'changeMonth' => true, + ], + ]); ?>
- field ($job_model, '['. ($index + 1) .']date_end') - ->label ('Дата окончания работы') - ->widget (DatePicker::className (), ['options' => ['class' => 'custom-input-2'], 'language' => 'ru', 'dateFormat' => 'dd-MM-yyyy', 'clientOptions' => ['changeYear' => true, 'yearRange' => 'c-20:c', 'changeMonth' => true]]); - ?> + field($job_model, '[' . ( $index + 1 ) . ']date_end') + ->label('Дата окончания работы') + ->widget(DatePicker::className(), [ + 'options' => [ 'class' => 'custom-input-2' ], + 'language' => 'ru', + 'dateFormat' => 'dd-MM-yyyy', + 'clientOptions' => [ + 'changeYear' => true, + 'yearRange' => 'c-20:c', + 'changeMonth' => true, + ], + ]); ?>
- field ($job_model, '['. ($index + 1) .']position') - ->label ('Должность') - ->textInput (['class'=> 'custom-input-2']); - ?> + field($job_model, '[' . ( $index + 1 ) . ']position') + ->label('Должность') + ->textInput([ 'class' => 'custom-input-2' ]); ?>
- field ($job_model, '['. ($index + 1) .']total_count') - ->label ('Количество проектов, в которых принимали участие') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number']); - ?> + field($job_model, '[' . ( $index + 1 ) . ']total_count') + ->label('Количество проектов, в которых принимали участие') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date', + 'type' => 'number', + ]); ?>
- field ($job_model, '['. ($index + 1) .']complete_count') - ->label ('из них реализовано') - ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number']); - ?> -
+ field($job_model, '[' . ( $index + 1 ) . ']complete_count') + ->label('из них реализовано') + ->textInput([ + 'class' => 'custom-input-2 custom-input-2-date', + 'type' => 'number', + ]); ?> +
- 'remove_job_button']) ?> -
- + 'remove_job_button' ]) ?> + +
- 'add_job_button', 'class' => 'btn']); - ?> + 'add_job_button', + 'class' => 'btn', + ]); ?>
- 'input-blocks-wrapper button']) ?> + 'input-blocks-wrapper button' ]) ?>
- end (); - ?> +end(); +?> diff --git a/frontend/views/layouts/performer.php b/frontend/views/layouts/performer.php index 068e6bd..b8ce798 100755 --- a/frontend/views/layouts/performer.php +++ b/frontend/views/layouts/performer.php @@ -186,12 +186,18 @@
  • params[ 'user' ]->payments, 'name')) ?>
  • -
  • -
    - Текущее место работы:
    params[ 'user' ]->currentJob ) ? $this->params[ 'user' ]->currentJob->name : "" ?> -
    -
  • - + params[ 'user' ]->currentJob )) { + ?> +
  • + +
    + Текущее место работы:
    params[ 'user' ]->currentJob->name ?> +
    +
  • + -- libgit2 0.21.4