Commit 4f404e202a9ae4b653b5ff0da49f604200719db3

Authored by Administrator
1 parent 47559a4b

09.02.16

common/models/Fields.php
... ... @@ -57,10 +57,12 @@ class Fields extends \yii\db\ActiveRecord
57 57  
58 58 public static function getData($id, $model, $type){
59 59 $data = ArrayHelper::toArray(self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->all());
60   - print_r($data);
  60 + $result = [];
  61 + for($i=0; $i < count($data); $i ++){
  62 + $result[$data[$i]['parent_key']][$data[$i]['field_name']] = $data[$i]['value'];
  63 + }
61 64  
62   - die();
63   - return self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->indexBy('parent_key')->all();
  65 + return $result;
64 66 }
65 67  
66 68  
... ...
common/models/UserInfo.php
... ... @@ -79,7 +79,7 @@ class UserInfo extends \yii\db\ActiveRecord
79 79  
80 80  
81 81 public function getLastVisit(){
82   - return \Yii::$app->formatter->asRelativeTime($this->date_visit);
  82 + return \Yii::$app->formatter->asRelativeTime(date('Y-m-d h:m:s',strtotime($this->date_visit)));
83 83 }
84 84  
85 85  
... ...
frontend/config/main.php
... ... @@ -64,7 +64,7 @@ return [
64 64 'showScriptName' => false,
65 65 'rules' => [
66 66 'landing/<view:[\w-]+>' => 'landing/view',
67   - 'performer/common/<performer_id:[\w-]+>' => 'performer/common',
  67 + 'performer/<action>/<performer_id:[\w-]+>' => 'performer/<action>',
68 68 ]
69 69 ],
70 70 ],
... ...
frontend/controllers/PerformerController.php
... ... @@ -2,27 +2,11 @@
2 2 namespace frontend\controllers;
3 3  
4 4 use common\models\Fields;
5   -use common\widgets\FieldEditor;
6 5 use Yii;
7   -use common\models\LoginForm;
8   -use frontend\models\PasswordResetRequestForm;
9   -use frontend\models\ResetPasswordForm;
10   -use frontend\models\SignupForm;
11   -use frontend\models\ContactForm;
12   -use frontend\models\Options;
13   -use frontend\models\OptionValues;
14   -use yii\base\InvalidParamException;
15   -use yii\web\BadRequestHttpException;
  6 +use yii\helpers\ArrayHelper;
16 7 use yii\web\Controller;
17   -use yii\filters\VerbFilter;
18   -use yii\filters\AccessControl;
19   -use frontend\models\OptionsToValues;
20   -use yii\validators\EmailValidator;
21 8 use common\models\User;
22   -use yii\helpers\VarDumper;
23   -use common\models\Page;
24   -use frontend\models\Option;
25   -use common\models\Social;
  9 +
26 10  
27 11  
28 12 /**
... ... @@ -31,6 +15,10 @@ use common\models\Social;
31 15 class PerformerController extends Controller
32 16 {
33 17 public $layout = 'performer';
  18 + public $user;
  19 +
  20 +
  21 +
34 22  
35 23 /**
36 24 * @inheritdoc
... ... @@ -57,29 +45,41 @@ class PerformerController extends Controller
57 45  
58 46 public function actionCommon($performer_id)
59 47 {
60   - if(\Yii::$app->user->identity instanceof User && \Yii::$app->user->identity->id == $performer_id ){
61   - $user = \Yii::$app->user->identity;
62   - } else {
63   - $user = User::findOne($performer_id);
64   - }
65 48  
  49 + $user = User::findOne($performer_id);
66 50  
67   - $educations = Fields::getData($user->id,$user::className(),'education');
  51 + $educations = Fields::getData($user->id,$user->className(),'education');
  52 + $phones = Fields::getData($user->id,$user->className(),'phone');
  53 + $sites = Fields::getData($user->id,$user->className(),'site');
  54 + $soft = implode(', ',ArrayHelper::getColumn(Fields::getData($user->id,$user->className(),'soft'), 'soft'));
68 55  
69 56 return $this->render('common',[
70 57 'user' => $user,
71   - 'educations' => $educations
  58 + 'educations' => $educations,
  59 + 'phones' => $phones,
  60 + 'sites' => $sites,
  61 + 'soft' => $soft
72 62 ]);
  63 +
  64 +
73 65 }
74 66  
75   - public function actionPortfolio(/*$performer_id*/)
  67 + public function actionPortfolio($performer_id)
76 68 {
77   - return $this->render('portfolio');
  69 + $user = User::findOne($performer_id);
  70 +
  71 + return $this->render('portfolio',[
  72 + 'user' => $user
  73 + ]);
  74 +
78 75 }
79 76  
80   - public function actionBlogList(/*$performer_id*/)
  77 + public function actionBlogList($performer_id)
81 78 {
82   - return $this->render('blog-list');
  79 + $user = User::findOne($performer_id);
  80 + return $this->render('blog-list',[
  81 + 'user' => $user
  82 + ]);
83 83 }
84 84  
85 85 public function actionBlogView(/*$performer_id, $article_id*/)
... ... @@ -87,19 +87,28 @@ class PerformerController extends Controller
87 87 return $this->render('blog-view');
88 88 }
89 89  
90   - public function actionReview(/*$performer_id*/)
  90 + public function actionReview($performer_id)
91 91 {
92   - return $this->render('review');
  92 + $user = User::findOne($performer_id);
  93 + return $this->render('review',[
  94 + 'user' => $user
  95 + ]);
93 96 }
94 97  
95   - public function actionWorkplace(/*$performer_id*/)
  98 + public function actionWorkplace($performer_id)
96 99 {
97   - return $this->render('workplace');
  100 + $user = User::findOne($performer_id);
  101 + return $this->render('workplace',[
  102 + 'user' => $user
  103 + ]);
98 104 }
99 105  
100   - public function actionGallery(/*$performer_id*/)
  106 + public function actionGallery($performer_id)
101 107 {
  108 + $user = User::findOne($performer_id);
102 109 $this->layout = 'gallery';
103   - return $this->render('gallery');
  110 + return $this->render('gallery',[
  111 + 'user' => $user
  112 + ]);
104 113 }
105 114 }
... ...
frontend/views/layouts/gallery.php
... ... @@ -23,38 +23,38 @@ $this-&gt;beginContent(&#39;@app/views/layouts/main.php&#39;);
23 23 <div class="box-wr">
24 24 <div class="box-all">
25 25 <?php
26   - echo Menu::widget([
27   - 'options' => [
28   - 'class' => 'menu-content',
  26 + echo Menu::widget([
  27 + 'options' => [
  28 + 'class' => 'menu-content',
  29 + ],
  30 + 'activeCssClass' => 'active-menu-content',
  31 + 'items' => [
  32 + [
  33 + 'label' => 'Общее',
  34 + 'url' => ['performer/common', 'performer_id'=>$this->params['user']->id],
29 35 ],
30   - 'activeCssClass' => 'active-menu-content',
31   - 'items' => [
32   - [
33   - 'label' => 'Общее',
34   - 'url' => ['performer/common'],
35   - ],
36   - [
37   - 'label' => 'Портфолио',
38   - 'url' => ['performer/portfolio'],
39   - ],
40   - [
41   - 'label' => 'Блог',
42   - 'url' => ['performer/blog-list'],
43   - ],
44   - [
45   - 'label' => 'Отзывы',
46   - 'url' => ['performer/review'],
47   - ],
48   - [
49   - 'label' => 'Места работы',
50   - 'url' => ['performer/workplace'],
51   - ],
52   - [
53   - 'label' => 'Галерея',
54   - 'url' => ['performer/gallery'],
55   - ],
  36 + [
  37 + 'label' => 'Портфолио',
  38 + 'url' => ['performer/portfolio', 'performer_id'=>$this->params['user']->id],
56 39 ],
57   - ]);
  40 + [
  41 + 'label' => 'Блог',
  42 + 'url' => ['performer/blog-list', 'performer_id'=>$this->params['user']->id],
  43 + ],
  44 + [
  45 + 'label' => 'Отзывы',
  46 + 'url' => ['performer/review', 'performer_id'=>$this->params['user']->id],
  47 + ],
  48 + [
  49 + 'label' => 'Места работы',
  50 + 'url' => ['performer/workplace', 'performer_id'=>$this->params['user']->id],
  51 + ],
  52 + [
  53 + 'label' => 'Галерея',
  54 + 'url' => ['performer/gallery', 'performer_id'=>$this->params['user']->id],
  55 + ],
  56 + ],
  57 + ]);
58 58 ?>
59 59 </div>
60 60 </div>
... ...
frontend/views/layouts/performer.php
1 1 <?php
2 2  
  3 +use common\models\User;
  4 +use yii\helpers\ArrayHelper;
3 5 use yii\helpers\Html;
4   -use yii\widgets\Breadcrumbs;
5 6 use yii\widgets\Menu;
6 7  
7 8 \frontend\assets\AppAsset::register($this);
8 9 /* @var $content string */
9 10 $this->beginContent('@app/views/layouts/main.php');
10 11  
  12 +
11 13 ?>
12 14 <div class="section-box content">
13   - <div class="section-box-16" style="background: url('<?= Yii::$app->user->identity->userInfo->poster;?>') 50% no-repeat">
  15 + <div class="section-box-16" style="background: url('<?= $this->params['user']->userInfo->poster;?>') 50% no-repeat">
14 16 <div class="box-wr">
15 17 <div class="box-all">
16 18 <div class="blog-buttons-wr style">
... ... @@ -33,27 +35,27 @@ $this-&gt;beginContent(&#39;@app/views/layouts/main.php&#39;);
33 35 'items' => [
34 36 [
35 37 'label' => 'Общее',
36   - 'url' => ['performer/common'],
  38 + 'url' => ['performer/common', 'performer_id'=>$this->params['user']->id],
37 39 ],
38 40 [
39 41 'label' => 'Портфолио',
40   - 'url' => ['performer/portfolio'],
  42 + 'url' => ['performer/portfolio', 'performer_id'=>$this->params['user']->id],
41 43 ],
42 44 [
43 45 'label' => 'Блог',
44   - 'url' => ['performer/blog-list'],
  46 + 'url' => ['performer/blog-list', 'performer_id'=>$this->params['user']->id],
45 47 ],
46 48 [
47 49 'label' => 'Отзывы',
48   - 'url' => ['performer/review'],
  50 + 'url' => ['performer/review', 'performer_id'=>$this->params['user']->id],
49 51 ],
50 52 [
51 53 'label' => 'Места работы',
52   - 'url' => ['performer/workplace'],
  54 + 'url' => ['performer/workplace', 'performer_id'=>$this->params['user']->id],
53 55 ],
54 56 [
55 57 'label' => 'Галерея',
56   - 'url' => ['performer/gallery'],
  58 + 'url' => ['performer/gallery', 'performer_id'=>$this->params['user']->id],
57 59 ],
58 60 ],
59 61 ]);
... ... @@ -93,36 +95,36 @@ $this-&gt;beginContent(&#39;@app/views/layouts/main.php&#39;);
93 95 <a href="#" class="performance-vacancy-sidebar-write style">написать отзыв</a>
94 96 </div>
95 97 <div class="performer-vacancy-sidebar-img style">
96   - <?= Html::img(Yii::$app->user->identity->userInfo->image);?>
  98 + <?= Html::img($this->params['user']->userInfo->image);?>
97 99 </div>
98 100 <div class="performer-vacancy-sidebar-all style">
99 101 <div class="performer-vacancy-sidebar-soc style">
100 102 <ul>
101 103 <li>
102   - <?= Html::a(Html::img('/images/ico-fb.png'),[Yii::$app->user->identity->userInfo->social_fb],['target'=>'_blank'])?>
  104 + <?= Html::a(Html::img('/images/ico-fb.png'),[$this->params['user']->userInfo->social_fb],['target'=>'_blank'])?>
103 105 </li>
104 106 <li>
105   - <?= Html::a(Html::img('/images/ico-tw.png'),[Yii::$app->user->identity->userInfo->social_t],['target'=>'_blank'])?>
  107 + <?= Html::a(Html::img('/images/ico-tw.png'),[$this->params['user']->userInfo->social_t],['target'=>'_blank'])?>
106 108 </li>
107 109 <li>
108   - <?= Html::a(Html::img('/images/ico-in.png'),[Yii::$app->user->identity->userInfo->social_in],['target'=>'_blank'])?>
  110 + <?= Html::a(Html::img('/images/ico-in.png'),[$this->params['user']->userInfo->social_in],['target'=>'_blank'])?>
109 111 </li>
110 112 <li>
111   - <?= Html::a(Html::img('/images/ico-vk.png'),[Yii::$app->user->identity->userInfo->social_vk],['target'=>'_blank'])?>
  113 + <?= Html::a(Html::img('/images/ico-vk.png'),[$this->params['user']->userInfo->social_vk],['target'=>'_blank'])?>
112 114 </li>
113 115 </ul>
114 116 </div>
115 117 <div class="performer-vacancy-sidebar-views style">
116 118 <ul class="style">
117   - <li><img src="/images/sidebar-ico/ico-1.png" alt=""/><div class="sidebarvievstxt"><?= Yii::$app->user->identity->userInfo->view_count?> просмотра</div></li>
118   - <li><img src="/images/sidebar-ico/ico-9.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Статус: </span><?= Yii::$app->user->identity->userInfo->busyText?></div></li>
119   - <li><img src="/images/sidebar-ico/ico-2.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">На сайте: </span><?= Yii::$app->user->identity->liveTime?></div></li>
120   - <li><img src="/images/sidebar-ico/ico-3.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Последний визит:<br /></span><?= Yii::$app->user->identity->userInfo->lastVisit?></div></li>
121   - <li><img src="/images/sidebar-ico/ico-10.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Трудовой стаж:<br /></span><?= Yii::$app->user->identity->userInfo->experience?></div></li>
122   - <li><img src="/images/sidebar-ico/ico-11.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Звание в МФП:<br /></span><?= Yii::$app->user->identity->userInfo->rank?></div></li>
123   - <li><img src="/images/sidebar-ico/ico-12.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Стоимость работ:<br /></span><?= Yii::$app->user->identity->userInfo->salary?></div></li>
124   - <li><img src="/images/sidebar-ico/ico-13.png" alt=""/><div class="sidebarvievstxt">Наличный, безналичный расчет, электронные деньги</div></li>
125   - <li><img src="/images/sidebar-ico/ico-14.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Текущее место работы:<br /></span><?= Yii::$app->user->identity->userInfo->job?></div></li>
  119 + <li><img src="/images/sidebar-ico/ico-1.png" alt=""/><div class="sidebarvievstxt"><?= $this->params['user']->userInfo->view_count?> просмотра</div></li>
  120 + <li><img src="/images/sidebar-ico/ico-9.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Статус: </span><?= $this->params['user']->userInfo->busyText?></div></li>
  121 + <li><img src="/images/sidebar-ico/ico-2.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">На сайте: </span><?= $this->params['user']->liveTime?></div></li>
  122 + <li><img src="/images/sidebar-ico/ico-3.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Последний визит:<br /></span><?= $this->params['user']->userInfo->lastVisit?></div></li>
  123 + <li><img src="/images/sidebar-ico/ico-10.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Трудовой стаж:<br /></span><?= $this->params['user']->userInfo->experience?></div></li>
  124 + <li><img src="/images/sidebar-ico/ico-11.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Звание в МФП:<br /></span><?= $this->params['user']->userInfo->rank?></div></li>
  125 + <li><img src="/images/sidebar-ico/ico-12.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Стоимость работ:<br /></span><?= $this->params['user']->userInfo->salary?></div></li>
  126 + <li><img src="/images/sidebar-ico/ico-13.png" alt=""/><div class="sidebarvievstxt"><?= implode(', ',ArrayHelper::getColumn($this->params['user']->payments,'name'))?></div></li>
  127 + <li><img src="/images/sidebar-ico/ico-14.png" alt=""/><div class="sidebarvievstxt"><span class="sidebar-views-txt">Текущее место работы:<br /></span><?= $this->params['user']->userInfo->job?></div></li>
126 128  
127 129 </ul>
128 130 </div>
... ...
frontend/views/performer/blog-list.php
... ... @@ -3,7 +3,7 @@
3 3 use \yii\helpers\Html;
4 4  
5 5 /* @var $this yii\web\View */
6   -
  6 +$this->params['user'] = $user;
7 7 $this->title = 'My Yii Application';
8 8 ?>
9 9 <div class="performer-vacancy-vacant-title-reclam-wr style">
... ...
frontend/views/performer/blog-view.php
... ... @@ -2,6 +2,7 @@
2 2 use \yii\helpers\Html;
3 3  
4 4 /* @var $this yii\web\View */
  5 +$this->params['user'] = $user;
5 6 $this->title = 'My Yii Application';
6 7 ?>
7 8 <div class="performer-vacancy-vacant-title-reclam-wr style">
... ...
frontend/views/performer/common.php
... ... @@ -5,6 +5,7 @@ use \yii\helpers\Html;
5 5 /* @var $this yii\web\View
6 6 * @var $user common\models\User
7 7 */
  8 +$this->params['user'] = $user;
8 9  
9 10 $this->title = 'My Yii Application';
10 11 ?>
... ... @@ -17,8 +18,8 @@ $this-&gt;title = &#39;My Yii Application&#39;;
17 18 <?php foreach( $educations as $education):?>
18 19 <div class="proektant-profile-courses">
19 20 <div class="proektant-profile-courses-title">Образование:</div>
20   - <div class="proektant-profile-courses-year"><?= $education->year_from ?>-<?= $education->year_to ?></div>
21   - <div class="proektant-profile-courses-content"><?= $education->name ?></div>
  21 + <div class="proektant-profile-courses-year"><?= $education['year_from'] ?>-<?= $education['year_to'] ?></div>
  22 + <div class="proektant-profile-courses-content"><?= $education['name'] ?></div>
22 23 </div>
23 24 <?php endforeach; ?>
24 25 </div>
... ... @@ -131,34 +132,40 @@ $this-&gt;title = &#39;My Yii Application&#39;;
131 132 <div class="style">
132 133 <div class="profile-phone-site style">
133 134 <div class="style">
  135 + <?php foreach( $phones as $phone):?>
134 136 <div class="profile-phone">
135 137 <img src="/images/ico-phone.png" alt=""/>
136   - <span>+38 (050) 123-45-67</span>
  138 + <span><?= $phone['phone'] ?></span>
137 139 </div>
  140 + <?php endforeach; ?>
138 141 </div>
139 142 <div class="style">
140   - <div class="profile-site">
141   - <img src="/images/ico-site.png" alt=""/>
142   - <a href="#" target="_blank">Сайт</a>
143   - </div>
  143 + <?php foreach( $sites as $site):?>
  144 + <div class="profile-site">
  145 + <img src="/images/ico-site.png" alt=""/>
  146 + <a href="#" target="_blank">Сайт</a>
  147 + </div>
  148 + <?php endforeach; ?>
144 149 </div>
145 150 </div>
146 151 <div class="profile-features style">
147 152 <ul>
148 153 <li><span>География работ: </span>Киев, Полтава, Харьков, Днепропетровск, Львов</li>
149   - <li><span>Местонахождение: </span>Киев</li>
  154 + <li><span>Местонахождение: </span><?= $user->userInfo->city ?></li>
150 155 <li>
151 156 <div class="features-tags features-tags-profile">
152   - <span><a href="#">Дизайн интерьера</a>, </span><span><a href="#">Архитектурное проектирование</a>, </span><span><a href="#">Ремонт квартир</a>, </span><span><a href="#">Ремонт ванной</a>, </span><span><a href="#">Отделка домов</a>, </span><span><a href="#">Строительство коттеджей</a>, </span><span><a href="#">Дизайн интерьера</a>, </span><span><a href="#">2Архитектурное проектирование</a>, </span><span><a href="#">2Ремонт квартир</a>, </span><span><a href="#">2Ремонт ванной</a>, </span><span><a href="#">2Отделка домов</a>, </span><span><a href="#">2Строительство коттеджей</a>, </span><span><a href="#">2Отделка домов</a>, </span><span><a href="#">2Строительство коттеджей</a>, </span>
  157 + <?php foreach($user->specializations as $specialization):?>
  158 + <span><a href="#"><?= $specialization->specialization_name ?></a>, </span>
  159 + <?php endforeach; ?>
153 160 </div>
154 161 </li>
155   - <li><span>Работа с программами: </span>3DMax, AutoCad, Photoshop, CorelDraw</li>
156   - <li><span>Гарантия: </span>2 года</li>
157   - <li><span>Договор: </span>Да</li>
158   - <li><span>Смета: </span>Да</li>
159   - <li><span>Закупка стройматериалов: </span>Да</li>
160   - <li><span>Доставка стройматериалов: </span>Да</li>
161   - <li><span>Предоплата: </span>15%</li>
  162 + <li><span>Работа с программами: </span><?= $soft ?></li>
  163 + <li><span>Гарантия: </span><?= $user->userInfo->guarantee ?> года</li>
  164 + <li><span>Договор: </span><?= \Yii::$app->formatter->asBoolean($user->userInfo->contract)?></li>
  165 + <li><span>Смета: </span><?= \Yii::$app->formatter->asBoolean($user->userInfo->estimate)?></li>
  166 + <li><span>Закупка стройматериалов: </span><?= \Yii::$app->formatter->asBoolean($user->userInfo->purchase)?></li>
  167 + <li><span>Доставка стройматериалов: </span><?= \Yii::$app->formatter->asBoolean($user->userInfo->delivery)?></li>
  168 + <li><span>Предоплата: </span><?= $user->userInfo->prepayment ?> %</li>
162 169 </ul>
163 170 </div>
164 171 <div class="profile-comments style">
... ...
frontend/views/performer/gallery.php
... ... @@ -3,7 +3,7 @@
3 3 use \yii\helpers\Html;
4 4  
5 5 /* @var $this yii\web\View */
6   -
  6 +$this->params['user'] = $user;
7 7 $this->title = 'My Yii Application';
8 8 ?>
9 9 <div class="video-performer-wrapper style">
... ...
frontend/views/performer/portfolio.php
... ... @@ -3,7 +3,7 @@
3 3 use \yii\helpers\Html;
4 4  
5 5 /* @var $this yii\web\View */
6   -
  6 +$this->params['user'] = $user;
7 7 $this->title = 'My Yii Application';
8 8 ?>
9 9 <div class="performer-vacancy-vacant-title-reclam-wr style">
... ...
frontend/views/performer/review.php
... ... @@ -3,7 +3,7 @@
3 3 use \yii\helpers\Html;
4 4  
5 5 /* @var $this yii\web\View */
6   -
  6 +$this->params['user'] = $user;
7 7 $this->title = 'My Yii Application';
8 8 ?>
9 9 <div class="performer-vacancy-vacant-title-reclam-wr style">
... ...
frontend/views/performer/workplace.php
... ... @@ -3,7 +3,7 @@
3 3 use \yii\helpers\Html;
4 4  
5 5 /* @var $this yii\web\View */
6   -
  6 +$this->params['user'] = $user;
7 7 $this->title = 'My Yii Application';
8 8 ?>
9 9 <div class="performer-vacancy-vacant-title-reclam-wr style">
... ...