Commit f389cee65b3db6e9775c46dbf4a1b0ead516d7d4
1 parent
1d31fd54
test
Showing
4 changed files
with
102 additions
and
21 deletions
Show diff stats
common/models/Vacancy.php
frontend/controllers/CompanyController.php
| @@ -11,6 +11,7 @@ use frontend\models\ContactForm; | @@ -11,6 +11,7 @@ use frontend\models\ContactForm; | ||
| 11 | use frontend\models\Options; | 11 | use frontend\models\Options; |
| 12 | use frontend\models\OptionValues; | 12 | use frontend\models\OptionValues; |
| 13 | use yii\base\InvalidParamException; | 13 | use yii\base\InvalidParamException; |
| 14 | +use yii\data\ActiveDataProvider; | ||
| 14 | use yii\helpers\ArrayHelper; | 15 | use yii\helpers\ArrayHelper; |
| 15 | use yii\web\BadRequestHttpException; | 16 | use yii\web\BadRequestHttpException; |
| 16 | use yii\web\Controller; | 17 | use yii\web\Controller; |
| @@ -121,19 +122,34 @@ class CompanyController extends Controller | @@ -121,19 +122,34 @@ class CompanyController extends Controller | ||
| 121 | public function actionVacancyList($company_id) | 122 | public function actionVacancyList($company_id) |
| 122 | { | 123 | { |
| 123 | $company = User::findOne($company_id); | 124 | $company = User::findOne($company_id); |
| 124 | - $vacancies = $company->vacancies; | 125 | + $query = $company->getVacancies(); |
| 126 | + $provider = new ActiveDataProvider([ | ||
| 127 | + 'query' => $query, | ||
| 128 | + 'pagination' => [ | ||
| 129 | + 'pageSize' => 2, | ||
| 130 | + ], | ||
| 131 | + 'sort' => [ | ||
| 132 | + 'defaultOrder' => [ | ||
| 133 | + 'date_add' => SORT_DESC, | ||
| 134 | + 'name' => SORT_ASC, | ||
| 135 | + ] | ||
| 136 | + ], | ||
| 137 | + ]); | ||
| 125 | 138 | ||
| 126 | return $this->render('vacancy-list',[ | 139 | return $this->render('vacancy-list',[ |
| 127 | - 'company' => $company | 140 | + 'company' => $company, |
| 141 | + 'provider' => $provider, | ||
| 128 | ]); | 142 | ]); |
| 129 | } | 143 | } |
| 130 | 144 | ||
| 131 | public function actionVacancyView($company_id, $vacancy_id) | 145 | public function actionVacancyView($company_id, $vacancy_id) |
| 132 | { | 146 | { |
| 133 | $company = User::findOne($company_id); | 147 | $company = User::findOne($company_id); |
| 148 | + $vacancy = $company->getVacancies()->where(['vacancy_id' => $vacancy_id])->with(['employments'])->one(); | ||
| 134 | 149 | ||
| 135 | return $this->render('vacancy-view',[ | 150 | return $this->render('vacancy-view',[ |
| 136 | - 'company' => $company | 151 | + 'company' => $company, |
| 152 | + 'vacancy' => $vacancy, | ||
| 137 | ]); | 153 | ]); |
| 138 | } | 154 | } |
| 139 | 155 |
frontend/views/company/vacancy-list.php
| 1 | <?php | 1 | <?php |
| 2 | + /** | ||
| 3 | + * @var User $company | ||
| 4 | + * @var ActiveDataProvider $provider | ||
| 5 | + */ | ||
| 6 | + use common\models\User; | ||
| 7 | + use yii\data\ActiveDataProvider; | ||
| 8 | + use yii\helpers\Html; | ||
| 9 | + use yii\helpers\StringHelper; | ||
| 10 | + use yii\widgets\ListView; | ||
| 2 | 11 | ||
| 3 | -use \yii\helpers\Html; | ||
| 4 | - | ||
| 5 | -/* @var $this yii\web\View */ | 12 | + /* @var $this yii\web\View */ |
| 6 | $this->params['company'] = $company; | 13 | $this->params['company'] = $company; |
| 7 | $this->title = 'My Yii Application'; | 14 | $this->title = 'My Yii Application'; |
| 8 | ?> | 15 | ?> |
| 9 | <div class="performer-vacancy-vacant-title style">Вакансии</div> | 16 | <div class="performer-vacancy-vacant-title style">Вакансии</div> |
| 17 | +<?php | ||
| 18 | +echo ListView::widget([ | ||
| 19 | + 'dataProvider' => $provider, | ||
| 20 | + 'itemView' => function($model, $key, $index, $widget) { | ||
| 21 | + $html = | ||
| 22 | + '<div class="performer-vacant-reclam-bl">' | ||
| 23 | + . Html::a($model->name, ['vacancy-view', 'company_id' => $model->user_id,'vacancy_id' => $model->vacancy_id], ['class' => 'performer-vacant-reclam-bl-title']) . | ||
| 24 | + '<div class="performer-vacant-reclam-bl-title-two">' . $model->city . '. ' . $model->date_add . ' xxxx грн.</div> | ||
| 25 | + <div class="performer-vacant-reclam-bl-content"> | ||
| 26 | + <span>' . StringHelper::truncateWords($model->description, 50, '...') . '</span>' | ||
| 27 | + . Html::a('<img src="/images/performar_vacancy/arrow-post.png" alt=""/>', ['vacancy-view', 'company_id' => $model->user_id,'vacancy_id' => $model->vacancy_id], ['class' => 'performer-vacant-reclam-bl-content-read']) . | ||
| 28 | + ' | ||
| 29 | + </div> | ||
| 30 | + </div>'; | ||
| 31 | + return $html; | ||
| 32 | + }, | ||
| 33 | + 'options' => [ | ||
| 34 | + 'class' => 'list-view performer-vacancy-vacant-title-reclam-wr style', | ||
| 35 | + ], | ||
| 36 | +]); | ||
| 37 | +?> | ||
| 38 | + | ||
| 39 | +<?php | ||
| 40 | +/* Markup | ||
| 10 | <div class="performer-vacancy-vacant-title-reclam-wr style"> | 41 | <div class="performer-vacancy-vacant-title-reclam-wr style"> |
| 11 | <div class="performer-vacant-reclam-bl"> | 42 | <div class="performer-vacant-reclam-bl"> |
| 12 | <a href="#" class="performer-vacant-reclam-bl-title">Инженер-технолог строитель</a> | 43 | <a href="#" class="performer-vacant-reclam-bl-title">Инженер-технолог строитель</a> |
| @@ -109,4 +140,6 @@ $this->title = 'My Yii Application'; | @@ -109,4 +140,6 @@ $this->title = 'My Yii Application'; | ||
| 109 | <li class="dots-next"><a href="#">...</a></li> | 140 | <li class="dots-next"><a href="#">...</a></li> |
| 110 | <li><a href="#">156</a></li> | 141 | <li><a href="#">156</a></li> |
| 111 | </ul> | 142 | </ul> |
| 112 | -</div> | ||
| 113 | \ No newline at end of file | 143 | \ No newline at end of file |
| 144 | +</div> | ||
| 145 | +*/ | ||
| 146 | +?> | ||
| 114 | \ No newline at end of file | 147 | \ No newline at end of file |
frontend/views/company/vacancy-view.php
| 1 | <?php | 1 | <?php |
| 2 | + /** | ||
| 3 | + * @var $this yii\web\View | ||
| 4 | + * @var User $company | ||
| 5 | + * @var Vacancy $vacancy | ||
| 6 | + */ | ||
| 2 | 7 | ||
| 3 | -use \yii\helpers\Html; | 8 | + use common\models\User; |
| 9 | + use common\models\Vacancy; | ||
| 10 | + use yii\helpers\ArrayHelper; | ||
| 11 | + use yii\helpers\Html; | ||
| 4 | 12 | ||
| 5 | -/* @var $this yii\web\View */ | ||
| 6 | -$this->params['company'] = $company; | 13 | + $this->params[ 'company'] = $company; |
| 7 | $this->title = 'My Yii Application'; | 14 | $this->title = 'My Yii Application'; |
| 8 | ?> | 15 | ?> |
| 9 | -<div class="performer-vacancy-list style"><a href="#" >к списку вакансий</a></div> | 16 | +<div class="performer-vacancy-list style"> |
| 17 | + <?php | ||
| 18 | + echo Html::a('к списку вакансий', ['vacancy-list', 'company_id' => $company->id]); | ||
| 19 | + ?> | ||
| 20 | +</div> | ||
| 10 | <div class="performer-vacancy-blocks-desk-wr style"> | 21 | <div class="performer-vacancy-blocks-desk-wr style"> |
| 11 | - <div class="performer-vacancy-date style"> Вакансия от 17.11.2015 </div> | ||
| 12 | - <div class="performance-vacancy-page-title style">Инженер-технолог строитель</div> | 22 | + <div class="performer-vacancy-date style"> Вакансия от <?= $vacancy->date_add ?> </div> |
| 23 | + <div class="performance-vacancy-page-title style"><?= $vacancy->name ?></div> | ||
| 13 | <div class="performance-vacancy-page-options style"> | 24 | <div class="performance-vacancy-page-options style"> |
| 14 | <ul> | 25 | <ul> |
| 15 | - <li><span>Контактное лицо:</span><p>Владимир</p></li> | ||
| 16 | - <li><span>Телефон:</span><p>096 345-23-42</p></li> | ||
| 17 | - <li><span>Город:</span><p>Бровары, ищем в Киеве</p></li> | ||
| 18 | - <li><span>Вид занятости:</span><p>полная занятость</p></li> | ||
| 19 | - <li><span>Требования:</span><p>опыт работы от 2 лет, высшее образование</p></li> | 26 | + <?php |
| 27 | + if(!empty($vacancy->user_name)) { | ||
| 28 | + echo "<li><span>Контактное лицо:</span><p>{$vacancy->user_name}</p></li>"; | ||
| 29 | + } | ||
| 30 | + ?> | ||
| 31 | + <li><span>Телефон:</span><p>XXX XXX-XX-XX</p></li> | ||
| 32 | + <?php | ||
| 33 | + if(!empty($vacancy->city)) { | ||
| 34 | + echo "<li><span>Город:</span><p>{$vacancy->city}</p></li>"; | ||
| 35 | + } | ||
| 36 | + ?> | ||
| 37 | + <?php | ||
| 38 | + if(!empty($vacancy->employments)) { | ||
| 39 | + echo "<li><span>Вид занятости:</span><p>".implode(', ', ArrayHelper::getColumn($vacancy->employments, 'name'))."</p></li>"; | ||
| 40 | + } | ||
| 41 | + ?> | ||
| 42 | + <?php | ||
| 43 | + if(!empty($vacancy->requirements)) { | ||
| 44 | + echo "<li><span>Требования:</span><p>".implode(', ', ArrayHelper::getColumn($vacancy->requirements, 'requirements'))."</p></li>"; | ||
| 45 | + } | ||
| 46 | + ?> | ||
| 20 | </ul> | 47 | </ul> |
| 21 | </div> | 48 | </div> |
| 22 | <div class="performance-vacancy-description style">Описание вакансии</div> | 49 | <div class="performance-vacancy-description style">Описание вакансии</div> |
| 23 | <div class="performance-vacancy-desc-txt style"> | 50 | <div class="performance-vacancy-desc-txt style"> |
| 24 | - <p>Требования: Инженер технолог строитель. Образование инженер-строитель. Доскональное знание технологиии строительных работ.</p> | ||
| 25 | - <p>Условия работы: Работа в офисе и командировки на стройки.</p> | ||
| 26 | - <p>Обязанности: Составление технологических карт, Ведение обучения технологии выполнения общестроительных и отделочных работ. Контроль.качества выполнения строительных работ. Работа с рекламациями. Работа с проектными организациями.</p> | 51 | + <?php |
| 52 | + echo $vacancy->description; | ||
| 53 | + ?> | ||
| 27 | </div> | 54 | </div> |
| 28 | <div class="performance-vacancy-desc-form style"> | 55 | <div class="performance-vacancy-desc-form style"> |
| 29 | <a href="#">Отправить резюме</a> | 56 | <a href="#">Отправить резюме</a> |