Commit 9bb0160de4c9f22b8a0afe64958b30703e5af9e4
1 parent
161155ac
09.02.16
Showing
7 changed files
with
31 additions
and
35 deletions
Show diff stats
common/models/Fields.php
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | namespace common\models; |
4 | 4 | |
5 | 5 | use Yii; |
6 | +use yii\helpers\ArrayHelper; | |
6 | 7 | |
7 | 8 | /** |
8 | 9 | * This is the model class for table "{{%fields}}". |
... | ... | @@ -55,7 +56,11 @@ class Fields extends \yii\db\ActiveRecord |
55 | 56 | } |
56 | 57 | |
57 | 58 | public static function getData($id, $model, $type){ |
58 | - return self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->all(); | |
59 | + $data = ArrayHelper::toArray(self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->all()); | |
60 | + print_r($data); | |
61 | + | |
62 | + die(); | |
63 | + return self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->indexBy('parent_key')->all(); | |
59 | 64 | } |
60 | 65 | |
61 | 66 | ... | ... |
common/widgets/views/courses_field.php
... | ... | @@ -43,7 +43,7 @@ |
43 | 43 | var block_id = $ (this) |
44 | 44 | .parent ('fieldset'); |
45 | 45 | var sub_block = '<div class="form-group" >' + |
46 | - '<input type="text" placeholder="Курсы, тренинги" class="form-control" value="" name="Fields[courses][' + start_i_<?=$this->context->id?>++ + '][0][name]" />' + | |
46 | + '<input type="text" placeholder="Курсы, тренинги" class="form-control" value="" name="Fields[courses][' + start_i_<?=$this->context->id?> + '][0][name]" />' + | |
47 | 47 | '<input type="number" class="form-control" value="" name="Fields[courses][' + start_i_<?=$this->context->id?>++ + '][1][year]" />' + |
48 | 48 | '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' + |
49 | 49 | '<div>'; | ... | ... |
common/widgets/views/development_field.php
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 | var block_id = $ (this) |
43 | 43 | .parent ('fieldset'); |
44 | 44 | var sub_block = '<div class="form-group" >' + |
45 | - '<input type="text" placeholder="Телефон" class="form-control" value="" name="Fields[development][' + start_i_<?=$this->context->id?>++ + '][0][name]" />' + | |
45 | + '<input type="text" placeholder="Телефон" class="form-control" value="" name="Fields[development][' + start_i_<?=$this->context->id?> + '][0][name]" />' + | |
46 | 46 | '<input type="number" class="form-control" value="" name="Fields[development][' + start_i_<?=$this->context->id?>++ + '][1][year]" />' + |
47 | 47 | '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' + |
48 | 48 | '<div>'; | ... | ... |
common/widgets/views/education_field.php
... | ... | @@ -55,9 +55,9 @@ |
55 | 55 | var block_id = $ (this) |
56 | 56 | .parent ('fieldset'); |
57 | 57 | var sub_block = '<div class="form-group" >' + |
58 | - '<input id="edu-name-' + ++start_label_<?=$this->context->id?> +'" type="text" placeholder="" class="form-control custom-input-2" value="" name="Fields[education][' + start_i_<?=$this->context->id?>++ + '][0][name]" />' + | |
58 | + '<input id="edu-name-' + ++start_label_<?=$this->context->id?> +'" type="text" placeholder="" class="form-control custom-input-2" value="" name="Fields[education][' + start_i_<?=$this->context->id?> + '][0][name]" />' + | |
59 | 59 | '<label for="edu-name-' + start_label_<?=$this->context->id?> +'"></label>'+ |
60 | - '<input id="edu-to-' + ++start_label_<?=$this->context->id?> +'" type="number" class="form-control custom-input-2 custom-input-2-date" value="" name="Fields[education][' + start_i_<?=$this->context->id?>++ + '][1][year_from]" />' + | |
60 | + '<input id="edu-to-' + ++start_label_<?=$this->context->id?> +'" type="number" class="form-control custom-input-2 custom-input-2-date" value="" name="Fields[education][' + start_i_<?=$this->context->id?> + '][1][year_from]" />' + | |
61 | 61 | '<label for="edu-to-' + start_label_<?=$this->context->id?> +'"></label>'+ |
62 | 62 | '<input id="edu-out-' + ++start_label_<?=$this->context->id?> +'"" type="number" class="form-control custom-input-2 custom-input-2-date" value="" name="Fields[education][' + start_i_<?=$this->context->id?>++ + '][2][year_to]" />' + |
63 | 63 | '<label for="edu-out-' + start_label_<?=$this->context->id?> +'"></label>'+ | ... | ... |
frontend/config/main.php
frontend/controllers/PerformerController.php
... | ... | @@ -48,24 +48,28 @@ class PerformerController extends Controller |
48 | 48 | ]; |
49 | 49 | } |
50 | 50 | |
51 | - /** | |
52 | - * @var $user common\models\User | |
53 | - */ | |
51 | + | |
54 | 52 | public function actionIndex() |
55 | 53 | { |
56 | - $user = \Yii::$app->user->identity; | |
54 | + $this->redirect('site/index'); | |
57 | 55 | |
58 | - $education = Fields::getData($user->id,$user::className(),'education'); | |
59 | - | |
60 | - return $this->render('common',[ | |
61 | - 'user' => \Yii::$app->user->identity, | |
62 | - '$education' => $education | |
63 | - ]); | |
64 | 56 | } |
65 | 57 | |
66 | - public function actionCommon(/*$performer_id*/) | |
58 | + public function actionCommon($performer_id) | |
67 | 59 | { |
68 | - return $this->render('common'); | |
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 | + | |
66 | + | |
67 | + $educations = Fields::getData($user->id,$user::className(),'education'); | |
68 | + | |
69 | + return $this->render('common',[ | |
70 | + 'user' => $user, | |
71 | + 'educations' => $educations | |
72 | + ]); | |
69 | 73 | } |
70 | 74 | |
71 | 75 | public function actionPortfolio(/*$performer_id*/) | ... | ... |
frontend/views/performer/common.php
... | ... | @@ -14,27 +14,13 @@ $this->title = 'My Yii Application'; |
14 | 14 | </div> |
15 | 15 | <a href="#" class="profile-see-all"></a> |
16 | 16 | <div class="proektant-profile-courses-wr style"> |
17 | + <?php foreach( $educations as $education):?> | |
17 | 18 | <div class="proektant-profile-courses"> |
18 | 19 | <div class="proektant-profile-courses-title">Образование:</div> |
19 | - <div class="proektant-profile-courses-year">1996-2000</div> | |
20 | - <div class="proektant-profile-courses-content">Сочинский государственный университет, специальность "Дизайнер среды".</div> | |
21 | - </div> | |
22 | - | |
23 | - <div class="proektant-profile-courses"> | |
24 | - <div class="proektant-profile-courses-title">Собственные разработки, патенты:</div> | |
25 | - <div class="proektant-profile-courses-year">2006</div> | |
26 | - <div class="proektant-profile-courses-content">Патент "Технология сборки деревянной клеенной стены".</div> | |
27 | - <div class="proektant-profile-courses-year">2014</div> | |
28 | - <div class="proektant-profile-courses-content">Патент "Способ литья центробежным способом".</div> | |
29 | - </div> | |
30 | - | |
31 | - <div class="proektant-profile-courses"> | |
32 | - <div class="proektant-profile-courses-title">Курсы, тренинги:</div> | |
33 | - <div class="proektant-profile-courses-year">2003</div> | |
34 | - <div class="proektant-profile-courses-content">Тренинг "Основы САПР и 2D черчения и проектирования на компьютере".</div> | |
35 | - <div class="proektant-profile-courses-year">2014</div> | |
36 | - <div class="proektant-profile-courses-content">Курс "Архитектурное моделирование".</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> | |
37 | 22 | </div> |
23 | + <?php endforeach; ?> | |
38 | 24 | </div> |
39 | 25 | |
40 | 26 | <div class="proektant-profile-statistic-wr style"> | ... | ... |