Commit a020aad3dc79cc2014f71c899d6969ad40ccfc8b
1 parent
4ff3ca88
test
Showing
7 changed files
with
117 additions
and
119 deletions
Show diff stats
frontend/controllers/CompanyController.php
... | ... | @@ -161,33 +161,27 @@ |
161 | 161 | public function actionTeam($company_id) |
162 | 162 | { |
163 | 163 | $company = User::findOne($company_id); |
164 | - | |
165 | 164 | if(!$company instanceof User) { |
166 | 165 | throw new BadRequestHttpException('Пользователь не найден'); |
167 | 166 | } |
168 | - | |
167 | + $comments = new ActiveDataProvider([ | |
168 | + 'query' => $company->getComments(), | |
169 | + 'pagination' => [ | |
170 | + 'pageSize' => 4 | |
171 | + ], | |
172 | + ]); | |
169 | 173 | $query = Team::find() |
170 | 174 | ->where([ 'user_id' => $company_id ]); |
171 | - | |
172 | - $countQuery = clone $query; | |
173 | - | |
174 | - $pagination = new Pagination([ | |
175 | - 'totalCount' => $countQuery->count(), | |
176 | - 'pageSize' => 9, | |
177 | - ]); | |
178 | - | |
179 | - $team = $query->offset($pagination->offset) | |
180 | - ->limit($pagination->limit) | |
181 | - ->all(); | |
182 | - | |
183 | - $team = new ArrayDataProvider([ | |
184 | - 'allModels' => $team, | |
175 | + $team = new ActiveDataProvider([ | |
176 | + 'query' => $query, | |
177 | + 'pagination' => [ | |
178 | + 'pageSize' => 9, | |
179 | + ], | |
185 | 180 | ]); |
186 | - | |
187 | 181 | return $this->render('team', [ |
188 | - 'company' => $company, | |
189 | - 'team' => $team, | |
190 | - 'pagination' => $pagination, | |
182 | + 'company' => $company, | |
183 | + 'team' => $team, | |
184 | + 'comments' => $comments, | |
191 | 185 | ]); |
192 | 186 | } |
193 | 187 | |
... | ... | @@ -269,19 +263,11 @@ |
269 | 263 | |
270 | 264 | $query = $company->getVacancies(); |
271 | 265 | |
272 | - $countQuery = clone $query; | |
273 | - | |
274 | - $pagination = new Pagination([ | |
275 | - 'totalCount' => $countQuery->count(), | |
276 | - 'pageSize' => 5, | |
277 | - ]); | |
278 | - | |
279 | - $vacancy = $query->offset($pagination->offset) | |
280 | - ->limit($pagination->limit); | |
281 | - | |
282 | 266 | $provider = new ActiveDataProvider([ |
283 | - 'query' => $vacancy, | |
284 | - 'pagination' => false, | |
267 | + 'query' => $query, | |
268 | + 'pagination' => [ | |
269 | + 'pageSize' => 5, | |
270 | + ], | |
285 | 271 | 'sort' => [ |
286 | 272 | 'defaultOrder' => [ |
287 | 273 | 'date_add' => SORT_DESC, |
... | ... | @@ -291,9 +277,8 @@ |
291 | 277 | ]); |
292 | 278 | |
293 | 279 | return $this->render('vacancy-list', [ |
294 | - 'company' => $company, | |
295 | - 'provider' => $provider, | |
296 | - 'pagination' => $pagination, | |
280 | + 'company' => $company, | |
281 | + 'provider' => $provider, | |
297 | 282 | ]); |
298 | 283 | |
299 | 284 | } | ... | ... |
frontend/views/company/_company_list_view.php
... | ... | @@ -6,7 +6,13 @@ |
6 | 6 | <div class="command-block-wrapper"> |
7 | 7 | <div class="command-block-wr-two"> |
8 | 8 | <div class="command-block-foto"> |
9 | - <?= Html::a(( $model->photo ? Html::img($model->photo) : '' ) . '<div class="hover-command-bg"></div>', Url::toRoute([ '#' ])) ?> | |
9 | + <?php | |
10 | + if(empty( $model->link )) { | |
11 | + echo ( $model->photo ? Html::img($model->photo) : '' ) . '<div class="hover-command-bg"></div>'; | |
12 | + } else { | |
13 | + echo Html::a(( $model->photo ? Html::img($model->photo) : '' ) . '<div class="hover-command-bg"></div>', 'http://'.$model->link); | |
14 | + } | |
15 | + ?> | |
10 | 16 | </div> |
11 | 17 | <div class="command-block-name"><?= $model->user ?></div> |
12 | 18 | <?php | ... | ... |
1 | +<?php | |
2 | + /** | |
3 | + * @var Comment $model | |
4 | + * @var int $key | |
5 | + * @var int $index | |
6 | + * @var ListView $widget | |
7 | + */ | |
8 | + use common\modules\comment\models\Comment; | |
9 | + use yii\helpers\Html; | |
10 | + use yii\widgets\ListView; | |
11 | + | |
12 | +?> | |
13 | +<?php | |
14 | + if(!empty( $model->rating )) { | |
15 | + ?> | |
16 | + <div class="rating"> | |
17 | + <!--оценка--> | |
18 | + <input type="hidden" class="val" value="<?= $model->rating->value ?>"/> | |
19 | + <!--количество голосов--> | |
20 | + <input type="hidden" class="votes" value="1"/> | |
21 | + </div> | |
22 | + <?php | |
23 | + } | |
24 | +?> | |
25 | +<?php | |
26 | + if(!empty( $model->user_id )) { | |
27 | + ?> | |
28 | + <div class="company-performer-comments-autor">Отзыв от: <?= $model->author->name ?></div> | |
29 | + <?php | |
30 | + } else { | |
31 | + ?> | |
32 | + <div class="company-performer-comments-autor">Отзыв от: <?= $model->user_name ?></div> | |
33 | + <?php | |
34 | + } | |
35 | +?> | |
36 | +<div class="company-performer-comments-txt"><?= $model->text ?></div> | |
37 | +<a href="#" class="company-comm-see-all"><span>Развернуть</span></a> | ... | ... |
frontend/views/company/_vacancy_list_view.php
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | ]), [ 'class' => 'performer-vacant-reclam-bl-title' ]) ?> |
18 | 18 | <div class="performer-vacant-reclam-bl-title-two"> |
19 | 19 | <?= $model->city ?> |
20 | - <?= \Yii::$app->formatter->asDatetime($model->date_add, 'dd.MM.Y') ?> | |
20 | + <?= \Yii::$app->formatter->asDate($model->date_add, 'dd.MM.Y') ?> | |
21 | 21 | <?php |
22 | 22 | if(!empty( $model->salary )) { |
23 | 23 | ?> | ... | ... |
frontend/views/company/team.php
1 | 1 | <?php |
2 | + /** | |
3 | + * @var User $company | |
4 | + * @var ActiveDataProvider $team | |
5 | + * @var View $this | |
6 | + * @var ActiveDataProvider $comments | |
7 | + */ | |
2 | 8 | |
3 | -use \yii\helpers\Html; | |
4 | -use yii\widgets\LinkPager; | |
5 | -use yii\widgets\ListView; | |
9 | + use common\models\User; | |
10 | + use common\modules\comment\models\Comment; | |
11 | + use yii\data\ActiveDataProvider; | |
12 | + use yii\helpers\Html; | |
13 | + use yii\web\View; | |
14 | + use yii\widgets\LinkPager; | |
15 | + use yii\widgets\ListView; | |
6 | 16 | |
7 | -/* @var $this yii\web\View */ | |
8 | -$this->params['company'] = $company; | |
9 | -$this->title = 'My Yii Application'; | |
17 | + $this->params[ 'company' ] = $company; | |
18 | + $this->title = 'My Yii Application'; | |
10 | 19 | ?> |
11 | 20 | <div class="command-blocks-wr style"> |
12 | - <?= | |
13 | - ListView::widget( [ | |
21 | + <?= ListView::widget([ | |
14 | 22 | 'dataProvider' => $team, |
15 | - 'itemView'=>'_company_list_view', | |
16 | - 'summary'=>'', | |
17 | - ] ); | |
18 | - ?> | |
23 | + 'itemView' => '_company_list_view', | |
24 | + 'layout' => '{items}', | |
25 | + ]); ?> | |
19 | 26 | |
20 | 27 | |
21 | 28 | </div> |
22 | 29 | <div class="navi-buttons-wr style command-command-style"> |
23 | - <?= | |
24 | - LinkPager::widget([ | |
25 | - 'pagination' => $pagination, | |
26 | - ]); | |
27 | - ?> | |
30 | + <?= LinkPager::widget([ | |
31 | + 'pagination' => $team->pagination, | |
32 | + ]); ?> | |
28 | 33 | </div> |
29 | 34 | <?php |
30 | 35 | /*====Blocks for layout====*/ |
31 | - $this->beginBlock('review'); | |
32 | -?> | |
33 | - <div class="section-box-19"> | |
34 | - <div class="box-wr"> | |
35 | - <div class="box-all"> | |
36 | - <div class="company-performer-comm-title style">Отзывов: 54</div> | |
37 | - <div class="company-performer-comments-wr style"> | |
38 | - <div class="company-performer-comments-bl"> | |
39 | - <div class="rating"> | |
40 | - <!--оценка--> | |
41 | - <input type="hidden" class="val" value="3"/> | |
42 | - <!--количество голосов--> | |
43 | - <input type="hidden" class="votes" value="12"/> | |
44 | - </div> | |
45 | - | |
46 | - <div class="company-performer-comments-autor">Отзыв от: Евгения</div> | |
47 | - <div class="company-performer-comments-txt"></div> | |
48 | - <a href="#" class="company-comm-see-all"><span>Развернуть</span></a> | |
49 | - </div> | |
50 | - | |
51 | - <div class="company-performer-comments-bl"> | |
52 | - <div class="rating"> | |
53 | - <!--оценка--> | |
54 | - <input type="hidden" class="val" value="2"/> | |
55 | - <!--количество голосов--> | |
56 | - <input type="hidden" class="votes" value="12"/> | |
57 | - </div> | |
58 | - | |
59 | - <div class="company-performer-comments-autor">Отзыв от: Евгения</div> | |
60 | - <div class="company-performer-comments-txt">2Петер, очень понравились Ваши работы. Замечательный вкус!!! Тонкое сочетание стиля, цвета и формы! Очень нравится. Успехов в работе и вдохновения.</div> | |
61 | - <a href="#" class="company-comm-see-all"><span>Развернуть</span></a> | |
62 | - </div> | |
63 | - | |
64 | - <div class="company-performer-comments-bl"> | |
65 | - <div class="rating"> | |
66 | - <!--оценка--> | |
67 | - <input type="hidden" class="val" value="4"/> | |
68 | - <!--количество голосов--> | |
69 | - <input type="hidden" class="votes" value="12"/> | |
70 | - </div> | |
71 | - | |
72 | - <div class="company-performer-comments-autor">Отзыв от: Евгения</div> | |
73 | - <div class="company-performer-comments-txt">3Петер, очень понравились Ваши работы. Замечательный вкус!!! Тонкое сочетание стиля, цвета и формы! Очень нравится. Успехов в работе и вдохновения. Петер, очень понравились Ваши работы. Замечательный вкус!!! Тонкое сочетание стиля, цвета и формы! Очень нравится. Успехов в работе и вдохновения. | |
74 | - </div> | |
75 | - <a href="#" class="company-comm-see-all"><span>Развернуть</span></a> | |
76 | - </div> | |
77 | - | |
78 | - <div class="company-performer-comments-bl"> | |
79 | - <div class="rating"> | |
80 | - <!--оценка--> | |
81 | - <input type="hidden" class="val" value="5"/> | |
82 | - <!--количество голосов--> | |
83 | - <input type="hidden" class="votes" value="12"/> | |
84 | - </div> | |
85 | - | |
86 | - <div class="company-performer-comments-autor">Отзыв от: Евгения</div> | |
87 | - <div class="company-performer-comments-txt">4Петер, очень понравились Ваши работы. Замечательный вкус!!! Тонкое сочетание стиля, цвета и формы! Очень нравится. Успехов в работе и вдохновения. | |
88 | - </div> | |
89 | - <a href="#" class="company-comm-see-all"><span>Развернуть</span></a> | |
36 | + if($comments->totalCount > 0) { | |
37 | + $this->beginBlock('review'); | |
38 | + ?> | |
39 | + <div class="section-box-19"> | |
40 | + <div class="box-wr"> | |
41 | + <div class="box-all"> | |
42 | + <div class="company-performer-comm-title style">Отзывов: <?= $comments->totalCount ?></div> | |
43 | + <?= ListView::widget([ | |
44 | + 'dataProvider' => $comments, | |
45 | + 'itemView' => '_company_team_review', | |
46 | + 'layout' => '{items}', | |
47 | + 'options' => [ | |
48 | + 'class' => 'company-performer-comments-wr style', | |
49 | + ], | |
50 | + 'itemOptions' => [ | |
51 | + 'class' => 'company-performer-comments-bl', | |
52 | + ], | |
53 | + ]) ?> | |
54 | + <div class="company-performer-comm-see-all-butt style"> | |
55 | + <?= Html::a('Читать все отзывы', [ | |
56 | + 'company/review', | |
57 | + 'company_id' => $company->id, | |
58 | + ]) ?> | |
90 | 59 | </div> |
91 | 60 | </div> |
92 | - <div class="company-performer-comm-see-all-butt style"><a href="#">Читать все отзывы</a></div> | |
93 | 61 | </div> |
94 | 62 | </div> |
95 | - </div> | |
96 | -<?php | |
97 | - $this->endBlock(); | |
63 | + <?php | |
64 | + $this->endBlock(); | |
65 | + } | |
98 | 66 | /*====End blocks for layout====*/ |
99 | 67 | ?> |
100 | 68 | \ No newline at end of file | ... | ... |
frontend/views/company/vacancy-list.php
... | ... | @@ -23,13 +23,15 @@ $this->title = 'My Yii Application'; |
23 | 23 | 'options' => [ |
24 | 24 | 'class' => 'list-view performer-vacancy-vacant-title-reclam-wr style', |
25 | 25 | ], |
26 | + 'summary' => 'Всего {count} записей из {totalCount}', | |
27 | + 'layout' => "{summary}\n{items}", | |
26 | 28 | ]); |
27 | 29 | ?> |
28 | 30 | </div> |
29 | 31 | <div class="navi-buttons-wr style"> |
30 | 32 | <?= |
31 | 33 | LinkPager::widget([ |
32 | - 'pagination' => $pagination, | |
34 | + 'pagination' => $provider->pagination, | |
33 | 35 | ]); |
34 | 36 | ?> |
35 | 37 | </div> | ... | ... |
frontend/views/company/vacancy-view.php