Commit 9e040221438347f13ae397e722888079ddfbddf3
1 parent
20a22bc7
test
Showing
2 changed files
with
25 additions
and
13 deletions
Show diff stats
common/models/Job.php
@@ -45,13 +45,15 @@ class Job extends \yii\db\ActiveRecord | @@ -45,13 +45,15 @@ class Job extends \yii\db\ActiveRecord | ||
45 | 45 | ||
46 | public function getExpTime() | 46 | public function getExpTime() |
47 | { | 47 | { |
48 | - if($this->date_end){ | 48 | + if($this->date_end && $this->date_start){ |
49 | $date = new \DateTime(date('Y-m-d H:i:s', $this->date_start)); | 49 | $date = new \DateTime(date('Y-m-d H:i:s', $this->date_start)); |
50 | return \Yii::$app->formatter->asRelativeTime($date->diff(new \DateTime(date('Y-m-d H:i:s', $this->date_end)))); | 50 | return \Yii::$app->formatter->asRelativeTime($date->diff(new \DateTime(date('Y-m-d H:i:s', $this->date_end)))); |
51 | + } elseif($this->date_start) { | ||
52 | + $now = new \DateTime(); | ||
53 | + $date = new \DateTime(date('Y-m-d H:i:s', strtotime($this->date_start))); | ||
54 | + return \Yii::$app->formatter->asRelativeTime($date->diff(new \DateTime())); | ||
51 | } else { | 55 | } else { |
52 | - $now = new \DateTime('now'); | ||
53 | - $date = new \DateTime(date('Y-m-d H:i:s', $this->date_start)); | ||
54 | - return \Yii::$app->formatter->asRelativeTime($date->diff(new \DateTime(date('Y-m-d H:i:s', $now)))); | 56 | + return 'неизвестна дата начала'; |
55 | } | 57 | } |
56 | 58 | ||
57 | } | 59 | } |
frontend/views/performer/workplace.php
1 | <?php | 1 | <?php |
2 | + /** | ||
3 | + * @var yii\web\View $this | ||
4 | + * @var User $user | ||
5 | + */ | ||
6 | + use common\models\User; | ||
2 | 7 | ||
3 | -use \yii\helpers\Html; | ||
4 | - | ||
5 | -/* @var $this yii\web\View */ | ||
6 | -$this->params['user'] = $user; | ||
7 | -$this->title = 'My Yii Application'; | 8 | + $this->params[ 'user' ] = $user; |
9 | + $this->title = 'My Yii Application'; | ||
8 | ?> | 10 | ?> |
9 | <div class="performer-vacancy-vacant-title-reclam-wr style"> | 11 | <div class="performer-vacancy-vacant-title-reclam-wr style"> |
10 | <div class="workplace-wr"> | 12 | <div class="workplace-wr"> |
11 | <div class="workplace-title style"><p>Опыт работы</p></div> | 13 | <div class="workplace-title style"><p>Опыт работы</p></div> |
12 | <div class="workplace-experience-wr style"> | 14 | <div class="workplace-experience-wr style"> |
13 | - | ||
14 | - <?php foreach($user->jobs as $job):?> | 15 | + <?php foreach($user->jobs as $job): ?> |
15 | <div class="workplace-experience-post"> | 16 | <div class="workplace-experience-post"> |
16 | <div class="workplace-experience-post-title"><?= $job->name ?></div> | 17 | <div class="workplace-experience-post-title"><?= $job->name ?></div> |
17 | - <div class="workplace-experience-post-date"><?= $job->date_start ?>-<?= $job->date_end ?> (<?= $job->expTime ?>)</div> | 18 | + <div class="workplace-experience-post-date"> |
19 | + <?php | ||
20 | + if(!empty($job->date_start) && !empty($job->date_end)) { | ||
21 | + echo $job->date_start . '-' . $job->date_end . ' (' . $job->expTime . ')'; | ||
22 | + } elseif(!empty($job->date_start)) { | ||
23 | + echo 'с ' . $job->date_start . ' (' . $job->expTime . ')'; | ||
24 | + } elseif(!empty($job->date_end)) { | ||
25 | + echo 'до ' . $job->date_end; | ||
26 | + } | ||
27 | + ?> | ||
28 | + </div> | ||
18 | <div class="workplace-experience-post-vacancy"><?= $job->position ?></div> | 29 | <div class="workplace-experience-post-vacancy"><?= $job->position ?></div> |
19 | </div> | 30 | </div> |
20 | <?php endforeach; ?> | 31 | <?php endforeach; ?> |
21 | 32 | ||
22 | 33 | ||
23 | - | ||
24 | </div> | 34 | </div> |
25 | </div> | 35 | </div> |
26 | </div> | 36 | </div> |
27 | \ No newline at end of file | 37 | \ No newline at end of file |